OSSP CVS Repository

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

Check-in Number: 634
Date: 2001-Aug-08 21:15:23 (local)
2001-Aug-08 19:15:23 (UTC)
User:rse
Branch:
Comment: First cut of the ruthless style adjustments to OSSP XDS:

o adjust source tree to follow OSSP source tree style by heavily combining sources into smaller sets (needs more work when still missing parts are added later)

o automatic re-indentation of sources with GNU indent (still needs manual review and adjustments; will follow)

These two heavy steps were mostly done automatically with the help of two helper scripts written in Perl. So expect more manual adjustments to follow...

Tickets:
Inspections:
Files:
ossp-pkg/xds/.cvsignore      1.4 -> 1.5     2 inserted, 0 deleted
ossp-pkg/xds/Makefile.in      1.22 -> 1.23     41 inserted, 45 deleted
ossp-pkg/xds/configure.ac      1.15 -> 1.16     9 inserted, 18 deleted
ossp-pkg/xds/decode.c      added-> 1.3
ossp-pkg/xds/destroy.c      added-> 1.10
ossp-pkg/xds/docs/Makefile.in      added-> 1.4
ossp-pkg/xds/docs/xds.pod      added-> 1.2
ossp-pkg/xds/encode.c      added-> 1.3
ossp-pkg/xds/find-engine.c      1.4->removed
ossp-pkg/xds/getbuffer.c      1.3->removed
ossp-pkg/xds/init.c      added-> 1.8
ossp-pkg/xds/internal.h      1.9->removed
ossp-pkg/xds/register.c      added-> 1.10
ossp-pkg/xds/regression-tests/.cvsignore      1.4->removed
ossp-pkg/xds/regression-tests/.run-tests      added-> 1.13
ossp-pkg/xds/regression-tests/Makefile.in      1.14 -> 1.15    
ossp-pkg/xds/regression-tests/xdr-int32.c      added-> 1.6
ossp-pkg/xds/regression-tests/xdr-int64.c      added-> 1.6
ossp-pkg/xds/regression-tests/xdr-octetstream-empty.c      1.2->removed
ossp-pkg/xds/regression-tests/xdr-octetstream.c      added-> 1.4
ossp-pkg/xds/regression-tests/xdr-string-empty.c      added-> 1.5
ossp-pkg/xds/regression-tests/xdr-string.c      added-> 1.6
ossp-pkg/xds/regression-tests/xdr-uint32.c      1.5->removed
ossp-pkg/xds/regression-tests/xdr-uint64.c      1.5->removed
ossp-pkg/xds/regression-tests/xds-core.c      added-> 1.2
ossp-pkg/xds/regression-tests/xds-decode.c      added-> 1.6
ossp-pkg/xds/regression-tests/xds-encode.c      1.6->removed
ossp-pkg/xds/regression-tests/xds-engine-restart.c      1.2->removed
ossp-pkg/xds/regression-tests/xds-find-engine.c      added-> 1.3
ossp-pkg/xds/regression-tests/xds-getbuffer.c      1.5->removed
ossp-pkg/xds/regression-tests/xds-mystruct.c      1.6->removed
ossp-pkg/xds/regression-tests/xds-register.c      1.7->removed
ossp-pkg/xds/regression-tests/xds-setbuffer.c      1.4->removed
ossp-pkg/xds/regression-tests/xml-double.c      added-> 1.3
ossp-pkg/xds/regression-tests/xml-int32.c      added-> 1.4
ossp-pkg/xds/regression-tests/xml-int64.c      added-> 1.5
ossp-pkg/xds/regression-tests/xml-octetstream-empty.c      added-> 1.3
ossp-pkg/xds/regression-tests/xml-octetstream.c      added-> 1.3
ossp-pkg/xds/regression-tests/xml-string-empty.c      1.1->removed
ossp-pkg/xds/regression-tests/xml-string.c      added-> 1.3
ossp-pkg/xds/regression-tests/xml-uint32.c      1.1->removed
ossp-pkg/xds/regression-tests/xml-uint64.c      added-> 1.4
ossp-pkg/xds/set-capacity.c      added-> 1.6
ossp-pkg/xds/setbuffer.c      1.7->removed
ossp-pkg/xds/unregister.c      added-> 1.8
ossp-pkg/xds/vdecode.c      added-> 1.7
ossp-pkg/xds/vencode.c      added-> 1.15
ossp-pkg/xds/xdr-decode-double.c      added-> 1.4
ossp-pkg/xds/xdr-decode-int32.c      added-> 1.6
ossp-pkg/xds/xdr-decode-int64.c      added-> 1.6
ossp-pkg/xds/xdr-decode-octetstream.c      added-> 1.6
ossp-pkg/xds/xdr-decode-string.c      added-> 1.8
ossp-pkg/xds/xdr-decode-uint32.c      added-> 1.6
ossp-pkg/xds/xdr-decode-uint64.c      added-> 1.6
ossp-pkg/xds/xdr-encode-double.c      added-> 1.4
ossp-pkg/xds/xdr-encode-int32.c      added-> 1.6
ossp-pkg/xds/xdr-encode-int64.c      added-> 1.6
ossp-pkg/xds/xdr-encode-octetstream.c      added-> 1.7
ossp-pkg/xds/xdr-encode-string.c      added-> 1.8
ossp-pkg/xds/xdr-encode-uint32.c      added-> 1.6
ossp-pkg/xds/xdr-encode-uint64.c      added-> 1.6
ossp-pkg/xds/xds.c      added-> 1.1
ossp-pkg/xds/xds.pod      1.6 -> 1.7    
ossp-pkg/xds/xds_engine_xdr.c      added-> 1.1
ossp-pkg/xds/xds_engine_xml.c      added-> 1.1
ossp-pkg/xds/xds_p.h      added-> 1.1
ossp-pkg/xds/xds_test.sh      added-> 1.1
ossp-pkg/xds/xds_test_lib.c      added-> 1.1
ossp-pkg/xds/xds_test_xdr.c      added-> 1.1
ossp-pkg/xds/xds_test_xml.c      added-> 1.1
ossp-pkg/xds/xml-decode-begin.c      added-> 1.4
ossp-pkg/xds/xml-decode-double.c      added-> 1.6
ossp-pkg/xds/xml-decode-end.c      added-> 1.4
ossp-pkg/xds/xml-decode-int32.c      added-> 1.6
ossp-pkg/xds/xml-decode-int64.c      added-> 1.7
ossp-pkg/xds/xml-decode-octetstream.c      added-> 1.4
ossp-pkg/xds/xml-decode-string.c      added-> 1.3
ossp-pkg/xds/xml-decode-uint32.c      added-> 1.6
ossp-pkg/xds/xml-decode-uint64.c      added-> 1.7
ossp-pkg/xds/xml-encode-begin.c      added-> 1.4
ossp-pkg/xds/xml-encode-double.c      added-> 1.6
ossp-pkg/xds/xml-encode-end.c      added-> 1.4
ossp-pkg/xds/xml-encode-int32.c      added-> 1.6
ossp-pkg/xds/xml-encode-int64.c      added-> 1.6
ossp-pkg/xds/xml-encode-octetstream.c      added-> 1.3
ossp-pkg/xds/xml-encode-string.c      added-> 1.3
ossp-pkg/xds/xml-encode-uint32.c      added-> 1.5
ossp-pkg/xds/xml-encode-uint64.c      added-> 1.6

ossp-pkg/xds/.cvsignore 1.4 -> 1.5

--- .cvsignore   2001/07/20 10:42:34     1.4
+++ .cvsignore   2001/08/08 19:15:23     1.5
@@ -1,2 +1,4 @@
+.*.t
+.*.l
 xds.3
 xds.h Makefile configure


ossp-pkg/xds/Makefile.in 1.22 -> 1.23

--- Makefile.in  2001/08/08 11:21:27     1.22
+++ Makefile.in  2001/08/08 19:15:23     1.23
@@ -1,70 +1,66 @@
 # Build libxds.
 
-CC              = @CC@
-AR              = ar
-RANLIB          = @RANLIB@
-
-CPPFLAGS        = @CPPFLAGS@ @DEFS@ -D_GNU_SOURCE
-CFLAGS          = @CFLAGS@
-LDFLAGS         = @LDFLAGS@
-
-XML64_OBJS      = @xml_64_bit_objects@
-XML_OBJS        = xml-encode-int32.o       xml-decode-int32.o \
-                  xml-encode-uint32.o      xml-decode-uint32.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 \
-                  xml-encode-octetstream.o xml-decode-octetstream.o \
-                  xml-encode-string.o      xml-decode-string.o \
-                  $(XML64_OBJS)
-
-XDR64_OBJS      = @xdr_64_bit_objects@
-XDR_OBJS        = xdr-encode-int32.o       xdr-decode-int32.o \
-                  xdr-encode-uint32.o      xdr-decode-uint32.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 \
-                  $(XDR64_OBJS)
-
-XDS_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
+CC        = @CC@
+AR        = ar
+RANLIB    = @RANLIB@
+CPPFLAGS  = @CPPFLAGS@ @DEFS@ -D_GNU_SOURCE
+CFLAGS    = @CFLAGS@
+LDFLAGS   = @LDFLAGS@
+LIBS      = @LIBS@
+POD2MAN   = @POD2MAN@
+
+LIB_NAME  = libxds.a
+LIB_OBJS  = xds.o xds_engine_xdr.o xds_engine_xml.o
+TST_SRCS  = xds_test_lib.c xds_test_xdr.c xds_test_xml.c
 
-OBJS            = $(XDS_OBJS) $(XDR_OBJS) $(XML_OBJS)
+.SUFFIXES:
+.SUFFIXES: .c .o .pod .3
+
+.PHONY: clean distclean realclean check docs
 
 .c.o:
         $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) -c $<
+.pod.3:
+        $(POD2MAN) --section=3 --center="XDS Library Programmer API" $< >$@
 
-.PHONY: clean distclean realclean check docs
+all: $(LIB_NAME) xds.3
 
-all:    libxds.a
-
-libxds.a:       $(OBJS)
+$(LIB_NAME):    $(LIB_OBJS)
         @rm -f $@
-        $(AR) cr $@ $(OBJS)
+        $(AR) cr $@ $(LIB_OBJS)
         $(RANLIB) $@
 
 clean::
-        @(cd regression-tests && $(MAKE) $@)
         @(cd docs && $(MAKE) $@)
-        rm -f $(OBJS)
-        rm -f libxds.a
+        -rm -f $(LIB_OBJS)
+        -rm -f ./.*.t ./.*.l
+        -rm -f $(LIB_NAME)
+        -rm -f xds.3
 
 distclean::     clean
-        @(cd regression-tests && $(MAKE) $@)
         @(cd docs && $(MAKE) $@)
-        rm -f config.log config.status Makefile
+        -rm -f config.log config.status Makefile
 
 realclean::     distclean
-        rm -f configure
+        -rm -f configure
 
-check:          libxds.a
-        (cd regression-tests && $(MAKE) check)
+check:          $(LIB_NAME) $(TST_SRCS)
+        -@for filename in $(TST_SRCS); do \
+            for testname in `grep "#ifdef XDS_TEST_" $$filename | sed -e 's;^#ifdef ;;'`; do \
+            filebase=`echo $$filename | sed -e 's;\.c;;'`; \
+            testbase=`echo $$testname | sed -e 's;^XDS_TEST_;;'`; \
+                if [ ! -f ".$$testbase.t" ]; then \
+                echo "$(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) $(LDFLAGS) -D$$testname -o .$$testbase.t $$filebase.c $(LIB_NAME)"; \
+                $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) $(LDFLAGS) -D$$testname -o .$$testbase.t $$filebase.c $(LIB_NAME); \
+            fi; \
+        done; \
+    done; \
+    sh ./xds_test.sh ./.*.t
 
 docs:
         @(cd docs && $(MAKE))
 
 # Dependencies
 
-$(XDS_OBJS):                    internal.h xds.h
-$(XDR_OBJS) $(XML_OBJS):        xds.h
+$(LIB_OBJS):                    xds_p.h xds.h
+


ossp-pkg/xds/configure.ac 1.15 -> 1.16

--- configure.ac 2001/08/08 11:49:07     1.15
+++ configure.ac 2001/08/08 19:15:23     1.16
@@ -1,8 +1,8 @@
 dnl configure.in -- Process this file with autoconf to produce a configure script.
 
-AC_INIT(libxds)
+AC_INIT(xds)
 AC_PREREQ(2.52)
-AC_REVISION($Revision: 1.15 $)
+AC_REVISION($Revision: 1.16 $)
 
 dnl Get rid of the lousy -g and -O defaults in CFLAGS.
 dnl
@@ -50,17 +50,6 @@
               [AC_MSG_WARN([no signed 64 bit data type found])
               xds_int64_t=undefined])
 dnl
-if test "$xds_int64_t" = "undefined" -o "$xds_uint64_t" = "undefined"; then
-   have_64_bit_support="#undef XDS_HAVE_64_BIT_SUPPORT"
-else
-   have_64_bit_support="#define XDS_HAVE_64_BIT_SUPPORT"
-   xdr_64_bit_objects="xdr-encode-int64.o xdr-decode-int64.o"
-   xdr_64_bit_objects="$xdr_64_bit_objects xdr-encode-uint64.o xdr-decode-uint64.o"
-   xml_64_bit_objects="xml-encode-int64.o xml-decode-int64.o"
-   xml_64_bit_objects="$xml_64_bit_objects xml-encode-uint64.o xml-decode-uint64.o"
-   tests_64_bit="xdr-int64.exe xdr-uint64.exe xml-int64.exe xml-uint64.exe"
-   tests_64_bit="$tests_64_bit xds-mystruct.exe"
-fi
 AC_SUBST([xds_uint8_t])
 AC_SUBST([xds_uint16_t])
 AC_SUBST([xds_uint32_t])
@@ -69,10 +58,12 @@
 AC_SUBST([xds_int16_t])
 AC_SUBST([xds_int32_t])
 AC_SUBST([xds_int64_t])
+if test "$xds_int64_t" = "undefined" -o "$xds_uint64_t" = "undefined"; then
+   have_64_bit_support="#undef XDS_HAVE_64_BIT_SUPPORT"
+else
+   have_64_bit_support="#define XDS_HAVE_64_BIT_SUPPORT"
+fi
 AC_SUBST([have_64_bit_support])
-AC_SUBST([xdr_64_bit_objects])
-AC_SUBST([xml_64_bit_objects])
-AC_SUBST([tests_64_bit])
 
 dnl Find the library containing the xdr_xxx() functions.
 dnl
@@ -81,6 +72,6 @@
 
 dnl Write results.
 dnl
