OSSP CVS Repository

ossp - Check-in [591]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 591
Date: 2001-Aug-01 17:25:47 (local)
2001-Aug-01 15:25:47 (UTC)
User:simons
Branch:
Comment: Merged the whole contents of branch "callback-semantic-rewrite" into the main branch. The changes there include:

- A change of the callback semantics; callbacks do now return XDS_ERR_(UNDER|OVER)FLOW in case the buffer size doesn't fit. Rather than passing the differing byte size through the return code, it is stored in the location used_buffer_size points to -- a new parameter provided to all callbacks.

   In order to implement this, the framework, all callbacks and most
   of the test suits had to be adapted.

- internal.h now provides the macro xds_check_parameter(), which can be used to verify the contents of function parameters with assert() and if in one line. If assert()s are deactivated, the routine will still return XDS_ERR_INVALID_ARG.

   Because of this change, internal.h now includes the system header
   assert.h. This means that this include coulde be removed from
   almost all modules.

- internal.h now provides the macros xds_init_(en|de)coding_engine(). These can be used to comfortably verify a callback's parameters and to verify the buffer size. All engines have been rewritten to use these.

Tickets:
Inspections:
Files:
ossp-pkg/xds/Makefile.in      1.11 -> 1.12     17 inserted, 11 deleted
ossp-pkg/xds/destroy.c      added-> 1.8
ossp-pkg/xds/find-engine.c      added-> 1.4
ossp-pkg/xds/getbuffer.c      added-> 1.3
ossp-pkg/xds/init.c      added-> 1.6
ossp-pkg/xds/internal.h      1.7 -> 1.8     35 inserted, 0 deleted
ossp-pkg/xds/register.c      added-> 1.7
ossp-pkg/xds/regression-tests/Makefile.in      1.10->removed
ossp-pkg/xds/regression-tests/xdr-octetstream-empty.c      added-> 1.2
ossp-pkg/xds/regression-tests/xdr-octetstream.c      added-> 1.2
ossp-pkg/xds/regression-tests/xdr-string-empty.c      added-> 1.3
ossp-pkg/xds/regression-tests/xdr-string.c      added-> 1.3
ossp-pkg/xds/regression-tests/xds-decode.c      added-> 1.4
ossp-pkg/xds/regression-tests/xds-encode.c      added-> 1.6
ossp-pkg/xds/regression-tests/xds-engine-restart.c      added-> 1.2
ossp-pkg/xds/regression-tests/xds-getbuffer.c      added-> 1.5
ossp-pkg/xds/regression-tests/xds-mystruct.c      added-> 1.6
ossp-pkg/xds/regression-tests/xds-register.c      added-> 1.7
ossp-pkg/xds/regression-tests/xds-setbuffer.c      added-> 1.4
ossp-pkg/xds/set-capacity.c      added-> 1.4
ossp-pkg/xds/setbuffer.c      added-> 1.7
ossp-pkg/xds/unregister.c      added-> 1.5
ossp-pkg/xds/vdecode.c      added-> 1.5
ossp-pkg/xds/vencode.c      added-> 1.13
ossp-pkg/xds/xdr-decode-double.c      1.1->removed
ossp-pkg/xds/xdr-decode-int32.c      1.3->removed
ossp-pkg/xds/xdr-decode-int64.c      1.3->removed
ossp-pkg/xds/xdr-decode-octetstream.c      1.3->removed
ossp-pkg/xds/xdr-decode-string.c      1.4->removed
ossp-pkg/xds/xdr-decode-uint32.c      1.3->removed
ossp-pkg/xds/xdr-decode-uint64.c      1.3->removed
ossp-pkg/xds/xdr-encode-double.c      1.1->removed
ossp-pkg/xds/xdr-encode-int32.c      1.3->removed
ossp-pkg/xds/xdr-encode-int64.c      1.3->removed
ossp-pkg/xds/xdr-encode-octetstream.c      1.4->removed
ossp-pkg/xds/xdr-encode-string.c      1.5->removed
ossp-pkg/xds/xdr-encode-uint32.c      1.3->removed
ossp-pkg/xds/xdr-encode-uint64.c      1.3->removed
ossp-pkg/xds/xds.h.in      1.6 -> 1.7     42 inserted, 43 deleted
ossp-pkg/xds/xml-decode-begin.c      1.1->removed
ossp-pkg/xds/xml-decode-double.c      added-> 1.4
ossp-pkg/xds/xml-decode-end.c      1.1->removed
ossp-pkg/xds/xml-decode-int32.c      added-> 1.3
ossp-pkg/xds/xml-decode-int64.c      added-> 1.4
ossp-pkg/xds/xml-decode-uint32.c      added-> 1.3
ossp-pkg/xds/xml-decode-uint64.c      added-> 1.4
ossp-pkg/xds/xml-encode-begin.c      1.1->removed
ossp-pkg/xds/xml-encode-double.c      added-> 1.4
ossp-pkg/xds/xml-encode-end.c      1.1->removed
ossp-pkg/xds/xml-encode-int32.c      added-> 1.4
ossp-pkg/xds/xml-encode-int64.c      added-> 1.4
ossp-pkg/xds/xml-encode-uint32.c      added-> 1.3
ossp-pkg/xds/xml-encode-uint64.c      added-> 1.4

ossp-pkg/xds/Makefile.in 1.11 -> 1.12

--- Makefile.in  2001/07/31 15:27:45     1.11
+++ Makefile.in  2001/08/01 15:25:47     1.12
@@ -8,19 +8,25 @@
 CFLAGS          = @CFLAGS@
 LDFLAGS         = @LDFLAGS@
 
+XML_OBJS        = xml-encode-int32.o       xml-decode-int32.o \
+                  xml-encode-uint32.o      xml-decode-uint32.o \
+                  xml-encode-int64.o       xml-decode-int64.o \
+                  xml-encode-uint64.o      xml-decode-uint64.o \
+                  xml-encode-double.o      xml-decode-double.o \
+                  xml-encode-begin.o       xml-decode-begin.o \
+                  xml-encode-end.o         xml-decode-end.o
+
+XDR_OBJS        = xdr-encode-int32.o       xdr-decode-int32.o \
+                  xdr-encode-uint32.o      xdr-decode-uint32.o \
+                  xdr-encode-int64.o       xdr-decode-int64.o \
+                  xdr-encode-uint64.o      xdr-decode-uint64.o \
+                  xdr-encode-double.o      xdr-decode-double.o \
+                  xdr-encode-octetstream.o xdr-decode-octetstream.o \
+                  xdr-encode-string.o      xdr-decode-string.o \
+
 OBJS            = decode.o destroy.o encode.o getbuffer.o init.o register.o \
                   setbuffer.o unregister.o vdecode.o vencode.o find-engine.o \
-                  set-capacity.o  xdr-encode-int32.o xdr-encode-int64.o \
-                  xdr-encode-uint32.o xdr-encode-uint64.o xdr-decode-int32.o \
-                  xdr-decode-int64.o xdr-decode-uint32.o xdr-decode-uint64.o \
-                  xdr-encode-octetstream.o xdr-decode-octetstream.o \
-                  xdr-encode-string.o xdr-decode-string.o xdr-encode-double.o \
-                  xdr-decode-double.o xml-encode-int32.o xml-decode-int32.o \
-                  xml-decode-int64.o xml-decode-uint32.o xml-decode-uint64.o \
-                  xml-encode-int64.o xml-encode-uint32.o xml-encode-uint64.o \
-                  xml-encode-double.o xml-decode-double.o \
-                  xml-encode-begin.o xml-decode-begin.o \
-                  xml-encode-end.o xml-decode-end.o
+                  set-capacity.o $(XDR_OBJS) $(XML_OBJS)
 
 .c.o:
         $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) -c $<


ossp-pkg/xds/destroy.c -> 1.8

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,58 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdlib.h>
+ #include "internal.h"
+ 
+ void xds_destroy(xds_t* xds)
+     {
+     /* Sanity checks. */
+ 
+     assert(xds != NULL);
+     if (xds == NULL)
+        return;
+ 
+     /* Free allocated memory. */
+ 
+     assert(xds->buffer != NULL || (xds->buffer_capacity == 0 && xds->buffer_len == 0));
+     if (xds->buffer != NULL && xds->we_own_buffer)
+        free(xds->buffer);
+ 
+     assert(xds->engines != NULL || xds->engines_capacity == 0);
+     if (xds->engines != NULL)
+        {
+         size_t i;
+         for (i = 0; i < xds->engines_len; ++i)
+            {
+            assert(xds->engines[i].name != NULL);
+            free(xds->engines[i].name);
+            }
+        free(xds->engines);
+        }
+ 
+     free(xds);
+     }


ossp-pkg/xds/find-engine.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,66 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include "internal.h"
+ 
+ int xds_find_engine(const engine_map_t* engines, size_t last, const char* name, size_t* pos)
+     {
+     size_t first;
+ 
+     /* Sanity checks. */
+ 
+     xds_check_parameter(engines != NULL || last == 0);
+     xds_check_parameter(name != NULL);
+     xds_check_parameter(pos != NULL);
+ 
+     /* Use binary search to find "name" in "engines". */
+ 
+     for (first = 0; (last - first) > 0; )
+        {
+        size_t half = first + ((last - first) / 2);
+        int rc = strcmp(engines[half].name, name);
+ 
+        if (rc < 0)
+            {
+            first = half + 1;
+            }
+        else if(rc == 0)
+            {                   /* found it */
+            *pos = half;
+            return XDS_TRUE;
+            }
+        else
+            {
+            last = half;
+            }
+        assert(first <= last);
+        }
+ 
+     *pos = first;
+     return XDS_FALSE;
+     }


