diff options
| author | 2020-02-26 18:47:58 +0000 | |
|---|---|---|
| committer | 2020-02-26 18:47:58 +0000 | |
| commit | 873f12b9e6aaf39ba104db6af3d0dc687cd95f7e (patch) | |
| tree | 80081a71df3f42a8248c43286fef79e79ede9a40 /usr.bin/dig/lib/isc/buffer.c | |
| parent | In preparation of compiling lib/dns/rdata/ files individually we need (diff) | |
| download | wireguard-openbsd-873f12b9e6aaf39ba104db6af3d0dc687cd95f7e.tar.xz wireguard-openbsd-873f12b9e6aaf39ba104db6af3d0dc687cd95f7e.zip | |
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.
Diffstat (limited to 'usr.bin/dig/lib/isc/buffer.c')
| -rw-r--r-- | usr.bin/dig/lib/isc/buffer.c | 19 |
1 files changed, 18 insertions, 1 deletions
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); +} |
