From 416ef5e2bf59bb2e45066a1d5d91ac677c0f48e5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 10 Dec 2014 03:05:47 +0000 Subject: Initial commit --- src/libs6dns/s6dns_analyze_record_strings.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/libs6dns/s6dns_analyze_record_strings.c (limited to 'src/libs6dns/s6dns_analyze_record_strings.c') diff --git a/src/libs6dns/s6dns_analyze_record_strings.c b/src/libs6dns/s6dns_analyze_record_strings.c new file mode 100644 index 0000000..c2aa15a --- /dev/null +++ b/src/libs6dns/s6dns_analyze_record_strings.c @@ -0,0 +1,23 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include +#include +#include + +int s6dns_analyze_record_strings (genwrite_t *gp, s6dns_message_rr_t const *rr, char const *packet, unsigned int packetlen, unsigned int start) +{ + stralloc sa = STRALLOC_ZERO ; + char buf[rr->rdlength] ; + unsigned int pos = start ; + register int r = s6dns_message_get_strings(buf, rr->rdlength, packet, packetlen, &pos) ; + if (r < 0) return 0 ; + if (rr->rdlength != pos - start) return (errno = EPROTO, 0) ; + if (!string_quote(&sa, buf, r)) return 0 ; + r = (*gp->put)(gp->target, sa.s, sa.len) >= 0 ; + stralloc_free(&sa) ; + return r ; +} -- cgit v1.3.1