if (!current) {
if (cursor->at_end) return NULL; /* At tail of the list */
- next = iter(cursor->dlist, fr_dlist_head(cursor->dlist), cursor->iter_uctx);
+ next = iter(cursor->dlist, NULL, cursor->iter_uctx);
VALIDATE(next);
return next;
}
VALIDATE(current);
/*
- * Get the next entry, and pass it to the iterator.
+ * The iterator will advance to the next matching entry.
*/
- next = fr_dlist_next(cursor->dlist, current);
- if (!next) return NULL;
-
- /*
- * The iterator can just return what it was passed for curr
- * if it just wants to advance by one.
- */
- next = iter(cursor->dlist, next, cursor->iter_uctx);
+ next = iter(cursor->dlist, current, cursor->iter_uctx);
VALIDATE(next);
return next;
fr_dlist_head_t head;
} test_item_list_t;
-static void *test_iter(UNUSED fr_dlist_head_t *list, void *current, UNUSED void *uctx)
+static void *test_iter(fr_dlist_head_t *list, void *current, UNUSED void *uctx)
{
- return current;
+ return fr_dlist_next(list, current);
}
static void test_list_init(test_item_list_t *list)
char val;
} item_filter;
-static void *iter_name_check(fr_dlist_head_t *list, void *to_eval, void *uctx)
+static void *iter_name_check(fr_dlist_head_t *list, void *current, void *uctx)
{
- test_item_t *c;
+ test_item_t *c = current;
item_filter *f = uctx;
- if (!to_eval) return NULL;
-
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while((c = fr_dlist_next(list, c))) {
if (c->name[f->pos] == f->val) break;
}
/** Iterate over pairs with a specified da
*
* @param[in] list to iterate over.
- * @param[in] to_eval The fr_pair_t after cursor->current. Will be checked to
+ * @param[in] current The fr_pair_t cursor->current. Will be advanced and checked to
* see if it matches the specified fr_dict_attr_t.
* @param[in] uctx The fr_dict_attr_t to search for.
* @return
* - Next matching fr_pair_t.
* - NULL if not more matching fr_pair_ts could be found.
*/
-static void *fr_pair_iter_next_by_da(fr_dlist_head_t *list, void *to_eval, void *uctx)
+static void *fr_pair_iter_next_by_da(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_attr_t *da = uctx;
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if (c->da == da) break;
}
/** Iterate over pairs which are decedents of the specified da
*
* @param[in] list to itterate over.
- * @param[in] to_eval The fr_pair_t after cursor->current. Will be checked to
+ * @param[in] current The fr_pair_t cursor->current. Will be advanced and checked to
* see if it matches the specified fr_dict_attr_t.
* @param[in] uctx The fr_dict_attr_t to search for.
* @return
* - Next matching fr_pair_t.
* - NULL if not more matching fr_pair_ts could be found.
*/
-static void *fr_pair_iter_next_by_ancestor(fr_dlist_head_t *list, void *to_eval, void *uctx)
+static void *fr_pair_iter_next_by_ancestor(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_attr_t *da = uctx;
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if (fr_dict_attr_common_parent(da, c->da, true)) break;
}
/** Implements the default iterator to encode pairs belonging to a specific dictionary that are not internal
*
* @param[in] list to itterate over.
- * @param[in] to_eval The fr_pair_t after cursor->current. Will be checked to
+ * @param[in] current The fr_pair_t cursor->current. Will be advanced and checked to
* see if it matches the specified fr_dict_t.
* @param[in] uctx The fr_dict_t to search for.
* @return
* - Next matching fr_pair_t.
* - NULL if not more matching fr_pair_ts could be found.
*/
-void *fr_proto_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
+void *fr_proto_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_t *dict = talloc_get_type_abort(uctx, fr_dict_t);
- if (!to_eval) return NULL;
-
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if ((c->da->dict == dict) && (!c->da->flags.internal)) break;
}
void fr_proto_print_hex_marker(char const *file, int line, uint8_t const *data, size_t data_len, ssize_t slen, char const *fmt, ...);
-void *fr_proto_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx);
+void *fr_proto_next_encodable(fr_dlist_head_t *list, void *current, void *uctx);
void fr_proto_da_stack_print(char const *file, int line, char const *func, fr_da_stack_t *da_stack, unsigned int depth);
return CMP_PREFER_SMALLER(my_a->da->attr, my_b->da->attr);
}
-static void *struct_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
+static void *struct_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_attr_t *parent = talloc_get_type_abort(uctx, fr_dict_attr_t);
- if (!to_eval) return NULL;
-
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if (c->da->dict != parent->dict || c->da->flags.internal) continue;
/** DHCPV4-specific iterator
*
*/
-void *fr_dhcpv4_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
+void *fr_dhcpv4_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_t *dict = talloc_get_type_abort(uctx, fr_dict_t);
- if (!to_eval) return NULL;
-
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if (c->da->dict != dict || c->da->flags.internal) continue;
/*
* A private function that is used only in base.c and encode.c
*/
-void *fr_dhcpv6_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx);
+void *fr_dhcpv6_next_encodable(fr_dlist_head_t *list, void *current, void *uctx);
/** DHCPV6-specific iterator
*
*/
-void *fr_dhcpv6_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
+void *fr_dhcpv6_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_t *dict = talloc_get_type_abort(uctx, fr_dict_t);
- if (!to_eval) return NULL;
-
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if (c->da->dict != dict || c->da->flags.internal) continue;
if (c->da->type == FR_TYPE_BOOL && !c->vp_bool) continue;
return 0;
}
-void *fr_radius_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx);
+void *fr_radius_next_encodable(fr_dlist_head_t *list, void *current, void *uctx);
-void *fr_radius_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
+void *fr_radius_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
{
- fr_pair_t *c;
+ fr_pair_t *c = current;
fr_dict_t *dict = talloc_get_type_abort(uctx, fr_dict_t);
- if (!to_eval) return NULL;
-
- for (c = to_eval; c; c = fr_dlist_next(list, c)) {
+ while ((c = fr_dlist_next(list, c))) {
PAIR_VERIFY(c);
if ((c->da->dict == dict) &&
(!c->da->flags.internal || ((c->da->attr > FR_TAG_BASE) && (c->da->attr < (FR_TAG_BASE + 0x20))))) {