--- xml-decode-uint32.c 2001/08/01 13:26:29 1.2.2.1
+++ xml-decode-uint32.c 2001/08/01 15:08:02 1.2.2.2
@@ -29,29 +29,18 @@
#include <ctype.h>
#include "internal.h"
-int xml_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xml_decode_uint32(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_uint32_t* value;
char* p;
- /* Consistency checks. */
-
- assert(xds != NULL);
- assert(buffer != NULL);
- assert(buffer_size != 0);
- assert(args != NULL);
- if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
- return XDS_ERR_INVALID_ARG;
-
- /* The buffer must contain at least opening tag, closing tag and
- one digit. Check whether it is large enough. */
-
- if (buffer_size < 8 + 9 + 1)
- return XDS_ERR_UNDERFLOW;
+ xds_init_decoding_engine(8 + 9 + 1);
/* Does the opening XML tag match? */
- if (strncmp(buffer, "<uint32>", 8) != 0)
+ if (strncasecmp(buffer, "<uint32>", 8) != 0)
return XDS_ERR_TYPE_MISMATCH;
/* Decode the representation of the value. */
@@ -71,8 +60,9 @@
if (p+9 > (char*)buffer + buffer_size)
return XDS_ERR_UNDERFLOW;
- else if (strncmp(p, "</uint32>", 9) != 0)
+ else if (strncasecmp(p, "</uint32>", 9) != 0)
return XDS_ERR_TYPE_MISMATCH;
- return p + 9 - (char*)buffer;
+ *used_buffer_size = p + 9 - (char*)buffer;
+ return XDS_OK;
}
|