X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Fconf.h;h=808e8a122b4771a912c28e5dfcf0320129e0f116;hb=8188ec7d7f7a806adf458a85d6099d0a1d3273ec;hp=774ea1fd838885c83328d0b6e045059902aa2421;hpb=85aa55b239c5e3bfcb45fdf9e143ac080a278caa;p=libucw.git diff --git a/lib/conf.h b/lib/conf.h index 774ea1fd..808e8a12 100644 --- a/lib/conf.h +++ b/lib/conf.h @@ -1,8 +1,8 @@ /* - * Sherlock Library -- Reading of configuration files + * UCW Library -- Reading of configuration files * * (c) 2001 Robert Spalek - * (c) 2003 Martin Mares + * (c) 2003--2005 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -19,7 +19,9 @@ extern struct mempool *cfpool; void *cfg_malloc(uns size); -byte *cfg_stralloc(byte *s); +void *cfg_malloc_zero(uns size); +byte *cfg_strdup(byte *s); +byte *cfg_printf(char *fmt, ...) FORMAT_CHECK(printf,1,2); /* * Every module places its configuration setting into some section. Section is @@ -34,7 +36,7 @@ byte *cfg_stralloc(byte *s); * function. */ -enum cftype { CT_STOP, CT_SECTION, CT_INCOMPLETE_SECTION, CT_INT, CT_STRING, CT_FUNCTION, CT_DOUBLE }; +enum cftype { CT_STOP, CT_SECTION, CT_INCOMPLETE_SECTION, CT_INT, CT_STRING, CT_FUNCTION, CT_DOUBLE, CT_U64 }; struct cfitem { byte *name; @@ -59,9 +61,18 @@ void cf_read(byte *filename); * Number parsing functions which could be useful in CT_FUNCTION callbacks. */ +#if 0 byte *cf_parse_int(byte *value, uns *varp); +byte *cf_parse_u64(byte *value, u64 *varp); byte *cf_parse_double(byte *value, double *varp); +/* + * Some useful parsing functions. + */ + +byte *cf_parse_ip(byte **value, u32 *varp); +#endif + /* * When using cf_getopt, you must prefix your own short/long options by the * CF_(SHORT|LONG)_OPTS. @@ -79,9 +90,10 @@ byte *cf_parse_double(byte *value, double *varp); {"set", 1, 0, 'S'},\ {"config", 1, 0, 'C'}, #define CF_NO_LONG_OPTS (const struct option []){ CF_LONG_OPTS { NULL, 0, 0, 0 } } +#define CF_USAGE_TAB "" #define CF_USAGE \ -"-S, --set sec.item=val\tManual setting of a configuration item\n\ --C, --config filename\tOverwrite default config filename\n" +"-S, --set sec.item=val\t" CF_USAGE_TAB "Manual setting of a configuration item\n\ +-C, --config filename\t" CF_USAGE_TAB "Overwrite default config filename\n" extern byte *cfdeffile;