global: Rename unsigned char to uint8, DynamicUCharArray to DynamicUInt8Array and DynamicUCharVector to DynamicUInt8Vector.
diff --git a/ndn-cpp/c/util/blob.h b/ndn-cpp/c/util/blob.h
index 90e665b..4784065 100644
--- a/ndn-cpp/c/util/blob.h
+++ b/ndn-cpp/c/util/blob.h
@@ -15,7 +15,7 @@
* An ndn_Blob holds a pointer to a read-only pre-allocated buffer and its length.
*/
struct ndn_Blob {
- unsigned char *value; /**< pointer to the pre-allocated buffer for the value. Must be treated as read only. */
+ uint8_t *value; /**< pointer to the pre-allocated buffer for the value. Must be treated as read only. */
unsigned int valueLength; /**< the number of bytes in value. */
};
@@ -25,7 +25,7 @@
* @param value The pre-allocated buffer for the value, or 0 for none.
* @param valueLength The number of bytes in value.
*/
-static inline void ndn_Blob_initialize(struct ndn_Blob *self, unsigned char *value, unsigned int valueLength)
+static inline void ndn_Blob_initialize(struct ndn_Blob *self, uint8_t *value, unsigned int valueLength)
{
self->value = value;
self->valueLength = valueLength;
diff --git a/ndn-cpp/c/util/crypto.c b/ndn-cpp/c/util/crypto.c
index 397a542..2cdc91b 100644
--- a/ndn-cpp/c/util/crypto.c
+++ b/ndn-cpp/c/util/crypto.c
@@ -6,7 +6,7 @@
#include "crypto.h"
-void ndn_digestSha256(const unsigned char *data, unsigned int dataLength, unsigned char *digest)
+void ndn_digestSha256(const uint8_t *data, unsigned int dataLength, uint8_t *digest)
{
SHA256_CTX sha256;
SHA256_Init(&sha256);
diff --git a/ndn-cpp/c/util/crypto.h b/ndn-cpp/c/util/crypto.h
index 9dea5b0..eb7cec5 100644
--- a/ndn-cpp/c/util/crypto.h
+++ b/ndn-cpp/c/util/crypto.h
@@ -9,6 +9,7 @@
#include <openssl/ssl.h>
#include <openssl/rsa.h>
+#include "../common.h"
#ifdef __cplusplus
extern "C" {
@@ -20,7 +21,7 @@
* @param dataLength The length of data.
* @param digest A pointer to a buffer of size SHA256_DIGEST_LENGTH to receive the data.
*/
-void ndn_digestSha256(const unsigned char *data, unsigned int dataLength, unsigned char *digest);
+void ndn_digestSha256(const uint8_t *data, unsigned int dataLength, uint8_t *digest);
#ifdef __cplusplus
}
diff --git a/ndn-cpp/c/util/dynamic-uchar-array.c b/ndn-cpp/c/util/dynamic-uint8-array.c
similarity index 60%
rename from ndn-cpp/c/util/dynamic-uchar-array.c
rename to ndn-cpp/c/util/dynamic-uint8-array.c
index aa573e8..5a7e96d 100644
--- a/ndn-cpp/c/util/dynamic-uchar-array.c
+++ b/ndn-cpp/c/util/dynamic-uint8-array.c
@@ -4,12 +4,12 @@
* See COPYING for copyright and distribution information.
*/
-#include "dynamic-uchar-array.h"
+#include "dynamic-uint8-array.h"
-ndn_Error ndn_DynamicUCharArray_reallocArray(struct ndn_DynamicUCharArray *self, unsigned int length)
+ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self, unsigned int length)
{
if (!self->realloc)
- return NDN_ERROR_DynamicUCharArray_realloc_function_pointer_not_supplied;
+ return NDN_ERROR_DynamicUInt8Array_realloc_function_pointer_not_supplied;
// See if double is enough.
unsigned int newLength = self->length * 2;
@@ -17,9 +17,9 @@
// The needed length is much greater, so use it.
newLength = length;
- unsigned char *newArray = (*self->realloc)(self, self->array, newLength);
+ uint8_t *newArray = (*self->realloc)(self, self->array, newLength);
if (!newArray)
- return NDN_ERROR_DynamicUCharArray_realloc_failed;
+ return NDN_ERROR_DynamicUInt8Array_realloc_failed;
self->array = newArray;
self->length = newLength;
diff --git a/ndn-cpp/c/util/dynamic-uchar-array.h b/ndn-cpp/c/util/dynamic-uint8-array.h
similarity index 62%
rename from ndn-cpp/c/util/dynamic-uchar-array.h
rename to ndn-cpp/c/util/dynamic-uint8-array.h
index 14f06e5..8b7b489 100644
--- a/ndn-cpp/c/util/dynamic-uchar-array.h
+++ b/ndn-cpp/c/util/dynamic-uint8-array.h
@@ -14,27 +14,27 @@
extern "C" {
#endif
-struct ndn_DynamicUCharArray {
- unsigned char *array; /**< the allocated array buffer */
+struct ndn_DynamicUInt8Array {
+ uint8_t *array; /**< the allocated array buffer */
unsigned int length; /**< the length of the allocated array buffer */
- unsigned char * (*realloc)
- (struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length); /**< a pointer to a function that reallocates array and returns a new pointer to a buffer of
+ uint8_t * (*realloc)
+ (struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length); /**< a pointer to a function that reallocates array and returns a new pointer to a buffer of
* length bytes, or 0 for error. On success, the contents of the old buffer are copied to the new one.
* On success, the original array pointer will no longer be used.
- * self is a pointer to the struct ndn_DynamicUCharArray which is calling realloc.
+ * self is a pointer to the struct ndn_DynamicUInt8Array which is calling realloc.
* This function pointer may be 0 (which causes an error if a reallocate is necessary). */
};
/**
- * Initialize an ndn_DynamicUCharArray struct with the given array buffer.
- * @param self pointer to the ndn_DynamicUCharArray struct
+ * Initialize an ndn_DynamicUInt8Array struct with the given array buffer.
+ * @param self pointer to the ndn_DynamicUInt8Array struct
* @param array the allocated array buffer
* @param length the length of the allocated array buffer
- * @param reallocFunction see ndn_DynamicUCharArray_ensureLength. This may be 0.
+ * @param reallocFunction see ndn_DynamicUInt8Array_ensureLength. This may be 0.
*/
-static inline void ndn_DynamicUCharArray_initialize
- (struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length,
- unsigned char * (*reallocFunction)(struct ndn_DynamicUCharArray *self, unsigned char *, unsigned int))
+static inline void ndn_DynamicUInt8Array_initialize
+ (struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length,
+ uint8_t * (*reallocFunction)(struct ndn_DynamicUInt8Array *self, uint8_t *, unsigned int))
{
self->array = array;
self->length = length;
@@ -42,44 +42,44 @@
}
/**
- * Do the work of ndn_DynamicUCharArray_ensureLength if realloc is necessary.
+ * Do the work of ndn_DynamicUInt8Array_ensureLength if realloc is necessary.
* If the self->realloc function pointer is null, then return an error.
* If not null, call self->realloc to reallocate self->array, and update self->length (which may be greater than length).
- * @param self pointer to the ndn_DynamicUCharArray struct
+ * @param self pointer to the ndn_DynamicUInt8Array struct
* @param length the needed minimum size for self->length
* @return 0 for success, else an error code if can't reallocate the array
*/
-ndn_Error ndn_DynamicUCharArray_reallocArray(struct ndn_DynamicUCharArray *self, unsigned int length);
+ndn_Error ndn_DynamicUInt8Array_reallocArray(struct ndn_DynamicUInt8Array *self, unsigned int length);
/**
* Ensure that self->length is greater than or equal to length. If it is, just return 0 for success.
* Otherwise, if the self->realloc function pointer is null, then return an error.
* If not null, call self->realloc to reallocate self->array, and update self->length (which may be greater than length).
- * @param self pointer to the ndn_DynamicUCharArray struct
+ * @param self pointer to the ndn_DynamicUInt8Array struct
* @param length the needed minimum size for self->length
* @return 0 for success, else an error code if need to reallocate the array but can't
*/
-static inline ndn_Error ndn_DynamicUCharArray_ensureLength(struct ndn_DynamicUCharArray *self, unsigned int length)
+static inline ndn_Error ndn_DynamicUInt8Array_ensureLength(struct ndn_DynamicUInt8Array *self, unsigned int length)
{
if (self->length >= length)
return NDN_ERROR_success;
- return ndn_DynamicUCharArray_reallocArray(self, length);
+ return ndn_DynamicUInt8Array_reallocArray(self, length);
}
/**
- * Copy value into self->array at offset, using ndn_DynamicUCharArray_ensureLength to make sure self->array has enough length.
- * @param self pointer to the ndn_DynamicUCharArray struct
+ * Copy value into self->array at offset, using ndn_DynamicUInt8Array_ensureLength to make sure self->array has enough length.
+ * @param self pointer to the ndn_DynamicUInt8Array struct
* @param value the buffer to copy from
* @param valueLength the length of the value buffer
* @param offset the offset in self->array to copy to
* @return 0 for success, else an error code if need to reallocate the array but can't
*/
-static inline ndn_Error ndn_DynamicUCharArray_set
- (struct ndn_DynamicUCharArray *self, unsigned char *value, unsigned int valueLength, unsigned int offset)
+static inline ndn_Error ndn_DynamicUInt8Array_set
+ (struct ndn_DynamicUInt8Array *self, uint8_t *value, unsigned int valueLength, unsigned int offset)
{
ndn_Error error;
- if ((error = ndn_DynamicUCharArray_ensureLength(self, valueLength + offset)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self, valueLength + offset)))
return error;
ndn_memcpy(self->array + offset, value, valueLength);
return NDN_ERROR_success;
diff --git a/ndn-cpp/c/util/ndn_memory.c b/ndn-cpp/c/util/ndn_memory.c
index 863e886..db92bde 100644
--- a/ndn-cpp/c/util/ndn_memory.c
+++ b/ndn-cpp/c/util/ndn_memory.c
@@ -7,7 +7,7 @@
#include "ndn_memory.h"
#if !HAVE_MEMCMP
-int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len)
+int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len)
{
unsigned int i;
@@ -25,7 +25,7 @@
#endif
#if !HAVE_MEMCPY
-void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len)
+void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len)
{
unsigned int i;
@@ -37,12 +37,12 @@
#endif
#if !HAVE_MEMSET
-void ndn_memset(unsigned char *dest, int val, unsigned int len)
+void ndn_memset(uint8_t *dest, int val, unsigned int len)
{
unsigned int i;
for (i = 0; i < len; i++)
- dest[i] = (unsigned char)val;
+ dest[i] = (uint8_t)val;
}
#else
int ndn_memset_stub_to_avoid_empty_file_warning = 0;
diff --git a/ndn-cpp/c/util/ndn_memory.h b/ndn-cpp/c/util/ndn_memory.h
index 85b01b3..ba0a85b 100644
--- a/ndn-cpp/c/util/ndn_memory.h
+++ b/ndn-cpp/c/util/ndn_memory.h
@@ -11,7 +11,7 @@
#ifndef NDN_MEMORY_H
#define NDN_MEMORY_H
-#include "../../../config.h"
+#include "../common.h"
#ifdef __cplusplus
extern "C" {
@@ -22,12 +22,12 @@
/**
* Use the library version of memcmp.
*/
-static inline int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len) { return memcmp(buf1, buf2, len); }
+static inline int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len) { return memcmp(buf1, buf2, len); }
#else
/**
* Use a local implementation of memcmp instead of the library version.
*/
-int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len);
+int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, unsigned int len);
#endif
#if HAVE_MEMCPY
@@ -35,12 +35,12 @@
/**
* Use the library version of memcpy.
*/
-static inline void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) { memcpy(dest, src, len); }
+static inline void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len) { memcpy(dest, src, len); }
#else
/**
* Use a local implementation of memcpy instead of the library version.
*/
-void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len);
+void ndn_memcpy(uint8_t *dest, uint8_t *src, unsigned int len);
#endif
#if HAVE_MEMSET
@@ -48,12 +48,12 @@
/**
* Use the library version of memset.
*/
-static inline void ndn_memset(unsigned char *dest, int val, unsigned int len) { memset(dest, val, len); }
+static inline void ndn_memset(uint8_t *dest, int val, unsigned int len) { memset(dest, val, len); }
#else
/**
* Use a local implementation of memset instead of the library version.
*/
-void ndn_memset(unsigned char *dest, int val, unsigned int len);
+void ndn_memset(uint8_t *dest, int val, unsigned int len);
#endif
#ifdef __cplusplus
diff --git a/ndn-cpp/c/util/ndn_realloc.c b/ndn-cpp/c/util/ndn_realloc.c
index bc701e0..8e560b9 100644
--- a/ndn-cpp/c/util/ndn_realloc.c
+++ b/ndn-cpp/c/util/ndn_realloc.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "ndn_realloc.h"
-unsigned char *ndn_realloc(struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length)
+uint8_t *ndn_realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length)
{
- return (unsigned char *)realloc(array, length);
+ return (uint8_t *)realloc(array, length);
}
diff --git a/ndn-cpp/c/util/ndn_realloc.h b/ndn-cpp/c/util/ndn_realloc.h
index 07dd053..5259f70 100644
--- a/ndn-cpp/c/util/ndn_realloc.h
+++ b/ndn-cpp/c/util/ndn_realloc.h
@@ -7,21 +7,21 @@
#ifndef NDN_NDN_REALLOC_H
#define NDN_NDN_REALLOC_H
-#include "dynamic-uchar-array.h"
+#include "dynamic-uint8-array.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Wrap the C stdlib realloc to convert to/from void * to unsigned char *.
- * This can be used by ndn_DynamicUCharArray_initialize.
+ * Wrap the C stdlib realloc to convert to/from void * to uint8_t *.
+ * This can be used by ndn_DynamicUInt8Array_initialize.
* @param self This is ignored.
* @param array the allocated array buffer to realloc.
* @param length the length for the new array buffer.
* @return the new allocated array buffer.
*/
-unsigned char *ndn_realloc(struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length);
+uint8_t *ndn_realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length);
#ifdef __cplusplus
}