while ((vp = fr_dlist_next(list, vp))) {
if (fr_dict_attr_cmp(ns->ar->ar_da, vp->da) == 0) break;
+ ns->num++;
}
return vp;
}
}
+
+ssize_t tmpl_dcursor_print(fr_sbuff_t *out, tmpl_dcursor_ctx_t const *cc)
+{
+ tmpl_dcursor_nested_t *ns;
+ tmpl_request_t *rr = NULL;
+ tmpl_attr_t *ar = NULL;
+ fr_sbuff_t our_out = FR_SBUFF(out);
+
+ /*
+ * Print all the request references
+ */
+ while ((rr = tmpl_request_list_next(&cc->vpt->data.attribute.rr, rr))) {
+ FR_SBUFF_IN_STRCPY_RETURN(&our_out, fr_table_str_by_value(tmpl_request_ref_table, rr->request, "<INVALID>"));
+ FR_SBUFF_IN_CHAR_RETURN(&our_out, '.');
+ }
+
+ ns = fr_dlist_head(&cc->nested);
+
+ /*
+ * This also prints out the things we're looping over in nested?
+ */
+ while ((ar = tmpl_attr_list_next(tmpl_attr(cc->vpt), ar))) {
+ if (ns->ar == ar) break;
+
+ if (ar->ar_da == request_attr_local) continue;
+
+ FR_SBUFF_IN_STRCPY_RETURN(&our_out, ar->da->name);
+ FR_SBUFF_IN_CHAR_RETURN(&our_out, '.');
+ }
+
+ /*
+ * Subtract one from the number, because ???
+ *
+ * @todo - for foo.[*], print out the actual da being used, which involves tracking the current
+ * vp, too. Except that we would then have to track _all_ instances of _all_ vps in a list,
+ * which is bad. Perhaps just forbid the use of foo.[*] instead.
+ */
+ while (true) {
+ fr_assert(ns->num > 0);
+
+ FR_SBUFF_IN_STRCPY_RETURN(&our_out, ns->ar->da->name);
+ FR_SBUFF_IN_CHAR_RETURN(&our_out, '[');
+ FR_SBUFF_IN_SPRINTF_RETURN(&our_out, "%zd", ns->num - 1);
+ FR_SBUFF_IN_CHAR_RETURN(&our_out, ']');
+
+ ns = fr_dlist_next(&cc->nested, ns);
+ if (!ns) break;
+
+ FR_SBUFF_IN_CHAR_RETURN(&our_out, ']');
+ }
+
+ FR_SBUFF_SET_RETURN(out, &our_out);
+}
fr_dcursor_t cursor; //!< Cursor to track where we are in the list in case
///< we're doing counts.
+ size_t num; //!< which attribute number we are looking at
};
/** Maintains state between cursor calls
#define tmpl_dcursor_build_init(_err, _ctx, _cc, _cursor, _request, _vpt, _build, _uctx) \
_tmpl_dcursor_init(_err, _ctx, _cc, _cursor, _request, _vpt, _build, _uctx)
+
+ssize_t tmpl_dcursor_print(fr_sbuff_t *out, tmpl_dcursor_ctx_t const *cc);