5 * conffile.h Defines for the conffile parsing routines.
7 * Version: $Id: conffile.h,v 1.1 2010/08/14 04:13:52 faust Exp $
11 #include <freeradius/ident.h>
12 RCSIDH(conffile_h, "$Id: conffile.h,v 1.1 2010/08/14 04:13:52 faust Exp $")
15 #include <freeradius/token.h>
18 * Export the minimum amount of information about these structs
20 typedef struct conf_item CONF_ITEM;
21 typedef struct conf_pair CONF_PAIR;
22 typedef struct conf_part CONF_SECTION;
23 typedef struct conf_data CONF_DATA;
26 * Instead of putting the information into a configuration structure,
27 * the configuration file routines MAY just parse it directly into
28 * user-supplied variables.
30 #define PW_TYPE_STRING_PTR 100
31 #define PW_TYPE_BOOLEAN 101
32 #define PW_TYPE_SUBSECTION 102
33 #define PW_TYPE_FILENAME 103
35 typedef struct CONF_PARSER {
37 int type; /* PW_TYPE_STRING, etc. */
38 size_t offset; /* relative pointer within "base" */
39 void *data; /* absolute pointer if base is NULL */
40 const char *dflt; /* default as it would appear in radiusd.conf */
43 /* This preprocessor trick will be useful in initializing CONF_PARSER struct */
44 #define XStringify(x) #x
45 #define Stringify(x) XStringify(x)
47 void cf_pair_free(CONF_PAIR **cp);
48 int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp,
50 void cf_section_free(CONF_SECTION **cp);
51 int cf_item_parse(CONF_SECTION *cs, const char *name,
52 int type, void *data, const char *dflt);
53 int cf_section_parse(CONF_SECTION *, void *base,
54 const CONF_PARSER *variables);
55 void cf_section_parse_free(CONF_SECTION *cs, void *base);
56 const CONF_PARSER *cf_section_parse_table(CONF_SECTION *cs);
57 CONF_SECTION *cf_file_read(const char *file);
58 int cf_file_include(const char *file, CONF_SECTION *cs);
60 CONF_PAIR *cf_pair_find(const CONF_SECTION *, const char *name);
61 CONF_PAIR *cf_pair_find_next(const CONF_SECTION *, CONF_PAIR *, const char *name);
62 CONF_SECTION *cf_section_find(const char *name);
63 CONF_SECTION *cf_section_sub_find(const CONF_SECTION *, const char *name);
64 CONF_SECTION *cf_section_sub_find_name2(const CONF_SECTION *, const char *name1, const char *name2);
65 const char *cf_section_value_find(const CONF_SECTION *, const char *attr);
66 CONF_SECTION *cf_top_section(CONF_SECTION *cs);
68 void *cf_data_find(CONF_SECTION *, const char *);
69 int cf_data_add(CONF_SECTION *, const char *, void *, void (*)(void *));
71 const char *cf_pair_attr(CONF_PAIR *pair);
72 const char *cf_pair_value(CONF_PAIR *pair);
73 VALUE_PAIR *cf_pairtovp(CONF_PAIR *pair);
74 const char *cf_section_name1(const CONF_SECTION *);
75 const char *cf_section_name2(const CONF_SECTION *);
76 int dump_config(CONF_SECTION *cs);
77 CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
78 CONF_SECTION *subsection,
80 CONF_SECTION *cf_section_find_next(CONF_SECTION *section,
81 CONF_SECTION *subsection,
83 int cf_section_lineno(CONF_SECTION *section);
84 int cf_pair_lineno(CONF_PAIR *pair);
85 const char *cf_pair_filename(CONF_PAIR *pair);
86 const char *cf_section_filename(CONF_SECTION *section);
87 CONF_ITEM *cf_item_find_next(CONF_SECTION *section, CONF_ITEM *item);
88 int cf_item_is_section(CONF_ITEM *item);
89 int cf_item_is_pair(CONF_ITEM *item);
90 CONF_PAIR *cf_itemtopair(CONF_ITEM *item);
91 CONF_SECTION *cf_itemtosection(CONF_ITEM *item);
92 CONF_ITEM *cf_pairtoitem(CONF_PAIR *cp);
93 CONF_ITEM *cf_sectiontoitem(CONF_SECTION *cs);
94 int cf_section_template(CONF_SECTION *cs, CONF_SECTION *_template);
95 void cf_log_err(CONF_ITEM *ci, const char *fmt, ...)
97 __attribute__ ((format (printf, 2, 3)))
100 void cf_log_info(CONF_SECTION *cs, const char *fmt, ...)
102 __attribute__ ((format (printf, 2, 3)))
105 void cf_log_module(CONF_SECTION *cs, const char *fmt, ...)
107 __attribute__ ((format (printf, 2, 3)))
110 CONF_ITEM *cf_reference_item(const CONF_SECTION *parentcs,
111 CONF_SECTION *outercs,
113 extern int cf_log_config;
114 extern int cf_log_modules;
116 extern int cf_pair2xml(FILE *fp, CONF_PAIR *cp);
117 extern int cf_section2xml(FILE *fp, CONF_SECTION *cs);
118 extern int cf_pair2file(FILE *fp, CONF_PAIR *cp);
119 extern int cf_section2file(FILE *fp, CONF_SECTION *cs);
124 int cf_section_migrate(CONF_SECTION *dst, CONF_SECTION *src);
126 #endif /* _CONFFILE_H */