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:
7
CHANGES
7
CHANGES
@@ -1,11 +1,12 @@
|
||||
328. [func] Added isc_base64_decodestring().
|
||||
|
||||
327. [bug] rndc.conf parser wasn't correctly recognising an IP
|
||||
address where a host specification was required.
|
||||
|
||||
326. [func] 'keys' in an 'inet' control statement is now
|
||||
required and must have at least one item in it.
|
||||
|
||||
warning is issued if a 'unix' control channel is
|
||||
defined (not supported).
|
||||
A "not supported" warning is now issued if a 'unix'
|
||||
control channel is defined.
|
||||
|
||||
325. [bug] isc_lex_gettoken was processing octal strings when
|
||||
ISC_LEXOPT_CNUMBER was not set.
|
||||
|
@@ -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;
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: base64.h,v 1.9 2000/06/06 17:50:38 gson Exp $ */
|
||||
/* $Id: base64.h,v 1.10 2000/07/11 21:51:13 tale Exp $ */
|
||||
|
||||
#ifndef ISC_BASE64_H
|
||||
#define ISC_BASE64_H 1
|
||||
@@ -53,10 +53,31 @@ isc_base64_totext(isc_region_t *source, int wordlength,
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base64_decodestring(isc_mem_t *mctx, char *cstr, isc_buffer_t *target);
|
||||
/*
|
||||
* Decode a null-terminated base64 string.
|
||||
*
|
||||
* Requires:
|
||||
* 'mctx' is non-null.
|
||||
* 'cstr' is non-null.
|
||||
* 'target' is a valid buffer.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS -- the entire decoded representation of 'cstring'
|
||||
* fit in 'target'.
|
||||
* ISC_R_BADBASE64 -- 'cstr' is not a valid base64 encoding.
|
||||
*
|
||||
* Other error returns are any possible error code from:
|
||||
* isc_lex_create(),
|
||||
* isc_lex_openbuffer(),
|
||||
* isc_base64_tobuffer().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
|
||||
/*
|
||||
* Convert base64 encoded text into data.
|
||||
* Convert base64 encoded text from a lexer context into data.
|
||||
*
|
||||
* Requires:
|
||||
* 'lex' is a valid lexer context
|
||||
@@ -71,6 +92,7 @@ isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BASE64_H */
|
||||
|
Reference in New Issue
Block a user