--- xml-decode-int32.c 2001/08/01 13:26:29 1.2.2.1
+++ xml-decode-int32.c 2001/08/01 15:08:02 1.2.2.2
@@ -29,30 +29,19 @@
#include <ctype.h>
#include "internal.h"
-int xml_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xml_decode_int32(xds_t* xds, void* engine_context,
+ void* buffer, size_t buffer_size, size_t* used_buffer_size,
+ va_list* args)
{
xds_int32_t* value;
char* p;
int negative;
- /* 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 < 7 + 8 + 1)
- return XDS_ERR_UNDERFLOW;
+ xds_init_decoding_engine(7 + 8 + 1);
/* Does the opening XML tag match? */
- if (strncmp(buffer, "<int32>", 7) != 0)
+ if (strncasecmp(buffer, "<int32>", 7) != 0)
return XDS_ERR_TYPE_MISMATCH;
/* Decode the representation of the value. */
@@ -81,8 +70,9 @@
if (p+8 > (char*)buffer + buffer_size)
return XDS_ERR_UNDERFLOW;
- else if (strncmp(p, "</int32>", 8) != 0)
+ else if (strncasecmp(p, "</int32>", 8) != 0)
return XDS_ERR_TYPE_MISMATCH;
- return p + 8 - (char*)buffer;
+ *used_buffer_size = p + 8 - (char*)buffer;
+ return XDS_OK;
}
|