--- xml-octetstream.c 2001/08/02 17:24:50 1.1
+++ xml-octetstream.c 2001/08/08 09:15:55 1.2
@@ -37,7 +37,7 @@
char* buffer;
size_t buffer_size;
- char msg[] = "Hello World";
+ char msg[] = "Hallo\000Worl";
char* new_msg;
size_t new_msg_size;
@@ -50,12 +50,14 @@
printf("Failed to initialize XDS context.\n");
return 1;
}
- if (xds_register(xds, "os", &xml_encode_octetstream, NULL) != XDS_OK)
+ if (xds_register(xds, "os", &xml_encode_octetstream, NULL) != XDS_OK ||
+ xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+ xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK)
{
printf("Failed to register my encoding engines.\n");
return 1;
}
- if (xds_encode(xds, "os", msg, strlen(msg)) != XDS_OK)
+ if (xds_encode(xds, "begin os end", msg, sizeof(msg)-1) != XDS_OK)
{
printf("xds_encode() failed.\n");
return 1;
@@ -75,7 +77,9 @@
printf("Failed to initialize XDS context.\n");
return 1;
}
- if (xds_register(xds, "os", &xml_decode_octetstream, NULL) != XDS_OK)
+ if (xds_register(xds, "os", &xml_decode_octetstream, NULL) != XDS_OK ||
+ xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+ xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK)
{
printf("Failed to register my decoding engines.\n");
return 1;
@@ -85,12 +89,12 @@
printf("xds_setbuffer() failed.\n");
return 1;
}
- if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+ if (xds_decode(xds, "begin os end", &new_msg, &new_msg_size) != XDS_OK)
{
printf("xds_decode() failed.\n");
return 1;
}
- if (new_msg_size != strlen(msg))
+ if (new_msg_size != sizeof(msg)-1)
{
printf("The size of the decoded message is wrong.\n");
return 1;
|