]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add type specific dcursors for value boxes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 15 Nov 2022 14:22:55 +0000 (08:22 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 15 Nov 2022 14:22:55 +0000 (08:22 -0600)
Doesn't perform any refactoring, just defines the types

src/lib/util/dcursor.c
src/lib/util/dcursor.h
src/lib/util/value.h

index c1c2a1178f5a1fb067b1ade6fbb4779a4e737be0..b54fca9beb8aca1564ba60ac5304ac4c59cf4c59 100644 (file)
@@ -31,8 +31,6 @@ RCSID("$Id$")
 #include <freeradius-devel/util/dcursor.h>
 #include <freeradius-devel/util/pair.h>
 
-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;
 
index 8ede020d0aad33e8d0d1be651dc9719a1f8af006..b686ce01a25a2d1b8091a30b304385fc0557b610 100644 (file)
@@ -34,6 +34,7 @@ extern "C" {
 #include <stddef.h>
 #include <stdbool.h>
 
+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); } \
index 47e973b9e6c401af403d1037d51dcc3105e0ad94..f24625dec2b8e96645f11bcbcdf2db519422f155 100644 (file)
@@ -36,6 +36,7 @@ typedef struct value_box_s fr_value_box_t;
 #endif
 
 #include <freeradius-devel/build.h>
+#include <freeradius-devel/util/dcursor.h>
 #include <freeradius-devel/missing.h>
 #include <freeradius-devel/util/dbuff.h>
 #include <freeradius-devel/util/debug.h>
@@ -45,9 +46,9 @@ typedef struct value_box_s fr_value_box_t;
 #include <freeradius-devel/util/log.h>
 #include <freeradius-devel/util/strerror.h>
 #include <freeradius-devel/util/table.h>
+#include <freeradius-devel/util/time.h>
 #include <freeradius-devel/util/token.h>
 #include <freeradius-devel/util/types.h>
-#include <freeradius-devel/util/time.h>
 
 #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.