Added bigEndianToUnsignedInt
diff --git a/ndn-cpp/c/encoding/BinaryXMLDecoder.c b/ndn-cpp/c/encoding/BinaryXMLDecoder.c
index 8f74ced..556fcfd 100644
--- a/ndn-cpp/c/encoding/BinaryXMLDecoder.c
+++ b/ndn-cpp/c/encoding/BinaryXMLDecoder.c
@@ -216,7 +216,7 @@
return error;
if (!gotExpectedTag) {
- value = -1;
+ *value = -1;
return 0;
}
@@ -227,3 +227,16 @@
*value = (int)unsignedValue;
return 0;
}
+
+// TODO: This could be in a more central source file.
+unsigned int ndn_BinaryXMLDecoder_bigEndianToUnsignedInt(unsigned char *bytes, unsigned int bytesLength)
+{
+ unsigned int result = 0;
+ unsigned int i;
+ for (i = 0; i < bytesLength; ++i) {
+ result <<= 8;
+ result += (unsigned int)bytes[i];
+ }
+
+ return result;
+}