summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-11-26 15:50:58 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2014-11-26 15:50:58 (GMT)
commitf9916482a7a13ab19c15a7b0ca46857cccff85a1 (patch)
treeb8adb901bd830152fd79766d67671570146de709
parent3a12f6ecc7b201601a7f902c5fdeaf21bb1930b7 (diff)
downloadlibnsutils-f9916482a7a13ab19c15a7b0ca46857cccff85a1.tar.gz
libnsutils-f9916482a7a13ab19c15a7b0ca46857cccff85a1.tar.bz2
fix base64 implementation namespace
-rw-r--r--include/nsutils/base64.h4
-rw-r--r--src/base64.c4
-rw-r--r--test/base64.c12
3 files changed, 12 insertions, 8 deletions
diff --git a/include/nsutils/base64.h b/include/nsutils/base64.h
index 139a1b6..f4622e8 100644
--- a/include/nsutils/base64.h
+++ b/include/nsutils/base64.h
@@ -17,12 +17,12 @@
#include <nsutils/errors.h>
-nserror base64_encode_alloc(const uint8_t *input,
+nserror nsu_base64_encode_alloc(const uint8_t *input,
size_t input_length,
uint8_t **output,
size_t *output_length);
-nserror base64_decode_alloc(const uint8_t *input,
+nserror nsu_base64_decode_alloc(const uint8_t *input,
size_t input_length,
uint8_t **output,
size_t *output_length);
diff --git a/src/base64.c b/src/base64.c
index b2e020b..c299955 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -33,7 +33,7 @@ static uint8_t encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
static unsigned int mod_table[] = {0, 2, 1};
/* exported interface documented in nsutils/base64.h */
-nserror base64_encode_alloc(const uint8_t *input,
+nserror nsu_base64_encode_alloc(const uint8_t *input,
size_t input_length,
uint8_t **output,
size_t *output_length)
@@ -76,7 +76,7 @@ nserror base64_encode_alloc(const uint8_t *input,
/* exported interface documented in nsutils/base64.h */
-nserror base64_decode_alloc(const uint8_t *input,
+nserror nsu_base64_decode_alloc(const uint8_t *input,
size_t input_length,
uint8_t **output,
size_t *output_length)
diff --git a/test/base64.c b/test/base64.c
index f86e65e..0b4b942 100644
--- a/test/base64.c
+++ b/test/base64.c
@@ -32,10 +32,13 @@ int main(int argc, char**argv)
if (argc == 1) {
/* encode */
- base64_encode_alloc(buffer, buffer_len, &output, &output_len);
- } else {
+ nsu_base64_encode_alloc(buffer, buffer_len, &output, &output_len);
+ } else if ((argv[1][0] == '-') && (argv[1][1] == 'd')) {
/* decode */
- base64_decode_alloc(buffer, buffer_len, &output, &output_len);
+ nsu_base64_decode_alloc(buffer, buffer_len, &output, &output_len);
+ } else {
+ fprintf(stderr, "Usage: %s [-d]\n", argv[0]);
+ return 1;
}
if (output != NULL) {
@@ -44,5 +47,6 @@ int main(int argc, char**argv)
}
free(buffer);
-
+
+ return 0;
}