added line numbers to configuration sections and value-pairs.
[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         int                     lineno;
18         struct conf_pair        *next;
19 } CONF_PAIR;
20
21 typedef struct conf_part {
22         char                    *name1;
23         char                    *name2;
24         int                     lineno;
25         CONF_PAIR               *cps;
26         struct conf_part        *sub;
27         struct conf_part        *next;
28 } CONF_SECTION;
29
30 /*
31  *  Instead of putting the information into a configuration structure,
32  *  the configuration file routines MAY just parse it directly into
33  *  user-supplied variables.
34  */
35 #define PW_TYPE_STRING_PTR      100
36 #define PW_TYPE_BOOLEAN         101
37
38 typedef struct CONF_PARSER {
39   const char *name;
40   int type;                     /* PW_TYPE_STRING, etc. */
41   void *data;                   /* pointer to where to put it */
42 } CONF_PARSER;
43
44 CONF_SECTION    *conf_read(const char *conffile);
45 CONF_PAIR       *cf_pair_alloc(const char *attr, const char *value, int operator);
46 void            cf_pair_add(CONF_SECTION *cs, CONF_PAIR *cp_new);
47 void            cf_pair_free(CONF_PAIR *cp);
48 CONF_SECTION    *cf_section_alloc(const char *name1, const char *name2);
49 void            cf_section_free(CONF_SECTION *cp);
50 void            cf_section_free_all(CONF_SECTION *cp);
51 int             cf_section_parse(CONF_SECTION *cs, const CONF_PARSER *variables);
52
53 /* JLN -- Newly added */
54                 
55 CONF_PAIR       *cf_pair_find(CONF_SECTION *section, const char *name);
56 CONF_PAIR       *cf_pair_find_next(CONF_SECTION *section, CONF_PAIR *pair, const char *name);
57 CONF_SECTION    *cf_section_find(const char *name);
58 CONF_SECTION    *cf_section_sub_find(CONF_SECTION *section, const char *name);
59 CONF_SECTION    *cf_module_config_find(const char *modulename);
60 char            *cf_section_value_find(CONF_SECTION *section, const char *attr);
61
62 int             read_radius_conf_file(void);
63
64 char *cf_pair_value(CONF_PAIR *pair);
65 int dump_config(void);
66 CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
67                                       CONF_SECTION *subsection,
68                                       const char *name1);
69 #endif /* _CONFFILE_H */