]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix dlist definition macros to be safer
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 17 Dec 2021 18:34:09 +0000 (12:34 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 17 Dec 2021 19:27:10 +0000 (13:27 -0600)
31 files changed:
src/bin/unit_test_map.c
src/include/build.h
src/lib/ldap/map.c
src/lib/redis/redis.c
src/lib/server/map.c
src/lib/server/map.h
src/lib/server/map_async.c
src/lib/server/pairmove.c
src/lib/server/tmpl_dcursor.c
src/lib/server/users_file.c
src/lib/unlang/compile.c
src/lib/unlang/edit.c
src/lib/unlang/map.c
src/lib/util/dlist.h
src/lib/util/pair.c
src/lib/util/pair.h
src/lib/util/strerror_tests.c
src/modules/rlm_attr_filter/rlm_attr_filter.c
src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c
src/modules/rlm_cache/rlm_cache.c
src/modules/rlm_cache/serialize.c
src/modules/rlm_client/rlm_client.c
src/modules/rlm_couchbase/rlm_couchbase.c
src/modules/rlm_csv/rlm_csv.c
src/modules/rlm_files/rlm_files.c
src/modules/rlm_json/rlm_json.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_radius/rlm_radius.c
src/modules/rlm_radius/rlm_radius_udp.c
src/modules/rlm_smtp/rlm_smtp.c
src/modules/rlm_sql/rlm_sql.c

index 34872a0edc36d391134bf4dbc8fccfd7b46513d3..3074e462b0fd25bbbf3c6d2fed6899848f55df05 100644 (file)
@@ -86,7 +86,7 @@ static int process_file(char const *filename)
                .allow_foreign = false, /* tests are in the RADIUS dictionary */
        };
 
-       fr_map_list_init(&list);
+       fr_dlist_map_init(&list);
        /*
         *      Must be called first, so the handler is called last
         */
@@ -122,7 +122,7 @@ static int process_file(char const *filename)
                cf_log_perr(cs, "map_afrom_cs failed");
                return EXIT_FAILURE; /* message already printed */
        }
-       if (fr_map_list_empty(&list)) {
+       if (fr_dlist_map_empty(&list)) {
                cf_log_err(cs, "'update' sections cannot be empty");
                return EXIT_FAILURE;
        }
@@ -141,7 +141,7 @@ static int process_file(char const *filename)
                printf("%s %s {\n", name1, name2);
        }
 
