]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add helper function for building test nested attribute lists
authorNick Porter <nick@portercomputing.co.uk>
Fri, 7 Jul 2023 07:05:53 +0000 (08:05 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 7 Jul 2023 07:05:53 +0000 (08:05 +0100)
src/lib/util/pair_test_helpers.h

index c4fe48e53fc6acf9c7035c989230e0c06d7e7702..b50b623db01744969a67f8fa5066df95a1a99707 100644 (file)
@@ -58,6 +58,24 @@ static inline int fr_pair_test_list_alloc(TALLOC_CTX *ctx, fr_pair_list_t *out,
        return 0;
 }
 
+static inline int fr_pair_test_list_alloc_nested(TALLOC_CTX *ctx, fr_pair_list_t *out,
+                                               fr_dict_test_attr_t const *test_defs)
+{
+       fr_dict_test_attr_t const *p;
+
+       if (!test_defs) test_defs = fr_dict_test_attrs;
+
+       fr_pair_list_init(out);
+
+       for (p = test_defs;
+            p->attr != -1;
+            p++) if (fr_pair_append_by_da_parent(ctx, NULL, out, *p->da) < 0) return -1;
+
+       PAIR_LIST_VERIFY(out);
+
+       return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif