Internal: Use C struct ndn_Blob where possible. Make ndn::Blob work with ndn_Blob.
diff --git a/ndn-cpp/c/encoding/binary-xml-decoder.c b/ndn-cpp/c/encoding/binary-xml-decoder.c
index 6cbb8ac..eab5cdf 100644
--- a/ndn-cpp/c/encoding/binary-xml-decoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-decoder.c
@@ -140,7 +140,7 @@
}
ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@@ -153,8 +153,8 @@
if (unsafeGetOctet(self) == ndn_BinaryXml_CLOSE) {
// The binary item is missing, and this is allowed, so read the element close and return a null value.
++self->offset;
- *value = 0;
- *valueLength = 0;
+ value->value = 0;
+ value->length = 0;
return NDN_ERROR_success;
}
}
@@ -164,9 +164,9 @@
if ((error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &itemType, &uintValueLength)))
return error;
// Ignore itemType.
- *value = self->input + self->offset;
- *valueLength = (size_t)uintValueLength;
- self->offset += *valueLength;
+ value->value = self->input + self->offset;
+ value->length = (size_t)uintValueLength;
+ self->offset += value->length;
if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
return error;
@@ -175,26 +175,26 @@
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value)
{
ndn_Error error;
int gotExpectedTag;
if ((error = ndn_BinaryXmlDecoder_peekDTag(self, expectedTag, &gotExpectedTag)))
return error;
if (gotExpectedTag) {
- if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, allowNull, value, valueLength)))
+ if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, allowNull, value)))
return error;
}
else {
- *value = 0;
- *valueLength = 0;
+ value->value = 0;
+ value->length = 0;
}
return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@@ -206,9 +206,9 @@
return error;
if (itemType != ndn_BinaryXml_UDATA)
return NDN_ERROR_item_is_not_UDATA;
- *value = self->input + self->offset;
- *valueLength = uintValueLength;
- self->offset += *valueLength;
+ value->value = self->input + self->offset;
+ value->length = uintValueLength;
+ self->offset += value->length;
if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
return error;
@@ -217,19 +217,19 @@
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
- (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength)
+ (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value)
{
ndn_Error error;
int gotExpectedTag;
if ((error = ndn_BinaryXmlDecoder_peekDTag(self, expectedTag, &gotExpectedTag)))
return error;
if (gotExpectedTag) {
- if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, value, valueLength)))
+ if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, value)))
return error;
}
else {
- *value = 0;
- *valueLength = 0;
+ value->value = 0;
+ value->length = 0;
}
return NDN_ERROR_success;
@@ -238,13 +238,12 @@
ndn_Error ndn_BinaryXmlDecoder_readUnsignedIntegerDTagElement
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned int *value)
{
- uint8_t *udataValue;
- size_t udataValueLength;
+ struct ndn_Blob udataValue;
ndn_Error error;
- if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, &udataValue, &udataValueLength)))
+ if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, &udataValue)))
return error;
- if ((error = parseUnsignedDecimalInt(udataValue, udataValueLength, value)))
+ if ((error = parseUnsignedDecimalInt(udataValue.value, udataValue.length, value)))
return error;
return NDN_ERROR_success;
@@ -275,12 +274,11 @@
(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, double *milliseconds)
{
ndn_Error error;
- uint8_t *bytes;
- size_t bytesLength;
- if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, 0, &bytes, &bytesLength)))
+ struct ndn_Blob bytes;
+ if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, 0, &bytes)))
return error;
- *milliseconds = 1000.0 * ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(bytes, bytesLength) / 4096.0;
+ *milliseconds = 1000.0 * ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(bytes.value, bytes.length) / 4096.0;
return NDN_ERROR_success;
}