]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
tmpl: More macro renaming
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 9 May 2020 15:13:03 +0000 (10:13 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 9 May 2020 15:13:08 +0000 (10:13 -0500)
src/lib/ldap/map.c
src/lib/server/cf_parse.c
src/lib/server/cond_eval.c
src/lib/server/cond_tokenize.c
src/lib/server/map_async.c
src/lib/server/tmpl.c
src/lib/server/tmpl.h
src/lib/unlang/compile.c
src/lib/unlang/switch.c
src/modules/rlm_csv/rlm_csv.c

index d40e36b623e760a47551eb4ab4e79e105d04e4bb..0685bc4f5a4e626f5607e96eedceb1b42bf12bb4 100644 (file)
@@ -193,7 +193,7 @@ int fr_ldap_map_verify(vp_map_t *map, UNUSED void *instance)
                break;
 
        case TMPL_TYPE_ATTR_UNPARSED:
-               cf_log_err(map->ci, "Unknown attribute %s", tmpl_unknown_name(map->lhs));
+               cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unparsed(map->lhs));
                return -1;
 
        default:
@@ -214,7 +214,7 @@ int fr_ldap_map_verify(vp_map_t *map, UNUSED void *instance)
                break;
 
        case TMPL_TYPE_ATTR_UNPARSED:
-               cf_log_err(map->ci, "Unknown attribute %s", tmpl_unknown_name(map->rhs));
+               cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unparsed(map->rhs));
                return -1;
 
        default:
index c08bd844b05ae9e44b630055c56314922e10f21c..87fda358799a5724890d823c16e7c1d9afe3f525 100644 (file)
@@ -1412,7 +1412,7 @@ int cf_section_parse_pass2(void *base, CONF_SECTION *cs)
                         *      All attributes should have been defined by this point.
                         */
                        case TMPL_TYPE_ATTR_UNPARSED:
-                               cf_log_err(cp, "Unknown attribute '%s'", tmpl_unknown_name(vpt));
+                               cf_log_err(cp, "Unknown attribute '%s'", tmpl_attr_unparsed(vpt));
                                talloc_free(vpt);       /* Free last (vpt needed for log) */
                                return -1;
 
