Importing all of DRL, including ulogd and all of its files.
[distributedratelimiting.git] / include / ulogd / conffile.h
1 /* config file parser functions
2  *
3  * (C) 2000 by Harald Welte <laforge@gnumonks.org>
4  *
5  * $Id: conffile.h 4946 2003-09-28 15:19:25Z laforge $
6  * 
7  * This code is distributed under the terms of GNU GPL */
8
9 #ifndef _CONFFILE_H
10 #define _CONFFILE_H
11
12 #include <sys/types.h>
13
14 /* errors returned by config functions */
15 enum {
16         ERRNONE = 0,
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 */
23 };
24
25 /* maximum line lenght of config file entries */
26 #define LINE_LEN                255
27
28 /* maximum lenght of config key name */
29 #define CONFIG_KEY_LEN          30
30
31 /* maximum lenght of string config value */
32 #define CONFIG_VAL_STRING_LEN   225
33
34 /* valid config types */
35 #define CONFIG_TYPE_INT         0x0001
36 #define CONFIG_TYPE_STRING      0x0002
37 #define CONFIG_TYPE_CALLBACK    0x0003
38
39 /* valid config options */
40 #define CONFIG_OPT_NONE         0x0000
41 #define CONFIG_OPT_MANDATORY    0x0001
42 #define CONFIG_OPT_MULTI        0x0002
43
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? */
50         union {
51                 char string[CONFIG_VAL_STRING_LEN];
52                 int value;
53                 int (*parser)(char *argstr);
54         } u;
55 } config_entry_t;
56
57 /* if an error occurs, config_errce is set to the erroneous ce */
58 extern config_entry_t *config_errce;
59
60 /* tell us the name of the config file */
61 int config_register_file(const char *file);
62
63 /* parse the config file */
64 int config_parse_file(const char *section, config_entry_t *keys);
65
66 #endif /* ifndef _CONFFILE_H */