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