]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Tue, 11 Jul 2000 23:11:16 +0000 (23:11 +0000)
committerAndreas Gustafsson <source@isc.org>
Tue, 11 Jul 2000 23:11:16 +0000 (23:11 +0000)
328.    [func]          Added isc_base64_decodestring().

CHANGES
lib/isc/base64.c
lib/isc/include/isc/base64.h

diff --git a/CHANGES b/CHANGES
index 8707e18b4592f563b81fbeb9f13e146a82a7410c..3595cd4d8835e6b47ef583df9f0909e626029037 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,4 @@
+ 328.  [func]          Added isc_base64_decodestring().
 
  325.  [bug]           isc_lex_gettoken was processing octal strings when
                        ISC_LEXOPT_CNUMBER was not set.
index a6f01ba50f06a35f61254be23a36b51622f8910c..5083c4510f66e40847612a63c39a21d3d47de206 100644 (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.15.2.1 2000/07/11 23:11:15 gson 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;
index 7fe9b316c2eb878f47c0d9d4ebe995f932bfef01..5162dc6fca224cd5039e4c6290d5a5d460d8c7d3 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: base64.h,v 1.9 2000/06/06 17:50:38 gson Exp $ */
+/* $Id: base64.h,v 1.9.2.1 2000/07/11 23:11:16 gson 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 */