summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-11-26 17:15:07 +0000
committerVincent Sanders <vince@kyllikki.org>2014-11-26 17:15:07 +0000
commit33e92ff899ca76809d8e826bd885a746264fa4e8 (patch)
tree39ddcb4913f69b5008fd55ae64e9cf29a8b76058 /src
parent2633e6f22b3de1030da5e65d5128672324ac9565 (diff)
downloadlibnsutils-33e92ff899ca76809d8e826bd885a746264fa4e8.tar.gz
libnsutils-33e92ff899ca76809d8e826bd885a746264fa4e8.tar.bz2
Fix error enum to not conflict and add monotonic time implementation
Diffstat (limited to 'src')
-rw-r--r--src/base64.c12
-rw-r--r--src/time.c15
2 files changed, 17 insertions, 10 deletions
diff --git a/src/base64.c b/src/base64.c
index c299955..c11364f 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 nsu_base64_encode_alloc(const uint8_t *input,
+nsuerror nsu_base64_encode_alloc(const uint8_t *input,
size_t input_length,
uint8_t **output,
size_t *output_length)
@@ -47,7 +47,7 @@ nserror nsu_base64_encode_alloc(const uint8_t *input,
encoded = malloc(encoded_len);
if (encoded == NULL) {
- return NSERROR_NOMEM;
+ return NSUERROR_NOMEM;
}
for (i = 0, j = 0; i < input_length;) {
@@ -71,12 +71,12 @@ nserror nsu_base64_encode_alloc(const uint8_t *input,
*output = encoded;
*output_length = encoded_len;
- return NSERROR_OK;
+ return NSUERROR_OK;
}
/* exported interface documented in nsutils/base64.h */
-nserror nsu_base64_decode_alloc(const uint8_t *input,
+nsuerror nsu_base64_decode_alloc(const uint8_t *input,
size_t input_length,
uint8_t **output,
size_t *output_length)
@@ -104,7 +104,7 @@ nserror nsu_base64_decode_alloc(const uint8_t *input,
decoded = malloc(decoded_len);
if (decoded == NULL) {
- return NSERROR_NOMEM;
+ return NSUERROR_NOMEM;
}
sextet_idx = 0;
@@ -177,5 +177,5 @@ nserror nsu_base64_decode_alloc(const uint8_t *input,
*output = decoded;
*output_length = opidx;
- return NSERROR_OK;
+ return NSUERROR_OK;
}
diff --git a/src/time.c b/src/time.c
index c0a5dff..2b83f3f 100644
--- a/src/time.c
+++ b/src/time.c
@@ -14,12 +14,19 @@
#include <stdint.h>
#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
+#include <sys/time.h>
#include "nsutils/time.h"
-nserror nsu_nsu_getmonotonic_ms(uint64_t *current)
+/* exported interface documented in nsutils/time.h */
+nsuerror nsu_nsu_getmonotonic_ms(uint64_t *current)
{
- return NSERROR_NOT_IMPLEMENTED;
+ /** \todo Implement this properly! */
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ *current = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+
+ return NSUERROR_OK;
}