Index: ossp-pkg/xds/Makefile RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/Makefile,v co -q -kk -p'1.4' '/v/ossp/cvs/ossp-pkg/xds/Attic/Makefile,v' | diff -u /dev/null - -L'ossp-pkg/xds/Makefile' 2>/dev/null --- ossp-pkg/xds/Makefile +++ - 2024-05-12 14:24:29.655466176 +0200 @@ -0,0 +1,34 @@ +# Build libxds and support/test programs. + +CC = gcc +CXX = g++ + +WARNFLAGS = -Wall -ansi -pedantic +OPTFLAGS = -O3 -pipe + +CPPFLAGS = +CFLAGS = +CXXFLAGS = +LDFLAGS = + +.c.o: + $(CC) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CFLAGS) -c $< + +.cpp.o: + $(CXX) $(CPPFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(CXXFLAGS) -c $< + +all: test xds.3 + +test: test.o + $(CC) $(LDFLAGS) -o $@ test.o + +xds.3: xds.pod + pod2man --section=3 --center="XDS Library Programmer API " $< >$@ + +clean:: + rm -f test.o test + rm -f xds.3 + +# Dependencies + +test.o: test.c xds.h Index: ossp-pkg/xds/xds.h RCS File: /v/ossp/cvs/ossp-pkg/xds/Attic/xds.h,v co -q -kk -p'1.12' '/v/ossp/cvs/ossp-pkg/xds/Attic/xds.h,v' | diff -u /dev/null - -L'ossp-pkg/xds/xds.h' 2>/dev/null --- ossp-pkg/xds/xds.h +++ - 2024-05-12 14:24:29.658109447 +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. + + xds.h: C API +*/ + +#ifndef __LIBXDS_H__ +#define __LIBXDS_H__ + +#include +#include + +enum + { + XDS_OK = 0, + XDS_ERR_NO_MEM = -1, + XDS_ERR_OVERFLOW = -2, + XDS_ERR_INVALID_ARG = -3, + XDS_ERR_TYPE_MISMATCH = -4, + XDS_ERR_UNKNOW_ENGINE = -5 + }; +typedef enum { XDS_ENCODE, XDS_DECODE } xds_mode_t; +typedef enum { XDS_LOAN, XDS_GIFT } xds_scope_t; + +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, + va_list args); + +xds_t* xds_init(xds_mode_t); +void xds_destroy(xds_t* xds); + +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_size); +int xds_getbuffer(xds_t* xds, xds_scope_t flag, void** buffer, size_t* buffer_size); + +int xds_encode(xds_t* xds, const char* fmt, ...); +int xds_decode(xds_t* xds, const char* fmt, ...); +int xds_vencode(xds_t* xds, const char* fmt, va_list args); +int xds_vdecode(xds_t* xds, const char* fmt, va_list args); + +#endif /* !defined(__LIBXDS_H__) */ Index: ossp-pkg/xds/xds.pod RCS File: /v/ossp/cvs/ossp-pkg/xds/xds.pod,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/xds/xds.pod,v' | diff -u /dev/null - -L'ossp-pkg/xds/xds.pod' 2>/dev/null --- ossp-pkg/xds/xds.pod +++ - 2024-05-12 14:24:29.660740062 +0200 @@ -0,0 +1,98 @@ +=pod + +=head1 NAME + +xds - eXtendable Data Serialization + +=head1 SYNOPSIS + + +=head1 DESCRIPTION + +=over 4 + +=item xds_t* B(xds_mode_t I); + +Valid settings for I are B and B. If +successful, a valid handle is returned -- B otherwise. If the +routine fails, the system variable B is set apropriately. + +=item void B(xds_t* I); + +Free all internally allocated resources associated with this context. +I must be a handle obtained by calling B. + +=item int B(xds_t* I, const char* I, xds_engine_t I, void* I); + +Register the function I as formatting engine in context I +under the name I. The function must have the following +prototype: + + int my_engine(xds_t* xds, void* engine_context, + void* buffer, size_t buffer_size, + va_list args); + +It must gather its values from I and encode/decode them into +I. The encoded/decoded representation must not take up more +than I byte of memory, because that's the maximum I can +hold. If the buffer is too small, I must return +B. In case of no error, I must return +B. The variable I is passed through to the +function every time it is called; it is not touched in any way by the +xds library. + +=item int B(xds_t* I, const char* I); + +Remove encoding/decoding engine I from context I. The +function will return B if successful and +B if I is not a registered engine. + +=item int B(xds_t* I, xds_scope_t I, void* I, size_t I); + +Encoding mode: Set internal buffer used in context I to +I. The buffer has a capacity of I byte. I +may be set to B or B. A "loaned" buffer is one +that is owned by the application; xds will use it, but it will not +B the buffer nor will it try to B it if it's too small. +A buffer given to xds as a "gift" is henceforth owned by xds and may +be Bd or Bed as the library sees fit. If I is +B, I must be a pointer obtained from calling +B or a comparable system routine. Calling B +with a I of B will cause the xds library to allocate a +buffer of its own. I is ignored in this case. + +Decoding mode: I contains the encoded representation of the +data to be used for following B calls. The encoded data is +I byte long. Unlike in encoding mode, such a buffer is +not modified, hence there is no need to extend the buffer. If I +is set to B, the library will B I when +the context is destroyed. + +=item int B(xds_t* I, xds_scope_t flag, void** buffer, size_t* buffer_size); + +This routine will write the address and size of the internal buffer in +context I to I and I. The I parameter +determines who owns the buffer after that; setting I to +B means that the buffer is owned by the xds library and that +the user may not rely on its contents still being there after another +xds library function call. Furthermore, calling B will +flush the registered buffer, meaning that coming B calls +will start at the beginning and potentially overwrite the buffer +contents. + +Setting I to B means that the returned buffer is owned +by the application programmer from now on, it is no longer modified or +used in any way by the library. + + +=item int B(xds_t* I, const char* I, ...); + +=item int B(xds_t* I, const char* I, ...); + +=item int B(xds_t* I, const char* I, va_list I); + +=item int B(xds_t* I, const char* I, va_list I); + +=back + +=cut