The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
cf_util.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: 6a31fb06dc2140d299017d2591d00b54f967d18d $
20  *
21  * @file lib/server/cf_util.h
22  * @brief API to create and manipulate internal format configurations.
23  *
24  * @copyright 2017 The FreeRADIUS server project
25  */
26 RCSIDH(conf_file_h, "$Id: 6a31fb06dc2140d299017d2591d00b54f967d18d $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /*
33  * Export the minimum amount of information about these structs
34  */
35 typedef struct cf_item CONF_ITEM; //!< Generic configuration element, extended to become
36  ///< a #CONF_PAIR, a #CONF_SECTION or #CONF_DATA.
37 typedef struct cf_section CONF_SECTION; //!< #CONF_ITEM used to group multiple #CONF_PAIR and #CONF_SECTION, together.
38 typedef struct cf_pair CONF_PAIR; //!< #CONF_ITEM with an attribute, an operator and a value.
39 typedef struct cf_data CONF_DATA; //!< #CONF_ITEM used to associate arbitrary data
40  ///< with a #CONF_PAIR or #CONF_SECTION.
41 
42 #include <stddef.h>
43 #include <stdint.h>
44 #include <stdbool.h>
45 #include <unistd.h>
46 #include <sys/time.h>
47 
48 #include <freeradius-devel/util/rb.h>
49 #include <freeradius-devel/util/table.h>
50 #include <freeradius-devel/util/token.h>
51 #include <freeradius-devel/util/log.h>
52 
53 #define FR_TIMEVAL_TO_MS(_x) (((_x)->tv_usec / 1000) + ((_x)->tv_sec * (uint64_t)1000))
54 #define FR_TIMESPEC_TO_MS(_x) (((_x)->tv_usec / 1000000) + ((_x)->tv_sec * (uint64_t)1000))
55 
56 /** Auto cast from the input type to CONF_ITEM (which is the base type)
57  *
58  * Automatically casts:
59  * - #CONF_SECTION
60  * - #CONF_PAIR
61  * - #CONF_DATA
62  *
63  * To a #CONF_ITEM, whilst performing talloc type checks.
64  */
65 #define CF_TO_ITEM(_cf) \
66 _Generic((_cf), \
67  CONF_SECTION * : cf_section_to_item((CONF_SECTION const *)_cf), \
68  CONF_SECTION const * : cf_section_to_item((CONF_SECTION const *)_cf), \
69  CONF_PAIR * : cf_pair_to_item((CONF_PAIR const *)_cf), \
70  CONF_PAIR const * : cf_pair_to_item((CONF_PAIR const *)_cf), \
71  CONF_DATA * : cf_data_to_item((CONF_DATA const *)_cf), \
72  CONF_DATA const * : cf_data_to_item((CONF_DATA const *)_cf), \
73  default: _cf \
74 )
75 
76 typedef int (*cf_walker_t)(void *data, void *ctx);
77 
78 #define CF_IDENT_ANY ((void *) (-1))
79 
80 /*
81  * Generic functions that apply to all types of #CONF_ITEM
82  */
83 #define cf_item_add(_parent, _child) _cf_item_add(CF_TO_ITEM(_parent), CF_TO_ITEM(_child))
84 void _cf_item_add(CONF_ITEM *parent, CONF_ITEM *child);
85 
86 #define cf_item_insert_after(_parent, _prev, _child) _cf_item_insert_after(CF_TO_ITEM(_parent), CF_TO_ITEM(_prev), CF_TO_ITEM(_child))
88 
89 #define cf_item_remove(_parent, _child) _cf_item_remove(CF_TO_ITEM(_parent), CF_TO_ITEM(_child))
91 
92 #define cf_item_next(_ci, _prev) _cf_item_next(CF_TO_ITEM(_ci), _prev)
93 CONF_ITEM *_cf_item_next(CONF_ITEM const *ci, CONF_ITEM const *prev);
94 
95 #define cf_root(_cf) _cf_root(CF_TO_ITEM(_cf))
96 CONF_SECTION *_cf_root(CONF_ITEM const *ci);
97 
98 #define cf_parent(_cf) _cf_parent(CF_TO_ITEM(_cf))
99 CONF_ITEM *_cf_parent(CONF_ITEM const *ci);
100 
101 #define cf_lineno(_cf) _cf_lineno(CF_TO_ITEM(_cf))
102 int _cf_lineno(CONF_ITEM const *ci);
103 
104 #define cf_filename(_cf) _cf_filename(CF_TO_ITEM(_cf))
105 char const *_cf_filename(CONF_ITEM const *ci);
106 
107 bool cf_item_is_section(CONF_ITEM const *ci);
108 bool cf_item_is_pair(CONF_ITEM const *ci);
109 bool cf_item_is_data(CONF_ITEM const *ci);
110 
111 /** @hidecallergraph */
113 /** @hidecallergraph */
115 /** @hidecallergraph */
117 
118 /** @hidecallergraph */
120 /** @hidecallergraph */
122 /** @hidecallergraph */
124 
125 #define cf_filename_set(_ci, _filename) _cf_filename_set(CF_TO_ITEM(_ci), _filename)
126 void _cf_filename_set(CONF_ITEM *cs, char const *filename);
127 
128 #define cf_lineno_set(_ci, _lineno) _cf_lineno_set(CF_TO_ITEM(_ci), _lineno)
129 void _cf_lineno_set(CONF_ITEM *cs, int lineno);
130 
132 
133 /*
134  * Section manipulation and searching
135  */
136 #ifndef NDEBUG
137 # define cf_section_alloc(_ctx, _parent, _name1, _name2) \
138  _cf_section_alloc(_ctx, _parent, _name1, _name2, __FILE__, __LINE__)
139 #else
140 # define cf_section_alloc(_ctx, _parent, _name1, _name2) \
141  _cf_section_alloc(_ctx, _parent, _name1, _name2, NULL, 0)
142 #endif
144  char const *name1, char const *name2,
145  char const *filename, int lineno);
146 CONF_SECTION *cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION const *cs,
147  char const *name1, char const *name2, bool copy_meta);
148 /** @hidecallergraph */
149 CONF_SECTION *cf_section_next(CONF_SECTION const *cs, CONF_SECTION const *prev);
150 /** @hidecallergraph */
151 CONF_SECTION *cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2);
152 /** @hidecallergraph */
154  char const *name1, char const *name2);
156  char const *name1, char const *name2);
158  char const *name1, char const *name2);
159 
160 char const *cf_section_value_find(CONF_SECTION const *, char const *attr);
161 
162 int8_t cf_section_name_cmp(CONF_SECTION const *cs, char const *name1, char const *name2);
163 /** @hidecallergraph */
164 char const *cf_section_name1(CONF_SECTION const *cs);
165 /** @hidecallergraph */
166 char const *cf_section_name2(CONF_SECTION const *cs);
167 /** @hidecallergraph */
168 char const *cf_section_name(CONF_SECTION const *cs);
169 char const *cf_section_argv(CONF_SECTION const *cs, int argc);
171 fr_token_t cf_section_argv_quote(CONF_SECTION const *cs, int argc);
172 
173 // only for rewrite_update
175 
176 #define cf_section_free_children(_x) cf_item_free_children(cf_section_to_item(_x))
177 
178 
179 /*
180  * Pair manipulation and searching
181  */
182 CONF_PAIR *cf_pair_alloc(CONF_SECTION *parent, char const *attr, char const *value,
183  fr_token_t op, fr_token_t lhs_type, fr_token_t rhs_type);
184 
186 
187 int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, char const *value);
188 
190 
191 bool cf_pair_is_parsed(CONF_PAIR *cp);
192 
193 CONF_PAIR *cf_pair_next(CONF_SECTION const *cs, CONF_PAIR const *prev);
194 
195 CONF_PAIR *cf_pair_find(CONF_SECTION const *cs, char const *name);
196 
197 CONF_PAIR *cf_pair_find_next(CONF_SECTION const *cs, CONF_PAIR const *prev, char const *name);
198 
199 CONF_PAIR *cf_pair_find_in_parent(CONF_SECTION const *cs, char const *attr);
200 
201 unsigned int cf_pair_count_descendents(CONF_SECTION const *cs);
202 
203 unsigned int cf_pair_count(CONF_SECTION const *cs, char const *attr);
204 
205 fr_slen_t cf_pair_values_concat(fr_sbuff_t *sbuff, CONF_SECTION const *cs, char const *attr, char const *sep);
206 
207 /** @hidecallergraph */
208 char const *cf_pair_attr(CONF_PAIR const *pair);
209 /** @hidecallergraph */
210 char const *cf_pair_value(CONF_PAIR const *pair);
211 /** @hidecallergraph */
213 
216 
217 /*
218  * Data manipulation and searching
219  */
220 #define cf_data_find(_cf, _type, _name) _cf_data_find(CF_TO_ITEM(_cf), #_type, _name)
221 CONF_DATA const *_cf_data_find(CONF_ITEM const *ci, char const *type, char const *name);
222 
223 #define cf_data_find_next(_cf, _prev, _type, _name) _cf_data_find_next(CF_TO_ITEM(_cf), CF_TO_ITEM(_prev), #_type, _name)
224 CONF_DATA const *_cf_data_find_next(CONF_ITEM const *ci, CONF_ITEM const *prev, char const *type, char const *name);
225 
226 #define cf_data_find_in_parent(_cf, _type, _name) _cf_data_find_in_parent(CF_TO_ITEM(_cf), #_type, _name)
227 CONF_DATA *_cf_data_find_in_parent(CONF_ITEM const *ci, char const *type, char const *name);
228 
229 void *cf_data_value(CONF_DATA const *cd);
230 
231 #define cf_data_add(_cf, _data, _name, _free) _cf_data_add(CF_TO_ITEM(_cf), (void const *) _data, _name, _free, __FILE__, __LINE__)
232 CONF_DATA const *_cf_data_add(CONF_ITEM *ci, void const *data, char const *name, bool free, char const *filename, int lineno);
233 
234 #define cf_data_add_static(_cf, _data, _type, _name) _cf_data_add_static(CF_TO_ITEM(_cf), _data, #_type, _name, __FILE__, __LINE__)
235 CONF_DATA const *_cf_data_add_static(CONF_ITEM *ci, void const *data, char const *type, char const *name, char const *filename, int lineno);
236 
237 /** Remove an item from a parent by type and name
238  *
239  * @param[in] _cf conf section or pair to remove data from.
240  * @param[in] _type of data to remove.
241  * @param[in] _name of data to remove.
242  */
243 #define cf_data_remove(_cf, _type, _name) _cf_data_remove(CF_TO_ITEM(_cf), cf_data_find(_cf, _type, _name))
244 
245 /** Remove an item from a parent
246  *
247  * @param[in] _cf conf section or pair to remove data from.
248  * @param[in] _cd conf data to remove.
249  */
250 #define cf_data_remove_by_data(_cf, _cd) _cf_data_remove(CF_TO_ITEM(_cf), _cd)
251 void *_cf_data_remove(CONF_ITEM *ci, CONF_DATA const *_cd);
252 
253 #define cf_data_walk(_cf, _type, _cb, _ctx) _cf_data_walk(CF_TO_ITEM(_cf), #_type, _cb, _ctx)
254 int _cf_data_walk(CONF_ITEM *ci, char const *type, cf_walker_t cb, void *ctx);
255 
256 /*
257  * Validation
258  */
259 int cf_pair_in_table(int32_t *out, fr_table_num_sorted_t const *table, size_t table_len, CONF_PAIR *cp);
260 
261 /*
262  * Error logging
263  */
264 
265 #define cf_log_err(_cf, _fmt, ...) _cf_log(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
266 #define cf_log_warn(_cf, _fmt, ...) _cf_log(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
267 #define cf_log_info(_cf, _fmt, ...) _cf_log(L_INFO, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
268 #define cf_log_debug(_cf, _fmt, ...) _cf_log(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
269 void _cf_vlog(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt, va_list ap) CC_HINT(format (printf, 5, 0));
270 void _cf_log(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt, ...) CC_HINT(format (printf, 5, 6));
271 
272 #define cf_log_perr(_cf, _fmt, ...) _cf_log_perr(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
273 #define cf_log_pwarn(_cf, _fmt, ...) _cf_log_perr(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
274 
275 void _cf_vlog_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
276  fr_log_perror_format_t const *f_rules, char const *fmt, va_list ap)
277  CC_HINT(format (printf, 6, 0));
278 void _cf_log_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line,
279  fr_log_perror_format_t const *f_rules, char const *fmt, ...)
280  CC_HINT(format (printf, 6, 7));
281 
282 #define cf_log_debug_prefix(_cf, _fmt, ...) _cf_log_with_filename(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
283 void _cf_log_with_filename(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt, ...) CC_HINT(format (printf, 5, 6));
284 
285 /** Log an error message against a specified child
286  *
287  * @param[in] _parent CONF_SECTION.
288  * @param[in] _child string identifier.
289  * @param[in] _fmt of message.
290  * @param[in] ... arguments.
291  */
292 #define cf_log_err_by_child(_parent, _child, _fmt, ...) _cf_log_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
293 
294 /** Log an error message against a specified child, draining the thread local error stack
295  *
296  * @param[in] _parent CONF_SECTION.
297  * @param[in] _child string identifier.
298  * @param[in] _f_rules Line prefixes.
299  * @param[in] _fmt of message.
300  * @param[in] ... arguments.
301  */
302 #define cf_log_perr_by_child(_parent, _child, _f_rules, _fmt, ...) _cf_log_perr_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _f_rules, _fmt, ## __VA_ARGS__)
303 
304 /** Log a warning message against a specified child
305  *
306  * @param[in] _parent CONF_SECTION.
307  * @param[in] _child string identifier.
308  * @param[in] _fmt of message.
309  * @param[in] ... arguments.
310  */
311 #define cf_log_warn_by_child(_parent, _child, _fmt, ...) _cf_log_by_child(L_WARN, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
312 
313 /** Log an info message against a specified child
314  *
315  * @param[in] _parent CONF_SECTION.
316  * @param[in] _child string identifier.
317  * @param[in] _fmt of message.
318  * @param[in] ... arguments.
319  */
320 #define cf_log_info_by_child(_parent, _child, _fmt, ...) _cf_log_by_child(L_INFO, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
321 
322 /** Log a debug message against a specified child
323  *
324  * @param[in] _parent CONF_SECTION.
325  * @param[in] _child string identifier.
326  * @param[in] _fmt of message.
327  * @param[in] ... arguments.
328  */
329 #define cf_log_debug_by_child(_parent, _child, _fmt, ...) _cf_log_by_child(L_DBG, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
330 void _cf_log_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child,
331  char const *file, int line, char const *fmt, ...) CC_HINT(format (printf, 6, 7));
332 
333 void _cf_log_perr_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child,
334  char const *file, int line, fr_log_perror_format_t const *f_rules,
335  char const *fmt, ...) CC_HINT(format (printf, 7, 8));
336 
337 #define cf_debug(_cf) _cf_debug(CF_TO_ITEM(_cf))
338 void _cf_debug(CONF_ITEM const *ci);
339 
340 #define cf_canonicalize_error(_ci, _slen, _msg, _str) _cf_canonicalize_error(CF_TO_ITEM(_ci), _slen, _msg, _str)
341 void _cf_canonicalize_error(CONF_ITEM *ci, ssize_t slen, char const *msg, char const *str);
342 
343 #ifdef __cplusplus
344 }
345 #endif
int const char * file
Definition: acutest.h:702
log_entry msg
Definition: acutest.h:794
static int const char * fmt
Definition: acutest.h:573
int const char int line
Definition: acutest.h:702
#define RCSIDH(h, id)
Definition: build.h:445
Internal data that is associated with a configuration section.
Definition: cf_priv.h:113
Common header for all CONF_* types.
Definition: cf_priv.h:49
Configuration AVP similar to a fr_pair_t.
Definition: cf_priv.h:70
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
CONF_DATA const * _cf_data_add(CONF_ITEM *ci, void const *data, char const *name, bool free, char const *filename, int lineno)
Add talloced user data to a config section.
Definition: cf_util.c:1703
void _cf_log_with_filename(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt,...))
Log a debug message relating to a CONF_ITEM.
Definition: cf_util.c:2100
CONF_ITEM * _cf_item_remove(CONF_ITEM *parent, CONF_ITEM *child)
Remove item from parent and fixup trees.
Definition: cf_util.c:428
bool cf_item_is_pair(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_PAIR.
Definition: cf_util.c:597
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
Definition: cf_util.c:629
CONF_SECTION * cf_section_find_parent(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a parent CONF_SECTION with name1 and optionally name2.
Definition: cf_util.c:1039
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
Definition: cf_util.c:703
fr_token_t cf_pair_attr_quote(CONF_PAIR const *pair)
Return the value (lhs) quoting of a pair.
Definition: cf_util.c:1540
char const * cf_section_value_find(CONF_SECTION const *, char const *attr)
Find a pair in a CONF_SECTION.
Definition: cf_util.c:1061
char const * cf_pair_attr(CONF_PAIR const *pair)
Return the attr of a CONF_PAIR.
Definition: cf_util.c:1495
void * _cf_data_remove(CONF_ITEM *ci, CONF_DATA const *_cd)
Remove data from a configuration section.
Definition: cf_util.c:1789
int _cf_data_walk(CONF_ITEM *ci, char const *type, cf_walker_t cb, void *ctx)
Walk over a specific type of CONF_DATA.
Definition: cf_util.c:1817
unsigned int cf_pair_count_descendents(CONF_SECTION const *cs)
Count the number of conf pairs beneath a section.
Definition: cf_util.c:1422
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
Definition: cf_util.c:970
void _cf_vlog_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, fr_log_perror_format_t const *f_rules, char const *fmt, va_list ap))
Log an error message relating to a CONF_ITEM.
Definition: cf_util.c:1988
CONF_SECTION * cf_section_find_in_parent(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a section in the lineage of a CONF_SECTION which matches a specific name1 and optionally name2.
Definition: cf_util.c:1012
fr_token_t cf_section_argv_quote(CONF_SECTION const *cs, int argc)
Return the quoting for one of the variadic arguments.
Definition: cf_util.c:1201
CONF_PAIR * cf_pair_find_in_parent(CONF_SECTION const *cs, char const *attr)
Find a pair with a name matching attr in the specified section or one of its parents.
Definition: cf_util.c:1384
unsigned int cf_pair_count(CONF_SECTION const *cs, char const *attr)
Count the number of times an attribute occurs in a parent section.
Definition: cf_util.c:1437
int cf_pair_in_table(int32_t *out, fr_table_num_sorted_t const *table, size_t table_len, CONF_PAIR *cp)
Check to see if the CONF_PAIR value is present in the specified table.
Definition: cf_util.c:1886
void _cf_item_insert_after(CONF_ITEM *parent, CONF_ITEM *prev, CONF_ITEM *child)
Insert a child after a given one.
Definition: cf_util.c:390
void _cf_log_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child, char const *file, int line, char const *fmt,...))
Log an error message in the context of a child pair of the specified parent.
Definition: cf_util.c:2139
void cf_item_free_children(CONF_ITEM *ci)
Definition: cf_util.c:2322
CONF_PAIR * cf_pair_next(CONF_SECTION const *cs, CONF_PAIR const *prev)
Return the next child that's a CONF_PAIR.
Definition: cf_util.c:1343
CONF_SECTION * _cf_section_alloc(TALLOC_CTX *ctx, CONF_SECTION *parent, char const *name1, char const *name2, char const *filename, int lineno)
Allocate a CONF_SECTION.
Definition: cf_util.c:752
CONF_DATA * _cf_data_find_in_parent(CONF_ITEM const *ci, char const *type, char const *name)
Find matching data in the specified section or one of its parents.
Definition: cf_util.c:1661
int8_t cf_section_name_cmp(CONF_SECTION const *cs, char const *name1, char const *name2)
Check if a given section matches the specified name1/name2 identifiers.
Definition: cf_util.c:1080
void _cf_vlog(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt, va_list ap))
Log an error message relating to a CONF_ITEM.
Definition: cf_util.c:1926
void _cf_log_perr(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, fr_log_perror_format_t const *f_rules, char const *fmt,...))
Log an error message relating to a CONF_ITEM.
Definition: cf_util.c:2077
CONF_PAIR * cf_pair_alloc(CONF_SECTION *parent, char const *attr, char const *value, fr_token_t op, fr_token_t lhs_type, fr_token_t rhs_type)
Allocate a CONF_PAIR.
Definition: cf_util.c:1220
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
Definition: cf_util.c:1126
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
Definition: cf_util.c:1511
CONF_PAIR * cf_pair_find_next(CONF_SECTION const *cs, CONF_PAIR const *prev, char const *name)
Find a pair with a name matching attr, after specified pair.
Definition: cf_util.c:1370
void cf_pair_mark_parsed(CONF_PAIR *cp)
Mark a pair as parsed.
Definition: cf_util.c:1318
void _cf_filename_set(CONF_ITEM *cs, char const *filename)
Set the filename of a CONF_ITEM.
Definition: cf_util.c:861
CONF_DATA const * _cf_data_find_next(CONF_ITEM const *ci, CONF_ITEM const *prev, char const *type, char const *name)
Return the next item of user data.
Definition: cf_util.c:1645
fr_slen_t cf_pair_values_concat(fr_sbuff_t *sbuff, CONF_SECTION const *cs, char const *attr, char const *sep)
Concatenate the values of any pairs with name attr.
Definition: cf_util.c:1457
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
Definition: cf_util.c:1680
CONF_SECTION * _cf_root(CONF_ITEM const *ci)
Return the top level CONF_SECTION holding all other CONF_ITEM.
Definition: cf_util.c:523
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *subcs, char const *name1, char const *name2)
Return the next matching section.
Definition: cf_util.c:991
void cf_section_add_name2_quote(CONF_SECTION *cs, fr_token_t token)
Set the quoting of the name2 identifier.
Definition: cf_util.c:1183
bool cf_item_is_data(CONF_ITEM const *ci)
Determine if CONF_ITEM is CONF_DATA.
Definition: cf_util.c:611
fr_token_t cf_pair_operator(CONF_PAIR const *pair)
Return the operator of a pair.
Definition: cf_util.c:1525
CONF_ITEM * cf_pair_to_item(CONF_PAIR const *cp)
Cast a CONF_PAIR to a CONF_ITEM.
Definition: cf_util.c:687
bool cf_pair_is_parsed(CONF_PAIR *cp)
Return whether a pair has already been parsed.
Definition: cf_util.c:1330
char const * _cf_filename(CONF_ITEM const *ci)
Return the filename the CONF_ITEM was parsed in.
Definition: cf_util.c:569
CONF_SECTION * cf_section_next(CONF_SECTION const *cs, CONF_SECTION const *prev)
Return the next child that's a CONF_SECTION.
Definition: cf_util.c:952
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
Definition: cf_util.c:649
fr_token_t cf_pair_value_quote(CONF_PAIR const *pair)
Return the value (rhs) quoting of a pair.
Definition: cf_util.c:1555
void _cf_canonicalize_error(CONF_ITEM *ci, ssize_t slen, char const *msg, char const *str)
Definition: cf_util.c:2335
CONF_ITEM * _cf_item_next(CONF_ITEM const *ci, CONF_ITEM const *prev)
Return the next child of cs.
Definition: cf_util.c:490
CONF_DATA const * _cf_data_find(CONF_ITEM const *ci, char const *type, char const *name)
Find user data in a config section.
Definition: cf_util.c:1627
bool cf_item_is_section(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_SECTION.
Definition: cf_util.c:583
CONF_DATA * cf_item_to_data(CONF_ITEM const *ci)
Cast CONF_ITEM to CONF_DATA performing a type check.
Definition: cf_util.c:669
CONF_SECTION * cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
Duplicate a configuration section.
Definition: cf_util.c:894
int _cf_lineno(CONF_ITEM const *ci)
Return the lineno the CONF_ITEM was parsed at.
Definition: cf_util.c:555
CONF_PAIR * cf_pair_find(CONF_SECTION const *cs, char const *name)
Search for a CONF_PAIR with a specific name.
Definition: cf_util.c:1356
fr_token_t cf_section_name2_quote(CONF_SECTION const *cs)
Return the quoting of the name2 identifier.
Definition: cf_util.c:1171
CONF_ITEM * _cf_parent(CONF_ITEM const *ci)
Return the parent of a CONF_ITEM.
Definition: cf_util.c:541
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
Definition: cf_util.c:1112
void _cf_debug(CONF_ITEM const *ci)
Print out debugging information about a CONFIG_ITEM.
Definition: cf_util.c:2194
int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, char const *value)
Replace pair in a given section with a new pair, of the given value.
Definition: cf_util.c:1290
void _cf_item_add(CONF_ITEM *parent, CONF_ITEM *child)
Add a child.
Definition: cf_util.c:363
char const * cf_section_name(CONF_SECTION const *cs)
Return name2 if set, else name1.
Definition: cf_util.c:1138
void _cf_log(fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt,...))
Log an error message relating to a CONF_ITEM.
Definition: cf_util.c:1965
void _cf_log_perr_by_child(fr_log_type_t type, CONF_SECTION const *parent, char const *child, char const *file, int line, fr_log_perror_format_t const *f_rules, char const *fmt,...))
Log an error message in the context of a child pair of the specified parent.
Definition: cf_util.c:2170
CONF_PAIR * cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp)
Duplicate a CONF_PAIR.
Definition: cf_util.c:1261
CONF_ITEM * cf_data_to_item(CONF_DATA const *cs)
Cast CONF_DATA to a CONF_ITEM.
Definition: cf_util.c:719
void _cf_lineno_set(CONF_ITEM *cs, int lineno)
Set the line number of a CONF_ITEM.
Definition: cf_util.c:873
char const * cf_section_argv(CONF_SECTION const *cs, int argc)
Return variadic argument at the specified index.
Definition: cf_util.c:1154
CONF_DATA const * _cf_data_add_static(CONF_ITEM *ci, void const *data, char const *type, char const *name, char const *filename, int lineno)
Add non-talloced user data to a config section.
Definition: cf_util.c:1745
int(* cf_walker_t)(void *data, void *ctx)
Definition: cf_util.h:76
Test enumeration values.
Definition: dict_test.h:92
free(array)
fr_log_type_t
Definition: log.h:54
long int ssize_t
Definition: merged_model.c:24
ssize_t fr_slen_t
Definition: merged_model.c:35
static char const * name
fr_aka_sim_id_type_t type
An element in a lexicographically sorted array of name to num mappings.
Definition: table.h:45
enum fr_token fr_token_t
static fr_slen_t parent
Definition: pair.h:844
static fr_slen_t data
Definition: value.h:1259
int format(printf, 5, 0))
static size_t char ** out
Definition: value.h:984