]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add iterators for protocols
authorAlan T. DeKok <aland@freeradius.org>
Mon, 9 Aug 2021 20:21:04 +0000 (16:21 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 10 Aug 2021 15:13:35 +0000 (11:13 -0400)
src/lib/util/dict.h
src/lib/util/dict_util.c
src/lib/util/hash.h

index 905a88762d280ecafadb5584108757794e4293aa..3df5078877f9568d461e0f220b3581aaac772276 100644 (file)
@@ -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);
index b5853b6f330fc45e9b8cb92aca97d02febbb5dab..616ac38703d627f89b6fb48fcaeb6a227900264d 100644 (file)
@@ -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
  *
  */
index d5c78ab4ef331243cd3484bf05abad369ad33a8d..e2eedc00e0c744f014b3d80565c3a731ea694064 100644 (file)
@@ -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;