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_dlist_next(maps, map))) {
+ while ((map = fr_map_list_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);
fr_ldap_result_t result;
char const *name;
- while ((map = fr_dlist_next(expanded->maps, map))) {
+ while ((map = fr_map_list_next(expanded->maps, map))) {
int ret;
name = expanded->attrs[total++];
}
MAP_VERIFY(map);
- fr_dlist_insert_tail(out, map);
+ fr_map_list_insert_tail(out, map);
return 0;
}
* caller will have to check for this!
*/
if (is_child && parent) {
- fr_dlist_insert_tail(&parent->child, map);
+ fr_map_list_insert_tail(&parent->child, map);
}
if (parent_p) *parent_p = new_parent;
* Free in reverse as successive entries have their
* prececessors as talloc parent contexts
*/
- fr_dlist_talloc_reverse_free(out);
+ fr_map_list_talloc_reverse_free(out);
return -1;
}
*/
if (_map_afrom_cs(map, &child_list, map, cf_item_to_section(ci),
&our_lhs_rules, rhs_rules, validate, uctx, max) < 0) {
- fr_dlist_talloc_free(&child_list);
+ fr_map_list_talloc_free(&child_list);
talloc_free(map);
goto error;
}
- fr_dlist_move(&map->child, &child_list);
+ fr_map_list_move(&map->child, &child_list);
our_lhs_rules.disallow_qualifiers = qualifiers;
MAP_VERIFY(map);
next:
parent_ctx = map;
- fr_dlist_insert_tail(out, map);
+ fr_map_list_insert_tail(out, map);
}
return 0;
return 0;
}
-/** Sort a doubly linked list of #map_t using merge sort
- *
- * @param[in,out] list of #map_t to sort.
- * @param[in] cmp to sort with
- */
-void map_sort(fr_map_list_t *list, fr_cmp_t cmp)
-{
- fr_dlist_sort(list, cmp);
-
-}
-
/** Process map which has exec as a src
*
* Evaluate maps which specify exec as a src. This may be used by various sorts of update sections, and so
MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
n->op = map->op;
- for (child = fr_dlist_next(&map->child, NULL);
+ for (child = fr_map_list_next(&map->child, NULL);
child != NULL;
- child = fr_dlist_next(&map->child, child)) {
+ child = fr_map_list_next(&map->child, child)) {
fr_pair_list_t list;
/*
* If there's no child and no RHS then the
* map was invalid.
*/
- if (fr_dlist_empty(&map->child) && !fr_cond_assert(map->rhs != NULL)) {
+ if (fr_map_list_empty(&map->child) && !fr_cond_assert(map->rhs != NULL)) {
fr_sbuff_terminate(out);
return 0;
}
*
* Specifically define a type for lists of map_t to aid type checking
*/
-typedef fr_dlist_head_t fr_map_list_t;
+typedef struct {
+ fr_dlist_head_t head;
+} fr_map_list_t;
/** Value pair map
*
fr_dlist_t entry; //!< List entry.
};
+FR_DLIST_NEW_TYPE(map_list, fr_map_list_t, head, map_t, entry)
+
/** A list modification
*
*/
tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules,
fr_sbuff_parse_rules_t const *p_rules);
-void map_sort(fr_map_list_t *list, fr_cmp_t cmp);
-
int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request,
map_t const *map, void *uctx) CC_HINT(nonnull (2,3,4));
extern fr_sbuff_parse_rules_t const map_parse_rules_bareword_quoted;
extern fr_sbuff_parse_rules_t const *map_parse_rules_quoted[T_TOKEN_LAST];
-#define fr_map_list_init(_list) fr_dlist_talloc_init(_list, map_t, entry)
-#define fr_map_list_head(_list) ((map_t *)fr_dlist_head(_list))
-#define fr_map_list_tail(_list) ((map_t *)fr_dlist_tail(_list))
-
#ifdef __cplusplus
}
#endif
talloc_free(n);
return NULL;
}
- fr_dlist_insert_tail(&n->mod, mod);
+ fr_map_list_insert_tail(&n->mod, mod);
return n;
}
talloc_free(n);
return NULL;
}
- fr_dlist_insert_tail(&n->mod, mod);
+ fr_map_list_insert_tail(&n->mod, mod);
return n;
}
talloc_free(n);
return NULL;
}
- fr_dlist_insert_tail(&n->mod, mod);
+ fr_map_list_insert_tail(&n->mod, mod);
return n;
}
mod->lhs = mutated->lhs;
mod->op = mutated->op;
mod->rhs = mutated->rhs;
- fr_dlist_insert_tail(&n->mod, mod);
+ fr_map_list_insert_tail(&n->mod, mod);
goto finish;
}
* before this map is applied.
*/
if (fr_value_box_copy(n_mod->rhs, tmpl_value(n_mod->rhs), &vp->data) < 0) goto error;
- fr_dlist_insert_tail(&n->mod, n_mod);
+ fr_map_list_insert_tail(&n->mod, n_mod);
MAP_VERIFY(n_mod);
} while ((vp = fr_pair_list_next(list, vp)));
fr_dcursor_init(&values, &head);
- if (fr_value_box_from_str(fr_dlist_head(&n->mod),
+ if (fr_value_box_from_str(fr_map_list_head(&n->mod),
tmpl_value(fr_map_list_head(&n->mod)->rhs), type,
tmpl_da(mutated->lhs),
mutated->rhs->name, mutated->rhs->len,
}
mod->op = vp->op;
- fr_dlist_insert_tail(&n->mod, mod);
+ fr_map_list_insert_tail(&n->mod, mod);
}
}
{
map_t *mod;
- fr_assert(!fr_dlist_empty(&vlm->mod));
+ fr_assert(!fr_map_list_empty(&vlm->mod));
/*
* Fast path...
*/
- mod = fr_dlist_head(&vlm->mod);
- if (vlm->mod.num_elements == 1) {
+ mod = fr_map_list_head(&vlm->mod);
+ if (fr_map_list_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);
*/
for (;
mod;
- mod = fr_dlist_next(&vlm->mod, mod)) {
+ mod = fr_map_list_next(&vlm->mod, mod)) {
fr_pair_t *vp;
vp = map_list_mod_to_vp(ctx, mod->lhs, tmpl_value(mod->rhs));
memset(&cc, 0, sizeof(cc));
MAP_VERIFY(map);
- fr_assert(!fr_dlist_empty(&vlm->mod));
+ fr_assert(!fr_map_list_empty(&vlm->mod));
/*
* Print debug information for the mods being applied
*/
- while ((mod = fr_dlist_next(&vlm->mod, mod))) {
+ while ((mod = fr_map_list_next(&vlm->mod, mod))) {
fr_value_box_t *vb;
MAP_VERIFY(mod);
map_list_mod_debug(request, map, mod, vb->type != FR_TYPE_NULL ? vb : NULL);
}
}
- mod = fr_dlist_head(&vlm->mod); /* Reset */
+ mod = fr_map_list_head(&vlm->mod); /* Reset */
/*
* All this has been checked by #map_to_list_mod
}
}
- fr_assert(!fr_dlist_next(&vlm->mod, mod));
+ fr_assert(!fr_map_list_next(&vlm->mod, mod));
/*
* Find the destination attribute. We leave with either
do_insert:
fr_assert(!new_map->parent);
- fr_dlist_insert_tail(&t->check, new_map);
+ fr_map_list_insert_tail(&t->check, new_map);
/*
* There can be spaces before any comma.
fr_assert(tmpl_list(new_map->lhs) == PAIR_LIST_REPLY);
- if (!new_map->parent) fr_dlist_insert_tail(&t->reply, new_map);
+ if (!new_map->parent) fr_map_list_insert_tail(&t->reply, new_map);
(void) fr_sbuff_adv_past_blank(&sbuff, SIZE_MAX, NULL);
/*
* Sanity check sublists.
*/
- if (!fr_dlist_empty(&map->child)) {
+ if (!fr_map_list_empty(&map->child)) {
fr_dict_attr_t const *da;
if (!tmpl_is_attr(map->lhs)) {
return false;
}
- return pass2_fixup_map(fr_dlist_head(&map->child), rules, da);
+ return pass2_fixup_map(fr_map_list_head(&map->child), rules, da);
}
return true;
RULES_VERIFY(rules);
- while ((map = fr_dlist_next(&gext->map, map))) {
+ while ((map = fr_map_list_next(&gext->map, map))) {
/*
* Mostly fixup the map, but maybe leave the RHS
* unresolved.
* the RHS as a reference to a json string, SQL column
* name, etc.
*/
- while ((map = fr_dlist_next(&gext->map, map))) {
+ while ((map = fr_map_list_next(&gext->map, map))) {
if (!pass2_fixup_map(map, rules, NULL)) return false;
}
g = unlang_generic_to_group(c);
gext = unlang_group_to_map(g);
map = NULL;
- while ((map = fr_dlist_next(&gext->map, map))) {
+ while ((map = fr_map_list_next(&gext->map, map))) {
map_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map);
DEBUG("%.*s%s", depth + 1, unlang_spaces, buffer);
}
edit = unlang_generic_to_edit(c);
map = NULL;
- while ((map = fr_dlist_next(&edit->maps, map))) {
+ while ((map = fr_map_list_next(&edit->maps, map))) {
map_print(&FR_SBUFF_OUT(buffer, sizeof(buffer)), map);
DEBUG("%.*s%s", depth + 1, unlang_spaces, buffer);
}
fr_map_list_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_dlist_empty(&gext->map)) {
+ if (fr_map_list_empty(&gext->map)) {
cf_log_err(cs, "'map' sections cannot be empty");
goto error;
}
fr_map_list_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_dlist_empty(&gext->map)) {
+ if (fr_map_list_empty(&gext->map)) {
cf_log_err(cs, "'update' sections cannot be empty");
error:
talloc_free(g);
fr_map_list_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_dlist_empty(&gext->map)) {
+ if (fr_map_list_empty(&gext->map)) {
cf_log_err(cs, "'filter' sections cannot be empty");
return NULL;
}
*/
// if (unlang_fixup_update(map, NULL) < 0) goto fail;
- fr_dlist_insert_tail(&edit->maps, map);
+ fr_map_list_insert_tail(&edit->maps, map);
*prev = c;
return out;
*/
if (unlang_fixup_update(map, NULL) < 0) goto fail;
- fr_dlist_insert_tail(&edit->maps, map);
+ fr_map_list_insert_tail(&edit->maps, map);
*prev = c;
return out;
*/
for (map = state->map;
map != NULL;
- map = state->map = fr_dlist_next(state->map_head, map)) {
+ map = state->map = fr_map_list_next(state->map_head, map)) {
repeatable_set(frame); /* Call us again when done */
switch (state->state) {
* 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_dlist_num_elements(&edit->maps)));
+ MEM(state->el = fr_edit_list_alloc(state, fr_map_list_num_elements(&edit->maps)));
state->map_head = &edit->maps;
- state->map = fr_dlist_head(state->map_head);
+ state->map = fr_map_list_head(state->map_head);
/*
* Call process_edit to do all of the work.
(sizeof(tmpl_t) * 2) + 128),
g->num_children)); /* 128 is for string buffers */
- fr_dcursor_init(&update_state->maps, &gext->map);
+ fr_dcursor_init(&update_state->maps, fr_map_list_dlist_head(&gext->map));
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);
return result; /* 0 is OK, !0 is !OK, just like memcmp */
}
-
/*
* We apply the rules in the reply items.
*/
- if (!fr_dlist_empty(&entry->check)) {
+ if (!fr_map_list_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_dlist_next(&entry->reply, map))) {
+ while ((map = fr_map_list_next(&entry->reply, map))) {
fr_dict_attr_t const *da;
if (!tmpl_is_attr(map->lhs)) {
fr_pair_list_init(&check_list);
- while ((map = fr_dlist_next(&pl->reply, map))) {
+ while ((map = fr_map_list_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;
c->created = tmpl_value(fr_map_list_head(&head)->rhs)->vb_date;
- map = fr_dlist_pop_head(&head);
+ map = fr_map_list_pop_head(&head);
talloc_free(map);
}
c->expires = tmpl_value(fr_map_list_head(&head)->rhs)->vb_date;
- map = fr_dlist_pop_head(&head);
+ map = fr_map_list_pop_head(&head);
talloc_free(map);
}
c->key = talloc_memdup(c, key, key_len);
c->key_len = key_len;
- fr_dlist_move(&c->maps, &head);
+ fr_map_list_move(&c->maps, &head);
*out = c;
return CACHE_OK;
fr_value_box_init(&expires_value.data.literal, FR_TYPE_DATE, NULL, true);
tmpl_value(&expires_value)->vb_date = c->expires;
- cnt = c->maps.num_elements + 2;
+ cnt = fr_map_list_num_elements(&c->maps) + 2;
/*
* The majority of serialized entries should be under 1k.
}
argv_p += 3;
argv_len_p += 3;
- while ((map = fr_dlist_next(&c->maps, map))) {
+ while ((map = fr_map_list_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);
uctx.cs = client->cs;
RINDENT();
- while ((map = fr_dlist_next(maps, map))) {
+ while ((map = fr_map_list_next(maps, map))) {
char *field = NULL;
if (tmpl_aexpand(request, &field, request, map->rhs, NULL, NULL) < 0) {
return -1;
}
- while ((map = fr_dlist_next(maps, map))) {
+ while ((map = fr_map_list_next(maps, map))) {
/*
* This function doesn't change the map, so it's OK.
*/
redo:
RINDENT();
- while ((map = fr_dlist_next(maps, map))) {
+ while ((map = fr_map_list_next(maps, map))) {
int field;
char *field_name;
ssize_t slen;
fr_value_box_t *key;
- if (fr_dlist_empty(&inst->map) || !inst->key) RETURN_MODULE_NOOP;
+ if (fr_map_list_empty(&inst->map) || !inst->key) RETURN_MODULE_NOOP;
/*
* Expand the key to whatever it is. For attributes,
* and probably ':=' for server
* configuration items.
*/
- while ((map = fr_dlist_next(&entry->check, map))) {
+ while ((map = fr_map_list_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);
* worth doing.
*/
map = NULL;
- while ((map = fr_dlist_next(&entry->reply, map))) {
+ while ((map = fr_map_list_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);
/*
* Realize the map to a list of VPs
*/
- while ((map = fr_dlist_next(&pl->check, map))) {
+ while ((map = fr_map_list_next(&pl->check, map))) {
fr_pair_list_t tmp_list;
/*
fr_pair_list_free(&list);
/* ctx may be reply */
- if (!fr_dlist_empty(&pl->reply)) {
+ if (!fr_map_list_empty(&pl->reply)) {
map = NULL;
- while ((map = fr_dlist_next(&pl->reply, map))) {
+ while ((map = fr_map_list_next(&pl->reply, map))) {
fr_pair_list_t tmp_list;
fr_pair_list_init(&tmp_list);
if (map->op == T_OP_CMP_FALSE) continue;
/* 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_dlist_head(&inst->header_maps);
+ conf_map = fr_map_list_head(&inst->header_maps);
/* Load in all of the header elements supplies in the config */
while (conf_map->rhs && conf_map->lhs) {
/* Do any string expansion required in the rhs */
talloc_free(conf_buffer.buff);
/* Check if there are more values to parse */
next:
- if (!fr_dlist_next(&inst->header_maps, conf_map)) break;
+ if (!fr_map_list_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_dlist_next(&inst->header_maps, conf_map);
+ conf_map = fr_map_list_next(&inst->header_maps, conf_map);
}
/* Add the FROM: line */
generate_from_header(t, uctx, &uctx->header, inst);