-       while ((map = fr_map_list_next(&list, map))) {
+       while ((map = fr_dlist_map_next(&list, map))) {
                map_print(&FR_SBUFF_OUT(buffer + 1, sizeof(buffer) - 1), map);
                puts(buffer);
        }
index e839468f51d6fcc2b946bff20ead23ba2f6f40ff..35784f04c253d96643db202ff82720be8855cde5 100644 (file)
@@ -255,17 +255,27 @@ do { \
  *
  * Expands to 1 if types are compatible, else 0.
  *
- * @param _x pointer to check.
- * @param _t type to check compatibility with.
+ * @param[in] _x pointer to check.
+ * @param[in] _t type to check compatibility with.
  */
 #define IS_COMPATIBLE(_x, _t) _Generic(_x, _t:1, default: 0)
 
+/** Check if a field in a struct is compatible (the C11 way)
+ *
+ * Expands to 1 if types are compatible, else 0.
+ *
+ * @param[in] _s struct to check.
+ * @param[in] _f field in struct.
+ * @param[in] _t type to check compatibility with.
+ */
+#define IS_FIELD_COMPATIBLE(_s, _f, _t) _Generic(((_s *)0)->_f, _t:1, default: 0)
+
 /*
  *     Only use GCC __attribute__ if were building with a GCClike
  *     compiler.
  */
 #ifdef __GNUC__
-#  define CC_HINT(...) __attribute__ ((__VA_ARGS__))
+#  define CC_HINT(...) __attribute__((__VA_ARGS__))
 #  define likely(_x)   __builtin_expect((_x), 1)
 #  define unlikely(_x) __builtin_expect((_x), 0)
 #else
index 6d76651d04336614a599cbb8f97f97fd54bcb20e..bba78ea3ce4f89a57d1b55c111be7960fcd2493f 100644 (file)
@@ -262,7 +262,7 @@ int fr_ldap_map_expand(fr_ldap_map_exp_t *expanded, request_t *request, fr_map_l
        char const      *attr;
        char            attr_buff[1024 + 1];    /* X.501 says we need to support at least 1024 chars for attr names */
 
-       while ((map = fr_map_list_next(maps, map))) {
+       while ((map = fr_dlist_map_next(maps, map))) {
                if (tmpl_expand(&attr, attr_buff, sizeof(attr_buff), request, map->rhs, NULL, NULL) < 0) {
                        REDEBUG("Expansion of LDAP attribute \"%s\" failed", map->rhs->name);
                        TALLOC_FREE(ctx);
@@ -314,7 +314,7 @@ int fr_ldap_map_do(request_t *request, LDAP *handle,
        fr_ldap_result_t        result;
        char const              *name;
 
-       while ((map = fr_map_list_next(expanded->maps, map))) {
+       while ((map = fr_dlist_map_next(expanded->maps, map))) {
                int ret;
 
                name = expanded->attrs[total++];
index d883648fb5bfdb969b7b1473fd882179eecb8c50..d714a03c71098bb3867da3dee1a2b19b0484630b 100644 (file)
@@ -425,7 +425,7 @@ int fr_redis_reply_to_map(TALLOC_CTX *ctx, fr_map_list_t *out, request_t *reques
        }
        MAP_VERIFY(map);
 
-       fr_map_list_insert_tail(out, map);
+       fr_dlist_map_insert_tail(out, map);
 
        return 0;
 }
index 5867864994346d3e031b39263901275ad8486e42..bff3c91945ea3b1314d117f716f0a10d6a8ed508 100644 (file)
@@ -69,7 +69,7 @@ static inline map_t *map_alloc(TALLOC_CTX *ctx, map_t *parent)
        }
        map->parent = parent;
 
-       fr_map_list_init(&map->child);
+       fr_dlist_map_init(&map->child);
        return map;
 }
 
@@ -624,7 +624,7 @@ check_for_child:
         *      caller will have to check for this!
         */
        if (is_child && parent) {
-               fr_map_list_insert_tail(&parent->child, map);
+               fr_dlist_map_insert_tail(&parent->child, map);
        }
 
        if (parent_p) *parent_p = new_parent;
@@ -718,7 +718,7 @@ static int _map_afrom_cs(TALLOC_CTX *ctx, fr_map_list_t *out, map_t *parent, CON
                         *      Free in reverse as successive entries have their
                         *      prececessors as talloc parent contexts
                         */
-                       fr_map_list_talloc_reverse_free(out);
+                       fr_dlist_map_talloc_reverse_free(out);
                        return -1;
                }
 
@@ -733,7 +733,7 @@ static int _map_afrom_cs(TALLOC_CTX *ctx, fr_map_list_t *out, map_t *parent, CON
                        bool qualifiers = our_lhs_rules.disallow_qualifiers;
                        fr_map_list_t child_list;
 
-                       fr_map_list_init(&child_list);
+                       fr_dlist_map_init(&child_list);
                        subcs = cf_item_to_section(ci);
                        token = cf_section_name2_quote(subcs);
 
@@ -806,11 +806,11 @@ static int _map_afrom_cs(TALLOC_CTX *ctx, fr_map_list_t *out, map_t *parent, CON
                         */
                        if (_map_afrom_cs(map, &child_list, map, cf_item_to_section(ci),
                                         &our_lhs_rules, rhs_rules, validate, uctx, max) < 0) {
-                               fr_map_list_talloc_free(&child_list);
+                               fr_dlist_map_talloc_free(&child_list);
                                talloc_free(map);
                                goto error;
                        }
-                       fr_map_list_move(&map->child, &child_list);
+                       fr_dlist_map_move(&map->child, &child_list);
 
                        our_lhs_rules.disallow_qualifiers = qualifiers;
                        MAP_VERIFY(map);
@@ -840,7 +840,7 @@ static int _map_afrom_cs(TALLOC_CTX *ctx, fr_map_list_t *out, map_t *parent, CON
 
        next:
                parent_ctx = map;
-               fr_map_list_insert_tail(out, map);
+               fr_dlist_map_insert_tail(out, map);
        }
 
        return 0;
@@ -1150,9 +1150,9 @@ int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t co
                MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
                n->op = map->op;
 
-               for (child = fr_map_list_next(&map->child, NULL);
+               for (child = fr_dlist_map_next(&map->child, NULL);
                     child != NULL;
-                    child = fr_map_list_next(&map->child, child)) {
+                    child = fr_dlist_map_next(&map->child, child)) {
                        fr_pair_list_t list;
 
                        /*
@@ -1947,7 +1947,7 @@ ssize_t map_print(fr_sbuff_t *out, map_t const *map)
         *      If there's no child and no RHS then the
         *      map was invalid.
         */
-       if (fr_map_list_empty(&map->child) && !fr_cond_assert(map->rhs != NULL)) {
+       if (fr_dlist_map_empty(&map->child) && !fr_cond_assert(map->rhs != NULL)) {
                fr_sbuff_terminate(out);
                return 0;
        }
index 0a2b70beb24bb0fcbc0e516df2288e69d2042078..de5f5471e8fbeb5f6d5e4a3465ddc5a6dff78cff 100644 (file)
@@ -39,6 +39,7 @@ typedef struct vp_list_mod_s vp_list_mod_t;
 
 #include <freeradius-devel/server/cf_util.h>
 #include <freeradius-devel/server/tmpl.h>
+#include <freeradius-devel/util/dlist.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -56,13 +57,12 @@ extern "C" {
        ['>'] = true, \
        ['~'] = true
 
-/** Value pair map list
+FR_DLIST_TYPES(map)
+
+/** Given these are used in so many places, it's more friendly to have a proper type
  *
- * Specifically define a type for lists of map_t to aid type checking
  */
-typedef struct {
-       fr_dlist_head_t head;
-} fr_map_list_t;
+typedef FR_DLIST_HEAD_TYPE(map) fr_map_list_t;
 
 /** Value pair map
  *
@@ -75,32 +75,32 @@ typedef struct {
  * @see tmpl_t
  */
 struct vp_map_s {
-       tmpl_t          *lhs;           //!< Typically describes the attribute to add, modify or compare.
-       tmpl_t          *rhs;           //!< Typically describes a literal value or a src attribute
-                                               ///< to copy or compare.
+       tmpl_t                          *lhs;           //!< Typically describes the attribute to add, modify or compare.
+       tmpl_t                          *rhs;           //!< Typically describes a literal value or a src attribute
+                                                       ///< to copy or compare.
 
-       fr_token_t              op;             //!< The operator that controls insertion of the dst attribute.
-       fr_type_t               cast;           //!< Cast value to this type.
+       fr_token_t                      op;             //!< The operator that controls insertion of the dst attribute.
+       fr_type_t                       cast;           //!< Cast value to this type.
 
-       CONF_ITEM               *ci;            //!< Config item that the map was created from. Mainly used for
-                                               //!< logging validation errors.
+       CONF_ITEM                       *ci;            //!< Config item that the map was created from. Mainly used for
+                                                       //!< logging validation errors.
 
-       map_t           *parent;        //! parent map, for nested ones
-       fr_map_list_t   child;          //!< a child map.  If it exists, `rhs` MUST be NULL
-       fr_dlist_t      entry;          //!< List entry.
+       map_t                           *parent;        //! parent map, for nested ones
+       fr_map_list_t                   child;          //!< a child map.  If it exists, `rhs` MUST be NULL
+       FR_DLIST_ENTRY_TYPE(map)        entry;          //!< List entry.
 };
 
-FR_DLIST_NEW_TYPE(map_list, fr_map_list_t, head, map_t, entry)
+FR_DLIST_FUNCS(map, map_t, entry)
 
 /** A list modification
  *
  */
 struct vp_list_mod_s {
-       map_t const             *map;           //!< Original map describing the change to be made.
+       map_t const                     *map;           //!< Original map describing the change to be made.
 
-       fr_map_list_t           mod;            //!< New map containing the destination (LHS) and
-                                               ///< values (RHS).
-       fr_dlist_t              entry;          //!< Entry into dlist
+       fr_map_list_t                   mod;            //!< New map containing the destination (LHS) and
+                                                       ///< values (RHS).
+       fr_dlist_t                      entry;          //!< Entry into dlist
 };
 
 #ifndef WITH_VERIFY_PTR
index 5b9f5320bb1daea8884108eb72bbdfde31e22a87..af430f81af54ac2d21f83c4f2bf2078aeb798a27 100644 (file)
@@ -46,7 +46,7 @@ static inline vp_list_mod_t *list_mod_alloc(TALLOC_CTX *ctx)
 {
        vp_list_mod_t *mod;
        mod = talloc_zero(ctx, vp_list_mod_t);
-       fr_map_list_init(&mod->mod);
+       fr_dlist_map_init(&mod->mod);
        return mod;
 }
 
@@ -54,7 +54,7 @@ static inline map_t *map_alloc(TALLOC_CTX *ctx)
 {
        map_t *map;
        map = talloc_zero(ctx, map_t);
-       fr_map_list_init(&map->child);
+       fr_dlist_map_init(&map->child);
        return map;
 }
 
@@ -92,7 +92,7 @@ static inline vp_list_mod_t *list_mod_generic_afrom_map(TALLOC_CTX *ctx,
                talloc_free(n);
                return NULL;
        }
-       fr_map_list_insert_tail(&n->mod, mod);
+       fr_dlist_map_insert_tail(&n->mod, mod);
 
        return n;
 }
@@ -134,7 +134,7 @@ static inline vp_list_mod_t *list_mod_delete_afrom_map(TALLOC_CTX *ctx,
                talloc_free(n);
                return NULL;
        }
-       fr_map_list_insert_tail(&n->mod, mod);
+       fr_dlist_map_insert_tail(&n->mod, mod);
 
        return n;
 }
@@ -194,7 +194,7 @@ static inline vp_list_mod_t *list_mod_empty_string_afrom_map(TALLOC_CTX *ctx,
                talloc_free(n);
                return NULL;
        }
-       fr_map_list_insert_tail(&n->mod, mod);
+       fr_dlist_map_insert_tail(&n->mod, mod);
 
        return n;
 }
@@ -361,7 +361,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                mod->lhs = mutated->lhs;
                mod->op = mutated->op;
                mod->rhs = mutated->rhs;
-               fr_map_list_insert_tail(&n->mod, mod);
+               fr_dlist_map_insert_tail(&n->mod, mod);
                goto finish;
        }
 
@@ -432,7 +432,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                         *      before this map is applied.
                         */
                        if (fr_value_box_copy(n_mod->rhs, tmpl_value(n_mod->rhs), &vp->data) < 0) goto error;
-                       fr_map_list_insert_tail(&n->mod, n_mod);
+                       fr_dlist_map_insert_tail(&n->mod, n_mod);
 
                        MAP_VERIFY(n_mod);
                } while ((vp = fr_pair_list_next(list, vp)));
@@ -455,8 +455,8 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
 
                fr_dcursor_init(&values, &head);
 
-               if (fr_value_box_from_str(fr_map_list_head(&n->mod),
-                                         tmpl_value(fr_map_list_head(&n->mod)->rhs), type,
+               if (fr_value_box_from_str(fr_dlist_map_head(&n->mod),
+                                         tmpl_value(fr_dlist_map_head(&n->mod)->rhs), type,
                                          tmpl_da(mutated->lhs),
                                          mutated->rhs->name, mutated->rhs->len,
                                          fr_value_unescape_by_quote[(uint8_t)mutated->rhs->quote], false)) {
@@ -511,7 +511,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                (void)fr_dcursor_init(&from, rhs_result);
                while ((vb = fr_dcursor_remove(&from))) {
                        if (vb->type != tmpl_da(mutated->lhs)->type) {
-                               n_vb = fr_value_box_alloc_null(fr_map_list_head(&n->mod)->rhs);
+                               n_vb = fr_value_box_alloc_null(fr_dlist_map_head(&n->mod)->rhs);
                                if (!n_vb) {
                                        fr_dcursor_head(&from);
                                        fr_dcursor_free_list(&from);
@@ -589,7 +589,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                vp = fr_dcursor_current(&from);
                fr_assert(vp);          /* Should have errored out */
                do {
-                       n_vb = fr_value_box_alloc_null(fr_map_list_head(&n->mod)->rhs);
+                       n_vb = fr_value_box_alloc_null(fr_dlist_map_head(&n->mod)->rhs);
                        if (!n_vb) {
                        attr_error:
                                fr_dcursor_head(&values);
@@ -629,7 +629,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
 
                vb = tmpl_value(mutated->rhs);
 
-               n_vb = fr_value_box_alloc_null(fr_map_list_head(&n->mod)->rhs);
+               n_vb = fr_value_box_alloc_null(fr_dlist_map_head(&n->mod)->rhs);
                if (!n_vb) {
                data_error:
                        fr_dcursor_head(&values);
@@ -756,7 +756,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                        }
 
                        mod->op = vp->op;
-                       fr_map_list_insert_tail(&n->mod, mod);
+                       fr_dlist_map_insert_tail(&n->mod, mod);
                }
 
        }
@@ -776,11 +776,11 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
         *      If tmpl_value were a pointer we could
         *      assign values directly.
         */
-       fr_value_box_copy(fr_map_list_head(&n->mod)->rhs, tmpl_value(fr_map_list_head(&n->mod)->rhs), fr_dlist_head(&head));
+       fr_value_box_copy(fr_dlist_map_head(&n->mod)->rhs, tmpl_value(fr_dlist_map_head(&n->mod)->rhs), fr_dlist_head(&head));
        /*
         *      value boxes in tmpls cannot now be the head of a list
         *
-        *tmpl_value(fr_map_list_head(&n->mod)->rhs)->next = head->next;
+        *tmpl_value(fr_dlist_map_head(&n->mod)->rhs)->next = head->next;
         */
        fr_dlist_talloc_free(&head);
 
@@ -826,13 +826,13 @@ static void map_list_mod_to_vps(TALLOC_CTX *ctx, fr_pair_list_t *list, vp_list_m
 {
        map_t   *mod;
 
-       fr_assert(!fr_map_list_empty(&vlm->mod));
+       fr_assert(!fr_dlist_map_empty(&vlm->mod));
 
        /*
         *      Fast path...
         */
-       mod = fr_map_list_head(&vlm->mod);
-       if (fr_map_list_num_elements(&vlm->mod) == 1) {
+       mod = fr_dlist_map_head(&vlm->mod);
+       if (fr_dlist_map_num_elements(&vlm->mod) == 1) {
                fr_pair_t *vp;
                vp = map_list_mod_to_vp(ctx, mod->lhs, tmpl_value(mod->rhs));
                fr_pair_append(list, vp);
@@ -844,7 +844,7 @@ static void map_list_mod_to_vps(TALLOC_CTX *ctx, fr_pair_list_t *list, vp_list_m
         */
        for (;
             mod;
-            mod = fr_map_list_next(&vlm->mod, mod)) {
+            mod = fr_dlist_map_next(&vlm->mod, mod)) {
                fr_pair_t       *vp;
 
                vp = map_list_mod_to_vp(ctx, mod->lhs, tmpl_value(mod->rhs));
@@ -956,12 +956,12 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm)
        memset(&cc, 0, sizeof(cc));
 
        MAP_VERIFY(map);
-       fr_assert(!fr_map_list_empty(&vlm->mod));
+       fr_assert(!fr_dlist_map_empty(&vlm->mod));
 
        /*
         *      Print debug information for the mods being applied
         */
-       while ((mod = fr_map_list_next(&vlm->mod, mod))) {
+       while ((mod = fr_dlist_map_next(&vlm->mod, mod))) {
                fr_value_box_t *vb;
 
                MAP_VERIFY(mod);
@@ -982,7 +982,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm)
                        map_list_mod_debug(request, map, mod, vb->type != FR_TYPE_NULL ? vb : NULL);
                }
        }
-       mod = fr_map_list_head(&vlm->mod);      /* Reset */
+       mod = fr_dlist_map_head(&vlm->mod);     /* Reset */
 
        /*
         *      All this has been checked by #map_to_list_mod
@@ -1082,7 +1082,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm)
                }
        }
 
-       fr_assert(!fr_map_list_next(&vlm->mod, mod));
+       fr_assert(!fr_dlist_map_next(&vlm->mod, mod));
 
        /*
         *      Find the destination attribute.  We leave with either
@@ -1141,7 +1141,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm)
                 *      any of these values.
                 */
                if (tmpl_num(map->lhs) != NUM_ALL) {
-                       fr_value_box_t  *vb = tmpl_value(fr_map_list_head(&vlm->mod)->rhs);
+                       fr_value_box_t  *vb = tmpl_value(fr_dlist_map_head(&vlm->mod)->rhs);
 
                        if (fr_value_box_cmp(vb, &found->data) == 0) {
                                fr_dcursor_free_item(&list);
@@ -1158,7 +1158,7 @@ int map_list_mod_apply(request_t *request, vp_list_mod_t const *vlm)
                 *      matches any of these values.
                 */
                do {
-                       fr_value_box_t  *vb = tmpl_value(fr_map_list_head(&vlm->mod)->rhs);
+                       fr_value_box_t  *vb = tmpl_value(fr_dlist_map_head(&vlm->mod)->rhs);
 
                        if (fr_value_box_cmp(vb, &found->data) == 0) {
                                fr_dcursor_free_item(&list);
index 9f217e4896a3ed44228b0668e1694953d19c5765..ae662b7a54dda660dd9b003f5ec39fe7ad1e0376 100644 (file)
@@ -145,7 +145,7 @@ void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *fro
                                RDEBUG4("::: OVERWRITING %s FROM %d TO %d",
                                       to_vp->da->name, i, j);
                                fr_pair_remove(from, from_vp);
-                               vp = fr_dlist_replace(&to->order, to_vp, from_vp);
+                               vp = fr_dlist_replace(&to->order.head, to_vp, from_vp);
                                talloc_free(vp);
                                from_vp = NULL;
                                edited[j] = true;
@@ -226,7 +226,7 @@ void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *fro
                                                RDEBUG4("::: REPLACING %s FROM %d TO %d",
                                                       from_vp->da->name, i, j);
                                                fr_pair_remove(from, from_vp);
-                                               vp = fr_dlist_replace(&to->order, to_vp, from_vp);
+                                               vp = fr_dlist_replace(&to->order.head, to_vp, from_vp);
                                                talloc_free(vp);
                                                from_vp = NULL;
                                                edited[j] = true;
@@ -239,7 +239,7 @@ void radius_pairmove(request_t *request, fr_pair_list_t *to, fr_pair_list_t *fro
                                                RDEBUG4("::: REPLACING %s FROM %d TO %d",
                                                       from_vp->da->name, i, j);
                                                fr_pair_remove(from, from_vp);
-                                               vp = fr_dlist_replace(&to->order, to_vp, from_vp);
+                                               vp = fr_dlist_replace(&to->order.head, to_vp, from_vp);
                                                talloc_free(vp);
                                                from_vp = NULL;
                                                edited[j] = true;
index 6a0b02cd20bf4044e33a23370601cbc907b0725b..2b1e10f68425d49f58271f4688d2022a109b1582 100644 (file)
@@ -587,7 +587,7 @@ int tmpl_extents_find(TALLOC_CTX *ctx,
 
                list_ctx = ns->list_ctx;
                ar = ns->ar;
-               curr = _tmpl_cursor_eval(&list_head->order, curr, &cc);
+               curr = _tmpl_cursor_eval(&list_head->order.head, curr, &cc);
                if (!curr) {
                        /*
                         *      References extend beyond current
index d2df206d9d0c9ce188b5174f6ae7c3f5fe05900a..24ba80c20d81d8979a08a602ebe722f1f995c3d8 100644 (file)
@@ -365,8 +365,8 @@ int pairlist_read(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR
                 *      We MUST be either at a valid entry, OR at EOF.
                 */
                MEM(t = talloc_zero(ctx, PAIR_LIST));
-               fr_map_list_init(&t->check);
-               fr_map_list_init(&t->reply);
+               fr_dlist_map_init(&t->check);
+               fr_dlist_map_init(&t->reply);
                t->filename = filename;
                t->lineno = lineno;
                t->order = order++;
@@ -470,7 +470,7 @@ check_item:
 
        do_insert:
                fr_assert(!new_map->parent);
-               fr_map_list_insert_tail(&t->check, new_map);
+               fr_dlist_map_insert_tail(&t->check, new_map);
 
                /*
                 *      There can be spaces before any comma.
@@ -646,7 +646,7 @@ next_reply_item:
 
                fr_assert(tmpl_list(new_map->lhs) == PAIR_LIST_REPLY);
 
-               if (!new_map->parent) fr_map_list_insert_tail(&t->reply, new_map);
+               if (!new_map->parent) fr_dlist_map_insert_tail(&t->reply, new_map);
 
                (void) fr_sbuff_adv_past_blank(&sbuff, SIZE_MAX, NULL);
 
index e41aa96d9cbc1d73ed1d8d4cf1a9b9c26924360b..1b15519902e50f131d5a6fe221f7735373fcf9c8 100644 (file)
@@ -591,7 +591,7 @@ static bool pass2_fixup_map(map_t *map, tmpl_rules_t const *rules, fr_dict_attr_
        /*
         *      Sanity check sublists.
         */
-       if (!fr_map_list_empty(&map->child)) {
+       if (!fr_dlist_map_empty(&map->child)) {
                fr_dict_attr_t const *da;
 
                if (!tmpl_is_attr(map->lhs)) {
@@ -611,7 +611,7 @@ static bool pass2_fixup_map(map_t *map, tmpl_rules_t const *rules, fr_dict_attr_
                        return false;
                }
 
-               return pass2_fixup_map(fr_map_list_head(&map->child), rules, da);
+               return pass2_fixup_map(fr_dlist_map_head(&map->child), rules, da);
        }
 
        return true;
@@ -627,7 +627,7 @@ static bool pass2_fixup_update(unlang_group_t *g, tmpl_rules_t const *rules)
 
        RULES_VERIFY(rules);
 
-       while ((map = fr_map_list_next(&gext->map, map))) {
+       while ((map = fr_dlist_map_next(&gext->map, map))) {
                /*
                 *      Mostly fixup the map, but maybe leave the RHS
                 *      unresolved.
@@ -660,7 +660,7 @@ static bool pass2_fixup_map_rhs(unlang_group_t *g, tmpl_rules_t const *rules)
         *      the RHS as a reference to a json string, SQL column
         *      name, etc.
         */
-       while ((map = fr_map_list_next(&gext->map, map))) {
+       while ((map = fr_dlist_map_next(&gext->map, map))) {
                if (!pass2_fixup_map(map, rules, NULL)) return false;
        }
 
@@ -669,7 +669,7 @@ static bool pass2_fixup_map_rhs(unlang_group_t *g, tmpl_rules_t const *rules)
         */
        if (!gext->vpt) return true;
 
-       return pass2_fixup_tmpl(fr_map_list_head(&gext->map)->ci, &gext->vpt,
+       return pass2_fixup_tmpl(fr_dlist_map_head(&gext->map)->ci, &gext->vpt,
                                cf_section_to_item(g->cs), rules->dict_def);
 }
 
@@ -709,7 +709,7 @@ static void unlang_dump(unlang_t *instruction, int depth)
                        g = unlang_generic_to_group(c);
                        gext = unlang_group_to_map(g);
                        map = NULL;
-                       while ((map = fr_map_list_next(&gext->map, map))) {
+                       while ((map = fr_dlist_map_next(&gext->map, map))) {
                                map_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map);
                                DEBUG("%.*s%s", depth + 1, unlang_spaces, buffer);
                        }
@@ -724,7 +724,7 @@ static void unlang_dump(unlang_t *instruction, int depth)
 
                        edit = unlang_generic_to_edit(c);
                        map = NULL;
-                       while ((map = fr_map_list_next(&edit->maps, map))) {
+                       while ((map = fr_dlist_map_next(&edit->maps, map))) {
                                map_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map);
                                DEBUG("%.*s%s", depth + 1, unlang_spaces, buffer);
                        }
@@ -1384,10 +1384,10 @@ static unlang_t *compile_map(unlang_t *parent, unlang_compile_t *unlang_ctx, CON
        /*
         *      This looks at cs->name2 to determine which list to update
         */
-       fr_map_list_init(&gext->map);
+       fr_dlist_map_init(&gext->map);
        rcode = map_afrom_cs(gext, &gext->map, cs, &t_rules, &t_rules, unlang_fixup_map, NULL, 256);
        if (rcode < 0) return NULL; /* message already printed */
-       if (fr_map_list_empty(&gext->map)) {
+       if (fr_dlist_map_empty(&gext->map)) {
                cf_log_err(cs, "'map' sections cannot be empty");
                goto error;
        }
@@ -1456,10 +1456,10 @@ static unlang_t *compile_update(unlang_t *parent, unlang_compile_t *unlang_ctx,
        /*
         *      This looks at cs->name2 to determine which list to update
         */
-       fr_map_list_init(&gext->map);
+       fr_dlist_map_init(&gext->map);
        rcode = map_afrom_cs(gext, &gext->map, cs, &t_rules, &t_rules, unlang_fixup_update, NULL, 128);
        if (rcode < 0) return NULL; /* message already printed */
-       if (fr_map_list_empty(&gext->map)) {
+       if (fr_dlist_map_empty(&gext->map)) {
                cf_log_err(cs, "'update' sections cannot be empty");
        error:
                talloc_free(g);
@@ -1515,10 +1515,10 @@ static unlang_t *compile_filter(unlang_t *parent, unlang_compile_t *unlang_ctx,
        /*
         *      This looks at cs->name2 to determine which list to update
         */
-       fr_map_list_init(&gext->map);
+       fr_dlist_map_init(&gext->map);
        rcode = map_afrom_cs(gext, &gext->map, cs, &t_rules, &t_rules, unlang_fixup_filter, NULL, 128);
        if (rcode < 0) return NULL; /* message already printed */
-       if (fr_map_list_empty(&gext->map)) {
+       if (fr_dlist_map_empty(&gext->map)) {
                cf_log_err(cs, "'filter' sections cannot be empty");
                return NULL;
        }
@@ -1684,7 +1684,7 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang
                c->debug_name = c->name;
                c->type = UNLANG_TYPE_EDIT;
 
-               fr_map_list_init(&edit->maps);
+               fr_dlist_map_init(&edit->maps);
                edit_free = edit;
 
                compile_action_defaults(c, unlang_ctx);
@@ -1696,7 +1696,7 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang
        MEM(map = talloc_zero(parent, map_t));
        map->op = op;
        map->ci = cf_section_to_item(cs);
-       fr_map_list_init(&map->child);
+       fr_dlist_map_init(&map->child);
 
        name = cf_section_name1(cs);
 
@@ -1732,7 +1732,7 @@ static unlang_t *compile_edit_section(unlang_t *parent, unlang_compile_t *unlang
         */
 //     if (unlang_fixup_update(map, NULL) < 0) goto fail;
 
-       fr_map_list_insert_tail(&edit->maps, map);
+       fr_dlist_map_insert_tail(&edit->maps, map);
 
        *prev = c;
        return out;
@@ -1776,7 +1776,7 @@ static unlang_t *compile_edit_pair(unlang_t *parent, unlang_compile_t *unlang_ct
                c->debug_name = c->name;
                c->type = UNLANG_TYPE_EDIT;
 
-               fr_map_list_init(&edit->maps);
+               fr_dlist_map_init(&edit->maps);
                edit_free = edit;
 
                compile_action_defaults(c, unlang_ctx);
@@ -1785,7 +1785,7 @@ static unlang_t *compile_edit_pair(unlang_t *parent, unlang_compile_t *unlang_ct
        /*
         *      Convert this particular map.
         */
-       if (map_afrom_cp(edit, &map, fr_map_list_tail(&edit->maps), cp, &t_rules, &t_rules) < 0) {
+       if (map_afrom_cp(edit, &map, fr_dlist_map_tail(&edit->maps), cp, &t_rules, &t_rules) < 0) {
        fail:
                talloc_free(edit_free);
                return NULL;
@@ -1802,7 +1802,7 @@ static unlang_t *compile_edit_pair(unlang_t *parent, unlang_compile_t *unlang_ct
         */
        if (unlang_fixup_update(map, NULL) < 0) goto fail;
 
-       fr_map_list_insert_tail(&edit->maps, map);
+       fr_dlist_map_insert_tail(&edit->maps, map);
 
        *prev = c;
        return out;
index e2715a60197afa0d51557ae280e1ebf7fa2faaf0..1dce9d89c6e90953663425227062e246863720d9 100644 (file)
@@ -488,7 +488,7 @@ static int expand_rhs_list(NDEBUG_UNUSED unlang_frame_state_edit_t *state, reque
                return -1;
        }
 
-       if (!fr_map_list_empty(&map->child)) {
+       if (!fr_dlist_map_empty(&map->child)) {
                REDEBUG("In-place lists not yet implemented");
                return -1;
        }
@@ -519,7 +519,7 @@ static unlang_action_t process_edit(rlm_rcode_t *p_result, request_t *request, u
         */
        for (map = state->map;
             map != NULL;
-            map = state->map = fr_map_list_next(state->map_head, map)) {
+            map = state->map = fr_dlist_map_next(state->map_head, map)) {
                repeatable_set(frame);  /* Call us again when done */
 
                switch (state->state) {
@@ -663,10 +663,10 @@ static unlang_action_t unlang_edit_state_init(rlm_rcode_t *p_result, request_t *
         *      The edit list creates a local pool which should
         *      generally be large enough for most edits.
         */
-       MEM(state->el = fr_edit_list_alloc(state, fr_map_list_num_elements(&edit->maps)));
+       MEM(state->el = fr_edit_list_alloc(state, fr_dlist_map_num_elements(&edit->maps)));
 
        state->map_head = &edit->maps;
-       state->map = fr_map_list_head(state->map_head);
+       state->map = fr_dlist_map_head(state->map_head);
        fr_pair_list_init(&state->rhs.pair_list);
 
        /*
index 851e1ea426711b353918562e1ad7ba32ed0d403c..612017bb9c7820f34dec7b29be8977db2ff702fe 100644 (file)
@@ -271,7 +271,7 @@ static unlang_action_t unlang_update_state_init(rlm_rcode_t *p_result, request_t
                                                                    (sizeof(tmpl_t) * 2) + 128),
                                                                    g->num_children));  /* 128 is for string buffers */
 
-       fr_dcursor_init(&update_state->maps, fr_map_list_dlist_head(&gext->map));
+       fr_dcursor_init(&update_state->maps, &gext->map.head);
        fr_value_box_list_init(&update_state->lhs_result);
        fr_value_box_list_init(&update_state->rhs_result);
        fr_dlist_init(&update_state->vlm_head, vp_list_mod_t, entry);
index 22ce085125e798c7f8c66ec6d01426b861bcd2ab..76aaeccd71f5978c99af59c6fe8c4dd6ca900592 100644 (file)
@@ -1047,97 +1047,126 @@ static inline void fr_dlist_sort(fr_dlist_head_t *list, fr_cmp_t cmp)
        }
 }
 
-/*
- *  Hang onto your hats.  This gets weird.
+/** Expands to the type name used for the entry wrapper structure
+ *
+ * @param[in] _name    Prefix we add to type-specific structures.
+ * @return fr_dlist_<name>_entry_t
  */
-#define FR_DLIST_NEW_TYPE(_name, _list_type, _member_head, _entry_type, _member) \
+#define FR_DLIST_ENTRY_TYPE(_name) fr_dlist_ ## _name ## _entry_t
+
+/** Expands to the type name used for the head wrapper structure
+ *
+ * @param[in] _name    Prefix we add to type-specific structures.
+ * @return fr_dlist_<name>_head_t
+ */
+#define FR_DLIST_HEAD_TYPE(_name) fr_dlist_ ## _name ## _head_t
+
+/** Define type specific wrapper structs for dlists
+ *
+ * @note This macro should be used inside the header for the area of code
+ * which will use type specific functions.
+ */
+#define FR_DLIST_TYPES(_name) \
+       typedef struct { fr_dlist_t entry; } FR_DLIST_ENTRY_TYPE(_name); \
+       typedef struct { fr_dlist_head_t head; } FR_DLIST_HEAD_TYPE(_name); \
+
+/** Define type specific wrapper functions for dlists
+ *
+ * @note This macro should be used inside the source file that will use
+ * the type specific functions.
+ *
+ * @param[in] _name            Prefix we add to type-specific dlist functions.
+ * @param[in] _element_type    Type of structure that'll be inserted into the dlist.
+ * @param[in] _element_entry   Field in the _element_type that holds the dlist entry information.
+ */
+#define FR_DLIST_FUNCS(_name, _element_type, _element_entry) \
 DIAG_OFF(unused-function) \
-       static inline   fr_dlist_head_t *fr_ ## _name ## _dlist_head(_list_type *list) \
-               {  return &list->_member_head; } \
-\
-       static inline   void fr_ ## _name ## _entry_init(_entry_type *entry) \
-               {                    fr_dlist_entry_init(&entry->_member); } \
+       _Static_assert(IS_FIELD_COMPATIBLE(_element_type, _element_entry, FR_DLIST_ENTRY_TYPE(_name)) == 1, "Bad dlist entry field type");\
+       static inline   fr_dlist_head_t *fr_dlist_ ## _name ## _list_head(FR_DLIST_HEAD_TYPE(_name) const *list) \
+               { return        UNCONST(fr_dlist_head_t *, &list->head); } \
+       static inline   void fr_dlist_ ## _name ## _entry_init(_element_type *entry) \
+               {               fr_dlist_entry_init(&entry->_element_entry.entry); } \
 \
-       static inline   void fr_ ## _name ## _init(_list_type *list) \
-               {                          _fr_dlist_init(&list->_member_head, offsetof(_entry_type, _member), NULL); } \
+       static inline   void fr_dlist_ ## _name ## _init(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               _fr_dlist_init(&list->head, offsetof(_element_type, _element_entry), NULL); } \
 \
-       static inline   void fr_ ## _name ## _talloc_init(_list_type *list) \
-               {                          _fr_dlist_init(&list->_member_head, offsetof(_entry_type, _member), #_entry_type); } \
+       static inline   void fr_dlist_ ## _name ## _talloc_init(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               _fr_dlist_init(&list->head, offsetof(_element_type, _element_entry), #_element_type); } \
 \
-       static inline   void fr_ ## _name ## _clear(_list_type *list) \
-               {                    fr_dlist_clear(&list->_member_head); } \
+       static inline   void fr_dlist_ ## _name ## _clear(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               fr_dlist_clear(&list->head); } \
 \
-       static inline   bool fr_ ## _name ## _in_list(_list_type *list, _entry_type *ptr) \
-               { return             fr_dlist_in_list(&list->_member_head, ptr); } \
+       static inline   bool fr_dlist_ ## _name ## _in_list(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+               { return        fr_dlist_in_list(&list->head, ptr); } \
 \
-       static inline   int fr_ ## _name ## _insert_head(_list_type *list, _entry_type *ptr) \
-               { return            fr_dlist_insert_head(&list->_member_head, ptr); } \
+       static inline   int fr_dlist_ ## _name ## _insert_head(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+               { return        fr_dlist_insert_head(&list->head, ptr); } \
 \
-       static inline   int fr_ ## _name ## _insert_tail(_list_type *list, _entry_type *ptr) \
-               { return            fr_dlist_insert_tail(&list->_member_head, ptr); } \
+       static inline   int fr_dlist_ ## _name ## _insert_tail(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+               { return        fr_dlist_insert_tail(&list->head, ptr); } \
 \
-       static inline   int fr_ ## _name ## _insert_after(_list_type *list, _entry_type *pos, _entry_type *ptr) \
-               { return            fr_dlist_insert_after(&list->_member_head, pos, ptr); } \
+       static inline   int fr_dlist_ ## _name ## _insert_after(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *pos, _element_type *ptr) \
+               { return        fr_dlist_insert_after(&list->head, pos, ptr); } \
 \
-       static inline   int fr_ ## _name ## _insert_before(_list_type *list, _entry_type *pos, _entry_type *ptr) \
-               { return            fr_dlist_insert_before(&list->_member_head, pos, ptr); } \
+       static inline   int fr_dlist_ ## _name ## _insert_before(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *pos, _element_type *ptr) \
+               { return        fr_dlist_insert_before(&list->head, pos, ptr); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _head(_list_type const *list) \
-               { return                     fr_dlist_head(&list->_member_head); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _head(FR_DLIST_HEAD_TYPE(_name) const *list) \
+               { return        fr_dlist_head(&list->head); } \
 \
-       static inline   bool fr_ ## _name ## _empty(_list_type const *list) \
-               { return             fr_dlist_empty(&list->_member_head); } \
+       static inline   bool fr_dlist_ ## _name ## _empty(FR_DLIST_HEAD_TYPE(_name) const *list) \
+               { return        fr_dlist_empty(&list->head); } \
 \
-       static inline   bool fr_ ## _name ## _initialised(_list_type const *list) \
-               { return            fr_dlist_initialised(&list->_member_head); } \
+       static inline   bool fr_dlist_ ## _name ## _initialised(FR_DLIST_HEAD_TYPE(_name) const *list) \
+               { return        fr_dlist_initialised(&list->head); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _tail(_list_type const *list) \
-               { return                     fr_dlist_tail(&list->_member_head); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _tail(FR_DLIST_HEAD_TYPE(_name) const *list) \
+               { return        fr_dlist_tail(&list->head); } \
 \
-       static inline _entry_type *fr_ ## _name ## _next(_list_type const *list, _entry_type const *ptr) \
-               { return                   fr_dlist_next(&list->_member_head, ptr); } \
+       static inline _element_type *fr_dlist_ ## _name ## _next(FR_DLIST_HEAD_TYPE(_name) const *list, _element_type const *ptr) \
+               { return        fr_dlist_next(&list->head, ptr); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _prev(_list_type const *list, _entry_type const *ptr) \
-               { return                     fr_dlist_prev(&list->_member_head, ptr); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _prev(FR_DLIST_HEAD_TYPE(_name) const *list, _element_type const *ptr) \
+               { return        fr_dlist_prev(&list->head, ptr); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _remove(_list_type *list, _entry_type *ptr) \
-               { return                     fr_dlist_remove(&list->_member_head, ptr); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _remove(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+               { return        fr_dlist_remove(&list->head, ptr); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _pop_head(_list_type *list) \
-               { return                     fr_dlist_pop_head(&list->_member_head); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _pop_head(FR_DLIST_HEAD_TYPE(_name) *list) \
+               { return        fr_dlist_pop_head(&list->head); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _pop_tail(_list_type *list) \
-               { return                     fr_dlist_pop_tail(&list->_member_head); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _pop_tail(FR_DLIST_HEAD_TYPE(_name) *list) \
+               { return        fr_dlist_pop_tail(&list->head); } \
 \
-       static inline   _entry_type *fr_ ## _name ## _replace(_list_type *list, _entry_type *item, _entry_type *ptr) \
-               { return                     fr_dlist_replace(&list->_member_head, item, ptr); } \
+       static inline   _element_type *fr_dlist_ ## _name ## _replace(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *item, _element_type *ptr) \
+               { return        fr_dlist_replace(&list->head, item, ptr); } \
 \
-       static inline   int fr_ ## _name ## _move(_list_type *dst, _list_type *src) \
-               { return            fr_dlist_move(&dst->_member_head, &src->_member_head); } \
+       static inline   int fr_dlist_ ## _name ## _move(FR_DLIST_HEAD_TYPE(_name) *dst, FR_DLIST_HEAD_TYPE(_name) *src) \
+               { return        fr_dlist_move(&dst->head, &src->head); } \
 \
-       static inline   int fr_ ## _name ## _move_head(_list_type *dst, _list_type *src) \
-               { return            fr_dlist_move_head(&dst->_member_head, &src->_member_head); } \
+       static inline   int fr_dlist_ ## _name ## _move_head(FR_DLIST_HEAD_TYPE(_name) *dst, FR_DLIST_HEAD_TYPE(_name) *src) \
+               { return        fr_dlist_move_head(&dst->head, &src->head); } \
 \
-       static inline   void fr_ ## _name ## _talloc_free_head(_list_type *list) \
-               {                    fr_dlist_talloc_free_head(&list->_member_head); } \
+       static inline   void fr_dlist_ ## _name ## _talloc_free_head(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               fr_dlist_talloc_free_head(&list->head); } \
 \
-       static inline   void fr_ ## _name ## _talloc_free_tail(_list_type *list) \
-               {                    fr_dlist_talloc_free_tail(&list->_member_head); } \
+       static inline   void fr_dlist_ ## _name ## _talloc_free_tail(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               fr_dlist_talloc_free_tail(&list->head); } \
 \
-       static inline   void fr_ ## _name ## _talloc_free_item(_list_type *list, _entry_type *ptr) \
-               {                    fr_dlist_talloc_free_item(&list->_member_head, ptr); } \
+       static inline   void fr_dlist_ ## _name ## _talloc_free_item(FR_DLIST_HEAD_TYPE(_name) *list, _element_type *ptr) \
+               {               fr_dlist_talloc_free_item(&list->head, ptr); } \
 \
-       static inline   void fr_ ## _name ## _talloc_free(_list_type *list) \
-               {                    fr_dlist_talloc_free(&list->_member_head); } \
+       static inline   void fr_dlist_ ## _name ## _talloc_free(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               fr_dlist_talloc_free(&list->head); } \
 \
-       static inline   void fr_ ## _name ## _talloc_reverse_free(_list_type *list) \
-               {                    fr_dlist_talloc_reverse_free(&list->_member_head); } \
+       static inline   void fr_dlist_ ## _name ## _talloc_reverse_free(FR_DLIST_HEAD_TYPE(_name) *list) \
+               {               fr_dlist_talloc_reverse_free(&list->head); } \
 \
-       static inline   unsigned int fr_ ## _name ## _num_elements(_list_type const *list) \
-               { return                     fr_dlist_num_elements(&list->_member_head); } \
+       static inline   unsigned int fr_dlist_ ## _name ## _num_elements(FR_DLIST_HEAD_TYPE(_name) const *list) \
+               { return        fr_dlist_num_elements(&list->head); } \
 \
-       static inline   void fr_ ## _name ## _sort(_list_type *list, fr_cmp_t cmp) \
-               {                    fr_dlist_sort(&list->_member_head, cmp); } \
+       static inline   void fr_dlist_ ## _name ## _sort(FR_DLIST_HEAD_TYPE(_name) *list, fr_cmp_t cmp) \
+               {               fr_dlist_sort(&list->head, cmp); } \
 DIAG_ON(unused-function)
 
 
index 546ebbca5b93415735f6506266c7963d5befb86d..b298775cac239ef21b129aed73a660ac9baad7c6 100644 (file)
@@ -32,7 +32,7 @@ RCSID("$Id$")
 #include <freeradius-devel/util/proto.h>
 #include <freeradius-devel/util/regex.h>
 
-FR_DLIST_NEW_TYPE(pair_dlist, fr_pair_list_t, order, fr_pair_t, order_entry)
+FR_DLIST_FUNCS(pair, fr_pair_t, order_entry)
 
 /** Initialise a pair list header
  *
@@ -46,7 +46,7 @@ void fr_pair_list_init(fr_pair_list_t *list)
         *      in the list and allows us to iterate over
         *      all of them.
         */
-       fr_pair_dlist_talloc_init(list);
+       fr_dlist_pair_talloc_init(&list->order);
 }
 
 /** Free a fr_pair_t
@@ -107,13 +107,12 @@ fr_pair_list_t *fr_pair_list_alloc(TALLOC_CTX *ctx)
  */
 static inline CC_HINT(always_inline) void pair_init_null(fr_pair_t *vp)
 {
-       fr_pair_dlist_entry_init(vp);
+       fr_dlist_pair_entry_init(vp);
 
        /*
         *      Legacy cruft
         */
        vp->op = T_OP_EQ;
-       vp->type = VT_DATA;
 }
 
 /** Dynamically allocate a new attribute with no #fr_dict_attr_t assigned
@@ -406,7 +405,6 @@ fr_pair_t *fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
        if (!n) return NULL;
 
        n->op = vp->op;
-       n->type = vp->type;
        /*
         *      Copy the unknown attribute hierarchy
         */
@@ -467,7 +465,7 @@ int fr_pair_steal(TALLOC_CTX *ctx, fr_pair_t *vp)
  */
 int fr_pair_steal_append(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
 {
-       if (fr_pair_dlist_in_list(list, vp)) {
+       if (fr_dlist_pair_in_list(&list->order, vp)) {
                fr_strerror_printf("Pair %pV is a list member, cannot be moved", vp);
                return -1;
        }
@@ -490,7 +488,7 @@ int fr_pair_steal_append(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *
  */
 int fr_pair_steal_prepend(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
 {
-       if (fr_pair_dlist_in_list(list, vp)) {
+       if (fr_dlist_pair_in_list(&list->order, vp)) {
                fr_strerror_printf("Pair %pV is a list member, cannot be moved", vp);
                return -1;
        }
@@ -510,7 +508,7 @@ int fr_pair_steal_prepend(TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t
  */
 void fr_pair_list_free(fr_pair_list_t *list)
 {
-       fr_pair_dlist_talloc_free(list);
+       fr_dlist_pair_talloc_free(&list->order);
 }
 
 /** Is a valuepair list empty
@@ -522,7 +520,7 @@ void fr_pair_list_free(fr_pair_list_t *list)
  */
 bool fr_pair_list_empty(fr_pair_list_t const *list)
 {
-       return fr_pair_dlist_empty(list);
+       return fr_dlist_pair_empty(&list->order);
 }
 
 /** Mark malformed or unrecognised attributed as unknown
@@ -611,9 +609,9 @@ unsigned int fr_pair_count_by_da(fr_pair_list_t const *list, fr_dict_attr_t cons
        fr_pair_t       *vp = NULL;
        unsigned int    count = 0;
 
-       if (fr_pair_dlist_empty(list)) return 0;
+       if (fr_dlist_pair_empty(&list->order)) return 0;
 
-       while ((vp = fr_pair_dlist_next(list, vp))) if (da == vp->da) count++;
+       while ((vp = fr_dlist_pair_next(&list->order, vp))) if (da == vp->da) count++;
 
        return count;
 }
@@ -633,11 +631,11 @@ fr_pair_t *fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev,
 {
        fr_pair_t *vp = UNCONST(fr_pair_t *, prev);
 
-       if (fr_pair_dlist_empty(list)) return NULL;
+       if (fr_dlist_pair_empty(&list->order)) return NULL;
 
        PAIR_LIST_VERIFY(list);
 
-       while ((vp = fr_pair_dlist_next(list, vp))) if (da == vp->da) return vp;
+       while ((vp = fr_dlist_pair_next(&list->order, vp))) if (da == vp->da) return vp;
 
        return NULL;
 }
@@ -657,7 +655,7 @@ fr_pair_t *fr_pair_find_by_da_idx(fr_pair_list_t const *list, fr_dict_attr_t con
 {
        fr_pair_t *vp = NULL;
 
-       if (fr_pair_dlist_empty(list)) return NULL;
+       if (fr_dlist_pair_empty(&list->order)) return NULL;
 
        PAIR_LIST_VERIFY(list);
 
@@ -738,7 +736,7 @@ fr_pair_t *fr_pair_find_by_child_num(fr_pair_list_t const *list, fr_pair_t const
        fr_dict_attr_t const    *da;
 
        /* List head may be NULL if it contains no VPs */
-       if (fr_pair_dlist_empty(list)) return NULL;
+       if (fr_dlist_pair_empty(&list->order)) return NULL;
 
        PAIR_LIST_VERIFY(list);
 
@@ -764,7 +762,7 @@ fr_pair_t *fr_pair_find_by_child_num_idx(fr_pair_list_t const *list,
        fr_dict_attr_t const    *da;
 
        /* List head may be NULL if it contains no VPs */
-       if (fr_pair_dlist_empty(list)) return NULL;
+       if (fr_dlist_pair_empty(&list->order)) return NULL;
 
        PAIR_LIST_VERIFY(list);
 
@@ -842,7 +840,7 @@ fr_pair_t *_fr_pair_dcursor_iter_init(fr_dcursor_t *cursor, fr_pair_list_t const
                                      fr_dcursor_iter_t iter, void const *uctx,
                                      bool is_const)
 {
-       return _fr_dcursor_init(cursor, &list->order,
+       return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
                                iter, uctx,
                                _pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
 }
@@ -863,7 +861,7 @@ fr_pair_t *_fr_pair_dcursor_iter_init(fr_dcursor_t *cursor, fr_pair_list_t const
 fr_pair_t *_fr_pair_dcursor_init(fr_dcursor_t *cursor, fr_pair_list_t const *list,
                                 bool is_const)
 {
-       return _fr_dcursor_init(cursor, &list->order,
+       return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
                                NULL, NULL,
                                _pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
 }
@@ -883,7 +881,7 @@ fr_pair_t *_fr_pair_dcursor_by_da_init(fr_dcursor_t *cursor,
                                        fr_pair_list_t const *list, fr_dict_attr_t const *da,
                                        bool is_const)
 {
-       return _fr_dcursor_init(cursor, &list->order,
+       return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
                                fr_pair_iter_next_by_da, da,
                                _pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
 }
@@ -902,7 +900,7 @@ fr_pair_t *_fr_pair_dcursor_by_ancestor_init(fr_dcursor_t *cursor,
                                             fr_pair_list_t const *list, fr_dict_attr_t const *da,
                                             bool is_const)
 {
-       return _fr_dcursor_init(cursor, &list->order,
+       return _fr_dcursor_init(cursor, fr_dlist_pair_list_head(&list->order),
                                fr_pair_iter_next_by_ancestor, da,
                                _pair_list_dcursor_insert, _pair_list_dcursor_remove, list, is_const);
 }
@@ -918,7 +916,7 @@ fr_pair_t *_fr_pair_dcursor_by_ancestor_init(fr_dcursor_t *cursor,
  */
 fr_pair_t *fr_pair_list_head(fr_pair_list_t const *list)
 {
-       return fr_pair_dlist_head(list);
+       return fr_dlist_pair_head(&list->order);
 }
 
 /** Get the next item in a valuepair list after a specific entry
@@ -932,7 +930,7 @@ fr_pair_t *fr_pair_list_head(fr_pair_list_t const *list)
  */
 fr_pair_t *fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item)
 {
-       return fr_pair_dlist_next(list, item);
+       return fr_dlist_pair_next(&list->order, item);
 }
 
 /** Get the previous item in a valuepair list before a specific entry
@@ -945,7 +943,7 @@ fr_pair_t *fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item)
  */
 fr_pair_t *fr_pair_list_prev(fr_pair_list_t const *list, fr_pair_t const *item)
 {
-       return fr_pair_dlist_prev(list, item);
+       return fr_dlist_pair_prev(&list->order, item);
 }
 
 /** Get the tail of a valuepair list
@@ -958,7 +956,7 @@ fr_pair_t *fr_pair_list_prev(fr_pair_list_t const *list, fr_pair_t const *item)
  */
 fr_pair_t *fr_pair_list_tail(fr_pair_list_t const *list)
 {
-       return fr_pair_dlist_tail(list);
+       return fr_dlist_pair_tail(&list->order);
 }
 
 /** Add a VP to the start of the list.
@@ -975,12 +973,12 @@ int fr_pair_prepend(fr_pair_list_t *list, fr_pair_t *to_add)
 {
        PAIR_VERIFY(to_add);
 
-       if (fr_pair_dlist_in_list(list, to_add)) {
+       if (fr_dlist_pair_in_list(&list->order, to_add)) {
                fr_strerror_printf("Pair %pV already inserted into list", to_add);
                return -1;
        }
 
-       fr_pair_dlist_insert_head(list, to_add);
+       fr_dlist_pair_insert_head(&list->order, to_add);
 
        return 0;
 }
@@ -999,12 +997,12 @@ int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
 {
        PAIR_VERIFY(to_add);
 
-       if (fr_pair_dlist_in_list(list, to_add)) {
+       if (fr_dlist_pair_in_list(&list->order, to_add)) {
                fr_strerror_printf("Pair %pV already inserted into list", to_add);
                return -1;
        }
 
-       fr_pair_dlist_insert_tail(list, to_add);
+       fr_dlist_pair_insert_tail(&list->order, to_add);
 
        return 0;
 }
@@ -1022,17 +1020,17 @@ int fr_pair_insert_after(fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add
 {
        PAIR_VERIFY(to_add);
 
-       if (fr_pair_dlist_in_list(list, to_add)) {
+       if (fr_dlist_pair_in_list(&list->order, to_add)) {
                fr_strerror_printf("Pair %pV already inserted into list", to_add);
                return -1;
        }
 
-       if (pos && !fr_pair_dlist_in_list(list, pos)) {
+       if (pos && !fr_dlist_pair_in_list(&list->order, pos)) {
                fr_strerror_printf("Pair %pV not in list", pos);
                return -1;
        }
 
-       fr_pair_dlist_insert_after(list, pos, to_add);
+       fr_dlist_pair_insert_after(&list->order, pos, to_add);
 
        return 0;
 }
@@ -1050,17 +1048,17 @@ int fr_pair_insert_before(fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_ad
 {
        PAIR_VERIFY(to_add);
 
-       if (fr_pair_dlist_in_list(list, to_add)) {
+       if (fr_dlist_pair_in_list(&list->order, to_add)) {
                fr_strerror_printf("Pair %pV already inserted into list", to_add);
                return -1;
        }
 
-       if (pos && !fr_pair_dlist_in_list(list, pos)) {
+       if (pos && !fr_dlist_pair_in_list(&list->order, pos)) {
                fr_strerror_printf("Pair %pV not in list", pos);
                return -1;
        }
 
-       fr_pair_dlist_insert_before(list, pos, to_add);
+       fr_dlist_pair_insert_before(&list->order, pos, to_add);
 
        return 0;
 }
@@ -1234,8 +1232,8 @@ fr_pair_t *fr_pair_remove(fr_pair_list_t *list, fr_pair_t *vp)
 {
        fr_pair_t *prev;
 
-       prev = fr_pair_dlist_prev(list, vp);
-       fr_pair_dlist_remove(list, vp);
+       prev = fr_dlist_pair_prev(&list->order, vp);
+       fr_dlist_pair_remove(&list->order, vp);
 
        return prev;
 }
@@ -1250,8 +1248,8 @@ fr_pair_t *fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
 {
        fr_pair_t *prev;
 
-       prev = fr_pair_dlist_prev(list, vp);
-       fr_pair_dlist_remove(list, vp);
+       prev = fr_dlist_pair_prev(&list->order, vp);
+       fr_dlist_pair_remove(&list->order, vp);
        talloc_free(vp);
 
        return prev;
@@ -1488,7 +1486,7 @@ int fr_pair_list_cmp(fr_pair_list_t const *a, fr_pair_list_t const *b)
  */
 void fr_pair_list_sort(fr_pair_list_t *list, fr_cmp_t cmp)
 {
-       fr_pair_dlist_sort(list, cmp);
+       fr_dlist_pair_sort(&list->order, cmp);
 }
 
 /** Write an error to the library errorbuff detailing the mismatch
@@ -1547,9 +1545,7 @@ bool fr_pair_validate(fr_pair_t const *failed[2], fr_pair_list_t *filter, fr_pai
 {
        fr_pair_t *check, *match;
 
-       if (fr_pair_dlist_empty(filter) && fr_pair_dlist_empty(list)) {
-               return true;
-       }
+       if (fr_dlist_pair_empty(&filter->order) && fr_dlist_pair_empty(&list->order)) return true;
 
        /*
         *      This allows us to verify the sets of validate and reply are equal
@@ -1622,9 +1618,7 @@ bool fr_pair_validate_relaxed(fr_pair_t const *failed[2], fr_pair_list_t *filter
 {
        fr_pair_t *check, *last_check = NULL, *match = NULL;
 
-       if (fr_pair_dlist_empty(filter) && fr_pair_dlist_empty(list)) {
-               return true;
-       }
+       if (fr_dlist_pair_empty(&filter->order) && fr_dlist_pair_empty(&list->order)) return true;
 
        /*
         *      This allows us to verify the sets of validate and reply are equal
@@ -1867,9 +1861,9 @@ void fr_pair_value_clear(fr_pair_t *vp)
                break;
 
        case FR_TYPE_STRUCTURAL:
-               if (!fr_pair_dlist_empty(&vp->vp_group)) return;
+               if (!fr_dlist_pair_empty(&vp->vp_group.order)) return;
 
-               while ((child = fr_pair_dlist_pop_tail(&vp->vp_group))) {
+               while ((child = fr_dlist_pair_pop_tail(&vp->vp_group.order))) {
                        fr_pair_value_clear(child);
                        talloc_free(child);
                }
@@ -2710,7 +2704,6 @@ void fr_pair_list_verify(char const *file, int line, TALLOC_CTX const *expected,
         */
        for (; slow; slow = fr_pair_list_next(list, slow)) {
                PAIR_VERIFY(slow);
-
                parent = talloc_parent(slow);
                if (expected && (parent != expected)) goto bad_parent;
        }
@@ -2751,7 +2744,7 @@ void fr_pair_list_tainted(fr_pair_list_t *list)
  */
 void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
 {
-       fr_pair_dlist_move(dst, src);
+       fr_dlist_pair_move(&dst->order, &src->order);
 }
 
 /** Move a list of fr_pair_t from a temporary list to the head of a destination list
@@ -2761,7 +2754,7 @@ void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
  */
 void fr_pair_list_prepend(fr_pair_list_t *dst, fr_pair_list_t *src)
 {
-       fr_pair_dlist_move_head(dst, src);
+       fr_dlist_pair_move_head(&dst->order, &src->order);
 }
 
 /** Evaluation function for matching if vp matches a given da
@@ -2788,7 +2781,7 @@ bool fr_pair_matches_da(void const *item, void const *uctx)
  */
 size_t fr_pair_list_len(fr_pair_list_t const *list)
 {
-       return fr_pair_dlist_num_elements(list);
+       return fr_dlist_pair_num_elements(&list->order);
 }
 
 /** Parse a list of VPs from a value box.
index 169f7b4063edf5fd12d290d8da0eb25d9b3da3bf..226e865311af5506c73286d909310c4489dd92c6 100644 (file)
@@ -44,22 +44,12 @@ extern "C" {
 #  define _CONST
 #endif
 
-/** The type of value a fr_pair_t contains
- *
- * This is used to add structure to nested fr_pair_ts and specifies what type of node it is (set, list, data).
- *
- * xlat is another type of data node which must first be expanded before use.
- */
-typedef enum value_type {
-       VT_INVALID = 0,                                         //!< fr_pair_t is broken
-       VT_SET,                                                 //!< fr_pair_t is #fr_value_box_list
-       VT_DATA,                                                //!< fr_pair_t has a single value.
-} value_type_t;
-
 typedef struct value_pair_s fr_pair_t;
 
+FR_DLIST_TYPES(pair)
+
 typedef struct {
-        fr_dlist_head_t                order;                          //!< Maintains the relative order of pairs in a list.
+        FR_DLIST_HEAD_TYPE(pair)               order;                  //!< Maintains the relative order of pairs in a list.
 } fr_pair_list_t;
 
 /** Stores an attribute, a value and various bits of other data
@@ -74,7 +64,7 @@ struct value_pair_s {
                                                                ///< Note: This should not be modified outside
                                                                ///< of pair.c except via #fr_pair_reinit_from_da.
 
-       fr_dlist_t _CONST       order_entry;                    //!< Entry to maintain relative order within a list
+       FR_DLIST_ENTRY_TYPE(pair) _CONST        order_entry;    //!< Entry to maintain relative order within a list
                                                                ///< of pairs.  This ensures pairs within the list
                                                                ///< are encoded in the same order as they were
                                                                ///< received or inserted.
@@ -95,8 +85,6 @@ struct value_pair_s {
                fr_token_t              op;                     //!< Operator to use when moving or inserting
                                                                //!< valuepair into a list.
                char const              *xlat;                  //!< Source string for xlat expansion.
-
-               value_type_t            type;                   //!< Type of pointer in value union.
        };
 };
 
index 7f0b7def149669d9311938578e10a2254e18e740..5f189910dbe5592bf694813feb199bf611d1a250 100644 (file)
@@ -197,7 +197,7 @@ static void strerror_printf_benchmark(void)
        printf("printf pop rate %" PRIu64 "\n", rate);
 
        /* shared runners are terrible for performance tests */
-       if (!getenv("NO_PERFORMANCE_TESTS")) TEST_CHECK(rate > 400000);
+       if (!getenv("NO_PERFORMANCE_TESTS")) TEST_CHECK(rate > 200000);
 }
 
 
index 559610ca4e29153671fd850b38ddeb3ae0945b1a..ae83b13533f4f4eca807aab3edf386f1303e5d26 100644 (file)
@@ -118,13 +118,13 @@ static int attr_filter_getfile(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, c
                /*
                 *      We apply the rules in the reply items.
                 */
-               if (!fr_map_list_empty(&entry->check)) {
+               if (!fr_dlist_map_empty(&entry->check)) {
                        WARN("%s[%d] Check list is not empty for entry \"%s\".\n",
                             filename, entry->lineno, entry->name);
                }
 
                map = NULL;
-               while ((map = fr_map_list_next(&entry->reply, map))) {
+               while ((map = fr_dlist_map_next(&entry->reply, map))) {
                        fr_dict_attr_t const *da;
 
                        if (!tmpl_is_attr(map->lhs)) {
@@ -240,7 +240,7 @@ static unlang_action_t CC_HINT(nonnull(1,2)) attr_filter_common(rlm_rcode_t *p_r
 
                fr_pair_list_init(&check_list);
 
-               while ((map = fr_map_list_next(&pl->reply, map))) {
+               while ((map = fr_dlist_map_next(&pl->reply, map))) {
                        if (map_to_vp(packet, &tmp_list, request, map, NULL) < 0) {
                                RPWARN("Failed parsing map %s for check item, skipping it", map->lhs->name);
                                continue;
index 30f87be8e2d2bbbdecb0ed0619cafa56777f656a..278a78ab900c2bac4945a919da4af9585681b695 100644 (file)
@@ -138,7 +138,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out,
 #endif
        rlm_cache_entry_t               *c;
 
-       fr_map_list_init(&head);
+       fr_dlist_map_init(&head);
        for (s_ret = fr_redis_cluster_state_init(&state, &conn, driver->cluster, request, key, key_len, false);
             s_ret == REDIS_RCODE_TRY_AGAIN;    /* Continue */
             s_ret = fr_redis_cluster_state_next(&state, &conn, driver->cluster, request, status, &reply)) {
@@ -198,7 +198,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out,
 #else
        c = talloc_zero(NULL, rlm_cache_entry_t);
 #endif
-       fr_map_list_init(&c->maps);
+       fr_dlist_map_init(&c->maps);
        /*
         *      Convert the key/value pairs back into maps
         */
@@ -215,30 +215,30 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out,
        /*
         *      Pull out the cache created date
         */
-       if (tmpl_da(fr_map_list_head(&head)->lhs) == attr_cache_created) {
+       if (tmpl_da(fr_dlist_map_head(&head)->lhs) == attr_cache_created) {
                map_t *map;
 
-               c->created = tmpl_value(fr_map_list_head(&head)->rhs)->vb_date;
+               c->created = tmpl_value(fr_dlist_map_head(&head)->rhs)->vb_date;
 
-               map = fr_map_list_pop_head(&head);
+               map = fr_dlist_map_pop_head(&head);
                talloc_free(map);
        }
 
        /*
         *      Pull out the cache expires date
         */
-       if (tmpl_da(fr_map_list_head(&head)->lhs) == attr_cache_expires) {
+       if (tmpl_da(fr_dlist_map_head(&head)->lhs) == attr_cache_expires) {
                map_t *map;
 
-               c->expires = tmpl_value(fr_map_list_head(&head)->rhs)->vb_date;
+               c->expires = tmpl_value(fr_dlist_map_head(&head)->rhs)->vb_date;
 
-               map = fr_map_list_pop_head(&head);
+               map = fr_dlist_map_pop_head(&head);
                talloc_free(map);
        }
 
        c->key = talloc_memdup(c, key, key_len);
        c->key_len = key_len;
-       fr_map_list_move(&c->maps, &head);
+       fr_dlist_map_move(&c->maps, &head);
        *out = c;
 
        return CACHE_OK;
@@ -306,7 +306,7 @@ static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config
        fr_value_box_init(&expires_value.data.literal, FR_TYPE_DATE, NULL, true);
        tmpl_value(&expires_value)->vb_date = c->expires;
 
-       cnt = fr_map_list_num_elements(&c->maps) + 2;
+       cnt = fr_dlist_map_num_elements(&c->maps) + 2;
 
        /*
         *      The majority of serialized entries should be under 1k.
@@ -342,7 +342,7 @@ static cache_status_t cache_entry_insert(UNUSED rlm_cache_config_t const *config
        }
        argv_p += 3;
        argv_len_p += 3;
-       while ((map = fr_map_list_next(&c->maps, map))) {
+       while ((map = fr_dlist_map_next(&c->maps, map))) {
                if (fr_redis_tuple_from_map(pool, argv_p, argv_len_p, map) < 0) {
                        REDEBUG("Failed encoding map as Redis K/V pair");
                        talloc_free(pool);
index 0afe721de124f3a57080c75fd2396d8a0ab5b147..a4098046b2641047bfb2e4f7d7ab5c7ea8b369c0 100644 (file)
@@ -160,7 +160,7 @@ static rlm_rcode_t cache_merge(rlm_cache_t const *inst, request_t *request, rlm_
 
        RDEBUG2("Merging cache entry into request");
        RINDENT();
-       while ((map = fr_map_list_next(&c->maps, map))) {
+       while ((map = fr_dlist_map_next(&c->maps, map))) {
                /*
                 *      The only reason that the application of a map entry
                 *      can fail, is if the destination list or request
@@ -320,7 +320,7 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result,
        if (!c) {
                RETURN_MODULE_FAIL;
        }
-       fr_map_list_init(&c->maps);
+       fr_dlist_map_init(&c->maps);
        c->key = talloc_memdup(c, key, key_len);
        c->key_len = key_len;
 
@@ -337,7 +337,7 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result,
         *      gathering fr_pair_ts to cache.
         */
        pool = talloc_pool(NULL, 2048);
-       while ((map = fr_map_list_next(&inst->maps, map))) {
+       while ((map = fr_dlist_map_next(&inst->maps, map))) {
                fr_pair_list_t  to_cache;
 
                fr_pair_list_init(&to_cache);
@@ -376,7 +376,7 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result,
 
                        MEM(c_map = talloc_zero(c, map_t));
                        c_map->op = map->op;
-                       fr_map_list_init(&c_map->child);
+                       fr_dlist_map_init(&c_map->child);
 
                        /*
                         *      Now we turn the fr_pair_ts into maps.
@@ -425,7 +425,7 @@ static unlang_action_t cache_insert(rlm_rcode_t *p_result,
                                fr_assert(0);
                        }
                        MAP_VERIFY(c_map);
-                       fr_map_list_insert_tail(&c->maps, c_map);
+                       fr_dlist_map_insert_tail(&c->maps, c_map);
                }
                talloc_free_children(pool); /* reset pool state */
        }
@@ -868,7 +868,7 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
                return XLAT_ACTION_FAIL;
        }
 
-       while ((map = fr_map_list_next(&c->maps, map))) {
+       while ((map = fr_dlist_map_next(&c->maps, map))) {
                if ((tmpl_da(map->lhs) != tmpl_da(target)) ||
                    (tmpl_list(map->lhs) != tmpl_list(target))) continue;
 
@@ -1044,14 +1044,14 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
                        .allow_foreign = true   /* Because we don't know where we'll be called */
                };
 
-               fr_map_list_init(&inst->maps);
+               fr_dlist_map_init(&inst->maps);
                if (map_afrom_cs(inst, &inst->maps, update,
                                 &parse_rules, &parse_rules, cache_verify, NULL, MAX_ATTRMAP) < 0) {
                        return -1;
                }
        }
 
-       if (fr_map_list_empty(&inst->maps)) {
+       if (fr_dlist_map_empty(&inst->maps)) {
                cf_log_err(conf, "Cache config must contain an update section, and "
                              "that section must not be empty");
                return -1;
index d8fc84bb8b1b0942816c9e2c04d099409704ce0e..96ce1ecf7f3e2d8817f517111223c606f86d6c8b 100644 (file)
@@ -53,7 +53,7 @@ int cache_serialize(TALLOC_CTX *ctx, char **out, rlm_cache_entry_t const *c)
        /*
         *      It's valid to have an empty cache entry (save allocing the pairs pool)
         */
-       if (fr_map_list_empty(&c->maps)) goto finish;
+       if (fr_dlist_map_empty(&c->maps)) goto finish;
 
        value_pool = talloc_pool(ctx, 512);
        if (!value_pool) {
@@ -63,7 +63,7 @@ int cache_serialize(TALLOC_CTX *ctx, char **out, rlm_cache_entry_t const *c)
                return -1;
        }
 
-       while ((map = fr_map_list_next(&c->maps, map))) {
+       while ((map = fr_dlist_map_next(&c->maps, map))) {
                char    *value;
                ssize_t slen;
 
@@ -167,7 +167,7 @@ int cache_deserialize(rlm_cache_entry_t *c, fr_dict_t const *dict, char *in, ssi
                MAP_VERIFY(map);
 
                /* It's not a special attribute, add it to the map list */
-               fr_map_list_insert_tail(&c->maps, map);
+               fr_dlist_map_insert_tail(&c->maps, map);
 
        next:
                p = q + 1;
index d295369535d2f02da04f008402dc49699b84e424..17fd9258fd9fb051920ba2f3aa43d152fe7d6302 100644 (file)
@@ -177,7 +177,7 @@ static rlm_rcode_t map_proc_client(UNUSED void *mod_inst, UNUSED void *proc_inst
        uctx.cs = client->cs;
 
        RINDENT();
-       while ((map = fr_map_list_next(maps, map))) {
+       while ((map = fr_dlist_map_next(maps, map))) {
                char    *field = NULL;
 
                if (tmpl_aexpand(request, &field, request, map->rhs, NULL, NULL) < 0) {
index 47e2d4b2a9a43e16cb0e2db638fd5a5df2adadb4..e3458e0da5d37e86f4ab766e138633b26cfad03d 100644 (file)
@@ -153,7 +153,7 @@ static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *
                vp_list_mod_t   *vlm;
                fr_dlist_head_t vlm_head;
 
-               fr_map_list_init(&map_head);
+               fr_dlist_map_init(&map_head);
                fr_dcursor_init(&maps, &map_head);
 
                /*
index 75385b8d9975067b7f289377a24d91f5357f88ff..e9b2de1fef10f1fd367ce2910fca09a0ada6b6f8 100644 (file)
@@ -490,7 +490,7 @@ static int csv_maps_verify(CONF_SECTION *cs, void *mod_inst, UNUSED void *proc_i
                return -1;
        }
 
-       while ((map = fr_map_list_next(maps, map))) {
+       while ((map = fr_dlist_map_next(maps, map))) {
                /*
                 *      This function doesn't change the map, so it's OK.
                 */
@@ -762,7 +762,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        };
        char buffer[8192];
 
-       fr_map_list_init(&inst->map);
+       fr_dlist_map_init(&inst->map);
        /*
         *      "update" without "key" is invalid, as we can't run the
         *      module.
@@ -907,7 +907,7 @@ static rlm_rcode_t mod_map_apply(rlm_csv_t const *inst, request_t *request,
 
 redo:
        RINDENT();
-       while ((map = fr_map_list_next(maps, map))) {
+       while ((map = fr_dlist_map_next(maps, map))) {
                int field;
                char *field_name;
 
@@ -1003,7 +1003,7 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul
        ssize_t slen;
        fr_value_box_t *key;
 
-       if (fr_map_list_empty(&inst->map) || !inst->key) RETURN_MODULE_NOOP;
+       if (fr_dlist_map_empty(&inst->map) || !inst->key) RETURN_MODULE_NOOP;
 
        /*
         *      Expand the key to whatever it is.  For attributes,
index 16479bfb4c95db4be028fe3ea909b543d7766899..50dd685e4fdbf65d9b831f8b983eb0031b93c442 100644 (file)
@@ -152,7 +152,7 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, fr_htrie_t **ptre
                 *      and probably ':=' for server
                 *      configuration items.
                 */
-               while ((map = fr_map_list_next(&entry->check, map))) {
+               while ((map = fr_dlist_map_next(&entry->check, map))) {
                        if (!tmpl_is_attr(map->lhs)) {
                                ERROR("%s[%d] Left side of check item %s is not an attribute",
                                      entry->filename, entry->lineno, map->lhs->name);
@@ -193,7 +193,7 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, fr_htrie_t **ptre
                 *      worth doing.
                 */
                map = NULL;
-               while ((map = fr_map_list_next(&entry->reply, map))) {
+               while ((map = fr_dlist_map_next(&entry->reply, map))) {
                        if (!tmpl_is_attr(map->lhs)) {
                                ERROR("%s[%d] Left side of reply item %s is not an attribute",
                                      entry->filename, entry->lineno, map->lhs->name);
@@ -477,7 +477,7 @@ redo:
                /*
                 *      Realize the map to a list of VPs
                 */
-               while ((map = fr_map_list_next(&pl->check, map))) {
+               while ((map = fr_dlist_map_next(&pl->check, map))) {
                        fr_pair_list_t tmp_list;
 
                        /*
@@ -529,9 +529,9 @@ redo:
                fr_pair_list_free(&list);
 
                /* ctx may be reply */
-               if (!fr_map_list_empty(&pl->reply)) {
+               if (!fr_dlist_map_empty(&pl->reply)) {
                        map = NULL;
-                       while ((map = fr_map_list_next(&pl->reply, map))) {
+                       while ((map = fr_dlist_map_next(&pl->reply, map))) {
                                fr_pair_list_t tmp_list;
                                fr_pair_list_init(&tmp_list);
                                if (map->op == T_OP_CMP_FALSE) continue;
index b233f6c46244410150387dcda560255dd6dca56e..a941a8401b7cb20a8ea22c206520f7e49c48cce9 100644 (file)
@@ -292,7 +292,7 @@ static int mod_map_proc_instantiate(CONF_SECTION *cs, UNUSED void *mod_inst, voi
                return -1;
        }
 
-       while ((map = fr_map_list_next(maps, map))) {
+       while ((map = fr_dlist_map_next(maps, map))) {
                CONF_PAIR       *cp = cf_item_to_pair(map->ci);
                char const      *p;
 
@@ -343,7 +343,7 @@ static int mod_map_proc_instantiate(CONF_SECTION *cs, UNUSED void *mod_inst, voi
                 *      list member was pre-allocated and passed to the
                 *      instantiation callback.
                 */
-               if (fr_map_list_next(maps, map)) {
+               if (fr_dlist_map_next(maps, map)) {
                        *tail = cache = talloc_zero(cache, rlm_json_jpath_cache_t);
                        tail = &cache->next;
                }
@@ -454,7 +454,7 @@ static rlm_rcode_t mod_map_proc(UNUSED void *mod_inst, void *proc_inst, request_
                goto finish;
        }
 
-       while ((map = fr_map_list_next(maps, map))) {
+       while ((map = fr_dlist_map_next(maps, map))) {
                switch (map->rhs->type) {
                /*
                 *      Cached types
index cb272bdf5d22bf45d20f39c4d5a3cc1fd950ef47..381a6d8c015fa28c8cc7bb7c7fc55494a264ef04 100644 (file)
@@ -833,9 +833,9 @@ static rlm_rcode_t mod_map_proc(void *mod_inst, UNUSED void *proc_inst, request_
                }
 
                RINDENT();
-               for (map = fr_map_list_head(maps), i = 0;
+               for (map = fr_dlist_map_head(maps), i = 0;
                     map != NULL;
-                    map = fr_map_list_next(maps, map), i++) {
+                    map = fr_dlist_map_next(maps, map), i++) {
                        int                     ret;
                        fr_ldap_result_t        attr;
 
@@ -1418,7 +1418,7 @@ skip_edir:
                }
        }
 
-       if (!fr_map_list_empty(&inst->user_map) || inst->valuepair_attr) {
+       if (!fr_dlist_map_empty(&inst->user_map) || inst->valuepair_attr) {
                RDEBUG2("Processing user attributes");
                RINDENT();
                if (fr_ldap_map_do(request, handle, inst->valuepair_attr,
@@ -1888,7 +1888,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        rlm_ldap_t      *inst = talloc_get_type_abort(mctx->inst->data, rlm_ldap_t);
        CONF_SECTION    *conf = mctx->inst->conf;
 
-       fr_map_list_init(&inst->user_map);
+       fr_dlist_map_init(&inst->user_map);
 
        options = cf_section_find(conf, "options", NULL);
        if (!options || !cf_pair_find(options, "chase_referrals")) {
index 6f9e27f0dd31ee296aa7c1957683e21f68961c16..45112c76d1dc3a1ade61a347108e585286aa98cb 100644 (file)
@@ -330,7 +330,7 @@ static int status_check_update_parse(TALLOC_CTX *ctx, void *out, UNUSED void *pa
        fr_map_list_t           *head = (fr_map_list_t *)out;
 
        fr_assert(cf_item_is_section(ci));
-       fr_map_list_init(head);
+       fr_dlist_map_init(head);
 
        cs = cf_item_to_section(ci);
        name2 = cf_section_name2(cs);
@@ -349,7 +349,7 @@ static int status_check_update_parse(TALLOC_CTX *ctx, void *out, UNUSED void *pa
 
                rcode = map_afrom_cs(ctx, head, cs, &parse_rules, &parse_rules, unlang_fixup_update, NULL, 128);
                if (rcode < 0) return -1; /* message already printed */
-               if (fr_map_list_empty(head)) {
+               if (fr_dlist_map_empty(head)) {
                        cf_log_err(cs, "'update' sections cannot be empty");
                        return -1;
                }
index b5e3a39721a0402ac74c3e39316a45cced152bd6..c890b11188227d5000ba49268eecb0e801a8207d 100644 (file)
@@ -370,7 +370,7 @@ static void CC_HINT(nonnull) status_check_alloc(udp_handle_t *h)
         *      Create the VPs, and ignore any errors
         *      creating them.
         */
-       while ((map = fr_map_list_next(&inst->parent->status_check_map, map))) {
+       while ((map = fr_dlist_map_next(&inst->parent->status_check_map, map))) {
                /*
                 *      Skip things which aren't attributes.
                 */
index b9524e6a864bf9ae2dbb94aec9058fe53eeb3d47..36095527313135b1e262c0201e226a4ced2d9750 100644 (file)
@@ -547,7 +547,7 @@ static int header_source(rlm_smtp_thread_t *t, fr_mail_ctx_t *uctx, rlm_smtp_t c
         *      Initialize the sbuff for writing the config elements as header attributes
         */
        fr_sbuff_init_talloc(uctx, &conf_buffer, &conf_ctx, 256, SIZE_MAX);
-       conf_map = fr_map_list_head(&inst->header_maps);
+       conf_map = fr_dlist_map_head(&inst->header_maps);
 
        /*
         *      Load in all of the header elements supplied in the config
@@ -571,10 +571,10 @@ static int header_source(rlm_smtp_thread_t *t, fr_mail_ctx_t *uctx, rlm_smtp_t c
        next:
                /* Check if there are more values to parse */
 
-               if (!fr_map_list_next(&inst->header_maps, conf_map)) break;
+               if (!fr_dlist_map_next(&inst->header_maps, conf_map)) break;
                /* reinitialize the buffer and move to the next value */
                fr_sbuff_init_talloc(uctx, &conf_buffer, &conf_ctx, 256, SIZE_MAX);
-               conf_map = fr_map_list_next(&inst->header_maps, conf_map);
+               conf_map = fr_dlist_map_next(&inst->header_maps, conf_map);
        }
 
        /* Add the FROM: line */
@@ -1045,7 +1045,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        CONF_SECTION    *conf = mctx->inst->conf;
        CONF_SECTION    *header;
 
-       fr_map_list_init(&inst->header_maps);
+       fr_dlist_map_init(&inst->header_maps);
        header = cf_section_find(conf, "header", NULL);
        if (!header) return 0;
 
index 6b215d906cd40b81ba98e6316e93366da6aaff80..b19fd0f428f4a43a372ad270928829353789cae2 100644 (file)
@@ -486,9 +486,9 @@ static rlm_rcode_t mod_map_proc(void *mod_inst, UNUSED void *proc_inst, request_
         *      faster than building a radix tree each time the
         *      map set is evaluated (map->rhs can be dynamic).
         */
-       for (map = fr_map_list_head(maps), i = 0;
+       for (map = fr_dlist_map_head(maps), i = 0;
             map && (i < MAX_SQL_FIELD_INDEX);
-            map = fr_map_list_next(maps, map), i++) {
+            map = fr_dlist_map_next(maps, map), i++) {
                /*
                 *      Expand the RHS to get the name of the SQL field
                 */
@@ -525,9 +525,9 @@ static rlm_rcode_t mod_map_proc(void *mod_inst, UNUSED void *proc_inst, request_
         */
        while (((ret = rlm_sql_fetch_row(&row, inst, request, &handle)) == RLM_SQL_OK)) {
                rows++;
-               for (map = fr_map_list_head(maps), j = 0;
+               for (map = fr_dlist_map_head(maps), j = 0;
                     map && (j < MAX_SQL_FIELD_INDEX);
-                    map = fr_map_list_next(maps, map), j++) {
+                    map = fr_dlist_map_next(maps, map), j++) {
                        if (field_index[j] < 0) continue;       /* We didn't find the map RHS in the field set */
                        if (map_to_request(request, map, _sql_map_proc_get_value, row[field_index[j]]) < 0) goto error;
                }