]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove duplicate name resolution function
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 29 Nov 2020 23:35:42 +0000 (16:35 -0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 29 Nov 2020 23:35:42 +0000 (16:35 -0700)
We don't need it now we have multi-level namespaces

src/lib/server/tmpl_tokenize.c
src/lib/util/dict.h
src/lib/util/dict_util.c

index 7ccb96b728fb0b7382160e4b93d7a78aa1f51abb..2ffd423a42be18970b20cb093a2e0d8f13ad5c11 100644 (file)
@@ -1408,7 +1408,8 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
         *      or its reference in the case of group attributes.
         */
        } else {
-               slen = fr_dict_attr_child_by_name_substr(&dict_err, &da, parent, name, false);
+               slen = fr_dict_attr_by_name_substr(&dict_err, &da, parent,
+                                                  name, p_rules ? p_rules->terminals : NULL);
        }
 
        /*
@@ -2919,10 +2920,9 @@ static inline CC_HINT(always_inline) int tmpl_attr_resolve(tmpl_t *vpt)
                                                                     NULL,
                                                                     !vpt->rules.disallow_internal);
                } else {
-                       slen = fr_dict_attr_child_by_name_substr(NULL, &da, parent,
-                                                                &FR_SBUFF_IN(ar->ar_unresolved,
-                                                                             strlen(ar->ar_unresolved)),
-                                                                false);
+                       slen = fr_dict_attr_by_name_substr(NULL, &da, parent,
+                                                          &FR_SBUFF_IN(ar->ar_unresolved, strlen(ar->ar_unresolved)),
+                                                          NULL);
                }
                if (slen <= 0) return -2;       /* Can't resolve, maybe the caller can resolve later */
 
index d7c0e214cfeef52ad84807dfe04c241c6f923d21..2858044d64b7df7a9f34467323fc70131feeace1 100644 (file)
@@ -478,7 +478,8 @@ fr_dict_attr_t const        *fr_dict_vendor_da_by_num(fr_dict_attr_t const *vendor_root
 
 ssize_t                        fr_dict_attr_by_qualified_name_substr(fr_dict_attr_err_t *err, fr_dict_attr_t const **out,
                                                              fr_dict_t const *dict_def,
-                                                             fr_sbuff_t *name, fr_sbuff_term_t const *tt, bool fallback)
+                                                             fr_sbuff_t *name, fr_sbuff_term_t const *tt,
+                                                             bool fallback)
                                                              CC_HINT(nonnull(2, 4));
 
 ssize_t                        fr_dict_attr_by_name_substr(fr_dict_attr_err_t *err, fr_dict_attr_t const **out,
@@ -503,10 +504,6 @@ fr_dict_attr_t const       *fr_dict_attr_child_by_da(fr_dict_attr_t const *parent, fr_
 
 fr_dict_attr_t const   *fr_dict_attr_child_by_num(fr_dict_attr_t const *parent, unsigned int attr);
 
-ssize_t                        fr_dict_attr_child_by_name_substr(fr_dict_attr_err_t *err,
-                                                         fr_dict_attr_t const **out, fr_dict_attr_t const *parent,
-                                                         fr_sbuff_t *name, bool is_direct_decendent);
-
 fr_dict_enum_t         *fr_dict_enum_by_value(fr_dict_attr_t const *da, fr_value_box_t const *value);
 
 char const             *fr_dict_enum_name_by_value(fr_dict_attr_t const *da, fr_value_box_t const *value);
index 0964df80e90eb995de5c65d1e103fe37fed3ca6e..f5c8d02679e3a8291174b4a5fa2ff2f6f7c02198 100644 (file)
@@ -2383,7 +2383,8 @@ error:
  */
 ssize_t fr_dict_attr_by_qualified_name_substr(fr_dict_attr_err_t *err, fr_dict_attr_t const **out,
                                             fr_dict_t const *dict_def,
-                                            fr_sbuff_t *name, fr_sbuff_term_t const *tt, bool fallback)
+                                            fr_sbuff_t *name, fr_sbuff_term_t const *tt,
+                                            bool fallback)
 {
        return dict_attr_search(err, out, dict_def, name, tt, fallback, fr_dict_attr_by_name_substr);
 }
@@ -2677,54 +2678,6 @@ fr_dict_attr_t const *fr_dict_attr_child_by_num(fr_dict_attr_t const *parent, un
        return dict_attr_child_by_num(parent, attr);
 }
 
-
-/** Look up an attribute by name in the dictionary that contains the parent
- *
- */
-ssize_t fr_dict_attr_child_by_name_substr(fr_dict_attr_err_t *err,
-                                         fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *name,
-                                         bool is_direct_decendent)
-{
-       ssize_t                 slen;
-       fr_dict_attr_t const    *ref;
-       DA_VERIFY(parent);
-
-       /*
-        *      Do any necessary dereferencing
-        */
-       ref = fr_dict_attr_ref(parent);
-       if (ref) parent = ref;
-
-       if (!fr_dict_attr_has_ext(parent, FR_DICT_ATTR_EXT_CHILDREN)) {
-               fr_strerror_printf("Parent (%s) is a %s, it cannot contain nested attributes",
-                                  parent->name,
-                                  fr_table_str_by_value(fr_value_box_type_table,
-                                                        parent->type, "?Unknown?"));
-               if (err) *err = FR_DICT_ATTR_NO_CHILDREN;
-               return 0;
-
-       } else if (!dict_attr_children(parent)) {
-               fr_strerror_printf("Parent (%s) has no children", parent->name);
-               if (err) *err = FR_DICT_ATTR_NO_CHILDREN;
-               return 0;
-       }
-
-       slen = fr_dict_attr_by_name_substr(err, out, parent, name, NULL);
-       if (slen <= 0) return slen;
-
-       if (is_direct_decendent) {
-               if ((*out)->parent != parent) {
-               not_decendent:
-                       fr_strerror_printf("%s is not a descendent of parent (%s)", parent->name, (*out)->name);
-                       if (err) *err = FR_DICT_ATTR_NOT_DESCENDENT;
-                       *out = NULL;
-                       return 0;
-               }
-       } else if (!fr_dict_attr_common_parent(parent, *out, true)) goto not_decendent;
-
-       return slen;
-}
-
 /** Lookup the structure representing an enum value in a #fr_dict_attr_t
  *
  * @param[in] da               to search in.