diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-20 23:22:44 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-21 02:55:06 -0700 |
commit | 22b6c53fd314a328631f492e371ade1374b439c7 (patch) | |
tree | ce70b1a82565abf9ce8f999bca33ca648d59ec5d /lib9p/tests | |
parent | 0febcde46a85855a3f3ec1bf872a2259b207efce (diff) |
lib9p: test_server: Tidy the static file macros
Diffstat (limited to 'lib9p/tests')
-rw-r--r-- | lib9p/tests/test_server/main.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index 10f67a3..2c64cd4 100644 --- a/lib9p/tests/test_server/main.c +++ b/lib9p/tests/test_server/main.c @@ -127,45 +127,40 @@ static uint32_t api_pread(struct api_file *, struct lib9p_srv_ctx *, void *, uin enum { PATH_BASE = __COUNTER__ }; #define PATH_COUNTER __COUNTER__ - PATH_BASE -#define STATIC_FILE(STRNAME, SYMNAME) \ +#define STATIC_COMMON(STRNAME, MODE) \ + { \ + .u_name = "root", .u_num = 0, /* owner user */ \ + .g_name = "root", .g_num = 0, /* owner group */ \ + .m_name = "root", .m_num = 0, /* last-modified-by user */ \ + \ + .pathnum = PATH_COUNTER, \ + .name = STRNAME, \ + .perm = MODE, \ + .atime = 1728337905, \ + .mtime = 1728337904, \ + } + +#define STATIC_FILE(STRNAME, SYMNAME) \ lo_box_util9p_static_file_as_lib9p_srv_file(&((struct util9p_static_file){ \ - ._util9p_static_common = { \ - .u_name = "root", .u_num = 0, /* owner user */ \ - .g_name = "root", .g_num = 0, /* owner group */ \ - .m_name = "root", .m_num = 0, /* last-modified-by user */ \ - \ - .pathnum = PATH_COUNTER, \ - .name = STRNAME, \ - .perm = 0444, \ - .atime = 1728337905, \ - .mtime = 1728337904, \ - }, \ - .data_start = _binary_static_##SYMNAME##_start, \ - .data_end = _binary_static_##SYMNAME##_end, \ + ._util9p_static_common = STATIC_COMMON(STRNAME, 0444), \ + .data_start = _binary_static_##SYMNAME##_start, \ + .data_end = _binary_static_##SYMNAME##_end, \ })) #define STATIC_DIR(STRNAME, ...) \ lo_box_util9p_static_dir_as_lib9p_srv_file(&((struct util9p_static_dir){ \ - ._util9p_static_common = { \ - .u_name = "root", .u_num = 0, /* owner user */ \ - .g_name = "root", .g_num = 0, /* owner group */ \ - .m_name = "root", .m_num = 0, /* last-modified-by user */ \ - \ - .pathnum = PATH_COUNTER, \ - .name = STRNAME, \ - .perm = 0555, \ - .atime = 1728337905, \ - .mtime = 1728337904, \ - }, \ - .members = { __VA_ARGS__ __VA_OPT__(,) LO_NULL(lib9p_srv_file) }, \ + ._util9p_static_common = STATIC_COMMON(STRNAME, 0555), \ + .members = { __VA_ARGS__ LO_NULL(lib9p_srv_file) }, \ })) struct lib9p_srv_file root = STATIC_DIR("", STATIC_DIR("Documentation", - STATIC_FILE("x", Documentation_x)), + STATIC_FILE("x", Documentation_x), + ), STATIC_FILE("README.md", README_md), - lo_box_api_as_lib9p_srv_file(&(struct api_file){.pathnum = PATH_COUNTER})); + lo_box_api_as_lib9p_srv_file(&(struct api_file){.pathnum = PATH_COUNTER}), + ); static lo_interface lib9p_srv_file get_root(struct lib9p_srv_ctx *LM_UNUSED(ctx), struct lib9p_s LM_UNUSED(treename)) { return root; |