summaryrefslogtreecommitdiffstats
path: root/usr.bin/dig/lib/isc/hex.c
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2020-02-26 18:47:58 +0000
committerflorian <florian@openbsd.org>2020-02-26 18:47:58 +0000
commit873f12b9e6aaf39ba104db6af3d0dc687cd95f7e (patch)
tree80081a71df3f42a8248c43286fef79e79ede9a40 /usr.bin/dig/lib/isc/hex.c
parentIn preparation of compiling lib/dns/rdata/ files individually we need (diff)
downloadwireguard-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/hex.c')
-rw-r--r--usr.bin/dig/lib/isc/hex.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/usr.bin/dig/lib/isc/hex.c b/usr.bin/dig/lib/isc/hex.c
index bb55f3b9260..35512536c35 100644
--- a/usr.bin/dig/lib/isc/hex.c
+++ b/usr.bin/dig/lib/isc/hex.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hex.c,v 1.4 2020/02/26 18:47:25 florian Exp $ */
+/* $Id: hex.c,v 1.5 2020/02/26 18:47:59 florian Exp $ */
/*! \file */
@@ -33,12 +33,6 @@
return (_r); \
} while (0)
-/*
- * BEW: These static functions are copied from lib/dns/rdata.c.
- */
-static isc_result_t
-str_totext(const char *source, isc_buffer_t *target);
-
static const char hex[] = "0123456789ABCDEF";
isc_result_t
@@ -55,7 +49,7 @@ isc_hex_totext(isc_region_t *source, int wordlength,
while (source->length > 0) {
buf[0] = hex[(source->base[0] >> 4) & 0xf];
buf[1] = hex[(source->base[0]) & 0xf];
- RETERR(str_totext(buf, target));
+ RETERR(isc_str_tobuffer(buf, target));
isc_region_consume(source, 1);
loops++;
@@ -63,7 +57,7 @@ isc_hex_totext(isc_region_t *source, int wordlength,
(int)((loops + 1) * 2) >= wordlength)
{
loops = 0;
- RETERR(str_totext(wordbreak, target));
+ RETERR(isc_str_tobuffer(wordbreak, target));
}
}
return (ISC_R_SUCCESS);
@@ -135,19 +129,3 @@ isc_hex_decodestring(const char *cstr, isc_buffer_t *target) {
RETERR(hex_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
-
-static isc_result_t
-str_totext(const char *source, isc_buffer_t *target) {
- unsigned int l;
- isc_region_t region;
-
- isc_buffer_availableregion(target, &region);
- 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);
-}