ossp-pkg/xds/getbuffer.c -> 1.3

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,52 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include "internal.h"
+ 
+ int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_len)
+     {
+     /* Sanity checks. */
+ 
+     xds_check_parameter(xds != NULL);
+     xds_check_parameter(flag == XDS_GIFT || flag == XDS_LOAN);
+     xds_check_parameter(buffer != NULL);
+     xds_check_parameter(buffer_len != NULL);
+ 
+     /* Return the buffer to the caller. */
+ 
+     *buffer = xds->buffer;
+     *buffer_len = xds->buffer_len;
+     if (flag == XDS_GIFT)
+        {
+        xds->buffer = NULL;
+        xds->buffer_capacity = xds->buffer_len = 0;
+        }
+     else
+        xds->buffer_len = 0;
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/init.c -> 1.6

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,71 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdlib.h>
+ #include <errno.h>
+ #include "internal.h"
+ 
+ xds_t* xds_init(xds_mode_t mode)
+     {
+     xds_t* ctx;
+ 
+     /* Sanity check parameter. */
+ 
+     assert(mode == XDS_ENCODE || mode == XDS_DECODE);
+     if (mode != XDS_ENCODE && mode != XDS_DECODE)
+        {
+        errno = EINVAL;
+        return NULL;
+        }
+ 
+     /* Allocate context structure. */
+ 
+     ctx = malloc(sizeof(struct xds_context));
+     if (ctx == NULL)
+        return NULL;            /* errno is set by calloc() */
+ 
+     /* Set mode of operation in context. */
+ 
+     ctx->mode = mode;
+ 
+     /* Initialize buffer handling. */
+ 
+     ctx->buffer = NULL;
+     ctx->buffer_len = 0;
+     ctx->buffer_capacity = 0;
+     ctx->we_own_buffer = XDS_FALSE;
+ 
+     /* Initialize engines map. */
+ 
+     ctx->engines = NULL;
+     ctx->engines_len = 0;
+     ctx->engines_capacity = 0;
+ 
+     /* Done. */
+ 
+     return ctx;
+     }


ossp-pkg/xds/internal.h 1.7 -> 1.8

--- internal.h   2001/07/31 15:27:45     1.7
+++ internal.h   2001/08/01 15:25:47     1.8
@@ -30,6 +30,7 @@
 #ifndef __INTERNAL_H__
 #define __INTERNAL_H__
 
+#include <assert.h>
 #include "xds.h"
 
 #define XDS_TRUE (1==1)
@@ -66,4 +67,38 @@
 extern const char xds_xml_begin_text[];
 extern const char xds_xml_end_text[];
 
+#define xds_check_parameter(condition)    \
+    do                                    \
+    {                                     \
+    assert(condition);                    \
+    if (!(condition))                     \
+        return XDS_ERR_INVALID_ARG;       \
+    } while(XDS_FALSE)
+
+#define xds_init_encoding_engine(size)                                          \
+    do                                                                          \
+    {                                                                           \
+    xds_check_parameter(xds != NULL);                                           \
+    xds_check_parameter(buffer != NULL);                                        \
+    xds_check_parameter(buffer_size != 0);                                      \
+    xds_check_parameter(used_buffer_size != NULL && *used_buffer_size == 0);    \
+    xds_check_parameter(args != NULL);                                          \
+    *used_buffer_size = size;                                                   \
+    if (buffer_size < size)                                                     \
+        return XDS_ERR_OVERFLOW;                                                \
+    } while(XDS_FALSE)
+
+#define xds_init_decoding_engine(size)                                          \
+    do                                                                          \
+    {                                                                           \
+    xds_check_parameter(xds != NULL);                                           \
+    xds_check_parameter(buffer != NULL);                                        \
+    xds_check_parameter(buffer_size != 0);                                      \
+    xds_check_parameter(used_buffer_size != NULL && *used_buffer_size == 0);    \
+    xds_check_parameter(args != NULL);                                          \
+    *used_buffer_size = size;                                                   \
+    if (buffer_size < size)                                                     \
+        return XDS_ERR_UNDERFLOW;                                               \
+    } while(XDS_FALSE)
+
 #endif /* !defined(__INTERNAL_H__) */


ossp-pkg/xds/register.c -> 1.7

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,83 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ int xds_register(xds_t* xds, const char* name, xds_engine_t engine, void* engine_context)
+     {
+     size_t pos;
+ 
+     /* Sanity checks. */
+ 
+     xds_check_parameter(xds != NULL);
+     xds_check_parameter(name != NULL);
+     xds_check_parameter(engine != NULL);
+     for(pos = 0; name[pos] != '\0'; ++pos)
+        {
+        if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_')
+            return XDS_ERR_INVALID_ARG;
+        }
+ 
+     /* Copy the name argument into our own memory. */
+ 
+     name = strdup(name);
+     if (name == NULL)
+        return XDS_ERR_NO_MEM;
+ 
+     /* Search engines for the entry. */
+ 
+     if (xds_find_engine(xds->engines, xds->engines_len, name, &pos))
+        {                       /* overwrite existing entry */
+        free(xds->engines[pos].name);
+        }
+     else
+        {                       /* insert new entry */
+        int rc = xds_set_capacity((void**)&xds->engines,
+                                  &xds->engines_capacity,
+                                  xds->engines_len + 1,
+                                  sizeof(engine_map_t),
+                                  XDS_INITIAL_ENGINES_CAPACITY);
+        assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM);
+        if (rc != XDS_OK)
+            return rc;
+        memmove(&xds->engines[pos+1], &xds->engines[pos], (xds->engines_len - pos) * sizeof(engine_map_t));
+        ++xds->engines_len;
+        }
+ 
+     /* Insert entry. */
+ 
+     xds->engines[pos].name    = (char*)name;
+     xds->engines[pos].engine  = engine;
+     xds->engines[pos].context = engine_context;
+ 
+     /* Everything is fine. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/regression-tests/Makefile.in 1.10 -> 1.11

--- Makefile.in  2001/07/24 14:55:56     1.10
+++ Makefile.in  2001/08/01 15:25:50     1.11
@@ -12,8 +12,8 @@
                   xds-getbuffer.exe xds-decode.exe xds-setbuffer.exe xds-engine-restart.exe \
                   xdr-uint32.exe xdr-int32.exe xdr-uint64.exe xdr-int64.exe  \
                   xdr-octetstream.exe xdr-octetstream-empty.exe xdr-string.exe \
-                  xdr-string-empty.exe xds-mystruct.exe xml-uint32.exe xml-int32.exe \
-                  xml-uint64.exe xml-int64.exe xml-double.exe
+                  xdr-string-empty.exe xds-mystruct.exe \
+                  xml-uint32.exe xml-int32.exe xml-uint64.exe xml-int64.exe xml-double.exe
 
 .SUFFIXES:
 .SUFFIXES:      .c .exe


ossp-pkg/xds/regression-tests/xdr-octetstream-empty.c -> 1.2

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,110 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     char   msg[] = "";
+     char*  new_msg;
+     size_t new_msg_size;
+ 
+     /* Encode the string as octet stream. Then erase the buffer and
+        decode the string back, verifying that it hasn't changed. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_encode_octetstream, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "os", msg, 0) != XDS_OK)
+        {
+        printf("xds_encode() failed.\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     if (buffer_size % 4 != 0)
+        {
+        printf("The encoded octet stream's buffer size is not a multiple of 4.\n");
+        return 1;
+        }
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_decode_octetstream, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (new_msg_size != 0)
+        {
+        printf("The size of the decoded message is wrong.\n");
+        return 1;
+        }
+     if (memcmp(msg, new_msg, new_msg_size) != 0)
+        {
+        printf("The decoded octet stream is not correct.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xdr-octetstream.c -> 1.2

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,110 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     char   msg[] = "Hello World";
+     char*  new_msg;
+     size_t new_msg_size;
+ 
+     /* Encode the string as octet stream. Then erase the buffer and
+        decode the string back, verifying that it hasn't changed. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_encode_octetstream, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "os", msg, strlen(msg)) != XDS_OK)
+        {
+        printf("xds_encode() failed.\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     if (buffer_size % 4 != 0)
+        {
+        printf("The encoded octet stream's buffer size is not a multiple of 4.\n");
+        return 1;
+        }
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_decode_octetstream, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (new_msg_size != strlen(msg))
+        {
+        printf("The size of the decoded message is wrong.\n");
+        return 1;
+        }
+     if (memcmp(msg, new_msg, new_msg_size) != 0)
+        {
+        printf("The decoded octet stream is not correct.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xdr-string-empty.c -> 1.3

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,110 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     char   msg[] = "";
+     char*  new_msg;
+     size_t new_msg_size;
+ 
+     /* Encode the string as octet stream. Then erase the buffer and
+        decode the string back, verifying that it hasn't changed. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_encode_string, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "os", msg, 0) != XDS_OK)
+        {
+        printf("xds_encode() failed.\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     if (buffer_size % 4 != 0)
+        {
+        printf("The encoded strings' buffer size is not a multiple of 4.\n");
+        return 1;
+        }
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_decode_string, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (new_msg_size != 0)
+        {
+        printf("The size of the decoded message is wrong.\n");
+        return 1;
+        }
+     if (memcmp(msg, new_msg, new_msg_size) != 0)
+        {
+        printf("The decoded string is not correct.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xdr-string.c -> 1.3

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,110 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     char   msg[] = "Hello World";
+     char*  new_msg;
+     size_t new_msg_size;
+ 
+     /* Encode the string as octet stream. Then erase the buffer and
+        decode the string back, verifying that it hasn't changed. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_encode_string, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "os", msg) != XDS_OK)
+        {
+        printf("xds_encode() failed.\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     if (buffer_size % 4 != 0)
+        {
+        printf("The encoded strings' buffer size is not a multiple of 4.\n");
+        return 1;
+        }
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xdr_decode_string, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (new_msg_size != strlen(msg))
+        {
+        printf("The size of the decoded message is wrong: %d.\n", new_msg_size);
+        return 1;
+        }
+     if (memcmp(msg, new_msg, new_msg_size) != 0)
+        {
+        printf("The decoded string is not correct.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-decode.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,124 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
+     {
+     if (xds == NULL)
+        {
+        printf("XDS context isn't passed through to registered engine.\n");
+        exit(1);
+        }
+     if (engine_context != (void*)42)
+        {
+        printf("Engine context isn't passed through to registered engine.\n");
+        exit(1);
+        }
+     if (buffer == NULL)
+        {
+        printf("Buffer passed to engine is NULL.\n");
+        exit(1);
+        }
+     if (buffer_size == 0)
+        {
+        printf("Buffer size passed to engine is zero!\n");
+        exit(1);
+        }
+     if (used_buffer_size == NULL)
+        {
+        printf("used_buffer_size passed to engine is zero!\n");
+        exit(1);
+        }
+     if (args == NULL)
+        {
+        printf("args pointer passed to engine is NULL!\n");
+        exit(1);
+        }
+     if (buffer_size < 6)
+        {
+        printf("The buffer is too small; can't verify my encoded string.\n");
+        exit(1);
+        }
+     if (memcmp(buffer, "Hallo!", 6) != 0)
+        {
+        printf("The contents of the decode buffer are not what we expected.\n");
+        exit(1);
+        }
+     *used_buffer_size = 6;
+     return XDS_OK;
+     }
+ 
+ int main()
+     {
+     xds_t* xds;
+     char buffer[] = "Hallo!Hallo!Hallo!";
+ 
+     /* Create XDS context. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+ 
+     /* Register the dummy callback under multiple names. */
+ 
+     if (xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+ 
+     /* Decode the buffer and have the callback report when something
+        is wrong. */
+ 
+     if (xds_setbuffer(xds, XDS_LOAN, buffer, strlen(buffer)) != XDS_OK)
+        {
+        printf("xds_decode() failed!");
+        return 1;
+        }
+ 
+     if (xds_decode(xds, "text::text text") != XDS_OK)
+        {
+        printf("xds_decode() failed!");
+        return 1;
+        }
+ 
+     /* Clean up. */
+ 
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-encode.c -> 1.6

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,117 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
+     {
+     if (xds == NULL)
+        {
+        printf("XDS context isn't passed through to registered engine.\n");
+        exit(1);
+        }
+     if (engine_context != (void*)42)
+        {
+        printf("Engine context isn't passed through to registered engine.\n");
+        exit(1);
+        }
+     if (buffer == NULL)
+        {
+        printf("Buffer passed to engine is NULL.\n");
+        exit(1);
+        }
+     if (buffer_size == 0)
+        {
+        printf("buffer_size passed to engine is zero!\n");
+        exit(1);
+        }
+     if (used_buffer_size == NULL)
+        {
+        printf("used_buffer_size pointer passed to engine is NULL!\n");
+        exit(1);
+        }
+     if (args == NULL)
+        {
+        printf("args pointer passed to engine is NULL!\n");
+        exit(1);
+        }
+     *used_buffer_size = 6;
+     if (buffer_size < 6)
+        return XDS_ERR_OVERFLOW;
+     memmove(buffer, "Hallo ", 6);
+     return XDS_OK;
+     }
+ 
+ int main()
+     {
+     xds_t* xds;
+ 
+     /* Create XDS context. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+ 
+     /* Register the dummy callback under multiple names. */
+ 
+     if (xds_register(xds, "int", &dummy_engine, (void*)42) != XDS_OK ||
+        xds_register(xds, "float", &dummy_engine, (void*)42) != XDS_OK ||
+        xds_register(xds, "double", &dummy_engine, (void*)42) != XDS_OK ||
+        xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+ 
+     /* Let's go and encode something. */
+ 
+     if (xds_encode(xds, "int:text    double double float") != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (memcmp(xds->buffer, "Hallo Hallo Hallo Hallo Hallo ", 30) != 0)
+        {
+        printf("xds_encode() did not yield the expected result.\n");
+        return 1;
+        }
+ 
+     /* Clean up. */
+ 
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-engine-restart.c -> 1.2

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,122 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
+     {
+     if (xds == NULL)
+        {
+        printf("XDS context isn't passed through to registered engine.\n");
+        exit(1);
+        }
+     if (engine_context != (void*)42)
+        {
+        printf("Engine context isn't passed through to registered engine.\n");
+        exit(1);
+        }
+     if (buffer == NULL)
+        {
+        printf("Buffer passed to engine is NULL.\n");
+        exit(1);
+        }
+     if (buffer_size == 0)
+        {
+        printf("Buffer size passed to engine is zero!\n");
+        exit(1);
+        }
+     if (used_buffer_size == NULL)
+        {
+        printf("used_buffer_size pointer passed to engine is NULL!\n");
+        exit(1);
+        }
+     if (args == NULL)
+        {
+        printf("args pointer passed to engine is NULL!\n");
+        exit(1);
+        }
+     if (va_arg(*args, int) != 42)
+        {
+        printf("The varadic argument is not what the engine expected!\n");
+        exit(1);
+        }
+     if (buffer_size < 64)
+        return XDS_ERR_OVERFLOW;
+     else
+        *used_buffer_size = 64;
+     return XDS_OK;
+     }
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     /* Create an XDS context and set a buffer that's too small for the
+        first encode() call. Then call encode() with two parameters:
+        the one the engine is expecting and a different one after that.
+        The engine will complain if it sees the second value -- what
+        would mean that the args parameter was not resetted to the
+        original value before the engine is restarted after buffer
+        enlargement. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &dummy_engine, (void*)42) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     buffer = malloc(32);
+     if (buffer == NULL)
+         {
+         printf("malloc() failed!\n");
+         return 1;
+         }
+     buffer_size = 32;
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+         {
+         printf("xds_setbuffer() failed!\n");
+         return 1;
+         }
+     if (xds_encode(xds, "int", 42, 13) != XDS_OK)
+        {
+        printf("xds_encode() failed!");
+        return 1;
+        }
+     xds_destroy(xds);
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-getbuffer.c -> 1.5

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,151 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
+     {
+     if (buffer_size < 6)
+        return XDS_ERR_OVERFLOW;
+     else
+        *used_buffer_size = 6;
+ 
+     memmove(buffer, "Hallo!", 6);
+     return XDS_OK;
+     }
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  old;
+     size_t old_len;
+     char*  new;
+     size_t new_len;
+ 
+     /* Create XDS context. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+ 
+     /* Register the dummy callback under multiple names. */
+ 
+     if (xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK)
+        {
+        printf("Failed to register my encoding engine.\n");
+        return 1;
+        }
+ 
+     /* Encode something, then flush the buffer by calling
+        xds_getbuffer(), then encode something new and verify that the
+        old buffer hasn't ben overwritten and that the new one contains
+        the correct string. */
+ 
+     if (xds_encode(xds, "text text") != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&old, &old_len) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed for the first buffer!\n");
+        return 1;
+        }
+     if (xds_encode(xds, "text") != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&new, &new_len) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed for the second buffer!\n");
+        return 1;
+        }
+     if ((memcmp(old, "Hallo!Hallo!", 12) != 0 || old_len != 12) &&
+        (memcmp(new, "Hallo!", 6) != 0 || new_len != 6))
+        {
+        printf("xds_encode() did not yield the expected result.\n");
+        return 1;
+        }
+     free(old);
+     free(new);
+ 
+     /* Encode somthing, then get the buffer via XDS_LOAN and verify
+        the contents. Encode something new and compare the new content
+        with what we expect. */
+ 
+     if (xds_encode(xds, "text text") != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_LOAN, (void**)&old, &old_len) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed for the first buffer!\n");
+        return 1;
+        }
+     if (memcmp(old, "Hallo!Hallo!", 12) != 0 || old_len != 12)
+        {
+        printf("xds_encode() did not yield the expected result.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "text") != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_LOAN, (void**)&new, &new_len) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed for the second buffer!\n");
+        return 1;
+        }
+     if (old != new)
+        {
+        printf("xds_encode() allocated a new buffer even though we used XDS_LOAN.\n");
+        return 1;
+        }
+     if (memcmp(new, "Hallo!", 6) != 0 || new_len != 6)
+        {
+        printf("xds_encode() did not yield the expected result.\n");
+        return 1;
+        }
+ 
+     /* Clean up. */
+ 
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-mystruct.c -> 1.6

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,168 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ struct mystruct
+     {
+     xds_int32_t   small;
+     xds_int64_t   big;
+     xds_uint32_t  positive;
+     };
+ 
+ static int encode_mystruct_engine(xds_t* xds, void* engine_context,
+                                  void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                                  va_list* args)
+     {
+     struct mystruct* ms;
+ 
+     assert(xds != NULL);
+     assert(buffer != NULL);
+     assert(buffer_size != 0);
+     assert(used_buffer_size != NULL);
+     assert(args != NULL);
+ 
+     ms = va_arg(*args, struct mystruct*);
+     return xds_encode(xds, "int32 int64 uint32", ms->small, ms->big, ms->positive);
+     }
+ 
+ static int decode_mystruct_engine(xds_t* xds, void* engine_context,
+                                  void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                                  va_list* args)
+     {
+     struct mystruct* ms;
+ 
+     assert(xds != NULL);
+     assert(buffer != NULL);
+     assert(buffer_size != 0);
+     assert(used_buffer_size != NULL);
+     assert(args != NULL);
+ 
+     ms = va_arg(*args, struct mystruct*);
+     return xds_decode(xds, "int32 int64 uint32", &(ms->small), &(ms->big), &(ms->positive));
+     }
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     struct mystruct ms, new_ms;
+     ms.small    = -0x1234567;
+     ms.big      = -0x1234567890abcdeLL;
+     ms.positive = 42;
+ 
+     /* Encode our copy of mystruct using our encoding callback. Then
+        get a the buffer and destroy the context again. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "mystruct", &encode_mystruct_engine, NULL) != XDS_OK ||
+        xds_register(xds, "int32", &xdr_encode_int32, NULL) != XDS_OK ||
+        xds_register(xds, "int64", &xdr_encode_int64, NULL) != XDS_OK ||
+        xds_register(xds, "uint32", &xdr_encode_uint32, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     buffer_size = 4;
+     buffer = malloc(buffer_size);
+     if (buffer == NULL)
+        {
+        printf("Failed to allocate memory for buffer.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed!\n");
+        return 1;
+        }
+     if (xds_encode(xds, "mystruct", &ms) != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (xds->buffer_capacity <= buffer_size)
+        {
+        printf("Buffer should have been enlarged after xds_encode()!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed!\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     printf("The encoded representation is %u bytes long.\n", buffer_size);
+ 
+     /* Now create a decoding context and decode the whole thing again. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "mystruct", &decode_mystruct_engine, NULL) != XDS_OK ||
+        xds_register(xds, "int32", &xdr_decode_int32, NULL) != XDS_OK ||
+        xds_register(xds, "int64", &xdr_decode_int64, NULL) != XDS_OK ||
+        xds_register(xds, "uint32", &xdr_decode_uint32, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed!\n");
+        return 1;
+        }
+     if (xds_decode(xds, "mystruct", &new_ms) != XDS_OK)
+        {
+        printf("xds_decode() failed!\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     /* Both structures must be identical. */
+ 
+     if (ms.small != new_ms.small || ms.big != new_ms.big || ms.positive != new_ms.positive)
+        {
+        printf("Decoded data does not match the original!\n");
+        return 1;
+        }
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-register.c -> 1.7

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,144 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
+     {
+     return 0;
+     }
+ 
+ int main()
+     {
+     const char* test_names[] =
+        {
+        "foo",
+        "bar",
+        "zarah",
+        "caesar",
+        "claus",
+        "heinz",
+        };
+     size_t test_names_len = sizeof(test_names) / sizeof(char*);
+     xds_t* xds;
+     size_t i;
+ 
+     /* Create context. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+ 
+     /* Register the dummy callback under an invalid name to see
+        whether the routine fails correctly. */
+ 
+     if (xds_register(xds, "abcdefh1230#", &dummy_engine, NULL) != XDS_ERR_INVALID_ARG)
+        {
+        printf("xds_register() illegally accepted an invalid name for the engine.\n");
+        return 1;
+        }
+ 
+     /* Register the dummy callback under multiple names. */
+ 
+     for(i = 0; i < test_names_len; ++i)
+        {
+        if (xds_register(xds, test_names[i], &dummy_engine, NULL) != XDS_OK)
+            {
+            printf("Failed to register engine for '%s'.\n", test_names[i]);
+            return 1;
+            }
+        }
+ 
+     /* Register the callback again, overwriting an existing entry. */
+ 
+     if (xds_register(xds, "claus", &dummy_engine, NULL) != XDS_OK)
+        {
+        printf("Failed to re-register engine for 'claus'.\n");
+        return 1;
+        }
+ 
+     /* Ensure that everything is in alphabetical order. */
+ 
+     for (i = 1; i < xds->engines_len; ++i)
+        {
+        assert(xds->engines[i-1].name != NULL);
+        assert(xds->engines[i].name != NULL);
+        if (strcmp(xds->engines[i-1].name, xds->engines[i].name) >= 0)
+            {
+            printf("xds->engines is not in alphabetical order!\n");
+            exit(1);
+            }
+        }
+ 
+     /* Try to remove an unknown entry. */
+ 
+     if (xds_unregister(xds, "abacadabra") != XDS_ERR_UNKNOWN_ENGINE)
+        {
+        printf("xds_unregister() succeeded at removing 'abacadabra' even though it is not there.\n");
+        exit(1);
+        }
+ 
+     /* Remove an entry from the middle. */
+ 
+     if (xds_unregister(xds, test_names[test_names_len/2]) != XDS_OK)
+        {
+        printf("xds_unregister() failed to remove '%s'.\n", test_names[test_names_len/2]);
+        exit(1);
+        }
+ 
+     /* Remove the last entry. */
+ 
+     assert(test_names_len > 0);
+     if (xds_unregister(xds, test_names[test_names_len-1]) != XDS_OK)
+        {
+        printf("xds_unregister() failed to remove '%s'.\n", test_names[test_names_len-1]);
+        exit(1);
+        }
+ 
+     /* Remove the first entry. */
+ 
+     if (xds_unregister(xds, test_names[0]) != XDS_OK)
+        {
+        printf("xds_unregister() failed to remove '%s'.\n", test_names[0]);
+        exit(1);
+        }
+ 
+     /* Clean up. */
+ 
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xds-setbuffer.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,134 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
+     {
+     assert(xds != NULL);
+     assert(buffer != NULL);
+     assert(buffer_size != 0);
+     assert(used_buffer_size != NULL);
+     assert(args != NULL);
+     if (buffer_size < 64)
+        return XDS_ERR_OVERFLOW;
+     else
+        *used_buffer_size = 64;
+     memset(buffer, 'a', 64);
+     return XDS_OK;
+     }
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     /* Create XDS context. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+ 
+     /* Register the callback. */
+ 
+     if (xds_register(xds, "dummy", &dummy_engine, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engine.\n");
+        return 1;
+        }
+ 
+     /* Give the library a buffer of 32 byte, call the engine once, get
+        the buffer back and see whether it has been enlarged or not. */
+ 
+     buffer_size = 32;
+     buffer = malloc(buffer_size);
+     if (buffer == NULL)
+        {
+        printf("Failed to allocate my memory.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed!\n");
+        return 1;
+        }
+     if (xds_encode(xds, "dummy") != XDS_OK)
+        {
+        printf("xds_encode() failed!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("xds_getbuffer() failed!\n");
+        return 1;
+        }
+     if (buffer_size < 64)
+        {
+        printf("xds_encode() did not enlarge the buffer after processing the callback\n");
+        printf("even though all capacity was used up!\n");
+        return 1;
+        }
+ 
+     /* Loan the library a buffer we own, call the engine once to
+        exceed the buffer's capacity and check, whether the library
+        returns the correct error code. */
+ 
+     buffer = malloc(32);
+     if (buffer == NULL)
+        {
+        printf("Failed to allocate my memory.\n");
+        return 1;
+        }
+     buffer_size = 32;
+     if (xds_setbuffer(xds, XDS_LOAN, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed!\n");
+        return 1;
+        }
+     if (xds_encode(xds, "dummy") != XDS_ERR_OVERFLOW)
+        {
+        printf("xds_encode() was supposed to fail with XDS_ERR_OVERFLOW!\n");
+        return 1;
+        }
+     free(buffer);
+ 
+     /* Clean up. */
+ 
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/set-capacity.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,62 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdlib.h>
+ #include "internal.h"
+ 
+ int xds_set_capacity(void** array, size_t* array_capacity, size_t new_capacity, size_t elem_size, size_t initial_capacity)
+     {
+     void*  buf;
+     size_t size;
+ 
+     /* Sanity checks. */
+ 
+     xds_check_parameter(array != NULL);
+     xds_check_parameter(array_capacity != NULL);
+     xds_check_parameter(elem_size != 0);
+     xds_check_parameter(initial_capacity != 0);
+ 
+     /* Do we need to re-allocate? */
+ 
+     if (*array_capacity > new_capacity)
+        return XDS_OK;
+ 
+     /* Find the correct capacity. */
+ 
+     for(size = (*array_capacity != 0) ? *array_capacity * 2 : initial_capacity; size < new_capacity; size *= 2)
+        ;
+ 
+     /* Allocate the array and store the new values. */
+ 
+     buf = realloc(*array, size * elem_size);
+     if (buf == NULL)
+        return XDS_ERR_NO_MEM;
+     *array = buf;
+     *array_capacity = size;
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/setbuffer.c -> 1.7

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,61 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include "internal.h"
+ 
+ int xds_setbuffer(xds_t* xds, xds_scope_t flag, void* buffer, size_t buffer_len)
+     {
+     /* Sanity checks. */
+ 
+     xds_check_parameter(xds != NULL);
+     xds_check_parameter(flag == XDS_GIFT || flag == XDS_LOAN);
+     xds_check_parameter((buffer != NULL && buffer_len != 0) || flag == XDS_GIFT);
+ 
+     /* Free the old buffer if there is one. */
+ 
+     if (xds->buffer != NULL && xds->we_own_buffer)
+        free(xds->buffer);
+     xds->buffer_len = 0;
+ 
+     if (flag == XDS_GIFT)
+        {
+        xds->buffer = buffer;
+        if (buffer == NULL)
+            xds->buffer_capacity = 0;
+        else
+            xds->buffer_capacity = buffer_len;
+        xds->we_own_buffer = XDS_TRUE;
+        }
+     else
+        {
+        xds->buffer = buffer;
+        xds->buffer_capacity = buffer_len;
+        xds->we_own_buffer = XDS_FALSE;
+        }
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/unregister.c -> 1.5

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,73 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ int xds_unregister(xds_t* xds, const char* name)
+     {
+     size_t pos;
+     int    rc;
+ 
+     /* Sanity checks. */
+ 
+     xds_check_parameter(xds != NULL);
+     xds_check_parameter(name != NULL);
+     for(pos = 0; name[pos] != '\0'; ++pos)
+        {
+        if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_')
+            return XDS_ERR_INVALID_ARG;
+        }
+ 
+     /* Find the entry we're supposed to delete. */
+ 
+     if (!xds_find_engine(xds->engines, xds->engines_len, name, &pos))
+        return XDS_ERR_UNKNOWN_ENGINE;
+ 
+     /* Free the memory allocated for this entry and move the entries
+        behind it back if necessary. */
+ 
+     assert(xds->engines[pos].name != NULL);
+     free(xds->engines[pos].name);
+     memmove(&xds->engines[pos], &xds->engines[pos+1], (xds->engines_len - (pos + 1)) * sizeof(engine_map_t));
+     --xds->engines_len;
+ 
+     /* Lower capacity if necessary. */
+ 
+     rc = xds_set_capacity((void**)&xds->engines,
+                          &xds->engines_capacity,
+                          xds->engines_len,
+                          sizeof(engine_map_t),
+                          XDS_INITIAL_ENGINES_CAPACITY);
+     assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM);
+     if (rc != XDS_OK)
+        return rc;
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/vdecode.c -> 1.5

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,102 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ int xds_vdecode(xds_t* xds, const char* fmt_arg, va_list args)
+     {
+     size_t buffer_len_backup;
+     char* name;
+     char* p;
+     char* fmt;
+     int rc;
+ 
+     /* Sanity checks. */
+ 
+     xds_check_parameter(xds != NULL);
+     xds_check_parameter(fmt_arg != NULL);
+     assert(xds->mode == XDS_DECODE);
+     if (xds->mode != XDS_DECODE)
+        return XDS_ERR_INVALID_MODE;
+ 
+     /* Ensure we have a buffer to decode. */
+ 
+     if (xds->buffer == NULL || xds->buffer_capacity == 0)
+        return XDS_ERR_UNDERFLOW;
+ 
+     /* Iterate through the items in the format string and execute the
+        apropriate engines. */
+ 
+     fmt = p = strdup(fmt_arg);
+     if (fmt == NULL)
+        return XDS_ERR_NO_MEM;
+     buffer_len_backup = xds->buffer_len;
+     for(name = p; *p != '\0'; name = p)
+        {
+        while(isalnum(*p) || *p == '-' || *p == '_')
+            ++p;
+        if (*p)
+            *p++ = '\0';
+        else
+            *p = '\0';
+ 
+        if (strlen(name) > 0)
+            {
+            size_t pos;
+            size_t used_buffer_size = 0;
+            if (xds_find_engine(xds->engines, xds->engines_len, name, &pos))
+                {
+                rc = (*xds->engines[pos].engine)(xds,
+                                                 xds->engines[pos].context,
+                                                 xds->buffer + xds->buffer_len,
+                                                 xds->buffer_capacity - xds->buffer_len,
+                                                 &used_buffer_size,
+                                                 &args);
+                assert(rc <= 0);
+                if (rc == XDS_OK)
+                    xds->buffer_len += used_buffer_size;
+                else
+                    goto leave;
+                }
+            else
+                {
+                rc = XDS_ERR_UNKNOWN_ENGINE;
+                goto leave;
+                }
+            }
+        }
+     rc = XDS_OK;
+ 
+     /* Clean up and leave. */
+   leave:
+     free(fmt);
+     if (rc != XDS_OK)
+        xds->buffer_len = buffer_len_backup;
+     return rc;
+     }


ossp-pkg/xds/vencode.c -> 1.13

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:56 2024
***************
*** 0 ****
--- 1,165 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ int xds_vencode(xds_t* xds, const char* fmt_arg, va_list args)
+     {
+     va_list args_backup;
+     size_t buffer_len_backup;
+     char* name;
+     char* p;
+     char* fmt;
+     int rc;
+ 
+     /* Sanity checks. */
+ 
+     xds_check_parameter(xds != NULL);
+     xds_check_parameter(fmt_arg != NULL);
+     assert(xds->mode == XDS_ENCODE);
+     if (xds->mode != XDS_ENCODE)
+        return XDS_ERR_INVALID_MODE;
+ 
+     /* Ensure we have a buffer allocated ready for use. */
+ 
+     if (xds->buffer == NULL)
+        {                       /* allocate a new buffer */
+        rc = xds_set_capacity((void**)&xds->buffer,
+                              &xds->buffer_capacity,
+                              XDS_INITIAL_BUFFER_CAPACITY,
+                              sizeof(char),
+                              XDS_INITIAL_BUFFER_CAPACITY);
+        assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM);
+        if (rc != XDS_OK)
+            return rc;
+        xds->buffer_len    = 0;
+        xds->we_own_buffer = XDS_TRUE;
+        }
+ 
+     /* Iterate through the items in the format string and execute the
+        apropriate engines. */
+ 
+     fmt = p = strdup(fmt_arg);
+     if (fmt == NULL)
+        return XDS_ERR_NO_MEM;
+     buffer_len_backup = xds->buffer_len;
+     for(name = p; *p != '\0'; name = p)
+        {
+        while(isalnum(*p) || *p == '-' || *p == '_')
+            ++p;
+        if (*p)
+            *p++ = '\0';
+        else
+            *p = '\0';
+ 
+        if (strlen(name) > 0)
+            {
+            int restart_engine;
+            size_t used_buffer_size;
+            size_t pos;
+ 
+            if (xds_find_engine(xds->engines, xds->engines_len, name, &pos) == XDS_FALSE)
+                {
+                rc = XDS_ERR_UNKNOWN_ENGINE;
+                goto leave;
+                }
+ 
+            do
+                {
+                /* Ensure the buffer has free space. */
+ 
+                assert(xds->buffer_len <= xds->buffer_capacity);
+                if (xds->buffer_len == xds->buffer_capacity)
+                    {
+                    if (xds->we_own_buffer)
+                        {
+                        rc = xds_set_capacity((void**)&xds->buffer,
+                                              &xds->buffer_capacity,
+                                              xds->buffer_len + 1,
+                                              sizeof(char),
+                                              XDS_INITIAL_BUFFER_CAPACITY);
+                        assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM);
+                        if (rc != XDS_OK)
+                            goto leave;
+                        }
+                    else
+                        {
+                        rc = XDS_ERR_OVERFLOW;
+                        goto leave;
+                        }
+                    }
+ 
+                /* Execute the engine. */
+ 
+                used_buffer_size = 0;
+                args_backup = args;
+                rc = (*xds->engines[pos].engine)(xds,
+                                                 xds->engines[pos].context,
+                                                 xds->buffer + xds->buffer_len,
+                                                 xds->buffer_capacity - xds->buffer_len,
+                                                 &used_buffer_size,
+                                                 &args);
+                assert(rc <= 0);
+                if (rc == XDS_OK)
+                    {
+                    restart_engine = XDS_FALSE;
+                    xds->buffer_len += used_buffer_size;
+                    }
+                else if (rc == XDS_ERR_OVERFLOW)
+                    {           /* enlarge buffer */
+                    if (!xds->we_own_buffer)
+                        goto leave;
+ 
+                    restart_engine = XDS_TRUE;
+                    args = args_backup;
+ 
+                    rc = xds_set_capacity((void**)&xds->buffer,
+                                          &xds->buffer_capacity,
+                                          xds->buffer_capacity + ((used_buffer_size == 0) ? 1 : used_buffer_size),
+                                          sizeof(char),
+                                          XDS_INITIAL_BUFFER_CAPACITY);
+                    assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM);
+                    if (rc != XDS_OK)
+                        goto leave;
+                    }
+                else
+                    goto leave;
+                }
+            while (restart_engine);
+            }
+        }
+     rc = XDS_OK;
+ 
+     /* Clean up and leave. */
+   leave:
+     free(fmt);
+     if (rc != XDS_OK)
+        xds->buffer_len = buffer_len_backup;
+     return rc;
+     }


ossp-pkg/xds/xdr-decode-double.c 1.1 -> 1.2

--- xdr-decode-double.c  2001/07/23 13:04:06     1.1
+++ xdr-decode-double.c  2001/08/01 15:25:47     1.2
@@ -27,7 +27,9 @@
 
 #include "internal.h"
 
-int xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_double(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
     return -1;
     }


ossp-pkg/xds/xdr-decode-int32.c 1.3 -> 1.4

--- xdr-decode-int32.c   2001/07/23 15:33:42     1.3
+++ xdr-decode-int32.c   2001/08/01 15:25:47     1.4
@@ -25,28 +25,21 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_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;
     xds_uint32_t  tmp;
 
-    /* Consistency checks. */
-
-    assert(xds != NULL);
-    assert(buffer != NULL);
-    assert(args != NULL);
-    if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
-        return XDS_ERR_INVALID_ARG;
-    if (buffer_size < 4)
-        return XDS_ERR_UNDERFLOW;
+    xds_init_decoding_engine(4);
 
     /* Get value and format it into the buffer. */
 
     value = va_arg(*args, xds_int32_t*);
-    assert(value != NULL);
+    xds_check_parameter(value != NULL);
 
     if (((xds_uint8_t*)buffer)[0] & 0x80)
         {                       /* negative number */
@@ -67,5 +60,5 @@
 
     /* Done. */
 
-    return 4;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-decode-int64.c 1.3 -> 1.4

--- xdr-decode-int64.c   2001/07/23 15:33:42     1.3
+++ xdr-decode-int64.c   2001/08/01 15:25:47     1.4
@@ -25,28 +25,21 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_int64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
     xds_int64_t*  value;
     xds_uint64_t  tmp;
 
-    /* Consistency checks. */
-
-    assert(xds != NULL);
-    assert(buffer != NULL);
-    assert(args != NULL);
-    if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
-        return XDS_ERR_INVALID_ARG;
-    if (buffer_size < 8)
-        return XDS_ERR_UNDERFLOW;
+    xds_init_decoding_engine(8);
 
     /* Get value and format it into the buffer. */
 
     value = va_arg(*args, xds_int64_t*);
-    assert(value != NULL);
+    xds_check_parameter(value != NULL);
 
     if (((xds_uint8_t*)buffer)[0] & 0x80)
         {                       /* negative number */
@@ -75,5 +68,5 @@
 
     /* Done. */
 
-    return 8;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-decode-octetstream.c 1.3 -> 1.4

--- xdr-decode-octetstream.c     2001/07/23 15:33:42     1.3
+++ xdr-decode-octetstream.c     2001/08/01 15:25:47     1.4
@@ -26,42 +26,29 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_octetstream(xds_t* xds, void* engine_context,
+                           void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                           va_list* args)
     {
     void**  p;
     size_t* p_len;
     size_t  padding;
 
-    /* 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;
-
-    /* Get pointers from the stack. */
+    xds_init_decoding_engine(4);
 
     p     = va_arg(*args, void**);
     p_len = va_arg(*args, size_t*);
-    assert(p != NULL);
-    assert(p_len != NULL);
+    xds_check_parameter(p != NULL);
+    xds_check_parameter(p_len != NULL);
 
     /* Read the size of the message. */
 
-    if (buffer_size >= 4)
-        {
-        *p_len  = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8;
-        *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8;
-        *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8;
-        *p_len += ((xds_uint8_t*)buffer)[3];
-        }
-    else
-        return XDS_ERR_UNDERFLOW;
+    *p_len  = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8;
+    *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8;
+    *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8;
+    *p_len += ((xds_uint8_t*)buffer)[3];
 
     /* Calculate padding. */
 
@@ -69,7 +56,8 @@
 
     /* Do we have enough data?. */
 
-    if (buffer_size < 4 + *p_len + padding)
+    *used_buffer_size = 4 + *p_len + padding;
+    if (buffer_size < *used_buffer_size)
         return XDS_ERR_UNDERFLOW;
 
     /* Allocate buffer for the data. */
@@ -84,5 +72,5 @@
 
     /* Done. */
 
-    return 4 + *p_len + padding;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-decode-string.c 1.4 -> 1.5

--- xdr-decode-string.c  2001/07/23 15:33:42     1.4
+++ xdr-decode-string.c  2001/08/01 15:25:47     1.5
@@ -26,42 +26,29 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_string(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
     char**  p;
     size_t* p_len;
     size_t  padding;
 
-    /* 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;
-
-    /* Get pointers from the stack. */
+    xds_init_decoding_engine(4);
 
     p     = va_arg(*args, char**);
     p_len = va_arg(*args, size_t*);
-    assert(p != NULL);
-    assert(p_len != NULL);
+    xds_check_parameter(p != NULL);
+    xds_check_parameter(p_len != NULL);
 
     /* Read the size of the message. */
 
-    if (buffer_size >= 4)
-        {
-        *p_len  = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8;
-        *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8;
-        *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8;
-        *p_len += ((xds_uint8_t*)buffer)[3];
-        }
-    else
-        return XDS_ERR_UNDERFLOW;
+    *p_len  = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8;
+    *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8;
+    *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8;
+    *p_len += ((xds_uint8_t*)buffer)[3];
 
     /* Calculate padding. */
 
@@ -69,7 +56,8 @@
 
     /* Do we have enough data?. */
 
-    if (buffer_size < 4 + *p_len + padding)
+    *used_buffer_size = 4 + *p_len + padding;
+    if (buffer_size < *used_buffer_size)
         return XDS_ERR_UNDERFLOW;
 
     /* Allocate buffer for the data. */
@@ -85,5 +73,5 @@
 
     /* Done. */
 
-    return 4 + *p_len + padding;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-decode-uint32.c 1.3 -> 1.4

--- xdr-decode-uint32.c  2001/07/23 15:33:42     1.3
+++ xdr-decode-uint32.c  2001/08/01 15:25:47     1.4
@@ -25,27 +25,20 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_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;
 
-    /* Consistency checks. */
-
-    assert(xds != NULL);
-    assert(buffer != NULL);
-    assert(args != NULL);
-    if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
-        return XDS_ERR_INVALID_ARG;
-    if (buffer_size < 4)
-        return XDS_ERR_UNDERFLOW;
+    xds_init_decoding_engine(4);
 
     /* Get value and format it into the buffer. */
 
     value = va_arg(*args, xds_uint32_t*);
-    assert(value != NULL);
+    xds_check_parameter(value != NULL);
 
     *value  = ((xds_uint8_t*)buffer)[0]; *value = *value << 8;
     *value += ((xds_uint8_t*)buffer)[1]; *value = *value << 8;
@@ -54,5 +47,5 @@
 
     /* Done. */
 
-    return 4;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-decode-uint64.c 1.3 -> 1.4

--- xdr-decode-uint64.c  2001/07/23 15:33:42     1.3
+++ xdr-decode-uint64.c  2001/08/01 15:25:47     1.4
@@ -25,27 +25,20 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_uint64(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
     xds_uint64_t*  value;
 
-    /* Consistency checks. */
-
-    assert(xds != NULL);
-    assert(buffer != NULL);
-    assert(args != NULL);
-    if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
-        return XDS_ERR_INVALID_ARG;
-    if (buffer_size < 8)
-        return XDS_ERR_UNDERFLOW;
+    xds_init_decoding_engine(8);
 
     /* Get value and format it into the buffer. */
 
     value = va_arg(*args, xds_uint64_t*);
-    assert(value != NULL);
+    xds_check_parameter(value != NULL);
 
     *value  = ((xds_uint8_t*)buffer)[0]; *value = *value << 8;
     *value += ((xds_uint8_t*)buffer)[1]; *value = *value << 8;
@@ -58,5 +51,5 @@
 
     /* Done. */
 
-    return 8;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-encode-double.c 1.1 -> 1.2

--- xdr-encode-double.c  2001/07/23 13:04:06     1.1
+++ xdr-encode-double.c  2001/08/01 15:25:47     1.2
@@ -27,7 +27,9 @@
 
 #include "internal.h"
 
-int xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_double(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
     return -1;
     }


ossp-pkg/xds/xdr-encode-int32.c 1.3 -> 1.4

--- xdr-encode-int32.c   2001/07/23 15:33:42     1.3
+++ xdr-encode-int32.c   2001/08/01 15:25:47     1.4
@@ -25,40 +25,33 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_encode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_int32(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
-    /* Consistency checks. */
+    xds_uint32_t tmp;
+    xds_int32_t value;
 
-    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;
+    xds_init_encoding_engine(4);
 
     /* Get value and format it into the buffer. */
 
-    if (buffer_size >= 4)
+    value = va_arg(*args, xds_uint32_t);
+    if (value < 0)
         {
-        xds_uint32_t tmp;
-        xds_int32_t value = va_arg(*args, xds_uint32_t);
-        if (value < 0)
-            {
-            value = 0 - value;
-            tmp = 0 - (xds_uint32_t)value;
-            }
-        else
-            tmp = (xds_uint32_t)value;
-        ((xds_uint8_t*)buffer)[0] = (tmp >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (tmp >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (tmp >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (tmp >>  0) & 0x000000ff;
+        value = 0 - value;
+        tmp = 0 - (xds_uint32_t)value;
         }
+    else
+        tmp = (xds_uint32_t)value;
+    ((xds_uint8_t*)buffer)[0] = (tmp >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (tmp >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (tmp >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (tmp >>  0) & 0x000000ff;
 
     /* Done. */
 
-    return 4;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-encode-int64.c 1.3 -> 1.4

--- xdr-encode-int64.c   2001/07/23 15:33:42     1.3
+++ xdr-encode-int64.c   2001/08/01 15:25:47     1.4
@@ -25,44 +25,37 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_int64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
-    /* Consistency checks. */
+    xds_uint64_t tmp;
+    xds_int64_t  value;
 
-    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;
+    xds_init_encoding_engine(8);
 
     /* Get value and format it into the buffer. */
 
-    if (buffer_size >= 8)
+    value = va_arg(*args, xds_uint64_t);
+    if (value < 0)
         {
-        xds_uint64_t tmp;
-        xds_int64_t  value = va_arg(*args, xds_uint64_t);
-        if (value < 0)
-            {
-            value = 0 - value;
-            tmp = 0 - (xds_uint64_t)value;
-            }
-        else
-            tmp = (xds_uint64_t)value;
-        ((xds_uint8_t*)buffer)[0] = (tmp >> 56) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (tmp >> 48) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (tmp >> 40) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (tmp >> 32) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[4] = (tmp >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[5] = (tmp >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[6] = (tmp >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[7] = (tmp >>  0) & 0x000000ff;
+        value = 0 - value;
+        tmp = 0 - (xds_uint64_t)value;
         }
+    else
+        tmp = (xds_uint64_t)value;
+    ((xds_uint8_t*)buffer)[0] = (tmp >> 56) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (tmp >> 48) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (tmp >> 40) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (tmp >> 32) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[4] = (tmp >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[5] = (tmp >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[6] = (tmp >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[7] = (tmp >>  0) & 0x000000ff;
 
     /* Done. */
 
-    return 8;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-encode-octetstream.c 1.4 -> 1.5

--- xdr-encode-octetstream.c     2001/07/23 15:33:42     1.4
+++ xdr-encode-octetstream.c     2001/08/01 15:25:47     1.5
@@ -25,47 +25,45 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include <string.h>
 #include "internal.h"
 
-int xdr_encode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_octetstream(xds_t* xds, void* engine_context,
+                           void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                           va_list* args)
     {
     xds_uint8_t* p;
     size_t       p_len;
     size_t       padding;
 
-    /* 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;
+    xds_init_encoding_engine(4);
 
     /* Get value from stack and calculate the correct amount of
        padding. */
 
     p       = (xds_uint8_t*)va_arg(*args, void*);
-    assert(p != NULL);
+    xds_check_parameter(p != NULL);
     p_len   = va_arg(*args, size_t);
     padding = (4 - (p_len & 0x03)) & 0x03;
     assert((p_len + padding) % 4 == 0);
 
+    /* We need (4 + p_len + padding) bytes in the buffer to format our
+       parameter. If we don't have them, return an underflow error. */
+
+    *used_buffer_size = 4 + p_len + padding;
+    if (buffer_size < *used_buffer_size)
+        return XDS_ERR_OVERFLOW;
+
     /* Format the values into the buffer. */
 
-    if (buffer_size >= 4 + p_len + padding)
-        {
-        ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (p_len >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (p_len >>  0) & 0x000000ff;
-        memmove((xds_uint8_t*)buffer+4, p, p_len);
-        memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
-        }
+    ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (p_len >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (p_len >>  0) & 0x000000ff;
+    memmove((xds_uint8_t*)buffer+4, p, p_len);
+    memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
 
     /* Done. */
 
-    return 4 + p_len + padding;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-encode-string.c 1.5 -> 1.6

--- xdr-encode-string.c  2001/07/23 15:33:42     1.5
+++ xdr-encode-string.c  2001/08/01 15:25:47     1.6
@@ -25,47 +25,45 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include <string.h>
 #include "internal.h"
 
-int xdr_encode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_string(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
     char*  p;
     size_t p_len;
     size_t padding;
 
-    /* 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;
+    xds_init_encoding_engine(4);
 
     /* Get value from stack and calculate the correct amount of
        padding. */
 
     p       = va_arg(*args, char*);
-    assert(p != NULL);
+    xds_check_parameter(p != NULL);
     p_len   = strlen(p);
     padding = (4 - (p_len & 0x03)) & 0x03;
     assert((p_len + padding) % 4 == 0);
 
+    /* We need (4 + p_len + padding) bytes in the buffer to format our
+       parameter. If we don't have them, return an underflow error. */
+
+    *used_buffer_size = 4 + p_len + padding;
+    if (buffer_size < *used_buffer_size)
+        return XDS_ERR_OVERFLOW;
+
     /* Format the values into the buffer. */
 
-    if (buffer_size >= 4 + p_len + padding)
-        {
-        ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (p_len >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (p_len >>  0) & 0x000000ff;
-        memmove((xds_uint8_t*)buffer+4, p, p_len);
-        memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
-        }
+    ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (p_len >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (p_len >>  0) & 0x000000ff;
+    memmove((xds_uint8_t*)buffer+4, p, p_len);
+    memset((xds_uint8_t*)buffer+4+p_len, 0, padding);
 
     /* Done. */
 
-    return 4 + p_len + padding;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-encode-uint32.c 1.3 -> 1.4

--- xdr-encode-uint32.c  2001/07/23 15:33:42     1.3
+++ xdr-encode-uint32.c  2001/08/01 15:25:47     1.4
@@ -25,32 +25,25 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_uint32(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
-    /* Consistency checks. */
+    xds_uint32_t value;
 
-    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;
+    xds_init_encoding_engine(4);
 
     /* Get value and format it into the buffer. */
 
-    if (buffer_size >= 4)
-        {
-        xds_uint32_t value = va_arg(*args, xds_uint32_t);
-        ((xds_uint8_t*)buffer)[0] = (value >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (value >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (value >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (value >>  0) & 0x000000ff;
-        }
+    value = va_arg(*args, xds_uint32_t);
+    ((xds_uint8_t*)buffer)[0] = (value >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (value >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (value >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (value >>  0) & 0x000000ff;
 
     /* Done. */
 
-    return 4;
+    return XDS_OK;
     }


ossp-pkg/xds/xdr-encode-uint64.c 1.3 -> 1.4

--- xdr-encode-uint64.c  2001/07/23 15:33:42     1.3
+++ xdr-encode-uint64.c  2001/08/01 15:25:47     1.4
@@ -25,36 +25,29 @@
    SUCH DAMAGE.
 */
 
-#include <assert.h>
 #include "internal.h"
 
-int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_encode_uint64(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
-    /* Consistency checks. */
+    xds_uint64_t value;
 
-    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;
+    xds_init_encoding_engine(8);
 
     /* Get value and format it into the buffer. */
 
-    if (buffer_size >= 8)
-        {
-        xds_uint64_t value = va_arg(*args, xds_uint64_t);
-        ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[6] = (value >>  8) & 0x000000ff;
-        ((xds_uint8_t*)buffer)[7] = (value >>  0) & 0x000000ff;
-        }
+    value = va_arg(*args, xds_uint64_t);
+    ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[6] = (value >>  8) & 0x000000ff;
+    ((xds_uint8_t*)buffer)[7] = (value >>  0) & 0x000000ff;
 
     /* Done. */
 
-    return 8;
+    return XDS_OK;
     }


ossp-pkg/xds/xds.h.in 1.6 -> 1.7

--- xds.h.in     2001/07/31 15:27:45     1.6
+++ xds.h.in     2001/08/01 15:25:47     1.7
@@ -61,10 +61,8 @@
 struct xds_context;
 typedef struct xds_context xds_t;
 
-typedef int (*xds_engine_t)(xds_t* xds,
-                            void* engine_context,
-                            void* buffer,
-                            size_t buffer_size,
+typedef int (*xds_engine_t)(xds_t* xds, void* engine_context,
+                            void* buffer, size_t buffer_size, size_t* used_buffer_size,
                             va_list* args);
 
 xds_t* xds_init(xds_mode_t);
@@ -73,7 +71,7 @@
 int xds_register(xds_t* xds, const char* name, xds_engine_t engine, void* engine_context);
 int xds_unregister(xds_t* xds, const char* name);
 
-int xds_setbuffer(xds_t* xds, xds_scope_t flag, void*  buffer, size_t  buffer_len);
+int xds_setbuffer(xds_t* xds, xds_scope_t flag, void* buffer, size_t buffer_len);
 int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_len);
 
 int xds_encode(xds_t* xds, const char* fmt, ...);
@@ -81,44 +79,45 @@
 int xds_vencode(xds_t* xds, const char* fmt, va_list args);
 int xds_vdecode(xds_t* xds, const char* fmt, va_list args);
 
-int xdr_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_encode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
+#define declare_formatting_engine(x) \
+    int x(xds_t* xds, void* engine_context, \
+          void* buffer, size_t buffer_size, size_t* used_buffer_size, \
+          va_list* args)
+
+declare_formatting_engine(xdr_encode_uint32);
+declare_formatting_engine(xdr_decode_uint32);
+declare_formatting_engine(xdr_encode_int32);
+declare_formatting_engine(xdr_decode_int32);
+declare_formatting_engine(xdr_encode_uint64);
+declare_formatting_engine(xdr_decode_uint64);
+declare_formatting_engine(xdr_encode_int64);
+declare_formatting_engine(xdr_decode_int64);
+declare_formatting_engine(xdr_encode_double);
+declare_formatting_engine(xdr_decode_double);
+declare_formatting_engine(xdr_encode_octetstream);
+declare_formatting_engine(xdr_decode_octetstream);
+declare_formatting_engine(xdr_encode_string);
+declare_formatting_engine(xdr_decode_string);
+
+declare_formatting_engine(xml_encode_begin);
+declare_formatting_engine(xml_decode_begin);
+declare_formatting_engine(xml_encode_end);
+declare_formatting_engine(xml_decode_end);
+declare_formatting_engine(xml_encode_uint32);
+declare_formatting_engine(xml_decode_uint32);
+declare_formatting_engine(xml_encode_int32);
+declare_formatting_engine(xml_decode_int32);
+declare_formatting_engine(xml_encode_uint64);
+declare_formatting_engine(xml_decode_uint64);
+declare_formatting_engine(xml_encode_int64);
+declare_formatting_engine(xml_decode_int64);
+declare_formatting_engine(xml_encode_double);
+declare_formatting_engine(xml_decode_double);
+declare_formatting_engine(xml_encode_octetstream);
+declare_formatting_engine(xml_decode_octetstream);
+declare_formatting_engine(xml_encode_string);
+declare_formatting_engine(xml_decode_string);
 
-int xdr_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-int xdr_encode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_decode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-int xdr_encode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_decode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-int xdr_encode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-
-int xml_encode_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, va_list* args);
-
-int xml_encode_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, va_list* args);
-
-int xml_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xml_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-int xml_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xml_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-int xml_encode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xml_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-
-int xml_encode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xml_decode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xml_encode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
-int xml_decode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args);
+#undef declare_formatting_engine
 
 #endif /* !defined(__LIBXDS_H__) */


ossp-pkg/xds/xml-decode-begin.c 1.1 -> 1.2

--- xml-decode-begin.c   2001/07/31 15:27:45     1.1
+++ xml-decode-begin.c   2001/08/01 15:25:47     1.2
@@ -26,25 +26,14 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
-int xml_decode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xml_decode_begin(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
-    /* 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;
-
-    if (buffer_size < strlen(xds_xml_begin_text))
-        return XDS_ERR_UNDERFLOW;
-
+    xds_init_encoding_engine(strlen(xds_xml_begin_text));
     if (strncasecmp(buffer, xds_xml_begin_text, strlen(xds_xml_begin_text)) != 0)
         return XDS_ERR_TYPE_MISMATCH;
-
-    return strlen(xds_xml_begin_text);
+    return XDS_OK;
     }


ossp-pkg/xds/xml-decode-double.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,35 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include "internal.h"
+ 
+ int xml_decode_double(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     return -1;
+     }


ossp-pkg/xds/xml-decode-end.c 1.1 -> 1.2

--- xml-decode-end.c     2001/07/31 15:28:14     1.1
+++ xml-decode-end.c     2001/08/01 15:25:47     1.2
@@ -26,25 +26,14 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
-int xml_decode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xml_decode_end(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
-    /* 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;
-
-    if (buffer_size < strlen(xds_xml_end_text))
-        return XDS_ERR_UNDERFLOW;
-
+    xds_init_decoding_engine(strlen(xds_xml_end_text));
     if (strncasecmp(buffer, xds_xml_end_text, strlen(xds_xml_end_text)) != 0)
         return XDS_ERR_TYPE_MISMATCH;
-
-    return strlen(xds_xml_end_text);
+    return XDS_OK;
     }


ossp-pkg/xds/xml-decode-int32.c -> 1.3

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,78 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(7 + 8 + 1);
+ 
+     /* Does the opening XML tag match? */
+ 
+     if (strncasecmp(buffer, "<int32>", 7) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Decode the representation of the value. */
+ 
+     value = va_arg(*args, xds_int32_t*);
+     *value = 0;
+     p = (char*)buffer + 7;
+     if (*p == '-')
+        {
+        negative = XDS_TRUE;
+        ++p;
+        }
+     else
+        negative = XDS_FALSE;
+     while(isdigit(*p))
+        {
+        if (p >= (char*)buffer + buffer_size)
+            return XDS_ERR_UNDERFLOW;
+        *value *= 10;
+        *value += *p++ - '0';
+        }
+     if (negative)
+        *value = 0 - *value;
+ 
+     /* Does the closing XML tag match? */
+ 
+     if (p+8 > (char*)buffer + buffer_size)
+        return XDS_ERR_UNDERFLOW;
+     else if (strncasecmp(p, "</int32>", 8) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     *used_buffer_size = p + 8 - (char*)buffer;
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-decode-int64.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,78 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ int xml_decode_int64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     xds_int64_t* value;
+     char* p;
+     int negative;
+ 
+     xds_init_decoding_engine(7 + 8 + 1);
+ 
+     /* Does the opening XML tag match? */
+ 
+     if (strncasecmp(buffer, "<int64>", 7) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Decode the representation of the value. */
+ 
+     value = va_arg(*args, xds_int64_t*);
+     *value = 0;
+     p = (char*)buffer + 7;
+     if (*p == '-')
+        {
+        negative = XDS_TRUE;
+        ++p;
+        }
+     else
+        negative = XDS_FALSE;
+     while(isdigit(*p))
+        {
+        if (p >= (char*)buffer + buffer_size)
+            return XDS_ERR_UNDERFLOW;
+        *value *= 10;
+        *value += *p++ - '0';
+        }
+     if (negative)
+        *value = 0 - *value;
+ 
+     /* Does the closing XML tag match? */
+ 
+     if (p+8 > (char*)buffer + buffer_size)
+        return XDS_ERR_UNDERFLOW;
+     else if (strncasecmp(p, "</int64>", 8) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     *used_buffer_size = p + 8 - (char*)buffer;
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-decode-uint32.c -> 1.3

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,68 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(8 + 9 + 1);
+ 
+     /* Does the opening XML tag match? */
+ 
+     if (strncasecmp(buffer, "<uint32>", 8) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Decode the representation of the value. */
+ 
+     value = va_arg(*args, xds_uint32_t*);
+     *value = 0;
+     p = (char*)buffer + 8;
+     while(isdigit(*p))
+        {
+        if (p >= (char*)buffer + buffer_size)
+            return XDS_ERR_UNDERFLOW;
+        *value *= 10;
+        *value += *p++ - '0';
+        }
+ 
+     /* Does the closing XML tag match? */
+ 
+     if (p+9 > (char*)buffer + buffer_size)
+        return XDS_ERR_UNDERFLOW;
+     else if (strncasecmp(p, "</uint32>", 9) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     *used_buffer_size = p + 9 - (char*)buffer;
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-decode-uint64.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,68 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include <ctype.h>
+ #include "internal.h"
+ 
+ int xml_decode_uint64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     xds_uint64_t* value;
+     char* p;
+ 
+     xds_init_decoding_engine(8 + 9 + 1);
+ 
+     /* Does the opening XML tag match? */
+ 
+     if (strncasecmp(buffer, "<uint64>", 8) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Decode the representation of the value. */
+ 
+     value = va_arg(*args, xds_uint64_t*);
+     *value = 0;
+     p = (char*)buffer + 8;
+     while(isdigit(*p))
+        {
+        if (p >= (char*)buffer + buffer_size)
+            return XDS_ERR_UNDERFLOW;
+        *value *= 10;
+        *value += *p++ - '0';
+        }
+ 
+     /* Does the closing XML tag match? */
+ 
+     if (p+9 > (char*)buffer + buffer_size)
+        return XDS_ERR_UNDERFLOW;
+     else if (strncasecmp(p, "</uint64>", 9) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     *used_buffer_size = p + 9 - (char*)buffer;
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-encode-begin.c 1.1 -> 1.2

--- xml-encode-begin.c   2001/07/31 15:27:45     1.1
+++ xml-encode-begin.c   2001/08/01 15:25:47     1.2
@@ -26,7 +26,6 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
 const char xds_xml_begin_text[] = \
@@ -34,19 +33,11 @@
     "<!DOCTYPE xds SYSTEM \"http://www.ossp.org/pkg/xds/xds-xml.dtd\">\n" \
     "<xds>\n";
 
-int xml_encode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xml_encode_begin(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
-    /* 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;
-
-    if (buffer_size >= strlen(xds_xml_begin_text))
-        memmove(buffer, xds_xml_begin_text, strlen(xds_xml_begin_text));
-
-    return strlen(xds_xml_begin_text);
+    xds_init_encoding_engine(strlen(xds_xml_begin_text));
+    memmove(buffer, xds_xml_begin_text, strlen(xds_xml_begin_text));
+    return XDS_OK;
     }


ossp-pkg/xds/xml-encode-double.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,35 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include "internal.h"
+ 
+ int xml_encode_double(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     return -1;
+     }


ossp-pkg/xds/xml-encode-end.c 1.1 -> 1.2

--- xml-encode-end.c     2001/07/31 15:28:14     1.1
+++ xml-encode-end.c     2001/08/01 15:25:47     1.2
@@ -26,24 +26,15 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
 const char xds_xml_end_text[] = "</xds>\n";
 
-int xml_encode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xml_encode_end(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
     {
-    /* 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;
-
-    if (buffer_size >= strlen(xds_xml_end_text))
-        memmove(buffer, xds_xml_end_text, strlen(xds_xml_end_text));
-
-    return strlen(xds_xml_end_text);
+    xds_init_encoding_engine(strlen(xds_xml_end_text));
+    memmove(buffer, xds_xml_end_text, strlen(xds_xml_end_text));
+    return XDS_OK;
     }


ossp-pkg/xds/xml-encode-int32.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,79 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include "internal.h"
+ 
+ int xml_encode_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 buf[32];
+     size_t i, j;
+     char* p;
+     int negative;
+ 
+     xds_init_encoding_engine(7 + 8 + 11);
+ 
+     /* Get the value and format it into our buffer. Keep track of the
+        length of the formatted result. */
+ 
+     value = va_arg(*args, xds_int32_t);
+     if (value < 0)
+        {
+        negative = XDS_TRUE;
+        value = 0 - value;
+        }
+     else
+        negative = XDS_FALSE;
+     i = 0;
+     do
+        {
+        unsigned char remainder = value % 10;
+        value = value / 10;
+        buf[i++] = '0' + remainder;
+        }
+     while (value != 0);
+     if (negative)
+        buf[i++] = '-';
+ 
+     /* Now that we know the correct size of our data's representation,
+        write it into the buffer. */
+ 
+     *used_buffer_size = 7 + 8 + i;
+     p = buffer;
+     memmove(p, "<int32>", 7);
+     p += 7;
+     for (j = i; j > 0; )
+        {
+        *p++ = buf[--j];
+        }
+     memmove(p, "</int32>", 8);
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-encode-int64.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,80 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include "internal.h"
+ 
+ int xml_encode_int64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     xds_int64_t value;
+     char buf[64];
+     size_t i, j;
+     char* p;
+     int negative;
+ 
+     xds_init_encoding_engine(7 + 8 + 21);
+ 
+     /* Format value into our buffer. */
+ 
+     value = va_arg(*args, xds_int64_t);
+     if (value < 0)
+        {
+        negative = XDS_TRUE;
+        value = 0 - value;
+        }
+     else
+        negative = XDS_FALSE;
+     i = 0;
+     do
+        {
+        unsigned char remainder = value % 10;
+        value = value / 10;
+        buf[i++] = '0' + remainder;
+        }
+     while (value != 0);
+     if (negative)
+        buf[i++] = '-';
+ 
+     /* Store the correct buffer size. */
+ 
+     *used_buffer_size = 7 + 8 + i;
+ 
+     /* Write result into the buffer. */
+ 
+     p = buffer;
+     memmove(p, "<int64>", 7);
+     p += 7;
+     for (j = i; j > 0; )
+        {
+        *p++ = buf[--j];
+        }
+     memmove(p, "</int64>", 8);
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-encode-uint32.c -> 1.3

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,70 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include "internal.h"
+ 
+ int xml_encode_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 buf[32];
+     size_t i, j;
+     char* p;
+ 
+     xds_init_encoding_engine(8 + 9 + 10);
+ 
+     /* Format value into our buffer. */
+ 
+     value = va_arg(*args, xds_uint32_t);
+     i = 0;
+     do
+        {
+        unsigned char remainder = value % 10;
+        value = value / 10;
+        buf[i++] = '0' + remainder;
+        }
+     while (value != 0);
+ 
+     /* Store the correct buffer size. */
+ 
+     *used_buffer_size = 8 + 9 + i;
+ 
+     /* Write result into the buffer. */
+ 
+     p = buffer;
+     memmove(p, "<uint32>", 8);
+     p += 8;
+     for (j = i; j > 0; )
+        {
+        *p++ = buf[--j];
+        }
+     memmove(p, "</uint32>", 9);
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xml-encode-uint64.c -> 1.4

*** /dev/null    Sat Apr 27 16:55:00 2024
--- -    Sat Apr 27 16:59:57 2024
***************
*** 0 ****
--- 1,70 ----
+ /*
+    XDS - OSSP Extensible Data Serialization Library
+    Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
+    Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ 
+    This file is part of OSSP XDS, an extensible data serialization
+    library which can be found at http://www.ossp.com/pkg/xds/.
+ 
+    Permission to use, copy, modify, and distribute this software for
+    any purpose with or without fee is hereby granted, provided that
+    the above copyright notice and this permission notice appear in all
+    copies.
+ 
+    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+ */
+ 
+ #include <string.h>
+ #include "internal.h"
+ 
+ int xml_encode_uint64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     xds_uint64_t value;
+     char buf[64];
+     size_t i, j;
+     char* p;
+ 
+     xds_init_encoding_engine(8 + 9 + 20);
+ 
+     /* Format value into our buffer. */
+ 
+     value = va_arg(*args, xds_uint64_t);
+     i = 0;
+     do
+        {
+        unsigned char remainder = value % 10;
+        value = value / 10;
+        buf[i++] = '0' + remainder;
+        }
+     while (value != 0);
+ 
+     /* Store the correct buffer size. */
+ 
+     *used_buffer_size = 8 + 9 + i;
+ 
+     /* Write result into the buffer. */
+ 
+     p = buffer;
+     memmove(p, "<uint64>", 8);
+     p += 8;
+     for (j = i; j > 0; )
+        {
+        *p++ = buf[--j];
+        }
+     memmove(p, "</uint64>", 9);
+ 
+     return XDS_OK;
+     }

CVSTrac 2.0.1