]> jfr.im git - solanum.git/blame - include/newconf.h
Merge pull request #346 from edk0/opmod-as-statusmsg
[solanum.git] / include / newconf.h
CommitLineData
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
7struct 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
16struct 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
47typedef 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}
59conf_parm_t;
60
61extern struct TopConf *conf_cur_block;
62
63extern char *current_file;
64
65int read_config(char *);
66int conf_start_block(char *, char *);
67int conf_end_block(struct TopConf *);
dceac3e4 68int conf_call_set(struct TopConf *, char *, conf_parm_t *);
212380e3 69void conf_report_error(const char *, ...);
d84acbce 70void conf_report_warning(const char *, ...);
212380e3
AC
71void newconf_init(void);
72int add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *));
73int remove_conf_item(const char *topconf, const char *name);
74int add_top_conf(const char *name, int (*sfunc) (struct TopConf *), int (*efunc) (struct TopConf *), struct ConfEntry *items);
75int remove_top_conf(char *name);
76struct TopConf *find_top_conf(const char *name);
77struct ConfEntry *find_conf_item(const struct TopConf *top, const char *name);
78
79#endif