]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add function for copying one pair's value to another pair
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 5 May 2019 21:11:29 +0000 (17:11 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 5 May 2019 21:21:21 +0000 (17:21 -0400)
src/lib/util/pair.c
src/lib/util/pair.h

index faf4d1f461367060288deec265dad8c30895f1dc..5b6c368871d7155d7e9ce4339f9b8b6e78a8189f 100644 (file)
@@ -2041,6 +2041,19 @@ void fr_pair_list_move(VALUE_PAIR **to, VALUE_PAIR **from)
        fr_pair_add(to, head_new);
 }
 
+/** Copy the value from one pair to another
+ *
+ * @param[out] out     where to copy the value to.
+ *                     will clear assigned value.
+ * @param[in] in       where to copy the value from
+ *                     Must have an assigned value.
+ */
+void fr_pair_value_copy(VALUE_PAIR *out, VALUE_PAIR *in)
+{
+       if (!fr_cond_assert(in->data.type != FR_TYPE_INVALID)) return;
+       if (out->data.type != FR_TYPE_INVALID) fr_value_box_clear(&out->data);
+       fr_value_box_copy(out, &out->data, &in->data);
+}
 
 /** Convert string value to native attribute value
  *
index ce7fd49004134f6d8aa7467dc1d2aadbb42d75c9..7ffb9c8f3c968643ced2a7dc3b5a788add4d8150 100644 (file)
@@ -304,6 +304,7 @@ int         fr_pair_list_copy_by_ancestor(TALLOC_CTX *ctx, VALUE_PAIR **to,
 void           fr_pair_list_move(VALUE_PAIR **to, VALUE_PAIR **from);
 
 /* Value manipulation */
+void           fr_pair_value_copy(VALUE_PAIR *out, VALUE_PAIR *in);
 int            fr_pair_value_from_str(VALUE_PAIR *vp, char const *value, ssize_t len, char quote, bool tainted);
 void           fr_pair_value_memcpy(VALUE_PAIR *vp, uint8_t const *src, size_t len);
 void           fr_pair_value_memsteal(VALUE_PAIR *vp, uint8_t const *src);