#ifndef CONFIG_H #define CONFIG_H #define TYPE_INT 1 #define TYPE_STR 2 #define TYPE_BOOL 3 #define TYPE_FLOAT 4 #define TYPE_DOUBLE 5 #define TYPE_MASK 0x0F /* bit mask for types */ #define TYPE_NOTNULL 0x10 #define TYPE_NULL 0x20 #define TYPE_MULTI 0x40 /* Is an array of values */ #ifdef __cplusplus extern "C" { #endif typedef struct array_t { int items; union { void *s; int i; float f; double d; } *data; } conf_array_t; typedef struct { char *key; int type; void *value; } config_t; int daemonised; int parse_config(config_t *config,char *filename); /* Example: * * #include * #include "config.h" * * int foo; * * struct config_t config[] = { * { "foo", TYPE_INT|TYPE_NOTNULL, &foo } * }; * * int main(int argc,char **argv) * { * if(!parse_config(config,"/usr/local/etc/wand.conf")) { * return 1; * } * * printf("foo=%i",foo); * return 0; * } */ void logger(int level, char *format, ...); #ifdef __cplusplus } #endif #endif