From: Arran Cudbard-Bell Date: Tue, 15 Nov 2022 14:22:55 +0000 (-0600) Subject: Add type specific dcursors for value boxes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35af8696b62356a15c25d3768a0446f3f15c325f;p=thirdparty%2Ffreeradius-server.git Add type specific dcursors for value boxes Doesn't perform any refactoring, just defines the types --- diff --git a/src/lib/util/dcursor.c b/src/lib/util/dcursor.c index c1c2a1178f5..b54fca9beb8 100644 --- a/src/lib/util/dcursor.c +++ b/src/lib/util/dcursor.c @@ -31,8 +31,6 @@ RCSID("$Id$") #include #include -static void *fr_dcursor_intersect_next(fr_dcursor_t *a, fr_dcursor_t *b); - /** Return the first item matching the iterator in cursor a and cursor b * * If a and b are not currently set to the same item, b will be reset, @@ -46,7 +44,7 @@ static void *fr_dcursor_intersect_next(fr_dcursor_t *a, fr_dcursor_t *b); * * @hidecallergraph */ -static void *fr_dcursor_intersect_head(fr_dcursor_t *a, fr_dcursor_t *b) +void *fr_dcursor_intersect_head(fr_dcursor_t *a, fr_dcursor_t *b) { void *a_item, *b_item; @@ -75,7 +73,7 @@ static void *fr_dcursor_intersect_head(fr_dcursor_t *a, fr_dcursor_t *b) * * @hidecallergraph */ -static void *fr_dcursor_intersect_next(fr_dcursor_t *a, fr_dcursor_t *b) +void *fr_dcursor_intersect_next(fr_dcursor_t *a, fr_dcursor_t *b) { void *a_next, *b_next; diff --git a/src/lib/util/dcursor.h b/src/lib/util/dcursor.h index 8ede020d0aa..b686ce01a25 100644 --- a/src/lib/util/dcursor.h +++ b/src/lib/util/dcursor.h @@ -34,6 +34,7 @@ extern "C" { #include #include +DIAG_OFF(unused-function) typedef struct fr_dcursor_s fr_dcursor_t; /** Callback for implementing custom iterators @@ -184,6 +185,7 @@ static inline void *dcursor_next(fr_dcursor_t *cursor, fr_dcursor_iter_t iter, v * * @hidecallergraph */ +CC_HINT(nonnull) static inline void fr_dcursor_copy(fr_dcursor_t *out, fr_dcursor_t const *in) { memcpy(out, in, sizeof(*out)); @@ -785,6 +787,12 @@ static inline fr_dcursor_stack_t *fr_dcursor_stack_alloc(TALLOC_CTX *ctx, uint8_ return stack; } +void *fr_dcursor_intersect_head(fr_dcursor_t *a, fr_dcursor_t *b); + +void *fr_dcursor_intersect_next(fr_dcursor_t *a, fr_dcursor_t *b); + +DIAG_OFF(unused-function) + /** Expands to the type name used for the dcursor wrapper structure * * @param[in] _name Prefix we add to type-specific structures. @@ -905,6 +913,10 @@ DIAG_OFF(unused-function) \ \ static inline CC_HINT(nonnull) _element_type *_name ## _next(FR_DCURSOR(_name) *dcursor) \ { return (_element_type *)fr_dcursor_next(&dcursor->dcursor); } \ +\ + static inline CC_HINT(nonnull) void _name ## _copy(FR_DCURSOR(_name) *out, \ + FR_DCURSOR(_name) const *in) \ + { fr_dcursor_copy(&out->dcursor, &in->dcursor); } \ \ static inline CC_HINT(nonnull) _element_type *_name ## _head(FR_DCURSOR(_name) *dcursor) \ { return (_element_type *)fr_dcursor_head(&dcursor->dcursor); } \ @@ -938,10 +950,6 @@ DIAG_OFF(unused-function) \ static inline CC_HINT(nonnull) void _name ## _merge(FR_DCURSOR(_name) *cursor, \ FR_DCURSOR(_name) *to_append) \ { fr_dcursor_merge(&cursor->dcursor, &to_append->dcursor); } \ -\ - static inline CC_HINT(nonnull) void _name ## _copy(FR_DCURSOR(_name) *out, \ - FR_DCURSOR(_name) const *in) \ - { fr_dcursor_copy(&out->dcursor, &in->dcursor); } \ \ static inline CC_HINT(nonnull) void _name ## _free_list(FR_DCURSOR(_name) *dcursor) \ { fr_dcursor_free_list(&dcursor->dcursor); } \ diff --git a/src/lib/util/value.h b/src/lib/util/value.h index 47e973b9e6c..f24625dec2b 100644 --- a/src/lib/util/value.h +++ b/src/lib/util/value.h @@ -36,6 +36,7 @@ typedef struct value_box_s fr_value_box_t; #endif #include +#include #include #include #include @@ -45,9 +46,9 @@ typedef struct value_box_s fr_value_box_t; #include #include #include +#include #include #include -#include #ifdef __cplusplus extern "C" { @@ -85,7 +86,11 @@ extern fr_sbuff_escape_rules_t *fr_value_escape_by_char[UINT8_MAX + 1]; extern fr_sbuff_escape_rules_t fr_value_escape_unprintables; +/** @name List and cursor type definitions + */ FR_DLIST_TYPES(fr_value_box_list) +FR_DCURSOR_DLIST_TYPES(fr_value_box_dcursor, fr_value_box_list, fr_value_box_t) +/** @} */ /** Union containing all data types supported by the server * @@ -150,12 +155,17 @@ struct value_box_s { FR_DLIST_ENTRY(fr_value_box_list) entry; //!< Doubly linked list entry. }; +/** @name List and cursor function definitions + */ FR_DLIST_FUNCS(fr_value_box_list, fr_value_box_t, entry) #define fr_value_box_list_foreach(_list_head, _iter) fr_dlist_foreach(fr_value_box_list_dlist_head(_list_head), fr_value_box_t, _iter) #define fr_value_box_list_foreach_safe(_list_head, _iter) fr_dlist_foreach_safe(fr_value_box_list_dlist_head(_list_head), fr_value_box_t, _iter) #define fr_value_box_list_verify(_list_head) _fr_value_box_list_verify(__FILE__, __LINE__, _list_head) +FR_DCURSOR_FUNCS(fr_value_box_dcursor, fr_value_box_list, fr_value_box_t) +/** @} */ + /** Actions to perform when we process a box in a list * */ @@ -376,8 +386,6 @@ extern fr_sbuff_parse_rules_t const *value_parse_rules_quoted_char[UINT8_MAX]; * * @{ */ -#define fr_value_box_foreach(_v, _iv) for (fr_value_box_t *_iv = fr_dlist_head(_v); _iv; _iv = fr_dlist_next(_v, _iv)) - /** Determines whether a list contains the number of boxes required * * @param[in] list of value boxes.