30ed6fe328aa723120a81d2615e8ef1cda65b057
[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 /*
14  * Export the minimum amount of information about these structs
15  */
16 typedef struct conf_item CONF_ITEM;
17 typedef struct conf_pair CONF_PAIR;
18 typedef struct conf_part CONF_SECTION;
19
20 /*
21  *  Instead of putting the information into a configuration structure,
22  *  the configuration file routines MAY just parse it directly into
23  *  user-supplied variables.
24  */
25 #define PW_TYPE_STRING_PTR      100
26 #define PW_TYPE_BOOLEAN         101
27 #define PW_TYPE_SUBSECTION      102
28
29 typedef struct CONF_PARSER {
30   const char *name;
31   int type;                     /* PW_TYPE_STRING, etc. */
32   void *data;                   /* pointer to where to put it */
33   const char *dflt;             /* default as it would appear in radiusd.conf */
34 } CONF_PARSER;
35
36 /* This preprocessor trick will be useful in initializing CONF_PARSER struct */
37 #define XStringify(x) #x
38 #define Stringify(x) XStringify(x)
39
40 void            cf_pair_free(CONF_PAIR *cp);
41 void            cf_section_free(CONF_SECTION *cp);
42 int             cf_section_parse(CONF_SECTION *cs, const CONF_PARSER *variables);
43
44 /* JLN -- Newly added */
45                 
46 CONF_PAIR       *cf_pair_find(CONF_SECTION *section, const char *name);
47 CONF_PAIR       *cf_pair_find_next(CONF_SECTION *section, CONF_PAIR *pair, const char *name);
48 CONF_SECTION    *cf_section_find(const char *name);
49 CONF_SECTION    *cf_section_sub_find(CONF_SECTION *section, const char *name);
50 char            *cf_section_value_find(CONF_SECTION *section, const char *attr);
51
52 int             read_radius_conf_file(void);
53
54 char *cf_pair_attr(CONF_PAIR *pair);
55 char *cf_pair_value(CONF_PAIR *pair);
56 char *cf_section_name1(CONF_SECTION *section);
57 char *cf_section_name2(CONF_SECTION *section);
58 int dump_config(void);
59 CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
60                                       CONF_SECTION *subsection,
61                                       const char *name1);
62 int cf_section_lineno(CONF_SECTION *section);
63 int cf_pair_lineno(CONF_PAIR *pair);
64 CONF_ITEM *cf_item_find_next(CONF_SECTION *section, CONF_ITEM *item);
65 int cf_item_is_section(CONF_ITEM *item);
66 CONF_PAIR *cf_itemtopair(CONF_ITEM *item);
67 CONF_SECTION *cf_itemtosection(CONF_ITEM *item);
68 #endif /* _CONFFILE_H */