2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

328. [func] Added isc_base64_decodestring().

(This is basically bin/named/server.c:base64_cstring_tobuffer(), which I
will remove in another revision that will not need to be pulled up.  I also
would like to change isc_base64_totext() and isc_base64_tobuffer() to be
isc_base64_encoderegion() and isc_base64_decodelexer(), unless there are
exceptions.  I find their existing names to be quite confusing with regard to
what translation function each performs.)
This commit is contained in:
David Lawrence
2000-07-11 21:51:13 +00:00
parent f4d9f465cd
commit 9bf765ab3a
3 changed files with 62 additions and 6 deletions

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: base64.c,v 1.15 2000/06/21 21:56:29 tale Exp $ */
/* $Id: base64.c,v 1.16 2000/07/11 21:51:12 tale Exp $ */
#include <config.h>
@@ -160,6 +160,39 @@ isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base64_decodestring(isc_mem_t *mctx, char *cstr, isc_buffer_t *target) {
isc_result_t result;
isc_buffer_t source;
isc_lex_t *lex = NULL;
isc_boolean_t isopen = ISC_FALSE;
REQUIRE(mctx != NULL);
REQUIRE(cstr != NULL);
REQUIRE(ISC_BUFFER_VALID(target));
isc_buffer_init(&source, cstr, strlen(cstr));
isc_buffer_add(&source, strlen(cstr));
result = isc_lex_create(mctx, 256, &lex);
if (result == ISC_R_SUCCESS)
result = isc_lex_openbuffer(lex, &source);
if (result == ISC_R_SUCCESS) {
isopen = ISC_TRUE;
result = isc_base64_tobuffer(lex, target, -1);
}
if (isopen)
(void)isc_lex_close(lex);
if (lex != NULL)
isc_lex_destroy(&lex);
return (result);
}
static isc_result_t
str_totext(const char *source, isc_buffer_t *target) {
unsigned int l;