From: Alan T. DeKok Date: Mon, 9 Aug 2021 20:21:04 +0000 (-0400) Subject: add iterators for protocols X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f75f14206f8dab352da6915c702ddf612579104b;p=thirdparty%2Ffreeradius-server.git add iterators for protocols --- diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index 905a88762d2..3df5078877f 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -618,6 +618,12 @@ void fr_dict_global_ctx_debug(void); char const *fr_dict_global_ctx_dir(void); +typedef struct fr_hash_iter_s fr_dict_global_ctx_iter_t; + +fr_dict_t *fr_dict_global_ctx_iter_init(fr_dict_global_ctx_iter_t *iter) CC_HINT(nonnull); + +fr_dict_t *fr_dict_global_ctx_iter_next(fr_dict_global_ctx_iter_t *iter) CC_HINT(nonnull); + fr_dict_t *fr_dict_unconst(fr_dict_t const *dict); fr_dict_attr_t *fr_dict_attr_unconst(fr_dict_attr_t const *da); diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index b5853b6f330..616ac38703d 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -3593,6 +3593,24 @@ void fr_dict_global_ctx_debug(void) } } +/** Iterate protocols by name + * + */ +fr_dict_t *fr_dict_global_ctx_iter_init(fr_dict_global_ctx_iter_t *iter) +{ + if (!dict_gctx) return NULL; + + return fr_hash_table_iter_init(dict_gctx->protocol_by_name, iter); +} + +fr_dict_t *fr_dict_global_ctx_iter_next(fr_dict_global_ctx_iter_t *iter) +{ + if (!dict_gctx) return NULL; + + return fr_hash_table_iter_next(dict_gctx->protocol_by_name, iter); +} + + /** Coerce to non-const * */ diff --git a/src/lib/util/hash.h b/src/lib/util/hash.h index d5c78ab4ef3..e2eedc00e0c 100644 --- a/src/lib/util/hash.h +++ b/src/lib/util/hash.h @@ -38,7 +38,7 @@ typedef uint32_t (*fr_hash_t)(void const *); /** Stores the state of the current iteration operation * */ -typedef struct { +typedef struct fr_hash_iter_s { uint32_t bucket; fr_hash_entry_t *node; } fr_hash_iter_t;