Index: ossp-pkg/xds/xds.h.in RCS File: /v/ossp/cvs/ossp-pkg/xds/xds.h.in,v rcsdiff -q -kk '-r1.10' '-r1.11' -u '/v/ossp/cvs/ossp-pkg/xds/xds.h.in,v' 2>/dev/null --- xds.h.in 2001/08/02 17:24:49 1.10 +++ xds.h.in 2001/08/08 19:29:26 1.11 @@ -1,59 +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. - - xds.h: C API +** 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__ +#ifndef __XDS_H__ +#define __XDS_H__ #include #include #include #include -#define XDS_TRUE (1==1) +#define XDS_TRUE (1==1) #define XDS_FALSE (1!=1) @have_64_bit_support@ -typedef @xds_uint8_t@ xds_uint8_t; -typedef @xds_int8_t@ xds_int8_t; +typedef @xds_uint8_t@ xds_uint8_t; +typedef @xds_int8_t@ xds_int8_t; typedef @xds_uint16_t@ xds_uint16_t; -typedef @xds_int16_t@ xds_int16_t; +typedef @xds_int16_t@ xds_int16_t; typedef @xds_uint32_t@ xds_uint32_t; -typedef @xds_int32_t@ xds_int32_t; +typedef @xds_int32_t@ xds_int32_t; #ifdef XDS_HAVE_64_BIT_SUPPORT typedef @xds_uint64_t@ xds_uint64_t; -typedef @xds_int64_t@ xds_int64_t; +typedef @xds_int64_t@ xds_int64_t; #endif -typedef double xds_double_t; +typedef double xds_double_t; -enum - { +enum { XDS_OK = 0, XDS_ERR_NO_MEM = -1, XDS_ERR_OVERFLOW = -2, @@ -63,69 +62,62 @@ XDS_ERR_INVALID_MODE = -6, XDS_ERR_UNDERFLOW = -7, XDS_ERR_UNKNOWN = -8 - }; +}; + 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, size_t* used_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_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, ...); -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); - -#define xds_check_parameter(condition) \ - do \ - { \ - assert(condition); \ - if (!(condition)) \ - return XDS_ERR_INVALID_ARG; \ +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); +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_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, ...); +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); + +#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; \ +#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; \ +#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) -#define xds_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) +#define xds_declare_formatting_engine(func) \ + int func(xds_t *, void *, void *, size_t, size_t *, va_list *) xds_declare_formatting_engine(xdr_encode_uint32); xds_declare_formatting_engine(xdr_decode_uint32); @@ -164,9 +156,11 @@ xds_declare_formatting_engine(xml_decode_octetstream); xds_declare_formatting_engine(xml_encode_string); xds_declare_formatting_engine(xml_decode_string); + extern const char xds_xml_begin_text[]; extern const char xds_xml_end_text[]; extern const char xds_base64[]; extern const char xds_pad64; -#endif /* !defined(__LIBXDS_H__) */ +#endif /* __XDS_H__ */ + Index: ossp-pkg/xds/xds_p.h RCS File: /v/ossp/cvs/ossp-pkg/xds/xds_p.h,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/xds/xds_p.h,v' 2>/dev/null --- xds_p.h 2001/08/08 19:15:23 1.1 +++ xds_p.h 2001/08/08 19:29:26 1.2 @@ -1,35 +1,38 @@ -/* - * XDS - OSSP Extensible Data Serialization Library Copyright (c) 2001 The - * OSSP Project (http://www.ossp.org/) Copyright (c) 2001 Cable & Wireless - * Deutschland (http://www.cw.com/de/) - * - * This file is part of OSSP XDS, an extensible data serialization library - * which can be found at http://www.ossp.com/pkg/xds/. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * internal.h: internal C API */ +/* +** 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_p.h: internal C API +*/ -#ifndef __INTERNAL_H__ -#define __INTERNAL_H__ +#ifndef __XDS_P_H__ +#define __XDS_P_H__ #include "xds.h" -#define XDS_INITIAL_BUFFER_CAPACITY 512 +#define XDS_INITIAL_BUFFER_CAPACITY 512 #define XDS_INITIAL_ENGINES_CAPACITY 32 typedef struct { @@ -40,21 +43,20 @@ struct xds_context { xds_mode_t mode; - char *buffer; size_t buffer_len; size_t buffer_capacity; int we_own_buffer; - engine_map_t *engines; size_t engines_len; size_t engines_capacity; }; -int xds_find_engine(const engine_map_t * engines, size_t last, - const char *name, size_t * pos); -int xds_set_capacity(void **array, size_t * array_capacity, +int xds_find_engine(const engine_map_t *engines, size_t last, + const char *name, size_t *pos); +int xds_set_capacity(void **array, size_t *array_capacity, size_t new_capacity, size_t elem_size, size_t initial_capacity); -#endif /* !defined(__INTERNAL_H__) */ +#endif /* __XDS_P_H__ */ +