]>
Commit | Line | Data |
---|---|---|
212380e3 | 1 | /* This code is in the public domain. |
212380e3 AC |
2 | */ |
3 | ||
4 | #ifndef _NEWCONF_H_INCLUDED | |
5 | #define _NEWCONF_H_INCLUDED | |
6 | ||
212380e3 AC |
7 | struct ConfEntry |
8 | { | |
9 | const char *cf_name; | |
10 | int cf_type; | |
11 | void (*cf_func) (void *); | |
12 | int cf_len; | |
13 | void *cf_arg; | |
14 | }; | |
15 | ||
16 | struct TopConf | |
17 | { | |
d7f753cd | 18 | const char *tc_name; |
212380e3 AC |
19 | int (*tc_sfunc) (struct TopConf *); |
20 | int (*tc_efunc) (struct TopConf *); | |
5b96d9a6 | 21 | rb_dlink_list tc_items; |
212380e3 AC |
22 | struct ConfEntry *tc_entries; |
23 | }; | |
24 | ||
25 | ||
dceac3e4 | 26 | #define CF_QSTRING 0x01 /* quoted string */ |
212380e3 | 27 | #define CF_INT 0x02 |
dceac3e4 | 28 | #define CF_STRING 0x03 /* unquoted string */ |
212380e3 AC |
29 | #define CF_TIME 0x04 |
30 | #define CF_YESNO 0x05 | |
212380e3 | 31 | |
dceac3e4 | 32 | #define CF_MTYPE 0xFF /* mask for type */ |
212380e3 | 33 | |
dceac3e4 KB |
34 | /* CF_FLIST is used to allow specifying that an option accepts a list of (type) |
35 | * values. conf_parm_t.type will never actually have another type & CF_FLIST; | |
36 | * it's only used as a true flag in newconf.c (which only consumes conf_parm_t | |
37 | * structures and doesn't create them itself). | |
38 | */ | |
39 | #define CF_FLIST 0x0100 /* flag for list */ | |
40 | #define CF_MFLAG 0xFF00 /* mask for flags */ | |
212380e3 | 41 | |
dceac3e4 KB |
42 | /* conf_parm_t.type must be either one type OR one flag. this is pretty easy to |
43 | * enforce because lists always contain nested conf_parm_t structures whose | |
44 | * .type is the real type, so it doesn't need to be stored in the top-level one | |
45 | * anyway. | |
46 | */ | |
212380e3 AC |
47 | typedef struct conf_parm_t_stru |
48 | { | |
49 | struct conf_parm_t_stru *next; | |
50 | int type; | |
51 | union | |
52 | { | |
53 | char *string; | |
54 | int number; | |
55 | struct conf_parm_t_stru *list; | |
56 | } | |
57 | v; | |
58 | } | |
59 | conf_parm_t; | |
60 | ||
61 | extern struct TopConf *conf_cur_block; | |
62 | ||
63 | extern char *current_file; | |
64 | ||
65 | int read_config(char *); | |
66 | int conf_start_block(char *, char *); | |
67 | int conf_end_block(struct TopConf *); | |
dceac3e4 | 68 | int conf_call_set(struct TopConf *, char *, conf_parm_t *); |
212380e3 | 69 | void conf_report_error(const char *, ...); |
d84acbce | 70 | void conf_report_warning(const char *, ...); |
212380e3 AC |
71 | void newconf_init(void); |
72 | int add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *)); | |
73 | int remove_conf_item(const char *topconf, const char *name); | |
74 | int add_top_conf(const char *name, int (*sfunc) (struct TopConf *), int (*efunc) (struct TopConf *), struct ConfEntry *items); | |
75 | int remove_top_conf(char *name); | |
76 | struct TopConf *find_top_conf(const char *name); | |
77 | struct ConfEntry *find_conf_item(const struct TopConf *top, const char *name); | |
78 | ||
79 | #endif |