CC_DYNAMIC, // dynamically allocated array
CC_PARSER, // arbitrary parser function
CC_SECTION, // section appears exactly once
CC_DYNAMIC, // dynamically allocated array
CC_PARSER, // arbitrary parser function
CC_SECTION, // section appears exactly once
/* A parser function gets an array of (strdup'ed) strings and a pointer with
* the customized information (most likely the target address). It can store
* the parsed value anywhere in any way it likes, however it must first call
* cf_journal_block() on the overwritten memory block. It returns an error
* message or NULL if everything is all right. */
/* A parser function gets an array of (strdup'ed) strings and a pointer with
* the customized information (most likely the target address). It can store
* the parsed value anywhere in any way it likes, however it must first call
* cf_journal_block() on the overwritten memory block. It returns an error
* message or NULL if everything is all right. */
/* A parser function for user-defined types gets a string and a pointer to
* the destination variable. It must store the value within [ptr,ptr+size),
* where size is fixed for each type. It should not call cf_journal_block(). */
/* A parser function for user-defined types gets a string and a pointer to
* the destination variable. It must store the value within [ptr,ptr+size),
* where size is fixed for each type. It should not call cf_journal_block(). */
/* Similar to init-hook, but it copies attributes from another list node
* instead of setting the attributes to default values. You have to provide
* it if your node contains parsed values and/or sub-lists. */
struct cf_user_type {
uns size; // of the parsed attribute
/* Similar to init-hook, but it copies attributes from another list node
* instead of setting the attributes to default values. You have to provide
* it if your node contains parsed values and/or sub-lists. */
struct cf_user_type {
uns size; // of the parsed attribute
int number; // length of an array or #parameters of a parser (negative means at most)
void *ptr; // pointer to a global variable or an offset in a section
union cf_union {
struct cf_section *sec; // declaration of a section or a list
cf_parser *par; // parser function
int number; // length of an array or #parameters of a parser (negative means at most)
void *ptr; // pointer to a global variable or an offset in a section
union cf_union {
struct cf_section *sec; // declaration of a section or a list
cf_parser *par; // parser function
#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_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)
/* 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_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_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,byte*,1)
-#define CF_STRING_ARY(n,p,c) CF_STATIC(n,p,STRING,byte*,c)
-#define CF_STRING_DYN(n,p,c) CF_DYNAMIC(n,p,STRING,byte*,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 }
#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 }
-void cf_declare_section(byte *name, struct cf_section *sec, uns allow_unknown);
-void cf_init_section(byte *name, struct cf_section *sec, void *ptr, uns do_bzero);
+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);
-byte *cf_parse_int(byte *str, int *ptr);
-byte *cf_parse_u64(byte *str, u64 *ptr);
-byte *cf_parse_double(byte *str, double *ptr);
-byte *cf_parse_ip(byte *p, u32 *varp);
+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);