static const char *edit_names[4] = {
"invalid",
"delete",
- "record_value",
+ "value",
"insert",
};
#endif
*
* After this function returns, it's safe to edit the pair.
*/
-int fr_edit_list_record_value(fr_edit_list_t *el, fr_pair_t *vp)
+int fr_edit_list_save_value(fr_edit_list_t *el, fr_pair_t *vp)
{
if (!el) return 0;
return edit_record(el, FR_EDIT_VALUE, vp, NULL, NULL);
}
+/** Write a new value to the #fr_value_box_t
+ *
+ * After this function returns, the value has been updated.
+ */
+int fr_edit_list_replace_value(fr_edit_list_t *el, fr_pair_t *vp, fr_value_box_t *box)
+{
+ if (!el) return 0;
+
+ if (!fr_type_is_leaf(vp->vp_type)) return -1;
+
+ if (edit_record(el, FR_EDIT_VALUE, vp, NULL, NULL) < 0) return -1;
+
+ if (!fr_type_is_fixed_size(vp->vp_type)) fr_value_box_clear(&vp->data);
+ fr_value_box_copy_shallow(NULL, &vp->data, box);
+ return 0;
+}
+
/** Replace a pair with another one.
*
* This function mirrors fr_pair_replace().
* edit VPs, recording edits
*
* free temporary map
- * talloc_free(edit list)
+ * commit(edit list)
*/
int fr_edit_list_delete(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *vp) CC_HINT(nonnull(2,3));
-int fr_edit_list_record_value(fr_edit_list_t *el, fr_pair_t *vp) CC_HINT(nonnull(2));
+int fr_edit_list_save_value(fr_edit_list_t *el, fr_pair_t *vp) CC_HINT(nonnull(2));
+
+int fr_edit_list_replace_value(fr_edit_list_t *el, fr_pair_t *vp, fr_value_box_t *box) CC_HINT(nonnull(2,3));
int fr_edit_list_replace(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp) CC_HINT(nonnull(2,3,4));
el = fr_edit_list_alloc(NULL, 5);
fr_assert(el != NULL);
- rcode = fr_edit_list_record_value(el, vp);
+ rcode = fr_edit_list_save_value(el, vp);
TEST_CHECK(rcode == 0);
TEST_CHECK(vp->vp_uint32 == 0);
el = fr_edit_list_alloc(NULL, 5);
fr_assert(el != NULL);
- rcode = fr_edit_list_record_value(el, vp);
+ rcode = fr_edit_list_save_value(el, vp);
TEST_CHECK(rcode == 0);
TEST_CHECK(vp->vp_uint32 == 0);