Change all C code to return ndn_Error enum instead of char * error string.
diff --git a/ndn-cpp/c/encoding/BinaryXMLStructureDecoder.c b/ndn-cpp/c/encoding/BinaryXMLStructureDecoder.c
index 571db24..f9d7dda 100644
--- a/ndn-cpp/c/encoding/BinaryXMLStructureDecoder.c
+++ b/ndn-cpp/c/encoding/BinaryXMLStructureDecoder.c
@@ -29,7 +29,7 @@
self->state = ndn_BinaryXMLStructureDecoder_READ_HEADER_OR_CLOSE;
}
-char *ndn_BinaryXMLStructureDecoder_findElementEnd
+ndn_Error ndn_BinaryXMLStructureDecoder_findElementEnd
(struct ndn_BinaryXMLStructureDecoder *self, unsigned char *input, unsigned int inputLength)
{
if (self->gotElementEnd)
@@ -56,7 +56,7 @@
return 0;
}
if (self->level < 0)
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Unexpected close tag";
+ return NDN_ERROR_findElementEnd_unexpected_close_tag;
// Get ready for the next header.
startHeader(self);
@@ -68,7 +68,7 @@
if (self->offset >= inputLength) {
// We can't get all of the header bytes from this input. Save in headerBuffer.
if (self->headerLength > sizeof(self->headerBuffer))
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Can't store more header bytes than the size of headerBuffer";
+ return NDN_ERROR_cannot_store_more_header_bytes_than_the_size_of_headerBuffer;
self->useHeaderBuffer = 1;
unsigned int nNewBytes = self->headerLength - startingHeaderLength;
ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
@@ -87,7 +87,7 @@
if (self->useHeaderBuffer) {
// Copy the remaining bytes into headerBuffer.
if (self->headerLength > sizeof(self->headerBuffer))
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Can't store more header bytes than the size of headerBuffer";
+ return NDN_ERROR_cannot_store_more_header_bytes_than_the_size_of_headerBuffer;
unsigned int nNewBytes = self->headerLength - startingHeaderLength;
ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
@@ -95,13 +95,13 @@
struct ndn_BinaryXMLDecoder bufferDecoder;
ndn_BinaryXMLDecoder_init(&bufferDecoder, self->headerBuffer, sizeof(self->headerBuffer));
if (ndn_BinaryXMLDecoder_decodeTypeAndValue(&bufferDecoder, &type, &value))
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Can't read header type and value";
+ return NDN_ERROR_findElementEnd_cannot_read_header_type_and_value;
}
else {
// We didn't have to use the headerBuffer.
ndn_BinaryXMLDecoder_seek(&decoder, self->offset - self->headerLength);
if (ndn_BinaryXMLDecoder_decodeTypeAndValue(&decoder, &type, &value))
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Can't read header type and value";
+ return NDN_ERROR_findElementEnd_cannot_read_header_type_and_value;
}
// Set the next state based on the type.
@@ -128,7 +128,7 @@
self->state = ndn_BinaryXMLStructureDecoder_READ_BYTES;
}
else
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Unrecognized header type";
+ return NDN_ERROR_findElementEnd_unrecognized_header_type;
}
else if (self->state == ndn_BinaryXMLStructureDecoder_READ_BYTES) {
unsigned int nRemainingBytes = inputLength - self->offset;
@@ -144,6 +144,6 @@
}
else
// We don't expect this to happen.
- return "ndn_BinaryXMLStructureDecoder_findElementEnd: Unrecognized state";
+ return NDN_ERROR_findElementEnd_unrecognized_state;
}
}