global: Rename unsigned char to uint8, DynamicUCharArray to DynamicUInt8Array and DynamicUCharVector to DynamicUInt8Vector.
diff --git a/ndn-cpp/c/data.h b/ndn-cpp/c/data.h
index 44d345e..81489f5 100644
--- a/ndn-cpp/c/data.h
+++ b/ndn-cpp/c/data.h
@@ -19,12 +19,12 @@
* An ndn_Signature struct holds the signature bits and other info representing the signature in a data packet.
*/
struct ndn_Signature {
- unsigned char *digestAlgorithm; /**< pointer to pre-allocated buffer. 0 for none.
+ uint8_t *digestAlgorithm; /**< pointer to pre-allocated buffer. 0 for none.
* If none, default is 2.16.840.1.101.3.4.2.1 (sha-256). */
unsigned int digestAlgorithmLength; /**< length of digestAlgorithm. 0 for none */
- unsigned char *witness; /**< pointer to pre-allocated buffer. 0 for none. */
+ uint8_t *witness; /**< pointer to pre-allocated buffer. 0 for none. */
unsigned int witnessLength; /**< length of witness. 0 for none */
- unsigned char *signature;
+ uint8_t *signature;
unsigned int signatureLength;
struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
struct ndn_KeyLocator keyLocator;
@@ -81,7 +81,7 @@
struct ndn_Signature signature;
struct ndn_Name name;
struct ndn_MetaInfo metaInfo;
- unsigned char *content; /**< pointer to the content */
+ uint8_t *content; /**< pointer to the content */
unsigned int contentLength; /**< length of content */
};
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index de34f9d..98dde11 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -76,7 +76,7 @@
if (!(metaInfo->type < 0 || metaInfo->type == ndn_ContentType_DATA)) {
// Not the default of DATA, so we need to encode the type.
- unsigned char *typeBytes;
+ uint8_t *typeBytes;
unsigned int typeBytesLength = 3;
if (metaInfo->type == ndn_ContentType_ENCR)
typeBytes = "\x10\xD0\x91";
@@ -127,7 +127,7 @@
(decoder, ndn_BinaryXml_DTag_Timestamp, &metaInfo->timestampMilliseconds))
return error;
- unsigned char *typeBytes;
+ uint8_t *typeBytes;
unsigned int typeBytesLength;
if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
(decoder, ndn_BinaryXml_DTag_Type, 0, &typeBytes, &typeBytesLength)))
diff --git a/ndn-cpp/c/encoding/binary-xml-decoder.c b/ndn-cpp/c/encoding/binary-xml-decoder.c
index 1ccaccc..4be2450 100644
--- a/ndn-cpp/c/encoding/binary-xml-decoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-decoder.c
@@ -34,13 +34,13 @@
* @param resultOut output the parsed integer.
* @return 0 for success, else an error code, including if an element of value is not a decimal digit.
*/
-static ndn_Error parseUnsignedDecimalInt(unsigned char *value, unsigned int valueLength, unsigned int *resultOut)
+static ndn_Error parseUnsignedDecimalInt(uint8_t *value, unsigned int valueLength, unsigned int *resultOut)
{
unsigned int result = 0;
unsigned int i;
for (i = 0; i < valueLength; ++i) {
- unsigned char digit = value[i];
+ uint8_t digit = value[i];
if (!(digit >= '0' && digit <= '9'))
return NDN_ERROR_element_of_value_is_not_a_decimal_digit;
@@ -140,7 +140,7 @@
}
ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, unsigned char **value, unsigned int *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@@ -173,7 +173,7 @@
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, unsigned char **value, unsigned int *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength)
{
ndn_Error error;
int gotExpectedTag;
@@ -192,7 +192,7 @@
}
ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned char **value, unsigned int *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@@ -213,7 +213,7 @@
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned char **value, unsigned int *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength)
{
ndn_Error error;
int gotExpectedTag;
@@ -234,7 +234,7 @@
ndn_Error ndn_BinaryXmlDecoder_readUnsignedIntegerDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned int *value)
{
- unsigned char *udataValue;
+ uint8_t *udataValue;
unsigned int udataValueLength;
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, &udataValue, &udataValueLength)))
@@ -271,7 +271,7 @@
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, double *milliseconds)
{
ndn_Error error;
- unsigned char *bytes;
+ uint8_t *bytes;
unsigned int bytesLength;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, 0, &bytes, &bytesLength)))
return error;
@@ -299,7 +299,7 @@
return NDN_ERROR_success;
}
-double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(unsigned char *bytes, unsigned int bytesLength)
+double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(uint8_t *bytes, unsigned int bytesLength)
{
double result = 0.0;
unsigned int i;
diff --git a/ndn-cpp/c/encoding/binary-xml-decoder.h b/ndn-cpp/c/encoding/binary-xml-decoder.h
index 3b58787..dfa9b97 100644
--- a/ndn-cpp/c/encoding/binary-xml-decoder.h
+++ b/ndn-cpp/c/encoding/binary-xml-decoder.h
@@ -7,6 +7,7 @@
#ifndef NDN_BINARYXMLDECODER_H
#define NDN_BINARYXMLDECODER_H
+#include "../common.h"
#include "../errors.h"
#ifdef __cplusplus
@@ -14,12 +15,12 @@
#endif
struct ndn_BinaryXmlDecoder {
- unsigned char *input;
+ uint8_t *input;
unsigned int inputLength;
unsigned int offset;
};
-static inline void ndn_BinaryXmlDecoder_initialize(struct ndn_BinaryXmlDecoder *self, unsigned char *input, unsigned int inputLength)
+static inline void ndn_BinaryXmlDecoder_initialize(struct ndn_BinaryXmlDecoder *self, uint8_t *input, unsigned int inputLength)
{
self->input = input;
self->inputLength = inputLength;
@@ -77,7 +78,7 @@
* and the binary data is absent
*/
ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, unsigned char **value, unsigned int *valueLength);
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength);
/**
* Peek at the next element and if it is the expectedTag, call ndn_BinaryXmlDecoder_readBinaryDTagElement.
@@ -92,7 +93,7 @@
* @return 0 for success, else an error code, including if allowNull is 0 and the binary data is absent
*/
ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, unsigned char **value, unsigned int *valueLength);
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, unsigned int *valueLength);
/**
* Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be expectedTag.
@@ -105,7 +106,7 @@
* @return 0 for success, else an error code, including an error if not the expected tag, or if the item is not UDATA.
*/
ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned char **value, unsigned int *valueLength);
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength);
/**
* Peek at the next element and if it is the expectedTag, call ndn_BinaryXmlDecoder_readUDataDTagElement.
@@ -119,7 +120,7 @@
* @return 0 for success, else an error code.
*/
ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned char **value, unsigned int *valueLength);
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, unsigned int *valueLength);
/**
* Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be expectedTag.
@@ -176,7 +177,7 @@
* @param bytesLength the length of bytes
* @return the result
*/
-double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(unsigned char *bytes, unsigned int bytesLength);
+double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(uint8_t *bytes, unsigned int bytesLength);
/**
* Set the offset into the input, used for the next read.
diff --git a/ndn-cpp/c/encoding/binary-xml-element-reader.c b/ndn-cpp/c/encoding/binary-xml-element-reader.c
index 837363c..51f635f 100644
--- a/ndn-cpp/c/encoding/binary-xml-element-reader.c
+++ b/ndn-cpp/c/encoding/binary-xml-element-reader.c
@@ -7,7 +7,7 @@
#include "binary-xml-element-reader.h"
ndn_Error ndn_BinaryXmlElementReader_onReceivedData
- (struct ndn_BinaryXmlElementReader *self, unsigned char *data, unsigned int dataLength)
+ (struct ndn_BinaryXmlElementReader *self, uint8_t *data, unsigned int dataLength)
{
// Process multiple objects in the data.
while(1) {
@@ -21,7 +21,7 @@
// Got the remainder of an element. Report to the caller.
if (self->usePartialData) {
// We have partial data from a previous call, so append this data and point to partialData.
- if ((error = ndn_DynamicUCharArray_set(&self->partialData, data, self->structureDecoder.offset, self->partialDataLength)))
+ if ((error = ndn_DynamicUInt8Array_set(&self->partialData, data, self->structureDecoder.offset, self->partialDataLength)))
return error;
self->partialDataLength += dataLength;
@@ -50,7 +50,7 @@
self->partialDataLength = 0;
}
- if ((error = ndn_DynamicUCharArray_set(&self->partialData, data, dataLength, self->partialDataLength)))
+ if ((error = ndn_DynamicUInt8Array_set(&self->partialData, data, dataLength, self->partialDataLength)))
return error;
self->partialDataLength += dataLength;
diff --git a/ndn-cpp/c/encoding/binary-xml-element-reader.h b/ndn-cpp/c/encoding/binary-xml-element-reader.h
index 666d15f..cb962cd 100644
--- a/ndn-cpp/c/encoding/binary-xml-element-reader.h
+++ b/ndn-cpp/c/encoding/binary-xml-element-reader.h
@@ -9,7 +9,7 @@
#include "../errors.h"
#include "binary-xml-structure-decoder.h"
-#include "../util/dynamic-uchar-array.h"
+#include "../util/dynamic-uint8-array.h"
#ifdef __cplusplus
extern "C" {
@@ -19,7 +19,7 @@
* will be passed to onReceivedElement.
*/
struct ndn_ElementListener {
- void (*onReceivedElement)(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength); /**< see ndn_ElementListener_initialize */
+ void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength); /**< see ndn_ElementListener_initialize */
};
/**
@@ -29,7 +29,7 @@
* self is the pointer to this ndn_ElementListener struct. See ndn_BinaryXmlElementReader_onReceivedData.
*/
static inline void ndn_ElementListener_initialize
- (struct ndn_ElementListener *self, void (*onReceivedElement)(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength))
+ (struct ndn_ElementListener *self, void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength))
{
self->onReceivedElement = onReceivedElement;
}
@@ -44,7 +44,7 @@
struct ndn_ElementListener *elementListener;
struct ndn_BinaryXmlStructureDecoder structureDecoder;
int usePartialData;
- struct ndn_DynamicUCharArray partialData;
+ struct ndn_DynamicUInt8Array partialData;
unsigned int partialDataLength;
};
@@ -54,16 +54,16 @@
* @param elementListener pointer to the ndn_ElementListener used by ndn_BinaryXmlElementReader_onReceivedData.
* @param buffer the allocated buffer. If reallocFunction is null, this should be large enough to save a full element, perhaps 8000 bytes.
* @param bufferLength the length of the 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_BinaryXmlElementReader_initialize
(struct ndn_BinaryXmlElementReader *self, struct ndn_ElementListener *elementListener,
- unsigned char *buffer, unsigned int bufferLength, unsigned char * (*reallocFunction)(struct ndn_DynamicUCharArray *self, unsigned char *, unsigned int))
+ uint8_t *buffer, unsigned int bufferLength, uint8_t * (*reallocFunction)(struct ndn_DynamicUInt8Array *self, uint8_t *, unsigned int))
{
self->elementListener = elementListener;
ndn_BinaryXmlStructureDecoder_initialize(&self->structureDecoder);
self->usePartialData = 0;
- ndn_DynamicUCharArray_initialize(&self->partialData, buffer, bufferLength, reallocFunction);
+ ndn_DynamicUInt8Array_initialize(&self->partialData, buffer, bufferLength, reallocFunction);
}
/**
@@ -75,7 +75,7 @@
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlElementReader_onReceivedData
- (struct ndn_BinaryXmlElementReader *self, unsigned char *data, unsigned int dataLength);
+ (struct ndn_BinaryXmlElementReader *self, uint8_t *data, unsigned int dataLength);
#ifdef __cplusplus
}
diff --git a/ndn-cpp/c/encoding/binary-xml-encoder.c b/ndn-cpp/c/encoding/binary-xml-encoder.c
index ae6eb26..fce9b2d 100644
--- a/ndn-cpp/c/encoding/binary-xml-encoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-encoder.c
@@ -17,17 +17,17 @@
};
/**
- * Call ndn_DynamicUCharArray_ensureLength to ensure that there is enough room in the output, and copy
+ * Call ndn_DynamicUInt8Array_ensureLength to ensure that there is enough room in the output, and copy
* array to the output. This does not write a header.
* @param self pointer to the ndn_BinaryXmlEncoder struct
* @param array the array to copy
* @param arrayLength the length of the array
* @return 0 for success, else an error code
*/
-static ndn_Error writeArray(struct ndn_BinaryXmlEncoder *self, unsigned char *array, unsigned int arrayLength)
+static ndn_Error writeArray(struct ndn_BinaryXmlEncoder *self, uint8_t *array, unsigned int arrayLength)
{
ndn_Error error;
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + arrayLength)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + arrayLength)))
return error;
ndn_memcpy(self->output->array + self->offset, array, arrayLength);
@@ -67,16 +67,16 @@
* @param array
* @param length
*/
-static void reverse(unsigned char *array, unsigned int length)
+static void reverse(uint8_t *array, unsigned int length)
{
if (length == 0)
return;
- unsigned char *left = array;
- unsigned char *right = array + length - 1;
+ uint8_t *left = array;
+ uint8_t *right = array + length - 1;
while (left < right) {
// Swap.
- unsigned char temp = *left;
+ uint8_t temp = *left;
*left = *right;
*right = temp;
@@ -86,7 +86,7 @@
}
/**
- * Write x as an unsigned decimal integer to the output with the digits in reverse order, using ndn_DynamicUCharArray_ensureLength.
+ * Write x as an unsigned decimal integer to the output with the digits in reverse order, using ndn_DynamicUInt8Array_ensureLength.
* This does not write a header.
* We encode in reverse order, because this is the natural way to encode the digits, and the caller can reverse as needed.
* @param self pointer to the ndn_BinaryXmlEncoder struct
@@ -97,10 +97,10 @@
{
while (1) {
ndn_Error error;
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + 1)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + 1)))
return error;
- self->output->array[self->offset++] = (unsigned char)(x % 10 + '0');
+ self->output->array[self->offset++] = (uint8_t)(x % 10 + '0');
x /= 10;
if (x == 0)
@@ -126,14 +126,14 @@
unsigned int nBufferBytes = self->offset - startOffset;
unsigned int nHeaderBytes = getNHeaderEncodingBytes(nBufferBytes);
ndn_Error error;
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + nHeaderBytes)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + nHeaderBytes)))
return error;
// To reverse and shift at the same time, we first shift nHeaderBytes to the destination while reversing,
// then reverse the remaining bytes in place.
- unsigned char *from = self->output->array + startOffset;
- unsigned char *fromEnd = from + nHeaderBytes;
- unsigned char *to = self->output->array + startOffset + nBufferBytes + nHeaderBytes - 1;
+ uint8_t *from = self->output->array + startOffset;
+ uint8_t *fromEnd = from + nHeaderBytes;
+ uint8_t *to = self->output->array + startOffset + nBufferBytes + nHeaderBytes - 1;
while (from < fromEnd)
*(to--) = *(from++);
// Reverse the remaining bytes in place (if any).
@@ -179,7 +179,7 @@
// Encode backwards. Calculate how many bytes we need.
unsigned int nEncodingBytes = getNHeaderEncodingBytes(value);
ndn_Error error;
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + nEncodingBytes)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + nEncodingBytes)))
return error;
// Bottom 4 bits of value go in last byte with tag.
@@ -208,7 +208,7 @@
ndn_Error ndn_BinaryXmlEncoder_writeElementClose(struct ndn_BinaryXmlEncoder *self)
{
ndn_Error error;
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + 1)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + 1)))
return error;
self->output->array[self->offset] = ndn_BinaryXml_CLOSE;
@@ -217,7 +217,7 @@
return NDN_ERROR_success;
}
-ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, unsigned char *value, unsigned int valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_BLOB, valueLength)))
@@ -229,7 +229,7 @@
return NDN_ERROR_success;
}
-ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag)))
@@ -244,7 +244,7 @@
return NDN_ERROR_success;
}
-ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, unsigned char *value, unsigned int valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_UDATA, valueLength)))
@@ -256,7 +256,7 @@
return NDN_ERROR_success;
}
-ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
{
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag)))
@@ -311,17 +311,17 @@
ndn_Error error;
while (lo32 != 0) {
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + 1)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + 1)))
return error;
- self->output->array[self->offset++] = (unsigned char)(lo32 & 0xff);
+ self->output->array[self->offset++] = (uint8_t)(lo32 & 0xff);
lo32 >>= 8;
}
if (hi32 != 0) {
// Pad the lo values out to 4 bytes.
while (self->offset - startOffset < 4) {
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + 1)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + 1)))
return error;
self->output->array[self->offset++] = 0;
@@ -329,10 +329,10 @@
// Encode hi32
while (hi32 != 0) {
- if ((error = ndn_DynamicUCharArray_ensureLength(self->output, self->offset + 1)))
+ if ((error = ndn_DynamicUInt8Array_ensureLength(self->output, self->offset + 1)))
return error;
- self->output->array[self->offset++] = (unsigned char)(hi32 & 0xff);
+ self->output->array[self->offset++] = (uint8_t)(hi32 & 0xff);
hi32 >>= 8;
}
}
diff --git a/ndn-cpp/c/encoding/binary-xml-encoder.h b/ndn-cpp/c/encoding/binary-xml-encoder.h
index d56cc8a..3cf4a89 100644
--- a/ndn-cpp/c/encoding/binary-xml-encoder.h
+++ b/ndn-cpp/c/encoding/binary-xml-encoder.h
@@ -8,7 +8,7 @@
#define NDN_BINARYXMLENCODER_H
#include "../errors.h"
-#include "../util/dynamic-uchar-array.h"
+#include "../util/dynamic-uint8-array.h"
#include "binary-xml.h"
#ifdef __cplusplus
@@ -19,18 +19,18 @@
* ndn_BinaryXmlEncoder_initialize.
*/
struct ndn_BinaryXmlEncoder {
- struct ndn_DynamicUCharArray *output; /**< A pointer to a ndn_DynamicUCharArray which receives the encoded output */
+ struct ndn_DynamicUInt8Array *output; /**< A pointer to a ndn_DynamicUInt8Array which receives the encoded output */
unsigned int offset; /**< the offset into output.array for the next encoding */
};
/**
- * Initialize an ndn_BinaryXmlEncoder_initialize struct with the arguments for initializing the ndn_DynamicUCharArray.
+ * Initialize an ndn_BinaryXmlEncoder_initialize struct with the arguments for initializing the ndn_DynamicUInt8Array.
* @param self pointer to the ndn_BinaryXmlEncoder struct
- * @param output A pointer to a ndn_DynamicUCharArray struct which receives the encoded output. The struct must
+ * @param output A pointer to a ndn_DynamicUInt8Array struct which receives the encoded output. The struct must
* remain valid during the entire life of this ndn_BinaryXmlEncoder. If the output->realloc
* function pointer is null, its array must be large enough to receive the entire encoding.
*/
-static inline void ndn_BinaryXmlEncoder_initialize(struct ndn_BinaryXmlEncoder *self, struct ndn_DynamicUCharArray *output)
+static inline void ndn_BinaryXmlEncoder_initialize(struct ndn_BinaryXmlEncoder *self, struct ndn_DynamicUInt8Array *output)
{
self->output = output;
self->offset = 0;
@@ -70,7 +70,7 @@
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, unsigned char *value, unsigned int valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength);
/**
* Write an element start header using DTAG with the tag to self->output, then the blob, then an element close.
@@ -81,7 +81,7 @@
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength);
/**
* If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeBlobDTagElement.
@@ -92,7 +92,7 @@
* @return 0 for success, else an error code
*/
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
- (struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
+ (struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
{
if (value && valueLength > 0)
return ndn_BinaryXmlEncoder_writeBlobDTagElement(self, tag, value, valueLength);
@@ -107,7 +107,7 @@
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, unsigned char *value, unsigned int valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, unsigned int valueLength);
/**
* Write an element start header using DTAG with the tag to self->output, then the UDATA value, then an element close.
@@ -118,7 +118,7 @@
* @param valueLength the length of the array
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength);
/**
* If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeUDataDTagElement.
@@ -129,7 +129,7 @@
* @return 0 for success, else an error code
*/
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalUDataDTagElement
- (struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
+ (struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, unsigned int valueLength)
{
if (value && valueLength > 0)
return ndn_BinaryXmlEncoder_writeUDataDTagElement(self, tag, value, valueLength);
diff --git a/ndn-cpp/c/encoding/binary-xml-interest.c b/ndn-cpp/c/encoding/binary-xml-interest.c
index a1b51a6..ee20f05 100644
--- a/ndn-cpp/c/encoding/binary-xml-interest.c
+++ b/ndn-cpp/c/encoding/binary-xml-interest.c
@@ -60,7 +60,7 @@
return error;
if (gotExpectedTag) {
// Component
- unsigned char *component;
+ uint8_t *component;
unsigned int componentLen;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component, &componentLen)))
return error;
@@ -96,7 +96,7 @@
return error;
if (gotExpectedTag) {
// Skip the Bloom and treat it as Any.
- unsigned char *value;
+ uint8_t *value;
unsigned int valueLen;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Bloom, 0, &value, &valueLen)))
return error;
diff --git a/ndn-cpp/c/encoding/binary-xml-name.c b/ndn-cpp/c/encoding/binary-xml-name.c
index c6f55f7..f36e0ef 100644
--- a/ndn-cpp/c/encoding/binary-xml-name.c
+++ b/ndn-cpp/c/encoding/binary-xml-name.c
@@ -44,7 +44,7 @@
// No more components.
break;
- unsigned char *component;
+ uint8_t *component;
unsigned int componentLen;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component, &componentLen)))
return error;
diff --git a/ndn-cpp/c/encoding/binary-xml-structure-decoder.c b/ndn-cpp/c/encoding/binary-xml-structure-decoder.c
index 4596910..603d07d 100644
--- a/ndn-cpp/c/encoding/binary-xml-structure-decoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-structure-decoder.c
@@ -31,7 +31,7 @@
}
ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
- (struct ndn_BinaryXmlStructureDecoder *self, unsigned char *input, unsigned int inputLength)
+ (struct ndn_BinaryXmlStructureDecoder *self, uint8_t *input, unsigned int inputLength)
{
if (self->gotElementEnd)
// Someone is calling when we already got the end.
diff --git a/ndn-cpp/c/encoding/binary-xml-structure-decoder.h b/ndn-cpp/c/encoding/binary-xml-structure-decoder.h
index e58471e..f8bf5d0 100644
--- a/ndn-cpp/c/encoding/binary-xml-structure-decoder.h
+++ b/ndn-cpp/c/encoding/binary-xml-structure-decoder.h
@@ -7,6 +7,7 @@
#ifndef NDN_BINARYXMLSTRUCTUREDECODER_H
#define NDN_BINARYXMLSTRUCTUREDECODER_H
+#include "../common.h"
#include "../errors.h"
#ifdef __cplusplus
@@ -21,7 +22,7 @@
unsigned int headerLength;
int useHeaderBuffer; /**< boolean */
// 10 bytes is enough to hold an encoded header with a type and a 64 bit value.
- unsigned char headerBuffer[10];
+ uint8_t headerBuffer[10];
int nBytesToRead;
};
@@ -43,7 +44,7 @@
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXmlStructureDecoder_findElementEnd
- (struct ndn_BinaryXmlStructureDecoder *self, unsigned char *input, unsigned int inputLength);
+ (struct ndn_BinaryXmlStructureDecoder *self, uint8_t *input, unsigned int inputLength);
/**
* Set the offset into the input, used for the next read.
diff --git a/ndn-cpp/c/errors.c b/ndn-cpp/c/errors.c
index 125be8a..5ccbec1 100644
--- a/ndn-cpp/c/errors.c
+++ b/ndn-cpp/c/errors.c
@@ -43,10 +43,10 @@
return "findElementEnd unrecognized header type";
case NDN_ERROR_findElementEnd_unrecognized_state:
return "findElementEnd unrecognized state";
- case NDN_ERROR_DynamicUCharArray_realloc_function_pointer_not_supplied:
- return "DynamicUCharArray realloc function pointer not supplied";
- case NDN_ERROR_DynamicUCharArray_realloc_failed:
- return "DynamicUCharArray realloc failed";
+ case NDN_ERROR_DynamicUInt8Array_realloc_function_pointer_not_supplied:
+ return "DynamicUInt8Array realloc function pointer not supplied";
+ case NDN_ERROR_DynamicUInt8Array_realloc_failed:
+ return "DynamicUInt8Array realloc failed";
case NDN_ERROR_unrecognized_ndn_ExcludeType:
return "unrecognized ndn_ExcludeType";
case NDN_ERROR_unrecognized_ndn_ContentType:
diff --git a/ndn-cpp/c/errors.h b/ndn-cpp/c/errors.h
index 1254c0b..9f992f9 100644
--- a/ndn-cpp/c/errors.h
+++ b/ndn-cpp/c/errors.h
@@ -30,8 +30,8 @@
NDN_ERROR_findElementEnd_cannot_read_header_type_and_value,
NDN_ERROR_findElementEnd_unrecognized_header_type,
NDN_ERROR_findElementEnd_unrecognized_state,
- NDN_ERROR_DynamicUCharArray_realloc_function_pointer_not_supplied,
- NDN_ERROR_DynamicUCharArray_realloc_failed,
+ NDN_ERROR_DynamicUInt8Array_realloc_function_pointer_not_supplied,
+ NDN_ERROR_DynamicUInt8Array_realloc_failed,
NDN_ERROR_unrecognized_ndn_ExcludeType,
NDN_ERROR_unrecognized_ndn_ContentType,
NDN_ERROR_unrecognized_ndn_KeyLocatorType,
diff --git a/ndn-cpp/c/forwarding-entry.h b/ndn-cpp/c/forwarding-entry.h
index f28ce69..8a77e2f 100644
--- a/ndn-cpp/c/forwarding-entry.h
+++ b/ndn-cpp/c/forwarding-entry.h
@@ -7,6 +7,7 @@
#ifndef NDN_FORWARDING_ENTRY_H
#define NDN_FORWARDING_ENTRY_H
+#include "common.h"
#include "name.h"
#include "publisher-public-key-digest.h"
@@ -18,7 +19,7 @@
* An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a hub.
*/
struct ndn_ForwardingEntry {
- unsigned char *action; /**< pointer to pre-allocated buffer. 0 for none. */
+ uint8_t *action; /**< pointer to pre-allocated buffer. 0 for none. */
unsigned int actionLength; /**< length of action. 0 for none. */
struct ndn_Name prefix;
struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
diff --git a/ndn-cpp/c/interest.h b/ndn-cpp/c/interest.h
index cda0598..ad1b700 100644
--- a/ndn-cpp/c/interest.h
+++ b/ndn-cpp/c/interest.h
@@ -34,7 +34,7 @@
* @param component the pre-allocated buffer for the component value, only used if type is ndn_Exclude_COMPONENT
* @param componentLength the number of bytes in value, only used if type is ndn_Exclude_COMPONENT
*/
-static inline void ndn_ExcludeEntry_initialize(struct ndn_ExcludeEntry *self, ndn_ExcludeType type, unsigned char *component, unsigned int componentLength)
+static inline void ndn_ExcludeEntry_initialize(struct ndn_ExcludeEntry *self, ndn_ExcludeType type, uint8_t *component, unsigned int componentLength)
{
self->type = type;
ndn_NameComponent_initialize(&self->component, component, componentLength);
@@ -102,7 +102,7 @@
int answerOriginKind; /**< -1 for none */
int scope; /**< -1 for none */
double interestLifetimeMilliseconds; /**< milliseconds. -1.0 for none */
- unsigned char *nonce; /**< pointer to pre-allocated buffer. 0 for none */
+ uint8_t *nonce; /**< pointer to pre-allocated buffer. 0 for none */
unsigned int nonceLength; /**< length of nonce. 0 for none */
};
diff --git a/ndn-cpp/c/key.h b/ndn-cpp/c/key.h
index fee3c64..2069789 100644
--- a/ndn-cpp/c/key.h
+++ b/ndn-cpp/c/key.h
@@ -31,7 +31,7 @@
*/
struct ndn_KeyLocator {
ndn_KeyLocatorType type; /**< -1 for none */
- unsigned char *keyData; /**< A pointer to a pre-allocated buffer for the key data as follows:
+ uint8_t *keyData; /**< A pointer to a pre-allocated buffer for the key data as follows:
* If type is ndn_KeyLocatorType_KEY, the key data.
* If type is ndn_KeyLocatorType_CERTIFICATE, the certificate data.
* If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST, the publisher public key digest.
diff --git a/ndn-cpp/c/name.h b/ndn-cpp/c/name.h
index ade193a..5415f6e 100644
--- a/ndn-cpp/c/name.h
+++ b/ndn-cpp/c/name.h
@@ -15,7 +15,7 @@
* An ndn_NameComponent holds a pointer to the component value.
*/
struct ndn_NameComponent {
- unsigned char *value; /**< pointer to the pre-allocated buffer for the component value */
+ uint8_t *value; /**< pointer to the pre-allocated buffer for the component value */
unsigned int valueLength; /**< the number of bytes in value */
};
@@ -25,7 +25,7 @@
* @param value the pre-allocated buffer for the component value
* @param valueLength the number of bytes in value
*/
-static inline void ndn_NameComponent_initialize(struct ndn_NameComponent *self, unsigned char *value, unsigned int valueLength)
+static inline void ndn_NameComponent_initialize(struct ndn_NameComponent *self, uint8_t *value, unsigned int valueLength)
{
self->value = value;
self->valueLength = valueLength;
diff --git a/ndn-cpp/c/publisher-public-key-digest.h b/ndn-cpp/c/publisher-public-key-digest.h
index 0fcf032..3e02b9b 100644
--- a/ndn-cpp/c/publisher-public-key-digest.h
+++ b/ndn-cpp/c/publisher-public-key-digest.h
@@ -7,6 +7,8 @@
#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_H
#define NDN_PUBLISHERPUBLICKEYDIGEST_H
+#include "common.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -16,7 +18,7 @@
* We make a separate struct since this is used by multiple other structs.
*/
struct ndn_PublisherPublicKeyDigest {
- unsigned char *publisherPublicKeyDigest; /**< pointer to pre-allocated buffer. 0 for none */
+ uint8_t *publisherPublicKeyDigest; /**< pointer to pre-allocated buffer. 0 for none */
unsigned int publisherPublicKeyDigestLength; /**< length of publisherPublicKeyDigest. 0 for none */
};
diff --git a/ndn-cpp/c/transport/socket-transport.c b/ndn-cpp/c/transport/socket-transport.c
index 53987b0..aef13ac 100644
--- a/ndn-cpp/c/transport/socket-transport.c
+++ b/ndn-cpp/c/transport/socket-transport.c
@@ -25,7 +25,7 @@
}
struct addrinfo hints;
- ndn_memset((unsigned char *)&hints, 0, sizeof(hints));
+ ndn_memset((uint8_t *)&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
if (socketType == SOCKET_TCP)
hints.ai_socktype = SOCK_STREAM;
@@ -67,7 +67,7 @@
return NDN_ERROR_success;
}
-ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, unsigned char *data, unsigned int dataLength)
+ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, uint8_t *data, unsigned int dataLength)
{
if (self->socketDescriptor < 0)
return NDN_ERROR_SocketTransport_socket_is_not_open;
@@ -115,7 +115,7 @@
}
ndn_Error ndn_SocketTransport_receive
- (struct ndn_SocketTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytesOut)
+ (struct ndn_SocketTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytesOut)
{
if (self->socketDescriptor < 0)
return NDN_ERROR_SocketTransport_socket_is_not_open;
diff --git a/ndn-cpp/c/transport/socket-transport.h b/ndn-cpp/c/transport/socket-transport.h
index 750cc56..e1388c3 100644
--- a/ndn-cpp/c/transport/socket-transport.h
+++ b/ndn-cpp/c/transport/socket-transport.h
@@ -8,6 +8,7 @@
#define NDN_SOCKETTRANSPORT_H
#include <sys/socket.h>
+#include "../common.h"
#include "../errors.h"
#ifdef __cplusplus
@@ -49,7 +50,7 @@
* @param dataLength The number of bytes in data.
* @return 0 for success, else an error code.
*/
-ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, unsigned char *data, unsigned int dataLength);
+ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, uint8_t *data, unsigned int dataLength);
/**
* Check if there is data ready on the socket to be received with ndn_SocketTransport_receive.
@@ -70,7 +71,7 @@
* @return 0 for success, else an error code.
*/
ndn_Error ndn_SocketTransport_receive
- (struct ndn_SocketTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes);
+ (struct ndn_SocketTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytes);
/**
* Close the socket.
diff --git a/ndn-cpp/c/transport/tcp-transport.h b/ndn-cpp/c/transport/tcp-transport.h
index e31e127..05902f9 100644
--- a/ndn-cpp/c/transport/tcp-transport.h
+++ b/ndn-cpp/c/transport/tcp-transport.h
@@ -45,7 +45,7 @@
* @param dataLength The number of bytes in data.
* @return 0 for success, else an error code.
*/
-static inline ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, unsigned char *data, unsigned int dataLength)
+static inline ndn_Error ndn_TcpTransport_send(struct ndn_TcpTransport *self, uint8_t *data, unsigned int dataLength)
{
return ndn_SocketTransport_send(&self->base, data, dataLength);
}
@@ -72,7 +72,7 @@
* @return 0 for success, else an error code.
*/
static inline ndn_Error ndn_TcpTransport_receive
- (struct ndn_TcpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes)
+ (struct ndn_TcpTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytes)
{
return ndn_SocketTransport_receive(&self->base, buffer, bufferLength, nBytes);
}
diff --git a/ndn-cpp/c/transport/udp-transport.h b/ndn-cpp/c/transport/udp-transport.h
index a97af10..fc9a173 100644
--- a/ndn-cpp/c/transport/udp-transport.h
+++ b/ndn-cpp/c/transport/udp-transport.h
@@ -45,7 +45,7 @@
* @param dataLength The number of bytes in data.
* @return 0 for success, else an error code.
*/
-static inline ndn_Error ndn_UdpTransport_send(struct ndn_UdpTransport *self, unsigned char *data, unsigned int dataLength)
+static inline ndn_Error ndn_UdpTransport_send(struct ndn_UdpTransport *self, uint8_t *data, unsigned int dataLength)
{
return ndn_SocketTransport_send(&self->base, data, dataLength);
}
@@ -72,7 +72,7 @@
* @return 0 for success, else an error code.
*/
static inline ndn_Error ndn_UdpTransport_receive
- (struct ndn_UdpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes)
+ (struct ndn_UdpTransport *self, uint8_t *buffer, unsigned int bufferLength, unsigned int *nBytes)
{
return ndn_SocketTransport_receive(&self->base, buffer, bufferLength, nBytes);
}
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
}