1 /* config file parser functions
3 * (C) 2000 by Harald Welte <laforge@gnumonks.org>
5 * $Id: conffile.h 4946 2003-09-28 15:19:25Z laforge $
7 * This code is distributed under the terms of GNU GPL */
12 #include <sys/types.h>
14 /* errors returned by config functions */
17 ERROPEN, /* unable to open config file */
18 ERROOM, /* out of memory */
19 ERRMULT, /* non-multiple option occured more than once */
20 ERRMAND, /* mandatory option not found */
21 ERRUNKN, /* unknown config key */
22 ERRSECTION, /* section not found */
25 /* maximum line lenght of config file entries */
28 /* maximum lenght of config key name */
29 #define CONFIG_KEY_LEN 30
31 /* maximum lenght of string config value */
32 #define CONFIG_VAL_STRING_LEN 225
34 /* valid config types */
35 #define CONFIG_TYPE_INT 0x0001
36 #define CONFIG_TYPE_STRING 0x0002
37 #define CONFIG_TYPE_CALLBACK 0x0003
39 /* valid config options */
40 #define CONFIG_OPT_NONE 0x0000
41 #define CONFIG_OPT_MANDATORY 0x0001
42 #define CONFIG_OPT_MULTI 0x0002
44 typedef struct config_entry {
45 struct config_entry *next; /* the next one in linked list */
46 char key[CONFIG_KEY_LEN]; /* name of config directive */
47 u_int8_t type; /* type; see above */
48 u_int8_t options; /* options; see above */
49 u_int8_t hit; /* found? */
51 char string[CONFIG_VAL_STRING_LEN];
53 int (*parser)(char *argstr);
57 /* if an error occurs, config_errce is set to the erroneous ce */
58 extern config_entry_t *config_errce;
60 /* tell us the name of the config file */
61 int config_register_file(const char *file);
63 /* parse the config file */
64 int config_parse_file(const char *section, config_entry_t *keys);
66 #endif /* ifndef _CONFFILE_H */