rhs = NULL; /* shut up clang scan */
fr_value_box_clear(&rhs_cast);
- for (vp = tmpl_cursor_init(&rcode, request, &cc, &cursor, request, map->rhs);
+ for (vp = tmpl_pair_cursor_init(&rcode, request, &cc, &cursor, request, map->rhs);
vp;
vp = fr_dcursor_next(&cursor)) {
if (cond_realize_attr(request, &rhs, &rhs_cast, map->rhs, vp, da) < 0) {
if (rcode != 0) break;
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return rcode;
}
rhs = NULL; /* shut up clang scan */
fr_value_box_clear(&rhs_cast);
- for (vp = tmpl_cursor_init(&rcode, request, &cc, &cursor, request, map->rhs);
+ for (vp = tmpl_pair_cursor_init(&rcode, request, &cc, &cursor, request, map->rhs);
vp;
vp = fr_dcursor_next(&cursor)) {
if (cond_realize_attr(request, &rhs, &rhs_cast, map->rhs, vp, NULL) < 0) {
if (rcode != 0) break;
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return rcode;
}
fr_assert(!lhs);
- for (vp = tmpl_cursor_init(&rcode, request, &cc, &cursor, request, map->lhs);
+ for (vp = tmpl_pair_cursor_init(&rcode, request, &cc, &cursor, request, map->lhs);
vp;
vp = fr_dcursor_next(&cursor)) {
fr_value_box_t lhs_cast;
continue;
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
}
break;
* the dst_list and vp pointing to the attribute or the VP
* being NULL (no attribute at that index).
*/
- dst = tmpl_cursor_init(NULL, tmp_ctx, &cc, &dst_list, request, map->lhs);
+ dst = tmpl_pair_cursor_init(NULL, tmp_ctx, &cc, &dst_list, request, map->lhs);
/*
* The destination is an attribute
*/
fr_assert(fr_pair_list_empty(&src_list));
finish:
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
talloc_free(tmp_ctx);
return rcode;
}
* Check we have pairs to copy *before*
* doing any expensive allocations.
*/
- vp = tmpl_cursor_init(&err, request, &cc_attr, &from, request, mutated->rhs);
+ vp = tmpl_pair_cursor_init(&err, request, &cc_attr, &from, request, mutated->rhs);
if (!vp) switch (err) {
default:
break;
* we should delete all LHS attributes.
*/
if (mutated->op == T_OP_SET) n = list_mod_delete_afrom_map(ctx, original, mutated);
- tmpl_cursor_clear(&cc_attr);
+ tmpl_pair_cursor_clear(&cc_attr);
goto finish;
case -2: /* No matching list */
case -3: /* No request context */
case -4: /* memory allocation error */
RPEDEBUG("Failed resolving attribute source");
- tmpl_cursor_clear(&cc_attr);
+ tmpl_pair_cursor_clear(&cc_attr);
goto error;
}
n = list_mod_generic_afrom_map(ctx, original, mutated);
if (!n) {
- tmpl_cursor_clear(&cc_attr);
+ tmpl_pair_cursor_clear(&cc_attr);
goto error;
}
attr_error:
fr_dcursor_head(&values);
fr_dcursor_free_list(&values);
- tmpl_cursor_clear(&cc_attr);
+ tmpl_pair_cursor_clear(&cc_attr);
goto error;
}
fr_dcursor_append(&values, n_vb);
} while ((vp = fr_dcursor_next(&from)));
- tmpl_cursor_clear(&cc_attr);
+ tmpl_pair_cursor_clear(&cc_attr);
}
break;
* the list and vp pointing to the attribute or the VP
* being NULL (no attribute at that index).
*/
- found = tmpl_cursor_init(NULL, request, &cc, &list, request, mod->lhs);
+ found = tmpl_pair_cursor_init(NULL, request, &cc, &list, request, mod->lhs);
/*
* The destination is an attribute
}
finish:
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return rcode;
}
* functions which can be used to iterate over only the #fr_pair_t that match a
* tmpl_t in a given list.
*
- * @see tmpl_cursor_init
+ * @see tmpl_pair_cursor_init
* @see tmpl_cursor_next
*
* Or for simplicity, there are functions which wrap the cursor functions, to copy or
fr_pair_t *vp;
// Iterate over all pairs in the request list
- for (vp = tmpl_cursor_init(NULL, &cursor, request, &list);
+ for (vp = tmpl_pair_cursor_init(NULL, &cursor, request, &list);
vp;
vp = tmpl_cursor_next(&cursor, &list)) {
// Do something
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
@endcode
*
* @param _request to locate the list in.
* @param _list to set as the target for the template.
- * @see tmpl_cursor_init
+ * @see tmpl_pair_cursor_init
* @see tmpl_cursor_next
*/
#define tmpl_init_initialiser_list(_request, _list)\
fr_type_t dst_type)
CC_HINT(nonnull (2, 3, 4));
-fr_pair_t *tmpl_cursor_init(int *err, TALLOC_CTX *ctx, tmpl_cursor_ctx_t *cc,
+fr_pair_t *tmpl_pair_cursor_init(int *err, TALLOC_CTX *ctx, tmpl_cursor_ctx_t *cc,
fr_dcursor_t *cursor, request_t *request,
tmpl_t const *vpt);
-void tmpl_cursor_clear(tmpl_cursor_ctx_t *cc);
+void tmpl_pair_cursor_clear(tmpl_cursor_ctx_t *cc);
int tmpl_copy_pairs(TALLOC_CTX *ctx, fr_pair_list_t *out,
request_t *request, tmpl_t const *vpt);
* name couldn't be resolved.
* @return a pointer to the HEAD of a list in the #request_t.
*
- * @see tmpl_cursor_init
+ * @see tmpl_pair_cursor_init
*/
fr_pair_list_t *tmpl_list_head(request_t *request, tmpl_pair_list_t list)
{
}
static inline CC_HINT(always_inline)
-void _tmpl_cursor_init(TALLOC_CTX *list_ctx, fr_pair_list_t *list, tmpl_attr_t const *ar, tmpl_cursor_ctx_t *cc)
+void _tmpl_pair_cursor_init(TALLOC_CTX *list_ctx, fr_pair_list_t *list, tmpl_attr_t const *ar, tmpl_cursor_ctx_t *cc)
{
if (fr_dlist_next(&cc->vpt->data.attribute.ar, ar)) switch (ar->ar_da->type) {
case FR_TYPE_TLV:
ar = fr_dlist_next(&vpt->data.attribute.ar, ar);
if (ar) {
list_head = &vp->vp_group;
- _tmpl_cursor_init(vp, list_head, ar, cc);
+ _tmpl_pair_cursor_init(vp, list_head, ar, cc);
curr = fr_pair_list_head(list_head);
list = &list_head->head;
continue;
*
* @see tmpl_cursor_next
*/
-fr_pair_t *tmpl_cursor_init(int *err, TALLOC_CTX *ctx, tmpl_cursor_ctx_t *cc,
- fr_dcursor_t *cursor, request_t *request, tmpl_t const *vpt)
+fr_pair_t *tmpl_pair_cursor_init(int *err, TALLOC_CTX *ctx, tmpl_cursor_ctx_t *cc,
+ fr_dcursor_t *cursor, request_t *request, tmpl_t const *vpt)
{
fr_pair_t *vp = NULL;
fr_pair_list_t *list_head;
fr_table_str_by_value(tmpl_request_ref_table, rr->request, "<INVALID>"));
}
error:
- memset(cc, 0, sizeof(*cc)); /* so tmpl_cursor_clear doesn't explode */
+ memset(cc, 0, sizeof(*cc)); /* so tmpl_pair_cursor_clear doesn't explode */
return NULL;
}
}
*/
switch (vpt->type) {
case TMPL_TYPE_ATTR:
- _tmpl_cursor_init(list_ctx, cc->list, fr_dlist_head(&vpt->data.attribute.ar), cc);
+ _tmpl_pair_cursor_init(list_ctx, cc->list, fr_dlist_head(&vpt->data.attribute.ar), cc);
break;
case TMPL_TYPE_LIST:
/** Clear any temporary state allocations
*
*/
-void tmpl_cursor_clear(tmpl_cursor_ctx_t *cc)
+void tmpl_pair_cursor_clear(tmpl_cursor_ctx_t *cc)
{
if (!fr_dlist_num_elements(&cc->nested)) return;/* Help simplify dealing with unused cursor ctxs */
fr_assert(tmpl_is_attr(vpt) || tmpl_is_list(vpt));
- for (vp = tmpl_cursor_init(&err, NULL, &cc, &from, request, vpt);
+ for (vp = tmpl_pair_cursor_init(&err, NULL, &cc, &from, request, vpt);
vp;
vp = fr_dcursor_next(&from)) {
vp = fr_pair_copy(ctx, vp);
}
fr_pair_append(out, vp);
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return err;
}
fr_pair_list_free(out);
- for (vp = tmpl_cursor_init(&err, NULL, &cc, &from, request, vpt);
+ for (vp = tmpl_pair_cursor_init(&err, NULL, &cc, &from, request, vpt);
vp;
vp = fr_dcursor_next(&from)) {
switch (vp->da->type) {
}
}
done:
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return err;
}
TMPL_VERIFY(vpt);
- vp = tmpl_cursor_init(&err, request, &cc, &cursor, request, vpt);
- tmpl_cursor_clear(&cc);
+ vp = tmpl_pair_cursor_init(&err, request, &cc, &cursor, request, vpt);
+ tmpl_pair_cursor_clear(&cc);
if (out) *out = vp;
*out = NULL;
- vp = tmpl_cursor_init(&err, NULL, &cc, &cursor, request, vpt);
- tmpl_cursor_clear(&cc);
+ vp = tmpl_pair_cursor_init(&err, NULL, &cc, &cursor, request, vpt);
+ tmpl_pair_cursor_clear(&cc);
switch (err) {
case 0:
/*
* Prime the stack!
*/
- _tmpl_cursor_init(list_ctx, cc.list, fr_dlist_head(&vpt->data.attribute.ar), &cc);
+ _tmpl_pair_cursor_init(list_ctx, cc.list, fr_dlist_head(&vpt->data.attribute.ar), &cc);
/*
* - Continue until there are no evaluation contexts
ar = n_ar;
list_head = &curr->vp_group;
list_ctx = curr; /* Allocations are under the group */
- _tmpl_cursor_init(list_ctx, list_head, ar, &cc);
+ _tmpl_pair_cursor_init(list_ctx, list_head, ar, &cc);
curr = fr_pair_list_head(list_head);
continue;
}
RIDEBUG("Attributes matching \"%s\"", fmt);
RINDENT();
- for (vp = tmpl_cursor_init(NULL, NULL, &cc, &cursor, request, vpt);
+ for (vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &cursor, request, vpt);
vp;
vp = fr_dcursor_next(&cursor)) {
fr_dict_vendor_t const *vendor;
talloc_free(dst);
}
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
REXDENT();
talloc_free(vpt);
return XLAT_ACTION_FAIL;
}
- for (vp = tmpl_cursor_init(NULL, NULL, &cc, &cursor, request, vpt);
+ for (vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &cursor, request, vpt);
vp;
vp = fr_dcursor_next(&cursor)) {
fr_token_t op = vp->op;
fr_dcursor_append(out, vb);
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
talloc_free(vpt);
return XLAT_ACTION_DONE;
* This allows users to manipulate virtual attributes as if
* they were real ones.
*/
- vp = tmpl_cursor_init(NULL, NULL, &cc, &cursor, request, vpt);
+ vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &cursor, request, vpt);
/*
* We didn't find the VP in a list, check to see if it's
default:
/*
* The cursor was set to the correct
- * position above by tmpl_cursor_init.
+ * position above by tmpl_pair_cursor_init.
*/
vp = fr_dcursor_current(&cursor); /* NULLness checked above */
value = fr_value_box_alloc(ctx, vp->data.type, vp->da, vp->data.tainted);
}
done:
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return ret;
}
MEM(cursor = talloc(ctx, fr_dcursor_t));
talloc_steal(cursor, vpt);
- vp = tmpl_cursor_init(NULL, NULL, &cc, cursor, request, vpt);
+ vp = tmpl_pair_cursor_init(NULL, NULL, &cc, cursor, request, vpt);
if (!vp) return XLAT_ACTION_DONE; /* Nothing to encode */
if (len < 0) {
RPEDEBUG("DHCP option encoding failed");
talloc_free(cursor);
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return XLAT_ACTION_FAIL;
}
p += len;
}
talloc_free(cursor);
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
/*
* Pass the options string back
}
x = 0;
- for (i = 0, vp = tmpl_cursor_init(&err, NULL, &cc, &cursor, request, vpt);
+ for (i = 0, vp = tmpl_pair_cursor_init(&err, NULL, &cc, &cursor, request, vpt);
(i < max) && (vp != NULL);
i++, vp = fr_dcursor_next(&cursor)) {
int64_t y;
RPEDEBUG("Failed converting &%.*s to an integer value", (int) vpt->len,
vpt->name);
error:
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return false;
}
if (value.vb_uint64 > INT64_MAX) {
x += y;
} /* loop over all found VPs */
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
if (err != 0) {
RWDEBUG("Can't find &%.*s. Using 0 as operand value", (int)vpt->len, vpt->name);
int alloced = VECTOR_INCREMENT, i;
MEM(vector = talloc_array(request, struct iovec, alloced));
- for (vp = tmpl_cursor_init(NULL, NULL, &cc, &cursor, request, vpt_p), i = 0;
+ for (vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &cursor, request, vpt_p), i = 0;
vp;
vp = fr_dcursor_next(&cursor), i++) {
/* need extra for line terminator */
vector[i].iov_len = inst->delimiter_len;
}
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
vector_p = vector;
vector_len = i;
}
int count = 0;
/* Iterate over the VP and add the string value to the curl_slist */
- vp = tmpl_cursor_init(NULL, NULL, &cc, &uctx->cursor, request, tmpl);
+ vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &uctx->cursor, request, tmpl);
while (vp) {
count += 1;
*out = curl_slist_append(*out, vp->vp_strvalue);
vp = fr_dcursor_next(&uctx->cursor);
}
/* Return the number of elements that were found */
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return count;
}
ssize_t copied = 0;
/* Loop through the elements to be added to the sbuff */
- vp = tmpl_cursor_init(NULL, NULL, &cc, &uctx->cursor, uctx->request, vpt);
+ vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &uctx->cursor, uctx->request, vpt);
while (vp) {
copied += fr_sbuff_in_bstrncpy(out, vp->vp_strvalue, vp->vp_length);
vp = fr_dcursor_next(&uctx->cursor);
copied += fr_sbuff_in_strcpy(out, delimeter);
}
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return copied;
}
int attachments_set = 0;
/* Check for any file attachments */
- for( vp = tmpl_cursor_init(NULL, NULL, &cc, &uctx->cursor, request, tmpl);
+ for( vp = tmpl_pair_cursor_init(NULL, NULL, &cc, &uctx->cursor, request, tmpl);
vp;
vp = fr_dcursor_next(&uctx->cursor)){
if(vp->vp_tainted) {
}
attachments_set += str_to_attachments(uctx, mime, vp->vp_strvalue, vp->vp_length, path_buffer, m);
}
- tmpl_cursor_clear(&cc);
+ tmpl_pair_cursor_clear(&cc);
return attachments_set;
}