-AC_CONFIG_FILES(xds.h Makefile regression-tests/Makefile docs/Makefile)
-AC_CONFIG_COMMANDS([default], [chmod -w xds.h Makefile regression-tests/Makefile docs/Makefile])
+AC_CONFIG_FILES(xds.h Makefile docs/Makefile)
+AC_CONFIG_COMMANDS([default], [chmod -w xds.h Makefile docs/Makefile])
 AC_OUTPUT


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,38 ----
+ /*
+    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_decode(xds_t* xds, const char* fmt, ...)
+     {
+     int rc;
+     va_list args;
+     va_start(args, fmt);
+     rc = xds_vdecode(xds, fmt, args);
+     va_end(args);
+     return rc;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,57 ----
+ /*
+    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"
+ 
+ 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/docs/Makefile.in -> 1.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,27 ----
+ # Build libxds documentation.
+ 
+ LATEX          = @LATEX@
+ 
+ .SUFFIXES:
+ .SUFFIXES:     .tex .dvi .ps
+ 
+ .tex.dvi:
+        latex \\nonstopmode\\input $<; \
+        while grep 'Rerun to' $*.log; do \
+             latex \\nonstopmode\\input $<; \
+        done
+ 
+ .dvi.ps:
+        dvips $< -o $@
+ 
+ all:   libxds.ps
+ 
+ clean:
+        rm -f libxds.aux libxds.dvi libxds.log libxds.ps libxds.toc
+ 
+ distclean realclean:
+        rm -f Makefile
+ 
+ # Dependencies
+ 
+ libxds.dvi:    architecture.eps data-exchange.eps setbuffer-logic.eps


ossp-pkg/xds/docs/xds.pod -> 1.2

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,134 ----
+ =pod
+ 
+ =head1 NAME
+ 
+ xds - eXtensible Data Serialization
+ 
+ =head1 SYNOPSIS
+ 
+ 
+ =head1 DESCRIPTION
+ 
+ =over 4
+ 
+ =item xds_t* B<xds_init>(xds_mode_t I<mode>);
+ 
+ Valid settings for I<mode> are B<XDS_ENCODE> and B<XDS_DECODE>. If
+ successful, a valid handle is returned -- B<NULL> otherwise. If the
+ routine fails, the system variable B<errno> is set apropriately.
+ 
+ =item void B<xds_destroy>(xds_t* I<xds>);
+ 
+ Free all internally allocated resources associated with this context.
+ I<xds> must be a handle obtained by calling B<xds_init>.
+ 
+ =item int B<xds_register>(xds_t* I<xds>, const char* I<name>, xds_engine_t I<engine>, void* I<engine_context>);
+ 
+ Register the function I<engine> as formatting engine in context I<xds>
+ under the name I<name>. The function must have the following
+ prototype:
+ 
+     int my_engine(xds_t* xds, void* engine_context,
+                  void* buffer, size_t buffer_size,
+                  va_list args);
+ 
+ It must gather its values from I<args> and encode/decode them into
+ I<buffer>. The encoded/decoded representation must not take up more
+ than I<size> byte of memory, because that's the maximum I<buffer> can
+ hold. If the buffer is too small, I<engine> must return
+ B<XDS_ERR_OVERFLOW>. In case of no error, I<engine> must return the
+ number of bytes it has written to the buffer. (Note that all xds error
+ defines are smaller than >0.) The variable I<engine_context> is passed
+ through to the function every time it is called; it is not touched in
+ any way by the xds library.
+ 
+ A valid name I<name> for a callback function consists of an arbitrary
+ number of characters from the class [a-zA-Z0-9_-].
+ 
+ =item int B<xds_unregister>(xds_t* I<xds>, const char* I<name>);
+ 
+ Remove encoding/decoding engine I<name> from context I<xds>. The
+ function will return B<XDS_OK> if successful and
+ B<XDS_ERR_UNKNOW_ENGINE> if I<name> is not a registered engine.
+ 
+ =item int B<xds_setbuffer>(xds_t* I<xds>, xds_scope_t I<flag>, void* I<buffer>, size_t I<buffer_size>);
+ 
+ Encoding mode: Set internal buffer used in context I<xds> to
+ I<buffer>. The buffer has a capacity of I<buffer_size> byte. I<flag>
+ may be set to B<XDS_LOAN> or B<XDS_GIFT>. A "loaned" buffer is one
+ that is owned by the application; xds will use it, but it will not
+ B<free> the buffer nor will it try to B<realloc> it if it's too small.
+ A buffer given to xds as a "gift" is henceforth owned by xds and may
+ be B<free>d or B<realloc>ed as the library sees fit. If I<flag> is
+ B<XDS_GIFT>, I<buffer> must be a pointer obtained from calling the
+ B<malloc(3)> API. Calling B<xds_setbuffer> with a I<buffer> of B<NULL>
+ will cause the xds library to allocate a buffer of its own.
+ I<buffer_size> is ignored in this case.
+ 
+ Decoding mode: I<buffer> contains the encoded representation of the
+ data to be used for following B<xds_decode> calls. The encoded data is
+ I<buffer_size> byte long. Unlike in encoding mode, such a buffer is
+ not modified, hence there is no need to extend the buffer. If I<flag>
+ is set to B<XDS_GIFT>, the library will B<free> I<buffer> when
+ the context is destroyed.
+ 
+ B<xds_setbuffer> returns one of the following codes signifying success
+ or failure: B<XDS_OK> (everything alright), B<XDS_ERR_NO_MEM> (failed
+ to allocate new internal buffers), and B<XDS_ERR_INVALID_ARG>
+ (arguments don't make sense).
+ 
+ =item int B<xds_getbuffer>(xds_t* I<xds>, xds_scope_t flag, void** buffer, size_t* buffer_size);
+ 
+ This routine will write the address and size of the internal buffer in
+ context I<xds> to I<buffer> and I<buffer_size>. The I<flag> parameter
+ determines who owns the buffer after that; setting I<flag> to
+ B<XDS_LOAN> means that the buffer is owned by the xds library and that
+ the user may not rely on its contents still being there after another
+ xds library function call. Furthermore, calling B<xds_getbuffer> will
+ flush the registered buffer, meaning that coming B<xds_encode> calls
+ will start at the beginning and potentially overwrite the buffer
+ contents.
+ 
+ Setting I<flag> to B<XDS_GIFT> means that the returned buffer is owned
+ by the application programmer from now on, it is no longer modified or
+ used in any way by the library. The application must B<free> the
+ buffer when it's not needed anymore.
+ 
+ =item int B<xds_encode>(xds_t* I<xds>, const char* I<fmt>, ...);
+ 
+ The B<encode> function call will encode an arbitrary number of values
+ into the chosen representation. The syntax is very similar to
+ B<sprintf>: As parameters, it requires the I<xds> handle obtained from
+ B<xds_init>, a format string I<fmt> describing the following value
+ parameters, and an arbitrary number of actual values.
+ 
+ The format string lists the names of the callback functions to be used
+ in order to format the values; it has the format "name name ...". The
+ names are delimited by any number of characters any of which is not
+ part of the character set allowed for function names here. Hence, you
+ can delimit the names by blanks, tabs, dollar signs or pretty much
+ anyting your want.
+ 
+ B<xds_encode> will return either B<XDS_OK> (everything OK),
+ B<XDS_ERR_NO_MEM> (failed allocating memory for intenal buffering),
+ B<XDS_ERR_OVERFLOW> (can't expand internal buffer because it's owned
+ by the application), B<XDS_ERR_INVALID_ARG> (parameters don't make
+ sense), B<XDS_ERR_TYPE_MISMATCH> (specified callback can't handle this
+ data type), and B<XDS_ERR_UNKNOW_ENGINE> (unknown call back name used
+ in I<fmt>).
+ 
+ =item int B<xds_decode>(xds_t* I<xds>, const char* I<fmt>, ...);
+ 
+ Like B<xds_encode>, only the other way round.
+ 
+ =item int B<xds_vencode>(xds_t* I<xds>, const char* I<fmt>, va_list I<args>);
+ 
+ See B<xds_encode>.
+ 
+ =item int B<xds_vdecode>(xds_t* I<xds>, const char* I<fmt>, va_list I<args>);
+ 
+ See B<xds_decode>.
+ 
+ =back
+ 
+ =cut


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,38 ----
+ /*
+    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_encode(xds_t* xds, const char* fmt, ...)
+     {
+     int rc;
+     va_list args;
+     va_start(args, fmt);
+     rc = xds_vencode(xds, fmt, args);
+     va_end(args);
+     return rc;
+     }


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



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



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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 <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.9 -> 1.10



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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,82 ----
+ /*
+    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_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((int)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/.cvsignore 1.4 -> 1.5



ossp-pkg/xds/regression-tests/.run-tests -> 1.13

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,42 ----
+ #!/bin/sh
+ 
+ if [ $# -lt 1 ]; then
+     echo "Usage: $0 test1.exe [...]"
+     exit 1
+ fi
+ 
+ RESCOLUMN=30
+ numTests=0
+ numFails=0
+ 
+ echo "Running test suite:"
+ 
+ pad=''
+ n=$RESCOLUMN
+ while [ $n -gt 0 ]; do
+     pad="$pad."
+     n=`expr $n - 1`
+ done
+ for suite in "$@"; do
+     name=`expr "${suite}" : '\(.*\)\.exe$'`
+     echo "$name$pad" | awk '{ printf("%s ", substr($0, 0, n)); }' n=$RESCOLUMN
+     numTests=`expr $numTests + 1`
+     eval ./$suite >${name}.log 2>&1
+     if [ $? -eq 0 ]; then
+         echo "OK"
+     else
+         numFails=`expr $numFails + 1`
+         echo "FAILED"
+     fi
+ done
+ 
+ echo
+ if [ $numFails -eq 0 ]; then
+     echo "Summary: All tests succeeded."
+     exit 0
+ else
+     percent=`expr $numFails \* 100`
+     percent=`expr $percent / $numTests`
+     echo "Summary: $numFails of $numTests tests failed ($percent%)."
+     exit 1
+ fi


ossp-pkg/xds/regression-tests/Makefile.in 1.14 -> 1.15



ossp-pkg/xds/regression-tests/xdr-int32.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 <rpc/types.h>
+ #include <rpc/xdr.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     XDR    xdrs;
+     char   xdr_buf[1024];
+     size_t xdr_buf_size;
+ 
+     xds_t* xds;
+     char*  xds_buf;
+     size_t xds_buf_size;
+ 
+     xds_int32_t values[] =
+        {
+         0x00000000,
+         0x12345678,
+        -0x12345678,
+         0x7bcdef01,
+        -0x7bcdef01,
+         0x7fffffff
+        };
+ 
+     size_t i;
+ 
+     /* Encode the values array using the RPC-XDR implementation. */
+ 
+     xdrmem_create(&xdrs, xdr_buf, sizeof(xdr_buf), XDR_ENCODE);
+     for (i = 0; i < sizeof(values)/sizeof(xds_int32_t); ++i)
+        xdr_int32_t(&xdrs, &values[i]);
+     xdr_buf_size = xdr_getpos(&xdrs);
+     xdr_destroy(&xdrs);
+ 
+     /* Encode the values array using the XDS implementation. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xdr_encode_int32, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int32_t); ++i)
+        {
+        if (xds_encode(xds, "int", values[i]) != XDS_OK)
+            {
+            printf("xds_encode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&xds_buf, &xds_buf_size) != XDS_OK)
+        {
+        printf("getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     /* Both buffers must be equal now. */
+ 
+     if (xdr_buf_size != xds_buf_size)
+        {
+        printf("The buffer sizes don't match: %d != %d.\n", xdr_buf_size, xds_buf_size);
+        return 1;
+        }
+     if (memcmp(xds_buf, xdr_buf, xds_buf_size) != 0)
+        {
+        printf("The buffers' contents is not identical!\n");
+        return 1;
+        }
+ 
+     /* Now we decode the values again using the XDS implementation and
+        compare them to our original values. Obviously, they should not
+        differ. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xdr_decode_int32, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, xds_buf, xds_buf_size) != XDS_OK)
+        {
+        printf("setbuffer() failed.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int32_t); ++i)
+        {
+        xds_int32_t tmp;
+        if (xds_decode(xds, "int", &tmp) != XDS_OK)
+            {
+            printf("xds_encode() failed for the %d value!\n", i);
+            return 1;
+            }
+        if (values[i] != tmp)
+            {
+            printf("The %dth value has not been decoded correctly!\n", i);
+            return 1;
+            }
+        }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xdr-int64.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 <rpc/types.h>
+ #include <rpc/xdr.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     XDR    xdrs;
+     char   xdr_buf[1024];
+     size_t xdr_buf_size;
+ 
+     xds_t* xds;
+     char*  xds_buf;
+     size_t xds_buf_size;
+ 
+     xds_int64_t values[] =
+        {
+         0x0000000000000000LL,
+         0x123456789abcdef0LL,
+        -0x123456789abcdef0LL,
+         0x7bcdef01cc45bb9aLL,
+        -0x7bcdef01cc45bb9aLL,
+         0x7fffffffffffffffLL
+        };
+ 
+     size_t i;
+ 
+     /* Encode the values array using the RPC-XDR implementation. */
+ 
+     xdrmem_create(&xdrs, xdr_buf, sizeof(xdr_buf), XDR_ENCODE);
+     for (i = 0; i < sizeof(values)/sizeof(xds_int64_t); ++i)
+        xdr_int64_t(&xdrs, &values[i]);
+     xdr_buf_size = xdr_getpos(&xdrs);
+     xdr_destroy(&xdrs);
+ 
+     /* Encode the values array using the XDS implementation. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xdr_encode_int64, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int64_t); ++i)
+        {
+        if (xds_encode(xds, "int", values[i]) != XDS_OK)
+            {
+            printf("xds_encode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&xds_buf, &xds_buf_size) != XDS_OK)
+        {
+        printf("getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     /* Both buffers must be equal now. */
+ 
+     if (xdr_buf_size != xds_buf_size)
+        {
+        printf("The buffer sizes don't match: %d != %d.\n", xdr_buf_size, xds_buf_size);
+        return 1;
+        }
+     if (memcmp(xds_buf, xdr_buf, xds_buf_size) != 0)
+        {
+        printf("The buffers' contents is not identical!\n");
+        return 1;
+        }
+ 
+     /* Now we decode the values again using the XDS implementation and
+        compare them to our original values. Obviously, they should not
+        differ. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xdr_decode_int64, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, xds_buf, xds_buf_size) != XDS_OK)
+        {
+        printf("setbuffer() failed.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int64_t); ++i)
+        {
+        xds_int64_t tmp;
+        if (xds_decode(xds, "int", &tmp) != XDS_OK)
+            {
+            printf("xds_encode() failed for the %d value!\n", i);
+            return 1;
+            }
+        if (values[i] != tmp)
+            {
+            printf("The %dth value has not been decoded correctly!\n", i);
+            return 1;
+            }
+        }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


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



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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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\000World";
+     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, sizeof(msg)-1) != 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 != sizeof(msg)-1)
+        {
+        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.5

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,104 ----
+ /*
+    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;
+ 
+     /* 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, "string", &xdr_encode_string, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "string", 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, "string", &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, "string", &new_msg) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (strlen(new_msg) != 0)
+        {
+        printf("The size of the decoded message is wrong.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,109 ----
+ /*
+    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;
+ 
+     /* 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, "string", &xdr_encode_string, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "string", 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, "string", &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, "string", &new_msg) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (strlen(new_msg) != sizeof(msg)-1)
+        {
+        printf("The size of the decoded message is wrong.\n");
+        return 1;
+        }
+     if (memcmp(msg, new_msg, sizeof(msg)-1) != 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-uint32.c 1.5 -> 1.6



ossp-pkg/xds/regression-tests/xdr-uint64.c 1.5 -> 1.6



ossp-pkg/xds/regression-tests/xds-core.c -> 1.2

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,74 ----
+ /*
+    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 <errno.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* ctx[50];
+     size_t i;
+ 
+     /* Open a bunch of contextes and close them again. */
+ 
+     for(i = 0; i < sizeof(ctx)/sizeof(xds_t*); ++i)
+        {
+        if (i % 2 == 0)
+            ctx[i] = xds_init(XDS_ENCODE);
+        else
+            ctx[i] = xds_init(XDS_DECODE);
+ 
+        if (ctx[i] == 0)
+            {
+            printf("Failed to initialize xds context: i = %d\n", i);
+            return 1;
+            }
+        }
+ 
+     for(i = 0; i < sizeof(ctx)/sizeof(xds_t*); ++i)
+        xds_destroy(ctx[i]);
+ 
+ #ifdef NDEBUG
+     /* Check how the library deals with errorneous arguments. */
+ 
+     if (xds_init((xds_mode_t)42) != NULL || errno != EINVAL)
+        {
+        printf("Called xds_init() with invalid mode but didn't get EINVAL.\n");
+        return 1;
+        }
+ 
+     /* Call xds_destroy() with an invalid context and see whether we
+        survive that. */
+ 
+     xds_destroy(NULL);
+ #endif
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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, sizeof(buffer)-1) != 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 -> 1.7



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



