2 * Sherlock Library -- Reading configuration files
4 * (c) 2001 Robert Spalek <robert@ucw.cz>
10 * Allocation in configuration memory pool.
13 void *cfg_malloc(uns size);
14 byte *cfg_stralloc(byte *s);
17 * Every module places its configuration setting into some section. Section is
18 * an array of cfitem, whose first record is of type CT_SECTION and contains
19 * the name of the section. The configuration sections are registered by
20 * calling cf_register().
22 * item->var is a pointer to the destination variable or to the special parsing
26 enum cftype { CT_STOP, CT_SECTION, CT_INT, CT_STRING, CT_FUNCTION };
34 typedef byte *(*ci_func)(struct cfitem *, byte *);
36 void cf_register(struct cfitem *items);
39 * Direct setting of configuration items and parsing the configuration file.
42 int cf_item_count(void);
43 struct cfitem *cf_get_item(byte *sect, byte *name);
44 byte *cf_set_item(byte *sect, byte *name, byte *value);
45 void cf_read(byte *filename);
48 * When using cf_getopt, you must prefix your own short/long options by the
49 * CF_(SHORT|LONG)_OPTS.
52 #define CF_SHORT_OPTS "S:C:"
53 #define CF_LONG_OPTS \
55 {"config", 1, 0, 'C'},
56 #define CF_NO_LONG_OPTS (const struct option []){ CF_LONG_OPTS { NULL, 0, 0, 0 } }
58 int cf_getopt(int argc,char * const argv[],
59 const char *shortopts,const struct option *longopts,