head 1.8; access; symbols last-version-in-peti-style:1.7 callback-semantic-rewrite:1.4.0.2; locks; strict; comment @ * @; 1.8 date 2001.08.08.19.15.23; author rse; state dead; branches; next 1.7; 1.7 date 2001.08.08.11.50.16; author simons; state Exp; branches; next 1.6; 1.6 date 2001.08.02.10.51.57; author simons; state Exp; branches; next 1.5; 1.5 date 2001.08.01.15.25.47; author simons; state Exp; branches; next 1.4; 1.4 date 2001.07.09.17.23.38; author simons; state Exp; branches 1.4.2.1; next 1.3; 1.3 date 2001.07.08.16.01.37; author simons; state Exp; branches; next 1.2; 1.2 date 2001.07.08.15.58.13; author simons; state Exp; branches; next 1.1; 1.1 date 2001.07.04.15.58.51; author simons; state Exp; branches; next ; 1.4.2.1 date 2001.08.01.09.55.58; author simons; state Exp; branches; next 1.4.2.2; 1.4.2.2 date 2001.08.01.13.26.29; author simons; state Exp; branches; next ; desc @@ 1.8 log @First cut of the ruthless style adjustments to OSSP XDS: o adjust source tree to follow OSSP source tree style by heavily combining sources into smaller sets (needs more work when still missing parts are added later) o automatic re-indentation of sources with GNU indent (still needs manual review and adjustments; will follow) These two heavy steps were mostly done automatically with the help of two helper scripts written in Perl. So expect more manual adjustments to follow... @ text @/* 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_unregister(xds_t* xds, const char* name) { size_t pos; int rc; /* Sanity checks. */ xds_check_parameter(xds != NULL); xds_check_parameter(name != NULL); for(pos = 0; name[pos] != '\0'; ++pos) { if (!isalnum((int)name[pos]) && name[pos] != '-' && name[pos] != '_') return XDS_ERR_INVALID_ARG; } /* Find the entry we're supposed to delete. */ if (!xds_find_engine(xds->engines, xds->engines_len, name, &pos)) return XDS_ERR_UNKNOWN_ENGINE; /* Free the memory allocated for this entry and move the entries behind it back if necessary. */ assert(xds->engines[pos].name != NULL); free(xds->engines[pos].name); memmove(&xds->engines[pos], &xds->engines[pos+1], (xds->engines_len - (pos + 1)) * sizeof(engine_map_t)); --xds->engines_len; /* Lower capacity if necessary. */ rc = xds_set_capacity((void**)&xds->engines, &xds->engines_capacity, xds->engines_len, sizeof(engine_map_t), XDS_INITIAL_ENGINES_CAPACITY); assert(rc == XDS_OK || rc == XDS_ERR_NO_MEM); if (rc != XDS_OK) return rc; return XDS_OK; } @ 1.7 log @Fixed warnings that complained about feeding a "char" into the isxxx() routines, which expect an "int". @ text @@ 1.6 log @Remove stdlib.h include here because it is included in xds.h already. @ text @d43 1 a43 1 if (!isalnum(name[pos]) && name[pos] != '-' && name[pos] != '_') @ 1.5 log @Merged the whole contents of branch "callback-semantic-rewrite" into the main branch. The changes there include: - A change of the callback semantics; callbacks do now return XDS_ERR_(UNDER|OVER)FLOW in case the buffer size doesn't fit. Rather than passing the differing byte size through the return code, it is stored in the location used_buffer_size points to -- a new parameter provided to all callbacks. In order to implement this, the framework, all callbacks and most of the test suits had to be adapted. - internal.h now provides the macro xds_check_parameter(), which can be used to verify the contents of function parameters with assert() and if in one line. If assert()s are deactivated, the routine will still return XDS_ERR_INVALID_ARG. Because of this change, internal.h now includes the system header assert.h. This means that this include coulde be removed from almost all modules. - internal.h now provides the macros xds_init_(en|de)coding_engine(). These can be used to comfortably verify a callback's parameters and to verify the buffer size. All engines have been rewritten to use these. @ text @a27 1 #include @ 1.4 log @Added test that return XDS_ERR_INVALID_ARG if the name argument contains illegal characters. Allowed are: "[a-zA-Z0-9_-]". @ text @a30 1 #include d40 2 a41 4 assert(xds != NULL); assert(name != NULL); if (xds == NULL || name == NULL) return XDS_ERR_INVALID_ARG; @ 1.4.2.1 log @Added xds_check_parameter() macro to short-cut the assert() and if-statements at the begining of every routine. Also rewrote some modules to take advantage of that macro. @ text @d41 4 a44 2 xds_check_parameter(xds != NULL); xds_check_parameter(name != NULL); @ 1.4.2.2 log @Now that internal.h includes assert.h we don't need to do that anymore. @ text @d31 1 @ 1.3 log @Messed up declaration of "rc" when doing cut & paste. Fixed that. @ text @d30 1 d45 5 @ 1.2 log @Implemented xds_unregister() function and added apropriate test cases. @ text @d36 1 d60 5 a64 5 int rc = xds_set_capacity((void**)&xds->engines, &xds->engines_capacity, xds->engines_len, sizeof(engine_map_t), XDS_INITIAL_ENGINES_CAPACITY); @ 1.1 log @Added function stubs that return errors when called. @ text @d28 3 d35 34 a68 1 return XDS_ERR_UNKNOWN_ENGINE; @