Index: ossp-pkg/xds/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/xds/Makefile.in,v rcsdiff -q -kk '-r1.11' '-r1.12' -u '/v/ossp/cvs/ossp-pkg/xds/Makefile.in,v' 2>/dev/null --- Makefile.in 2001/07/31 15:27:45 1.11 +++ Makefile.in 2001/08/01 15:25:47 1.12 @@ -8,19 +8,25 @@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ +XML_OBJS = xml-encode-int32.o xml-decode-int32.o \ + xml-encode-uint32.o xml-decode-uint32.o \ + xml-encode-int64.o xml-decode-int64.o \ + xml-encode-uint64.o xml-decode-uint64.o \ + xml-encode-double.o xml-decode-double.o \ + xml-encode-begin.o xml-decode-begin.o \ + xml-encode-end.o xml-decode-end.o + +XDR_OBJS = xdr-encode-int32.o xdr-decode-int32.o \ + xdr-encode-uint32.o xdr-decode-uint32.o \ + xdr-encode-int64.o xdr-decode-int64.o \ + xdr-encode-uint64.o xdr-decode-uint64.o \ + xdr-encode-double.o xdr-decode-double.o \ + xdr-encode-octetstream.o xdr-decode-octetstream.o \ + xdr-encode-string.o xdr-decode-string.o \ + OBJS = decode.o destroy.o encode.o getbuffer.o init.o register.o \ setbuffer.o unregister.o vdecode.o vencode.o find-engine.o \ - set-capacity.o xdr-encode-int32.o xdr-encode-int64.o \ - xdr-encode-uint32.o xdr-encode-uint64.o xdr-decode-int32.o \ - xdr-decode-int64.o xdr-decode-uint32.o xdr-decode-uint64.o \ - xdr-encode-octetstream.o xdr-decode-octetstream.o \ - xdr-encode-string.o xdr-decode-string.o xdr-encode-double.o \ - xdr-decode-double.o xml-encode-int32.o xml-decode-int32.o \ - xml-decode-int64.o xml-decode-uint32.o xml-decode-uint64.o \ - xml-encode-int64.o xml-encode-uint32.o xml-encode-uint64.o \ - xml-encode-double.o xml-decode-double.o \ - xml-encode-begin.o xml-decode-begin.o \ - xml-encode-end.o xml-decode-end.o + set-capacity.o $(XDR_OBJS) $(XML_OBJS) .c.o: $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) -c $< Index: ossp-pkg/xds/destroy.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/destroy.c,v co -q -kk -p'1.8' '/v/ossp/cvs/ossp-pkg/xds/Attic/destroy.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/destroy.c' 2>/dev/null --- ossp-pkg/xds/destroy.c +++ - 2024-05-10 04:35:01.028882928 +0200 @@ -0,0 +1,58 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#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); + } Index: ossp-pkg/xds/find-engine.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/find-engine.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/find-engine.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/find-engine.c' 2>/dev/null --- ossp-pkg/xds/find-engine.c +++ - 2024-05-10 04:35:01.031379980 +0200 @@ -0,0 +1,66 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include "internal.h" + +int xds_find_engine(const engine_map_t* engines, size_t last, const char* name, size_t* pos) + { + size_t first; + + /* Sanity checks. */ + + xds_check_parameter(engines != NULL || last == 0); + xds_check_parameter(name != NULL); + xds_check_parameter(pos != NULL); + + /* Use binary search to find "name" in "engines". */ + + for (first = 0; (last - first) > 0; ) + { + size_t half = first + ((last - first) / 2); + int rc = strcmp(engines[half].name, name); + + if (rc < 0) + { + first = half + 1; + } + else if(rc == 0) + { /* found it */ + *pos = half; + return XDS_TRUE; + } + else + { + last = half; + } + assert(first <= last); + } + + *pos = first; + return XDS_FALSE; + } Index: ossp-pkg/xds/getbuffer.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/getbuffer.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/getbuffer.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/getbuffer.c' 2>/dev/null --- ossp-pkg/xds/getbuffer.c +++ - 2024-05-10 04:35:01.033825913 +0200 @@ -0,0 +1,52 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include "internal.h" + +int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_len) + { + /* Sanity checks. */ + + xds_check_parameter(xds != NULL); + xds_check_parameter(flag == XDS_GIFT || flag == XDS_LOAN); + xds_check_parameter(buffer != NULL); + xds_check_parameter(buffer_len != NULL); + + /* Return the buffer to the caller. */ + + *buffer = xds->buffer; + *buffer_len = xds->buffer_len; + if (flag == XDS_GIFT) + { + xds->buffer = NULL; + xds->buffer_capacity = xds->buffer_len = 0; + } + else + xds->buffer_len = 0; + + return XDS_OK; + } Index: ossp-pkg/xds/init.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/init.c,v co -q -kk -p'1.6' '/v/ossp/cvs/ossp-pkg/xds/Attic/init.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/init.c' 2>/dev/null --- ossp-pkg/xds/init.c +++ - 2024-05-10 04:35:01.036276705 +0200 @@ -0,0 +1,71 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#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; + } Index: ossp-pkg/xds/internal.h RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/internal.h,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/xds/Attic/internal.h,v' 2>/dev/null --- internal.h 2001/07/31 15:27:45 1.7 +++ internal.h 2001/08/01 15:25:47 1.8 @@ -30,6 +30,7 @@ #ifndef __INTERNAL_H__ #define __INTERNAL_H__ +#include #include "xds.h" #define XDS_TRUE (1==1) @@ -66,4 +67,38 @@ extern const char xds_xml_begin_text[]; extern const char xds_xml_end_text[]; +#define xds_check_parameter(condition) \ + do \ + { \ + assert(condition); \ + if (!(condition)) \ + return XDS_ERR_INVALID_ARG; \ + } while(XDS_FALSE) + +#define xds_init_encoding_engine(size) \ + do \ + { \ + xds_check_parameter(xds != NULL); \ + xds_check_parameter(buffer != NULL); \ + xds_check_parameter(buffer_size != 0); \ + xds_check_parameter(used_buffer_size != NULL && *used_buffer_size == 0); \ + xds_check_parameter(args != NULL); \ + *used_buffer_size = size; \ + if (buffer_size < size) \ + return XDS_ERR_OVERFLOW; \ + } while(XDS_FALSE) + +#define xds_init_decoding_engine(size) \ + do \ + { \ + xds_check_parameter(xds != NULL); \ + xds_check_parameter(buffer != NULL); \ + xds_check_parameter(buffer_size != 0); \ + xds_check_parameter(used_buffer_size != NULL && *used_buffer_size == 0); \ + xds_check_parameter(args != NULL); \ + *used_buffer_size = size; \ + if (buffer_size < size) \ + return XDS_ERR_UNDERFLOW; \ + } while(XDS_FALSE) + #endif /* !defined(__INTERNAL_H__) */ Index: ossp-pkg/xds/register.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/register.c,v co -q -kk -p'1.7' '/v/ossp/cvs/ossp-pkg/xds/Attic/register.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/register.c' 2>/dev/null --- ossp-pkg/xds/register.c +++ - 2024-05-10 04:35:01.042526219 +0200 @@ -0,0 +1,83 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include +#include "internal.h" + +int xds_register(xds_t* xds, const char* name, xds_engine_t engine, void* engine_context) + { + size_t pos; + + /* Sanity checks. */ + + xds_check_parameter(xds != NULL); + xds_check_parameter(name != NULL); + xds_check_parameter(engine != NULL); + for(pos = 0; name[pos] != '\0'; ++pos) + { + if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_') + return XDS_ERR_INVALID_ARG; + } + + /* Copy the name argument into our own memory. */ + + name = strdup(name); + if (name == NULL) + return XDS_ERR_NO_MEM; + + /* Search engines for the entry. */ + + if (xds_find_engine(xds->engines, xds->engines_len, name, &pos)) + { /* overwrite existing entry */ + free(xds->engines[pos].name); + } + else + { /* insert new entry */ + int rc = xds_set_capacity((void**)&xds->engines, + &xds->engines_capacity, + xds->engines_len + 1, + sizeof(engine_map_t), + XDS_INITIAL_ENGINES_CAPACITY); + assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM); + if (rc != XDS_OK) + return rc; + memmove(&xds->engines[pos+1], &xds->engines[pos], (xds->engines_len - pos) * sizeof(engine_map_t)); + ++xds->engines_len; + } + + /* Insert entry. */ + + xds->engines[pos].name = (char*)name; + xds->engines[pos].engine = engine; + xds->engines[pos].context = engine_context; + + /* Everything is fine. */ + + return XDS_OK; + } Index: ossp-pkg/xds/regression-tests/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/Makefile.in,v co -q -kk -p'1.10' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/Makefile.in,v' | diff -u - /dev/null -L'ossp-pkg/xds/regression-tests/Makefile.in' 2>/dev/null --- ossp-pkg/xds/regression-tests/Makefile.in +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,42 +0,0 @@ -# Build and run the regression tests for libxds. - -CC = @CC@ -AR = ar -RANLIB = @RANLIB@ - -CPPFLAGS = @CPPFLAGS@ @DEFS@ -D_GNU_SOURCE -CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ @xdr_lib@ -L.. - -TESTS = xds-core.exe xds-find-engine.exe xds-register.exe xds-encode.exe \ - xds-getbuffer.exe xds-decode.exe xds-setbuffer.exe xds-engine-restart.exe \ - xdr-uint32.exe xdr-int32.exe xdr-uint64.exe xdr-int64.exe \ - xdr-octetstream.exe xdr-octetstream-empty.exe xdr-string.exe \ - xdr-string-empty.exe xds-mystruct.exe xml-uint32.exe xml-int32.exe \ - xml-uint64.exe xml-int64.exe xml-double.exe - -.SUFFIXES: -.SUFFIXES: .c .exe - -.c.exe: - $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< -lxds - -all: $(TESTS) - -check: all - @./.run-tests $(TESTS) - -../libxds.a: - (cd .. && $(MAKE) libxds.a) -clean:: - rm -f $(TESTS) *.log - -distclean:: clean - rm -f Makefile - -realclean:: distclean - - -# Dependencies - -$(TESTS): ../libxds.a ../internal.h ../xds.h Index: ossp-pkg/xds/regression-tests/xdr-octetstream-empty.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-octetstream-empty.c,v co -q -kk -p'1.2' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-octetstream-empty.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xdr-octetstream-empty.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xdr-octetstream-empty.c +++ - 2024-05-10 04:35:01.047844843 +0200 @@ -0,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 +#include +#include "../internal.h" + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + char msg[] = ""; + char* new_msg; + size_t new_msg_size; + + /* Encode the string as octet stream. Then erase the buffer and + decode the string back, verifying that it hasn't changed. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_encode_octetstream, NULL) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + if (xds_encode(xds, "os", msg, 0) != XDS_OK) + { + printf("xds_encode() failed.\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK) + { + printf("xds_getbuffer() failed.\n"); + return 1; + } + xds_destroy(xds); + if (buffer_size % 4 != 0) + { + printf("The encoded octet stream's buffer size is not a multiple of 4.\n"); + return 1; + } + + xds = xds_init(XDS_DECODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_decode_octetstream, NULL) != XDS_OK) + { + printf("Failed to register my decoding engines.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed.\n"); + return 1; + } + if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK) + { + printf("xds_decode() failed.\n"); + return 1; + } + if (new_msg_size != 0) + { + printf("The size of the decoded message is wrong.\n"); + return 1; + } + if (memcmp(msg, new_msg, new_msg_size) != 0) + { + printf("The decoded octet stream is not correct.\n"); + return 1; + } + xds_destroy(xds); + free(new_msg); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xdr-octetstream.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-octetstream.c,v co -q -kk -p'1.2' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-octetstream.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xdr-octetstream.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xdr-octetstream.c +++ - 2024-05-10 04:35:01.050369619 +0200 @@ -0,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 +#include +#include "../internal.h" + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + char msg[] = "Hello World"; + char* new_msg; + size_t new_msg_size; + + /* Encode the string as octet stream. Then erase the buffer and + decode the string back, verifying that it hasn't changed. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_encode_octetstream, NULL) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + if (xds_encode(xds, "os", msg, strlen(msg)) != XDS_OK) + { + printf("xds_encode() failed.\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK) + { + printf("xds_getbuffer() failed.\n"); + return 1; + } + xds_destroy(xds); + if (buffer_size % 4 != 0) + { + printf("The encoded octet stream's buffer size is not a multiple of 4.\n"); + return 1; + } + + xds = xds_init(XDS_DECODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_decode_octetstream, NULL) != XDS_OK) + { + printf("Failed to register my decoding engines.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed.\n"); + return 1; + } + if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK) + { + printf("xds_decode() failed.\n"); + return 1; + } + if (new_msg_size != strlen(msg)) + { + printf("The size of the decoded message is wrong.\n"); + return 1; + } + if (memcmp(msg, new_msg, new_msg_size) != 0) + { + printf("The decoded octet stream is not correct.\n"); + return 1; + } + xds_destroy(xds); + free(new_msg); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xdr-string-empty.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-string-empty.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-string-empty.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xdr-string-empty.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xdr-string-empty.c +++ - 2024-05-10 04:35:01.052880989 +0200 @@ -0,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 +#include +#include "../internal.h" + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + char msg[] = ""; + char* new_msg; + size_t new_msg_size; + + /* Encode the string as octet stream. Then erase the buffer and + decode the string back, verifying that it hasn't changed. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_encode_string, NULL) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + if (xds_encode(xds, "os", msg, 0) != XDS_OK) + { + printf("xds_encode() failed.\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK) + { + printf("xds_getbuffer() failed.\n"); + return 1; + } + xds_destroy(xds); + if (buffer_size % 4 != 0) + { + printf("The encoded strings' buffer size is not a multiple of 4.\n"); + return 1; + } + + xds = xds_init(XDS_DECODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_decode_string, NULL) != XDS_OK) + { + printf("Failed to register my decoding engines.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed.\n"); + return 1; + } + if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK) + { + printf("xds_decode() failed.\n"); + return 1; + } + if (new_msg_size != 0) + { + printf("The size of the decoded message is wrong.\n"); + return 1; + } + if (memcmp(msg, new_msg, new_msg_size) != 0) + { + printf("The decoded string is not correct.\n"); + return 1; + } + xds_destroy(xds); + free(new_msg); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xdr-string.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-string.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xdr-string.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xdr-string.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xdr-string.c +++ - 2024-05-10 04:35:01.055377122 +0200 @@ -0,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 +#include +#include "../internal.h" + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + char msg[] = "Hello World"; + char* new_msg; + size_t new_msg_size; + + /* Encode the string as octet stream. Then erase the buffer and + decode the string back, verifying that it hasn't changed. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_encode_string, NULL) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + if (xds_encode(xds, "os", msg) != XDS_OK) + { + printf("xds_encode() failed.\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK) + { + printf("xds_getbuffer() failed.\n"); + return 1; + } + xds_destroy(xds); + if (buffer_size % 4 != 0) + { + printf("The encoded strings' buffer size is not a multiple of 4.\n"); + return 1; + } + + xds = xds_init(XDS_DECODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "os", &xdr_decode_string, NULL) != XDS_OK) + { + printf("Failed to register my decoding engines.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed.\n"); + return 1; + } + if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK) + { + printf("xds_decode() failed.\n"); + return 1; + } + if (new_msg_size != strlen(msg)) + { + printf("The size of the decoded message is wrong: %d.\n", new_msg_size); + return 1; + } + if (memcmp(msg, new_msg, new_msg_size) != 0) + { + printf("The decoded string is not correct.\n"); + return 1; + } + xds_destroy(xds); + free(new_msg); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-decode.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-decode.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-decode.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-decode.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-decode.c +++ - 2024-05-10 04:35:01.057870286 +0200 @@ -0,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 +#include +#include "../internal.h" + +static int dummy_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + if (xds == NULL) + { + printf("XDS context isn't passed through to registered engine.\n"); + exit(1); + } + if (engine_context != (void*)42) + { + printf("Engine context isn't passed through to registered engine.\n"); + exit(1); + } + if (buffer == NULL) + { + printf("Buffer passed to engine is NULL.\n"); + exit(1); + } + if (buffer_size == 0) + { + printf("Buffer size passed to engine is zero!\n"); + exit(1); + } + if (used_buffer_size == NULL) + { + printf("used_buffer_size passed to engine is zero!\n"); + exit(1); + } + if (args == NULL) + { + printf("args pointer passed to engine is NULL!\n"); + exit(1); + } + if (buffer_size < 6) + { + printf("The buffer is too small; can't verify my encoded string.\n"); + exit(1); + } + if (memcmp(buffer, "Hallo!", 6) != 0) + { + printf("The contents of the decode buffer are not what we expected.\n"); + exit(1); + } + *used_buffer_size = 6; + return XDS_OK; + } + +int main() + { + xds_t* xds; + char buffer[] = "Hallo!Hallo!Hallo!"; + + /* Create XDS context. */ + + xds = xds_init(XDS_DECODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + + /* Register the dummy callback under multiple names. */ + + if (xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK) + { + printf("Failed to register my decoding engines.\n"); + return 1; + } + + /* Decode the buffer and have the callback report when something + is wrong. */ + + if (xds_setbuffer(xds, XDS_LOAN, buffer, strlen(buffer)) != XDS_OK) + { + printf("xds_decode() failed!"); + return 1; + } + + if (xds_decode(xds, "text::text text") != XDS_OK) + { + printf("xds_decode() failed!"); + return 1; + } + + /* Clean up. */ + + xds_destroy(xds); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-encode.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-encode.c,v co -q -kk -p'1.6' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-encode.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-encode.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-encode.c +++ - 2024-05-10 04:35:01.060381478 +0200 @@ -0,0 +1,117 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include "../internal.h" + +static int dummy_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + if (xds == NULL) + { + printf("XDS context isn't passed through to registered engine.\n"); + exit(1); + } + if (engine_context != (void*)42) + { + printf("Engine context isn't passed through to registered engine.\n"); + exit(1); + } + if (buffer == NULL) + { + printf("Buffer passed to engine is NULL.\n"); + exit(1); + } + if (buffer_size == 0) + { + printf("buffer_size passed to engine is zero!\n"); + exit(1); + } + if (used_buffer_size == NULL) + { + printf("used_buffer_size pointer passed to engine is NULL!\n"); + exit(1); + } + if (args == NULL) + { + printf("args pointer passed to engine is NULL!\n"); + exit(1); + } + *used_buffer_size = 6; + if (buffer_size < 6) + return XDS_ERR_OVERFLOW; + memmove(buffer, "Hallo ", 6); + return XDS_OK; + } + +int main() + { + xds_t* xds; + + /* Create XDS context. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + + /* Register the dummy callback under multiple names. */ + + if (xds_register(xds, "int", &dummy_engine, (void*)42) != XDS_OK || + xds_register(xds, "float", &dummy_engine, (void*)42) != XDS_OK || + xds_register(xds, "double", &dummy_engine, (void*)42) != XDS_OK || + xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + + /* Let's go and encode something. */ + + if (xds_encode(xds, "int:text double double float") != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (memcmp(xds->buffer, "Hallo Hallo Hallo Hallo Hallo ", 30) != 0) + { + printf("xds_encode() did not yield the expected result.\n"); + return 1; + } + + /* Clean up. */ + + xds_destroy(xds); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-engine-restart.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-engine-restart.c,v co -q -kk -p'1.2' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-engine-restart.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-engine-restart.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-engine-restart.c +++ - 2024-05-10 04:35:01.062934039 +0200 @@ -0,0 +1,122 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include "../internal.h" + +static int dummy_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + if (xds == NULL) + { + printf("XDS context isn't passed through to registered engine.\n"); + exit(1); + } + if (engine_context != (void*)42) + { + printf("Engine context isn't passed through to registered engine.\n"); + exit(1); + } + if (buffer == NULL) + { + printf("Buffer passed to engine is NULL.\n"); + exit(1); + } + if (buffer_size == 0) + { + printf("Buffer size passed to engine is zero!\n"); + exit(1); + } + if (used_buffer_size == NULL) + { + printf("used_buffer_size pointer passed to engine is NULL!\n"); + exit(1); + } + if (args == NULL) + { + printf("args pointer passed to engine is NULL!\n"); + exit(1); + } + if (va_arg(*args, int) != 42) + { + printf("The varadic argument is not what the engine expected!\n"); + exit(1); + } + if (buffer_size < 64) + return XDS_ERR_OVERFLOW; + else + *used_buffer_size = 64; + return XDS_OK; + } + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + /* Create an XDS context and set a buffer that's too small for the + first encode() call. Then call encode() with two parameters: + the one the engine is expecting and a different one after that. + The engine will complain if it sees the second value -- what + would mean that the args parameter was not resetted to the + original value before the engine is restarted after buffer + enlargement. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "int", &dummy_engine, (void*)42) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + buffer = malloc(32); + if (buffer == NULL) + { + printf("malloc() failed!\n"); + return 1; + } + buffer_size = 32; + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed!\n"); + return 1; + } + if (xds_encode(xds, "int", 42, 13) != XDS_OK) + { + printf("xds_encode() failed!"); + return 1; + } + xds_destroy(xds); + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-getbuffer.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-getbuffer.c,v co -q -kk -p'1.5' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-getbuffer.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-getbuffer.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-getbuffer.c +++ - 2024-05-10 04:35:01.065441547 +0200 @@ -0,0 +1,151 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include "../internal.h" + +static int dummy_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + if (buffer_size < 6) + return XDS_ERR_OVERFLOW; + else + *used_buffer_size = 6; + + memmove(buffer, "Hallo!", 6); + return XDS_OK; + } + +int main() + { + xds_t* xds; + char* old; + size_t old_len; + char* new; + size_t new_len; + + /* Create XDS context. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + + /* Register the dummy callback under multiple names. */ + + if (xds_register(xds, "text", &dummy_engine, (void*)42) != XDS_OK) + { + printf("Failed to register my encoding engine.\n"); + return 1; + } + + /* Encode something, then flush the buffer by calling + xds_getbuffer(), then encode something new and verify that the + old buffer hasn't ben overwritten and that the new one contains + the correct string. */ + + if (xds_encode(xds, "text text") != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&old, &old_len) != XDS_OK) + { + printf("xds_getbuffer() failed for the first buffer!\n"); + return 1; + } + if (xds_encode(xds, "text") != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&new, &new_len) != XDS_OK) + { + printf("xds_getbuffer() failed for the second buffer!\n"); + return 1; + } + if ((memcmp(old, "Hallo!Hallo!", 12) != 0 || old_len != 12) && + (memcmp(new, "Hallo!", 6) != 0 || new_len != 6)) + { + printf("xds_encode() did not yield the expected result.\n"); + return 1; + } + free(old); + free(new); + + /* Encode somthing, then get the buffer via XDS_LOAN and verify + the contents. Encode something new and compare the new content + with what we expect. */ + + if (xds_encode(xds, "text text") != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_LOAN, (void**)&old, &old_len) != XDS_OK) + { + printf("xds_getbuffer() failed for the first buffer!\n"); + return 1; + } + if (memcmp(old, "Hallo!Hallo!", 12) != 0 || old_len != 12) + { + printf("xds_encode() did not yield the expected result.\n"); + return 1; + } + if (xds_encode(xds, "text") != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_LOAN, (void**)&new, &new_len) != XDS_OK) + { + printf("xds_getbuffer() failed for the second buffer!\n"); + return 1; + } + if (old != new) + { + printf("xds_encode() allocated a new buffer even though we used XDS_LOAN.\n"); + return 1; + } + if (memcmp(new, "Hallo!", 6) != 0 || new_len != 6) + { + printf("xds_encode() did not yield the expected result.\n"); + return 1; + } + + /* Clean up. */ + + xds_destroy(xds); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-mystruct.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-mystruct.c,v co -q -kk -p'1.6' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-mystruct.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-mystruct.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-mystruct.c +++ - 2024-05-10 04:35:01.067927788 +0200 @@ -0,0 +1,168 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include "../internal.h" + +struct mystruct + { + xds_int32_t small; + xds_int64_t big; + xds_uint32_t positive; + }; + +static int encode_mystruct_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + struct mystruct* ms; + + assert(xds != NULL); + assert(buffer != NULL); + assert(buffer_size != 0); + assert(used_buffer_size != NULL); + assert(args != NULL); + + ms = va_arg(*args, struct mystruct*); + return xds_encode(xds, "int32 int64 uint32", ms->small, ms->big, ms->positive); + } + +static int decode_mystruct_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + struct mystruct* ms; + + assert(xds != NULL); + assert(buffer != NULL); + assert(buffer_size != 0); + assert(used_buffer_size != NULL); + assert(args != NULL); + + ms = va_arg(*args, struct mystruct*); + return xds_decode(xds, "int32 int64 uint32", &(ms->small), &(ms->big), &(ms->positive)); + } + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + struct mystruct ms, new_ms; + ms.small = -0x1234567; + ms.big = -0x1234567890abcdeLL; + ms.positive = 42; + + /* Encode our copy of mystruct using our encoding callback. Then + get a the buffer and destroy the context again. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "mystruct", &encode_mystruct_engine, NULL) != XDS_OK || + xds_register(xds, "int32", &xdr_encode_int32, NULL) != XDS_OK || + xds_register(xds, "int64", &xdr_encode_int64, NULL) != XDS_OK || + xds_register(xds, "uint32", &xdr_encode_uint32, NULL) != XDS_OK) + { + printf("Failed to register my encoding engines.\n"); + return 1; + } + buffer_size = 4; + buffer = malloc(buffer_size); + if (buffer == NULL) + { + printf("Failed to allocate memory for buffer.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed!\n"); + return 1; + } + if (xds_encode(xds, "mystruct", &ms) != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (xds->buffer_capacity <= buffer_size) + { + printf("Buffer should have been enlarged after xds_encode()!\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK) + { + printf("xds_getbuffer() failed!\n"); + return 1; + } + xds_destroy(xds); + printf("The encoded representation is %u bytes long.\n", buffer_size); + + /* Now create a decoding context and decode the whole thing again. */ + + xds = xds_init(XDS_DECODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + if (xds_register(xds, "mystruct", &decode_mystruct_engine, NULL) != XDS_OK || + xds_register(xds, "int32", &xdr_decode_int32, NULL) != XDS_OK || + xds_register(xds, "int64", &xdr_decode_int64, NULL) != XDS_OK || + xds_register(xds, "uint32", &xdr_decode_uint32, NULL) != XDS_OK) + { + printf("Failed to register my decoding engines.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed!\n"); + return 1; + } + if (xds_decode(xds, "mystruct", &new_ms) != XDS_OK) + { + printf("xds_decode() failed!\n"); + return 1; + } + xds_destroy(xds); + + /* Both structures must be identical. */ + + if (ms.small != new_ms.small || ms.big != new_ms.big || ms.positive != new_ms.positive) + { + printf("Decoded data does not match the original!\n"); + return 1; + } + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-register.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-register.c,v co -q -kk -p'1.7' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-register.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-register.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-register.c +++ - 2024-05-10 04:35:01.070472086 +0200 @@ -0,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 +#include +#include "../internal.h" + +static int dummy_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + return 0; + } + +int main() + { + const char* test_names[] = + { + "foo", + "bar", + "zarah", + "caesar", + "claus", + "heinz", + }; + size_t test_names_len = sizeof(test_names) / sizeof(char*); + xds_t* xds; + size_t i; + + /* Create context. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + + /* Register the dummy callback under an invalid name to see + whether the routine fails correctly. */ + + if (xds_register(xds, "abcdefh1230#", &dummy_engine, NULL) != XDS_ERR_INVALID_ARG) + { + printf("xds_register() illegally accepted an invalid name for the engine.\n"); + return 1; + } + + /* Register the dummy callback under multiple names. */ + + for(i = 0; i < test_names_len; ++i) + { + if (xds_register(xds, test_names[i], &dummy_engine, NULL) != XDS_OK) + { + printf("Failed to register engine for '%s'.\n", test_names[i]); + return 1; + } + } + + /* Register the callback again, overwriting an existing entry. */ + + if (xds_register(xds, "claus", &dummy_engine, NULL) != XDS_OK) + { + printf("Failed to re-register engine for 'claus'.\n"); + return 1; + } + + /* Ensure that everything is in alphabetical order. */ + + for (i = 1; i < xds->engines_len; ++i) + { + assert(xds->engines[i-1].name != NULL); + assert(xds->engines[i].name != NULL); + if (strcmp(xds->engines[i-1].name, xds->engines[i].name) >= 0) + { + printf("xds->engines is not in alphabetical order!\n"); + exit(1); + } + } + + /* Try to remove an unknown entry. */ + + if (xds_unregister(xds, "abacadabra") != XDS_ERR_UNKNOWN_ENGINE) + { + printf("xds_unregister() succeeded at removing 'abacadabra' even though it is not there.\n"); + exit(1); + } + + /* Remove an entry from the middle. */ + + if (xds_unregister(xds, test_names[test_names_len/2]) != XDS_OK) + { + printf("xds_unregister() failed to remove '%s'.\n", test_names[test_names_len/2]); + exit(1); + } + + /* Remove the last entry. */ + + assert(test_names_len > 0); + if (xds_unregister(xds, test_names[test_names_len-1]) != XDS_OK) + { + printf("xds_unregister() failed to remove '%s'.\n", test_names[test_names_len-1]); + exit(1); + } + + /* Remove the first entry. */ + + if (xds_unregister(xds, test_names[0]) != XDS_OK) + { + printf("xds_unregister() failed to remove '%s'.\n", test_names[0]); + exit(1); + } + + /* Clean up. */ + + xds_destroy(xds); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/regression-tests/xds-setbuffer.c RCS File: /v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-setbuffer.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/regression-tests/Attic/xds-setbuffer.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/regression-tests/xds-setbuffer.c' 2>/dev/null --- ossp-pkg/xds/regression-tests/xds-setbuffer.c +++ - 2024-05-10 04:35:01.073002602 +0200 @@ -0,0 +1,134 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include "../internal.h" + +static int dummy_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + assert(xds != NULL); + assert(buffer != NULL); + assert(buffer_size != 0); + assert(used_buffer_size != NULL); + assert(args != NULL); + if (buffer_size < 64) + return XDS_ERR_OVERFLOW; + else + *used_buffer_size = 64; + memset(buffer, 'a', 64); + return XDS_OK; + } + +int main() + { + xds_t* xds; + char* buffer; + size_t buffer_size; + + /* Create XDS context. */ + + xds = xds_init(XDS_ENCODE); + if (xds == NULL) + { + printf("Failed to initialize XDS context.\n"); + return 1; + } + + /* Register the callback. */ + + if (xds_register(xds, "dummy", &dummy_engine, NULL) != XDS_OK) + { + printf("Failed to register my encoding engine.\n"); + return 1; + } + + /* Give the library a buffer of 32 byte, call the engine once, get + the buffer back and see whether it has been enlarged or not. */ + + buffer_size = 32; + buffer = malloc(buffer_size); + if (buffer == NULL) + { + printf("Failed to allocate my memory.\n"); + return 1; + } + if (xds_setbuffer(xds, XDS_GIFT, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed!\n"); + return 1; + } + if (xds_encode(xds, "dummy") != XDS_OK) + { + printf("xds_encode() failed!\n"); + return 1; + } + if (xds_getbuffer(xds, XDS_GIFT, (void**)&buffer, &buffer_size) != XDS_OK) + { + printf("xds_getbuffer() failed!\n"); + return 1; + } + if (buffer_size < 64) + { + printf("xds_encode() did not enlarge the buffer after processing the callback\n"); + printf("even though all capacity was used up!\n"); + return 1; + } + + /* Loan the library a buffer we own, call the engine once to + exceed the buffer's capacity and check, whether the library + returns the correct error code. */ + + buffer = malloc(32); + if (buffer == NULL) + { + printf("Failed to allocate my memory.\n"); + return 1; + } + buffer_size = 32; + if (xds_setbuffer(xds, XDS_LOAN, buffer, buffer_size) != XDS_OK) + { + printf("xds_setbuffer() failed!\n"); + return 1; + } + if (xds_encode(xds, "dummy") != XDS_ERR_OVERFLOW) + { + printf("xds_encode() was supposed to fail with XDS_ERR_OVERFLOW!\n"); + return 1; + } + free(buffer); + + /* Clean up. */ + + xds_destroy(xds); + + /* Everything went fine. */ + + return 0; + } Index: ossp-pkg/xds/set-capacity.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/set-capacity.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/set-capacity.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/set-capacity.c' 2>/dev/null --- ossp-pkg/xds/set-capacity.c +++ - 2024-05-10 04:35:01.075515375 +0200 @@ -0,0 +1,62 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#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; + } Index: ossp-pkg/xds/setbuffer.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/setbuffer.c,v co -q -kk -p'1.7' '/v/ossp/cvs/ossp-pkg/xds/Attic/setbuffer.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/setbuffer.c' 2>/dev/null --- ossp-pkg/xds/setbuffer.c +++ - 2024-05-10 04:35:01.078006259 +0200 @@ -0,0 +1,61 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include "internal.h" + +int xds_setbuffer(xds_t* xds, xds_scope_t flag, void* buffer, size_t buffer_len) + { + /* Sanity checks. */ + + xds_check_parameter(xds != NULL); + xds_check_parameter(flag == XDS_GIFT || flag == XDS_LOAN); + xds_check_parameter((buffer != NULL && buffer_len != 0) || flag == XDS_GIFT); + + /* Free the old buffer if there is one. */ + + if (xds->buffer != NULL && xds->we_own_buffer) + free(xds->buffer); + xds->buffer_len = 0; + + if (flag == XDS_GIFT) + { + xds->buffer = buffer; + if (buffer == NULL) + xds->buffer_capacity = 0; + else + xds->buffer_capacity = buffer_len; + xds->we_own_buffer = XDS_TRUE; + } + else + { + xds->buffer = buffer; + xds->buffer_capacity = buffer_len; + xds->we_own_buffer = XDS_FALSE; + } + + return XDS_OK; + } Index: ossp-pkg/xds/unregister.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/unregister.c,v co -q -kk -p'1.5' '/v/ossp/cvs/ossp-pkg/xds/Attic/unregister.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/unregister.c' 2>/dev/null --- ossp-pkg/xds/unregister.c +++ - 2024-05-10 04:35:01.080465271 +0200 @@ -0,0 +1,73 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include +#include +#include +#include "internal.h" + +int xds_unregister(xds_t* xds, const char* name) + { + size_t pos; + int rc; + + /* Sanity checks. */ + + xds_check_parameter(xds != NULL); + xds_check_parameter(name != NULL); + for(pos = 0; name[pos] != '\0'; ++pos) + { + if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_') + return XDS_ERR_INVALID_ARG; + } + + /* Find the entry we're supposed to delete. */ + + if (!xds_find_engine(xds->engines, xds->engines_len, name, &pos)) + return XDS_ERR_UNKNOWN_ENGINE; + + /* Free the memory allocated for this entry and move the entries + behind it back if necessary. */ + + assert(xds->engines[pos].name != NULL); + free(xds->engines[pos].name); + memmove(&xds->engines[pos], &xds->engines[pos+1], (xds->engines_len - (pos + 1)) * sizeof(engine_map_t)); + --xds->engines_len; + + /* Lower capacity if necessary. */ + + rc = xds_set_capacity((void**)&xds->engines, + &xds->engines_capacity, + xds->engines_len, + sizeof(engine_map_t), + XDS_INITIAL_ENGINES_CAPACITY); + assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM); + if (rc != XDS_OK) + return rc; + + return XDS_OK; + } Index: ossp-pkg/xds/vdecode.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/vdecode.c,v co -q -kk -p'1.5' '/v/ossp/cvs/ossp-pkg/xds/Attic/vdecode.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/vdecode.c' 2>/dev/null --- ossp-pkg/xds/vdecode.c +++ - 2024-05-10 04:35:01.082969654 +0200 @@ -0,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 +#include +#include "internal.h" + +int xds_vdecode(xds_t* xds, const char* fmt_arg, va_list args) + { + size_t buffer_len_backup; + char* name; + char* p; + char* fmt; + int rc; + + /* Sanity checks. */ + + xds_check_parameter(xds != NULL); + xds_check_parameter(fmt_arg != NULL); + assert(xds->mode == XDS_DECODE); + if (xds->mode != XDS_DECODE) + return XDS_ERR_INVALID_MODE; + + /* Ensure we have a buffer to decode. */ + + if (xds->buffer == NULL || xds->buffer_capacity == 0) + return XDS_ERR_UNDERFLOW; + + /* Iterate through the items in the format string and execute the + apropriate engines. */ + + fmt = p = strdup(fmt_arg); + if (fmt == NULL) + return XDS_ERR_NO_MEM; + buffer_len_backup = xds->buffer_len; + for(name = p; *p != '\0'; name = p) + { + while(isalnum(*p) || *p == '-' || *p == '_') + ++p; + if (*p) + *p++ = '\0'; + else + *p = '\0'; + + if (strlen(name) > 0) + { + size_t pos; + size_t used_buffer_size = 0; + if (xds_find_engine(xds->engines, xds->engines_len, name, &pos)) + { + rc = (*xds->engines[pos].engine)(xds, + xds->engines[pos].context, + xds->buffer + xds->buffer_len, + xds->buffer_capacity - xds->buffer_len, + &used_buffer_size, + &args); + assert(rc <= 0); + if (rc == XDS_OK) + xds->buffer_len += used_buffer_size; + else + goto leave; + } + else + { + rc = XDS_ERR_UNKNOWN_ENGINE; + goto leave; + } + } + } + rc = XDS_OK; + + /* Clean up and leave. */ + leave: + free(fmt); + if (rc != XDS_OK) + xds->buffer_len = buffer_len_backup; + return rc; + } Index: ossp-pkg/xds/vencode.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/vencode.c,v co -q -kk -p'1.13' '/v/ossp/cvs/ossp-pkg/xds/Attic/vencode.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/vencode.c' 2>/dev/null --- ossp-pkg/xds/vencode.c +++ - 2024-05-10 04:35:01.085477579 +0200 @@ -0,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 +#include +#include "internal.h" + +int xds_vencode(xds_t* xds, const char* fmt_arg, va_list args) + { + va_list args_backup; + size_t buffer_len_backup; + char* name; + char* p; + char* fmt; + int rc; + + /* Sanity checks. */ + + xds_check_parameter(xds != NULL); + xds_check_parameter(fmt_arg != NULL); + assert(xds->mode == XDS_ENCODE); + if (xds->mode != XDS_ENCODE) + return XDS_ERR_INVALID_MODE; + + /* Ensure we have a buffer allocated ready for use. */ + + if (xds->buffer == NULL) + { /* allocate a new buffer */ + rc = xds_set_capacity((void**)&xds->buffer, + &xds->buffer_capacity, + XDS_INITIAL_BUFFER_CAPACITY, + sizeof(char), + XDS_INITIAL_BUFFER_CAPACITY); + assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM); + if (rc != XDS_OK) + return rc; + xds->buffer_len = 0; + xds->we_own_buffer = XDS_TRUE; + } + + /* Iterate through the items in the format string and execute the + apropriate engines. */ + + fmt = p = strdup(fmt_arg); + if (fmt == NULL) + return XDS_ERR_NO_MEM; + buffer_len_backup = xds->buffer_len; + for(name = p; *p != '\0'; name = p) + { + while(isalnum(*p) || *p == '-' || *p == '_') + ++p; + if (*p) + *p++ = '\0'; + else + *p = '\0'; + + if (strlen(name) > 0) + { + int restart_engine; + size_t used_buffer_size; + size_t pos; + + if (xds_find_engine(xds->engines, xds->engines_len, name, &pos) == XDS_FALSE) + { + rc = XDS_ERR_UNKNOWN_ENGINE; + goto leave; + } + + do + { + /* Ensure the buffer has free space. */ + + assert(xds->buffer_len <= xds->buffer_capacity); + if (xds->buffer_len == xds->buffer_capacity) + { + if (xds->we_own_buffer) + { + rc = xds_set_capacity((void**)&xds->buffer, + &xds->buffer_capacity, + xds->buffer_len + 1, + sizeof(char), + XDS_INITIAL_BUFFER_CAPACITY); + assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM); + if (rc != XDS_OK) + goto leave; + } + else + { + rc = XDS_ERR_OVERFLOW; + goto leave; + } + } + + /* Execute the engine. */ + + used_buffer_size = 0; + args_backup = args; + rc = (*xds->engines[pos].engine)(xds, + xds->engines[pos].context, + xds->buffer + xds->buffer_len, + xds->buffer_capacity - xds->buffer_len, + &used_buffer_size, + &args); + assert(rc <= 0); + if (rc == XDS_OK) + { + restart_engine = XDS_FALSE; + xds->buffer_len += used_buffer_size; + } + else if (rc == XDS_ERR_OVERFLOW) + { /* enlarge buffer */ + if (!xds->we_own_buffer) + goto leave; + + restart_engine = XDS_TRUE; + args = args_backup; + + rc = xds_set_capacity((void**)&xds->buffer, + &xds->buffer_capacity, + xds->buffer_capacity + ((used_buffer_size == 0) ? 1 : used_buffer_size), + sizeof(char), + XDS_INITIAL_BUFFER_CAPACITY); + assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM); + if (rc != XDS_OK) + goto leave; + } + else + goto leave; + } + while (restart_engine); + } + } + rc = XDS_OK; + + /* Clean up and leave. */ + leave: + free(fmt); + if (rc != XDS_OK) + xds->buffer_len = buffer_len_backup; + return rc; + } Index: ossp-pkg/xds/xdr-decode-double.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-double.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-double.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-double.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-double.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,33 +0,0 @@ -/* - 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 xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - return -1; - } Index: ossp-pkg/xds/xdr-decode-int32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-int32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-int32.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-int32.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-int32.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,71 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - xds_int32_t* value; - xds_uint32_t tmp; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - if (buffer_size < 4) - return XDS_ERR_UNDERFLOW; - - /* Get value and format it into the buffer. */ - - value = va_arg(*args, xds_int32_t*); - assert(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 4; - } Index: ossp-pkg/xds/xdr-decode-int64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-int64.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-int64.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-int64.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-int64.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,79 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - xds_int64_t* value; - xds_uint64_t tmp; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - if (buffer_size < 8) - return XDS_ERR_UNDERFLOW; - - /* Get value and format it into the buffer. */ - - value = va_arg(*args, xds_int64_t*); - assert(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 8; - } Index: ossp-pkg/xds/xdr-decode-octetstream.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-octetstream.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-octetstream.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-octetstream.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-octetstream.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,88 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -int xdr_decode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - void** p; - size_t* p_len; - size_t padding; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get pointers from the stack. */ - - p = va_arg(*args, void**); - p_len = va_arg(*args, size_t*); - assert(p != NULL); - assert(p_len != NULL); - - /* Read the size of the message. */ - - if (buffer_size >= 4) - { - *p_len = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8; - *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8; - *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8; - *p_len += ((xds_uint8_t*)buffer)[3]; - } - else - return XDS_ERR_UNDERFLOW; - - /* Calculate padding. */ - - padding = (4 - (*p_len & 0x03)) & 0x03; - - /* Do we have enough data?. */ - - if (buffer_size < 4 + *p_len + padding) - 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 4 + *p_len + padding; - } Index: ossp-pkg/xds/xdr-decode-string.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-string.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-string.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-string.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-string.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,89 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -int xdr_decode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - char** p; - size_t* p_len; - size_t padding; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get pointers from the stack. */ - - p = va_arg(*args, char**); - p_len = va_arg(*args, size_t*); - assert(p != NULL); - assert(p_len != NULL); - - /* Read the size of the message. */ - - if (buffer_size >= 4) - { - *p_len = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8; - *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8; - *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8; - *p_len += ((xds_uint8_t*)buffer)[3]; - } - else - return XDS_ERR_UNDERFLOW; - - /* Calculate padding. */ - - padding = (4 - (*p_len & 0x03)) & 0x03; - - /* Do we have enough data?. */ - - if (buffer_size < 4 + *p_len + padding) - 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 4 + *p_len + padding; - } Index: ossp-pkg/xds/xdr-decode-uint32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-uint32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-uint32.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-uint32.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-uint32.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,58 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - xds_uint32_t* value; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - if (buffer_size < 4) - return XDS_ERR_UNDERFLOW; - - /* Get value and format it into the buffer. */ - - value = va_arg(*args, xds_uint32_t*); - assert(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 4; - } Index: ossp-pkg/xds/xdr-decode-uint64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-uint64.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-decode-uint64.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-decode-uint64.c' 2>/dev/null --- ossp-pkg/xds/xdr-decode-uint64.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,62 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - xds_uint64_t* value; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - if (buffer_size < 8) - return XDS_ERR_UNDERFLOW; - - /* Get value and format it into the buffer. */ - - value = va_arg(*args, xds_uint64_t*); - assert(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 8; - } Index: ossp-pkg/xds/xdr-encode-double.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-double.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-double.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-double.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-double.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,33 +0,0 @@ -/* - 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 xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - return -1; - } Index: ossp-pkg/xds/xdr-encode-int32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-int32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-int32.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-int32.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-int32.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,64 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_encode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get value and format it into the buffer. */ - - if (buffer_size >= 4) - { - xds_uint32_t tmp; - xds_int32_t value = va_arg(*args, xds_uint32_t); - if (value < 0) - { - value = 0 - value; - tmp = 0 - (xds_uint32_t)value; - } - else - tmp = (xds_uint32_t)value; - ((xds_uint8_t*)buffer)[0] = (tmp >> 24) & 0x000000ff; - ((xds_uint8_t*)buffer)[1] = (tmp >> 16) & 0x000000ff; - ((xds_uint8_t*)buffer)[2] = (tmp >> 8) & 0x000000ff; - ((xds_uint8_t*)buffer)[3] = (tmp >> 0) & 0x000000ff; - } - - /* Done. */ - - return 4; - } Index: ossp-pkg/xds/xdr-encode-int64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-int64.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-int64.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-int64.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-int64.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,68 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get value and format it into the buffer. */ - - if (buffer_size >= 8) - { - xds_uint64_t tmp; - xds_int64_t value = va_arg(*args, xds_uint64_t); - if (value < 0) - { - value = 0 - value; - tmp = 0 - (xds_uint64_t)value; - } - else - tmp = (xds_uint64_t)value; - ((xds_uint8_t*)buffer)[0] = (tmp >> 56) & 0x000000ff; - ((xds_uint8_t*)buffer)[1] = (tmp >> 48) & 0x000000ff; - ((xds_uint8_t*)buffer)[2] = (tmp >> 40) & 0x000000ff; - ((xds_uint8_t*)buffer)[3] = (tmp >> 32) & 0x000000ff; - ((xds_uint8_t*)buffer)[4] = (tmp >> 24) & 0x000000ff; - ((xds_uint8_t*)buffer)[5] = (tmp >> 16) & 0x000000ff; - ((xds_uint8_t*)buffer)[6] = (tmp >> 8) & 0x000000ff; - ((xds_uint8_t*)buffer)[7] = (tmp >> 0) & 0x000000ff; - } - - /* Done. */ - - return 8; - } Index: ossp-pkg/xds/xdr-encode-octetstream.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-octetstream.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-octetstream.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-octetstream.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-octetstream.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,71 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -int xdr_encode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - xds_uint8_t* p; - size_t p_len; - size_t padding; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get value from stack and calculate the correct amount of - padding. */ - - p = (xds_uint8_t*)va_arg(*args, void*); - assert(p != NULL); - p_len = va_arg(*args, size_t); - padding = (4 - (p_len & 0x03)) & 0x03; - assert((p_len + padding) % 4 == 0); - - /* Format the values into the buffer. */ - - if (buffer_size >= 4 + p_len + padding) - { - ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff; - ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff; - ((xds_uint8_t*)buffer)[2] = (p_len >> 8) & 0x000000ff; - ((xds_uint8_t*)buffer)[3] = (p_len >> 0) & 0x000000ff; - memmove((xds_uint8_t*)buffer+4, p, p_len); - memset((xds_uint8_t*)buffer+4+p_len, 0, padding); - } - - /* Done. */ - - return 4 + p_len + padding; - } Index: ossp-pkg/xds/xdr-encode-string.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-string.c,v co -q -kk -p'1.5' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-string.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-string.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-string.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,71 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -int xdr_encode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - char* p; - size_t p_len; - size_t padding; - - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get value from stack and calculate the correct amount of - padding. */ - - p = va_arg(*args, char*); - assert(p != NULL); - p_len = strlen(p); - padding = (4 - (p_len & 0x03)) & 0x03; - assert((p_len + padding) % 4 == 0); - - /* Format the values into the buffer. */ - - if (buffer_size >= 4 + p_len + padding) - { - ((xds_uint8_t*)buffer)[0] = (p_len >> 24) & 0x000000ff; - ((xds_uint8_t*)buffer)[1] = (p_len >> 16) & 0x000000ff; - ((xds_uint8_t*)buffer)[2] = (p_len >> 8) & 0x000000ff; - ((xds_uint8_t*)buffer)[3] = (p_len >> 0) & 0x000000ff; - memmove((xds_uint8_t*)buffer+4, p, p_len); - memset((xds_uint8_t*)buffer+4+p_len, 0, padding); - } - - /* Done. */ - - return 4 + p_len + padding; - } Index: ossp-pkg/xds/xdr-encode-uint32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-uint32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-uint32.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-uint32.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-uint32.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,56 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get value and format it into the buffer. */ - - if (buffer_size >= 4) - { - xds_uint32_t value = va_arg(*args, xds_uint32_t); - ((xds_uint8_t*)buffer)[0] = (value >> 24) & 0x000000ff; - ((xds_uint8_t*)buffer)[1] = (value >> 16) & 0x000000ff; - ((xds_uint8_t*)buffer)[2] = (value >> 8) & 0x000000ff; - ((xds_uint8_t*)buffer)[3] = (value >> 0) & 0x000000ff; - } - - /* Done. */ - - return 4; - } Index: ossp-pkg/xds/xdr-encode-uint64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-uint64.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xdr-encode-uint64.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xdr-encode-uint64.c' 2>/dev/null --- ossp-pkg/xds/xdr-encode-uint64.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,60 +0,0 @@ -/* - 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 -#include "internal.h" - -int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - /* Get value and format it into the buffer. */ - - if (buffer_size >= 8) - { - xds_uint64_t value = va_arg(*args, xds_uint64_t); - ((xds_uint8_t*)buffer)[0] = (value >> 56) & 0x000000ff; - ((xds_uint8_t*)buffer)[1] = (value >> 48) & 0x000000ff; - ((xds_uint8_t*)buffer)[2] = (value >> 40) & 0x000000ff; - ((xds_uint8_t*)buffer)[3] = (value >> 32) & 0x000000ff; - ((xds_uint8_t*)buffer)[4] = (value >> 24) & 0x000000ff; - ((xds_uint8_t*)buffer)[5] = (value >> 16) & 0x000000ff; - ((xds_uint8_t*)buffer)[6] = (value >> 8) & 0x000000ff; - ((xds_uint8_t*)buffer)[7] = (value >> 0) & 0x000000ff; - } - - /* Done. */ - - return 8; - } Index: ossp-pkg/xds/xds.h.in RCS File: /v/ossp/cvs/ossp-pkg/xds/xds.h.in,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/xds/xds.h.in,v' 2>/dev/null --- xds.h.in 2001/07/31 15:27:45 1.6 +++ xds.h.in 2001/08/01 15:25:47 1.7 @@ -61,10 +61,8 @@ struct xds_context; typedef struct xds_context xds_t; -typedef int (*xds_engine_t)(xds_t* xds, - void* engine_context, - void* buffer, - size_t buffer_size, +typedef int (*xds_engine_t)(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, va_list* args); xds_t* xds_init(xds_mode_t); @@ -73,7 +71,7 @@ int xds_register(xds_t* xds, const char* name, xds_engine_t engine, void* engine_context); int xds_unregister(xds_t* xds, const char* name); -int xds_setbuffer(xds_t* xds, xds_scope_t flag, void* buffer, size_t buffer_len); +int xds_setbuffer(xds_t* xds, xds_scope_t flag, void* buffer, size_t buffer_len); int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_len); int xds_encode(xds_t* xds, const char* fmt, ...); @@ -81,44 +79,45 @@ int xds_vencode(xds_t* xds, const char* fmt, va_list args); int xds_vdecode(xds_t* xds, const char* fmt, va_list args); -int xdr_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_encode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); +#define declare_formatting_engine(x) \ + int x(xds_t* xds, void* engine_context, \ + void* buffer, size_t buffer_size, size_t* used_buffer_size, \ + va_list* args) + +declare_formatting_engine(xdr_encode_uint32); +declare_formatting_engine(xdr_decode_uint32); +declare_formatting_engine(xdr_encode_int32); +declare_formatting_engine(xdr_decode_int32); +declare_formatting_engine(xdr_encode_uint64); +declare_formatting_engine(xdr_decode_uint64); +declare_formatting_engine(xdr_encode_int64); +declare_formatting_engine(xdr_decode_int64); +declare_formatting_engine(xdr_encode_double); +declare_formatting_engine(xdr_decode_double); +declare_formatting_engine(xdr_encode_octetstream); +declare_formatting_engine(xdr_decode_octetstream); +declare_formatting_engine(xdr_encode_string); +declare_formatting_engine(xdr_decode_string); + +declare_formatting_engine(xml_encode_begin); +declare_formatting_engine(xml_decode_begin); +declare_formatting_engine(xml_encode_end); +declare_formatting_engine(xml_decode_end); +declare_formatting_engine(xml_encode_uint32); +declare_formatting_engine(xml_decode_uint32); +declare_formatting_engine(xml_encode_int32); +declare_formatting_engine(xml_decode_int32); +declare_formatting_engine(xml_encode_uint64); +declare_formatting_engine(xml_decode_uint64); +declare_formatting_engine(xml_encode_int64); +declare_formatting_engine(xml_decode_int64); +declare_formatting_engine(xml_encode_double); +declare_formatting_engine(xml_decode_double); +declare_formatting_engine(xml_encode_octetstream); +declare_formatting_engine(xml_decode_octetstream); +declare_formatting_engine(xml_encode_string); +declare_formatting_engine(xml_decode_string); -int xdr_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xdr_encode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_decode_octetstream(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xdr_encode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_decode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xdr_encode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xdr_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - - -int xml_encode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_int32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xml_encode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_uint32(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xml_encode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_int64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xml_encode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_uint64(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xml_encode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_double(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); - -int xml_encode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_encode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); -int xml_decode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args); +#undef declare_formatting_engine #endif /* !defined(__LIBXDS_H__) */ Index: ossp-pkg/xds/xml-decode-begin.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-begin.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-begin.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xml-decode-begin.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-begin.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,50 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -int xml_decode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - if (buffer_size < strlen(xds_xml_begin_text)) - return XDS_ERR_UNDERFLOW; - - if (strncasecmp(buffer, xds_xml_begin_text, strlen(xds_xml_begin_text)) != 0) - return XDS_ERR_TYPE_MISMATCH; - - return strlen(xds_xml_begin_text); - } Index: ossp-pkg/xds/xml-decode-double.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-double.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-double.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-decode-double.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-double.c +++ - 2024-05-10 04:35:01.131145717 +0200 @@ -0,0 +1,35 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include "internal.h" + +int xml_decode_double(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + return -1; + } Index: ossp-pkg/xds/xml-decode-end.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-end.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-end.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xml-decode-end.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-end.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,50 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -int xml_decode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - if (buffer_size < strlen(xds_xml_end_text)) - return XDS_ERR_UNDERFLOW; - - if (strncasecmp(buffer, xds_xml_end_text, strlen(xds_xml_end_text)) != 0) - return XDS_ERR_TYPE_MISMATCH; - - return strlen(xds_xml_end_text); - } Index: ossp-pkg/xds/xml-decode-int32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-int32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-int32.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-decode-int32.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-int32.c +++ - 2024-05-10 04:35:01.136152839 +0200 @@ -0,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 +#include +#include "internal.h" + +int xml_decode_int32(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_int32_t* value; + char* p; + int negative; + + xds_init_decoding_engine(7 + 8 + 1); + + /* Does the opening XML tag match? */ + + if (strncasecmp(buffer, "", 7) != 0) + return XDS_ERR_TYPE_MISMATCH; + + /* Decode the representation of the value. */ + + value = va_arg(*args, xds_int32_t*); + *value = 0; + p = (char*)buffer + 7; + if (*p == '-') + { + negative = XDS_TRUE; + ++p; + } + else + negative = XDS_FALSE; + while(isdigit(*p)) + { + if (p >= (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + *value *= 10; + *value += *p++ - '0'; + } + if (negative) + *value = 0 - *value; + + /* Does the closing XML tag match? */ + + if (p+8 > (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + else if (strncasecmp(p, "", 8) != 0) + return XDS_ERR_TYPE_MISMATCH; + + *used_buffer_size = p + 8 - (char*)buffer; + return XDS_OK; + } Index: ossp-pkg/xds/xml-decode-int64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-int64.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-int64.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-decode-int64.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-int64.c +++ - 2024-05-10 04:35:01.138605247 +0200 @@ -0,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 +#include +#include "internal.h" + +int xml_decode_int64(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_int64_t* value; + char* p; + int negative; + + xds_init_decoding_engine(7 + 8 + 1); + + /* Does the opening XML tag match? */ + + if (strncasecmp(buffer, "", 7) != 0) + return XDS_ERR_TYPE_MISMATCH; + + /* Decode the representation of the value. */ + + value = va_arg(*args, xds_int64_t*); + *value = 0; + p = (char*)buffer + 7; + if (*p == '-') + { + negative = XDS_TRUE; + ++p; + } + else + negative = XDS_FALSE; + while(isdigit(*p)) + { + if (p >= (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + *value *= 10; + *value += *p++ - '0'; + } + if (negative) + *value = 0 - *value; + + /* Does the closing XML tag match? */ + + if (p+8 > (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + else if (strncasecmp(p, "", 8) != 0) + return XDS_ERR_TYPE_MISMATCH; + + *used_buffer_size = p + 8 - (char*)buffer; + return XDS_OK; + } Index: ossp-pkg/xds/xml-decode-uint32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-uint32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-uint32.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-decode-uint32.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-uint32.c +++ - 2024-05-10 04:35:01.141098183 +0200 @@ -0,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 +#include +#include "internal.h" + +int xml_decode_uint32(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_uint32_t* value; + char* p; + + xds_init_decoding_engine(8 + 9 + 1); + + /* Does the opening XML tag match? */ + + if (strncasecmp(buffer, "", 8) != 0) + return XDS_ERR_TYPE_MISMATCH; + + /* Decode the representation of the value. */ + + value = va_arg(*args, xds_uint32_t*); + *value = 0; + p = (char*)buffer + 8; + while(isdigit(*p)) + { + if (p >= (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + *value *= 10; + *value += *p++ - '0'; + } + + /* Does the closing XML tag match? */ + + if (p+9 > (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + else if (strncasecmp(p, "", 9) != 0) + return XDS_ERR_TYPE_MISMATCH; + + *used_buffer_size = p + 9 - (char*)buffer; + return XDS_OK; + } Index: ossp-pkg/xds/xml-decode-uint64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-uint64.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-decode-uint64.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-decode-uint64.c' 2>/dev/null --- ossp-pkg/xds/xml-decode-uint64.c +++ - 2024-05-10 04:35:01.143593722 +0200 @@ -0,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 +#include +#include "internal.h" + +int xml_decode_uint64(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_uint64_t* value; + char* p; + + xds_init_decoding_engine(8 + 9 + 1); + + /* Does the opening XML tag match? */ + + if (strncasecmp(buffer, "", 8) != 0) + return XDS_ERR_TYPE_MISMATCH; + + /* Decode the representation of the value. */ + + value = va_arg(*args, xds_uint64_t*); + *value = 0; + p = (char*)buffer + 8; + while(isdigit(*p)) + { + if (p >= (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + *value *= 10; + *value += *p++ - '0'; + } + + /* Does the closing XML tag match? */ + + if (p+9 > (char*)buffer + buffer_size) + return XDS_ERR_UNDERFLOW; + else if (strncasecmp(p, "", 9) != 0) + return XDS_ERR_TYPE_MISMATCH; + + *used_buffer_size = p + 9 - (char*)buffer; + return XDS_OK; + } Index: ossp-pkg/xds/xml-encode-begin.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-begin.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-begin.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xml-encode-begin.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-begin.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,52 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -const char xds_xml_begin_text[] = \ - "\n" \ - "\n" \ - "\n"; - -int xml_encode_begin(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - if (buffer_size >= strlen(xds_xml_begin_text)) - memmove(buffer, xds_xml_begin_text, strlen(xds_xml_begin_text)); - - return strlen(xds_xml_begin_text); - } Index: ossp-pkg/xds/xml-encode-double.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-double.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-double.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-encode-double.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-double.c +++ - 2024-05-10 04:35:01.148665260 +0200 @@ -0,0 +1,35 @@ +/* + XDS - OSSP Extensible Data Serialization Library + Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) + Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) + + This file is part of OSSP XDS, an extensible data serialization + library which can be found at http://www.ossp.com/pkg/xds/. + + Permission to use, copy, modify, and distribute this software for + any purpose with or without fee is hereby granted, provided that + the above copyright notice and this permission notice appear in all + copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. +*/ + +#include "internal.h" + +int xml_encode_double(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + return -1; + } Index: ossp-pkg/xds/xml-encode-end.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-end.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-end.c,v' | diff -u - /dev/null -L'ossp-pkg/xds/xml-encode-end.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-end.c +++ /dev/null 2024-05-10 04:33:00.000000000 +0200 @@ -1,49 +0,0 @@ -/* - 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 -#include -#include "internal.h" - -const char xds_xml_end_text[] = "\n"; - -int xml_encode_end(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args) - { - /* Consistency checks. */ - - assert(xds != NULL); - assert(buffer != NULL); - assert(buffer_size != 0); - assert(args != NULL); - if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL) - return XDS_ERR_INVALID_ARG; - - if (buffer_size >= strlen(xds_xml_end_text)) - memmove(buffer, xds_xml_end_text, strlen(xds_xml_end_text)); - - return strlen(xds_xml_end_text); - } Index: ossp-pkg/xds/xml-encode-int32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-int32.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-int32.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-encode-int32.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-int32.c +++ - 2024-05-10 04:35:01.153687960 +0200 @@ -0,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 +#include "internal.h" + +int xml_encode_int32(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_int32_t value; + char buf[32]; + size_t i, j; + char* p; + int negative; + + xds_init_encoding_engine(7 + 8 + 11); + + /* Get the value and format it into our buffer. Keep track of the + length of the formatted result. */ + + value = va_arg(*args, xds_int32_t); + if (value < 0) + { + negative = XDS_TRUE; + value = 0 - value; + } + else + negative = XDS_FALSE; + i = 0; + do + { + unsigned char remainder = value % 10; + value = value / 10; + buf[i++] = '0' + remainder; + } + while (value != 0); + if (negative) + buf[i++] = '-'; + + /* Now that we know the correct size of our data's representation, + write it into the buffer. */ + + *used_buffer_size = 7 + 8 + i; + p = buffer; + memmove(p, "", 7); + p += 7; + for (j = i; j > 0; ) + { + *p++ = buf[--j]; + } + memmove(p, "", 8); + + return XDS_OK; + } Index: ossp-pkg/xds/xml-encode-int64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-int64.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-int64.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-encode-int64.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-int64.c +++ - 2024-05-10 04:35:01.156157981 +0200 @@ -0,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 +#include "internal.h" + +int xml_encode_int64(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_int64_t value; + char buf[64]; + size_t i, j; + char* p; + int negative; + + xds_init_encoding_engine(7 + 8 + 21); + + /* Format value into our buffer. */ + + value = va_arg(*args, xds_int64_t); + if (value < 0) + { + negative = XDS_TRUE; + value = 0 - value; + } + else + negative = XDS_FALSE; + i = 0; + do + { + unsigned char remainder = value % 10; + value = value / 10; + buf[i++] = '0' + remainder; + } + while (value != 0); + if (negative) + buf[i++] = '-'; + + /* Store the correct buffer size. */ + + *used_buffer_size = 7 + 8 + i; + + /* Write result into the buffer. */ + + p = buffer; + memmove(p, "", 7); + p += 7; + for (j = i; j > 0; ) + { + *p++ = buf[--j]; + } + memmove(p, "", 8); + + return XDS_OK; + } Index: ossp-pkg/xds/xml-encode-uint32.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-uint32.c,v co -q -kk -p'1.3' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-uint32.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-encode-uint32.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-uint32.c +++ - 2024-05-10 04:35:01.158640797 +0200 @@ -0,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 +#include "internal.h" + +int xml_encode_uint32(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_uint32_t value; + char buf[32]; + size_t i, j; + char* p; + + xds_init_encoding_engine(8 + 9 + 10); + + /* Format value into our buffer. */ + + value = va_arg(*args, xds_uint32_t); + i = 0; + do + { + unsigned char remainder = value % 10; + value = value / 10; + buf[i++] = '0' + remainder; + } + while (value != 0); + + /* Store the correct buffer size. */ + + *used_buffer_size = 8 + 9 + i; + + /* Write result into the buffer. */ + + p = buffer; + memmove(p, "", 8); + p += 8; + for (j = i; j > 0; ) + { + *p++ = buf[--j]; + } + memmove(p, "", 9); + + return XDS_OK; + } Index: ossp-pkg/xds/xml-encode-uint64.c RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-uint64.c,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/xml-encode-uint64.c,v' | diff -u /dev/null - -L'ossp-pkg/xds/xml-encode-uint64.c' 2>/dev/null --- ossp-pkg/xds/xml-encode-uint64.c +++ - 2024-05-10 04:35:01.161095235 +0200 @@ -0,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 +#include "internal.h" + +int xml_encode_uint64(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, size_t* used_buffer_size, + va_list* args) + { + xds_uint64_t value; + char buf[64]; + size_t i, j; + char* p; + + xds_init_encoding_engine(8 + 9 + 20); + + /* Format value into our buffer. */ + + value = va_arg(*args, xds_uint64_t); + i = 0; + do + { + unsigned char remainder = value % 10; + value = value / 10; + buf[i++] = '0' + remainder; + } + while (value != 0); + + /* Store the correct buffer size. */ + + *used_buffer_size = 8 + 9 + i; + + /* Write result into the buffer. */ + + p = buffer; + memmove(p, "", 8); + p += 8; + for (j = i; j > 0; ) + { + *p++ = buf[--j]; + } + memmove(p, "", 9); + + return XDS_OK; + }