| 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> |
|---|
| 12 | RCSIDH(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 | */ |
|---|
| 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; |
|---|
| 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 | |
|---|
| 35 | typedef 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 | |
|---|
| 47 | void cf_pair_free(CONF_PAIR **cp); |
|---|
| 48 | int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, |
|---|
| 49 | const char *value); |
|---|
| 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); |
|---|
| 59 | |
|---|
| 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); |
|---|
| 67 | |
|---|
| 68 | void *cf_data_find(CONF_SECTION *, const char *); |
|---|
| 69 | int cf_data_add(CONF_SECTION *, const char *, void *, void (*)(void *)); |
|---|
| 70 | |
|---|
| 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, |
|---|
| 79 | const char *name1); |
|---|
| 80 | CONF_SECTION *cf_section_find_next(CONF_SECTION *section, |
|---|
| 81 | CONF_SECTION *subsection, |
|---|
| 82 | const char *name1); |
|---|
| 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, ...) |
|---|
| 96 | #ifdef __GNUC__ |
|---|
| 97 | __attribute__ ((format (printf, 2, 3))) |
|---|
| 98 | #endif |
|---|
| 99 | ; |
|---|
| 100 | void cf_log_info(CONF_SECTION *cs, const char *fmt, ...) |
|---|
| 101 | #ifdef __GNUC__ |
|---|
| 102 | __attribute__ ((format (printf, 2, 3))) |
|---|
| 103 | #endif |
|---|
| 104 | ; |
|---|
| 105 | void cf_log_module(CONF_SECTION *cs, const char *fmt, ...) |
|---|
| 106 | #ifdef __GNUC__ |
|---|
| 107 | __attribute__ ((format (printf, 2, 3))) |
|---|
| 108 | #endif |
|---|
| 109 | ; |
|---|
| 110 | CONF_ITEM *cf_reference_item(const CONF_SECTION *parentcs, |
|---|
| 111 | CONF_SECTION *outercs, |
|---|
| 112 | const char *ptr); |
|---|
| 113 | extern int cf_log_config; |
|---|
| 114 | extern int cf_log_modules; |
|---|
| 115 | |
|---|
| 116 | extern int cf_pair2xml(FILE *fp, const CONF_PAIR *cp); |
|---|
| 117 | extern int cf_section2xml(FILE *fp, const CONF_SECTION *cs); |
|---|
| 118 | extern int cf_pair2file(FILE *fp, const CONF_PAIR *cp); |
|---|
| 119 | extern int cf_section2file(FILE *fp, const CONF_SECTION *cs); |
|---|
| 120 | |
|---|
| 121 | /* |
|---|
| 122 | * Big magic. |
|---|
| 123 | */ |
|---|
| 124 | int cf_section_migrate(CONF_SECTION *dst, CONF_SECTION *src); |
|---|
| 125 | |
|---|
| 126 | #endif /* _CONFFILE_H */ |
|---|