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