ossp-pkg/xds/regression-tests/xds-find-engine.c -> 1.3

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,163 ----
+ /*
+    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 "../internal.h"
+ 
+ int main()
+     {
+     const engine_map_t engines[] =
+        {
+        { "alan", NULL, 0 },
+        { "berta", NULL, 0 },
+        { "caesar", NULL, 0 },
+        { "doris", NULL, 0 },
+        { "egon", NULL, 0 },
+        { "franziska", NULL, 0 },
+        { "gudrun", NULL, 0 },
+        { "heinz", NULL, 0 },
+        { "igor", NULL, 0 },
+        { "jamila", NULL, 0 },
+        { "karin", NULL, 0 },
+        { "louis", NULL, 0 },
+        };
+     size_t engines_len = sizeof(engines) / sizeof(engine_map_t);
+     size_t pos;
+     size_t i;
+ 
+     /* Does xds_find_engine handle an empty array? */
+ 
+     if (xds_find_engine(engines, 0, "whatever", &pos))
+        {
+        printf("xds_find_engine() said 'whatever' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != 0)
+        {
+        printf("xds_find_engine() would insert 'whatever' at position %d, but 0 is correct.\n", pos);
+        exit(1);
+        }
+ 
+     /* Search for every single entry in the array and check the
+        results. */
+ 
+     for (i = 0; i < engines_len; ++i)
+        {
+        if (!xds_find_engine(engines, engines_len, engines[i].name, &pos))
+            {
+            printf("xds_find_engine() said '%s' wouldn't be in the array, but that's wrong.\n",
+                   engines[i].name);
+            exit(1);
+            }
+        if (pos != i)
+            {
+            printf("xds_find_engine() would insert '%s' at position %d, but %d is correct.\n",
+                   engines[i].name, pos, i);
+            exit(1);
+            }
+        }
+ 
+     /* Search for non-existing name that would be inserted at the
+        first position. */
+ 
+     if (xds_find_engine(engines, engines_len, "aaron", &pos))
+        {
+        printf("xds_find_engine() said 'aaron' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != 0)
+        {
+        printf("xds_find_engine() would insert 'aaron' at position %d, but 0 is correct.\n", pos);
+        exit(1);
+        }
+ 
+     /* Search for non-existing name that would be inserted at last
+        position. */
+ 
+     if (xds_find_engine(engines, engines_len, "zerberos", &pos))
+        {
+        printf("xds_find_engine() said 'zerberos' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != engines_len)
+        {
+        printf("xds_find_engine() would insert 'zerberos' at position %d, but %d is correct.\n",
+               pos, engines_len);
+        exit(1);
+        }
+ 
+     /* Search for non-existing names that would be inserted at random
+        positions. */
+ 
+     if (xds_find_engine(engines, engines_len, "balthasar", &pos))
+        {
+        printf("xds_find_engine() said 'balthasar' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != 1)
+        {
+        printf("xds_find_engine() would insert 'balthasar' at position %d, but 1 is correct.\n", pos);
+        exit(1);
+        }
+ 
+     if (xds_find_engine(engines, engines_len, "bulli", &pos))
+        {
+        printf("xds_find_engine() said 'bulli' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != 2)
+        {
+        printf("xds_find_engine() would insert 'bulli' at position %d, but 2 is correct.\n", pos);
+        exit(1);
+        }
+ 
+     if (xds_find_engine(engines, engines_len, "hildegard", &pos))
+        {
+        printf("xds_find_engine() said 'hildegard' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != 8)
+        {
+        printf("xds_find_engine() would insert 'hildegard' at position %d, but 8 is correct.\n", pos);
+        exit(1);
+        }
+ 
+     if (xds_find_engine(engines, engines_len, "harald", &pos))
+        {
+        printf("xds_find_engine() said 'harald' would be in the array, but that's wrong.\n");
+        exit(1);
+        }
+     if (pos != 7)
+        {
+        printf("xds_find_engine() would insert 'harald' at position %d, but 7 is correct.\n", pos);
+        exit(1);
+        }
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


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



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



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



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



ossp-pkg/xds/regression-tests/xml-double.c -> 1.3

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,114 ----
+ /*
+    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 <rpc/types.h>
+ #include <rpc/xdr.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+ #if 0
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     xds_double_t values[] =
+        {
+        3.14159265358979323844
+        };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the
+        numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xml_encode_double, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_double_t); ++i)
+        {
+        if (xds_encode(xds, "int", values[i]) != XDS_OK)
+            {
+            printf("xds_encode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     printf("%s\n", buffer);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xml_decode_double, 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("setbuffer() failed.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_double_t); ++i)
+        {
+        xds_double_t val;
+        if (xds_decode(xds, "int", &val) != XDS_OK)
+            {
+            printf("xds_decode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        if (val != values[i])
+            {
+            printf("Decoded value (%E) does not match the original value (%E)!\n", val, values[i]);
+            return 1;
+            }
+        }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ #endif
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xml-int32.c -> 1.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,140 ----
+ /*
+    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 <rpc/types.h>
+ #include <rpc/xdr.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     xds_int32_t values[] =
+        {
+         0x00000000,
+         0x12345678,
+        -0x12345678,
+         0x7bcdef01,
+        -0x7bcdef01,
+         0x7fffffff
+        };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the
+        numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK ||
+        xds_register(xds, "int", &xml_encode_int32, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "begin") != XDS_OK)
+        {
+        printf("xds_encode_begin() failed!\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int32_t); ++i)
+        {
+        if (xds_encode(xds, "int", values[i]) != XDS_OK)
+            {
+            printf("xds_encode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        }
+     if (xds_encode(xds, "end") != XDS_OK)
+        {
+        printf("xds_encode_end() failed!\n");
+        return 1;
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK ||
+        xds_register(xds, "int", &xml_decode_int32, 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("setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "begin") != XDS_OK)
+        {
+        printf("xds_decode_begin() failed!\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int32_t); ++i)
+        {
+        xds_int32_t val;
+        if (xds_decode(xds, "int", &val) != XDS_OK)
+            {
+            printf("xds_decode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        if (val != values[i])
+            {
+            printf("Decoded value (%d) does not match the original value (%d)!\n", val, values[i]);
+            return 1;
+            }
+        }
+     if (xds_decode(xds, "end") != XDS_OK)
+        {
+        printf("xds_decode_end() failed!\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xml-int64.c -> 1.5

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,116 ----
+ /*
+    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 <rpc/types.h>
+ #include <rpc/xdr.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     xds_int64_t values[] =
+        {
+         0x0000000000000000LL,
+         0x123456789abcdef0LL,
+        -0x123456789abcdef0LL,
+         0x7bcdef01cc45bb9aLL,
+        -0x7bcdef01cc45bb9aLL,
+         0x7fffffffffffffffLL
+        };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the
+        numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xml_encode_int64, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int64_t); ++i)
+        {
+        if (xds_encode(xds, "int", values[i]) != XDS_OK)
+            {
+            printf("xds_encode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xml_decode_int64, 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("setbuffer() failed.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_int64_t); ++i)
+        {
+        xds_int64_t val;
+        if (xds_decode(xds, "int", &val) != XDS_OK)
+            {
+            printf("xds_decode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        if (val != values[i])
+            {
+            printf("Decoded value does not match the original!\n");
+            return 1;
+            }
+        }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


ossp-pkg/xds/regression-tests/xml-octetstream-empty.c -> 1.3

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,113 ----
+ /*
+    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 <unistd.h>
+ 
+ #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", &xml_encode_octetstream, NULL) != XDS_OK ||
+        xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "begin os end", msg, sizeof(msg)-1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xml_decode_octetstream, NULL) != XDS_OK ||
+        xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "begin os end", &new_msg, &new_msg_size) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (new_msg_size != sizeof(msg)-1)
+        {
+        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/xml-octetstream.c -> 1.3

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,113 ----
+ /*
+    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 <unistd.h>
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     char   msg[] = "Hallo\000Worl";
+     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", &xml_encode_octetstream, NULL) != XDS_OK ||
+        xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "begin os end", msg, sizeof(msg)-1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "os", &xml_decode_octetstream, NULL) != XDS_OK ||
+        xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "begin os end", &new_msg, &new_msg_size) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (new_msg_size != sizeof(msg)-1)
+        {
+        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/xml-string-empty.c 1.1 -> 1.2



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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,112 ----
+ /*
+    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 <unistd.h>
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     char   msg[] = "<Hallo> ]]>&<&>World: äöüß";
+     char*  new_msg;
+ 
+     /* Encode the string, 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, "string", &xml_encode_string, NULL) != XDS_OK ||
+        xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     if (xds_encode(xds, "begin string end", msg, sizeof(msg)-1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "string", &xml_decode_string, NULL) != XDS_OK ||
+        xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+        xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK)
+        {
+        printf("Failed to register my decoding engines.\n");
+        return 1;
+        }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK)
+        {
+        printf("xds_setbuffer() failed.\n");
+        return 1;
+        }
+     if (xds_decode(xds, "begin string end", &new_msg) != XDS_OK)
+        {
+        printf("xds_decode() failed.\n");
+        return 1;
+        }
+     if (strlen(new_msg) != sizeof(msg)-1)
+        {
+        printf("The size of the decoded message is wrong.\n");
+        return 1;
+        }
+     if (memcmp(msg, new_msg, sizeof(msg)-1) != 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/xml-uint32.c 1.1 -> 1.2



ossp-pkg/xds/regression-tests/xml-uint64.c -> 1.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,115 ----
+ /*
+    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 <rpc/types.h>
+ #include <rpc/xdr.h>
+ #include "../internal.h"
+ 
+ int main()
+     {
+     xds_t* xds;
+     char*  buffer;
+     size_t buffer_size;
+ 
+     xds_uint64_t values[] =
+        {
+        0x0000000000000000ULL,
+        0x123456789abcdef0ULL,
+        0xabcdef01cc45bb9aULL,
+        0xc500b3efdd34ca9eULL,
+        0xffffffffffffffffULL
+        };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the
+        numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xml_encode_uint64, NULL) != XDS_OK)
+        {
+        printf("Failed to register my encoding engines.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_uint64_t); ++i)
+        {
+        if (xds_encode(xds, "int", values[i]) != XDS_OK)
+            {
+            printf("xds_encode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        }
+     if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK)
+        {
+        printf("getbuffer() failed.\n");
+        return 1;
+        }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL)
+        {
+        printf("Failed to initialize XDS context.\n");
+        return 1;
+        }
+     if (xds_register(xds, "int", &xml_decode_uint64, 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("setbuffer() failed.\n");
+        return 1;
+        }
+     for (i = 0; i < sizeof(values)/sizeof(xds_uint64_t); ++i)
+        {
+        xds_uint64_t val;
+        if (xds_decode(xds, "int", &val) != XDS_OK)
+            {
+            printf("xds_decode(values[%d]) failed!\n", i);
+            return 1;
+            }
+        if (val != values[i])
+            {
+            printf("Decoded value does not match the original!\n");
+            return 1;
+            }
+        }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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_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 -> 1.8



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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,72 ----
+ /*
+    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_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((int)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.7

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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((int)*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.15

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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((int)*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.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.h"
+ 
+ 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.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,64 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_int32_t*);
+     xds_check_parameter(value != NULL);
+ 
+     if (((xds_uint8_t*)buffer)[0] & 0x80)
+        {                       /* negative number */
+        tmp  = ((xds_uint8_t*)buffer)[0]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[1]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[2]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[3];
+        tmp = 0 - tmp;
+        *value = 0 - (int32_t)tmp;
+        }
+     else
+        {                       /* positive number */
+        *value  = ((xds_uint8_t*)buffer)[0]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[1]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[2]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[3];
+        }
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-decode-int64.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,72 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_int64_t*);
+     xds_check_parameter(value != NULL);
+ 
+     if (((xds_uint8_t*)buffer)[0] & 0x80)
+        {                       /* negative number */
+        tmp  = ((xds_uint8_t*)buffer)[0]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[1]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[2]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[3]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[4]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[5]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[6]; tmp = tmp << 8;
+        tmp += ((xds_uint8_t*)buffer)[7];
+        tmp = 0 - tmp;
+        *value = 0 - (xds_int64_t)tmp;
+        }
+     else
+        {                       /* positive number */
+        *value  = ((xds_uint8_t*)buffer)[0]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[1]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[2]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[3]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[4]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[5]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[6]; *value = *value << 8;
+        *value += ((xds_uint8_t*)buffer)[7];
+        }
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-decode-octetstream.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,76 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     p     = va_arg(*args, void**);
+     p_len = va_arg(*args, size_t*);
+     xds_check_parameter(p != NULL);
+     xds_check_parameter(p_len != NULL);
+ 
+     /* Read the size of the message. */
+ 
+     *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. */
+ 
+     padding = (4 - (*p_len & 0x03)) & 0x03;
+ 
+     /* Do we have enough data?. */
+ 
+     *used_buffer_size = 4 + *p_len + padding;
+     if (buffer_size < *used_buffer_size)
+        return XDS_ERR_UNDERFLOW;
+ 
+     /* Allocate buffer for the data. */
+ 
+     *p = malloc(*p_len);
+     if (*p == NULL)
+        return XDS_ERR_NO_MEM;
+ 
+     /* Copy data into the buffer. */
+ 
+     memmove(*p, (xds_uint8_t*)buffer+4, *p_len);
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-decode-string.c -> 1.8

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,75 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     p     = va_arg(*args, char**);
+     xds_check_parameter(p != NULL);
+ 
+     /* Read the size of the message. */
+ 
+     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. */
+ 
+     padding = (4 - (p_len & 0x03)) & 0x03;
+ 
+     /* Do we have enough data?. */
+ 
+     *used_buffer_size = 4 + p_len + padding;
+     if (buffer_size < *used_buffer_size)
+        return XDS_ERR_UNDERFLOW;
+ 
+     /* Allocate buffer for the data. */
+ 
+     *p = (char*)malloc(p_len + 1);
+     if (*p == NULL)
+        return XDS_ERR_NO_MEM;
+ 
+     /* Copy data into the buffer. */
+ 
+     memmove(*p, (xds_uint8_t*)buffer+4, p_len);
+     ((xds_uint8_t*)buffer)[4+p_len] = '\0';
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-decode-uint32.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,51 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_uint32_t*);
+     xds_check_parameter(value != NULL);
+ 
+     *value  = ((xds_uint8_t*)buffer)[0]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[1]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[2]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[3];
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-decode-uint64.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,55 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_decoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_uint64_t*);
+     xds_check_parameter(value != NULL);
+ 
+     *value  = ((xds_uint8_t*)buffer)[0]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[1]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[2]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[3]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[4]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[5]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[6]; *value = *value << 8;
+     *value += ((xds_uint8_t*)buffer)[7];
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.h"
+ 
+ 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.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,57 ----
+ /*
+    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 "xds.h"
+ 
+ int xdr_encode_int32(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     xds_uint32_t tmp;
+     xds_int32_t value;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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;
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-encode-int64.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.h"
+ 
+ int xdr_encode_int64(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     xds_uint64_t tmp;
+     xds_int64_t  value;
+ 
+     xds_init_encoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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;
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


ossp-pkg/xds/xdr-encode-octetstream.c -> 1.7

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,69 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value from stack and calculate the correct amount of
+        padding. */
+ 
+     p       = (xds_uint8_t*)va_arg(*args, void*);
+     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. */
+ 
+     ((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 XDS_OK;
+     }


ossp-pkg/xds/xdr-encode-string.c -> 1.8

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,69 ----
+ /*
+    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 "xds.h"
+ 
+ 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;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value from stack and calculate the correct amount of
+        padding. */
+ 
+     p       = va_arg(*args, char*);
+     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. */
+ 
+     ((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 XDS_OK;
+     }


ossp-pkg/xds/xdr-encode-uint32.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,49 ----
+ /*
+    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 "xds.h"
+ 
+ int xdr_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;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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 XDS_OK;
+     }


ossp-pkg/xds/xdr-encode-uint64.c -> 1.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,53 ----
+ /*
+    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 "xds.h"
+ 
+ int xdr_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;
+ 
+     xds_init_encoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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 XDS_OK;
+     }


ossp-pkg/xds/xds.c -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,500 ----
+ /* 
+  * 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 <errno.h>
+ 
+ #include "xds_p.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;
+ 
+     return ctx;
+ }
+ 
+ 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);
+     return;
+ }
+ 
+ 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;
+ }
+ 
+ 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;
+ }
+ 
+ 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. */
+     size = (*array_capacity != 0) ? *array_capacity * 2 : initial_capacity; 
+     while (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;
+ }
+ 
+ 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;
+ }
+ 
+ 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((int)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;
+ }
+ 
+ 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((int)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;
+ }
+ 
+ int xds_encode(xds_t *xds, const char *fmt, ...)
+ {
+     int rc;
+     va_list args;
+     va_start(args, fmt);
+     rc = xds_vencode(xds, fmt, args);
+     va_end(args);
+     return rc;
+ }
+ 
+ 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((int)*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;
+ }
+ 
+ int xds_decode(xds_t *xds, const char *fmt, ...)
+ {
+     int rc;
+     va_list args;
+     va_start(args, fmt);
+     rc = xds_vdecode(xds, fmt, args);
+     va_end(args);
+     return rc;
+ }
+ 
+ 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((int)*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/xds.pod 1.6 -> 1.7



ossp-pkg/xds/xds_engine_xdr.c -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,483 ----
+ /* 
+  * 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 "xds.h"
+ 
+ int xdr_encode_int32(xds_t * xds, void *engine_context,
+                      void *buffer, size_t buffer_size,
+                      size_t * used_buffer_size, va_list * args)
+ {
+     xds_uint32_t tmp;
+     xds_int32_t value;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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;
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_int32_t *);
+     xds_check_parameter(value != NULL);
+ 
+     if (((xds_uint8_t *) buffer)[0] & 0x80) {   /* negative number */
+         tmp = ((xds_uint8_t *) buffer)[0];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[1];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[2];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[3];
+         tmp = 0 - tmp;
+         *value = 0 - (int32_t) tmp;
+     }
+     else {                             /* positive number */
+         *value = ((xds_uint8_t *) buffer)[0];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[1];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[2];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[3];
+     }
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ int xdr_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;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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 XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_uint32_t *);
+     xds_check_parameter(value != NULL);
+ 
+     *value = ((xds_uint8_t *) buffer)[0];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[1];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[2];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[3];
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ #ifdef XDS_HAVE_64_BIT_SUPPORT
+ 
+ int xdr_encode_int64(xds_t * xds, void *engine_context,
+                      void *buffer, size_t buffer_size,
+                      size_t * used_buffer_size, va_list * args)
+ {
+     xds_uint64_t tmp;
+     xds_int64_t value;
+ 
+     xds_init_encoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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;
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_decoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_int64_t *);
+     xds_check_parameter(value != NULL);
+ 
+     if (((xds_uint8_t *) buffer)[0] & 0x80) {   /* negative number */
+         tmp = ((xds_uint8_t *) buffer)[0];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[1];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[2];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[3];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[4];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[5];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[6];
+         tmp = tmp << 8;
+         tmp += ((xds_uint8_t *) buffer)[7];
+         tmp = 0 - tmp;
+         *value = 0 - (xds_int64_t) tmp;
+     }
+     else {                             /* positive number */
+         *value = ((xds_uint8_t *) buffer)[0];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[1];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[2];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[3];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[4];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[5];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[6];
+         *value = *value << 8;
+         *value += ((xds_uint8_t *) buffer)[7];
+     }
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ int xdr_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;
+ 
+     xds_init_encoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     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 XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_decoding_engine(8);
+ 
+     /* Get value and format it into the buffer. */
+ 
+     value = va_arg(*args, xds_uint64_t *);
+     xds_check_parameter(value != NULL);
+ 
+     *value = ((xds_uint8_t *) buffer)[0];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[1];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[2];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[3];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[4];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[5];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[6];
+     *value = *value << 8;
+     *value += ((xds_uint8_t *) buffer)[7];
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ #endif /* XDS_HAVE_64_BIT_SUPPORT */
+ 
+ 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;
+ }
+ 
+ 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;
+ }
+ 
+ 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;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value from stack and calculate the correct amount of padding. */
+ 
+     p = va_arg(*args, char *);
+     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. */
+ 
+     ((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 XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     p = va_arg(*args, char **);
+     xds_check_parameter(p != NULL);
+ 
+     /* Read the size of the message. */
+ 
+     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. */
+ 
+     padding = (4 - (p_len & 0x03)) & 0x03;
+ 
+     /* Do we have enough data?. */
+ 
+     *used_buffer_size = 4 + p_len + padding;
+     if (buffer_size < *used_buffer_size)
+         return XDS_ERR_UNDERFLOW;
+ 
+     /* Allocate buffer for the data. */
+ 
+     *p = (char *)malloc(p_len + 1);
+     if (*p == NULL)
+         return XDS_ERR_NO_MEM;
+ 
+     /* Copy data into the buffer. */
+ 
+     memmove(*p, (xds_uint8_t *) buffer + 4, p_len);
+     ((xds_uint8_t *) buffer)[4 + p_len] = '\0';
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_encoding_engine(4);
+ 
+     /* Get value from stack and calculate the correct amount of padding. */
+ 
+     p = (xds_uint8_t *) va_arg(*args, void *);
+     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. */
+ 
+     ((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 XDS_OK;
+ }
+ 
+ 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;
+ 
+     xds_init_decoding_engine(4);
+ 
+     p = va_arg(*args, void **);
+     p_len = va_arg(*args, size_t *);
+     xds_check_parameter(p != NULL);
+     xds_check_parameter(p_len != NULL);
+ 
+     /* Read the size of the message. */
+ 
+     *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. */
+ 
+     padding = (4 - (*p_len & 0x03)) & 0x03;
+ 
+     /* Do we have enough data?. */
+ 
+     *used_buffer_size = 4 + *p_len + padding;
+     if (buffer_size < *used_buffer_size)
+         return XDS_ERR_UNDERFLOW;
+ 
+     /* Allocate buffer for the data. */
+ 
+     *p = malloc(*p_len);
+     if (*p == NULL)
+         return XDS_ERR_NO_MEM;
+ 
+     /* Copy data into the buffer. */
+ 
+     memmove(*p, (xds_uint8_t *) buffer + 4, *p_len);
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }


ossp-pkg/xds/xds_engine_xml.c -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,1049 ----
+ /* 
+  * 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 <stdio.h>
+ #include "xds.h"
+ 
+ const char xds_xml_begin_text[] =
+     "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\">\n"
+     "<!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,
+                      size_t * used_buffer_size, va_list * args)
+ {
+     xds_init_encoding_engine(strlen(xds_xml_begin_text));
+     memmove(buffer, xds_xml_begin_text, strlen(xds_xml_begin_text));
+     return XDS_OK;
+ }
+ 
+ int xml_decode_begin(xds_t * xds, void *engine_context,
+                      void *buffer, size_t buffer_size,
+                      size_t * used_buffer_size, va_list * args)
+ {
+     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 XDS_OK;
+ }
+ 
+ const char xds_xml_end_text[] = "</xds>\n";
+ 
+ int xml_encode_end(xds_t * xds, void *engine_context,
+                    void *buffer, size_t buffer_size,
+                    size_t * used_buffer_size, va_list * args)
+ {
+     xds_init_encoding_engine(strlen(xds_xml_end_text));
+     memmove(buffer, xds_xml_end_text, strlen(xds_xml_end_text));
+     return XDS_OK;
+ }
+ 
+ int xml_decode_end(xds_t * xds, void *engine_context,
+                    void *buffer, size_t buffer_size,
+                    size_t * used_buffer_size, va_list * args)
+ {
+     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 XDS_OK;
+ }
+ 
+ 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;
+ }
+ 
+ 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((int)*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;
+ }
+ 
+ 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;
+ }
+ 
+ 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((int)*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;
+ }
+ 
+ #ifdef XDS_HAVE_64_BIT_SUPPORT
+ 
+ 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;
+ }
+ 
+ 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((int)*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;
+ }
+ 
+ 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;
+ }
+ 
+ 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((int)*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;
+ }
+ 
+ #endif /* XDS_HAVE_64_BIT_SUPPORT */
+ 
+ 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;
+ }
+ 
+ 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;
+ }
+ 
+ #define bits(c) (0x80 | ((c) & 0x3F))
+ #define put(c)  *strptr++ = (c);
+ #define putbits(c)  put(bits(c))
+ #define finish()    *strptr = '\0'
+ 
+ static char *sputu8(xds_uint32_t c, char *strptr)
+ {
+     if (strptr == NULL)
+         return NULL;
+ 
+     if (c < 0x80) {
+         put(c);
+         finish();
+     }
+     else if (c < 0x800) {
+         put(0xC0 | (c >> 6));
+         putbits(c);
+         finish();
+     }
+     else if (c < 0x10000) {
+         put(0xE0 | (c >> 12));
+         putbits(c >> 6);
+         putbits(c);
+         finish();
+     }
+     else if (c < 0x200000) {
+         put(0xF0 | (c >> 18));
+         putbits(c >> 12);
+         putbits(c >> 6);
+         putbits(c);
+         finish();
+     }
+     else if (c < 0x400000) {
+         put(0xF8 | (c >> 24));
+         putbits(c >> 18);
+         putbits(c >> 12);
+         putbits(c >> 6);
+         putbits(c);
+         finish();
+     }
+     else if (c < 0x80000000) {
+         put(0xFC | (c >> 30));
+         putbits(c >> 24);
+         putbits(c >> 18);
+         putbits(c >> 12);
+         putbits(c >> 6);
+         putbits(c);
+         finish();
+     }
+     else
+         finish();                      /* Not a valid Unicode "character" */
+ 
+     return strptr;
+ }
+ 
+ static const char TAG_OPEN[] = "<string>";
+ static const char TAG_CLOSE[] = "</string>";
+ static const size_t TAG_OPEN_LEN = sizeof (TAG_OPEN) - 1;
+ static const size_t TAG_CLOSE_LEN = sizeof (TAG_CLOSE) - 1;
+ 
+ int xml_encode_string(xds_t * xds, void *engine_context,
+                       void *buffer, size_t buffer_size,
+                       size_t * used_buffer_size, va_list * args)
+ {
+     char *src;
+     size_t src_len;
+     char *dst;
+     size_t dst_size;
+     char *tmp;
+ 
+     /* Setup the engine. We need at least space for our tags; how long the
+      * actual content is going to be will be seen soon. */
+ 
+     xds_init_encoding_engine(TAG_OPEN_LEN + TAG_CLOSE_LEN);
+ 
+     /* Get the data from the stack. */
+ 
+     src = va_arg(*args, char *);
+     xds_check_parameter(src != NULL);
+     src_len = strlen(src);
+ 
+     /* Set up the target buffer. */
+ 
+     dst = buffer;
+     dst_size = buffer_size;
+ 
+     /* Write the opening tag. */
+ 
+     memmove(dst, TAG_OPEN, TAG_OPEN_LEN);
+     dst += TAG_OPEN_LEN;
+     dst_size -= TAG_OPEN_LEN;
+ 
+     /* Format the data into the buffer. */
+ 
+     while (src_len > 0 && dst_size > 0) {
+         if (*((xds_uint8_t *) src) >= 0x80) {   /* UTF-8ify it. */
+             if (dst_size >= 7) {
+                 tmp = sputu8((xds_uint32_t) * ((xds_uint8_t *) src), dst);
+                 ++src;
+                 --src_len;
+                 dst_size -= tmp - dst;
+                 dst = tmp;
+             }
+             else
+                 dst_size = 0;
+         }
+         else if (*src == '<') {        /* Turn into "&lt;". */
+             if (dst_size >= 4) {
+                 *dst++ = '&';
+                 --dst_size;
+                 *dst++ = 'l';
+                 --dst_size;
+                 *dst++ = 't';
+                 --dst_size;
+                 *dst++ = ';';
+                 --dst_size;
+                 ++src;
+                 --src_len;
+             }
+             else
+                 dst_size = 0;
+         }
+         else if (*src == '&') {        /* Turn into "&amp;". */
+             if (dst_size >= 5) {
+                 *dst++ = '&';
+                 --dst_size;
+                 *dst++ = 'a';
+                 --dst_size;
+                 *dst++ = 'm';
+                 --dst_size;
+                 *dst++ = 'p';
+                 --dst_size;
+                 *dst++ = ';';
+                 --dst_size;
+                 ++src;
+                 --src_len;
+             }
+             else
+                 dst_size = 0;
+         }
+         else if (*src == '>') {        /* Turn into "&gt;". */
+             if (dst_size >= 4) {
+                 *dst++ = '&';
+                 --dst_size;
+                 *dst++ = 'g';
+                 --dst_size;
+                 *dst++ = 't';
+                 --dst_size;
+                 *dst++ = ';';
+                 --dst_size;
+                 ++src;
+                 --src_len;
+             }
+             else
+                 dst_size = 0;
+         }
+         else {                         /* No special character; just copy it. 
+                                         */
+             *dst++ = *src++;
+             --src_len;
+             --dst_size;
+         }
+     }
+     if (src_len > 0) {                 /* Target buffer was too small. */
+         *used_buffer_size = buffer_size + 1;
+         return XDS_ERR_OVERFLOW;
+     }
+ 
+     /* Write the closing tag. */
+ 
+     memmove(dst, TAG_CLOSE, TAG_CLOSE_LEN);
+     dst += TAG_CLOSE_LEN;
+     dst_size -= TAG_CLOSE_LEN;
+ 
+     /* Done. */
+ 
+     *used_buffer_size = dst - (char *)buffer;
+     return XDS_OK;
+ }
+ 
+ #define INVALID 0x80000000
+ 
+ #define get(c)  c = *strptr++; \
+     if (chars) (*chars)++; \
+     if ((c) == 0) return (unsigned int)EOF
+ 
+ static unsigned int sgetu8(unsigned char *strptr, int *chars)
+ {
+     unsigned int c;
+     int i, iterations;
+     unsigned char ch;
+ 
+     if (chars)
+         *chars = 0;
+ 
+     if (strptr == NULL)
+         return (unsigned int)EOF;
+ 
+     get(c);
+ 
+     if ((c & 0xFE) == 0xFC) {
+         c &= 0x01;
+         iterations = 5;
+     }
+     else if ((c & 0xFC) == 0xF8) {
+         c &= 0x03;
+         iterations = 4;
+     }
+     else if ((c & 0xF8) == 0xF0) {
+         c &= 0x07;
+         iterations = 3;
+     }
+     else if ((c & 0xF0) == 0xE0) {
+         c &= 0x0F;
+         iterations = 2;
+     }
+     else if ((c & 0xE0) == 0xC0) {
+         c &= 0x1F;
+         iterations = 1;
+     }
+     else if ((c & 0x80) == 0x80)
+         return INVALID;
+     else
+         return c;
+ 
+     for (i = 0; i < iterations; i++) {
+         get(ch);
+         if ((ch & 0xC0) != 0x80)
+             return INVALID;
+         c <<= 6;
+         c |= ch & 0x3F;
+     }
+ 
+     return c;
+ }
+ 
+ int xml_decode_string(xds_t * xds, void *engine_context,
+                       void *buffer, size_t buffer_size,
+                       size_t * used_buffer_size, va_list * args)
+ {
+     char **target_buffer;
+     char *src;
+     size_t src_len;
+     char *dst;
+     int utf8_len;
+     unsigned int rc;
+ 
+     /* Setup the engine. We need at least space for our tags; how long the
+      * actual content is going to be will be seen soon. */
+ 
+     xds_init_encoding_engine(TAG_OPEN_LEN + TAG_CLOSE_LEN);
+ 
+     /* Is the opening tag there? */
+ 
+     if (strncasecmp(buffer, TAG_OPEN, TAG_OPEN_LEN) != 0)
+         return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Determine the length of the encoded data. */
+ 
+     src = (char *)buffer + TAG_OPEN_LEN;
+     for (src_len = 0; src[src_len] != '<'; ++src_len)
+         if (src[src_len] == '\0')
+             return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Check the closing tag. */
+ 
+     if (strncasecmp(src + src_len, TAG_CLOSE, TAG_CLOSE_LEN) != 0)
+         return XDS_ERR_TYPE_MISMATCH;
+     *used_buffer_size = TAG_OPEN_LEN + src_len + TAG_CLOSE_LEN;
+ 
+     /* Allocate target buffer. */
+ 
+     target_buffer = va_arg(*args, char **);
+     xds_check_parameter(target_buffer != NULL);
+     *target_buffer = dst = malloc(src_len + 1);
+     if (dst == NULL)
+         return XDS_ERR_NO_MEM;
+ 
+     /* Decode the data into the target buffer. */
+ 
+     while (src_len > 0) {
+         if (*src == '&') {
+             if (src_len >= 4 && strncmp(src, "&lt;", 4) == 0) {
+                 *dst++ = '<';
+                 src += 4;
+                 src_len -= 4;
+             }
+             else if (src_len >= 4 && strncmp(src, "&gt;", 4) == 0) {
+                 *dst++ = '>';
+                 src += 4;
+                 src_len -= 4;
+             }
+             else if (src_len >= 5 && strncmp(src, "&amp;", 5) == 0) {
+                 *dst++ = '&';
+                 src += 5;
+                 src_len -= 5;
+             }
+             else {
+                 free(dst);
+                 return XDS_ERR_TYPE_MISMATCH;
+             }
+         }
+         else if (*((xds_uint8_t *) src) >= 0x80) {
+             rc = sgetu8((xds_uint8_t *) src, &utf8_len);
+             if (rc == (unsigned int)EOF)
+                 return XDS_ERR_UNDERFLOW;
+             else if (rc == INVALID || rc > 255)
+                 return XDS_ERR_TYPE_MISMATCH;
+             *dst++ = (xds_uint8_t) rc;
+             src += utf8_len;
+             src_len -= utf8_len;
+         }
+         else {
+             *dst++ = *src++;
+             --src_len;
+         }
+     }
+     *dst = '\0';
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ const char xds_base64[] =
+     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const char xds_pad64 = '=';
+ 
+ static int base64_encode(char *dst, size_t dstlen, unsigned char const *src,
+                          size_t srclen)
+ {
+     size_t dstpos;
+     unsigned char input[3];
+     unsigned char output[4];
+     int ocnt;
+     size_t i;
+ 
+     if (srclen == 0)
+         return 0;
+     if (dst == NULL) {
+         /* just calculate required length of dst */
+         dstlen = (((srclen + 2) / 3) * 4);
+         return dstlen;
+     }
+ 
+     /* bulk encoding */
+     dstpos = 0;
+     ocnt = 0;
+     while (srclen >= 3) {
+         input[0] = *src++;
+         input[1] = *src++;
+         input[2] = *src++;
+         srclen -= 3;
+ 
+         output[0] = (input[0] >> 2);
+         output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+         output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+         output[3] = (input[2] & 0x3f);
+ 
+         if (dstpos + 4 > dstlen)
+             return -1;
+         dst[dstpos++] = xds_base64[output[0]];
+         dst[dstpos++] = xds_base64[output[1]];
+         dst[dstpos++] = xds_base64[output[2]];
+         dst[dstpos++] = xds_base64[output[3]];
+     }
+ 
+     /* now worry about padding with remaining 1 or 2 bytes */
+     if (srclen != 0) {
+         input[0] = input[1] = input[2] = '\0';
+         for (i = 0; i < srclen; i++)
+             input[i] = *src++;
+ 
+         output[0] = (input[0] >> 2);
+         output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+         output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ 
+         if (dstpos + 4 > dstlen)
+             return -1;
+         dst[dstpos++] = xds_base64[output[0]];
+         dst[dstpos++] = xds_base64[output[1]];
+         if (srclen == 1)
+             dst[dstpos++] = xds_pad64;
+         else
+             dst[dstpos++] = xds_base64[output[2]];
+         dst[dstpos++] = xds_pad64;
+     }
+ 
+     if (dstpos >= dstlen)
+         return -1;
+     dst[dstpos] = '\0';
+ 
+     return dstpos;
+ }
+ 
+ int xml_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 *src;
+     size_t src_len;
+ 
+     /* We need at least 27 byte for the starting and ending tag. */
+ 
+     xds_init_encoding_engine(13 + 14);
+ 
+     /* Get parameters from stack. */
+ 
+     src = (xds_uint8_t *) va_arg(*args, void *);
+     xds_check_parameter(src != NULL);
+     src_len = va_arg(*args, size_t);
+ 
+     /* Calculate how many bytes we'll need in buffer and make sure we have
+      * them. */
+ 
+     *used_buffer_size = base64_encode(NULL, 0, src, src_len);
+     if (*used_buffer_size == (size_t) - 1)
+         return XDS_ERR_UNKNOWN;
+     else
+         *used_buffer_size += 13 + 14;
+     if (buffer_size < *used_buffer_size)
+         return XDS_ERR_OVERFLOW;
+ 
+     /* Format the data into the buffer. */
+ 
+     memmove(buffer, "<octetstream>", 13);
+     if (base64_encode((char *)buffer + 13, buffer_size - 13, src, src_len) <
+         0)
+         return XDS_ERR_UNKNOWN;
+     memmove((char *)buffer + *used_buffer_size - 14, "</octetstream>", 14);
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+ }
+ 
+ static int base64_decode(unsigned char *dst, size_t dstlen, char const *src,
+                          size_t srclen)
+ {
+     int dstidx, state, ch = 0;
+     unsigned char res;
+     char *pos;
+ 
+     if (srclen == 0)
+         return 0;
+     state = 0;
+     dstidx = 0;
+     res = 0;
+     while (srclen-- > 0) {
+         ch = *src++;
+         if (isascii(ch) && isspace(ch)) /* Skip whitespace anywhere */
+             continue;
+         if (ch == xds_pad64)
+             break;
+         pos = strchr(xds_base64, ch);
+         if (pos == 0)                  /* A non-base64 character */
+             return -1;
+         switch (state) {
+             case 0:
+                 if (dst != NULL) {
+                     if ((size_t) dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] = ((pos - xds_base64) << 2);
+                 }
+                 state = 1;
+                 break;
+             case 1:
+                 if (dst != NULL) {
+                     if ((size_t) dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] |= ((pos - xds_base64) >> 4);
+                     res = (((pos - xds_base64) & 0x0f) << 4);
+                 }
+                 dstidx++;
+                 state = 2;
+                 break;
+             case 2:
+                 if (dst != NULL) {
+                     if ((size_t) dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] = res | ((pos - xds_base64) >> 2);
+                     res = ((pos - xds_base64) & 0x03) << 6;
+                 }
+                 dstidx++;
+                 state = 3;
+                 break;
+             case 3:
+                 if (dst != NULL) {
+                     if ((size_t) dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] = res | (pos - xds_base64);
+                 }
+                 dstidx++;
+                 state = 0;
+                 break;
+             default:
+                 break;
+         }
+     }
+ 
+     /* 
+      * We are done decoding Base-64 chars.  Let's see if we ended
+      * on a byte boundary, and/or with erroneous trailing characters.
+      */
+ 
+     if (ch == xds_pad64) {             /* We got a pad char. */
+         switch (state) {
+             case 0:                /* Invalid = in first position */
+             case 1:                /* Invalid = in second position */
+                 return -1;
+             case 2:                /* Valid, means one byte of info */
+                 /* Skip any number of spaces. */
+                 while (srclen > 0) {
+                     ch = *src++;
+                     --srclen;
+                     if (!(isascii(ch) && isspace(ch)))
+                         break;
+                 }
+                 /* Make sure there is another trailing = sign. */
+                 if (ch != xds_pad64)
+                     return -1;
+                 /* FALLTHROUGH */
+             case 3:                /* Valid, means two bytes of info */
+                 /* 
+                  * We know this char is an =.  Is there anything but
+                  * whitespace after it?
+                  */
+                 while (srclen > 0) {
+                     ch = *src++;
+                     --srclen;
+                     if (!(isascii(ch) && isspace(ch)))
+                         return -1;
+                 }
+                 /* 
+                  * Now make sure for cases 2 and 3 that the "extra"
+                  * bits that slopped past the last full byte were
+                  * zeros.  If we don't check them, they become a
+                  * subliminal channel.
+                  */
+                 if (dst != NULL && res != 0)
+                     return -1;
+             default:
+                 break;
+         }
+     }
+     else {
+         /* 
+          * We ended by seeing the end of the string.  Make sure we
+          * have no partial bytes lying around.
+          */
+         if (state != 0)
+             return -1;
+     }
+ 
+     return dstidx;
+ }
+ 
+ int xml_decode_octetstream(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;
+     xds_uint8_t **data;
+     size_t *data_len;
+ 
+     /* We need at least 27 byte for the starting and ending tag. */
+ 
+     xds_init_encoding_engine(13 + 14);
+ 
+     /* Get parameters from stack. */
+ 
+     data = va_arg(*args, xds_uint8_t **);
+     xds_check_parameter(data != NULL);
+     data_len = va_arg(*args, size_t *);
+ 
+     /* Check for the opening tag. */
+ 
+     if (memcmp("<octetstream>", buffer, 13) != 0)
+         return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Find the end of the data and calculate the length of the
+      * base64-encoded stuff. */
+ 
+     p = (char *)buffer + 13;
+     while (p < ((char *)buffer + buffer_size) && *p != '<')
+         ++p;
+     if (p == ((char *)buffer + buffer_size))
+         return XDS_ERR_TYPE_MISMATCH;
+     else {
+         p_len = p - ((char *)buffer + 13);
+         p = (char *)buffer + 13;
+     }
+ 
+     /* Now find out how long the decoded data is going to be, allocate a
+      * buffer for it, and decode away. */
+ 
+     *data_len = base64_decode(NULL, 0, p, p_len);
+     if (*data_len == (size_t) - 1)
+         return XDS_ERR_UNKNOWN;
+     *data = malloc(*data_len);
+     if (*data == NULL)
+         return XDS_ERR_NO_MEM;
+     base64_decode(*data, *data_len, p, p_len);
+ 
+     /* Check that we have a closing tag. */
+ 
+     if (memcmp(p + p_len, "</octetstream>", 14) != 0) {
+         free(*data);
+         return XDS_ERR_TYPE_MISMATCH;
+     }
+ 
+     /* Done. */
+ 
+     *used_buffer_size = 13 + p_len + 14;
+     return XDS_OK;
+ }


ossp-pkg/xds/xds_p.h -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,60 ----
+ /* 
+  * 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.
+  * 
+  * internal.h: internal C API */
+ 
+ #ifndef __INTERNAL_H__
+ #define __INTERNAL_H__
+ 
+ #include "xds.h"
+ 
+ #define XDS_INITIAL_BUFFER_CAPACITY  512
+ #define XDS_INITIAL_ENGINES_CAPACITY  32
+ 
+ typedef struct {
+     char *name;
+     xds_engine_t engine;
+     void *context;
+ } engine_map_t;
+ 
+ struct xds_context {
+     xds_mode_t mode;
+ 
+     char *buffer;
+     size_t buffer_len;
+     size_t buffer_capacity;
+     int we_own_buffer;
+ 
+     engine_map_t *engines;
+     size_t engines_len;
+     size_t engines_capacity;
+ };
+ 
+ int xds_find_engine(const engine_map_t * engines, size_t last,
+                     const char *name, size_t * pos);
+ int xds_set_capacity(void **array, size_t * array_capacity,
+                      size_t new_capacity, size_t elem_size,
+                      size_t initial_capacity);
+ 
+ #endif /* !defined(__INTERNAL_H__) */


ossp-pkg/xds/xds_test.sh -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,42 ----
+ #!/bin/sh
+ 
+ if [ $# -lt 1 ]; then
+     echo "Usage: $0 test1.t [...]"
+     exit 1
+ fi
+ 
+ RESCOLUMN=30
+ numTests=0
+ numFails=0
+ 
+ echo "Running test suite:"
+ 
+ pad=''
+ n=$RESCOLUMN
+ while [ $n -gt 0 ]; do
+     pad="$pad."
+     n=`expr $n - 1`
+ done
+ for suite in "$@"; do
+     name=`expr "${suite}" : '\./\.\(.*\)\.t$'`
+     echo "$name$pad" | awk '{ printf("%s ", substr($0, 0, n)); }' n=$RESCOLUMN
+     numTests=`expr $numTests + 1`
+     eval ./$suite >.${name}.l 2>&1
+     if [ $? -eq 0 ]; then
+         echo "OK"
+     else
+         numFails=`expr $numFails + 1`
+         echo "FAILED"
+     fi
+ done
+ 
+ echo
+ if [ $numFails -eq 0 ]; then
+     echo "Summary: All tests succeeded."
+     exit 0
+ else
+     percent=`expr $numFails \* 100`
+     percent=`expr $percent / $numTests`
+     echo "Summary: $numFails of $numTests tests failed ($percent%)."
+     exit 1
+ fi


ossp-pkg/xds/xds_test_lib.c -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,914 ----
+ /* 
+  * 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 <errno.h>
+ #include <stdio.h>
+ #include "xds_p.h"
+ 
+ #ifdef XDS_TEST_XDS_CORE
+ 
+ int main()
+ {
+     xds_t *ctx[50];
+     size_t i;
+ 
+     /* Open a bunch of contextes and close them again. */
+ 
+     for (i = 0; i < sizeof (ctx) / sizeof (xds_t *); ++i) {
+         if (i % 2 == 0)
+             ctx[i] = xds_init(XDS_ENCODE);
+         else
+             ctx[i] = xds_init(XDS_DECODE);
+ 
+         if (ctx[i] == 0) {
+             printf("Failed to initialize xds context: i = %d\n", i);
+             return 1;
+         }
+     }
+ 
+     for (i = 0; i < sizeof (ctx) / sizeof (xds_t *); ++i)
+         xds_destroy(ctx[i]);
+ 
+ #ifdef NDEBUG
+     /* Check how the library deals with errorneous arguments. */
+ 
+     if (xds_init((xds_mode_t) 42) != NULL || errno != EINVAL) {
+         printf
+             ("Called xds_init() with invalid mode but didn't get EINVAL.\n");
+         return 1;
+     }
+ 
+     /* Call xds_destroy() with an invalid context and see whether we survive
+      * that. */
+ 
+     xds_destroy(NULL);
+ #endif
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDS_CORE */
+ 
+ #ifdef XDS_TEST_XDS_FIND_ENGINE
+ 
+ int main()
+ {
+     const engine_map_t engines[] = {
+         {"alan", NULL, 0},
+         {"berta", NULL, 0},
+         {"caesar", NULL, 0},
+         {"doris", NULL, 0},
+         {"egon", NULL, 0},
+         {"franziska", NULL, 0},
+         {"gudrun", NULL, 0},
+         {"heinz", NULL, 0},
+         {"igor", NULL, 0},
+         {"jamila", NULL, 0},
+         {"karin", NULL, 0},
+         {"louis", NULL, 0},
+     };
+     size_t engines_len = sizeof (engines) / sizeof (engine_map_t);
+     size_t pos;
+     size_t i;
+ 
+     /* Does xds_find_engine handle an empty array? */
+ 
+     if (xds_find_engine(engines, 0, "whatever", &pos)) {
+         printf
+             ("xds_find_engine() said 'whatever' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != 0) {
+         printf
+             ("xds_find_engine() would insert 'whatever' at position %d, but 0 is correct.\n",
+              pos);
+         exit(1);
+     }
+ 
+     /* Search for every single entry in the array and check the results. */
+ 
+     for (i = 0; i < engines_len; ++i) {
+         if (!xds_find_engine(engines, engines_len, engines[i].name, &pos)) {
+             printf
+                 ("xds_find_engine() said '%s' wouldn't be in the array, but that's wrong.\n",
+                  engines[i].name);
+             exit(1);
+         }
+         if (pos != i) {
+             printf
+                 ("xds_find_engine() would insert '%s' at position %d, but %d is correct.\n",
+                  engines[i].name, pos, i);
+             exit(1);
+         }
+     }
+ 
+     /* Search for non-existing name that would be inserted at the first
+      * position. */
+ 
+     if (xds_find_engine(engines, engines_len, "aaron", &pos)) {
+         printf
+             ("xds_find_engine() said 'aaron' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != 0) {
+         printf
+             ("xds_find_engine() would insert 'aaron' at position %d, but 0 is correct.\n",
+              pos);
+         exit(1);
+     }
+ 
+     /* Search for non-existing name that would be inserted at last position. */
+ 
+     if (xds_find_engine(engines, engines_len, "zerberos", &pos)) {
+         printf
+             ("xds_find_engine() said 'zerberos' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != engines_len) {
+         printf
+             ("xds_find_engine() would insert 'zerberos' at position %d, but %d is correct.\n",
+              pos, engines_len);
+         exit(1);
+     }
+ 
+     /* Search for non-existing names that would be inserted at random
+      * positions. */
+ 
+     if (xds_find_engine(engines, engines_len, "balthasar", &pos)) {
+         printf
+             ("xds_find_engine() said 'balthasar' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != 1) {
+         printf
+             ("xds_find_engine() would insert 'balthasar' at position %d, but 1 is correct.\n",
+              pos);
+         exit(1);
+     }
+ 
+     if (xds_find_engine(engines, engines_len, "bulli", &pos)) {
+         printf
+             ("xds_find_engine() said 'bulli' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != 2) {
+         printf
+             ("xds_find_engine() would insert 'bulli' at position %d, but 2 is correct.\n",
+              pos);
+         exit(1);
+     }
+ 
+     if (xds_find_engine(engines, engines_len, "hildegard", &pos)) {
+         printf
+             ("xds_find_engine() said 'hildegard' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != 8) {
+         printf
+             ("xds_find_engine() would insert 'hildegard' at position %d, but 8 is correct.\n",
+              pos);
+         exit(1);
+     }
+ 
+     if (xds_find_engine(engines, engines_len, "harald", &pos)) {
+         printf
+             ("xds_find_engine() said 'harald' would be in the array, but that's wrong.\n");
+         exit(1);
+     }
+     if (pos != 7) {
+         printf
+             ("xds_find_engine() would insert 'harald' at position %d, but 7 is correct.\n",
+              pos);
+         exit(1);
+     }
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDS_FIND_ENGINE */
+ 
+ #ifdef XDS_TEST_XDS_REGISTER
+ 
+ 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;
+ }
+ 
+ #endif /* XDS_TEST_XDS_REGISTER */
+ 
+ #ifdef XDS_TEST_XDS_SETBUFFER
+ 
+ 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;
+ }
+ 
+ #endif /* XDS_TEST_XDS_SETBUFFER */
+ 
+ #ifdef XDS_TEST_XDS_GETBUFFER
+ 
+ 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;
+ }
+ 
+ #endif /* XDS_TEST_XDS_GETBUFFER */
+ 
+ #ifdef XDS_TEST_XDS_ENCODE
+ 
+ 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;
+ }
+ 
+ #endif /* XDS_TEST_XDS_ENCODE */
+ 
+ #ifdef XDS_TEST_XDS_DECODE
+ 
+ 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, sizeof (buffer) - 1) != 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;
+ }
+ 
+ #endif /* XDS_TEST_XDS_DECODE */
+ 
+ #ifdef XDS_TEST_XDS_ENGINE_RESTART
+ 
+ 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;
+ }
+ 
+ #endif /* XDS_TEST_XDS_ENGINE_RESTART */
+ 
+ #ifdef XDS_TEST_XDS_MYSTRUCT
+ 
+ struct mystruct {
+     xds_int32_t small;
+     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 uint32", ms->small, 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 uint32", &(ms->small), &(ms->positive));
+ }
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     struct mystruct ms, new_ms;
+     ms.small = -0x1234567;
+     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, "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, "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.positive != new_ms.positive) {
+         printf("Decoded data does not match the original!\n");
+         return 1;
+     }
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDS_MYSTRUCT */


ossp-pkg/xds/xds_test_xdr.c -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,759 ----
+ /* 
+  * 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 <sys/types.h>
+ #include <rpc/types.h>
+ #include <rpc/xdr.h>
+ 
+ #include "xds.h"
+ 
+ #ifdef XDS_TEST_XDR_INT32
+ 
+ int main()
+ {
+     XDR xdrs;
+     char xdr_buf[1024];
+     size_t xdr_buf_size;
+ 
+     xds_t *xds;
+     char *xds_buf;
+     size_t xds_buf_size;
+ 
+     xds_int32_t values[] = {
+         0x00000000,
+         0x12345678,
+         -0x12345678,
+         0x7bcdef01,
+         -0x7bcdef01,
+         0x7fffffff
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array using the RPC-XDR implementation. */
+ 
+     xdrmem_create(&xdrs, xdr_buf, sizeof (xdr_buf), XDR_ENCODE);
+     for (i = 0; i < sizeof (values) / sizeof (xds_int32_t); ++i)
+         xdr_int32_t(&xdrs, &values[i]);
+     xdr_buf_size = xdr_getpos(&xdrs);
+     xdr_destroy(&xdrs);
+ 
+     /* Encode the values array using the XDS implementation. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xdr_encode_int32, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int32_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&xds_buf, &xds_buf_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     /* Both buffers must be equal now. */
+ 
+     if (xdr_buf_size != xds_buf_size) {
+         printf("The buffer sizes don't match: %d != %d.\n", xdr_buf_size,
+                xds_buf_size);
+         return 1;
+     }
+     if (memcmp(xds_buf, xdr_buf, xds_buf_size) != 0) {
+         printf("The buffers' contents is not identical!\n");
+         return 1;
+     }
+ 
+     /* Now we decode the values again using the XDS implementation and
+      * compare them to our original values. Obviously, they should not
+      * differ. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xdr_decode_int32, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, xds_buf, xds_buf_size) != XDS_OK) {
+         printf("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int32_t); ++i) {
+         xds_int32_t tmp;
+         if (xds_decode(xds, "int", &tmp) != XDS_OK) {
+             printf("xds_encode() failed for the %d value!\n", i);
+             return 1;
+         }
+         if (values[i] != tmp) {
+             printf("The %dth value has not been decoded correctly!\n", i);
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDR_INT32 */
+ 
+ #ifdef XDS_TEST_XDR_UINT32
+ 
+ #ifdef __FreeBSD__
+ static int xdr_uint32_t(XDR * xdrs, uint32_t * val)
+ {
+     return xdr_u_int32_t(xdrs, val);
+ }
+ #endif
+ 
+ int main()
+ {
+     XDR xdrs;
+     char xdr_buf[1024];
+     size_t xdr_buf_size;
+ 
+     xds_t *xds;
+     char *xds_buf;
+     size_t xds_buf_size;
+ 
+     xds_uint32_t values[] = {
+         0x00000000,
+         0x12345678,
+         0xabcdef01,
+         0xc500b3ef,
+         0xffffffff
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array using the RPC-XDR implementation. */
+ 
+     xdrmem_create(&xdrs, xdr_buf, sizeof (xdr_buf), XDR_ENCODE);
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint32_t); ++i)
+         xdr_uint32_t(&xdrs, &values[i]);
+     xdr_buf_size = xdr_getpos(&xdrs);
+     xdr_destroy(&xdrs);
+ 
+     /* Encode the values array using the XDS implementation. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "uint", &xdr_encode_uint32, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (uint32_t); ++i) {
+         if (xds_encode(xds, "uint", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&xds_buf, &xds_buf_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     /* Both buffers must be equal now. */
+ 
+     if (xdr_buf_size != xds_buf_size) {
+         printf("The buffer sizes don't match: %d != %d.\n", xdr_buf_size,
+                xds_buf_size);
+         return 1;
+     }
+     if (memcmp(xds_buf, xdr_buf, xds_buf_size) != 0) {
+         printf("The buffers' contents is not identical!\n");
+         return 1;
+     }
+ 
+     /* Now we decode the values again using the XDS implementation and
+      * compare them to our original values. Obviously, they should not
+      * differ. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "uint", &xdr_decode_uint32, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, xds_buf, xds_buf_size) != XDS_OK) {
+         printf("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint32_t); ++i) {
+         xds_uint32_t tmp;
+         if (xds_decode(xds, "uint", &tmp) != XDS_OK) {
+             printf("xds_encode() failed for the %d value!\n", i);
+             return 1;
+         }
+         if (values[i] != tmp) {
+             printf("The %dth value has not been decoded correctly!\n", i);
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDR_UINT32 */
+ 
+ #ifdef XDS_TEST_XDR_INT64
+ 
+ #ifdef XDS_HAVE_64_BIT_SUPPORT
+ 
+ int main()
+ {
+     XDR xdrs;
+     char xdr_buf[1024];
+     size_t xdr_buf_size;
+ 
+     xds_t *xds;
+     char *xds_buf;
+     size_t xds_buf_size;
+ 
+     xds_int64_t values[] = {
+         0x0000000000000000LL,
+         0x123456789abcdef0LL,
+         -0x123456789abcdef0LL,
+         0x7bcdef01cc45bb9aLL,
+         -0x7bcdef01cc45bb9aLL,
+         0x7fffffffffffffffLL
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array using the RPC-XDR implementation. */
+ 
+     xdrmem_create(&xdrs, xdr_buf, sizeof (xdr_buf), XDR_ENCODE);
+     for (i = 0; i < sizeof (values) / sizeof (xds_int64_t); ++i)
+         xdr_int64_t(&xdrs, &values[i]);
+     xdr_buf_size = xdr_getpos(&xdrs);
+     xdr_destroy(&xdrs);
+ 
+     /* Encode the values array using the XDS implementation. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xdr_encode_int64, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int64_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&xds_buf, &xds_buf_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     /* Both buffers must be equal now. */
+ 
+     if (xdr_buf_size != xds_buf_size) {
+         printf("The buffer sizes don't match: %d != %d.\n", xdr_buf_size,
+                xds_buf_size);
+         return 1;
+     }
+     if (memcmp(xds_buf, xdr_buf, xds_buf_size) != 0) {
+         printf("The buffers' contents is not identical!\n");
+         return 1;
+     }
+ 
+     /* Now we decode the values again using the XDS implementation and
+      * compare them to our original values. Obviously, they should not
+      * differ. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xdr_decode_int64, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, xds_buf, xds_buf_size) != XDS_OK) {
+         printf("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int64_t); ++i) {
+         xds_int64_t tmp;
+         if (xds_decode(xds, "int", &tmp) != XDS_OK) {
+             printf("xds_encode() failed for the %d value!\n", i);
+             return 1;
+         }
+         if (values[i] != tmp) {
+             printf("The %dth value has not been decoded correctly!\n", i);
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_HAVE_64_BIT_SUPPORT */
+ 
+ #endif /* XDS_TEST_XDR_INT64 */
+ 
+ #ifdef XDS_TEST_XDR_UINT64
+ 
+ #ifdef XDS_HAVE_64_BIT_SUPPORT 
+ 
+ #ifdef __FreeBSD__
+ static int xdr_uint64_t(XDR * xdrs, uint64_t * val)
+ {
+     return xdr_u_int64_t(xdrs, val);
+ }
+ #endif
+ 
+ int main()
+ {
+     XDR xdrs;
+     char xdr_buf[1024];
+     size_t xdr_buf_size;
+ 
+     xds_t *xds;
+     char *xds_buf;
+     size_t xds_buf_size;
+ 
+     xds_uint64_t values[] = {
+         0x0000000000000000ULL,
+         0x123456789abcdef0ULL,
+         0xabcdef01cc45bb9aULL,
+         0xc500b3efdd34ca9eULL,
+         0xffffffffffffffffULL
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array using the RPC-XDR implementation. */
+ 
+     xdrmem_create(&xdrs, xdr_buf, sizeof (xdr_buf), XDR_ENCODE);
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint64_t); ++i)
+         xdr_uint64_t(&xdrs, &values[i]);
+     xdr_buf_size = xdr_getpos(&xdrs);
+     xdr_destroy(&xdrs);
+ 
+     /* Encode the values array using the XDS implementation. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "uint", &xdr_encode_uint64, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (uint64_t); ++i) {
+         if (xds_encode(xds, "uint", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&xds_buf, &xds_buf_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     /* Both buffers must be equal now. */
+ 
+     if (xdr_buf_size != xds_buf_size) {
+         printf("The buffer sizes don't match: %d != %d.\n", xdr_buf_size,
+                xds_buf_size);
+         return 1;
+     }
+     if (memcmp(xds_buf, xdr_buf, xds_buf_size) != 0) {
+         printf("The buffers' contents is not identical!\n");
+         return 1;
+     }
+ 
+     /* Now we decode the values again using the XDS implementation and
+      * compare them to our original values. Obviously, they should not
+      * differ. */
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "uint", &xdr_decode_uint64, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, xds_buf, xds_buf_size) != XDS_OK) {
+         printf("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint64_t); ++i) {
+         xds_uint64_t tmp;
+         if (xds_decode(xds, "uint", &tmp) != XDS_OK) {
+             printf("xds_encode() failed for the %d value!\n", i);
+             return 1;
+         }
+         if (values[i] != tmp) {
+             printf("The %dth value has not been decoded correctly!\n", i);
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_HAVE_64_BIT_SUPPORT */
+ 
+ #endif /* XDS_TEST_XDR_UINT64 */
+ 
+ #ifdef XDS_TEST_XDR_STRING
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     char msg[] = "Hello World";
+     char *new_msg;
+ 
+     /* 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, "string", &xdr_encode_string, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "string", 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, "string", &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, "string", &new_msg) != XDS_OK) {
+         printf("xds_decode() failed.\n");
+         return 1;
+     }
+     if (strlen(new_msg) != sizeof (msg) - 1) {
+         printf("The size of the decoded message is wrong.\n");
+         return 1;
+     }
+     if (memcmp(msg, new_msg, sizeof (msg) - 1) != 0) {
+         printf("The decoded string is not correct.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDR_STRING */
+ 
+ #ifdef XDS_TEST_XDR_STRING_EMPTY
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     char msg[] = "";
+     char *new_msg;
+ 
+     /* 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, "string", &xdr_encode_string, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "string", 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, "string", &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, "string", &new_msg) != XDS_OK) {
+         printf("xds_decode() failed.\n");
+         return 1;
+     }
+     if (strlen(new_msg) != 0) {
+         printf("The size of the decoded message is wrong.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XDR_STRING_EMPTY */
+ 
+ #ifdef XDS_TEST_XDR_OCTETSTREAM
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     char msg[] = "Hello\000World";
+     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, sizeof (msg) - 1) != 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 != sizeof (msg) - 1) {
+         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;
+ }
+ 
+ #endif /* XDS_TEST_XDR_OCTETSTREAM */
+ 
+ #ifdef XDS_TEST_XDR_OCTETSTREAM_EMPTY
+ 
+ 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;
+ }
+ 
+ #endif /* XDS_TEST_XDR_OCTETSTREAM_EMPTY */


ossp-pkg/xds/xds_test_xml.c -> 1.1

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,741 ----
+ /* 
+  * 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 <unistd.h>
+ 
+ #include "xds_p.h"
+ 
+ #ifdef XDS_TEST_XML_INT32
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     xds_int32_t values[] = {
+         0x00000000,
+         0x12345678,
+         -0x12345678,
+         0x7bcdef01,
+         -0x7bcdef01,
+         0x7fffffff
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK ||
+         xds_register(xds, "int", &xml_encode_int32, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "begin") != XDS_OK) {
+         printf("xds_encode_begin() failed!\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int32_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_encode(xds, "end") != XDS_OK) {
+         printf("xds_encode_end() failed!\n");
+         return 1;
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&buffer, &buffer_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK ||
+         xds_register(xds, "int", &xml_decode_int32, 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("setbuffer() failed.\n");
+         return 1;
+     }
+     if (xds_decode(xds, "begin") != XDS_OK) {
+         printf("xds_decode_begin() failed!\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int32_t); ++i) {
+         xds_int32_t val;
+         if (xds_decode(xds, "int", &val) != XDS_OK) {
+             printf("xds_decode(values[%d]) failed!\n", i);
+             return 1;
+         }
+         if (val != values[i]) {
+             printf
+                 ("Decoded value (%d) does not match the original value (%d)!\n",
+                  val, values[i]);
+             return 1;
+         }
+     }
+     if (xds_decode(xds, "end") != XDS_OK) {
+         printf("xds_decode_end() failed!\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XML_INT32 */
+ 
+ #ifdef XDS_TEST_XML_UINT32
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     xds_uint32_t values[] = {
+         0x00000000,
+         0x12345678,
+         0xabcdef01,
+         0xc500b3ef,
+         0xffffffff
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_encode_uint32, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint32_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&buffer, &buffer_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_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("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint32_t); ++i) {
+         xds_uint32_t val;
+         if (xds_decode(xds, "int", &val) != XDS_OK) {
+             printf("xds_decode(values[%d]) failed!\n", i);
+             return 1;
+         }
+         if (val != values[i]) {
+             printf
+                 ("Decoded value (%d) does not match the original value (%d)!\n",
+                  val, values[i]);
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XML_UINT32 */
+ 
+ #ifdef XDS_TEST_XML_INT64
+ 
+ #ifdef XDS_HAVE_64_BIT_SUPPORT
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     xds_int64_t values[] = {
+         0x0000000000000000LL,
+         0x123456789abcdef0LL,
+         -0x123456789abcdef0LL,
+         0x7bcdef01cc45bb9aLL,
+         -0x7bcdef01cc45bb9aLL,
+         0x7fffffffffffffffLL
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_encode_int64, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int64_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&buffer, &buffer_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_decode_int64, 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("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_int64_t); ++i) {
+         xds_int64_t val;
+         if (xds_decode(xds, "int", &val) != XDS_OK) {
+             printf("xds_decode(values[%d]) failed!\n", i);
+             return 1;
+         }
+         if (val != values[i]) {
+             printf("Decoded value does not match the original!\n");
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_HAVE_64_BIT_SUPPORT */
+ 
+ #endif /* XDS_TEST_XML_INT64 */
+ 
+ #ifdef XDS_TEST_XML_UINT64
+ 
+ #ifdef XDS_HAVE_64_BIT_SUPPORT
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     xds_uint64_t values[] = {
+         0x0000000000000000ULL,
+         0x123456789abcdef0ULL,
+         0xabcdef01cc45bb9aULL,
+         0xc500b3efdd34ca9eULL,
+         0xffffffffffffffffULL
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_encode_uint64, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint64_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&buffer, &buffer_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_decode_uint64, 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("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_uint64_t); ++i) {
+         xds_uint64_t val;
+         if (xds_decode(xds, "int", &val) != XDS_OK) {
+             printf("xds_decode(values[%d]) failed!\n", i);
+             return 1;
+         }
+         if (val != values[i]) {
+             printf("Decoded value does not match the original!\n");
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_HAVE_64_BIT_SUPPORT */
+ 
+ #endif /* XDS_TEST_XML_UINT64 */
+ 
+ #ifdef XDS_TEST_XML_DOUBLE
+ 
+ int main()
+ {
+ #if 0
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     xds_double_t values[] = {
+         3.14159265358979323844
+     };
+ 
+     size_t i;
+ 
+     /* Encode the values array, then decode it back and compare the numbers. */
+ 
+     xds = xds_init(XDS_ENCODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_encode_double, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_double_t); ++i) {
+         if (xds_encode(xds, "int", values[i]) != XDS_OK) {
+             printf("xds_encode(values[%d]) failed!\n", i);
+             return 1;
+         }
+     }
+     if (xds_getbuffer(xds, XDS_GIFT, (void **)&buffer, &buffer_size) !=
+         XDS_OK) {
+         printf("getbuffer() failed.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+ 
+     printf("%s\n", buffer);
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "int", &xml_decode_double, 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("setbuffer() failed.\n");
+         return 1;
+     }
+     for (i = 0; i < sizeof (values) / sizeof (xds_double_t); ++i) {
+         xds_double_t val;
+         if (xds_decode(xds, "int", &val) != XDS_OK) {
+             printf("xds_decode(values[%d]) failed!\n", i);
+             return 1;
+         }
+         if (val != values[i]) {
+             printf
+                 ("Decoded value (%E) does not match the original value (%E)!\n",
+                  val, values[i]);
+             return 1;
+         }
+     }
+     xds_destroy(xds);
+ 
+     /* Everything went fine. */
+ #endif
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XML_DOUBLE */
+ 
+ #ifdef XDS_TEST_XML_STRING
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     char msg[] = "<Hallo> ]]>&<&>World: äöüß";
+     char *new_msg;
+ 
+     /* Encode the string, 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, "string", &xml_encode_string, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "begin string end", msg, sizeof (msg) - 1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "string", &xml_decode_string, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) {
+         printf("xds_setbuffer() failed.\n");
+         return 1;
+     }
+     if (xds_decode(xds, "begin string end", &new_msg) != XDS_OK) {
+         printf("xds_decode() failed.\n");
+         return 1;
+     }
+     if (strlen(new_msg) != sizeof (msg) - 1) {
+         printf("The size of the decoded message is wrong.\n");
+         return 1;
+     }
+     if (memcmp(msg, new_msg, sizeof (msg) - 1) != 0) {
+         printf("The decoded string is not correct.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XML_STRING */
+ 
+ #ifdef XDS_TEST_XML_STRING_EMPTY
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     char msg[] = "";
+     char *new_msg;
+ 
+     /* Encode the string, 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, "string", &xml_encode_string, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "begin string end", msg, sizeof (msg) - 1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "string", &xml_decode_string, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) {
+         printf("xds_setbuffer() failed.\n");
+         return 1;
+     }
+     if (xds_decode(xds, "begin string end", &new_msg) != XDS_OK) {
+         printf("xds_decode() failed.\n");
+         return 1;
+     }
+     if (strlen(new_msg) != sizeof (msg) - 1) {
+         printf("The size of the decoded message is wrong.\n");
+         return 1;
+     }
+     if (memcmp(msg, new_msg, sizeof (msg) - 1) != 0) {
+         printf("The decoded string is not correct.\n");
+         return 1;
+     }
+     xds_destroy(xds);
+     free(new_msg);
+ 
+     /* Everything went fine. */
+ 
+     return 0;
+ }
+ 
+ #endif /* XDS_TEST_XML_STRING_EMPTY */
+ 
+ #ifdef XDS_TEST_XML_OCTETSTREAM
+ 
+ int main()
+ {
+     xds_t *xds;
+     char *buffer;
+     size_t buffer_size;
+ 
+     char msg[] = "Hallo\000Worl";
+     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", &xml_encode_octetstream, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "begin os end", msg, sizeof (msg) - 1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "os", &xml_decode_octetstream, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) {
+         printf("xds_setbuffer() failed.\n");
+         return 1;
+     }
+     if (xds_decode(xds, "begin os end", &new_msg, &new_msg_size) != XDS_OK) {
+         printf("xds_decode() failed.\n");
+         return 1;
+     }
+     if (new_msg_size != sizeof (msg) - 1) {
+         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;
+ }
+ 
+ #endif /* XDS_TEST_XML_OCTETSTREAM */
+ 
+ #ifdef XDS_TEST_XML_OCTETSTREAM_EMPTY
+ 
+ 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", &xml_encode_octetstream, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_encode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_encode_end, NULL) != XDS_OK) {
+         printf("Failed to register my encoding engines.\n");
+         return 1;
+     }
+     if (xds_encode(xds, "begin os end", msg, sizeof (msg) - 1) != 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);
+     write(1, buffer, buffer_size);
+     printf("\n");
+ 
+     xds = xds_init(XDS_DECODE);
+     if (xds == NULL) {
+         printf("Failed to initialize XDS context.\n");
+         return 1;
+     }
+     if (xds_register(xds, "os", &xml_decode_octetstream, NULL) != XDS_OK ||
+         xds_register(xds, "begin", &xml_decode_begin, NULL) != XDS_OK ||
+         xds_register(xds, "end", &xml_decode_end, NULL) != XDS_OK) {
+         printf("Failed to register my decoding engines.\n");
+         return 1;
+     }
+     if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) {
+         printf("xds_setbuffer() failed.\n");
+         return 1;
+     }
+     if (xds_decode(xds, "begin os end", &new_msg, &new_msg_size) != XDS_OK) {
+         printf("xds_decode() failed.\n");
+         return 1;
+     }
+     if (new_msg_size != sizeof (msg) - 1) {
+         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;
+ }
+ 
+ #endif /* XDS_TEST_XML_OCTETSTREAM_EMPTY */


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,39 ----
+ /*
+    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 "xds.h"
+ 
+ int xml_decode_begin(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     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 XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,39 ----
+ /*
+    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 "xds.h"
+ 
+ int xml_decode_end(xds_t* xds, void* engine_context,
+                     void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     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 XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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((int)*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.7

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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((int)*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-octetstream.c -> 1.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,224 ----
+ /*
+    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 "xds.h"
+ 
+ static int base64_decode(unsigned char *dst, size_t dstlen, char const *src, size_t srclen)
+     {
+     int dstidx, state, ch = 0;
+     unsigned char res;
+     char *pos;
+ 
+     if (srclen == 0)
+        return 0;
+     state = 0;
+     dstidx = 0;
+     res = 0;
+     while (srclen-- > 0)
+        {
+         ch = *src++;
+         if (isascii(ch) && isspace(ch)) /* Skip whitespace anywhere */
+             continue;
+         if (ch == xds_pad64)
+             break;
+         pos = strchr(xds_base64, ch);
+         if (pos == 0)           /* A non-base64 character */
+             return -1;
+         switch (state)
+            {
+             case 0:
+                 if (dst != NULL)
+                    {
+                     if ((size_t)dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] = ((pos - xds_base64) << 2);
+                    }
+                 state = 1;
+                 break;
+             case 1:
+                 if (dst != NULL)
+                    {
+                     if ((size_t)dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] |= ((pos - xds_base64) >> 4);
+                     res = (((pos - xds_base64) & 0x0f) << 4);
+                    }
+                 dstidx++;
+                 state = 2;
+                 break;
+             case 2:
+                 if (dst != NULL)
+                    {
+                     if ((size_t)dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] = res | ((pos - xds_base64) >> 2);
+                     res = ((pos - xds_base64) & 0x03) << 6;
+                    }
+                 dstidx++;
+                 state = 3;
+                 break;
+             case 3:
+                 if (dst != NULL)
+                    {
+                     if ((size_t)dstidx >= dstlen)
+                         return -1;
+                     dst[dstidx] = res | (pos - xds_base64);
+                    }
+                 dstidx++;
+                 state = 0;
+                 break;
+             default:
+                 break;
+            }
+        }
+ 
+     /*
+      * We are done decoding Base-64 chars.  Let's see if we ended
+      * on a byte boundary, and/or with erroneous trailing characters.
+      */
+ 
+     if (ch == xds_pad64)
+        {          /* We got a pad char. */
+         switch (state)
+            {
+             case 0:             /* Invalid = in first position */
+             case 1:             /* Invalid = in second position */
+                 return -1;
+             case 2:             /* Valid, means one byte of info */
+                 /* Skip any number of spaces. */
+                while(srclen > 0)
+                    {
+                    ch = *src++;
+                    --srclen;
+                     if (!(isascii(ch) && isspace(ch)))
+                         break;
+                    }
+                 /* Make sure there is another trailing = sign. */
+                 if (ch != xds_pad64)
+                     return -1;
+                 /* FALLTHROUGH */
+             case 3:             /* Valid, means two bytes of info */
+                 /*
+                  * We know this char is an =.  Is there anything but
+                  * whitespace after it?
+                  */
+                while(srclen > 0)
+                    {
+                    ch = *src++;
+                    --srclen;
+                     if (!(isascii(ch) && isspace(ch)))
+                         return -1;
+                    }
+                 /*
+                  * Now make sure for cases 2 and 3 that the "extra"
+                  * bits that slopped past the last full byte were
+                  * zeros.  If we don't check them, they become a
+                  * subliminal channel.
+                  */
+                 if (dst != NULL && res != 0)
+                     return -1;
+             default:
+                 break;
+            }
+        }
+     else
+        {
+         /*
+          * We ended by seeing the end of the string.  Make sure we
+          * have no partial bytes lying around.
+          */
+         if (state != 0)
+             return -1;
+        }
+ 
+     return dstidx;
+     }
+ 
+ int xml_decode_octetstream(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;
+     xds_uint8_t**  data;
+     size_t*        data_len;
+ 
+     /* We need at least 27 byte for the starting and ending tag. */
+ 
+     xds_init_encoding_engine(13 + 14);
+ 
+     /* Get parameters from stack. */
+ 
+     data     = va_arg(*args, xds_uint8_t**);
+     xds_check_parameter(data != NULL);
+     data_len = va_arg(*args, size_t*);
+ 
+     /* Check for the opening tag. */
+ 
+     if (memcmp("<octetstream>", buffer, 13) != 0)
+        return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Find the end of the data and calculate the length of the
+        base64-encoded stuff. */
+ 
+     p = (char*)buffer + 13;
+     while(p < ((char*)buffer+buffer_size) && *p != '<')
+        ++p;
+     if (p == ((char*)buffer+buffer_size))
+        return XDS_ERR_TYPE_MISMATCH;
+     else
+        {
+        p_len = p - ((char*)buffer + 13);
+        p = (char*)buffer + 13;
+        }
+ 
+     /* Now find out how long the decoded data is going to be, allocate
+        a buffer for it, and decode away. */
+ 
+     *data_len = base64_decode(NULL, 0, p, p_len);
+     if (*data_len == (size_t)-1)
+        return XDS_ERR_UNKNOWN;
+     *data = malloc(*data_len);
+     if (*data == NULL)
+        return XDS_ERR_NO_MEM;
+     base64_decode(*data, *data_len, p, p_len);
+ 
+     /* Check that we have a closing tag. */
+ 
+     if (memcmp(p + p_len, "</octetstream>", 14) != 0)
+        {
+        free(*data);
+        return XDS_ERR_TYPE_MISMATCH;
+        }
+ 
+     /* Done. */
+ 
+     *used_buffer_size = 13 + p_len + 14;
+     return XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,188 ----
+ /*
+    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 "xds.h"
+ 
+ #define        INVALID 0x80000000
+ 
+ #define        get(c)  c = *strptr++; \
+        if (chars) (*chars)++; \
+        if ((c) == 0) return (unsigned int)EOF
+ 
+ static unsigned int sgetu8(unsigned char *strptr, int *chars)
+     {
+     unsigned int c;
+     int i, iterations;
+     unsigned char ch;
+ 
+     if (chars)
+        *chars = 0;
+ 
+     if (strptr == NULL)
+        return (unsigned int)EOF;
+ 
+     get(c);
+ 
+     if ((c & 0xFE) == 0xFC)
+        {
+        c &= 0x01;
+        iterations = 5;
+        }
+     else if ((c & 0xFC) == 0xF8)
+        {
+        c &= 0x03;
+        iterations = 4;
+        }
+     else if ((c & 0xF8) == 0xF0)
+        {
+        c &= 0x07;
+        iterations = 3;
+        }
+     else if ((c & 0xF0) == 0xE0)
+        {
+        c &= 0x0F;
+        iterations = 2;
+        }
+     else if ((c & 0xE0) == 0xC0)
+        {
+        c &= 0x1F;
+        iterations = 1;
+        }
+     else if ((c & 0x80) == 0x80)
+        return INVALID;
+     else return c;
+ 
+     for (i = 0; i < iterations; i++)
+        {
+        get(ch);
+        if ((ch & 0xC0) != 0x80)
+            return INVALID;
+        c <<= 6;
+        c |= ch & 0x3F;
+        }
+ 
+     return c;
+     }
+ 
+ static const char TAG_OPEN[] = "<string>";
+ static const char TAG_CLOSE[] = "</string>";
+ static const size_t TAG_OPEN_LEN = sizeof(TAG_OPEN)-1;
+ static const size_t TAG_CLOSE_LEN = sizeof(TAG_CLOSE)-1;
+ 
+ int xml_decode_string(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
+     {
+     char**  target_buffer;
+     char*   src;
+     size_t  src_len;
+     char*   dst;
+     int     utf8_len;
+     unsigned int rc;
+ 
+     /* Setup the engine. We need at least space for our tags; how long
+        the actual content is going to be will be seen soon. */
+ 
+     xds_init_encoding_engine(TAG_OPEN_LEN + TAG_CLOSE_LEN);
+ 
+     /* Is the opening tag there? */
+ 
+     if (strncasecmp(buffer, TAG_OPEN, TAG_OPEN_LEN) != 0)
+         return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Determine the length of the encoded data. */
+ 
+     src = (char*)buffer + TAG_OPEN_LEN;
+     for (src_len = 0; src[src_len] != '<'; ++src_len)
+        if (src[src_len] == '\0')
+            return XDS_ERR_TYPE_MISMATCH;
+ 
+     /* Check the closing tag. */
+ 
+     if (strncasecmp(src + src_len, TAG_CLOSE, TAG_CLOSE_LEN) != 0)
+         return XDS_ERR_TYPE_MISMATCH;
+     *used_buffer_size = TAG_OPEN_LEN + src_len + TAG_CLOSE_LEN;
+ 
+     /* Allocate target buffer. */
+ 
+     target_buffer = va_arg(*args, char**);
+     xds_check_parameter(target_buffer != NULL);
+     *target_buffer = dst = malloc(src_len + 1);
+     if (dst == NULL)
+        return XDS_ERR_NO_MEM;
+ 
+     /* Decode the data into the target buffer. */
+ 
+     while(src_len > 0)
+        {
+        if (*src == '&')
+            {
+            if (src_len >= 4 && strncmp(src, "&lt;", 4) == 0)
+                {
+                *dst++ = '<';
+                src += 4; src_len -= 4;
+                }
+            else if (src_len >= 4 && strncmp(src, "&gt;", 4) == 0)
+                {
+                *dst++ = '>';
+                src += 4; src_len -= 4;
+                }
+            else if (src_len >= 5 && strncmp(src, "&amp;", 5) == 0)
+                {
+                *dst++ = '&';
+                src += 5; src_len -= 5;
+                }
+            else
+                {
+                free(dst);
+                return XDS_ERR_TYPE_MISMATCH;
+                }
+            }
+        else if (*((xds_uint8_t*)src) >= 0x80)
+            {
+            rc = sgetu8((xds_uint8_t*)src, &utf8_len);
+            if (rc == (unsigned int)EOF)
+                return XDS_ERR_UNDERFLOW;
+            else if (rc == INVALID || rc > 255)
+                return XDS_ERR_TYPE_MISMATCH;
+            *dst++ = (xds_uint8_t)rc;
+            src += utf8_len; src_len -= utf8_len;
+            }
+        else
+            {
+            *dst++ = *src++;
+            --src_len;
+            }
+        }
+     *dst = '\0';
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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((int)*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.7

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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((int)*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.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,43 ----
+ /*
+    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 "xds.h"
+ 
+ const char xds_xml_begin_text[] = \
+     "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\">\n" \
+     "<!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, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     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.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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.4

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,40 ----
+ /*
+    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 "xds.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, size_t* used_buffer_size,
+                     va_list* args)
+     {
+     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.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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-octetstream.c -> 1.3

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,142 ----
+ /*
+    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 "xds.h"
+ 
+ const char xds_base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const char xds_pad64    = '=';
+ 
+ static int base64_encode(char *dst, size_t dstlen, unsigned char const *src, size_t srclen)
+     {
+     size_t dstpos;
+     unsigned char input[3];
+     unsigned char output[4];
+     int ocnt;
+     size_t i;
+ 
+     if (srclen == 0)
+         return 0;
+     if (dst == NULL)
+        {
+         /* just calculate required length of dst */
+         dstlen = (((srclen + 2) / 3) * 4);
+         return dstlen;
+        }
+ 
+     /* bulk encoding */
+     dstpos = 0;
+     ocnt = 0;
+     while (srclen >= 3)
+        {
+         input[0] = *src++;
+         input[1] = *src++;
+         input[2] = *src++;
+         srclen -= 3;
+ 
+         output[0] = (input[0] >> 2);
+         output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+         output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+         output[3] = (input[2] & 0x3f);
+ 
+         if (dstpos + 4 > dstlen)
+             return -1;
+         dst[dstpos++] = xds_base64[output[0]];
+         dst[dstpos++] = xds_base64[output[1]];
+         dst[dstpos++] = xds_base64[output[2]];
+         dst[dstpos++] = xds_base64[output[3]];
+        }
+ 
+     /* now worry about padding with remaining 1 or 2 bytes */
+     if (srclen != 0)
+        {
+         input[0] = input[1] = input[2] = '\0';
+         for (i = 0; i < srclen; i++)
+             input[i] = *src++;
+ 
+         output[0] = (input[0] >> 2);
+         output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+         output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+ 
+         if (dstpos + 4 > dstlen)
+             return -1;
+         dst[dstpos++] = xds_base64[output[0]];
+         dst[dstpos++] = xds_base64[output[1]];
+         if (srclen == 1)
+             dst[dstpos++] = xds_pad64;
+         else
+             dst[dstpos++] = xds_base64[output[2]];
+         dst[dstpos++] = xds_pad64;
+        }
+ 
+     if (dstpos >= dstlen)
+         return -1;
+     dst[dstpos] = '\0';
+ 
+     return dstpos;
+     }
+ 
+ int xml_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* src;
+     size_t       src_len;
+ 
+     /* We need at least 27 byte for the starting and ending tag. */
+ 
+     xds_init_encoding_engine(13 + 14);
+ 
+     /* Get parameters from stack. */
+ 
+     src     = (xds_uint8_t*)va_arg(*args, void*);
+     xds_check_parameter(src != NULL);
+     src_len = va_arg(*args, size_t);
+ 
+     /* Calculate how many bytes we'll need in buffer and make sure we
+        have them. */
+ 
+     *used_buffer_size = base64_encode(NULL, 0, src, src_len);
+     if (*used_buffer_size == (size_t)-1)
+        return XDS_ERR_UNKNOWN;
+     else
+        *used_buffer_size += 13 + 14;
+     if (buffer_size < *used_buffer_size)
+        return XDS_ERR_OVERFLOW;
+ 
+     /* Format the data into the buffer. */
+ 
+     memmove(buffer, "<octetstream>", 13);
+     if (base64_encode((char*)buffer + 13, buffer_size - 13, src, src_len) < 0)
+        return XDS_ERR_UNKNOWN;
+     memmove((char*)buffer + *used_buffer_size - 14, "</octetstream>", 14);
+ 
+     /* Done. */
+ 
+     return XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 2024
***************
*** 0 ****
--- 1,208 ----
+ /*
+    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 "xds.h"
+ 
+ #define        bits(c) (0x80 | ((c) & 0x3F))
+ #define        put(c)  *strptr++ = (c);
+ #define        putbits(c)      put(bits(c))
+ #define        finish()        *strptr = '\0'
+ 
+ static char* sputu8(xds_uint32_t c, char* strptr)
+     {
+     if (strptr == NULL)
+        return NULL;
+ 
+     if (c < 0x80)
+        {
+        put(c);
+        finish();
+        }
+     else if (c < 0x800)
+        {
+        put(0xC0 | (c >>  6));
+        putbits(c);
+        finish();
+        }
+     else if (c < 0x10000)
+        {
+        put(0xE0 | (c >> 12));
+        putbits(c >>  6);
+        putbits(c);
+        finish();
+        }
+     else if (c < 0x200000)
+        {
+        put(0xF0 | (c >> 18));
+        putbits(c >> 12);
+        putbits(c >>  6);
+        putbits(c);
+        finish();
+        }
+     else if (c < 0x400000)
+        {
+        put(0xF8 | (c >> 24));
+        putbits(c >> 18);
+        putbits(c >> 12);
+        putbits(c >>  6);
+        putbits(c);
+        finish();
+        }
+     else if (c < 0x80000000)
+        {
+        put(0xFC | (c >> 30));
+        putbits(c >> 24);
+        putbits(c >> 18);
+        putbits(c >> 12);
+        putbits(c >>  6);
+        putbits(c);
+        finish();
+        }
+     else
+        finish();               /* Not a valid Unicode "character" */
+ 
+     return strptr;
+     }
+ 
+ static const char TAG_OPEN[] = "<string>";
+ static const char TAG_CLOSE[] = "</string>";
+ static const size_t TAG_OPEN_LEN = sizeof(TAG_OPEN)-1;
+ static const size_t TAG_CLOSE_LEN = sizeof(TAG_CLOSE)-1;
+ 
+ int xml_encode_string(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
+     {
+     char*  src;
+     size_t src_len;
+     char*  dst;
+     size_t dst_size;
+     char*  tmp;
+ 
+     /* Setup the engine. We need at least space for our tags; how long
+        the actual content is going to be will be seen soon. */
+ 
+     xds_init_encoding_engine(TAG_OPEN_LEN + TAG_CLOSE_LEN);
+ 
+     /* Get the data from the stack. */
+ 
+     src      = va_arg(*args, char*);
+     xds_check_parameter(src != NULL);
+     src_len  = strlen(src);
+ 
+     /* Set up the target buffer. */
+ 
+     dst      = buffer;
+     dst_size = buffer_size;
+ 
+     /* Write the opening tag. */
+ 
+     memmove(dst, TAG_OPEN, TAG_OPEN_LEN);
+     dst      += TAG_OPEN_LEN;
+     dst_size -= TAG_OPEN_LEN;
+ 
+     /* Format the data into the buffer. */
+ 
+     while(src_len > 0 && dst_size > 0)
+        {
+        if (*((xds_uint8_t*)src) >= 0x80)
+            {                   /* UTF-8ify it. */
+            if (dst_size >= 7)
+                {
+                tmp = sputu8((xds_uint32_t)*((xds_uint8_t*)src), dst);
+                ++src; --src_len;
+                dst_size -= tmp - dst;
+                dst = tmp;
+                }
+            else
+                dst_size = 0;
+            }
+        else if (*src == '<')
+            {                   /* Turn into "&lt;". */
+            if (dst_size >= 4)
+                {
+                *dst++ = '&'; --dst_size;
+                *dst++ = 'l'; --dst_size;
+                *dst++ = 't'; --dst_size;
+                *dst++ = ';'; --dst_size;
+                ++src; --src_len;
+                }
+            else
+                dst_size = 0;
+            }
+        else if (*src == '&')
+            {                   /* Turn into "&amp;". */
+            if (dst_size >= 5)
+                {
+                *dst++ = '&'; --dst_size;
+                *dst++ = 'a'; --dst_size;
+                *dst++ = 'm'; --dst_size;
+                *dst++ = 'p'; --dst_size;
+                *dst++ = ';'; --dst_size;
+                ++src; --src_len;
+                }
+            else
+                dst_size = 0;
+            }
+        else if (*src == '>')
+            {                   /* Turn into "&gt;". */
+            if (dst_size >= 4)
+                {
+                *dst++ = '&'; --dst_size;
+                *dst++ = 'g'; --dst_size;
+                *dst++ = 't'; --dst_size;
+                *dst++ = ';'; --dst_size;
+                ++src; --src_len;
+                }
+            else
+                dst_size = 0;
+            }
+        else
+            {                   /* No special character; just copy it. */
+            *dst++ = *src++;
+            --src_len; --dst_size;
+            }
+        }
+     if (src_len > 0)
+        {                       /* Target buffer was too small. */
+        *used_buffer_size = buffer_size + 1;
+        return XDS_ERR_OVERFLOW;
+        }
+ 
+     /* Write the closing tag. */
+ 
+     memmove(dst, TAG_CLOSE, TAG_CLOSE_LEN);
+     dst      += TAG_CLOSE_LEN;
+     dst_size -= TAG_CLOSE_LEN;
+ 
+     /* Done. */
+ 
+     *used_buffer_size = dst - (char*)buffer;
+     return XDS_OK;
+     }


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

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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.6

*** /dev/null    Sat Nov 23 01:07:30 2024
--- -    Sat Nov 23 01:07:33 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 "xds.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