]>
Commit | Line | Data |
---|---|---|
1 | /* This code is in the public domain. | |
2 | */ | |
3 | ||
4 | #ifndef _NEWCONF_H_INCLUDED | |
5 | #define _NEWCONF_H_INCLUDED | |
6 | ||
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 | { | |
18 | const char *tc_name; | |
19 | int (*tc_sfunc) (struct TopConf *); | |
20 | int (*tc_efunc) (struct TopConf *); | |
21 | rb_dlink_list tc_items; | |
22 | struct ConfEntry *tc_entries; | |
23 | }; | |
24 | ||
25 | ||
26 | #define CF_QSTRING 0x01 /* quoted string */ | |
27 | #define CF_INT 0x02 | |
28 | #define CF_STRING 0x03 /* unquoted string */ | |
29 | #define CF_TIME 0x04 | |
30 | #define CF_YESNO 0x05 | |
31 | ||
32 | #define CF_MTYPE 0xFF /* mask for type */ | |
33 | ||
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 */ | |
41 | ||
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 | */ | |
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 *); | |
68 | int conf_call_set(struct TopConf *, char *, conf_parm_t *); | |
69 | void conf_report_error(const char *, ...); | |
70 | void conf_report_warning(const char *, ...); | |
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 |