+/* 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_COPY(f) .copy = (cf_copier*) f
+#define CF_ITEMS .cfg = ( struct cf_item[] )
+#define CF_END { .cls = CC_END }
+/* Configuration items */
+#define CF_STATIC(n,p,T,t,c) { .cls = CC_STATIC, .type = CT_##T, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,t*) }
+#define CF_DYNAMIC(n,p,T,t,c) { .cls = CC_DYNAMIC, .type = CT_##T, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,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.sec = s }
+#define CF_LIST(n,p,s) { .cls = CC_LIST, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,clist*), .u.sec = s }
+#define CF_BITMAP_INT(n,p) { .cls = CC_BITMAP, .type = CT_INT, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,u32*) }
+#define CF_BITMAP_LOOKUP(n,p,t) { .cls = CC_BITMAP, .type = CT_LOOKUP, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,u32*), .u.lookup = t }
+/* 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)
+#define CF_INT_DYN(n,p,c) CF_DYNAMIC(n,p,INT,int,c)
+#define CF_UNS(n,p) CF_STATIC(n,p,INT,uns,1)
+#define CF_UNS_ARY(n,p,c) CF_STATIC(n,p,INT,uns,c)
+#define CF_UNS_DYN(n,p,c) CF_DYNAMIC(n,p,INT,uns,c)
+#define CF_U64(n,p) CF_STATIC(n,p,U64,u64,1)
+#define CF_U64_ARY(n,p,c) CF_STATIC(n,p,U64,u64,c)
+#define CF_U64_DYN(n,p,c) CF_DYNAMIC(n,p,U64,u64,c)
+#define CF_DOUBLE(n,p) CF_STATIC(n,p,DOUBLE,double,1)
+#define CF_DOUBLE_ARY(n,p,c) CF_STATIC(n,p,DOUBLE,double,c)
+#define CF_DOUBLE_DYN(n,p,c) CF_DYNAMIC(n,p,DOUBLE,double,c)
+#define CF_IP(n,p) CF_STATIC(n,p,IP,u32,1)
+#define CF_IP_ARY(n,p,c) CF_STATIC(n,p,IP,u32,c)
+#define CF_IP_DYN(n,p,c) CF_DYNAMIC(n,p,IP,u32,c)
+#define CF_STRING(n,p) CF_STATIC(n,p,STRING,char*,1)
+#define CF_STRING_ARY(n,p,c) CF_STATIC(n,p,STRING,char*,c)
+#define CF_STRING_DYN(n,p,c) CF_DYNAMIC(n,p,STRING,char*,c)
+#define CF_LOOKUP(n,p,t) { .cls = CC_STATIC, .type = CT_LOOKUP, .name = n, .number = 1, .ptr = CHECK_PTR_TYPE(p,int*), .u.lookup = t }
+#define CF_LOOKUP_ARY(n,p,t,c) { .cls = CC_STATIC, .type = CT_LOOKUP, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,int*), .u.lookup = t }
+#define CF_LOOKUP_DYN(n,p,t,c) { .cls = CC_DYNAMIC, .type = CT_LOOKUP, .name = n, .number = c, .ptr = CHECK_PTR_TYPE(p,int**), .u.lookup = t }
+#define CF_USER(n,p,t) { .cls = CC_STATIC, .type = CT_USER, .name = n, .number = 1, .ptr = p, .u.utype = t }
+#define CF_USER_ARY(n,p,t,c) { .cls = CC_STATIC, .type = CT_USER, .name = n, .number = c, .ptr = p, .u.utype = t }
+#define CF_USER_DYN(n,p,t,c) { .cls = CC_DYNAMIC, .type = CT_USER, .name = n, .number = c, .ptr = p, .u.utype = t }
+
+/* If you aren't picky about the number of parameters */
+#define CF_ANY_NUM -0x7fffffff
+
+#define DARY_LEN(a) ((uns*)a)[-1]
+ // length of a dynamic array
+#define DARY_ALLOC(type,len,val...) ((struct { uns l; type a[len]; }) { .l = len, .a = { val } }).a
+ // creates a static instance of a dynamic array
+
+/* Memory allocation: conf-alloc.c */
+struct mempool;
+extern struct mempool *cf_pool;
+void *cf_malloc(uns size);
+void *cf_malloc_zero(uns size);
+char *cf_strdup(const char *s);
+char *cf_printf(const char *fmt, ...) FORMAT_CHECK(printf,1,2);
+
+/* Undo journal for error recovery: conf-journal.c */
+extern uns cf_need_journal;
+void cf_journal_block(void *ptr, uns len);
+#define CF_JOURNAL_VAR(var) cf_journal_block(&(var), sizeof(var))
+
+/* Declaration: conf-section.c */
+void cf_declare_section(const char *name, struct cf_section *sec, uns allow_unknown);
+void cf_init_section(const char *name, struct cf_section *sec, void *ptr, uns do_bzero);
+
+/* Parsers for basic types: conf-parse.c */
+char *cf_parse_int(const char *str, int *ptr);
+char *cf_parse_u64(const char *str, u64 *ptr);
+char *cf_parse_double(const char *str, double *ptr);
+char *cf_parse_ip(const char *p, u32 *varp);