added CONF_PARSER data structure, so that the user can pass
[freeradius.git] / src / include / conffile.h
1 #ifndef _CONFFILE_H
2 #define _CONFFILE_H
3
4 /*
5  * conffile.h   Defines for the conffile parsing routines.
6  *
7  * Version:     $Id$
8  *
9  */
10
11 #include "token.h"
12
13 typedef struct conf_pair {
14         char                    *attr;
15         char                    *value;
16         int                     operator;
17         struct conf_pair        *next;
18 } CONF_PAIR;
19
20 typedef struct conf_part {
21         char                    *name1;
22         char                    *name2;
23         CONF_PAIR               *cps;
24         struct conf_part        *sub;
25         struct conf_part        *next;
26 } CONF_SECTION;
27
28 /*
29  *  Instead of putting the information into a configuration structure,
30  *  the configuration file routines MAY just parse it directly into
31  *  user-supplied variables.
32  */
33 #define PW_TYPE_STRING_PTR      100
34
35 typedef struct CONF_PARSER {
36   const char *name;
37   int type;                     /* PW_TYPE_STRING, etc. */
38   void *data;                   /* pointer to where to put it */
39 } CONF_PARSER;
40
41 CONF_SECTION    *conf_read(const char *conffile, const CONF_PARSER vars[]);
42 CONF_PAIR       *cf_pair_alloc(const char *attr, const char *value, int operator);
43 void            cf_pair_add(CONF_SECTION *cs, CONF_PAIR *cp_new);
44 void            cf_pair_free(CONF_PAIR *cp);
45 CONF_SECTION    *cf_section_alloc(const char *name1, const char *name2);
46 void            cf_section_free(CONF_SECTION *cp);
47 void            cf_section_free_all(CONF_SECTION *cp);
48
49 /* JLN -- Newly added */
50                 
51 CONF_PAIR       *cf_pair_find(CONF_SECTION *section, const char *name);
52 CONF_PAIR       *cf_pair_find_next(CONF_SECTION *section, CONF_PAIR *pair, const char *name);
53 CONF_SECTION    *cf_section_find(const char *name);
54 CONF_SECTION    *cf_section_sub_find(CONF_SECTION *section, const char *name);
55 CONF_SECTION    *cf_module_config_find(const char *modulename);
56 char            *cf_section_value_find(CONF_SECTION *section, const char *attr);
57
58 #endif /* _CONFFILE_H */