summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}