From 873f12b9e6aaf39ba104db6af3d0dc687cd95f7e Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 26 Feb 2020 18:47:58 +0000 Subject: In preparation of compiling lib/dns/rdata/ files individually we need global visibility of str_totext. Rename it to isc_str_tobuffer, put it into buffer.c and delete duplicate implementations. --- usr.bin/dig/lib/isc/buffer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'usr.bin/dig/lib/isc/buffer.c') diff --git a/usr.bin/dig/lib/isc/buffer.c b/usr.bin/dig/lib/isc/buffer.c index 9dce1033ec8..421b7abe1d8 100644 --- a/usr.bin/dig/lib/isc/buffer.c +++ b/usr.bin/dig/lib/isc/buffer.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: buffer.c,v 1.7 2020/02/26 18:47:25 florian Exp $ */ +/* $Id: buffer.c,v 1.8 2020/02/26 18:47:59 florian Exp $ */ /*! \file */ @@ -364,3 +364,20 @@ isc_mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { isc_buffer_add(target, length); return (ISC_R_SUCCESS); } + +/* this used to be str_totext() in rdata.c etc. */ +isc_result_t +isc_str_tobuffer(const char *source, isc_buffer_t *target) { + unsigned int l; + isc_region_t region; + + isc_buffer_availableregion(target, ®ion); + l = strlen(source); + + if (l > region.length) + return (ISC_R_NOSPACE); + + memmove(region.base, source, l); + isc_buffer_add(target, l); + return (ISC_R_SUCCESS); +} -- cgit v1.2.3-59-g8ed1b