From: Arran Cudbard-Bell Date: Thu, 28 May 2020 19:41:32 +0000 (-0500) Subject: Remove unused tmpl functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6fcf296f0fb0ecfd17c4e6bbde3335de6f5a271;p=thirdparty%2Ffreeradius-server.git Remove unused tmpl functions --- diff --git a/src/lib/server/tmpl.c b/src/lib/server/tmpl.c index 5cd9ccc8390..b12232b3e93 100644 --- a/src/lib/server/tmpl.c +++ b/src/lib/server/tmpl.c @@ -1851,9 +1851,6 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, * #tmpl_cast_in_place can be used to convert #TMPL_TYPE_UNPARSED to a #TMPL_TYPE_DATA of a * specified #fr_type_t. * - * #tmpl_cast_in_place_str does the same as #tmpl_cast_in_place, but will always convert to - * #fr_type_t #FR_TYPE_STRING. - * * #tmpl_cast_to_vp does the same as #tmpl_cast_in_place, but outputs a #VALUE_PAIR. * * #tmpl_define_unknown_attr converts a #TMPL_TYPE_ATTR with an unknown #fr_dict_attr_t to a @@ -1916,82 +1913,6 @@ int tmpl_cast_in_place(vp_tmpl_t *vpt, fr_type_t type, fr_dict_attr_t const *enu return 0; } -/** Convert #vp_tmpl_t of type #TMPL_TYPE_UNPARSED to #TMPL_TYPE_DATA of type #FR_TYPE_STRING - * - * @note Conversion is done in place. - * - * @param[in,out] vpt The template to modify. Must be of type #TMPL_TYPE_UNPARSED. - */ -void tmpl_cast_in_place_str(vp_tmpl_t *vpt) -{ - fr_assert(vpt != NULL); - fr_assert(tmpl_is_unparsed(vpt)); - - vpt->type = TMPL_TYPE_DATA; - - fr_value_box_strdup(vpt, &vpt->data.literal, NULL, vpt->name, false); -} - -/** Expand a #vp_tmpl_t to a string, parse it as an attribute of type cast, create a #VALUE_PAIR from the result - * - * @note Like #tmpl_expand, but produces a #VALUE_PAIR. - * - * @param out Where to write pointer to the new #VALUE_PAIR. - * @param request The current #REQUEST. - * @param vpt to cast. Must be one of the following types: - * - #TMPL_TYPE_UNPARSED - * - #TMPL_TYPE_EXEC - * - #TMPL_TYPE_XLAT_UNPARSED - * - #TMPL_TYPE_XLAT - * - #TMPL_TYPE_ATTR - * - #TMPL_TYPE_DATA - * @param cast type of #VALUE_PAIR to create. - * @return - * - 0 on success. - * - -1 on failure. - */ -int tmpl_cast_to_vp(VALUE_PAIR **out, REQUEST *request, - vp_tmpl_t const *vpt, fr_dict_attr_t const *cast) -{ - int rcode; - VALUE_PAIR *vp; - char *p; - - TMPL_VERIFY(vpt); - - *out = NULL; - - MEM(vp = fr_pair_afrom_da(request, cast)); - if (tmpl_is_data(vpt)) { - VP_VERIFY(vp); - fr_assert(vp->vp_type == tmpl_value_type(vpt)); - - fr_value_box_copy(vp, &vp->data, tmpl_value(vpt)); - *out = vp; - return 0; - } - - rcode = tmpl_aexpand(vp, &p, request, vpt, NULL, NULL); - if (rcode < 0) { - fr_pair_list_free(&vp); - return rcode; - } - - /* - * New escapes: strings are in binary form. - */ - if (vp->vp_type == FR_TYPE_STRING) { - fr_pair_value_strdup(vp, p); - } else if (fr_pair_value_from_str(vp, p, rcode, '\0', false) < 0) { - talloc_free(p); - fr_pair_list_free(&vp); - return -1; - } - - *out = vp; - return 0; -} - /** Add an unknown #fr_dict_attr_t specified by a #vp_tmpl_t to the main dictionary * * @param vpt to add. ``tmpl_da`` pointer will be updated to point to the diff --git a/src/lib/server/tmpl.h b/src/lib/server/tmpl.h index ad0f522a34b..6d154f649fc 100644 --- a/src/lib/server/tmpl.h +++ b/src/lib/server/tmpl.h @@ -656,11 +656,6 @@ ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *name, siz int tmpl_cast_in_place(vp_tmpl_t *vpt, fr_type_t type, fr_dict_attr_t const *enumv); -void tmpl_cast_in_place_str(vp_tmpl_t *vpt); - -int tmpl_cast_to_vp(VALUE_PAIR **out, REQUEST *request, - vp_tmpl_t const *vpt, fr_dict_attr_t const *cast); - size_t tmpl_snprint_attr_str(size_t *need, char *out, size_t outlen, vp_tmpl_t const *vpt); size_t tmpl_snprint(size_t *need, char *out, size_t outlen, vp_tmpl_t const *vpt);