if ((tmpl_list(attr->lhs) != tmpl_list(map->lhs))) {
RWDEBUG("valuepair \"%pV\" has conflicting list qualifier (%s vs %s), skipping...",
fr_box_strvalue_len(self->values[i]->bv_val, self->values[i]->bv_len),
- fr_table_str_by_value(pair_list_table, tmpl_list(attr->lhs), "<INVALID>"),
- fr_table_str_by_value(pair_list_table, tmpl_list(map->lhs), "<INVALID>"));
+ tmpl_list_name(tmpl_list(attr->lhs), "<INVALID>"),
+ tmpl_list_name(tmpl_list(map->lhs), "<INVALID>"));
goto next_pair;
}
tmpl_t *vpt;
static tmpl_rules_t rules = {
.attr = {
- .list_def = PAIR_LIST_REQUEST,
.allow_unknown = true,
.allow_unresolved = true,
.allow_foreign = true
};
fr_sbuff_t sbuff = FR_SBUFF_IN(cp->value, strlen(cp->value));
+ rules.attr.list_def = PAIR_LIST_REQUEST;
/*
* Parse the cast operator for barewords
*/
if (!list) {
REDEBUG("Mapping \"%.*s\" -> \"%.*s\" cannot be performed due to to invalid list qualifier \"%s\" in left side of map",
(int)map->rhs->len, map->rhs->name, (int)map->lhs->len, map->lhs->name,
- fr_table_str_by_value(pair_list_table, list_ref, "<INVALID>"));
+ tmpl_list_name(list_ref, "<INVALID>"));
rcode = -2;
goto finish;
}
if (!list) {
REDEBUG("Mapping \"%.*s\" -> \"%.*s\" cannot be performed due to to invalid list qualifier \"%s\"",
(int)map->rhs->len, map->rhs->name, (int)map->lhs->len, map->lhs->name,
- fr_table_str_by_value(pair_list_table, list_ref, "<INVALID>"));
+ tmpl_list_name(list_ref, "<INVALID>"));
return NULL;
}
}
/** @} */
+/** Return the name of a tmpl list or def if list not provided
+ *
+*/
+static inline char const *tmpl_list_name(fr_dict_attr_t const *list, char const *def)
+{
+ return (list ? list->name : def);
+}
+
/** @name Field accessors for #TMPL_TYPE_XLAT
*
* @{
list = tmpl_get_list(request, vpt);
if (!list) {
fr_strerror_printf("List \"%s\" not available in this context",
- fr_table_str_by_value(pair_list_table, tmpl_list(vpt), "<INVALID>"));
+ tmpl_list_name(tmpl_list(vpt), "<INVALID>"));
if (err) *err = -2;
goto error;
}
list_head = tmpl_list_head(request, tmpl_list(vpt));
if (!list_head) {
fr_strerror_printf("List \"%s\" not available in this context",
- fr_table_str_by_value(pair_list_table, tmpl_list(vpt), "<INVALID>"));
+ tmpl_list_name(tmpl_list(vpt), "<INVALID>"));
return -2;
}
list_ctx = tmpl_list_ctx(request, tmpl_list(vpt));
}
RWDEBUG2("List \"%s\" is not available",
- fr_table_str_by_value(pair_list_table, list, "<INVALID>"));
+ tmpl_list_name(list, "<INVALID>"));
return NULL;
}
*
* Defaults are used if a NULL rules pointer is passed to the parsing function.
*/
-static tmpl_rules_t const default_rules = {
- .attr = {
- .list_def = PAIR_LIST_REQUEST,
- },
-};
+#define DEFAULT_RULES tmpl_rules_t const default_rules = { .attr = { .list_def = PAIR_LIST_REQUEST }}
/* clang-format off */
i++;
}
- FR_FAULT_LOG("list: %s", fr_table_str_by_value(pair_list_table, vpt->data.attribute.list, "<INVALID>"));
+ FR_FAULT_LOG("list: %s", tmpl_list_name(vpt->data.attribute.list, "<INVALID>"));
tmpl_attr_ref_list_debug(tmpl_attr(vpt));
}
tmpl_request_t *tail = tmpl_request_list_tail(out);
unsigned int depth = 0;
fr_sbuff_marker_t m;
+ DEFAULT_RULES;
if (!at_rules) at_rules = &default_rules.attr;
bool is_raw = false;
tmpl_attr_rules_t const *at_rules;
fr_sbuff_marker_t m_l;
+ DEFAULT_RULES;
if (!t_rules) t_rules = &default_rules;
at_rules = &t_rules->attr;
tmpl_t **out, char const *name, tmpl_rules_t const *t_rules)
{
ssize_t slen, name_len;
+ DEFAULT_RULES;
if (!t_rules) t_rules = &default_rules; /* Use the defaults */
char *str;
tmpl_t *vpt = NULL;
+ DEFAULT_RULES;
if (!t_rules) t_rules = &default_rules; /* Use the defaults */
if (tmpl_list(vpt) != PAIR_LIST_REQUEST) { /* Don't print the default list */
if (printed_rr) FR_SBUFF_IN_CHAR_RETURN(&our_out, '.');
- FR_SBUFF_IN_TABLE_STR_RETURN(&our_out, pair_list_table, tmpl_list(vpt), "<INVALID>");
+ slen = fr_sbuff_in_strcpy(&our_out, tmpl_list_name(tmpl_list(vpt), "<INVALID>"));
+ if (slen < 0) return slen;
if (tmpl_attr_list_num_elements(tmpl_attr(vpt))) FR_SBUFF_IN_CHAR_RETURN(&our_out, '.');
/*
if (!vpt->rules.attr.list_as_attr && ((tmpl_list(vpt) == PAIR_LIST_UNKNOWN) || tmpl_list(vpt) > PAIR_LIST_STATE)) {
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
- "attribute \"%s\" has invalid list (%i)",
- file, line, tmpl_attr_tail_da(vpt)->name, tmpl_list(vpt));
+ "attribute \"%s\" has invalid list (%s)",
+ file, line, tmpl_attr_tail_da(vpt)->name,
+ tmpl_list_name(tmpl_list(vpt), "<INVALID>"));
}
tmpl_attr_verify(file, line, vpt);
if (name2) {
snprintf(list_buffer, sizeof(list_buffer), "&%s", name2);
} else {
- snprintf(list_buffer, sizeof(list_buffer), "&%s", fr_table_str_by_value(pair_list_table, unlang_ctx->rules->attr.list_def, "<INVALID>"));
+ snprintf(list_buffer, sizeof(list_buffer), "&%s", tmpl_list_name(unlang_ctx->rules->attr.list_def, "<INVALID>"));
}
/*
case FR_TYPE_STRUCTURAL:
if (vpt) {
RIDEBUG2("&%s.%s = {",
- fr_table_str_by_value(pair_list_table, tmpl_list(vpt), "<INVALID>"),
+ tmpl_list_name(tmpl_list(vpt), "<INVALID>"),
vp->da->name);
} else {
RIDEBUG2("%s = {", vp->da->name);
default:
if (vpt) {
RIDEBUG2("&%s.%s = %pV",
- fr_table_str_by_value(pair_list_table, tmpl_list(vpt), "<INVALID>"),
+ tmpl_list_name(tmpl_list(vpt), "<INVALID>"),
vp->da->name,
&vp->data);
} else {
while ((rr = tmpl_request_list_next(list, rr))) {
INFO_INDENT("ref %d", rr->request);
}
- INFO_INDENT("list %d", tmpl_list(node->vpt));
+ INFO_INDENT("list %s", tmpl_list_name(tmpl_list(node->vpt), "<INVALID>"));
if (tmpl_attr_tail_num(node->vpt) != NUM_UNSPEC) {
if (tmpl_attr_tail_num(node->vpt) == NUM_COUNT) {
INFO_INDENT("[#]");
if (!vp) continue;
}
RINDENT();
- RDEBUG2("&%s:%pP", fr_table_str_by_value(pair_list_table, tmpl_list(dst), ""), vp);
+ RDEBUG2("&%s:%pP", tmpl_list_name(tmpl_list(dst), ""), vp);
REXDENT();
fr_pair_list_init(&tmp_list);