}
static struct cf_section cf_sec_1 = {
- CF_TYPE(struct sub_sect_1)
- CF_INIT(init_sec_1)
- CF_COMMIT(commit_sec_1)
+ CF_TYPE(struct sub_sect_1),
+ CF_INIT(init_sec_1),
+ CF_COMMIT(commit_sec_1),
#define F(x) PTR_TO(struct sub_sect_1, x)
- CF_START_ITEMS
- CF_STRING("name", F(name))
- CF_STRING("level", F(level))
- CF_INT_ARY("confidence", F(confidence[0]), 2) // XXX: the [0] is needed for the sake of macros :-(
- CF_DOUBLE_DYN("list", F(list), 100)
- CF_END_ITEMS
+ CF_ITEMS {
+ CF_STRING("name", F(name)),
+ CF_STRING("level", F(level)),
+ CF_INT_ARY("confidence", F(confidence[0]), 2), // XXX: the [0] is needed for the sake of type checking
+ CF_DOUBLE_DYN("list", F(list), 100),
+ CF_END
+ }
#undef F
};
}
static struct cf_section cf_top UNUSED = {
- CF_COMMIT(commit_top)
- CF_START_ITEMS
- CF_INT("nr1", &nr1)
- CF_INT_DYN("nrs1", &nrs1, 1000)
- CF_INT_ARY("nrs2", nrs2, 5)
- CF_STRING("str1", &str1)
- CF_STRING_DYN("str2", &str2, 2)
- CF_U64("u1", &u1)
- CF_DOUBLE("d1", &d1)
- CF_PARSER("FirstTime", &t1, time_parser, -1)
- CF_PARSER("SecondTime", &t2, time_parser, 1)
- CF_SECTION("master", &sec1, &cf_sec_1)
- CF_LIST("slaves", &secs, &cf_sec_1)
- CF_END_ITEMS
+ CF_COMMIT(commit_top),
+ CF_ITEMS {
+ CF_INT("nr1", &nr1),
+ CF_INT_DYN("nrs1", &nrs1, 1000),
+ CF_INT_ARY("nrs2", nrs2, 5),
+ CF_STRING("str1", &str1),
+ CF_STRING_DYN("str2", &str2, 2),
+ CF_U64("u1", &u1),
+ CF_DOUBLE("d1", &d1),
+ CF_PARSER("FirstTime", &t1, time_parser, -1),
+ CF_PARSER("SecondTime", &t2, time_parser, 1),
+ CF_SECTION("master", &sec1, &cf_sec_1),
+ CF_LIST("slaves", &secs, &cf_sec_1),
+ CF_END
+ }
};
int
uns size; // 0 for a global block, sizeof(struct) for a section
cf_hook *init; // fills in default values (otherwise 0's are used)
cf_hook *commit; // verifies parsed data (optional)
- struct cf_item *cfg; // CT_END-terminated array of items
+ struct cf_item *cfg; // CC_END-terminated array of items
};
/* Declaration of cf_section */
-#define CF_TYPE(s) .size = sizeof(s),
-#define CF_INIT(f) .init = (cf_hook*) f,
-#define CF_COMMIT(f) .commit = (cf_hook*) f,
-#define CF_START_ITEMS .cfg = ( struct cf_item[] ) {
-#define CF_END_ITEMS { .cls = CC_END } },
+#define CF_TYPE(s) .size = sizeof(s)
+#define CF_INIT(f) .init = (cf_hook*) f
+#define CF_COMMIT(f) .commit = (cf_hook*) f
+#define CF_ITEMS .cfg = ( struct cf_item[] )
+#define CF_END { .cls = CC_END }
/* Configuration items */
struct clist;
-#define CF_STATIC(n,p,T,t,c) { .cls = CC_STATIC, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,t*), .u.type = CT_##T },
-#define CF_DYNAMIC(n,p,T,t,c) { .cls = CC_DYNAMIC, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,t**), .u.type = CT_##T },
-#define CF_PARSER(n,p,f,c) { .cls = CC_PARSER, .name = n, .number = c, .ptr = p, .u.par = (cf_parser*) f },
-#define CF_SECTION(n,p,s) { .cls = CC_SECTION, .name = n, .number = 1, .ptr = p, .u.sub = s },
-#define CF_LIST(n,p,s) { .cls = CC_LIST, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,struct clist*), .u.sub = s },
+#define CF_STATIC(n,p,T,t,c) { .cls = CC_STATIC, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,t*), .u.type = CT_##T }
+#define CF_DYNAMIC(n,p,T,t,c) { .cls = CC_DYNAMIC, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,t**), .u.type = CT_##T }
+#define CF_PARSER(n,p,f,c) { .cls = CC_PARSER, .name = n, .number = c, .ptr = p, .u.par = (cf_parser*) f }
+#define CF_SECTION(n,p,s) { .cls = CC_SECTION, .name = n, .number = 1, .ptr = p, .u.sub = s }
+#define CF_LIST(n,p,s) { .cls = CC_LIST, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,struct clist*), .u.sub = s }
/* Configuration items for basic types */
#define CF_INT(n,p) CF_STATIC(n,p,INT,int,1)
#define CF_INT_ARY(n,p,c) CF_STATIC(n,p,INT,int,c)