index 048e442984d8300a4d182ec52e499e3c92856998..c0b830159f9ce998a15d424cc294522f1d6fdc5b 100644 (file)
@@ -416,7 +416,7 @@ do {\
        if (map->op == T_OP_REG_EQ) {
                cast_type = FR_TYPE_STRING;
 
-               if (tmpl_is_xlat_struct(map->rhs)) escape = regex_escape;
+               if (tmpl_is_xlat(map->rhs)) escape = regex_escape;
        }
        else
 #endif
index f62f26e8ac9bdbf09cd4d5f39a004c4c25255d83..71019ebf1eb8054d8b8ab3b8ced6dc733cb2d892 100644 (file)
@@ -256,7 +256,7 @@ static ssize_t cond_check_cast(fr_cond_t *c, char const *start,
        }
 
 #ifdef HAVE_REGEX
-       if (tmpl_is_regex(c->data.map->rhs)) {
+       if (tmpl_is_regex_unparsed(c->data.map->rhs)) {
                *error = "Cannot use cast with regex comparison";
                return -(rhs - start);
        }
@@ -512,8 +512,8 @@ static ssize_t cond_check_attrs(fr_cond_t *c, char const *start,
         *      there, too.
         */
        if (tmpl_is_attr(c->data.map->lhs) &&
-           (tmpl_is_xlat(c->data.map->rhs) ||
-            tmpl_is_xlat_struct(c->data.map->rhs) ||
+           (tmpl_is_xlat_unparsed(c->data.map->rhs) ||
+            tmpl_is_xlat(c->data.map->rhs) ||
             tmpl_is_exec(c->data.map->rhs))) {
                if (tmpl_da(c->data.map->lhs)->type == FR_TYPE_IPV4_ADDR) {
                        c->cast = fr_dict_attr_child_by_num(fr_dict_root(fr_dict_internal()),
@@ -815,7 +815,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, CONF_SECTION *cs,
                        return_P(fr_strerror());
                }
 
-               fr_assert(!tmpl_is_regex(c->data.vpt));
+               fr_assert(!tmpl_is_regex_unparsed(c->data.vpt));
 
                if (tmpl_define_unknown_attr(c->data.vpt) < 0) {
                        p = lhs - tlen;
@@ -1020,7 +1020,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, CONF_SECTION *cs,
 
                        memset(&regex_flags, 0, sizeof(regex_flags));
 
-                       if (!tmpl_is_regex(c->data.map->rhs)) {
+                       if (!tmpl_is_regex_unparsed(c->data.map->rhs)) {
                                return_rhs("Expected regex");
                        }
 
index 300da89b568d9514a006f0dcc61a5bebc2ca235c..b3e7aee8a95de5c0d88340d25d98bd2da8950f9a 100644 (file)
@@ -259,7 +259,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
 
        fr_assert(tmpl_is_list(original->lhs) ||
                   tmpl_is_attr(original->lhs) ||
-                  tmpl_is_xlat_struct(original->lhs));
+                  tmpl_is_xlat(original->lhs));
 
        *out = NULL;
 
index 9d8193bc53c12329bb0d0bab7b38837fdd0ee2be..6bafcb9ff058e1264ea96aa0b785fa5ec2e7a483 100644 (file)
@@ -796,7 +796,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, attr_ref_error_t *err,
                        slen = -(p - name);
                        goto error;
                }
-               tmpl_unknown_name_set(vpt, talloc_strndup(vpt, p, q - p));
+               tmpl_attr_unparsed_set(vpt, talloc_strndup(vpt, p, q - p));
                p = q;
 
                goto do_num;
@@ -1447,7 +1447,7 @@ int tmpl_define_unknown_attr(vp_tmpl_t *vpt)
  *     are identical.
  *
  * @param[in] dict_def Default dictionary to use if none is
- *                     specified by the tmpl_unknown_name.
+ *                     specified by the tmpl_attr_unparsed.
  * @param[in] vpt      specifying undefined attribute to add.
  *                     ``tmpl_da`` pointer will be updated to
  *                     point to the #fr_dict_attr_t inserted
@@ -1471,10 +1471,10 @@ int tmpl_define_undefined_attr(fr_dict_t *dict_def, vp_tmpl_t *vpt,
 
        if (!tmpl_is_attr_unparsed(vpt)) return 1;
 
-       if (fr_dict_attr_add(dict_def, fr_dict_root(fr_dict_internal()), tmpl_unknown_name(vpt), -1, type, flags) < 0) {
+       if (fr_dict_attr_add(dict_def, fr_dict_root(fr_dict_internal()), tmpl_attr_unparsed(vpt), -1, type, flags) < 0) {
                return -1;
        }
-       da = fr_dict_attr_by_name(dict_def, tmpl_unknown_name(vpt));
+       da = fr_dict_attr_by_name(dict_def, tmpl_attr_unparsed(vpt));
        if (!da) return -1;
 
        if (type != da->type) {
@@ -2115,7 +2115,7 @@ size_t tmpl_snprint_attr_str(size_t *need, char *out, size_t outlen, vp_tmpl_t c
                goto inst_and_tag;
 
        case TMPL_TYPE_ATTR_UNPARSED:
-               p = tmpl_unknown_name(vpt);
+               p = tmpl_attr_unparsed(vpt);
                goto print_name;
 
        case TMPL_TYPE_ATTR:
@@ -2611,7 +2611,7 @@ void tmpl_verify(char const *file, int line, vp_tmpl_t const *vpt)
 {
        fr_assert(vpt);
 
-       if (tmpl_is_unknown(vpt)) {
+       if (tmpl_is_uninitialised(vpt)) {
                fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: vp_tmpl_t type was "
                                     "TMPL_TYPE_UNINITIALISED (uninitialised)", file, line);
        }
index 9078fc63d064092aef0428348c7b01589864cbed..b817502c9d4f26c67a438319bf1f651fd38c1acc 100644 (file)
@@ -149,18 +149,23 @@ typedef enum tmpl_type_e {
 
 /** Helpers to verify the type of #vp_tmpl_t
  */
-#define tmpl_is_unknown(vpt)           (vpt->type == TMPL_TYPE_UNINITIALISED)
-#define tmpl_is_unparsed(vpt)          (vpt->type == TMPL_TYPE_UNPARSED)
-#define tmpl_is_xlat(vpt)              (vpt->type == TMPL_TYPE_XLAT_UNPARSED)
+#define tmpl_is_uninitialised(vpt)     (vpt->type == TMPL_TYPE_UNINITIALISED)
+
+#define tmpl_is_null(vpt)              (vpt->type == TMPL_TYPE_NULL)
+#define tmpl_is_data(vpt)              (vpt->type == TMPL_TYPE_DATA)
+
 #define tmpl_is_attr(vpt)              (vpt->type == TMPL_TYPE_ATTR)
-#define tmpl_is_attr_unparsed(vpt)     (vpt->type == TMPL_TYPE_ATTR_UNPARSED)
 #define tmpl_is_list(vpt)              (vpt->type == TMPL_TYPE_LIST)
-#define tmpl_is_regex(vpt)             (vpt->type == TMPL_TYPE_REGEX_UNPARSED)
+
+#define tmpl_is_xlat(vpt)              (vpt->type == TMPL_TYPE_XLAT)
 #define tmpl_is_exec(vpt)              (vpt->type == TMPL_TYPE_EXEC)
-#define tmpl_is_data(vpt)              (vpt->type == TMPL_TYPE_DATA)
-#define tmpl_is_xlat_struct(vpt)       (vpt->type == TMPL_TYPE_XLAT)
-#define tmpl_is_regex_struct(vpt)      (vpt->type == TMPL_TYPE_REGEX)
-#define tmpl_is_null(vpt)              (vpt->type == TMPL_TYPE_NULL)
+
+#define tmpl_is_regex(vpt)             (vpt->type == TMPL_TYPE_REGEX)
+
+#define tmpl_is_unparsed(vpt)          (vpt->type == TMPL_TYPE_UNPARSED)
+#define tmpl_is_attr_unparsed(vpt)     (vpt->type == TMPL_TYPE_ATTR_UNPARSED)
+#define tmpl_is_xlat_unparsed(vpt)     (vpt->type == TMPL_TYPE_XLAT_UNPARSED)
+#define tmpl_is_regex_unparsed(vpt)    (vpt->type == TMPL_TYPE_REGEX_UNPARSED)
 
 extern fr_table_num_sorted_t const tmpl_type_table[];
 extern size_t tmpl_type_table_len;
@@ -243,7 +248,7 @@ struct vp_tmpl_s {
 #define tmpl_list(_tmpl)               (_tmpl)->data.attribute.list
 #define tmpl_da(_tmpl)                 (_tmpl)->data.attribute.da
 #define tmpl_unknown(_tmpl)            (_tmpl)->data.attribute.unknown.da
-#define tmpl_unknown_name(_tmpl)       (_tmpl)->data.attribute.unknown.name
+#define tmpl_attr_unparsed(_tmpl)      (_tmpl)->data.attribute.unknown.name
 #define tmpl_num(_tmpl)                        (_tmpl)->data.attribute.num
 #define tmpl_tag(_tmpl)                        (_tmpl)->data.attribute.tag
 
@@ -252,7 +257,7 @@ struct vp_tmpl_s {
  */
 #define tmpl_request_set(_tmpl, _request)      (_tmpl)->data.attribute.request = (_request)
 #define tmpl_list_set(_tmpl, _list)            (_tmpl)->data.attribute.list = (_list)
-#define tmpl_unknown_name_set(_tmpl, _name)            (_tmpl)->data.attribute.unknown.name = (_name)
+#define tmpl_attr_unparsed_set(_tmpl, _name)           (_tmpl)->data.attribute.unknown.name = (_name)
 #define tmpl_tag_set(_tmpl, _tag)              (_tmpl)->data.attribute.tag = (_tag)
 #define tmpl_num_set(_tmpl, _num)              (_tmpl)->data.attribute.num = (_num)
 #define tmpl_da_set(_tmpl, _da)                        (_tmpl)->data.attribute.da = (_da)
index adbcccdabe48c8ce6bd47e36ff79e2b87670c020..9a6b2643f153154d1306ffd19b0416896d649197 100644 (file)
@@ -256,7 +256,7 @@ static bool pass2_fixup_xlat(CONF_ITEM const *ci, vp_tmpl_t **pvpt, bool convert
 
        vpt = *pvpt;
 
-       fr_assert(tmpl_is_xlat(vpt));
+       fr_assert(tmpl_is_xlat_unparsed(vpt));
 
        slen = xlat_tokenize(vpt, &head, vpt->name, talloc_array_length(vpt->name) - 1, rules);
 
@@ -335,7 +335,7 @@ static bool pass2_fixup_regex(CONF_ITEM const *ci, vp_tmpl_t *vpt, vp_tmpl_rules
        ssize_t slen;
        regex_t *preg;
 
-       fr_assert(tmpl_is_regex(vpt));
+       fr_assert(tmpl_is_regex_unparsed(vpt));
 
        /*
         *      It's a dynamic expansion.  We can't expand the string,
@@ -427,7 +427,7 @@ static bool pass2_fixup_tmpl(CONF_ITEM const *ci, vp_tmpl_t **pvpt, vp_tmpl_rule
 {
        vp_tmpl_t *vpt = *pvpt;
 
-       if (tmpl_is_xlat(vpt)) {
+       if (tmpl_is_xlat_unparsed(vpt)) {
                return pass2_fixup_xlat(ci, pvpt, convert, NULL, rules);
        }
 
@@ -570,7 +570,7 @@ static bool pass2_fixup_map(fr_cond_t *c, vp_tmpl_rules_t const *rules)
        /*
         *      Precompile xlat's
         */
-       if (tmpl_is_xlat(map->lhs)) {
+       if (tmpl_is_xlat_unparsed(map->lhs)) {
                /*
                 *      Compile the LHS to an attribute reference only
                 *      if the RHS is a literal.
@@ -639,7 +639,7 @@ static bool pass2_fixup_map(fr_cond_t *c, vp_tmpl_rules_t const *rules)
                }
        }
 
-       if (tmpl_is_xlat(map->rhs)) {
+       if (tmpl_is_xlat_unparsed(map->rhs)) {
                /*
                 *      Convert the RHS to an attribute reference only
                 *      if the LHS is an attribute reference, AND is
@@ -709,12 +709,12 @@ static bool pass2_fixup_map(fr_cond_t *c, vp_tmpl_rules_t const *rules)
        }
 
 #ifdef HAVE_REGEX
-       if (tmpl_is_regex(map->rhs)) {
+       if (tmpl_is_regex_unparsed(map->rhs)) {
                if (!pass2_fixup_regex(map->ci, map->rhs, rules)) {
                        return false;
                }
        }
-       fr_assert(!tmpl_is_regex(map->lhs));
+       fr_assert(!tmpl_is_regex_unparsed(map->lhs));
 #endif
 
        /*
@@ -747,7 +747,7 @@ static bool pass2_fixup_map(fr_cond_t *c, vp_tmpl_rules_t const *rules)
 
        if (!paircmp_find(tmpl_da(map->lhs))) return true;
 
-       if (tmpl_is_regex(map->rhs)) {
+       if (tmpl_is_regex_unparsed(map->rhs)) {
                cf_log_err(map->ci, "Cannot compare virtual attribute %s via a regex", map->lhs->name);
                return false;
        }
@@ -793,7 +793,7 @@ static bool pass2_cond_callback(fr_cond_t *c, void *uctx)
         *      Fix up the template.
         */
        case COND_TYPE_EXISTS:
-               fr_assert(!tmpl_is_regex(c->data.vpt));
+               fr_assert(!tmpl_is_regex_unparsed(c->data.vpt));
                return pass2_fixup_tmpl(c->ci, &c->data.vpt, unlang_ctx->rules, true);
 
        /*
@@ -813,7 +813,7 @@ static bool pass2_cond_callback(fr_cond_t *c, void *uctx)
 
 static bool pass2_fixup_update_map(vp_map_t *map, vp_tmpl_rules_t const *rules, fr_dict_attr_t const *parent)
 {
-       if (tmpl_is_xlat(map->lhs)) {
+       if (tmpl_is_xlat_unparsed(map->lhs)) {
                fr_assert(tmpl_xlat(map->lhs) == NULL);
 
                /*
@@ -875,7 +875,7 @@ static bool pass2_fixup_update_map(vp_map_t *map, vp_tmpl_rules_t const *rules,
        }
 
        if (map->rhs) {
-               if (tmpl_is_xlat(map->rhs)) {
+               if (tmpl_is_xlat_unparsed(map->rhs)) {
                        fr_assert(tmpl_xlat(map->rhs) == NULL);
 
                        /*
@@ -887,7 +887,7 @@ static bool pass2_fixup_update_map(vp_map_t *map, vp_tmpl_rules_t const *rules,
                        }
                }
 
-               fr_assert(!tmpl_is_regex(map->rhs));
+               fr_assert(!tmpl_is_regex_unparsed(map->rhs));
 
                if (tmpl_is_attr_unparsed(map->rhs)) {
                        if (!pass2_fixup_undefined(map->ci, map->rhs, rules)) return false;
@@ -2379,7 +2379,7 @@ static unlang_t *compile_case(unlang_t *parent, unlang_compile_t *unlang_ctx, CO
                 *      Compile and sanity check xlat
                 *      expansions.
                 */
-               if (tmpl_is_xlat(vpt)) {
+               if (tmpl_is_xlat_unparsed(vpt)) {
                        fr_dict_attr_t const *da = NULL;
 
                        if (tmpl_is_attr(f->vpt)) da = tmpl_da(f->vpt);
index 32d47782dc29cb2e52365e140b45d7f6e8062882..bb8cf36e173c9ba929b0dda4d9e735d9ea9f7a5a 100644 (file)
@@ -80,8 +80,8 @@ static unlang_action_t unlang_switch(REQUEST *request, UNUSED rlm_rcode_t *presu
         *      is evaluated once instead of for each 'case'
         *      statement.
         */
-       if (tmpl_is_xlat_struct(g->vpt) ||
-           tmpl_is_xlat(g->vpt) ||
+       if (tmpl_is_xlat(g->vpt) ||
+           tmpl_is_xlat_unparsed(g->vpt) ||
            tmpl_is_exec(g->vpt)) {
                char *p;
                ssize_t len;
@@ -132,8 +132,8 @@ static unlang_action_t unlang_switch(REQUEST *request, UNUSED rlm_rcode_t *presu
                        /*
                         *      Use the pre-expanded string.
                         */
-               } else if (tmpl_is_xlat_struct(g->vpt) ||
-                          tmpl_is_xlat(g->vpt) ||
+               } else if (tmpl_is_xlat(g->vpt) ||
+                          tmpl_is_xlat_unparsed(g->vpt) ||
                           tmpl_is_exec(g->vpt)) {
                        map.rhs = h->vpt;
                        map.lhs = &vpt;
index dbc4aea87ab0cc4688434bbb48f6dc2d83d781ac..ea86f9163a8d32c1f838b1b1748f1c323e7dd836 100644 (file)
@@ -283,7 +283,7 @@ static int csv_map_verify(vp_map_t *map, void *instance)
                break;
 
        case TMPL_TYPE_ATTR_UNPARSED:
-               cf_log_err(map->ci, "Unknown attribute %s", tmpl_unknown_name(map->lhs));
+               cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unparsed(map->lhs));
                return -1;
 
        default:
@@ -305,7 +305,7 @@ static int csv_map_verify(vp_map_t *map, void *instance)
                break;
 
        case TMPL_TYPE_ATTR_UNPARSED:
-               cf_log_err(map->ci, "Unknown attribute %s", tmpl_unknown_name(map->rhs));
+               cf_log_err(map->ci, "Unknown attribute %s", tmpl_attr_unparsed(map->rhs));
                return -1;
 
        default: