source: src/router/freeradius/src/include/conffile.h @ 14669

Last change on this file since 14669 was 14669, checked in by BrainSlayer, 3 years ago

update to 2.1.9

File size: 4.3 KB
Line 
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 <freeradius-devel/ident.h>
12RCSIDH(conffile_h, "$Id$")
13
14#include <stddef.h>
15#include <freeradius-devel/token.h>
16
17/*
18 * Export the minimum amount of information about these structs
19 */
20typedef struct conf_item CONF_ITEM;
21typedef struct conf_pair CONF_PAIR;
22typedef struct conf_part CONF_SECTION;
23typedef struct conf_data CONF_DATA;
24
25/*
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.
29 */
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
34
35typedef struct CONF_PARSER {
36  const char *name;
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 */
41} CONF_PARSER;
42
43/* This preprocessor trick will be useful in initializing CONF_PARSER struct */
44#define XStringify(x) #x
45#define Stringify(x) XStringify(x)
46
47void            cf_pair_free(CONF_PAIR **cp);
48int             cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp,
49                                const char *value);
50void            cf_section_free(CONF_SECTION **cp);
51int             cf_item_parse(CONF_SECTION *cs, const char *name,
52                              int type, void *data, const char *dflt);
53int             cf_section_parse(CONF_SECTION *, void *base,
54                                 const CONF_PARSER *variables);
55void            cf_section_parse_free(CONF_SECTION *cs, void *base);
56const CONF_PARSER *cf_section_parse_table(CONF_SECTION *cs);
57CONF_SECTION    *cf_file_read(const char *file);
58int             cf_file_include(const char *file, CONF_SECTION *cs);
59
60CONF_PAIR       *cf_pair_find(const CONF_SECTION *, const char *name);
61CONF_PAIR       *cf_pair_find_next(const CONF_SECTION *, CONF_PAIR *, const char *name);
62CONF_SECTION    *cf_section_find(const char *name);
63CONF_SECTION    *cf_section_sub_find(const CONF_SECTION *, const char *name);
64CONF_SECTION    *cf_section_sub_find_name2(const CONF_SECTION *, const char *name1, const char *name2);
65const char      *cf_section_value_find(const CONF_SECTION *, const char *attr);
66CONF_SECTION    *cf_top_section(CONF_SECTION *cs);
67
68void *cf_data_find(CONF_SECTION *, const char *);
69int cf_data_add(CONF_SECTION *, const char *, void *, void (*)(void *));
70
71const char *cf_pair_attr(CONF_PAIR *pair);
72const char *cf_pair_value(CONF_PAIR *pair);
73VALUE_PAIR *cf_pairtovp(CONF_PAIR *pair);
74const char *cf_section_name1(const CONF_SECTION *);
75const char *cf_section_name2(const CONF_SECTION *);
76int dump_config(CONF_SECTION *cs);
77CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
78                                      CONF_SECTION *subsection,
79                                      const char *name1);
80CONF_SECTION *cf_section_find_next(CONF_SECTION *section,
81                                   CONF_SECTION *subsection,
82                                   const char *name1);
83int cf_section_lineno(CONF_SECTION *section);
84int cf_pair_lineno(CONF_PAIR *pair);
85const char *cf_pair_filename(CONF_PAIR *pair);
86const char *cf_section_filename(CONF_SECTION *section);
87CONF_ITEM *cf_item_find_next(CONF_SECTION *section, CONF_ITEM *item);
88int cf_item_is_section(CONF_ITEM *item);
89int cf_item_is_pair(CONF_ITEM *item);
90CONF_PAIR *cf_itemtopair(CONF_ITEM *item);
91CONF_SECTION *cf_itemtosection(CONF_ITEM *item);
92CONF_ITEM *cf_pairtoitem(CONF_PAIR *cp);
93CONF_ITEM *cf_sectiontoitem(CONF_SECTION *cs);
94int cf_section_template(CONF_SECTION *cs, CONF_SECTION *template);
95void cf_log_err(CONF_ITEM *ci, const char *fmt, ...)
96#ifdef __GNUC__
97                __attribute__ ((format (printf, 2, 3)))
98#endif
99;
100void cf_log_info(CONF_SECTION *cs, const char *fmt, ...)
101#ifdef __GNUC__
102                __attribute__ ((format (printf, 2, 3)))
103#endif
104;
105void cf_log_module(CONF_SECTION *cs, const char *fmt, ...)
106#ifdef __GNUC__
107                __attribute__ ((format (printf, 2, 3)))
108#endif
109;
110CONF_ITEM *cf_reference_item(const CONF_SECTION *parentcs,
111                             CONF_SECTION *outercs,
112                             const char *ptr);
113extern int cf_log_config;
114extern int cf_log_modules;
115
116extern int cf_pair2xml(FILE *fp, const CONF_PAIR *cp);
117extern int cf_section2xml(FILE *fp, const CONF_SECTION *cs);
118extern int cf_pair2file(FILE *fp, const CONF_PAIR *cp);
119extern int cf_section2file(FILE *fp, const CONF_SECTION *cs);
120
121/*
122 *      Big magic.
123 */
124int cf_section_migrate(CONF_SECTION *dst, CONF_SECTION *src);
125
126#endif /* _CONFFILE_H */
Note: See TracBrowser for help on using the repository browser.