From 743aed3ee3952c13f79289d1a7b8efe2aeaa20bf Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Wed, 25 Mar 2009 17:59:54 +0100 Subject: Refactoring related to isc_buffer_t. --- str.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'str.c') diff --git a/str.c b/str.c index 684f73a..53d02e9 100644 --- a/str.c +++ b/str.c @@ -24,8 +24,10 @@ * Review all the REQUIRE() macros. */ +#include #include #include +#include #include #include @@ -342,6 +344,30 @@ cleanup: return result; } +isc_result_t +str_cat_isc_region(ld_string_t *dest, const isc_region_t *region) +{ + REQUIRE(dest != NULL); + REQUIRE(region != NULL); + + return str_cat_char_len(dest, (char *)region->base, region->length); +} + +isc_result_t +str_cat_isc_buffer(ld_string_t *dest, const isc_buffer_t *buffer) +{ + isc_region_t region; + isc_buffer_t *deconst_buffer; + + REQUIRE(dest != NULL); + REQUIRE(ISC_BUFFER_VALID(buffer)); + + DE_CONST(buffer, deconst_buffer); + isc_buffer_usedregion(deconst_buffer, ®ion); + + return str_cat_isc_region(dest, ®ion); +} + /* * Concatenate string src to string dest. */ @@ -412,6 +438,20 @@ str_toupper(ld_string_t *str) *ptr = toupper((unsigned char)*ptr); } +void +str_to_isc_buffer(const ld_string_t *src, isc_buffer_t *dest) +{ + size_t len; + + REQUIRE(src != NULL); + REQUIRE(dest != NULL); + + len = str_len_internal(src) - 1; + + isc_buffer_init(dest, src->data, len); + isc_buffer_add(dest, len); +} + int str_casecmp_char(const ld_string_t *s1, const char *s2) { -- cgit