diff --git a/cde/configure.ac b/cde/configure.ac index 13fdab9f4..f16acd90f 100644 --- a/cde/configure.ac +++ b/cde/configure.ac @@ -378,7 +378,10 @@ AC_PATH_PROG(KSH, ksh) if test -z "$ac_cv_path_KSH"; then AC_PATH_PROG(KSH, ksh93) if test -z "$ac_cv_path_KSH"; then - MISSING_PROGS="[ksh or ksh93] ${MISSING_PROGS}" + AC_PATH_PROG(KSH, mksh) + if test -z "$ac_cv_path_KSH"; then + MISSING_PROGS="[ksh or ksh93] ${MISSING_PROGS}" + fi fi fi @@ -492,6 +495,12 @@ AC_CHECK_LIB(jpeg, jpeg_read_header, [JPEGLIB="-ljpeg"], [${EXTRA_INCS} ${EXTRA_LIBS}]) AC_SUBST(JPEGLIB) +dnl lmdb +AC_CHECK_LIB(lmdb, mdb_version, [LMDBLIB="-llmdb"], + [AC_MSG_ERROR([liblmdb not found, please install it])], + [${EXTRA_INCS} ${EXTRA_LIBS}]) +AC_SUBST(LMDBLIB) + dnl Setup XTOOLLIB - we do it in this specific order to avoid ordering dnl issues XTOOLLIB="" @@ -633,7 +642,6 @@ lib/DtMmdb/HardCopy/Makefile lib/DtMmdb/StyleSheet/Makefile lib/DtMmdb/api/Makefile lib/DtMmdb/btree/Makefile -lib/DtMmdb/btree_berkeley/Makefile lib/DtMmdb/compression/Makefile lib/DtMmdb/diskhash/Makefile lib/DtMmdb/dstr/Makefile diff --git a/cde/contrib/rc/netbsd/dtlogin b/cde/contrib/rc/netbsd/dtlogin new file mode 100755 index 000000000..5fafbfb8e --- /dev/null +++ b/cde/contrib/rc/netbsd/dtlogin @@ -0,0 +1,16 @@ +#!/bin/sh +# PROVIDE: dtlogin +# REQUIRE: DAEMON LOGIN wscons +# KEYWORD: shutdown + +$_rc_subr_loaded . /etc/rc.subr + +name="dtlogin" +rcvar=$name +command="/usr/dt/bin/${name}" +command_args="-daemon" +pidfile=/var/dt/Xpid +extra_commands="" + +load_rc_config $name +run_rc_command "$1" diff --git a/cde/contrib/rc/openbsd/cmsd b/cde/contrib/rc/openbsd/cmsd new file mode 100755 index 000000000..407a821f8 --- /dev/null +++ b/cde/contrib/rc/openbsd/cmsd @@ -0,0 +1,11 @@ +daemon="/usr/dt/bin/rpc.cmsd &" + +. /etc/rc.d/rc.subr + +pexp="rpc.cmsd: ${daemon}${daemon_flags:+ ${daemon_flags}} \[listener\].*" + +rc_reload() { + ${daemon} ${daemon_flags} -t && pkill -HUP -xf "${pexp}" +} + +rc_cmd $1 diff --git a/cde/contrib/rc/openbsd/dtlogin b/cde/contrib/rc/openbsd/dtlogin new file mode 100755 index 000000000..73838e22a --- /dev/null +++ b/cde/contrib/rc/openbsd/dtlogin @@ -0,0 +1,25 @@ +#!/bin/ksh + +daemon="/usr/dt/bin/dtlogin" + +. /etc/rc.d/rc.subr + +rc_reload=NO + +if [ -n "${INRC}" ]; then +# on boot: make sure we don't hang in _rc_wait +_rc_wait() { + return 0 +} +# on boot: wait for ttys to be initialized +rc_start() { + ( local i=0 + while ! pgrep -qf "^/usr/libexec/getty "; do + sleep 1 + [ $((i++)) -ge 10 ] && return 1 + done + ${rcexec} "${daemon} ${daemon_flags}" ) & +} +fi + +rc_cmd $1 diff --git a/cde/contrib/rc/systemd/dtlogin.service b/cde/contrib/rc/systemd/dtlogin.service new file mode 100644 index 000000000..cdf5dbfe0 --- /dev/null +++ b/cde/contrib/rc/systemd/dtlogin.service @@ -0,0 +1,11 @@ +[Unit] +Description=CDE login service +Documentation=man:dtlogin(1) +Requires=rpcbind.service +After=systemd-user-sessions.service + +[Service] +ExecStart=/usr/dt/bin/dtlogin -nodaemon + +[Install] +Alias=display-manager.service diff --git a/cde/include/Dt/dproto.h b/cde/include/Dt/dproto.h index 2baa462f7..37f592a3a 100644 --- a/cde/include/Dt/dproto.h +++ b/cde/include/Dt/dproto.h @@ -189,10 +189,10 @@ int d_cmtype(int, int *, int); /* cmtype.c */ int d_connect(int, int); /* connect.c */ int d_cotype(int, int *, int); /* cotype.c */ int d_crget(DB_ADDR *, int); /* crget.c */ -int d_crread(long, char *, int); /* crread.c */ +int d_crread(long, void *, int); /* crread.c */ int d_crset(DB_ADDR *, int); /* crset.c */ int d_crtype(int *, int); /* crtype.c */ -int d_crwrite(long, char *, int); /* crwrite.c */ +int d_crwrite(long, void *, int); /* crwrite.c */ int d_csmget(int, DB_ADDR *, int); /* csmget.c */ int d_csmread(int, long, char *, int); /* csmread.c */ @@ -217,7 +217,7 @@ int d_recnext(int); /* recnext.c */ int d_recprev(int); /* recprev.c */ int d_destroy(const char *); /* destroy.c */ int d_discon(int, int); /* discon.c */ -int d_fillnew(int, const char *, int); /* fillnew.c */ +int d_fillnew(int, const void *, int); /* fillnew.c */ int d_findco(int, int); /* findco.c */ int d_findfm(int, int); /* findfm.c */ int d_findlm(int, int); /* findlm.c */ @@ -258,9 +258,9 @@ int d_reclast(int, int); /* reclast.c */ int d_reclock(int, char *, int); /* dblfcns.c */ int d_reclstat(int, char *, int); /* dblfcns.c */ int d_recover(const char *); /* recover.c */ -int d_recread(char *, int); /* recread.c */ +int d_recread(void *, int); /* recread.c */ int d_recset(int, int); /* recset.c */ -int d_recwrite(const char *, int); /* recwrite.c */ +int d_recwrite(const void *, int); /* recwrite.c */ int d_renfile(const char *dbn, FILE_NO fno, const char *fnm); /* renfile.c */ int d_retries(int); /* dblfcns.c */ int d_rlbclr(void); /* dblfcns.c */ diff --git a/cde/lib/DtMmdb/Makefile.am b/cde/lib/DtMmdb/Makefile.am index b52f2d0e6..d4a56fa0e 100644 --- a/cde/lib/DtMmdb/Makefile.am +++ b/cde/lib/DtMmdb/Makefile.am @@ -4,7 +4,6 @@ SUBDIRS = HardCopy \ StyleSheet \ api \ btree \ - btree_berkeley \ compression \ diskhash \ dstr \ @@ -29,7 +28,6 @@ libDtMmdb_la_LIBADD = HardCopy/libHardCopy.la \ StyleSheet/libStyleSheet.la \ api/libapi.la \ btree/libbtree.la \ - btree_berkeley/libbtree_berkeley.la \ compression/libcompression.la \ diskhash/libdiskhash.la \ dstr/libdstr.la \ diff --git a/cde/lib/DtMmdb/btree/Makefile.am b/cde/lib/DtMmdb/btree/Makefile.am index 5d60eabe4..e48cb1cc4 100644 --- a/cde/lib/DtMmdb/btree/Makefile.am +++ b/cde/lib/DtMmdb/btree/Makefile.am @@ -4,4 +4,4 @@ noinst_LTLIBRARIES = libbtree.la libbtree_la_CXXFLAGS = -I.. -libbtree_la_SOURCES = mmdb_btree.C +libbtree_la_SOURCES = btree.C diff --git a/cde/lib/DtMmdb/btree/mmdb_btree.C b/cde/lib/DtMmdb/btree/btree.C similarity index 53% rename from cde/lib/DtMmdb/btree/mmdb_btree.C rename to cde/lib/DtMmdb/btree/btree.C index 4eb34d64d..748061c96 100644 --- a/cde/lib/DtMmdb/btree/mmdb_btree.C +++ b/cde/lib/DtMmdb/btree/btree.C @@ -48,44 +48,45 @@ */ -#include "btree/mmdb_btree.h" +#include "btree/btree.h" btree::btree(const char* store_name) { -// let the package figure out all these parameters - btree_info.flags = 0; - btree_info.cachesize = 0; - btree_info.maxkeypage = 0; - btree_info.minkeypage = 0; - btree_info.psize = 0; - btree_info.compare = NULL; - btree_info.prefix = NULL; - btree_info.lorder = 0; - - key_DBT.data = 0; - key_DBT.size = 0; - - int mode = O_CREAT|O_RDWR; - - //btree_DB = dbopen(store_name, mode, 0640, DB_BTREE, &btree_info); - btree_DB = dbopen(store_name, mode, 0640, DB_BTREE, NULL); - - if ( btree_DB == 0 ) - throw(stringException("btree dbopen failed")); + int err; + MDB_txn *txn; + + key_DBT.mv_data = 0; + key_DBT.mv_size = 0; + + if ((err = mdb_env_create(&btree_env))) + throw(stringException(mdb_strerror(err))); + + if ((err = mdb_env_open(btree_env, store_name, MDB_NOSUBDIR | MDB_NOSYNC, + 0640))) + throw(stringException(mdb_strerror(err))); + + txn = txn_begin(); + + if ((err = mdb_dbi_open(txn, NULL, 0, &btree_DB))) { + mdb_txn_abort(txn); + throw(stringException(mdb_strerror(err))); + } + + txn_commit(txn); } btree::~btree() { - if ( btree_DB->sync(btree_DB, 0) == RET_ERROR ) { - cerr << "btree sync failed"; - std::exit(1); - } + int err; - if ( btree_DB->close(btree_DB) == RET_ERROR ) { - cerr << "btree close failed"; + if ((err = mdb_env_sync(btree_env, 0))) { + cerr << mdb_strerror(err); std::exit(1); } + + mdb_dbi_close(btree_env, btree_DB); + mdb_env_close(btree_env); } void btree::clean() @@ -97,13 +98,13 @@ void btree::data_t_2_DBT(data_t& w) { switch (w.flag) { case data_t::INT: - key_DBT.data = &w.key.int_key; - key_DBT.size = sizeof(w.key.int_key); + key_DBT.mv_data = &w.key.int_key; + key_DBT.mv_size = sizeof(w.key.int_key); break; case data_t::STRING: - key_DBT.data = w.key.str_key; - key_DBT.size = strlen(w.key.str_key); + key_DBT.mv_data = w.key.str_key; + key_DBT.mv_size = strlen(w.key.str_key); break; case data_t::VOID: @@ -113,74 +114,78 @@ void btree::data_t_2_DBT(data_t& w) Boolean btree::insert(data_t& w) { + int err; + MDB_txn *txn; + data_t_2_DBT(w); - DBT data_DBT; - data_DBT.data = &w.dt; - data_DBT.size = sizeof(w.dt); + MDB_val data_DBT; + data_DBT.mv_data = &w.dt; + data_DBT.mv_size = sizeof(w.dt); + + txn = txn_begin(); - //int status = btree_DB->put(btree_DB, &key_DBT, &data_DBT, R_NOOVERWRITE); - int status = btree_DB->put(btree_DB, &key_DBT, &data_DBT, 0); + err = mdb_put(txn, btree_DB, &key_DBT, &data_DBT, 0); - switch (status) { - case RET_ERROR: - throw(stringException("btree put failed")); - break; + if (err && err != MDB_MAP_FULL && err != MDB_TXN_FULL) { + mdb_txn_abort(txn); + throw(stringException(mdb_strerror(err))); + } - case RET_SPECIAL: - throw(stringException("btree put: dup key")); - break; + txn_commit(txn); - case RET_SUCCESS: - return true; + if (err) { + cerr << mdb_strerror(err); + return false; } - return false; + return true; } Boolean btree::remove(data_t& w) { - data_t_2_DBT(w); + int err; + MDB_txn *txn; - int status = btree_DB->del(btree_DB, &key_DBT, 0); + data_t_2_DBT(w); - switch (status) { - case RET_ERROR: - throw(stringException("btree delete failed")); - break; + txn = txn_begin(); - case RET_SPECIAL: - case RET_SUCCESS: - return true; + if ((err = mdb_del(txn, btree_DB, &key_DBT, NULL))) { + mdb_txn_abort(txn); + throw(stringException(mdb_strerror(err))); } - return false; + txn_commit(txn); + + return true; } -Boolean btree::member(data_t& w) +Boolean btree::member(data_t& w) { - data_t_2_DBT(w); - DBT data_DBT; + int err; + MDB_txn *txn; - int status = btree_DB->get(btree_DB, &key_DBT, &data_DBT, 0); + data_t_2_DBT(w); + MDB_val data_DBT; - switch (status) { - case RET_ERROR: - throw(stringException("btree get failed")); - break; + txn = txn_begin(MDB_RDONLY); - case RET_SPECIAL: - return false; + err = mdb_get(txn, btree_DB, &key_DBT, &data_DBT); - case RET_SUCCESS: - if ( data_DBT.size != sizeof(w.dt) ) - throw(stringException("btree get: tree corrupted")); + mdb_txn_abort(txn); - memcpy((char*)&w.dt, data_DBT.data, data_DBT.size); - return true; + if (err) { + if (err != MDB_NOTFOUND) throw(stringException(mdb_strerror(err))); + return false; } - return false; + if (data_DBT.mv_size != sizeof(w.dt)) + throw(stringException("btree get: tree corrupted")); + + memcpy((char*)&w.dt, data_DBT.mv_data, data_DBT.mv_size); + + return true; } ostream& btree::asciiOut(ostream& out) @@ -193,3 +198,19 @@ istream& btree::asciiIn(istream& in) return in; } +MDB_txn *btree::txn_begin(unsigned int flags) { + int err; + MDB_txn *txn; + + if ((err = mdb_txn_begin(btree_env, NULL, flags, &txn))) + throw(stringException(mdb_strerror(err))); + + return txn; +} + +void btree::txn_commit(MDB_txn *txn) { + int err; + + if ((err = mdb_txn_commit(txn))) + throw(stringException(mdb_strerror(err))); +} diff --git a/cde/lib/DtMmdb/btree/mmdb_btree.h b/cde/lib/DtMmdb/btree/btree.h similarity index 94% rename from cde/lib/DtMmdb/btree/mmdb_btree.h rename to cde/lib/DtMmdb/btree/btree.h index 49cfef606..b09d68353 100644 --- a/cde/lib/DtMmdb/btree/mmdb_btree.h +++ b/cde/lib/DtMmdb/btree/btree.h @@ -69,9 +69,9 @@ #endif #include +#include #include "dstr/index_agent.h" -#include "btree_berkeley/db.h" class btree : public index_agent @@ -91,12 +91,14 @@ public: istream& asciiIn(istream& in); protected: - DBT key_DBT; - DB* btree_DB; - BTREEINFO btree_info; + MDB_val key_DBT; + MDB_dbi btree_DB; + MDB_env *btree_env; protected: void data_t_2_DBT(data_t& w); + MDB_txn *txn_begin(unsigned int flags = 0); + void txn_commit(MDB_txn *txn); }; #endif diff --git a/cde/lib/DtMmdb/btree_berkeley/Makefile.am b/cde/lib/DtMmdb/btree_berkeley/Makefile.am deleted file mode 100644 index 6cfdbdf1b..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -noinst_LTLIBRARIES = libbtree_berkeley.la - -libbtree_berkeley_la_CFLAGS = -DMEMMOVE -I.. - -libbtree_berkeley_la_SOURCES = bt_close.c bt_conv.c bt_debug.c bt_delete.c \ - bt_get.c bt_open.c bt_overflow.c bt_page.c \ - bt_put.c bt_search.c bt_seq.c bt_split.c \ - bt_stack.c bt_utils.c mktemp.c \ - realloc.c snprintf.c mpool.c db.c - -if AIX -else -libbtree_berkeley_la_SOURCES += memmove.c -endif diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_close.c b/cde/lib/DtMmdb/btree_berkeley/bt_close.c deleted file mode 100644 index 13b657a27..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_close.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_close.c /main/4 1996/06/11 17:12:14 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_close.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_meta __P((BTREE *)); - -/* - * BT_CLOSE -- Close a btree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_close(DB *dbp) -{ - BTREE *t; - int fd; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * Delete any already deleted record that we've been saving - * because the cursor pointed to it. - */ - if (ISSET(t, B_DELCRSR) && __bt_crsrdel(t, &t->bt_bcursor)) - return (RET_ERROR); - - if (__bt_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - if (mpool_close(t->bt_mp) == RET_ERROR) - return (RET_ERROR); - - if (t->bt_stack) - free(t->bt_stack); - if (t->bt_kbuf) - free(t->bt_kbuf); - if (t->bt_dbuf) - free(t->bt_dbuf); - - fd = t->bt_fd; - free(t); - free(dbp); - return (close(fd) ? RET_ERROR : RET_SUCCESS); -} - -/* - * BT_SYNC -- sync the btree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_sync(const DB *dbp, u_int flags) -{ - BTREE *t; - int status; - PAGE *h; - void *p = NULL; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync doesn't currently take any flags. */ - if (flags != 0) { - errno = EINVAL; - return (RET_ERROR); - } - - if (ISSET(t, B_INMEM | B_RDONLY) || !ISSET(t, B_MODIFIED)) - return (RET_SUCCESS); - - if (ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) - return (RET_ERROR); - - /* - * Nastiness. If the cursor has been marked for deletion, but not - * actually deleted, we have to make a copy of the page, delete the - * key/data item, sync the file, and then restore the original page - * contents. - */ - if (ISSET(t, B_DELCRSR)) { - if ((p = (void*)malloc(t->bt_psize)) == NULL) - return (RET_ERROR); - if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) { - free(p); - return (RET_ERROR); - } - memmove(p, h, t->bt_psize); - if ((status = - __bt_dleaf(t, h, t->bt_bcursor.index)) == RET_ERROR) - goto ecrsr; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } - - if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS) - CLR(t, B_MODIFIED); - -ecrsr: if (ISSET(t, B_DELCRSR)) { - if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) { - free(p); - return (RET_ERROR); - } - memmove(h, p, t->bt_psize); - free(p); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } - return (status); -} - -/* - * BT_META -- write the tree meta data to disk. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_meta(BTREE *t) -{ - BTMETA m; - void *p; - - if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL) - return (RET_ERROR); - - /* Fill in metadata. */ - m.m_magic = BTREEMAGIC; - m.m_version = BTREEVERSION; - m.m_psize = t->bt_psize; - m.m_free = t->bt_free; - m.m_nrecs = t->bt_nrecs; - m.m_flags = t->bt_flags & SAVEMETA; - - memmove(p, &m, sizeof(BTMETA)); - mpool_put(t->bt_mp, p, MPOOL_DIRTY); - return (RET_SUCCESS); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_conv.c b/cde/lib/DtMmdb/btree_berkeley/bt_conv.c deleted file mode 100644 index 58ad4d1ad..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_conv.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_conv.c /main/3 1996/06/11 17:12:19 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_conv.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -static void mswap __P((PAGE *)); - -/* - * __BT_BPGIN, __BT_BPGOUT -- - * Convert host-specific number layout to/from the host-independent - * format stored on disk. - * - * Parameters: - * t: tree - * pg: page number - * h: page to convert - */ -void -__bt_pgin(void *t, pgno_t pg, void *pp) -{ - PAGE *h; - int i, top; - u_char flags; - char *p; - - if (!ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - BLSWAP(h->pgno); - BLSWAP(h->prevpg); - BLSWAP(h->nextpg); - BLSWAP(h->flags); - BSSWAP(h->lower); - BSSWAP(h->upper); - - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - BSSWAP(h->linp[i]); - p = (char *)GETBINTERNAL(h, i); - BLPSWAP(p); - p += sizeof(size_t); - BLPSWAP(p); - p += sizeof(pgno_t); - if (*(u_char *)p & P_BIGKEY) { - p += sizeof(u_char); - BLPSWAP(p); - p += sizeof(pgno_t); - BLPSWAP(p); - } - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - BSSWAP(h->linp[i]); - p = (char *)GETBLEAF(h, i); - BLPSWAP(p); - p += sizeof(size_t); - BLPSWAP(p); - p += sizeof(size_t); - flags = *(u_char *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(u_char); - if (flags & P_BIGKEY) { - BLPSWAP(p); - p += sizeof(pgno_t); - BLPSWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(size_t); - BLPSWAP(p); - p += sizeof(pgno_t); - BLPSWAP(p); - } - } - } -} - -void -__bt_pgout(void *t, pgno_t pg, void *pp) -{ - PAGE *h; - int i, top; - u_char flags; - char *p; - - if (!ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - p = (char *)GETBINTERNAL(h, i); - BLPSWAP(p); - p += sizeof(size_t); - BLPSWAP(p); - p += sizeof(pgno_t); - if (*(u_char *)p & P_BIGKEY) { - p += sizeof(u_char); - BLPSWAP(p); - p += sizeof(pgno_t); - BLPSWAP(p); - } - BSSWAP(h->linp[i]); - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - p = (char *)GETBLEAF(h, i); - BLPSWAP(p); - p += sizeof(size_t); - BLPSWAP(p); - p += sizeof(size_t); - flags = *(u_char *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(u_char); - if (flags & P_BIGKEY) { - BLPSWAP(p); - p += sizeof(pgno_t); - BLPSWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(size_t); - BLPSWAP(p); - p += sizeof(pgno_t); - BLPSWAP(p); - } - } - BSSWAP(h->linp[i]); - } - - BLSWAP(h->pgno); - BLSWAP(h->prevpg); - BLSWAP(h->nextpg); - BLSWAP(h->flags); - BSSWAP(h->lower); - BSSWAP(h->upper); -} - -/* - * MSWAP -- Actually swap the bytes on the meta page. - * - * Parameters: - * p: page to convert - */ -static void -mswap(PAGE *pg) -{ - char *p; - - p = (char *)pg; - BLPSWAP(p); /* m_magic */ - p += sizeof(u_long); - BLPSWAP(p); /* m_version */ - p += sizeof(u_long); - BLPSWAP(p); /* m_psize */ - p += sizeof(u_long); - BLPSWAP(p); /* m_free */ - p += sizeof(u_long); - BLPSWAP(p); /* m_nrecs */ - p += sizeof(u_long); - BLPSWAP(p); /* m_flags */ - p += sizeof(u_long); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_debug.c b/cde/lib/DtMmdb/btree_berkeley/bt_debug.c deleted file mode 100644 index 93b6048b9..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_debug.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_debug.c /main/4 1996/10/04 09:54:32 drk $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_debug.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -/* - * BT_DUMP -- Dump the tree - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_dump(dbp) - DB *dbp; -{ - BTREE *t; - PAGE *h; - pgno_t i; - char *sep; - - t = dbp->internal; - (void)fprintf(stderr, "%s: pgsz %ld", - ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize); - if (ISSET(t, R_RECNO)) - (void)fprintf(stderr, " keys %lu", t->bt_nrecs); -#undef X -#define X(flag, name) \ - if (ISSET(t, flag)) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (t->bt_flags) { - sep = " flags ("; - X(B_DELCRSR, "DELCRSR"); - X(R_FIXLEN, "FIXLEN"); - X(B_INMEM, "INMEM"); - X(B_NODUPS, "NODUPS"); - X(B_RDONLY, "RDONLY"); - X(R_RECNO, "RECNO"); - X(B_SEQINIT, "SEQINIT"); - X(B_METADIRTY,"METADIRTY"); - (void)fprintf(stderr, ")\n"); - } -#undef X - - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DMPAGE -- Dump the meta page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dmpage(h) - PAGE *h; -{ - BTMETA *m; - char *sep; - - m = (BTMETA *)h; - (void)fprintf(stderr, "magic %lx\n", m->m_magic); - (void)fprintf(stderr, "version %lu\n", m->m_version); - (void)fprintf(stderr, "psize %lu\n", m->m_psize); - (void)fprintf(stderr, "free %lu\n", m->m_free); - (void)fprintf(stderr, "nrecs %lu\n", m->m_nrecs); - (void)fprintf(stderr, "flags %lu", m->m_flags); -#undef X -#define X(flag, name) \ - if (m->m_flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (m->m_flags) { - sep = " ("; - X(B_NODUPS, "NODUPS"); - X(R_RECNO, "RECNO"); - (void)fprintf(stderr, ")"); - } -} - -/* - * BT_DNPAGE -- Dump the page - * - * Parameters: - * n: page number to dump. - */ -void -__bt_dnpage(dbp, pgno) - DB *dbp; - pgno_t pgno; -{ - BTREE *t; - PAGE *h; - - t = dbp->internal; - if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DPAGE -- Dump the page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dpage(h) - PAGE *h; -{ - BINTERNAL *bi; - BLEAF *bl; - RINTERNAL *ri; - RLEAF *rl; - indx_t cur, top; - char *sep; - - (void)fprintf(stderr, " page %ld: (", h->pgno); -#undef X -#define X(flag, name) \ - if (h->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - sep = ""; - X(P_BINTERNAL, "BINTERNAL") /* types */ - X(P_BLEAF, "BLEAF") - X(P_RINTERNAL, "RINTERNAL") /* types */ - X(P_RLEAF, "RLEAF") - X(P_OVERFLOW, "OVERFLOW") - X(P_PRESERVE, "PRESERVE"); - (void)fprintf(stderr, ")\n"); -#undef X - - (void)fprintf(stderr, "\tprev %2ld next %2ld", h->prevpg, h->nextpg); - if (h->flags & P_OVERFLOW) - return; - - top = NEXTINDEX(h); - (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n", - h->lower, h->upper, top); - for (cur = 0; cur < top; cur++) { - (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]); - switch(h->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(h, cur); - (void)fprintf(stderr, - "size %03ld pgno %03ld", (long)bi->ksize, bi->pgno); - if (bi->flags & P_BIGKEY) - (void)fprintf(stderr, " (indirect)"); - else if (bi->ksize) - (void)fprintf(stderr, - " {%.*s}", (int)bi->ksize, bi->bytes); - break; - case P_RINTERNAL: - ri = GETRINTERNAL(h, cur); - (void)fprintf(stderr, "entries %03ld pgno %03ld", - ri->nrecs, ri->pgno); - break; - case P_BLEAF: - bl = GETBLEAF(h, cur); - if (bl->flags & P_BIGKEY) - (void)fprintf(stderr, - "big key page %lu size %lu/", - *(pgno_t *)bl->bytes, - (long)*(size_t *)(bl->bytes + sizeof(pgno_t))); - else if (bl->ksize) - (void)fprintf(stderr, "%s/", bl->bytes); - if (bl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %lu", - *(pgno_t *)(bl->bytes + bl->ksize), - (long)*(size_t *)(bl->bytes + bl->ksize + - sizeof(pgno_t))); - else if (bl->dsize) - (void)fprintf(stderr, "%.*s", - (int)bl->dsize, bl->bytes + bl->ksize); - break; - case P_RLEAF: - rl = GETRLEAF(h, cur); - if (rl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %lu", - *(pgno_t *)rl->bytes, - (long)*(size_t *)(rl->bytes + sizeof(pgno_t))); - else if (rl->dsize) - (void)fprintf(stderr, - "%.*s", (int)rl->dsize, rl->bytes); - break; - } - (void)fprintf(stderr, "\n"); - } -} -#endif - -#ifdef STATISTICS -/* - * BT_STAT -- Gather/print the tree statistics - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_stat(dbp) - DB *dbp; -{ - extern u_long bt_cache_hit, bt_cache_miss; - extern u_long bt_rootsplit, bt_split, bt_sortsplit; - extern u_long bt_pfxsaved; - BTREE *t; - PAGE *h; - pgno_t i, pcont, pinternal, pleaf; - u_long ifree, lfree, nkeys; - int levels; - - t = dbp->internal; - pcont = pinternal = pleaf = 0; - nkeys = ifree = lfree = 0; - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - switch(h->flags & P_TYPE) { - case P_BINTERNAL: - case P_RINTERNAL: - ++pinternal; - ifree += h->upper - h->lower; - break; - case P_BLEAF: - case P_RLEAF: - ++pleaf; - lfree += h->upper - h->lower; - nkeys += NEXTINDEX(h); - break; - case P_OVERFLOW: - ++pcont; - break; - } - (void)mpool_put(t->bt_mp, h, 0); - } - - /* Count the levels of the tree. */ - for (i = P_ROOT, levels = 0 ;; ++levels) { - h = mpool_get(t->bt_mp, i, 0); - if (h->flags & (P_BLEAF|P_RLEAF)) { - if (levels == 0) - levels = 1; - (void)mpool_put(t->bt_mp, h, 0); - break; - } - i = ISSET(t, R_RECNO) ? - GETRINTERNAL(h, 0)->pgno : - GETBINTERNAL(h, 0)->pgno; - (void)mpool_put(t->bt_mp, h, 0); - } - - (void)fprintf(stderr, "%d level%s with %ld keys", - levels, levels == 1 ? "" : "s", nkeys); - if (ISSET(t, R_RECNO)) - (void)fprintf(stderr, " (%ld header count)", t->bt_nrecs); - (void)fprintf(stderr, - "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n", - pinternal + pleaf + pcont, pleaf, pinternal, pcont); - (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n", - bt_cache_hit, bt_cache_miss); - (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n", - bt_split, bt_rootsplit, bt_sortsplit); - pleaf *= t->bt_psize - BTDATAOFF; - if (pleaf) - (void)fprintf(stderr, - "%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n", - ((double)(pleaf - lfree) / pleaf) * 100, - pleaf - lfree, lfree); - pinternal *= t->bt_psize - BTDATAOFF; - if (pinternal) - (void)fprintf(stderr, - "%.0f%% internal fill (%ld bytes used, %ld bytes free\n", - ((double)(pinternal - ifree) / pinternal) * 100, - pinternal - ifree, ifree); - if (bt_pfxsaved) - (void)fprintf(stderr, "prefix checking removed %lu bytes.\n", - bt_pfxsaved); -} -#endif diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_delete.c b/cde/lib/DtMmdb/btree_berkeley/bt_delete.c deleted file mode 100644 index d31aaf0c6..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_delete.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_delete.c /main/3 1996/06/11 17:12:29 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_delete.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -static int bt_bdelete __P((BTREE *, const DBT *)); - -/* - * __BT_DELETE -- Delete the item(s) referenced by a key. - * - * Parameters: - * dbp: pointer to access method - * key: key to delete - * flags: R_CURSOR if deleting what the cursor references - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__bt_delete(const DB *dbp, const DBT *key, u_int flags) -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch(flags) { - case 0: - status = bt_bdelete(t, key); - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, delete the cursor; must already have - * started a scan and not have already deleted the record. For - * the delete cursor bit to have been set requires that the - * scan be initialized, so no reason to check. - */ - if (!ISSET(t, B_SEQINIT)) - goto einval; - status = ISSET(t, B_DELCRSR) ? - RET_SPECIAL : __bt_crsrdel(t, &t->bt_bcursor); - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - if (status == RET_SUCCESS) - SET(t, B_MODIFIED); - return (status); -} - -/* - * BT_BDELETE -- Delete all key/data pairs matching the specified key. - * - * Parameters: - * tree: tree - * key: key to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -bt_bdelete(BTREE *t, const DBT *key) -{ - EPG *e, save; - PAGE *h; - pgno_t cpgno, pg; - indx_t cindex; - int deleted, dirty1, dirty2, exact; - - /* Find any matching record; __bt_search pins the page. */ - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (RET_SPECIAL); - } - - /* - * Delete forward, then delete backward, from the found key. The - * ordering is so that the deletions don't mess up the page refs. - * The first loop deletes the key from the original page, the second - * unpins the original page. In the first loop, dirty1 is set if - * the original page is modified, and dirty2 is set if any subsequent - * pages are modified. In the second loop, dirty1 starts off set if - * the original page has been modified, and is set if any subsequent - * pages are modified. - * - * If find the key referenced by the cursor, don't delete it, just - * flag it for future deletion. The cursor page number is P_INVALID - * unless the sequential scan is initialized, so no reason to check. - * A special case is when the already deleted cursor record was the - * only record found. If so, then the delete opertion fails as no - * records were deleted. - * - * Cycle in place in the current page until the current record doesn't - * match the key or the page is empty. If the latter, walk forward, - * skipping empty pages and repeating until a record doesn't match - * the key or the end of the tree is reached. - */ - cpgno = t->bt_bcursor.pgno; - cindex = t->bt_bcursor.index; - save = *e; - dirty1 = 0; - for (h = e->page, deleted = 0;;) { - dirty2 = 0; - do { - if (h->pgno == cpgno && e->index == cindex) { - if (!ISSET(t, B_DELCRSR)) { - SET(t, B_DELCRSR); - deleted = 1; - } - ++e->index; - } else { - if (__bt_dleaf(t, h, e->index)) { - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, dirty2); - mpool_put(t->bt_mp, save.page, dirty1); - return (RET_ERROR); - } - if (h->pgno == save.page->pgno) - dirty1 = MPOOL_DIRTY; - else - dirty2 = MPOOL_DIRTY; - deleted = 1; - } - } while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0); - - /* - * Quit if didn't find a match, no next page, or first key on - * the next page doesn't match. Don't unpin the original page - * unless an error occurs. - */ - if (e->index < NEXTINDEX(h)) - break; - for (;;) { - if ((pg = h->nextpg) == P_INVALID) - goto done1; - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, dirty2); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) { - mpool_put(t->bt_mp, save.page, dirty1); - return (RET_ERROR); - } - if (NEXTINDEX(h) != 0) { - e->page = h; - e->index = 0; - break; - } - } - - if (__bt_cmp(t, key, e) != 0) - break; - } - - /* - * Reach here with the original page and the last page referenced - * pinned (they may be the same). Release it if not the original. - */ -done1: if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, dirty2); - - /* - * Walk backwards from the record previous to the record returned by - * __bt_search, skipping empty pages, until a record doesn't match - * the key or reach the beginning of the tree. - */ - *e = save; - for (;;) { - if (e->index) - --e->index; - for (h = e->page; e->index; --e->index) { - if (__bt_cmp(t, key, e) != 0) - goto done2; - if (h->pgno == cpgno && e->index == cindex) { - if (!ISSET(t, B_DELCRSR)) { - SET(t, B_DELCRSR); - deleted = 1; - } - } else { - if (__bt_dleaf(t, h, e->index) == RET_ERROR) { - mpool_put(t->bt_mp, h, dirty1); - return (RET_ERROR); - } - if (h->pgno == save.page->pgno) - dirty1 = MPOOL_DIRTY; - deleted = 1; - } - } - - if ((pg = h->prevpg) == P_INVALID) - goto done2; - mpool_put(t->bt_mp, h, dirty1); - dirty1 = 0; - if ((e->page = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - e->index = NEXTINDEX(e->page); - } - - /* - * Reach here with the last page that was looked at pinned. Release - * it. - */ -done2: mpool_put(t->bt_mp, h, dirty1); - return (deleted ? RET_SUCCESS : RET_SPECIAL); -} - -/* - * __BT_DLEAF -- Delete a single record from a leaf page. - * - * Parameters: - * t: tree - * index: index on current page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_dleaf(BTREE *t, PAGE *h, int index) -{ - BLEAF *bl; - indx_t *ip, offset; - size_t nbytes; - int cnt; - char *from; - void *to; - - /* - * Delete a record from a btree leaf page. Internal records are never - * deleted from internal pages, regardless of the records that caused - * them to be added being deleted. Pages made empty by deletion are - * not reclaimed. They are, however, made available for reuse. - * - * Pack the remaining entries at the end of the page, shift the indices - * down, overwriting the deleted record and its index. If the record - * uses overflow pages, make them available for reuse. - */ - to = bl = GETBLEAF(h, index); - if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) - return (RET_ERROR); - if (bl->flags & P_BIGDATA && - __ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR) - return (RET_ERROR); - nbytes = NBLEAF(bl); - - /* - * Compress the key/data pairs. Compress and adjust the [BR]LEAF - * offsets. Reset the headers. - */ - from = (char *)h + h->upper; - memmove(from + nbytes, from, (char *)to - from); - h->upper += nbytes; - - offset = h->linp[index]; - for (cnt = index, ip = &h->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - for (cnt = NEXTINDEX(h) - index; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - return (RET_SUCCESS); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_get.c b/cde/lib/DtMmdb/btree_berkeley/bt_get.c deleted file mode 100644 index f2ea0f145..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_get.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_get.c /main/3 1996/06/11 17:12:34 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_get.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__bt_get(const DB *dbp, const DBT *key, DBT *data, u_int flags) -{ - BTREE *t; - EPG *e; - int exact, status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags. */ - if (flags) { - errno = EINVAL; - return (RET_ERROR); - } - - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (RET_SPECIAL); - } - - /* - * A special case is if we found the record but it's flagged for - * deletion. In this case, we want to find another record with the - * same key, if it exists. Rather than look around the tree we call - * __bt_first and have it redo the search, as __bt_first will not - * return keys marked for deletion. Slow, but should never happen. - */ - if (ISSET(t, B_DELCRSR) && e->page->pgno == t->bt_bcursor.pgno && - e->index == t->bt_bcursor.index) { - mpool_put(t->bt_mp, e->page, 0); - if ((e = __bt_first(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) - return (RET_SPECIAL); - } - - status = __bt_ret(t, e, NULL, data); - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} - -/* - * __BT_FIRST -- Find the first entry. - * - * Parameters: - * t: the tree - * key: the key - * - * Returns: - * The first entry in the tree greater than or equal to key. - */ -EPG * -__bt_first(BTREE *t, const DBT *key, int *exactp) -{ - PAGE *h; - EPG *e; - EPG save; - pgno_t cpgno, pg; - indx_t cindex; - int found; - - /* - * Find any matching record; __bt_search pins the page. Only exact - * matches are tricky, otherwise just return the location of the key - * if it were to be inserted into the tree. - */ - if ((e = __bt_search(t, key, exactp)) == NULL) - return (NULL); - if (!*exactp) - return (e); - - if (ISSET(t, B_DELCRSR)) { - cpgno = t->bt_bcursor.pgno; - cindex = t->bt_bcursor.index; - } else { - cpgno = P_INVALID; - cindex = 0; /* GCC thinks it's uninitialized. */ - } - - /* - * Walk backwards, skipping empty pages, as long as the entry matches - * and there are keys left in the tree. Save a copy of each match in - * case we go too far. A special case is that we don't return a match - * on records that the cursor references that have already been flagged - * for deletion. - */ - save = *e; - h = e->page; - found = 0; - do { - if (cpgno != h->pgno || cindex != e->index) { - if (save.page->pgno != e->page->pgno) { - mpool_put(t->bt_mp, save.page, 0); - save = *e; - } else - save.index = e->index; - found = 1; - } - /* - * Make a special effort not to unpin the page the last (or - * original) match was on, but also make sure it's unpinned - * if an error occurs. - */ - while (e->index == 0) { - if (h->prevpg == P_INVALID) - goto done1; - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) { - if (h->pgno == save.page->pgno) - mpool_put(t->bt_mp, save.page, 0); - return (NULL); - } - e->page = h; - e->index = NEXTINDEX(h); - } - --e->index; - } while (__bt_cmp(t, key, e) == 0); - - /* - * Reach here with the last page that was looked at pinned, which may - * or may not be the same as the last (or original) match page. If - * it's not useful, release it. - */ -done1: if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - - /* - * If still haven't found a record, the only possibility left is the - * next one. Move forward one slot, skipping empty pages and check. - */ - if (!found) { - h = save.page; - if (++save.index == NEXTINDEX(h)) { - do { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) { - *exactp = 0; - return (e); - } - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - } while ((save.index = NEXTINDEX(h)) == 0); - save.page = h; - } - if (__bt_cmp(t, key, &save) != 0) { - *exactp = 0; - return (e); - } - } - *e = save; - *exactp = 1; - return (e); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_open.c b/cde/lib/DtMmdb/btree_berkeley/bt_open.c deleted file mode 100644 index 62c87d95f..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_open.c +++ /dev/null @@ -1,461 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_open.c /main/3 1996/06/11 17:12:40 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_open.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Implementation of btree access method for 4.4BSD. - * - * The design here was originally based on that of the btree access method - * used in the Postgres database system at UC Berkeley. This implementation - * is wholly independent of the Postgres code. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define __DBINTERFACE_PRIVATE -#include -#include "btree.h" - -static int byteorder __P((void)); -static int nroot __P((BTREE *)); -static int tmp __P((void)); - -/* - * __BT_OPEN -- Open a btree. - * - * Creates and fills a DB struct, and calls the routine that actually - * opens the btree. - * - * Parameters: - * fname: filename (NULL for in-memory trees) - * flags: open flag bits - * mode: open permission bits - * b: BTREEINFO pointer - * - * Returns: - * NULL on failure, pointer to DB on success. - * - */ -DB * -__bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int dflags) -{ - BTMETA m; - BTREE *t; - BTREEINFO b; - DB *dbp; - pgno_t ncache; - struct stat sb; - int machine_lorder, nr; - - t = NULL; - - /* - * Intention is to make sure all of the user's selections are okay - * here and then use them without checking. Can't be complete, since - * we don't know the right page size, lorder or flags until the backing - * file is opened. Also, the file's page size can cause the cachesize - * to change. - */ - machine_lorder = byteorder(); - if (openinfo) { - b = *openinfo; - - /* Flags: R_DUP. */ - if (b.flags & ~(R_DUP)) - goto einval; - - /* - * Page size must be indx_t aligned and >= MINPSIZE. Default - * page size is set farther on, based on the underlying file - * transfer size. - */ - if (b.psize && - (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 || - b.psize & (sizeof(indx_t) - 1))) - goto einval; - - /* Minimum number of keys per page; absolute minimum is 2. */ - if (b.minkeypage) { - if (b.minkeypage < 2) - goto einval; - } else - b.minkeypage = DEFMINKEYPAGE; - - /* If no comparison, use default comparison and prefix. */ - if (b.compare == NULL) { - b.compare = __bt_defcmp; - if (b.prefix == NULL) - b.prefix = __bt_defpfx; - } - - if (b.lorder == 0) - b.lorder = machine_lorder; - } else { - b.compare = __bt_defcmp; - b.cachesize = 0; - b.flags = 0; - b.lorder = machine_lorder; - b.minkeypage = DEFMINKEYPAGE; - b.prefix = __bt_defpfx; - b.psize = 0; - } - - /* Check for the ubiquitous PDP-11. */ - if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN) - goto einval; - - /* Allocate and initialize DB and BTREE structures. */ - if ((t = malloc(sizeof(BTREE))) == NULL) - goto err; - t->bt_fd = -1; /* Don't close unopened fd on error. */ - if ((t->bt_dbp = dbp = malloc(sizeof(DB))) == NULL) - goto err; - t->bt_bcursor.pgno = P_INVALID; - t->bt_bcursor.index = 0; - t->bt_stack = NULL; - t->bt_pinned = NULL; - t->bt_sp = t->bt_maxstack = 0; - t->bt_kbuf = t->bt_dbuf = NULL; - t->bt_kbufsz = t->bt_dbufsz = 0; - t->bt_lorder = b.lorder; - t->bt_order = NOT; - t->bt_cmp = b.compare; - t->bt_pfx = b.prefix; - t->bt_flags = 0; - if (t->bt_lorder != machine_lorder) - SET(t, B_NEEDSWAP); - - dbp->type = DB_BTREE; - dbp->internal = t; - dbp->close = __bt_close; - dbp->del = __bt_delete; - dbp->fd = __bt_fd; - dbp->get = __bt_get; - dbp->put = __bt_put; - dbp->seq = __bt_seq; - dbp->sync = __bt_sync; - - /* - * If no file name was supplied, this is an in-memory btree and we - * open a backing temporary file. Otherwise, it's a disk-based tree. - */ - if (fname) { - switch(flags & O_ACCMODE) { - case O_RDONLY: - SET(t, B_RDONLY); - break; - case O_RDWR: - break; - case O_WRONLY: - default: - goto einval; - } - - if ((t->bt_fd = open(fname, flags, mode)) < 0) - goto err; - - } else { - if ((flags & O_ACCMODE) != O_RDWR) - goto einval; - if ((t->bt_fd = tmp()) == -1) - goto err; - SET(t, B_INMEM); - } - - if (fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - - if (fstat(t->bt_fd, &sb)) - goto err; - if (sb.st_size) { - nr = read(t->bt_fd, &m, sizeof(BTMETA)); - if (nr < 0) - goto err; - if (nr != sizeof(BTMETA)) - goto eftype; - - /* - * Read in the meta-data. This can change the notion of what - * the lorder, page size and flags are, and, when the page size - * changes, the cachesize value can change too. If the user - * specified the wrong byte order for an existing database, we - * don't bother to return an error, we just clear the NEEDSWAP - * bit. - */ - if (m.m_magic == BTREEMAGIC) - CLR(t, B_NEEDSWAP); - else { - SET(t, B_NEEDSWAP); - BLSWAP(m.m_magic); - BLSWAP(m.m_version); - BLSWAP(m.m_psize); - BLSWAP(m.m_free); - BLSWAP(m.m_nrecs); - BLSWAP(m.m_flags); - } - if (m.m_magic != BTREEMAGIC || m.m_version != BTREEVERSION) - goto eftype; - if (m.m_psize < MINPSIZE || m.m_psize > MAX_PAGE_OFFSET + 1 || - m.m_psize & (sizeof(indx_t) - 1)) - goto eftype; - if (m.m_flags & ~SAVEMETA) - goto eftype; - b.psize = m.m_psize; - t->bt_flags |= m.m_flags; - t->bt_free = m.m_free; - t->bt_nrecs = m.m_nrecs; - } else { - /* - * Set the page size to the best value for I/O to this file. - * Don't overflow the page offset type. - */ - if (b.psize == 0) { - b.psize = sb.st_blksize; - if (b.psize < MINPSIZE) - b.psize = MINPSIZE; - if (b.psize > MAX_PAGE_OFFSET + 1) - b.psize = MAX_PAGE_OFFSET + 1; - } - - /* Set flag if duplicates permitted. */ - if (!(b.flags & R_DUP)) - SET(t, B_NODUPS); - - t->bt_free = P_INVALID; - t->bt_nrecs = 0; - SET(t, B_METADIRTY); - } - - t->bt_psize = b.psize; - - /* Set the cache size; must be a multiple of the page size. */ - if (b.cachesize && b.cachesize & (b.psize - 1)) - b.cachesize += (~b.cachesize & (b.psize - 1)) + 1; - if (b.cachesize < b.psize * MINCACHE) - b.cachesize = b.psize * MINCACHE; - - /* Calculate number of pages to cache. */ - ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; - - /* - * The btree data structure requires that at least two keys can fit on - * a page, but other than that there's no fixed requirement. The user - * specified a minimum number per page, and we translated that into the - * number of bytes a key/data pair can use before being placed on an - * overflow page. This calculation includes the page header, the size - * of the index referencing the leaf item and the size of the leaf item - * structure. Also, don't let the user specify a minkeypage such that - * a key/data pair won't fit even if both key and data are on overflow - * pages. - */ - t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage - - (sizeof(indx_t) + NBLEAFDBT(0, 0)); - if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t)) - t->bt_ovflsize = - NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t); - - /* Initialize the buffer pool. */ - if ((t->bt_mp = - mpool_open(NULL, t->bt_fd, t->bt_psize, ncache)) == NULL) - goto err; - if (!ISSET(t, B_INMEM)) - mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t); - - /* Create a root page if new tree. */ - if (nroot(t) == RET_ERROR) - goto err; - - /* Global flags. */ - if (dflags & DB_LOCK) - SET(t, B_DB_LOCK); - if (dflags & DB_SHMEM) - SET(t, B_DB_SHMEM); - if (dflags & DB_TXN) - SET(t, B_DB_TXN); - - return (dbp); - -einval: errno = EINVAL; - goto err; - -eftype: errno = EFTYPE; - goto err; - -err: if (t) { - if (t->bt_dbp) - free(t->bt_dbp); - if (t->bt_fd != -1) - (void)close(t->bt_fd); - free(t); - } - return (NULL); -} - -/* - * NROOT -- Create the root of a new tree. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -nroot(BTREE *t) -{ - PAGE *meta, *root; - pgno_t npg; - - if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { - mpool_put(t->bt_mp, meta, 0); - return (RET_SUCCESS); - } - if (errno != EINVAL) - return (RET_ERROR); - - if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if ((root = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if (npg != P_ROOT) - return (RET_ERROR); - root->pgno = npg; - root->prevpg = root->nextpg = P_INVALID; - root->lower = BTDATAOFF; - root->upper = t->bt_psize; - root->flags = P_BLEAF; - memset(meta, 0, t->bt_psize); - mpool_put(t->bt_mp, meta, MPOOL_DIRTY); - mpool_put(t->bt_mp, root, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -static int -tmp(void) -{ - sigset_t set, oset; - int fd; - char *envtmp; - char path[MAXPATHLEN]; - - envtmp = getenv("TMPDIR"); - (void)snprintf(path, - sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : "/tmp"); - - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return(fd); -} - -static int -byteorder(void) -{ - u_long x; /* XXX: 32-bit assumption. */ - u_char *p; - - x = 0x01020304; - p = (u_char *)&x; - switch (*p) { - case 1: - return (BIG_ENDIAN); - case 4: - return (LITTLE_ENDIAN); - default: - return (0); - } -} - -int -__bt_fd(const DB *dbp) -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* In-memory database can't have a file descriptor. */ - if (ISSET(t, B_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_fd); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_overflow.c b/cde/lib/DtMmdb/btree_berkeley/bt_overflow.c deleted file mode 100644 index c09337068..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_overflow.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_overflow.c /main/3 1996/06/11 17:12:45 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_overflow.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * Big key/data code. - * - * Big key and data entries are stored on linked lists of pages. The initial - * reference is byte string stored with the key or data and is the page number - * and size. The actual record is stored in a chain of pages linked by the - * nextpg field of the PAGE header. - * - * The first page of the chain has a special property. If the record is used - * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set - * in the header. - * - * XXX - * A single DBT is written to each chain, so a lot of space on the last page - * is wasted. This is a fairly major bug for some data sets. - */ - -/* - * __OVFL_GET -- Get an overflow key/data item. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, size_t } - * buf: storage address - * bufsz: storage size - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_get(BTREE *t, void *p, size_t *ssz, char **buf, size_t *bufsz) -{ - PAGE *h; - pgno_t pg; - size_t nb, plen, sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t)); - *ssz = sz; - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - /* Make the buffer bigger as necessary. */ - if (*bufsz < sz) { - if ((*buf = __fix_realloc(*buf, sz)) == NULL) - return (RET_ERROR); - *bufsz = sz; - } - - /* - * Step through the linked list of pages, copying the data on each one - * into the buffer. Never copy more than the data's length. - */ - plen = t->bt_psize - BTDATAOFF; - for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - nb = MIN(sz, plen); - memmove(p, (char *)h + BTDATAOFF, nb); - mpool_put(t->bt_mp, h, 0); - - if ((sz -= nb) == 0) - break; - } - return (RET_SUCCESS); -} - -/* - * __OVFL_PUT -- Store an overflow key/data item. - * - * Parameters: - * t: tree - * data: DBT to store - * pgno: storage page number - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_put(BTREE *t, const DBT *dbt, pgno_t *pg) -{ - PAGE *h, *last; - void *p; - pgno_t npg; - size_t nb, plen, sz; - - /* - * Allocate pages and copy the key/data record into them. Store the - * number of the first page in the chain. - */ - plen = t->bt_psize - BTDATAOFF; - for (last = NULL, p = dbt->data, sz = dbt->size;; - p = (char *)p + plen, last = h) { - if ((h = __bt_new(t, &npg)) == NULL) - return (RET_ERROR); - - h->pgno = npg; - h->nextpg = h->prevpg = P_INVALID; - h->flags = P_OVERFLOW; - h->lower = h->upper = 0; - - nb = MIN(sz, plen); - memmove((char *)h + BTDATAOFF, p, nb); - - if (last) { - last->nextpg = h->pgno; - mpool_put(t->bt_mp, last, MPOOL_DIRTY); - } else - *pg = h->pgno; - - if ((sz -= nb) == 0) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - } - return (RET_SUCCESS); -} - -/* - * __OVFL_DELETE -- Delete an overflow chain. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, size_t } - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_delete(BTREE *t, void *p) -{ - PAGE *h; - pgno_t pg; - size_t plen, sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t)); - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Don't delete chains used by internal pages. */ - if (h->flags & P_PRESERVE) { - mpool_put(t->bt_mp, h, 0); - return (RET_SUCCESS); - } - - /* Step through the chain, calling the free routine for each page. */ - for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) { - pg = h->nextpg; - __bt_free(t, h); - if (sz <= plen) - break; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - return (RET_SUCCESS); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_page.c b/cde/lib/DtMmdb/btree_berkeley/bt_page.c deleted file mode 100644 index fb69b1fd3..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_page.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_page.c /main/3 1996/06/11 17:12:50 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_page.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#define __DBINTERFACE_PRIVATE -#include - -#include -#include "btree.h" - -/* - * __BT_FREE -- Put a page on the freelist. - * - * Parameters: - * t: tree - * h: page to free - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_free(BTREE *t, PAGE *h) -{ - /* Insert the page at the start of the free list. */ - h->prevpg = P_INVALID; - h->nextpg = t->bt_free; - t->bt_free = h->pgno; - - /* Make sure the page gets written back. */ - return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); -} - -/* - * __BT_NEW -- Get a new page, preferably from the freelist. - * - * Parameters: - * t: tree - * npg: storage for page number. - * - * Returns: - * Pointer to a page, NULL on error. - */ -PAGE * -__bt_new(BTREE *t, pgno_t *npg) -{ - PAGE *h; - - if (t->bt_free != P_INVALID && - (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { - *npg = t->bt_free; - t->bt_free = h->nextpg; - return (h); - } - return (mpool_new(t->bt_mp, npg)); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_put.c b/cde/lib/DtMmdb/btree_berkeley/bt_put.c deleted file mode 100644 index 3c34b9bf1..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_put.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_put.c /main/3 1996/06/11 17:12:56 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_put.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static EPG *bt_fast __P((BTREE *, const DBT *, const DBT *, int *)); - -/* - * __BT_PUT -- Add a btree item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the - * tree and R_NOOVERWRITE specified. - */ -int -__bt_put(const DB *dbp, DBT *key, const DBT *data, u_int flags) -{ - BTREE *t; - DBT tkey, tdata; - EPG *e = NULL; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - size_t nbytes; - int dflags, exact, status; - char *dest, db[NOVFLSIZE], kb[NOVFLSIZE]; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch (flags) { - case R_CURSOR: - if (!ISSET(t, B_SEQINIT)) - goto einval; - if (ISSET(t, B_DELCRSR)) - goto einval; - break; - case 0: - case R_NOOVERWRITE: - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - /* - * If the key/data won't fit on a page, store it on indirect pages. - * Only store the key on the overflow page if it's too big after the - * data is on an overflow page. - * - * XXX - * If the insert fails later on, these pages aren't recovered. - */ - dflags = 0; - if (key->size + data->size > t->bt_ovflsize) { - if (key->size > t->bt_ovflsize) { -storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR) - return (RET_ERROR); - tkey.data = kb; - tkey.size = NOVFLSIZE; - memmove(kb, &pg, sizeof(pgno_t)); - memmove(kb + sizeof(pgno_t), - &key->size, sizeof(size_t)); - dflags |= P_BIGKEY; - key = &tkey; - } - if (key->size + data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - memmove(db, &pg, sizeof(pgno_t)); - memmove(db + sizeof(pgno_t), - &data->size, sizeof(size_t)); - dflags |= P_BIGDATA; - data = &tdata; - } - if (key->size + data->size > t->bt_ovflsize) - goto storekey; - } - - /* Replace the cursor. */ - if (flags == R_CURSOR) { - if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) - return (RET_ERROR); - index = t->bt_bcursor.index; - goto delete; - } - - /* - * Find the key to delete, or, the location at which to insert. Bt_fast - * and __bt_search pin the returned page. - */ - if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL) - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - h = e->page; - index = e->index; - - /* - * Add the specified key/data pair to the tree. If an identical key - * is already in the tree, and R_NOOVERWRITE is set, an error is - * returned. If R_NOOVERWRITE is not set, the key is either added (if - * duplicates are permitted) or an error is returned. - * - * Pages are split as required. - */ - switch (flags) { - case R_NOOVERWRITE: - if (!exact) - break; - /* - * One special case is if the cursor references the record and - * it's been flagged for deletion. Then, we delete the record, - * leaving the cursor there -- this means that the inserted - * record will not be seen in a cursor scan. - */ - if (ISSET(t, B_DELCRSR) && t->bt_bcursor.pgno == h->pgno && - t->bt_bcursor.index == index) { - CLR(t, B_DELCRSR); - goto delete; - } - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - default: - if (!exact || !ISSET(t, B_NODUPS)) - break; -delete: if (__bt_dleaf(t, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, or the user has put a ceiling on the number of - * keys permitted in the page, split the page. The split code will - * insert the key and data and unpin the current page. If inserting - * into the offset array, shift the pointers up. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - if ((status = __bt_split(t, h, key, - data, dflags, nbytes, index)) != RET_SUCCESS) - return (status); - goto success; - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BLEAF(dest, key, data, dflags); - - if (t->bt_order == NOT) { - if (h->nextpg == P_INVALID) { - if (index == NEXTINDEX(h) - 1) { - t->bt_order = FORWARD; - t->bt_last.index = index; - t->bt_last.pgno = h->pgno; - } - } else if (h->prevpg == P_INVALID) { - if (index == 0) { - t->bt_order = BACK; - t->bt_last.index = 0; - t->bt_last.pgno = h->pgno; - } - } - } - - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - -success: - if (flags == R_SETCURSOR) { - t->bt_bcursor.pgno = e->page->pgno; - t->bt_bcursor.index = e->index; - } - SET(t, B_MODIFIED); - return (RET_SUCCESS); -} - -#ifdef STATISTICS -u_long bt_cache_hit, bt_cache_miss; -#endif - -/* - * BT_FAST -- Do a quick check for sorted data. - * - * Parameters: - * t: tree - * key: key to insert - * - * Returns: - * EPG for new record or NULL if not found. - */ -static EPG * -bt_fast(BTREE *t, const DBT *key, const DBT *data, int *exactp) -{ - static EPG e; - PAGE *h; - size_t nbytes; - int cmp; - - if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) { - t->bt_order = NOT; - return (NULL); - } - e.page = h; - e.index = t->bt_last.index; - - /* - * If won't fit in this page or have too many keys in this page, have - * to search to get split stack. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) - goto miss; - - if (t->bt_order == FORWARD) { - if (e.page->nextpg != P_INVALID) - goto miss; - if (e.index != NEXTINDEX(h) - 1) - goto miss; - if ((cmp = __bt_cmp(t, key, &e)) < 0) - goto miss; - t->bt_last.index = cmp ? ++e.index : e.index; - } else { - if (e.page->prevpg != P_INVALID) - goto miss; - if (e.index != 0) - goto miss; - if ((cmp = __bt_cmp(t, key, &e)) > 0) - goto miss; - t->bt_last.index = 0; - } - *exactp = cmp == 0; -#ifdef STATISTICS - ++bt_cache_hit; -#endif - return (&e); - -miss: -#ifdef STATISTICS - ++bt_cache_miss; -#endif - t->bt_order = NOT; - mpool_put(t->bt_mp, h, 0); - return (NULL); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_search.c b/cde/lib/DtMmdb/btree_berkeley/bt_search.c deleted file mode 100644 index 7ab48abd5..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_search.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_search.c /main/3 1996/06/11 17:13:01 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_search.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -/* - * __BT_SEARCH -- Search a btree for a key. - * - * Parameters: - * t: tree to search - * key: key to find - * exactp: pointer to exact match flag - * - * Returns: - * EPG for matching record, if any, or the EPG for the location of the - * key, if it were inserted into the tree. - * - * Warnings: - * The EPG returned is in static memory, and will be overwritten by the - * next search of any kind in any tree. - */ -EPG * -__bt_search(BTREE *t, const DBT *key, int *exactp) -{ - indx_t index; - int base, cmp, lim; - PAGE *h; - pgno_t pg; - static EPG e; - - BT_CLR(t); - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - - /* Do a binary search on the current page. */ - e.page = h; - for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { - e.index = index = base + (lim >> 1); - if ((cmp = __bt_cmp(t, key, &e)) == 0) { - if (h->flags & P_BLEAF) { - *exactp = 1; - return (&e); - } - goto next; - } - if (cmp > 0) { - base = index + 1; - --lim; - } - } - - /* If it's a leaf page, we're done. */ - if (h->flags & P_BLEAF) { - e.index = base; - *exactp = 0; - return (&e); - } - - /* - * No match found. Base is the smallest index greater than - * key and may be zero or a last + 1 index. If it's non-zero, - * decrement by one, and record the internal page which should - * be a parent page for the key. If a split later occurs, the - * inserted page will be to the right of the saved page. - */ - index = base ? base - 1 : base; - -next: if (__bt_push(t, h->pgno, index) == RET_ERROR) - return (NULL); - pg = GETBINTERNAL(h, index)->pgno; - mpool_put(t->bt_mp, h, 0); - } -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_seq.c b/cde/lib/DtMmdb/btree_berkeley/bt_seq.c deleted file mode 100644 index 82bab6087..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_seq.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_seq.c /main/3 1996/06/11 17:13:05 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_seq.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_seqadv __P((BTREE *, EPG *, int)); -static int bt_seqset __P((BTREE *, EPG *, DBT *, int)); - -/* - * Sequential scan support. - * - * The tree can be scanned sequentially, starting from either end of the tree - * or from any specific key. A scan request before any scanning is done is - * initialized as starting from the least node. - * - * Each tree has an EPGNO which has the current position of the cursor. The - * cursor has to survive deletions/insertions in the tree without losing its - * position. This is done by noting deletions without doing them, and then - * doing them when the cursor moves (or the tree is closed). - */ - -/* - * __BT_SEQ -- Btree sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__bt_seq(const DB *dbp, DBT *key, DBT *data, u_int flags) -{ - BTREE *t; - EPG e; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If scan unitialized as yet, or starting at a specific record, set - * the scan to a specific key. Both bt_seqset and bt_seqadv pin the - * page the cursor references if they're successful. - */ - switch(flags) { - case R_NEXT: - case R_PREV: - if (ISSET(t, B_SEQINIT)) { - status = bt_seqadv(t, &e, flags); - break; - } - /* FALLTHROUGH */ - case R_CURSOR: - case R_FIRST: - case R_LAST: - status = bt_seqset(t, &e, key, flags); - break; - default: - errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) { - status = __bt_ret(t, &e, key, data); - - /* Update the actual cursor. */ - t->bt_bcursor.pgno = e.page->pgno; - t->bt_bcursor.index = e.index; - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e.page, 0); - else - t->bt_pinned = e.page; - SET(t, B_SEQINIT); - } - return (status); -} - -/* - * BT_SEQSET -- Set the sequential scan to a specific key. - * - * Parameters: - * t: tree - * ep: storage for returned key - * key: key for initial scan position - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV - * - * Side effects: - * Pins the page the cursor references. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -bt_seqset(BTREE *t, EPG *ep, DBT *key, int flags) -{ - EPG *e; - PAGE *h; - pgno_t pg; - int exact; - - /* - * Delete any already deleted record that we've been saving because - * the cursor pointed to it. Since going to a specific key, should - * delete any logically deleted records so they aren't found. - */ - if (ISSET(t, B_DELCRSR) && __bt_crsrdel(t, &t->bt_bcursor)) - return (RET_ERROR); - - /* - * Find the first, last or specific key in the tree and point the cursor - * at it. The cursor may not be moved until a new key has been found. - */ - switch(flags) { - case R_CURSOR: /* Keyed scan. */ - /* - * Find the first instance of the key or the smallest key which - * is greater than or equal to the specified key. If run out - * of keys, return RET_SPECIAL. - */ - if (key->data == NULL || key->size == 0) { - errno = EINVAL; - return (RET_ERROR); - } - e = __bt_first(t, key, &exact); /* Returns pinned page. */ - if (e == NULL) - return (RET_ERROR); - /* - * If at the end of a page, skip any empty pages and find the - * next entry. - */ - if (e->index == NEXTINDEX(e->page)) { - h = e->page; - do { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } while (NEXTINDEX(h) == 0); - e->index = 0; - e->page = h; - } - *ep = *e; - break; - case R_FIRST: /* First record. */ - case R_NEXT: - /* Walk down the left-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, 0)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - /* Skip any empty pages. */ - while (NEXTINDEX(h) == 0 && h->nextpg != P_INVALID) { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - ep->page = h; - ep->index = 0; - break; - case R_LAST: /* Last record. */ - case R_PREV: - /* Walk down the right-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - /* Skip any empty pages. */ - while (NEXTINDEX(h) == 0 && h->prevpg != P_INVALID) { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - ep->page = h; - ep->index = NEXTINDEX(h) - 1; - break; - } - return (RET_SUCCESS); -} - -/* - * BT_SEQADVANCE -- Advance the sequential scan. - * - * Parameters: - * t: tree - * flags: R_NEXT, R_PREV - * - * Side effects: - * Pins the page the new key/data record is on. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -bt_seqadv(BTREE *t, EPG *e, int flags) -{ - EPGNO *c, delc; - PAGE *h; - indx_t index; - pgno_t pg; - - /* Save the current cursor if going to delete it. */ - c = &t->bt_bcursor; - if (ISSET(t, B_DELCRSR)) - delc = *c; - - if ((h = mpool_get(t->bt_mp, c->pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * Find the next/previous record in the tree and point the cursor at it. - * The cursor may not be moved until a new key has been found. - */ - index = c->index; - switch(flags) { - case R_NEXT: /* Next record. */ - if (++index == NEXTINDEX(h)) { - do { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } while (NEXTINDEX(h) == 0); - index = 0; - } - break; - case R_PREV: /* Previous record. */ - if (index-- == 0) { - do { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } while (NEXTINDEX(h) == 0); - index = NEXTINDEX(h) - 1; - } - break; - } - - e->page = h; - e->index = index; - - /* - * Delete any already deleted record that we've been saving because the - * cursor pointed to it. This could cause the new index to be shifted - * down by one if the record we're deleting is on the same page and has - * a larger index. - */ - if (ISSET(t, B_DELCRSR)) { - CLR(t, B_DELCRSR); /* Don't try twice. */ - if (c->pgno == delc.pgno && c->index > delc.index) - --c->index; - if (__bt_crsrdel(t, &delc)) - return (RET_ERROR); - } - return (RET_SUCCESS); -} - -/* - * __BT_CRSRDEL -- Delete the record referenced by the cursor. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_crsrdel(BTREE *t, EPGNO *c) -{ - PAGE *h; - int status; - - CLR(t, B_DELCRSR); /* Don't try twice. */ - if ((h = mpool_get(t->bt_mp, c->pgno, 0)) == NULL) - return (RET_ERROR); - status = __bt_dleaf(t, h, c->index); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (status); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_split.c b/cde/lib/DtMmdb/btree_berkeley/bt_split.c deleted file mode 100644 index 434af3001..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_split.c +++ /dev/null @@ -1,826 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_split.c /main/3 1996/06/11 17:13:10 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_split.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#define __DBINTERFACE_PRIVATE -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static PAGE *bt_page - __P((BTREE *, PAGE *, PAGE **, PAGE **, u_int *, size_t)); -static int bt_preserve __P((BTREE *, pgno_t)); -static PAGE *bt_psplit - __P((BTREE *, PAGE *, PAGE *, PAGE *, u_int *, size_t)); -static PAGE *bt_root - __P((BTREE *, PAGE *, PAGE **, PAGE **, u_int *, size_t)); -static int bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static recno_t rec_total __P((PAGE *)); - -#ifdef STATISTICS -u_long bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved; -#endif - -/* - * __BT_SPLIT -- Split the tree. - * - * Parameters: - * t: tree - * sp: page to split - * key: key to insert - * data: data to insert - * flags: BIGKEY/BIGDATA flags - * ilen: insert length - * skip: index to leave open - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, u_long flags, size_t ilen, u_int skip) -{ - BINTERNAL *bi = NULL; - BLEAF *bl = NULL; - BLEAF *tbl; - DBT a, b; - EPGNO *parent; - PAGE *h, *l, *r, *lchild, *rchild; - indx_t nxtindex; - size_t n, nbytes; - size_t nksize = 0; - int parentsplit; - char *dest; - - /* - * Split the page into two pages, l and r. The split routines return - * a pointer to the page into which the key should be inserted and with - * skip set to the offset which should be used. Additionally, l and r - * are pinned. - */ - h = sp->pgno == P_ROOT ? - bt_root(t, sp, &l, &r, &skip, ilen) : - bt_page(t, sp, &l, &r, &skip, ilen); - if (h == NULL) - return (RET_ERROR); - - /* - * Insert the new key/data pair into the leaf page. (Key inserts - * always cause a leaf page to split first.) - */ - h->linp[skip] = h->upper -= ilen; - dest = (char *)h + h->upper; - if (ISSET(t, R_RECNO)) - WR_RLEAF(dest, data, flags) - else - WR_BLEAF(dest, key, data, flags) - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err2; - - /* - * Now we walk the parent page stack -- a LIFO stack of the pages that - * were traversed when we searched for the page that split. Each stack - * entry is a page number and a page index offset. The offset is for - * the page traversed on the search. We've just split a page, so we - * have to insert a new key into the parent page. - * - * If the insert into the parent page causes it to split, may have to - * continue splitting all the way up the tree. We stop if the root - * splits or the page inserted into didn't have to split to hold the - * new key. Some algorithms replace the key for the old page as well - * as the new page. We don't, as there's no reason to believe that the - * first key on the old page is any better than the key we have, and, - * in the case of a key being placed at index 0 causing the split, the - * key is unavailable. - * - * There are a maximum of 5 pages pinned at any time. We keep the left - * and right pages pinned while working on the parent. The 5 are the - * two children, left parent and right parent (when the parent splits) - * and the root page or the overflow key page when calling bt_preserve. - * This code must make sure that all pins are released other than the - * root page or overflow page which is unlocked elsewhere. - */ - while ((parent = BT_POP(t)) != NULL) { - lchild = l; - rchild = r; - - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - goto err2; - - /* - * The new key goes ONE AFTER the index, because the split - * was to the right. - */ - skip = parent->index + 1; - - /* - * Calculate the space needed on the parent page. - * - * Prefix trees: space hack when inserting into BINTERNAL - * pages. Retain only what's needed to distinguish between - * the new entry and the LAST entry on the page to its left. - * If the keys compare equal, retain the entire key. Note, - * we don't touch overflow keys, and the entire key must be - * retained for the next-to-left most key on the leftmost - * page of each level, or the search will fail. Applicable - * ONLY to internal pages that have leaf pages as children. - * Further reduction of the key between pairs of internal - * pages loses too much information. - */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(rchild, 0); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - bl = GETBLEAF(rchild, 0); - nbytes = NBINTERNAL(bl->ksize); - if (t->bt_pfx && !(bl->flags & P_BIGKEY) && - (h->prevpg != P_INVALID || skip > 1)) { - tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1); - a.size = tbl->ksize; - a.data = tbl->bytes; - b.size = bl->ksize; - b.data = bl->bytes; - nksize = t->bt_pfx(&a, &b); - n = NBINTERNAL(nksize); - if (n < nbytes) { -#ifdef STATISTICS - bt_pfxsaved += nbytes - n; -#endif - nbytes = n; - } else - nksize = 0; - } else - nksize = 0; - break; - case P_RINTERNAL: - case P_RLEAF: - nbytes = NRINTERNAL; - break; - default: - abort(); - } - - /* Split the parent page if necessary or shift the indices. */ - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - sp = h; - h = h->pgno == P_ROOT ? - bt_root(t, h, &l, &r, &skip, nbytes) : - bt_page(t, h, &l, &r, &skip, nbytes); - if (h == NULL) - goto err1; - parentsplit = 1; - } else { - if (skip < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + skip + 1, h->linp + skip, - (nxtindex - skip) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - parentsplit = 0; - } - - /* Insert the key into the parent page. */ - switch(rchild->flags & P_TYPE) { - case P_BINTERNAL: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_BLEAF: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, - rchild->pgno, bl->flags & P_BIGKEY); - memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(char *)bl->bytes) == RET_ERROR) - goto err1; - break; - case P_RINTERNAL: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = rec_total(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = rec_total(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_RLEAF: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - default: - abort(); - } - - /* Unpin the held pages. */ - if (!parentsplit) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err1; - - mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - } - - /* Unpin the held pages. */ - mpool_put(t->bt_mp, l, MPOOL_DIRTY); - mpool_put(t->bt_mp, r, MPOOL_DIRTY); - - /* Clear any pages left on the stack. */ - return (RET_SUCCESS); - - /* - * If something fails in the above loop we were already walking back - * up the tree and the tree is now inconsistent. Nothing much we can - * do about it but release any memory we're holding. - */ -err1: mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - -err2: mpool_put(t->bt_mp, l, 0); - mpool_put(t->bt_mp, r, 0); - __dbpanic(t->bt_dbp); - return (RET_ERROR); -} - -/* - * BT_PAGE -- Split a non-root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_page(BTREE *t, PAGE *h, PAGE **lp, PAGE **rp, u_int *skip, size_t ilen) -{ - PAGE *l, *r, *tp; - pgno_t npg; - -#ifdef STATISTICS - ++bt_split; -#endif - /* Put the new right page for the split into place. */ - if ((r = __bt_new(t, &npg)) == NULL) - return (NULL); - r->pgno = npg; - r->lower = BTDATAOFF; - r->upper = t->bt_psize; - r->nextpg = h->nextpg; - r->prevpg = h->pgno; - r->flags = h->flags & P_TYPE; - - /* - * If we're splitting the last page on a level because we're appending - * a key to it (skip is NEXTINDEX()), it's likely that the data is - * sorted. Adding an empty page on the side of the level is less work - * and can push the fill factor much higher than normal. If we're - * wrong it's no big deal, we'll just do the split the right way next - * time. It may look like it's equally easy to do a similar hack for - * reverse sorted data, that is, split the tree left, but it's not. - * Don't even try. - */ - if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) { -#ifdef STATISTICS - ++bt_sortsplit; -#endif - h->nextpg = r->pgno; - r->lower = BTDATAOFF + sizeof(indx_t); - *skip = 0; - *lp = h; - *rp = r; - return (r); - } - - /* Put the new left page for the split into place. */ - if ((l = malloc(t->bt_psize)) == NULL) { - mpool_put(t->bt_mp, r, 0); - return (NULL); - } - l->pgno = h->pgno; - l->nextpg = r->pgno; - l->prevpg = h->prevpg; - l->lower = BTDATAOFF; - l->upper = t->bt_psize; - l->flags = h->flags & P_TYPE; - - /* Fix up the previous pointer of the page after the split page. */ - if (h->nextpg != P_INVALID) { - if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) { - free(l); - /* XXX mpool_free(t->bt_mp, r->pgno); */ - return (NULL); - } - tp->prevpg = r->pgno; - mpool_put(t->bt_mp, tp, 0); - } - - /* - * Split right. The key/data pairs aren't sorted in the btree page so - * it's simpler to copy the data from the split page onto two new pages - * instead of copying half the data to the right page and compacting - * the left page in place. Since the left page can't change, we have - * to swap the original and the allocated left page after the split. - */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - /* Move the new left page onto the old left page. */ - memmove(h, l, t->bt_psize); - if (tp == l) - tp = h; - free(l); - - *lp = h; - *rp = r; - return (tp); -} - -/* - * BT_ROOT -- Split the root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_root(BTREE *t, PAGE *h, PAGE **lp, PAGE **rp, u_int *skip, size_t ilen) -{ - PAGE *l, *r, *tp; - pgno_t lnpg, rnpg; - -#ifdef STATISTICS - ++bt_split; - ++bt_rootsplit; -#endif - /* Put the new left and right pages for the split into place. */ - if ((l = __bt_new(t, &lnpg)) == NULL || - (r = __bt_new(t, &rnpg)) == NULL) - return (NULL); - l->pgno = lnpg; - r->pgno = rnpg; - l->nextpg = r->pgno; - r->prevpg = l->pgno; - l->prevpg = r->nextpg = P_INVALID; - l->lower = r->lower = BTDATAOFF; - l->upper = r->upper = t->bt_psize; - l->flags = r->flags = h->flags & P_TYPE; - - /* Split the root page. */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - *lp = l; - *rp = r; - return (tp); -} - -/* - * BT_RROOT -- Fix up the recno root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_rroot(BTREE *t, PAGE *h, PAGE *l, PAGE *r) -{ - char *dest; - - /* Insert the left and right keys, set the header information. */ - h->linp[0] = h->upper = t->bt_psize - NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno); - - h->linp[1] = h->upper -= NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno); - - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to recno internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_RINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_BROOT -- Fix up the btree root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r) -{ - BINTERNAL *bi; - BLEAF *bl; - size_t nbytes; - char *dest; - - /* - * If the root page was a leaf page, change it into an internal page. - * We copy the key we split on (but not the key's data, in the case of - * a leaf page) to the new root page. - * - * The btree comparison code guarantees that the left-most key on any - * level of the tree is never used, so it doesn't need to be filled in. - */ - nbytes = NBINTERNAL(0); - h->linp[0] = h->upper = t->bt_psize - nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, 0, l->pgno, 0); - - switch(h->flags & P_TYPE) { - case P_BLEAF: - bl = GETBLEAF(r, 0); - nbytes = NBINTERNAL(bl->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, bl->ksize, r->pgno, 0); - memmove(dest, bl->bytes, bl->ksize); - - /* - * If the key is on an overflow page, mark the overflow chain - * so it isn't deleted when the leaf copy of the key is deleted. - */ - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(char *)bl->bytes) == RET_ERROR) - return (RET_ERROR); - break; - case P_BINTERNAL: - bi = GETBINTERNAL(r, 0); - nbytes = NBINTERNAL(bi->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = r->pgno; - break; - default: - abort(); - } - - /* There are two keys on the page. */ - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to btree internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_BINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_PSPLIT -- Do the real work of splitting the page. - * - * Parameters: - * t: tree - * h: page to be split - * l: page to put lower half of data - * r: page to put upper half of data - * pskip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert. - */ -static PAGE * -bt_psplit(BTREE *t, PAGE *h, PAGE *l, PAGE *r, u_int *pskip, size_t ilen) -{ - BINTERNAL *bi; - BLEAF *bl; - RLEAF *rl; - EPGNO *c; - PAGE *rval; - void *src = NULL; - indx_t full, half, nxt, off, skip, top, used; - size_t nbytes; - int bigkeycnt, isbigkey; - - /* - * Split the data to the left and right pages. Leave the skip index - * open. Additionally, make some effort not to split on an overflow - * key. This makes internal page processing faster and can save - * space as overflow keys used by internal pages are never deleted. - */ - bigkeycnt = 0; - skip = *pskip; - full = t->bt_psize - BTDATAOFF; - half = full / 2; - used = 0; - for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { - if (skip == off) { - nbytes = ilen; - isbigkey = 0; /* XXX: not really known. */ - } else - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - isbigkey = bi->flags & P_BIGKEY; - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - isbigkey = bl->flags & P_BIGKEY; - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - isbigkey = 0; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - isbigkey = 0; - break; - default: - abort(); - } - - /* - * If the key/data pairs are substantial fractions of the max - * possible size for the page, it's possible to get situations - * where we decide to try and copy too much onto the left page. - * Make sure that doesn't happen. - */ - if (skip <= off && used + nbytes >= full) { - --off; - break; - } - - /* Copy the key/data pair, if not the skipped index. */ - if (skip != off) { - ++nxt; - - l->linp[off] = l->upper -= nbytes; - memmove((char *)l + l->upper, src, nbytes); - } - - used += nbytes; - if (used >= half) { - if (!isbigkey || bigkeycnt == 3) - break; - else - ++bigkeycnt; - } - } - - /* - * Off is the last offset that's valid for the left page. - * Nxt is the first offset to be placed on the right page. - */ - l->lower += (off + 1) * sizeof(indx_t); - - /* - * If splitting the page that the cursor was on, the cursor has to be - * adjusted to point to the same record as before the split. If the - * cursor is at or past the skipped slot, the cursor is incremented by - * one. If the cursor is on the right page, it is decremented by the - * number of records split to the left page. - * - * Don't bother checking for the B_SEQINIT flag, the page number will - * be P_INVALID. - */ - c = &t->bt_bcursor; - if (c->pgno == h->pgno) { - if (c->index >= skip) - ++c->index; - if (c->index < nxt) /* Left page. */ - c->pgno = l->pgno; - else { /* Right page. */ - c->pgno = r->pgno; - c->index -= nxt; - } - } - - /* - * If the skipped index was on the left page, just return that page. - * Otherwise, adjust the skip index to reflect the new position on - * the right page. - */ - if (skip <= off) { - skip = 0; - rval = l; - } else { - rval = r; - *pskip -= nxt; - } - - for (off = 0; nxt < top; ++off) { - if (skip == nxt) { - ++off; - skip = 0; - } - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - break; - default: - abort(); - } - ++nxt; - r->linp[off] = r->upper -= nbytes; - memmove((char *)r + r->upper, src, nbytes); - } - r->lower += off * sizeof(indx_t); - - /* If the key is being appended to the page, adjust the index. */ - if (skip == top) - r->lower += sizeof(indx_t); - - return (rval); -} - -/* - * BT_PRESERVE -- Mark a chain of pages as used by an internal node. - * - * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the - * record that references them gets deleted. Chains pointed to by internal - * pages never get deleted. This routine marks a chain as pointed to by an - * internal page. - * - * Parameters: - * t: tree - * pg: page number of first page in the chain. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -bt_preserve(BTREE *t, pgno_t pg) -{ - PAGE *h; - - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - h->flags |= P_PRESERVE; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * REC_TOTAL -- Return the number of recno entries below a page. - * - * Parameters: - * h: page - * - * Returns: - * The number of recno entries below a page. - * - * XXX - * These values could be set by the bt_psplit routine. The problem is that the - * entry has to be popped off of the stack etc. or the values have to be passed - * all the way back to bt_split/bt_rroot and it's not very clean. - */ -static recno_t -rec_total(PAGE *h) -{ - recno_t recs; - indx_t nxt, top; - - for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt) - recs += GETRINTERNAL(h, nxt)->nrecs; - return (recs); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_stack.c b/cde/lib/DtMmdb/btree_berkeley/bt_stack.c deleted file mode 100644 index 27c10452c..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_stack.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_stack.c /main/3 1996/06/11 17:13:15 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_stack.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * When a page splits, a new record has to be inserted into its parent page. - * This page may have to split as well, all the way up to the root. Since - * parent pointers in each page would be expensive, we maintain a stack of - * parent pages as we descend the tree. - * - * XXX - * This is a concurrency problem -- if user a builds a stack, then user b - * splits the tree, then user a tries to split the tree, there's a new level - * in the tree that user a doesn't know about. - */ - -/* - * __BT_PUSH -- Push parent page info onto the stack (LIFO). - * - * Parameters: - * t: tree - * pgno: page - * index: page index - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_push(BTREE *t, pgno_t pgno, int index) -{ - if (t->bt_sp == t->bt_maxstack) { - t->bt_maxstack += 50; - if ((t->bt_stack = __fix_realloc(t->bt_stack, - t->bt_maxstack * sizeof(EPGNO))) == NULL) { - t->bt_maxstack -= 50; - return (RET_ERROR); - } - } - - t->bt_stack[t->bt_sp].pgno = pgno; - t->bt_stack[t->bt_sp].index = index; - ++t->bt_sp; - return (RET_SUCCESS); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/bt_utils.c b/cde/lib/DtMmdb/btree_berkeley/bt_utils.c deleted file mode 100644 index 3e6f499eb..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/bt_utils.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: bt_utils.c /main/3 1996/06/11 17:13:20 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_utils.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_RET -- Build return key/data pair as a result of search or scan. - * - * Parameters: - * t: tree - * d: LEAF to be returned to the user. - * key: user's key structure (NULL if not to be filled in) - * data: user's data structure - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_ret(BTREE *t, EPG *e, DBT *key, DBT *data) -{ - BLEAF *bl; - void *p; - - bl = GETBLEAF(e->page, e->index); - - /* - * We always copy big keys/data to make them contigous. Otherwise, - * we leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - if (bl->flags & P_BIGDATA) { - if (__ovfl_get(t, bl->bytes + bl->ksize, - &data->size, &t->bt_dbuf, &t->bt_dbufsz)) - return (RET_ERROR); - data->data = t->bt_dbuf; - } else if (ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (bl->dsize + 1 > t->bt_dbufsz) { - if ((p = __fix_realloc(t->bt_dbuf, bl->dsize + 1)) == NULL) - return (RET_ERROR); - t->bt_dbuf = p; - t->bt_dbufsz = bl->dsize + 1; - } - memmove(t->bt_dbuf, bl->bytes + bl->ksize, bl->dsize); - data->size = bl->dsize; - data->data = t->bt_dbuf; - } else { - data->size = bl->dsize; - data->data = bl->bytes + bl->ksize; - } - - if (key == NULL) - return (RET_SUCCESS); - - if (bl->flags & P_BIGKEY) { - if (__ovfl_get(t, bl->bytes, - &key->size, &t->bt_kbuf, &t->bt_kbufsz)) - return (RET_ERROR); - key->data = t->bt_kbuf; - } else if (ISSET(t, B_DB_LOCK)) { - if (bl->ksize > t->bt_kbufsz) { - if ((p = __fix_realloc(t->bt_kbuf, bl->ksize)) == NULL) - return (RET_ERROR); - t->bt_kbuf = p; - t->bt_kbufsz = bl->ksize; - } - memmove(t->bt_kbuf, bl->bytes, bl->ksize); - key->size = bl->ksize; - key->data = t->bt_kbuf; - } else { - key->size = bl->ksize; - key->data = bl->bytes; - } - return (RET_SUCCESS); -} - -/* - * __BT_CMP -- Compare a key to a given record. - * - * Parameters: - * t: tree - * k1: DBT pointer of first arg to comparison - * e: pointer to EPG for comparison - * - * Returns: - * < 0 if k1 is < record - * = 0 if k1 is = record - * > 0 if k1 is > record - */ -int -__bt_cmp(BTREE *t, const DBT *k1, EPG *e) -{ - BINTERNAL *bi; - BLEAF *bl; - DBT k2; - PAGE *h; - void *bigkey; - - /* - * The left-most key on internal pages, at any level of the tree, is - * guaranteed by the following code to be less than any user key. - * This saves us from having to update the leftmost key on an internal - * page when the user inserts a new key in the tree smaller than - * anything we've yet seen. - */ - h = e->page; - if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF)) - return (1); - - bigkey = NULL; - if (h->flags & P_BLEAF) { - bl = GETBLEAF(h, e->index); - if (bl->flags & P_BIGKEY) - bigkey = bl->bytes; - else { - k2.data = bl->bytes; - k2.size = bl->ksize; - } - } else { - bi = GETBINTERNAL(h, e->index); - if (bi->flags & P_BIGKEY) - bigkey = bi->bytes; - else { - k2.data = bi->bytes; - k2.size = bi->ksize; - } - } - - if (bigkey) { - if (__ovfl_get(t, bigkey, - &k2.size, &t->bt_dbuf, &t->bt_dbufsz)) - return (RET_ERROR); - k2.data = t->bt_dbuf; - } - return ((*t->bt_cmp)(k1, &k2)); -} - -/* - * __BT_DEFCMP -- Default comparison routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * < 0 if a is < b - * = 0 if a is = b - * > 0 if a is > b - */ -int -__bt_defcmp(const DBT *a, const DBT *b) -{ - u_char *p1, *p2; - int diff, len; - - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2) - if ((diff = *p1 - *p2)) - return (diff); - return (a->size - b->size); -} - -/* - * __BT_DEFPFX -- Default prefix routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * Number of bytes needed to distinguish b from a. - */ -int -__bt_defpfx(const DBT *a, const DBT *b) -{ - u_char *p1, *p2; - int len; - int cnt; - - cnt = 1; - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt) - if (*p1 != *p2) - return (cnt); - - /* a->size must be <= b->size, or they wouldn't be in this order. */ - return (a->size < b->size ? a->size + 1 : a->size); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/btree.h b/cde/lib/DtMmdb/btree_berkeley/btree.h deleted file mode 100644 index b353017dc..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/btree.h +++ /dev/null @@ -1,374 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: btree.h /main/5 1996/07/18 16:31:58 drk $ */ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)btree.h 8.2 (Berkeley) 9/7/93 - */ - -#include - -#define DEFMINKEYPAGE (2) /* Minimum keys per page */ -#define MINCACHE (5) /* Minimum cached pages */ -#define MINPSIZE (512) /* Minimum page size */ - -/* - * Page 0 of a btree file contains a copy of the meta-data. This page is also - * used as an out-of-band page, i.e. page pointers that point to nowhere point - * to page 0. Page 1 is the root of the btree. - */ -#define P_INVALID 0 /* Invalid tree page number. */ -#define P_META 0 /* Tree metadata page number. */ -#define P_ROOT 1 /* Tree root page number. */ - -/* - * There are five page layouts in the btree: btree internal pages (BINTERNAL), - * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages - * (RLEAF) and overflow pages. All five page types have a page header (PAGE). - * This implementation requires that longs within structures are NOT padded. - * (ANSI C permits random padding.) If your compiler pads randomly you'll have - * to do some work to get this package to run. - */ -typedef struct _page { - pgno_t pgno; /* this page's page number */ - pgno_t prevpg; /* left sibling */ - pgno_t nextpg; /* right sibling */ - -#define P_BINTERNAL 0x01 /* btree internal page */ -#define P_BLEAF 0x02 /* leaf page */ -#define P_OVERFLOW 0x04 /* overflow page */ -#define P_RINTERNAL 0x08 /* recno internal page */ -#define P_RLEAF 0x10 /* leaf page */ -#define P_TYPE 0x1f /* type mask */ - -#define P_PRESERVE 0x20 /* never delete this chain of pages */ - u_long flags; - - indx_t lower; /* lower bound of free space on page */ - indx_t upper; /* upper bound of free space on page */ - indx_t linp[1]; /* long-aligned VARIABLE LENGTH DATA */ -} PAGE; - -/* First and next index. */ -#define BTDATAOFF (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ - sizeof(u_long) + sizeof(indx_t) + sizeof(indx_t)) -#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) - -/* - * For pages other than overflow pages, there is an array of offsets into the - * rest of the page immediately following the page header. Each offset is to - * an item which is unique to the type of page. The h_lower offset is just - * past the last filled-in index. The h_upper offset is the first item on the - * page. Offsets are from the beginning of the page. - * - * If an item is too big to store on a single page, a flag is set and the item - * is a { page, size } pair such that the page is the first page of an overflow - * chain with size bytes of item. Overflow pages are simply bytes without any - * external structure. - * - * The size and page number fields in the items are long aligned so they can be - * manipulated without copying. - */ -#define LALIGN(n) (((n) + sizeof(u_long) - 1) & ~(sizeof(u_long) - 1)) -#define NOVFLSIZE (sizeof(pgno_t) + sizeof(size_t)) - -/* - * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} - * pairs, such that the key compares less than or equal to all of the records - * on that page. For a tree without duplicate keys, an internal page with two - * consecutive keys, a and b, will have all records greater than or equal to a - * and less than b stored on the page associated with a. Duplicate keys are - * somewhat special and can cause duplicate internal and leaf page records and - * some minor modifications of the above rule. - */ -typedef struct _binternal { - size_t ksize; /* key size */ - pgno_t pgno; /* page number stored on */ -#define P_BIGDATA 0x01 /* overflow data */ -#define P_BIGKEY 0x02 /* overflow key */ - u_char flags; - char bytes[1]; /* data */ -} BINTERNAL; - -/* Get the page's BINTERNAL structure at index indx. */ -#define GETBINTERNAL(pg, indx) \ - ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBINTERNAL(len) \ - LALIGN(sizeof(size_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) - -/* Copy a BINTERNAL entry to the page. */ -#define WR_BINTERNAL(p, size, pgno, flags) { \ - *(size_t *)p = size; \ - p += sizeof(size_t); \ - *(pgno_t *)p = pgno; \ - p += sizeof(pgno_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ -} - -/* - * For the recno internal pages, the item is a page number with the number of - * keys found on that page and below. - */ -typedef struct _rinternal { - recno_t nrecs; /* number of records */ - pgno_t pgno; /* page number stored below */ -} RINTERNAL; - -/* Get the page's RINTERNAL structure at index indx. */ -#define GETRINTERNAL(pg, indx) \ - ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRINTERNAL \ - LALIGN(sizeof(recno_t) + sizeof(pgno_t)) - -/* Copy a RINTERAL entry to the page. */ -#define WR_RINTERNAL(p, nrecs, pgno) { \ - *(recno_t *)p = nrecs; \ - p += sizeof(recno_t); \ - *(pgno_t *)p = pgno; \ -} - -/* For the btree leaf pages, the item is a key and data pair. */ -typedef struct _bleaf { - size_t ksize; /* size of key */ - size_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA, P_BIGKEY */ - char bytes[1]; /* data */ -} BLEAF; - -/* Get the page's BLEAF structure at index indx. */ -#define GETBLEAF(pg, indx) \ - ((BLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) - -/* Get the number of bytes in the user's key/data pair. */ -#define NBLEAFDBT(ksize, dsize) \ - LALIGN(sizeof(size_t) + sizeof(size_t) + sizeof(u_char) + \ - (ksize) + (dsize)) - -/* Copy a BLEAF entry to the page. */ -#define WR_BLEAF(p, key, data, flags) { \ - *(size_t *)p = key->size; \ - p += sizeof(size_t); \ - *(size_t *)p = data->size; \ - p += sizeof(size_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, key->data, key->size); \ - p += key->size; \ - memmove(p, data->data, data->size); \ -} - -/* For the recno leaf pages, the item is a data entry. */ -typedef struct _rleaf { - size_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA */ - char bytes[1]; -} RLEAF; - -/* Get the page's RLEAF structure at index indx. */ -#define GETRLEAF(pg, indx) \ - ((RLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRLEAF(p) NRLEAFDBT((p)->dsize) - -/* Get the number of bytes from the user's data. */ -#define NRLEAFDBT(dsize) \ - LALIGN(sizeof(size_t) + sizeof(u_char) + (dsize)) - -/* Copy a RLEAF entry to the page. */ -#define WR_RLEAF(p, data, flags) { \ - *(size_t *)p = data->size; \ - p += sizeof(size_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, data->data, data->size); \ -} - -/* - * A record in the tree is either a pointer to a page and an index in the page - * or a page number and an index. These structures are used as a cursor, stack - * entry and search returns as well as to pass records to other routines. - * - * One comment about searches. Internal page searches must find the largest - * record less than key in the tree so that descents work. Leaf page searches - * must find the smallest record greater than key so that the returned index - * is the record's correct position for insertion. - * - * One comment about cursors. The cursor key is never removed from the tree, - * even if deleted. This is because it is quite difficult to decide where the - * cursor should be when other keys have been inserted/deleted in the tree; - * duplicate keys make it impossible. This scheme does require extra work - * though, to make sure that we don't perform an operation on a deleted key. - */ -typedef struct _epgno { - pgno_t pgno; /* the page number */ - indx_t index; /* the index on the page */ -} EPGNO; - -typedef struct _epg { - PAGE *page; /* the (pinned) page */ - indx_t index; /* the index on the page */ -} EPG; - -/* - * The metadata of the tree. The m_nrecs field is used only by the RECNO code. - * This is because the btree doesn't really need it and it requires that every - * put or delete call modify the metadata. - */ -typedef struct _btmeta { - u_long m_magic; /* magic number */ - u_long m_version; /* version */ - u_long m_psize; /* page size */ - u_long m_free; /* page number of first free page */ - u_long m_nrecs; /* R: number of records */ -#define SAVEMETA (B_NODUPS | R_RECNO) - u_long m_flags; /* bt_flags & SAVEMETA */ - u_long m_unused; /* unused */ -} BTMETA; - -/* The in-memory btree/recno data structure. */ -typedef struct _btree { - MPOOL *bt_mp; /* memory pool cookie */ - - DB *bt_dbp; /* pointer to enclosing DB */ - - PAGE *bt_pinned; /* page pinned across calls */ - - EPGNO bt_bcursor; /* B: btree cursor */ - recno_t bt_rcursor; /* R: recno cursor (1-based) */ - -#define BT_POP(t) (t->bt_sp ? t->bt_stack + --t->bt_sp : NULL) -#define BT_CLR(t) (t->bt_sp = 0) - EPGNO *bt_stack; /* stack of parent pages */ - u_int bt_sp; /* current stack pointer */ - u_int bt_maxstack; /* largest stack */ - - char *bt_kbuf; /* key buffer */ - size_t bt_kbufsz; /* key buffer size */ - char *bt_dbuf; /* data buffer */ - size_t bt_dbufsz; /* data buffer size */ - - int bt_fd; /* tree file descriptor */ - - pgno_t bt_free; /* next free page */ - u_long bt_psize; /* page size */ - indx_t bt_ovflsize; /* cut-off for key/data overflow */ - int bt_lorder; /* byte order */ - /* sorted order */ - enum { NOT, BACK, FORWARD } bt_order; - EPGNO bt_last; /* last insert */ - - /* B: key comparison function */ - int (*bt_cmp) __P((const DBT *, const DBT *)); - /* B: prefix comparison function */ - int (*bt_pfx) __P((const DBT *, const DBT *)); - /* R: recno input function */ - int (*bt_irec) __P((struct _btree *, recno_t)); - - FILE *bt_rfp; /* R: record FILE pointer */ - int bt_rfd; /* R: record file descriptor */ - - caddr_t bt_cmap; /* R: current point in mapped space */ - caddr_t bt_smap; /* R: start of mapped space */ - caddr_t bt_emap; /* R: end of mapped space */ - size_t bt_msize; /* R: size of mapped region. */ - - recno_t bt_nrecs; /* R: number of records */ - size_t bt_reclen; /* R: fixed record length */ - u_char bt_bval; /* R: delimiting byte/pad character */ - -/* - * NB: - * B_NODUPS and R_RECNO are stored on disk, and may not be changed. - */ -#define B_DELCRSR 0x00001 /* cursor has been deleted */ -#define B_INMEM 0x00002 /* in-memory tree */ -#define B_METADIRTY 0x00004 /* need to write metadata */ -#define B_MODIFIED 0x00008 /* tree modified */ -#define B_NEEDSWAP 0x00010 /* if byte order requires swapping */ -#define B_NODUPS 0x00020 /* no duplicate keys permitted */ -#define B_RDONLY 0x00040 /* read-only tree */ -#define R_RECNO 0x00080 /* record oriented tree */ -#define B_SEQINIT 0x00100 /* sequential scan initialized */ - -#define R_CLOSEFP 0x00200 /* opened a file pointer */ -#define R_EOF 0x00400 /* end of input file reached. */ -#define R_FIXLEN 0x00800 /* fixed length records */ -#define R_MEMMAPPED 0x01000 /* memory mapped file. */ -#define R_INMEM 0x02000 /* in-memory file */ -#define R_MODIFIED 0x04000 /* modified file */ -#define R_RDONLY 0x08000 /* read-only file */ - -#define B_DB_LOCK 0x10000 /* DB_LOCK specified. */ -#define B_DB_SHMEM 0x20000 /* DB_SHMEM specified. */ -#define B_DB_TXN 0x40000 /* DB_TXN specified. */ - - u_long bt_flags; /* btree state */ -} BTREE; - -#define SET(t, f) ((t)->bt_flags |= (f)) -#define CLR(t, f) ((t)->bt_flags &= ~(f)) -#define ISSET(t, f) ((t)->bt_flags & (f)) - -#include "extern.h" diff --git a/cde/lib/DtMmdb/btree_berkeley/cdefs.h b/cde/lib/DtMmdb/btree_berkeley/cdefs.h deleted file mode 100644 index 76660a964..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/cdefs.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: cdefs.h /main/4 1996/06/11 17:13:31 cde-hal $ */ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _CDEFS_H_ -#define _CDEFS_H_ - -#if defined(__cplusplus) -#ifndef __BEGIN_DECLS -#define __BEGIN_DECLS extern "C" { -#endif -#ifndef __END_DECLS -#define __END_DECLS }; -#endif -#else -#undef __BEGIN_DECLS -#define __BEGIN_DECLS -#undef __END_DECLS -#define __END_DECLS -#endif - -/* - * The __CONCAT macro is used to concatenate parts of symbol names, e.g. - * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. - * The __CONCAT macro is a bit tricky -- make sure you don't put spaces - * in between its arguments. __CONCAT can also concatenate double-quoted - * strings produced by the __STRING macro, but this only works with ANSI C. - */ -#if defined(__STDC__) || defined(__cplusplus) -#ifdef __P -#undef __P -#endif -#define __P(protos) protos /* full-blown ANSI C */ -#ifndef __CONCAT -#define __CONCAT(x,y) x ## y -#endif -#define __STRING(x) #x - -#else /* !(__STDC__ || __cplusplus) */ -#ifdef __P -#undef __P -#endif -#define __P(protos) () /* traditional C preprocessor */ -#define __CONCAT(x,y) x/**/y -#define __STRING(x) "x" - -#ifdef __GNUC__ -#define const __const /* GCC: ANSI C with -traditional */ -#define inline __inline -#define signed __signed -#define volatile __volatile - -#else /* !__GNUC__ */ -#define const /* delete ANSI C keywords */ -#define inline -#define signed -#define volatile -#endif /* !__GNUC__ */ -#endif /* !(__STDC__ || __cplusplus) */ - -/* - * GCC has extensions for declaring functions as `pure' (always returns - * the same value given the same inputs, i.e., has no external state and - * no side effects) and `dead' (nonreturning). These mainly affect - * optimization and warnings. Unfortunately, GCC complains if these are - * used under strict ANSI mode (`gcc -ansi -pedantic'), hence we need to - * define them only if compiling without this. - */ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#undef __dead -#define __dead __volatile -#ifndef __pure -#define __pure __const -#endif -#else -#define __dead -#define __pure -#endif - -#endif /* !_CDEFS_H_ */ diff --git a/cde/lib/DtMmdb/btree_berkeley/compat.h b/cde/lib/DtMmdb/btree_berkeley/compat.h deleted file mode 100644 index e5c8d5bab..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/compat.h +++ /dev/null @@ -1,254 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: compat.h /main/8 1996/07/18 16:32:14 drk $ */ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)compat.h 8.3 (Berkeley) 9/6/93 - */ - -#ifndef _COMPAT_H_ -#define _COMPAT_H_ - -#include -#include "utility/config.h" - -/* - * If your system doesn't typedef u_long, u_short, or u_char, change - * the 0 to a 1. - */ -#if 0 -typedef unsigned long u_long; -typedef unsigned short u_short; -typedef unsigned char u_char; -#endif - -/* If your system doesn't typedef size_t, change the 0 to a 1. */ -#if 0 -typedef unsigned int size_t; -#endif - -/* - * If your system doesn't have the POSIX type for a signal mask, - * change the 0 to a 1. - */ -#if 0 -typedef unsigned int sigset_t; -#endif - -/* - * If you don't have POSIX 1003.1 signals, the signal code surrounding the - * temporary file creation is intended to block all of the possible signals - * long enough to create the file and unlink it. All of this stuff is - * intended to use old-style BSD calls to fake POSIX 1003.1 calls. - */ -#ifdef NO_POSIX_SIGNALS -#define sigemptyset(set) (*(set) = 0) -#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) -#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) -#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) -#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) - -#define SIG_BLOCK 1 -#define SIG_UNBLOCK 2 -#define SIG_SETMASK 3 - -static int __sigtemp; /* For the use of sigprocmask */ - -/* Repeated test of oset != NULL is to avoid "*0". */ -#define sigprocmask(how, set, oset) \ - ((__sigtemp = \ - (((how) == SIG_BLOCK) ? \ - sigblock(0) | *(set) : \ - (((how) == SIG_UNBLOCK) ? \ - sigblock(0) & ~(*(set)) : \ - ((how) == SIG_SETMASK ? \ - *(set) : sigblock(0))))), \ - ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ - sigsetmask(__sigtemp)), 0) -#endif - -/* - * If realloc(3) of a NULL pointer on your system isn't the same as - * a malloc(3) call, change the 0 to a 1, and add realloc.o to the - * MISC line in your Makefile. - */ -/* -#if 1 -#define realloc __fix_realloc -#endif -*/ -void * __fix_realloc __P((void*, size_t)); - - -/* - * If your system doesn't have an include file with the appropriate - * byte order set, make sure you specify the correct one. - */ -#ifndef BYTE_ORDER - -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ - -#ifdef MMDB_LITTLE_ENDIAN -#define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ -#endif - -#ifdef MMDB_BIG_ENDIAN -#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ -#endif - - -#endif - -#if defined(SYSV) || defined(SYSTEM5) || defined(SVR4) -/* #define index(a, b) strchr(a, b) */ -#ifndef rindex -#define rindex(a, b) strrchr(a, b) -#endif -#define bzero(a, b) memset(a, 0, b) -#define bcmp(a, b, n) memcmp(a, b, n) -#define bcopy(a, b, n) memmove(b, a, n) -#endif - -#if defined(BSD) || defined(BSD4_3) -#define strchr(a, b) index(a, b) -#define strrchr(a, b) rindex(a, b) -#define memcmp(a, b, n) bcmp(a, b, n) -#define memmove(a, b, n) bcopy(b, a, n) -#endif - -/* - * 32-bit machine. The db routines are theoretically independent of - * the size of u_shorts and u_longs, but I don't know that anyone has - * ever actually tried it. At a minimum, change the following #define's - * if you are trying to compile on a different type of system. - */ -#ifndef USHRT_MAX -#define USHRT_MAX 0xFFFF -#define ULONG_MAX 0xFFFFFFFF -#endif - -/* POSIX 1003.1 access mode mask. */ -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) -#endif - -/* POSIX 1003.2 RE limit. */ -#ifndef _POSIX2_RE_DUP_MAX -#define _POSIX2_RE_DUP_MAX 255 -#endif - -/* - * If you can't provide lock values in the open(2) call. Note, this - * allows races to happen. - */ -#ifndef O_EXLOCK -#define O_EXLOCK 0 -#endif - -#ifndef O_SHLOCK -#define O_SHLOCK 0 -#endif - -#ifndef EFTYPE -#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ -#endif - -#ifndef WCOREDUMP /* 4.4BSD extension */ -#define WCOREDUMP(a) 0 -#endif - -#ifndef STDERR_FILENO -#define STDIN_FILENO 0 /* ANSI C #defines */ -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif - -#ifndef SEEK_END -#define SEEK_SET 0 /* POSIX 1003.1 seek values */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ -#define S_ISLNK(m) ((m & 0170000) == 0120000) -#define S_ISSOCK(m) ((m & 0170000) == 0140000) -#endif - -#ifndef TCSASOFT -#define TCSASOFT 0 -#endif - -#ifndef _POSIX2_RE_DUP_MAX -#define _POSIX2_RE_DUP_MAX 255 -#endif - -#ifndef NULL /* ANSI C #defines NULL everywhere. */ -#define NULL 0 -#endif - -#undef MAX -#define MAX(a,b) ((a)<(b)?(b):(a)) - -#undef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) - -#ifndef DEFFILEMODE /* Default file permissions. */ -#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) -#endif - -#ifndef _BSD_VA_LIST_ -#define _BSD_VA_LIST_ char * -#endif - -#endif /* !_COMPAT_H_ */ diff --git a/cde/lib/DtMmdb/btree_berkeley/db.c b/cde/lib/DtMmdb/btree_berkeley/db.c deleted file mode 100644 index a735506c5..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/db.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: db.c /main/3 1996/06/11 17:13:41 cde-hal $ */ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)db.c 8.2 (Berkeley) 9/7/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#define __DBINTERFACE_PRIVATE -#include - -DB * -dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo) -{ - -#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) -#define USE_OPEN_FLAGS \ - (O_CREAT | O_EXCL | O_EXLOCK | O_RDONLY | O_RDWR | \ - O_SHLOCK | O_TRUNC) - - if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) - switch (type) { - case DB_BTREE: - return (__bt_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); -/* - case DB_HASH: - return (__hash_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); - case DB_RECNO: - return (__rec_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, flags & DB_FLAGS)); -*/ - default: - break; - } - errno = EINVAL; - return (NULL); -} - -static int -__dberr(void) -{ - return (RET_ERROR); -} - -/* - * __DBPANIC -- Stop. - * - * Parameters: - * dbp: pointer to the DB structure. - */ -void -__dbpanic(DB *dbp) -{ - /* The only thing that can succeed is a close. */ - dbp->del = (int (*)())__dberr; - dbp->fd = (int (*)())__dberr; - dbp->get = (int (*)())__dberr; - dbp->put = (int (*)())__dberr; - dbp->seq = (int (*)())__dberr; - dbp->sync = (int (*)())__dberr; -} diff --git a/cde/lib/DtMmdb/btree_berkeley/db.h b/cde/lib/DtMmdb/btree_berkeley/db.h deleted file mode 100644 index d1bc23654..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/db.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: db.h /main/3 1996/06/11 17:13:46 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)db.h 8.2 (Berkeley) 9/7/93 - */ - -#ifndef _DB_H_ -#define _DB_H_ - -#include -#include "cdefs.h" - -#include -#include "compat.h" - -#define RET_ERROR -1 /* Return values. */ -#define RET_SUCCESS 0 -#define RET_SPECIAL 1 - -#define MAX_PAGE_NUMBER ULONG_MAX /* >= # of pages in a file */ -typedef u_long pgno_t; -#define MAX_PAGE_OFFSET USHRT_MAX /* >= # of bytes in a page */ -typedef u_short indx_t; -#define MAX_REC_NUMBER ULONG_MAX /* >= # of records in a tree */ -typedef u_long recno_t; - -/* Key/data structure -- a Data-Base Thang. */ -typedef struct { - void *data; /* data */ - size_t size; /* data length */ -} DBT; - -/* Routine flags. */ -#define R_CURSOR 1 /* del, put, seq */ -#define __R_UNUSED 2 /* UNUSED */ -#define R_FIRST 3 /* seq */ -#define R_IAFTER 4 /* put (RECNO) */ -#define R_IBEFORE 5 /* put (RECNO) */ -#define R_LAST 6 /* seq (BTREE, RECNO) */ -#define R_NEXT 7 /* seq */ -#define R_NOOVERWRITE 8 /* put */ -#define R_PREV 9 /* seq (BTREE, RECNO) */ -#define R_SETCURSOR 10 /* put (RECNO) */ -#define R_RECNOSYNC 11 /* sync (RECNO) */ - -typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; - -/* - * !!! - * The following flags are included in the dbopen(3) call as part of the - * open(2) flags. In order to avoid conflicts with the open flags, start - * at the top of the 16 or 32-bit number space and work our way down. If - * the open flags were significantly expanded in the future, it could be - * a problem. Wish I'd left another flags word in the dbopen call. - * - * !!! - * None of this stuff is implemented yet. The only reason that it's here - * is so that the access methods can skip copying the key/data pair when - * the DB_LOCK flag isn't set. - */ - -/* -assume 32 bit UINT. -*/ - -/* -#if UINT_MAX > 65535 -*/ -#define DB_LOCK 0x20000000 /* Do locking. */ -#define DB_SHMEM 0x40000000 /* Use shared memory. */ -#define DB_TXN 0x80000000 /* Do transactions. */ - -/* -#else -#define DB_LOCK 0x00002000 -#define DB_SHMEM 0x00004000 -#define DB_TXN 0x00008000 -#endif -*/ - -/* Access method description structure. */ -typedef struct __db { - DBTYPE type; /* Underlying db type. */ - int (*close) __P((struct __db *)); - int (*del) __P((const struct __db *, const DBT *, u_int)); - int (*fd) __P((const struct __db *)); - int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); - int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); - int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); - int (*sync) __P((const struct __db *, u_int)); - void *internal; /* access method private */ -} DB; - -#define BTREEMAGIC 0x053162 -#define BTREEVERSION 3 - -/* Structure used to pass parameters to the btree routines. */ -typedef struct { -#define R_DUP 0x01 /* duplicate keys */ - u_long flags; - int cachesize; /* bytes to cache */ - int maxkeypage; /* maximum keys per page */ - int minkeypage; /* minimum keys per page */ - int psize; /* page size */ - /* comparison, prefix functions */ - int (*compare) __P((const DBT *, const DBT *)); - int (*prefix) __P((const DBT *, const DBT *)); - int lorder; /* byte order */ -} BTREEINFO; - -#define HASHMAGIC 0x061561 -#define HASHVERSION 2 - -/* Structure used to pass parameters to the hashing routines. */ -typedef struct { - int bsize; /* bucket size */ - int ffactor; /* fill factor */ - int nelem; /* number of elements */ - int cachesize; /* bytes to cache */ - /* hash function */ - int (*hash) __P((const void *, size_t)); - int lorder; /* byte order */ -} HASHINFO; - -/* Structure used to pass parameters to the record routines. */ -typedef struct { -#define R_FIXEDLEN 0x01 /* fixed-length records */ -#define R_NOKEY 0x02 /* key not required */ -#define R_SNAPSHOT 0x04 /* snapshot the input */ - u_long flags; - int cachesize; /* bytes to cache */ - int psize; /* page size */ - int lorder; /* byte order */ - size_t reclen; /* record length (fixed-length records) */ - u_char bval; /* delimiting byte (variable-length records */ - char *bfname; /* btree file name */ -} RECNOINFO; - -/* - * Little endian <==> big endian long swap macros. - * BLSWAP swap a memory location - * BLPSWAP swap a referenced memory location - * BLSWAP_COPY swap from one location to another - */ -#define BLSWAP(a) { \ - u_long _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[3]; \ - ((char *)&a)[1] = ((char *)&_tmp)[2]; \ - ((char *)&a)[2] = ((char *)&_tmp)[1]; \ - ((char *)&a)[3] = ((char *)&_tmp)[0]; \ -} -#define BLPSWAP(a) { \ - u_long _tmp = *(u_long *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[3]; \ - ((char *)a)[1] = ((char *)&_tmp)[2]; \ - ((char *)a)[2] = ((char *)&_tmp)[1]; \ - ((char *)a)[3] = ((char *)&_tmp)[0]; \ -} -#define BLSWAP_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[3]; \ - ((char *)&(b))[1] = ((char *)&(a))[2]; \ - ((char *)&(b))[2] = ((char *)&(a))[1]; \ - ((char *)&(b))[3] = ((char *)&(a))[0]; \ -} - -/* - * Little endian <==> big endian short swap macros. - * BSSWAP swap a memory location - * BSPSWAP swap a referenced memory location - * BSSWAP_COPY swap from one location to another - */ -#define BSSWAP(a) { \ - u_short _tmp = a; \ - ((char *)&a)[0] = ((char *)&_tmp)[1]; \ - ((char *)&a)[1] = ((char *)&_tmp)[0]; \ -} -#define BSPSWAP(a) { \ - u_short _tmp = *(u_short *)a; \ - ((char *)a)[0] = ((char *)&_tmp)[1]; \ - ((char *)a)[1] = ((char *)&_tmp)[0]; \ -} -#define BSSWAP_COPY(a, b) { \ - ((char *)&(b))[0] = ((char *)&(a))[1]; \ - ((char *)&(b))[1] = ((char *)&(a))[0]; \ -} - -__BEGIN_DECLS -DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); - -#ifdef __DBINTERFACE_PRIVATE -DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); -DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); -DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); -void __dbpanic __P((DB *dbp)); -#endif -__END_DECLS -#endif /* !_DB_H_ */ diff --git a/cde/lib/DtMmdb/btree_berkeley/extern.h b/cde/lib/DtMmdb/btree_berkeley/extern.h deleted file mode 100644 index 813562c26..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/extern.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: extern.h /main/3 1996/06/11 17:13:51 cde-hal $ */ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)extern.h 8.2 (Berkeley) 9/7/93 - */ - -int __bt_close __P((DB *)); -int __bt_cmp __P((BTREE *, const DBT *, EPG *)); -int __bt_crsrdel __P((BTREE *, EPGNO *)); -int __bt_defcmp __P((const DBT *, const DBT *)); -int __bt_defpfx __P((const DBT *, const DBT *)); -int __bt_delete __P((const DB *, const DBT *, u_int)); -int __bt_dleaf __P((BTREE *, PAGE *, int)); -int __bt_fd __P((const DB *)); -EPG *__bt_first __P((BTREE *, const DBT *, int *)); -int __bt_free __P((BTREE *, PAGE *)); -int __bt_get __P((const DB *, const DBT *, DBT *, u_int)); -PAGE *__bt_new __P((BTREE *, pgno_t *)); -void __bt_pgin __P((void *, pgno_t, void *)); -void __bt_pgout __P((void *, pgno_t, void *)); -int __bt_push __P((BTREE *, pgno_t, int)); -int __bt_put __P((const DB *dbp, DBT *, const DBT *, u_int)); -int __bt_ret __P((BTREE *, EPG *, DBT *, DBT *)); -EPG *__bt_search __P((BTREE *, const DBT *, int *)); -int __bt_seq __P((const DB *, DBT *, DBT *, u_int)); -int __bt_split __P((BTREE *, PAGE *, - const DBT *, const DBT *, u_long, size_t, u_int)); -int __bt_sync __P((const DB *, u_int)); - -int __ovfl_delete __P((BTREE *, void *)); -int __ovfl_get __P((BTREE *, void *, size_t *, char **, size_t *)); -int __ovfl_put __P((BTREE *, const DBT *, pgno_t *)); - -#ifdef DEBUG -void __bt_dnpage __P((DB *, pgno_t)); -void __bt_dpage __P((PAGE *)); -void __bt_dump __P((DB *)); -#endif -#ifdef STATISTICS -void __bt_stat __P((DB *)); -#endif diff --git a/cde/lib/DtMmdb/btree_berkeley/memmove.c b/cde/lib/DtMmdb/btree_berkeley/memmove.c deleted file mode 100644 index 3568a01d2..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/memmove.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: memmove.c /main/3 1996/06/11 17:13:55 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include "cdefs.h" -#include - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef int word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -/* - * Copy a block of memory, handling overlap. - * This is the routine that actually implements - * (the portable versions of) bcopy, memcpy, and memmove. - */ -#ifdef MEMCOPY -void * -memcpy(dst0, src0, length) -#else -#ifdef MEMMOVE -void * -memmove(dst0, src0, length) -#else -void -bcopy(src0, dst0, length) -#endif -#endif - void *dst0; - const void *src0; - size_t length; -{ - char *dst = dst0; - const char *src = src0; - size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - if ((unsigned long)dst < (unsigned long)src) { - /* - * Copy forward. - */ - t = (size_t)src; /* only need low bits */ - if ((t | (size_t)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (size_t)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (size_t)src; - if ((t | (size_t)dst) & wmask) { - if ((t ^ (size_t)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: -#if defined(MEMCOPY) || defined(MEMMOVE) - return (dst0); -#else - return; -#endif -} diff --git a/cde/lib/DtMmdb/btree_berkeley/mktemp.c b/cde/lib/DtMmdb/btree_berkeley/mktemp.c deleted file mode 100644 index 4f043799b..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/mktemp.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: mktemp.c /main/4 1996/11/01 10:18:53 drk $ */ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#ifdef X_NOT_STDC_ENV -extern int errno; -#endif - -static int _gettemp(char*, int*); - -int mkstemp(char *path) -{ - int fd; - - return (_gettemp(path, &fd) ? fd : -1); -} - -char * -mktemp(char *path) -{ - return(_gettemp(path, (int *)NULL) ? path : (char *)NULL); -} - -static int -_gettemp(char *path, int *doopen) -{ - char *start, *trv; - struct stat sbuf; - u_int pid; - - pid = getpid(); - for (trv = path; *trv; ++trv); /* extra X's get set to 0's */ - while (*--trv == 'X') { - *trv = (pid % 10) + '0'; - pid /= 10; - } - - /* - * check the target directory; if you have six X's and it - * doesn't exist this runs for a *very* long time. - */ - for (start = trv + 1;; --trv) { - if (trv <= path) - break; - if (*trv == '/') { - *trv = '\0'; - if (stat(path, &sbuf)) - return(0); - if (!S_ISDIR(sbuf.st_mode)) { - errno = ENOTDIR; - return(0); - } - *trv = '/'; - break; - } - } - - for (;;) { - if (doopen) { - if ((*doopen = - open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) - return(1); - if (errno != EEXIST) - return(0); - } - else if (stat(path, &sbuf)) - return(errno == ENOENT ? 1 : 0); - - /* tricky little algorithm for backward compatibility */ - for (trv = start;;) { - if (!*trv) - return(0); - if (*trv == 'z') - *trv++ = 'a'; - else { - if (isdigit((unsigned char) *trv)) - *trv = 'a'; - else - ++*trv; - break; - } - } - } - /*NOTREACHED*/ -} diff --git a/cde/lib/DtMmdb/btree_berkeley/mpool.c b/cde/lib/DtMmdb/btree_berkeley/mpool.c deleted file mode 100644 index 92ce371bf..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/mpool.c +++ /dev/null @@ -1,542 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: mpool.c /main/4 1996/10/04 09:47:13 drk $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mpool.c 8.1 (Berkeley) 6/6/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include -#include -#include -#include - -#include -#define __MPOOLINTERFACE_PRIVATE -#include "mpool.h" - -static BKT *mpool_bkt __P((MPOOL *)); -static BKT *mpool_look __P((MPOOL *, pgno_t)); -static int mpool_write __P((MPOOL *, BKT *)); -#ifdef DEBUG -static void __mpoolerr __P((const char *fmt, ...)); -#endif - -/* - * MPOOL_OPEN -- initialize a memory pool. - * - * Parameters: - * key: Shared buffer key. - * fd: File descriptor. - * pagesize: File page size. - * maxcache: Max number of cached pages. - * - * Returns: - * MPOOL pointer, NULL on error. - */ -MPOOL * -mpool_open(DBT *key, int fd, pgno_t pagesize, pgno_t maxcache) -{ - struct stat sb; - MPOOL *mp; - int entry; - - if (fstat(fd, &sb)) - return (NULL); - /* XXX - * We should only set st_size to 0 for pipes -- 4.4BSD has the fix so - * that stat(2) returns true for ISSOCK on pipes. Until then, this is - * fairly close. - */ - if (!S_ISREG(sb.st_mode)) { - errno = ESPIPE; - return (NULL); - } - - if ((mp = malloc(sizeof(MPOOL))) == NULL) - return (NULL); - mp->free.cnext = mp->free.cprev = (BKT *)(void *)&mp->free; - mp->lru.cnext = mp->lru.cprev = (BKT *)(void *)&mp->lru; - for (entry = 0; entry < HASHSIZE; ++entry) - mp->hashtable[entry].hnext = mp->hashtable[entry].hprev = - mp->hashtable[entry].cnext = mp->hashtable[entry].cprev = - (BKT *)&mp->hashtable[entry]; - mp->curcache = 0; - mp->maxcache = maxcache; - mp->pagesize = pagesize; - mp->npages = sb.st_size / pagesize; - mp->fd = fd; - mp->pgcookie = NULL; - mp->pgin = mp->pgout = NULL; - -#ifdef STATISTICS - mp->cachehit = mp->cachemiss = mp->pagealloc = mp->pageflush = - mp->pageget = mp->pagenew = mp->pageput = mp->pageread = - mp->pagewrite = 0; -#endif - return (mp); -} - -/* - * MPOOL_FILTER -- initialize input/output filters. - * - * Parameters: - * pgin: Page in conversion routine. - * pgout: Page out conversion routine. - * pgcookie: Cookie for page in/out routines. - */ -void -mpool_filter(MPOOL *mp, - void (*pgin) __P((void *, pgno_t, void *)), - void (*pgout) __P((void *, pgno_t, void *)), - void *pgcookie) -{ - mp->pgin = pgin; - mp->pgout = pgout; - mp->pgcookie = pgcookie; -} - -/* - * MPOOL_NEW -- get a new page - * - * Parameters: - * mp: mpool cookie - * pgnoadddr: place to store new page number - * Returns: - * RET_ERROR, RET_SUCCESS - */ -void * -mpool_new(MPOOL *mp, pgno_t *pgnoaddr) -{ - BKT *b; - BKTHDR *hp; - -#ifdef STATISTICS - ++mp->pagenew; -#endif - /* - * Get a BKT from the cache. Assign a new page number, attach it to - * the hash and lru chains and return. - */ - if ((b = mpool_bkt(mp)) == NULL) - return (NULL); - *pgnoaddr = b->pgno = mp->npages++; - b->flags = MPOOL_PINNED; - inshash(b, b->pgno); - inschain(b, &mp->lru); - return (b->page); -} - -/* - * MPOOL_GET -- get a page from the pool - * - * Parameters: - * mp: mpool cookie - * pgno: page number - * flags: not used - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -void * -mpool_get(MPOOL *mp, pgno_t pgno, u_int flags /* XXX not used? */) -{ - BKT *b; - BKTHDR *hp; - off_t off; - int nr; - - /* - * If asking for a specific page that is already in the cache, find - * it and return it. - */ - if ((b = mpool_look(mp, pgno))) { -#ifdef STATISTICS - ++mp->pageget; -#endif -#ifdef DEBUG - if (b->flags & MPOOL_PINNED) - __mpoolerr("mpool_get: page %d already pinned", - b->pgno); -#endif - rmchain(b); - inschain(b, &mp->lru); - b->flags |= MPOOL_PINNED; - return (b->page); - } - - /* Not allowed to retrieve a non-existent page. */ - if (pgno >= mp->npages) { - errno = EINVAL; - return (NULL); - } - - /* Get a page from the cache. */ - if ((b = mpool_bkt(mp)) == NULL) - return (NULL); - b->pgno = pgno; - b->flags = MPOOL_PINNED; - -#ifdef STATISTICS - ++mp->pageread; -#endif - /* Read in the contents. */ - off = mp->pagesize * pgno; - if (lseek(mp->fd, off, SEEK_SET) != off) - return (NULL); - if ((nr = read(mp->fd, b->page, mp->pagesize)) != mp->pagesize) { - if (nr >= 0) - errno = EFTYPE; - return (NULL); - } - if (mp->pgin) - (mp->pgin)(mp->pgcookie, b->pgno, b->page); - - inshash(b, b->pgno); - inschain(b, &mp->lru); -#ifdef STATISTICS - ++mp->pageget; -#endif - return (b->page); -} - -/* - * MPOOL_PUT -- return a page to the pool - * - * Parameters: - * mp: mpool cookie - * page: page pointer - * pgno: page number - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -mpool_put(MPOOL *mp, void *page, u_int flags) -{ - BKT *baddr; -#ifdef DEBUG - BKT *b; -#endif - -#ifdef STATISTICS - ++mp->pageput; -#endif - baddr = (BKT *)((char *)page - sizeof(BKT)); -#ifdef DEBUG - if (!(baddr->flags & MPOOL_PINNED)) - __mpoolerr("mpool_put: page %d not pinned", b->pgno); - for (b = mp->lru.cnext; b != (BKT *)&mp->lru; b = b->cnext) { - if (b == (BKT *)&mp->lru) - __mpoolerr("mpool_put: %0x: bad address", baddr); - if (b == baddr) - break; - } -#endif - baddr->flags &= ~MPOOL_PINNED; - baddr->flags |= flags & MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * MPOOL_CLOSE -- close the buffer pool - * - * Parameters: - * mp: mpool cookie - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -mpool_close(MPOOL *mp) -{ - BKT *b, *next; - - /* Free up any space allocated to the lru pages. */ - for (b = mp->lru.cprev; b != (BKT *)(void *)&mp->lru; b = next) { - next = b->cprev; - free(b); - } - free(mp); - return (RET_SUCCESS); -} - -/* - * MPOOL_SYNC -- sync the file to disk. - * - * Parameters: - * mp: mpool cookie - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -mpool_sync(MPOOL *mp) -{ - BKT *b; - - for (b = mp->lru.cprev; b != (BKT *)(void *)&mp->lru; b = b->cprev) - if (b->flags & MPOOL_DIRTY && mpool_write(mp, b) == RET_ERROR) - return (RET_ERROR); - return (fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); -} - -/* - * MPOOL_BKT -- get/create a BKT from the cache - * - * Parameters: - * mp: mpool cookie - * - * Returns: - * NULL on failure and a pointer to the BKT on success - */ -static BKT * -mpool_bkt(MPOOL *mp) -{ - BKT *b; - - if (mp->curcache < mp->maxcache) - goto new; - - /* - * If the cache is maxxed out, search the lru list for a buffer we - * can flush. If we find one, write it if necessary and take it off - * any lists. If we don't find anything we grow the cache anyway. - * The cache never shrinks. - */ - for (b = mp->lru.cprev; b != (BKT *)(void *)&mp->lru; b = b->cprev) - if (!(b->flags & MPOOL_PINNED)) { - if (b->flags & MPOOL_DIRTY && - mpool_write(mp, b) == RET_ERROR) - return (NULL); - rmhash(b); - rmchain(b); -#ifdef STATISTICS - ++mp->pageflush; -#endif -#ifdef DEBUG - { - void *spage; - spage = b->page; - memset(b, 0xff, sizeof(BKT) + mp->pagesize); - b->page = spage; - } -#endif - return (b); - } - -new: if ((b = malloc(sizeof(BKT) + mp->pagesize)) == NULL) - return (NULL); -#ifdef STATISTICS - ++mp->pagealloc; -#endif -/* -#ifdef DEBUG -*/ - memset(b, 0xff, sizeof(BKT) + mp->pagesize); -/* -#endif -*/ - b->page = (char *)b + sizeof(BKT); - - ++mp->curcache; - return (b); -} - -/* - * MPOOL_WRITE -- sync a page to disk - * - * Parameters: - * mp: mpool cookie - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -mpool_write(MPOOL *mp, BKT *b) -{ - off_t off; - - if (mp->pgout) - (mp->pgout)(mp->pgcookie, b->pgno, b->page); - -#ifdef STATISTICS - ++mp->pagewrite; -#endif - off = mp->pagesize * b->pgno; - if (lseek(mp->fd, off, SEEK_SET) != off) - return (RET_ERROR); - if (write(mp->fd, b->page, mp->pagesize) != mp->pagesize) - return (RET_ERROR); - b->flags &= ~MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * MPOOL_LOOK -- lookup a page - * - * Parameters: - * mp: mpool cookie - * pgno: page number - * - * Returns: - * NULL on failure and a pointer to the BKT on success - */ -static BKT * -mpool_look(MPOOL *mp, pgno_t pgno) -{ - BKT *b; - BKTHDR *tb; - - /* XXX - * If find the buffer, put it first on the hash chain so can - * find it again quickly. - */ - tb = &mp->hashtable[HASHKEY(pgno)]; - for (b = tb->hnext; b != (BKT *)tb; b = b->hnext) - if (b->pgno == pgno) { -#ifdef STATISTICS - ++mp->cachehit; -#endif - return (b); - } -#ifdef STATISTICS - ++mp->cachemiss; -#endif - return (NULL); -} - -#ifdef STATISTICS -/* - * MPOOL_STAT -- cache statistics - * - * Parameters: - * mp: mpool cookie - */ -void -mpool_stat(MPOOL *mp) -{ - BKT *b; - int cnt; - char *sep; - - (void)fprintf(stderr, "%lu pages in the file\n", mp->npages); - (void)fprintf(stderr, - "page size %lu, cacheing %lu pages of %lu page max cache\n", - mp->pagesize, mp->curcache, mp->maxcache); - (void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n", - mp->pageput, mp->pageget, mp->pagenew); - (void)fprintf(stderr, "%lu page allocs, %lu page flushes\n", - mp->pagealloc, mp->pageflush); - if (mp->cachehit + mp->cachemiss) - (void)fprintf(stderr, - "%.0f%% cache hit rate (%lu hits, %lu misses)\n", - ((double)mp->cachehit / (mp->cachehit + mp->cachemiss)) - * 100, mp->cachehit, mp->cachemiss); - (void)fprintf(stderr, "%lu page reads, %lu page writes\n", - mp->pageread, mp->pagewrite); - - sep = ""; - cnt = 0; - for (b = mp->lru.cnext; b != (BKT *)&mp->lru; b = b->cnext) { - (void)fprintf(stderr, "%s%ld", sep, b->pgno); - if (b->flags & MPOOL_DIRTY) - (void)fprintf(stderr, "d"); - if (b->flags & MPOOL_PINNED) - (void)fprintf(stderr, "P"); - if (++cnt == 10) { - sep = "\n"; - cnt = 0; - } else - sep = ", "; - - } - (void)fprintf(stderr, "\n"); -} -#endif - -#ifdef DEBUG -#if __STDC__ -#include -#else -#include -#endif - -static void -#if __STDC__ -__mpoolerr(const char *fmt, ...) -#else -__mpoolerr(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - abort(); - /* NOTREACHED */ -} -#endif diff --git a/cde/lib/DtMmdb/btree_berkeley/mpool.h b/cde/lib/DtMmdb/btree_berkeley/mpool.h deleted file mode 100644 index be7d18280..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/mpool.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: mpool.h /main/3 1996/06/11 17:14:12 cde-hal $ */ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)mpool.h 8.1 (Berkeley) 6/2/93 - */ - -/* - * The memory pool scheme is a simple one. Each in memory page is referenced - * by a bucket which is threaded in three ways. All active pages are threaded - * on a hash chain (hashed by the page number) and an lru chain. Inactive - * pages are threaded on a free chain. Each reference to a memory pool is - * handed an MPOOL which is the opaque cookie passed to all of the memory - * routines. - */ -#define HASHSIZE 128 -#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) - -/* The BKT structures are the elements of the lists. */ -typedef struct BKT { - struct BKT *hnext; /* next hash bucket */ - struct BKT *hprev; /* previous hash bucket */ - struct BKT *cnext; /* next free/lru bucket */ - struct BKT *cprev; /* previous free/lru bucket */ - void *page; /* page */ - pgno_t pgno; /* page number */ - -#define MPOOL_DIRTY 0x01 /* page needs to be written */ -#define MPOOL_PINNED 0x02 /* page is pinned into memory */ - unsigned long flags; /* flags */ -} BKT; - -/* The BKTHDR structures are the heads of the lists. */ -typedef struct BKTHDR { - struct BKT *hnext; /* next hash bucket */ - struct BKT *hprev; /* previous hash bucket */ - struct BKT *cnext; /* next free/lru bucket */ - struct BKT *cprev; /* previous free/lru bucket */ -} BKTHDR; - -typedef struct MPOOL { - BKTHDR free; /* The free list. */ - BKTHDR lru; /* The LRU list. */ - BKTHDR hashtable[HASHSIZE]; /* Hashed list by page number. */ - pgno_t curcache; /* Current number of cached pages. */ - pgno_t maxcache; /* Max number of cached pages. */ - pgno_t npages; /* Number of pages in the file. */ - u_long pagesize; /* File page size. */ - int fd; /* File descriptor. */ - /* Page in conversion routine. */ - void (*pgin) __P((void *, pgno_t, void *)); - /* Page out conversion routine. */ - void (*pgout) __P((void *, pgno_t, void *)); - void *pgcookie; /* Cookie for page in/out routines. */ -#ifdef STATISTICS - unsigned long cachehit; - unsigned long cachemiss; - unsigned long pagealloc; - unsigned long pageflush; - unsigned long pageget; - unsigned long pagenew; - unsigned long pageput; - unsigned long pageread; - unsigned long pagewrite; -#endif -} MPOOL; - -#ifdef __MPOOLINTERFACE_PRIVATE -/* Macros to insert/delete into/from hash chain. */ -#define rmhash(bp) { \ - (bp)->hprev->hnext = (bp)->hnext; \ - (bp)->hnext->hprev = (bp)->hprev; \ -} -#define inshash(bp, pg) { \ - hp = &mp->hashtable[HASHKEY(pg)]; \ - (bp)->hnext = hp->hnext; \ - (bp)->hprev = (struct BKT *)hp; \ - hp->hnext->hprev = (bp); \ - hp->hnext = (bp); \ -} - -/* Macros to insert/delete into/from lru and free chains. */ -#define rmchain(bp) { \ - (bp)->cprev->cnext = (bp)->cnext; \ - (bp)->cnext->cprev = (bp)->cprev; \ -} -#define inschain(bp, dp) { \ - (bp)->cnext = (dp)->cnext; \ - (bp)->cprev = (struct BKT *)(void *)(dp); \ - (dp)->cnext->cprev = (bp); \ - (dp)->cnext = (bp); \ -} -#endif - -__BEGIN_DECLS -MPOOL *mpool_open __P((DBT *, int, pgno_t, pgno_t)); -void mpool_filter __P((MPOOL *, void (*)(void *, pgno_t, void *), - void (*)(void *, pgno_t, void *), void *)); -void *mpool_new __P((MPOOL *, pgno_t *)); -void *mpool_get __P((MPOOL *, pgno_t, u_int)); -int mpool_put __P((MPOOL *, void *, u_int)); -int mpool_sync __P((MPOOL *)); -int mpool_close __P((MPOOL *)); -#ifdef STATISTICS -void mpool_stat __P((MPOOL *)); -#endif -__END_DECLS diff --git a/cde/lib/DtMmdb/btree_berkeley/ndbm.h b/cde/lib/DtMmdb/btree_berkeley/ndbm.h deleted file mode 100644 index 077de5fbd..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/ndbm.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ndbm.h /main/3 1996/06/11 17:14:17 cde-hal $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS 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 REGENTS OR 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. - * - * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _NDBM_H_ -#define _NDBM_H_ - -#include - -/* Map dbm interface onto db(3). */ -#define DBM_RDONLY O_RDONLY - -/* Flags to dbm_store(). */ -#define DBM_INSERT 0 -#define DBM_REPLACE 1 - -/* - * The db(3) support for ndbm(3) always appends this suffix to the - * file name to avoid overwriting the user's original database. - */ -#define DBM_SUFFIX ".db" - -typedef struct { - char *dptr; - int dsize; -} datum; - -typedef DB DBM; -#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE - -__BEGIN_DECLS -void dbm_close __P((DBM *)); -int dbm_delete __P((DBM *, datum)); -datum dbm_fetch __P((DBM *, datum)); -datum dbm_firstkey __P((DBM *)); -long dbm_forder __P((DBM *, datum)); -datum dbm_nextkey __P((DBM *)); -DBM *dbm_open __P((const char *, int, int)); -int dbm_store __P((DBM *, datum, datum, int)); -int dbm_dirfno __P((DBM *)); -__END_DECLS - -#endif /* !_NDBM_H_ */ diff --git a/cde/lib/DtMmdb/btree_berkeley/realloc.c b/cde/lib/DtMmdb/btree_berkeley/realloc.c deleted file mode 100644 index 16b5854f5..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/realloc.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: realloc.c /main/3 1996/06/11 17:14:22 cde-hal $ */ -#include - -#include - -void * -__fix_realloc(void *p, size_t n) -{ - return (p == 0 ? malloc(n) : realloc(p, n)); -} diff --git a/cde/lib/DtMmdb/btree_berkeley/snprintf.c b/cde/lib/DtMmdb/btree_berkeley/snprintf.c deleted file mode 100644 index 5be30e363..000000000 --- a/cde/lib/DtMmdb/btree_berkeley/snprintf.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: snprintf.c /main/3 1996/06/11 17:14:27 cde-hal $ */ -#include -#include "cdefs.h" - -#include -#include -#include - -#ifdef __STDC__ -#include -#else -#include -#endif - -int -#ifdef __STDC__ -snprintf(char *str, size_t n, const char *fmt, ...) -#else -snprintf(str, n, fmt, va_alist) - char *str; - size_t n; - const char *fmt; - va_dcl -#endif -{ - va_list ap; -#ifdef VSPRINTF_CHARSTAR - char *rp; -#else - int rval; -#endif - -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - -#ifdef VSPRINTF_CHARSTAR - rp = (char*)(size_t)vsnprintf(str, n, fmt, ap); - va_end(ap); - return (strlen(rp)); -#else - rval = vsnprintf(str, n, fmt, ap); - va_end(ap); - return (rval); -#endif -} - -#if 0 -int -vsnprintf(str, n, fmt, ap) - char *str; - size_t n; - const char *fmt; - va_list ap; -{ -#ifdef VSPRINTF_CHARSTAR - return (strlen((char*)(size_t)vsnprintf(str, fmt, ap))); -#else - return (vsnprintf(str, fmt, ap)); -#endif -} -#endif diff --git a/cde/lib/DtMmdb/compression/code.C b/cde/lib/DtMmdb/compression/code.C index f4272fa65..de27ea8f2 100644 --- a/cde/lib/DtMmdb/compression/code.C +++ b/cde/lib/DtMmdb/compression/code.C @@ -48,9 +48,10 @@ */ +#include "utility/debug.h" #include "compression/code.h" -encoding_unit::encoding_unit(ostring* w, unsigned int f) : +encoding_unit::encoding_unit(std::string* w, unsigned int f) : word(w), bits(0), freq(f), code(0), leaf_htr_node(NULL) { } @@ -60,7 +61,7 @@ encoding_unit::~encoding_unit() delete word; } -ostream& operator<<(ostream& out, encoding_unit& eu) +std::ostream& operator<<(std::ostream& out, encoding_unit& eu) { debug(out, *eu.word); debug(out, eu.freq); diff --git a/cde/lib/DtMmdb/compression/code.h b/cde/lib/DtMmdb/compression/code.h index 1fa14b8d8..e82f0cc16 100644 --- a/cde/lib/DtMmdb/compression/code.h +++ b/cde/lib/DtMmdb/compression/code.h @@ -51,7 +51,8 @@ #ifndef _code_h #define _code_h 1 -#include "utility/ostring.h" +#include + //////////////////////////////////////// // //////////////////////////////////////// @@ -61,17 +62,17 @@ class htr_node; class encoding_unit { public: - ostring* word; + std::string* word; int bits; unsigned int freq; unsigned int code; htr_node* leaf_htr_node; public: - encoding_unit(ostring* w, unsigned int freq); + encoding_unit(std::string* w, unsigned int freq); ~encoding_unit(); - friend ostream& operator <<(ostream&, encoding_unit&); + friend std::ostream& operator <<(std::ostream&, encoding_unit&); }; diff --git a/cde/lib/DtMmdb/compression/huffman.C b/cde/lib/DtMmdb/compression/huffman.C index d4cf430c5..8808f0b61 100644 --- a/cde/lib/DtMmdb/compression/huffman.C +++ b/cde/lib/DtMmdb/compression/huffman.C @@ -310,7 +310,7 @@ void huff::compress(const buffer& uncompressed, buffer& compressed) void huff::decompress(buffer& compressed, buffer& uncompressed) { char* buf_base = uncompressed.get_base(); - char* str; + const char* str; int str_len; char rem_bits; @@ -339,7 +339,7 @@ void huff::decompress(buffer& compressed, buffer& uncompressed) //} str_len = node_ptr -> eu -> word -> size(); - str = node_ptr -> eu -> word -> get(); + str = node_ptr -> eu -> word -> c_str(); if ( str_len == 1 ) { @@ -379,8 +379,8 @@ void huff::decompress(buffer& compressed, buffer& uncompressed) uncompressed.set_content_sz(buf_base-uncompressed.get_base()); if ( rem_bits > 0 ) - uncompressed.put( node_ptr -> eu -> word -> get(), - node_ptr -> eu -> word -> size() + uncompressed.put( node_ptr -> eu -> word -> c_str(), + node_ptr -> eu -> word -> size() ); } @@ -422,7 +422,7 @@ io_status huff::cdrOut(buffer& buf) word_sz = e_units[i] -> word -> size(); v_out_buf.put(char(word_sz)); - v_out_buf.put(e_units[i] -> word -> get(), word_sz); + v_out_buf.put(e_units[i] -> word -> c_str(), word_sz); v_out_buf.put(e_units[i] -> freq); } diff --git a/cde/lib/DtMmdb/compression/trie.C b/cde/lib/DtMmdb/compression/trie.C index f352ab321..dec1ab6b6 100644 --- a/cde/lib/DtMmdb/compression/trie.C +++ b/cde/lib/DtMmdb/compression/trie.C @@ -221,7 +221,7 @@ void trie::add(unsigned char* word, int sz, int fq) encoding_unit* trie::add_to_alphabet(unsigned char* word, int sz, int fq) { extend_alphabet(); - encoding_unit *x = new encoding_unit(new ostring((char*)word, sz), fq); + encoding_unit *x = new encoding_unit(new string((char*)word, sz), fq); alphabet[alphabet_sz++] = x; return x; } @@ -240,7 +240,7 @@ cerr << "\n"; static trie_node_info* y = 0; static char buf[1]; - static ostring *z; + static string *z; if ( root == 0 ) root = new trie_node(0); @@ -261,7 +261,7 @@ cerr << "\n"; y -> info.info_view.letter = j; buf[0] = char(j); - z = new ostring(buf, 1); + z = new string(buf, 1); y -> info.info_view.mark = 1; extend_alphabet(); @@ -292,7 +292,7 @@ void update_index(int ind, void* x) void trie::_find_leaf(trie_node* z, int& j) { trie_node_info* x = 0; - ostring *y; + string *y; for ( int i=0; i member(k) == false ) throw(stringException("first_of_invlist(): key is not in btree")); diff --git a/cde/lib/DtMmdb/index/btree_index.h b/cde/lib/DtMmdb/index/btree_index.h index d2fb82c0b..438e61828 100644 --- a/cde/lib/DtMmdb/index/btree_index.h +++ b/cde/lib/DtMmdb/index/btree_index.h @@ -53,7 +53,7 @@ #define _btree_index_h 1 #include "index/dyn_index.h" -#include "btree/mmdb_btree.h" +#include "btree/btree.h" class btree_index : public dyn_index { diff --git a/cde/lib/DtMmdb/index/dyn_index.C b/cde/lib/DtMmdb/index/dyn_index.C index 62f13e92e..852f698c7 100644 --- a/cde/lib/DtMmdb/index/dyn_index.C +++ b/cde/lib/DtMmdb/index/dyn_index.C @@ -81,7 +81,7 @@ if ( v_static_key.get() ) MESSAGE(cerr, "************"); */ - return new data_t(v_static_key.get(), v_static_key.size()); + return new data_t(v_static_key.c_str(), v_static_key.size()); } Boolean diff --git a/cde/lib/DtMmdb/index/fast_mphf.C b/cde/lib/DtMmdb/index/fast_mphf.C index 870ff1eb3..7db5f542f 100644 --- a/cde/lib/DtMmdb/index/fast_mphf.C +++ b/cde/lib/DtMmdb/index/fast_mphf.C @@ -257,7 +257,7 @@ debug(cerr, k); throw(stringException("hash table empty")); } - i = v_tbl0 -> atoi(k.get(), k.size(), r, v_key_set_sz); // for halmphf + i = v_tbl0 -> atoi(k.c_str(), k.size(), r, v_key_set_sz); // for halmphf if ( i < v_p1 ) { @@ -275,7 +275,7 @@ debug(cerr, k); //i = v_tbl1 -> atoi(k, c_bit+r+1) + gv; //debug(cerr, c_bit+r); - i = v_tbl1 -> atoi(k.get(), k.size(), c_bit+r+1, v_hash_tbl_sz) + gv; // for halmphf + i = v_tbl1 -> atoi(k.c_str(), k.size(), c_bit+r+1, v_hash_tbl_sz) + gv; // for halmphf return i % v_hash_tbl_sz; @@ -422,7 +422,7 @@ fast_mphf::print_mapping(const char *key_file, int option) //debug(cerr, option); MESSAGE(cerr, "print_mapping()"); - char string[LBUFSIZ]; + char str[LBUFSIZ]; fstream in(key_file, ios::in); if ( !in ) { @@ -432,23 +432,23 @@ fast_mphf::print_mapping(const char *key_file, int option) char *hash_table = new char[v_hash_tbl_sz]; for (unsigned int i = 0; i < v_hash_tbl_sz; hash_table[i++] = 0 ); - ostring lbuf(LBUFSIZ); + string lbuf; lbuf.reserve(LBUFSIZ); - while ( in.getline(string, LBUFSIZ, '\n') ) { + while ( in.getline(str, LBUFSIZ, '\n') ) { -// string[strlen(string)-1] = '\0'; +// str[strlen(str)-1] = '\0'; -//debug(cerr, string); -//debug(cerr, strlen(string)); +//debug(cerr, str); +//debug(cerr, strlen(str)); - lbuf.reset(); - lbuf.set(string, strlen(string)); + lbuf.clear(); + lbuf.assign(str, strlen(str)); int hash = hashTo(lbuf) ; if ( option == 1 ) { - cout << " string = " << string; + cout << " string = " << str; cout << ", hash = " << hash << "\n"; } @@ -457,7 +457,7 @@ fast_mphf::print_mapping(const char *key_file, int option) else hash_table[hash] = 1; - in.getline(string, LBUFSIZ, '\n'); + in.getline(str, LBUFSIZ, '\n'); } MESSAGE(cerr, "print_mapping() done"); diff --git a/cde/lib/DtMmdb/index/index.C b/cde/lib/DtMmdb/index/index.C index 8f3ad8d70..14fddffff 100644 --- a/cde/lib/DtMmdb/index/index.C +++ b/cde/lib/DtMmdb/index/index.C @@ -54,7 +54,7 @@ key_type* c_index::v_static_key_ptr; #define v_static_key (*v_static_key_ptr) #else -key_type c_index::v_static_key(LBUFSIZ); +key_type c_index::v_static_key; #endif void c_index::init_persistent_info(persistent_info* x) @@ -66,6 +66,7 @@ void c_index::init_persistent_info(persistent_info* x) c_index::c_index(c_code_t c_cd) : composite(c_cd), v_inv_lists_hd(NULL) { v_cmp_selector = 0; + v_static_key.reserve(LBUFSIZ); } oid_list_handler* c_index::operator()(int ind) @@ -108,27 +109,21 @@ oid_t c_index::first_of_invlist(int ind) Boolean c_index::get_key_string(const handler& t) const { ostringstream out; - int len; ((handler&)t) -> asciiOut(out); - len = out.str().size(); - v_static_key.set_size(len); - *((char *) memcpy(v_static_key.get(), out.str().c_str(), len) + len) = '\0'; + v_static_key = out.str(); return true; } Boolean c_index::get_key_string(const oid_t& t) const { - v_static_key.reset(); - int len; + v_static_key.clear(); - ostringstream out(v_static_key.get()); - t.asciiOut(out); + ostringstream out(v_static_key.c_str()); - len = out.str().size(); - v_static_key.set_size(len); - *((char *) memcpy(v_static_key.get(), out.str().c_str(), len) + len) = '\0'; + t.asciiOut(out); + v_static_key = out.str(); return true; } diff --git a/cde/lib/DtMmdb/index/mphf_index.C b/cde/lib/DtMmdb/index/mphf_index.C index 8439915c3..d0f990cd5 100644 --- a/cde/lib/DtMmdb/index/mphf_index.C +++ b/cde/lib/DtMmdb/index/mphf_index.C @@ -150,13 +150,13 @@ debug(cerr, (void*)(v_mphf->operator->())); v_sz = (*v_mphf) -> keysetsize(); (*v_inv_lists_hd) -> expand_space(v_sz); - key_type key(LBUFSIZ); - + key_type key; key.reserve(LBUFSIZ); + #ifdef DEBUG int i = 0; #endif - while ( in >> key ) { + while (std::getline(in, key)) { oid_t key_id(c_code_t(0), 0); diff --git a/cde/lib/DtMmdb/mgrs/misc.C b/cde/lib/DtMmdb/mgrs/misc.C index fa5a7bfa3..61f052a0b 100644 --- a/cde/lib/DtMmdb/mgrs/misc.C +++ b/cde/lib/DtMmdb/mgrs/misc.C @@ -62,7 +62,7 @@ debug(cerr, y -> v_name); */ - return ( x -> v_name.string_LS(y -> v_name) ); + return ( x -> v_name.compare(y -> v_name) < 0); } Boolean name_oid_eq(const void* o1, const void* o2) @@ -75,7 +75,7 @@ MESSAGE(cerr, "in name_oid_eq"); debug(cerr, x -> v_name); debug(cerr, y -> v_name); */ - return ( x -> v_name.string_EQ(y -> v_name) ); + return ( x -> v_name.compare(y -> v_name) == 0); } Boolean oid_ls(const void* o1, const void* o2) @@ -145,15 +145,14 @@ void delete_name_oid_rec_f(const void* name_oid_ptr) // // *************************************************** -mark_t::mark_t(char* marks) : ostring(strlen(marks)) +mark_t::mark_t(char* marks) : string(marks) { - set(marks); } istream& operator >>(istream& in, mark_t& m) { char c ; - char* ptr = m.get(); + const char* ptr = m.c_str(); Boolean read_marks = false; while ( in && in.get(c) ) { @@ -175,7 +174,7 @@ istream& operator >>(istream& in, mark_t& m) ostream& operator <<(ostream& out, mark_t& m) { - out << m.get(); + out << m.c_str(); return out ; } diff --git a/cde/lib/DtMmdb/mgrs/misc.h b/cde/lib/DtMmdb/mgrs/misc.h index ab3027461..11c664c39 100644 --- a/cde/lib/DtMmdb/mgrs/misc.h +++ b/cde/lib/DtMmdb/mgrs/misc.h @@ -52,7 +52,6 @@ #define _misc_h #include "object/root.h" -#include "utility/ostring.h" #include "storage/abs_storage.h" #include "object/handler.h" @@ -71,25 +70,25 @@ class name_oid_t public: name_oid_t(const char* nm, abs_storage* store = 0) : v_store(store) { - v_name.set(nm); + v_name.assign(nm); } name_oid_t(const char* nm, const oid_t& id, abs_storage* store = 0) : v_oid(id), v_store(store) { - v_name.set(nm); + v_name.assign(nm); }; ~name_oid_t() {}; public: - ostring v_name; + string v_name; oid_t v_oid; abs_storage* v_store; }; void delete_name_oid_rec_f(const void* name_oid_ptr); -class mark_t : private ostring +class mark_t : private string { public: mark_t(char* marks = (char*)"\t\n "); diff --git a/cde/lib/DtMmdb/mgrs/name_oid_t.h b/cde/lib/DtMmdb/mgrs/name_oid_t.h deleted file mode 100644 index 47903bac8..000000000 --- a/cde/lib/DtMmdb/mgrs/name_oid_t.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: name_oid_t.h /main/3 1996/06/11 17:22:59 cde-hal $ */ -class name_oid_t { - -public: - ostring name; - oid_t v_oid; - - name_oid_t(const char* nm, oid_t& id) : v_oid(id) { - name.set(nm); - }; -}; diff --git a/cde/lib/DtMmdb/object/long_pstring.h b/cde/lib/DtMmdb/object/long_pstring.h index c72bc26f3..89aab9689 100644 --- a/cde/lib/DtMmdb/object/long_pstring.h +++ b/cde/lib/DtMmdb/object/long_pstring.h @@ -52,7 +52,6 @@ #define _long_pstring_h 1 #include "object/pstring.h" -#include "utility/ostring.h" #include "storage/page_storage.h" #include "storage/chunks_index.h" diff --git a/cde/lib/DtMmdb/object/oid_list.C b/cde/lib/DtMmdb/object/oid_list.C index a1e6e2d3b..0bc1954be 100644 --- a/cde/lib/DtMmdb/object/oid_list.C +++ b/cde/lib/DtMmdb/object/oid_list.C @@ -52,7 +52,7 @@ void oid_list::init_persistent_info(persistent_info* x) { - ostring* u = list_ptr.p; + string* u = list_ptr.p; root::init_persistent_info(x); @@ -62,7 +62,7 @@ void oid_list::init_persistent_info(persistent_info* x) //debug(cerr, (void*)this); //debug(cerr, my_oid()); - char* w = 0; + const char* w = 0; int v= 0; //MESSAGE(cerr, "oid_list::init_persistent_info(), new object case"); @@ -70,7 +70,7 @@ void oid_list::init_persistent_info(persistent_info* x) //debug(cerr, (void*)list_ptr.p); if (u) { - w = u -> get(); + w = u -> c_str(); v = u -> size(); } @@ -132,7 +132,7 @@ void oid_list::init_data_member(int leng) } list_ptr.loc = 0; // to please purify - list_ptr.p = new ostring(ptr, char_leng); + list_ptr.p = new string(ptr, char_leng); //MESSAGE(cerr, "oid_list::init_data_member(int leng)"); //debug(cerr, (void*)this); @@ -170,8 +170,6 @@ debug(cerr, int(list_ptr.loc)); debug(cerr, int(&list_ptr.loc)); */ - Boolean ok; - int extra_char_leng = extra_oids * OID_T_SZ; if ( get_mode(PERSISTENT) == true ) { @@ -189,18 +187,15 @@ debug(cerr, int(&list_ptr.loc)); } delete [] ptr; - - ok = true; - } else { - ok = list_ptr.p -> expand( extra_char_leng ); + list_ptr.p -> resize( extra_char_leng ); } v_sz += extra_oids; set_mode(UPDATE, true); - return ok; + return true; } @@ -275,7 +270,7 @@ debug(cerr, int(list_ptr.p)); if ( list_ptr.p == 0 ) throw(stringException("zero list_ptr.p value")); - memcpy(z, list_ptr.p -> get() + offset, OID_T_SZ); + memcpy(z, list_ptr.p -> c_str() + offset, OID_T_SZ); } //MESSAGE(cerr, "oid_list::operator() done"); @@ -363,7 +358,7 @@ oid_list::update_component(int index, const oid_t& new_oid) if ( list_ptr.p == 0 ) throw(stringException("zero list_ptr.p value")); - list_ptr.p -> update(z, OID_T_SZ, (index-1)*OID_T_SZ); + list_ptr.p -> replace((index-1)*OID_T_SZ, OID_T_SZ, z); } //MESSAGE(cerr, "oid_list::update_component() done"); @@ -435,8 +430,8 @@ io_status oid_list::asciiIn(istream& in) } else { delete list_ptr.p; - list_ptr.p = new ostring(0); - list_ptr.p -> set(oid_array, v_sz); + list_ptr.p = new string(0); + list_ptr.p -> assign(oid_array, v_sz); } delete [] oid_array; diff --git a/cde/lib/DtMmdb/object/oid_list.h b/cde/lib/DtMmdb/object/oid_list.h index 8c8f1808b..ae3ca86a4 100644 --- a/cde/lib/DtMmdb/object/oid_list.h +++ b/cde/lib/DtMmdb/object/oid_list.h @@ -51,7 +51,6 @@ #ifndef _oid_list_h #define _oid_list_h 1 -#include "utility/ostring.h" #include "dstr/dlist.h" #include "dstr/dlist_void_ptr_cell.h" #include "object/oid.h" @@ -71,7 +70,7 @@ protected: union { mmdb_pos_t loc; - ostring* p; + string* p; } list_ptr; protected: diff --git a/cde/lib/DtMmdb/object/oid_t.C b/cde/lib/DtMmdb/object/oid_t.C index 0cc7c567e..f57f18430 100644 --- a/cde/lib/DtMmdb/object/oid_t.C +++ b/cde/lib/DtMmdb/object/oid_t.C @@ -91,7 +91,7 @@ oid_t::oid_t(const char* source, Boolean ascii_format, Boolean swap_order) memcpy((char*)&v_i_code, source, sizeof(v_i_code)); if ( swap_order == true ) - ORDER_SWAP_LONG(v_i_code); + ORDER_SWAP_I_CODE_T(v_i_code); } else { istringstream in((char*)source); @@ -248,7 +248,7 @@ void oid_t::to_char_string(char* sink, Boolean swap_order) const if ( swap_order == true ) { i_code_t x = v_i_code; - ORDER_SWAP_LONG(x); + ORDER_SWAP_I_CODE_T(x); memcpy(sink, (char*)&x, sizeof(x)); } else memcpy(sink, (char*)&v_i_code, sizeof(v_i_code)); diff --git a/cde/lib/DtMmdb/object/oid_t.h b/cde/lib/DtMmdb/object/oid_t.h index a2a0e3649..3b4c0ea0e 100644 --- a/cde/lib/DtMmdb/object/oid_t.h +++ b/cde/lib/DtMmdb/object/oid_t.h @@ -65,6 +65,7 @@ typedef unsigned short c_code_t; typedef mmdb_pos_t i_code_t; #define OID_T_SZ (sizeof(i_code_t)) +#define ORDER_SWAP_I_CODE_T(x) ORDER_SWAP(i_code_t, x) /************************************* // class code root diff --git a/cde/lib/DtMmdb/schema/index_desc.C b/cde/lib/DtMmdb/schema/index_desc.C index 0f3587cce..c82a13df8 100644 --- a/cde/lib/DtMmdb/schema/index_desc.C +++ b/cde/lib/DtMmdb/schema/index_desc.C @@ -164,7 +164,7 @@ handler* btree_index_desc::init_handler(object_dict& dict) (*(btree_index_handler*)v_handler_ptr) -> init_data_member( (inv_lists_handler*)inv_handler, - form("%s/%s", get_agent_nm(), dict.db_path()) + form("%s/%s", dict.db_path(), get_agent_nm()) ); (*(btree_index_handler*)v_handler_ptr) -> set_selector(position) ; diff --git a/cde/lib/DtMmdb/schema/object_dict.h b/cde/lib/DtMmdb/schema/object_dict.h index d863d7bd6..72d204e7c 100644 --- a/cde/lib/DtMmdb/schema/object_dict.h +++ b/cde/lib/DtMmdb/schema/object_dict.h @@ -53,7 +53,6 @@ #define _object_dict 1 #include "dstr/bset.h" -#include "utility/ostring.h" #include "object/handler.h" #include "mgrs/template_mgr.h" diff --git a/cde/lib/DtMmdb/storage/spointer.h b/cde/lib/DtMmdb/storage/spointer.h index f45641bba..aa13b45e0 100644 --- a/cde/lib/DtMmdb/storage/spointer.h +++ b/cde/lib/DtMmdb/storage/spointer.h @@ -118,7 +118,7 @@ public: }; void swap_order() { - ORDER_SWAP_LONG(fwd_ptr); + ORDER_SWAP_MMDB_POS_T(fwd_ptr); ORDER_SWAP_UINT(header.int_view); swapped = true; }; diff --git a/cde/lib/DtMmdb/utility/Makefile.am b/cde/lib/DtMmdb/utility/Makefile.am index 10beddabc..f9842303e 100644 --- a/cde/lib/DtMmdb/utility/Makefile.am +++ b/cde/lib/DtMmdb/utility/Makefile.am @@ -4,7 +4,7 @@ noinst_LTLIBRARIES = libutility.la libutility_la_CXXFLAGS = -DPORTABLE_DB -I.. -libutility_la_SOURCES = funcs.C ostring.C pm_random.C \ +libutility_la_SOURCES = funcs.C pm_random.C \ atoi_pearson.C xtime.C buffer.C \ atoi_larson.C atomic_lock.C rw_lock.C \ atoi_fast.C filter.C mmdb_exception.C \ diff --git a/cde/lib/DtMmdb/utility/atoi_fast.C b/cde/lib/DtMmdb/utility/atoi_fast.C index f9bf41e5e..a598d32a6 100644 --- a/cde/lib/DtMmdb/utility/atoi_fast.C +++ b/cde/lib/DtMmdb/utility/atoi_fast.C @@ -98,7 +98,7 @@ union u_tag { int atoi_fast::atoi(const key_type& k, int offset) const { - char* string = k.get(); + const char* string = k.c_str(); int l = k.size(); return atoi((const char*)string, l, offset, 0); } diff --git a/cde/lib/DtMmdb/utility/atoi_larson.C b/cde/lib/DtMmdb/utility/atoi_larson.C index 91695dd62..88e104ec7 100644 --- a/cde/lib/DtMmdb/utility/atoi_larson.C +++ b/cde/lib/DtMmdb/utility/atoi_larson.C @@ -73,7 +73,7 @@ atoi_larson::atoi(const char* str, int sz, int, int rang) const int atoi_larson::atoi(const key_type& k, int) const { - char* string = k.get(); + const char* string = k.c_str(); int l = k.size(); unsigned int sum = 0; diff --git a/cde/lib/DtMmdb/utility/atoi_larson.h b/cde/lib/DtMmdb/utility/atoi_larson.h index e21125d05..9bf2f5ff0 100644 --- a/cde/lib/DtMmdb/utility/atoi_larson.h +++ b/cde/lib/DtMmdb/utility/atoi_larson.h @@ -52,6 +52,7 @@ #else #include #endif +#include #include "key.h" // Based on Larson's algorithm presented in CACM ???. diff --git a/cde/lib/DtMmdb/utility/atoi_pearson.C b/cde/lib/DtMmdb/utility/atoi_pearson.C index afd001288..1a3c3a671 100644 --- a/cde/lib/DtMmdb/utility/atoi_pearson.C +++ b/cde/lib/DtMmdb/utility/atoi_pearson.C @@ -129,7 +129,7 @@ union u_tag { int atoi_pearson::atoi(const key_type& k, int offset) const { - char* string = k.get(); + const char* string = k.c_str(); int l = k.size(); return atoi((const char*)string, l, offset, 0); } diff --git a/cde/lib/DtMmdb/utility/key.h b/cde/lib/DtMmdb/utility/key.h index 2e690b335..156a258ed 100644 --- a/cde/lib/DtMmdb/utility/key.h +++ b/cde/lib/DtMmdb/utility/key.h @@ -45,8 +45,8 @@ #ifndef _key_h #define _key_h 1 -#include "utility/ostring.h" +#include -typedef ostring key_type; +typedef std::string key_type; #endif diff --git a/cde/lib/DtMmdb/utility/macro.h b/cde/lib/DtMmdb/utility/macro.h index 295619f83..f88c3ebfe 100644 --- a/cde/lib/DtMmdb/utility/macro.h +++ b/cde/lib/DtMmdb/utility/macro.h @@ -77,48 +77,18 @@ /* little endian to/from big endian swap macros. */ -#define ORDER_SWAP_LONG(x) \ -{ \ - long tmp_long = x; \ - ((unsigned char*)&x)[0] = ((unsigned char*)&tmp_long)[3]; \ - ((unsigned char*)&x)[1] = ((unsigned char*)&tmp_long)[2]; \ - ((unsigned char*)&x)[2] = ((unsigned char*)&tmp_long)[1]; \ - ((unsigned char*)&x)[3] = ((unsigned char*)&tmp_long)[0]; \ +#define ORDER_SWAP(type, value) \ +{ \ + type tmp = value; \ + int n = sizeof(type) - 1; \ + for (int i = 0; i <= n; ++i) \ + ((uint8_t *)&value)[i] = ((uint8_t *)&tmp)[n - i]; \ } -#define ORDER_SWAP_FLOAT(x) \ -{ \ - float tmp_float = x; \ - ((unsigned char*)&x)[0] = ((unsigned char*)&tmp_float)[3]; \ - ((unsigned char*)&x)[1] = ((unsigned char*)&tmp_float)[2]; \ - ((unsigned char*)&x)[2] = ((unsigned char*)&tmp_float)[1]; \ - ((unsigned char*)&x)[3] = ((unsigned char*)&tmp_float)[0]; \ -} - -#define ORDER_SWAP_INT(x) \ -{ \ - int tmp_uint = x; \ - ((unsigned char*)&x)[0] = ((unsigned char*)&tmp_uint)[3]; \ - ((unsigned char*)&x)[1] = ((unsigned char*)&tmp_uint)[2]; \ - ((unsigned char*)&x)[2] = ((unsigned char*)&tmp_uint)[1]; \ - ((unsigned char*)&x)[3] = ((unsigned char*)&tmp_uint)[0]; \ -} - -#define ORDER_SWAP_UINT(x) \ -{ \ - unsigned int tmp_uint = x; \ - ((unsigned char*)&x)[0] = ((unsigned char*)&tmp_uint)[3]; \ - ((unsigned char*)&x)[1] = ((unsigned char*)&tmp_uint)[2]; \ - ((unsigned char*)&x)[2] = ((unsigned char*)&tmp_uint)[1]; \ - ((unsigned char*)&x)[3] = ((unsigned char*)&tmp_uint)[0]; \ -} - -#define ORDER_SWAP_USHORT(x) \ -{ \ - unsigned short tmp_ushort = x; \ - ((unsigned char*)&x)[0] = ((unsigned char*)&tmp_ushort)[1]; \ - ((unsigned char*)&x)[1] = ((unsigned char*)&tmp_ushort)[0]; \ -} - +#define ORDER_SWAP_FLOAT(x) ORDER_SWAP(float, x) +#define ORDER_SWAP_LONG(x) ORDER_SWAP(long, x) +#define ORDER_SWAP_INT(x) ORDER_SWAP(int, x) +#define ORDER_SWAP_UINT(x) ORDER_SWAP(unsigned int, x) +#define ORDER_SWAP_USHORT(x) ORDER_SWAP(unsigned short, x) +#define ORDER_SWAP_MMDB_POS_T(x) ORDER_SWAP(mmdb_pos_t, x) #endif - diff --git a/cde/lib/DtMmdb/utility/ostring.C b/cde/lib/DtMmdb/utility/ostring.C deleted file mode 100644 index 32c572050..000000000 --- a/cde/lib/DtMmdb/utility/ostring.C +++ /dev/null @@ -1,284 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* - * $XConsortium: ostring.cc /main/3 1996/06/11 17:38:07 cde-hal $ - * - * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved. - * UNPUBLISHED -- rights reserved under the Copyright Laws of the United - * States. Use of a copyright notice is precautionary only and does not - * imply publication or disclosure. - * - * This software contains confidential information and trade secrets of HaL - * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited - * without the prior express written permission of HaL Computer Systems, Inc. - * - * RESTRICTED RIGHTS LEGEND - * Use, duplication, or disclosure by the Government is subject to - * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in - * Technical Data and Computer Software clause at DFARS 252.227-7013. - * HaL Computer Systems, Inc. - * 1315 Dell Avenue, Campbell, CA 95008 - * - */ - - -#include "utility/ostring.h" - -#ifdef C_API -char* ostring::input_buf = 0; -#else -char ostring::input_buf[LBUFSIZ]; -#endif - -ostring::ostring() : v_sz(0), v_allo_sz(1) -{ - v_p = new char[1]; -} - -ostring::ostring(const int i) : v_sz(0), v_allo_sz(i+1) -{ - v_p = new char[i+1]; -} - -ostring::ostring(char* x, const int i) -{ - int w = i; - - if ( w == -1 ) { - w = strlen(x); - } - - v_sz = w; - v_allo_sz = w+1; - - v_p = new char[w+1]; - memcpy(v_p, x, w); - v_p[w] = 0; -} - -ostring::ostring(const ostring& s) : -v_sz(s.v_sz), v_allo_sz(s.v_allo_sz) -{ - v_p = new char[v_allo_sz]; - memcpy(v_p, s.v_p, v_sz); - v_p[v_sz] = 0; -} - -/* -ostring::~ostring() -{ - delete v_p; -} -*/ - -Boolean ostring::set(const char* x, int l) -{ - expand(l+1); - - memcpy(v_p, x, l); - v_p[l] = 0; - v_sz = l; - - return true; -} - -/* -Boolean ostring::set(const char* x) -{ - return set(x, strlen(x)); -} - -void ostring::reset() -{ - v_sz = 0; -} - -void ostring::set_size(const int s) -{ - v_sz = s; - v_p[v_sz] = 0; -} -*/ - -/********************************************/ -// set alloc_sz to at least new_alloc_sz bytes -/********************************************/ -Boolean ostring::expand(const int new_alloc_sz, Boolean pre_zero) -{ - if ( new_alloc_sz > v_allo_sz ) { - v_allo_sz = new_alloc_sz+1; - char* new_p = new char[v_allo_sz]; - - if ( pre_zero == true ) - memset(new_p, char(0), v_allo_sz); - - if ( v_p ) { - memcpy(new_p, v_p, v_sz); - delete [] v_p; - } - - v_p = new_p; - } - return true; -} - -char* ostring::acquire() -{ - v_allo_sz = v_sz = 0; - char *x = v_p; - v_p = 0; - return x; -} - -Boolean ostring::append(const char* x, int l) -{ - expand(v_sz+l+1); - - memcpy(v_p+v_sz, x, l); - v_sz += l; - v_p[v_sz] = 0; - return true; -} - -Boolean ostring::update(const char* x, int l, int offset) -{ - if ( offset + l > v_sz ) { - MESSAGE(cerr, "update(): char chunk too small"); - throw(boundaryException(0, v_sz, offset+l)); - } - - memcpy(v_p+offset, x, l); - return true; -} - -int ostring::substr(ostring& s) -{ - if ( v_p == 0 || s.v_p == 0 ) - return -1; - - char* sub_p = strstr(v_p, s.v_p); - - if ( sub_p == 0 ) - return -1; - else - return (int)(sub_p - v_p); -} - -/* -int ostring::size() const -{ - return v_sz; -} - -int ostring::alloc_size() const -{ - return v_allo_sz; -} -*/ - -ostring& ostring::operator +(ostring& s) -{ - int l1 = v_sz; - int l2 = s.v_sz; - - ostring *new_ostring = new ostring(l1+l2); - - int i; - for ( i = 0; i get() ; - char* y_str = y.get() ; - - int x_sz = this -> size() ; - int y_sz = y.size() ; - - if ( x_sz == y_sz ) { - if ( memcmp(x_str, y_str, x_sz ) < 0 ) - return true; - else - return false; - } else { - - int min = MIN(x_sz, y_sz); - - for ( int i=0; i y_str[i] ) - return false; - } - if ( x_sz < y_sz ) - return true; - else - return false; - } -} - -Boolean ostring::string_EQ(ostring& y) const -{ - if ( this -> size() == y.size() && - memcmp(this -> get(), y.get(), this -> size() ) == 0 - ) - return true; - else - return false; -} - -ostream& operator <<(ostream& s, const ostring& o) -{ - if ( o.v_p ) { - //s << o.v_sz << ":"; - for ( int i=0; i>(istream& s, ostring& o) -{ - s.getline( o.input_buf, LBUFSIZ ); - o.set(o.input_buf); - return s; -} - - -ostring* ostring::operator+= (ostring* ) -{ - return 0; -} - -ostring* ostring::concate_with(...) -{ - return 0 ; -} - diff --git a/cde/lib/DtMmdb/utility/ostring.h b/cde/lib/DtMmdb/utility/ostring.h deleted file mode 100644 index b969b3add..000000000 --- a/cde/lib/DtMmdb/utility/ostring.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* - * $XConsortium: ostring.h /main/3 1996/06/11 17:38:12 cde-hal $ - * - * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved. - * UNPUBLISHED -- rights reserved under the Copyright Laws of the United - * States. Use of a copyright notice is precautionary only and does not - * imply publication or disclosure. - * - * This software contains confidential information and trade secrets of HaL - * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited - * without the prior express written permission of HaL Computer Systems, Inc. - * - * RESTRICTED RIGHTS LEGEND - * Use, duplication, or disclosure by the Government is subject to - * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in - * Technical Data and Computer Software clause at DFARS 252.227-7013. - * HaL Computer Systems, Inc. - * 1315 Dell Avenue, Campbell, CA 95008 - * - */ - - -#ifndef _ostring_h -#define _ostring_h 1 - -#include "utility/funcs.h" - -class ostring { - -public: - ostring(); - ostring(const int chunk_size); - ostring(char* str, const int str_sz = -1); // -1 means take strlen(str) - ostring(const ostring&); - virtual ~ostring() { delete [] v_p; }; - -// length of the string - int size() const { return v_sz; }; -// length of the allocated chunk - int alloc_size() const { return v_allo_sz; }; - - ostring& operator +(ostring&); // merge of two strings - int substr(ostring&); // substring matching - -// set string to content x - Boolean set(const char* x) { return set(x, strlen(x)); }; - - Boolean set(const char* x, int i); // set string to content x with length i - Boolean append(const char* x, int l); // append a string x of length i - Boolean update(const char* x, int l, int offset); // update a substring x of length i at 'offset'. offset + l should be sz - -//set alloc_sz to at least new_alloc_sz bytes -// pre_zero = true -> zero new space before copy old content over - Boolean expand(const int, Boolean pre_zero = false); - - void reset() { v_sz = 0; }; - void set_size(const int s) { v_sz = s; v_p[v_sz] = 0; }; - - char* get() const { return v_p; }; // get char pointer p - - char* acquire() ; // return what is pointed at by p and reset - // alloc_sz, sz, and p to 0; - -// append x to this and return this. - ostring* operator+= (ostring* x); - -// concate all ostring arguments (ostring* 's) to this and return this. - ostring* concate_with(...); - - Boolean string_LS(ostring&) const; - Boolean string_EQ(ostring&) const; - - friend ostream& operator <<(ostream&, const ostring&); - friend istream& operator >>(istream&, ostring&); - -protected: - char *v_p; // memory chunk pointer - int v_sz; // string size - int v_allo_sz; // allocated memory chunk size - -#ifdef C_API - static char* input_buf; - - friend void initialize_MMDB(); - friend void quit_MMDB(); -#else - static char input_buf[LBUFSIZ]; -#endif -}; - -#endif diff --git a/cde/lib/DtMmdb/utility/types.h b/cde/lib/DtMmdb/utility/types.h index b7ab58603..33a38beba 100644 --- a/cde/lib/DtMmdb/utility/types.h +++ b/cde/lib/DtMmdb/utility/types.h @@ -47,8 +47,10 @@ #define _types_h 1 #ifdef C_API +#include #include "utility/c_iostream.h" #else +#include #include using namespace std; #endif @@ -60,15 +62,7 @@ typedef char Boolean; typedef void* voidPtr; typedef char* charPtr; -typedef short s_int16; -typedef unsigned short u_int16; - -typedef int s_int32; -typedef unsigned int u_int32; - -typedef long s_long32; - -typedef float s_float32; +typedef intptr_t mmdb_pos_t; enum io_status { done, fail }; @@ -76,14 +70,4 @@ class root; typedef Boolean (*cmp_func_ptr_t)(const void*, const void*); typedef void (*app_func_ptr_t)(const void*); typedef void (*print_func_ptr_t)(ostream&, const void*); - -//enum Boolean { true, false }; - -#if !defined(__linux__) && !defined(CSRG_BASED) -typedef long mmdb_pos_t; -#else -typedef int mmdb_pos_t; -#endif - - #endif diff --git a/cde/lib/DtSearch/boolyac.y b/cde/lib/DtSearch/boolyac.y index 8e3118d1f..8c7cf41df 100644 --- a/cde/lib/DtSearch/boolyac.y +++ b/cde/lib/DtSearch/boolyac.y @@ -41,6 +41,9 @@ */ #include #include "boolpars.h" + +void yyerror(char *); +int yylex(void); %} %union { diff --git a/cde/lib/DtSearch/raima/crread.c b/cde/lib/DtSearch/raima/crread.c index 59fcd9e7e..80ba29282 100644 --- a/cde/lib/DtSearch/raima/crread.c +++ b/cde/lib/DtSearch/raima/crread.c @@ -53,7 +53,7 @@ int d_crread( long field, /* Field constant */ -char *data, /* Data area to contain field contents */ +void *data, /* Data area to contain field contents */ int dbn /* database number */ ) { diff --git a/cde/lib/DtSearch/raima/crwrite.c b/cde/lib/DtSearch/raima/crwrite.c index 516b4e3ad..5bfe5f780 100644 --- a/cde/lib/DtSearch/raima/crwrite.c +++ b/cde/lib/DtSearch/raima/crwrite.c @@ -53,7 +53,7 @@ int d_crwrite( long field, /* field constant */ -char *data, /* data area to contain field contents */ +void *data, /* data area to contain field contents */ int dbn /* database number */ ) { diff --git a/cde/lib/DtSearch/raima/fillnew.c b/cde/lib/DtSearch/raima/fillnew.c index c52bb07cc..f7444944b 100644 --- a/cde/lib/DtSearch/raima/fillnew.c +++ b/cde/lib/DtSearch/raima/fillnew.c @@ -57,7 +57,7 @@ int d_fillnew( int nrec, /* record number */ -const char *recval, /* record value */ +const void *recval, /* record value */ int dbn /* database number */ ) { diff --git a/cde/lib/DtSearch/raima/recread.c b/cde/lib/DtSearch/raima/recread.c index 427a8731f..194806cfa 100644 --- a/cde/lib/DtSearch/raima/recread.c +++ b/cde/lib/DtSearch/raima/recread.c @@ -53,7 +53,7 @@ */ int d_recread( -char *rec, /* ptr to record area */ +void *rec, /* ptr to record area */ int dbn ) { diff --git a/cde/lib/DtSearch/raima/recwrite.c b/cde/lib/DtSearch/raima/recwrite.c index 34a092cf9..62bf8a1a9 100644 --- a/cde/lib/DtSearch/raima/recwrite.c +++ b/cde/lib/DtSearch/raima/recwrite.c @@ -53,7 +53,7 @@ */ int d_recwrite( -const char *rec, /* ptr to record area */ +const void *rec, /* ptr to record area */ int dbn ) { diff --git a/cde/lib/DtTerm/Term/Term.c b/cde/lib/DtTerm/Term/Term.c index 82fdedd82..536c6519d 100644 --- a/cde/lib/DtTerm/Term/Term.c +++ b/cde/lib/DtTerm/Term/Term.c @@ -699,7 +699,6 @@ static void Resize(Widget w) { DtTermWidget tw = (DtTermWidget) w; - DtTermData td = tw->vt.td; /* let our superclass (the Term Widget) perform the resize... */ tw->core.widget_class->core_class.superclass->core_class.resize(w); @@ -880,7 +879,6 @@ static void Destroy(Widget w) { DtTermWidget tw = (DtTermWidget) w; - DtTermData td = tw->vt.td; /* remove the DtTermData structure contents, followed by the structure... */ diff --git a/cde/lib/DtTerm/Term/TermAction.c b/cde/lib/DtTerm/Term/TermAction.c index 12c163eae..c1c4fa8c5 100644 --- a/cde/lib/DtTerm/Term/TermAction.c +++ b/cde/lib/DtTerm/Term/TermAction.c @@ -572,7 +572,6 @@ _DtTermActionEditKeyExecute(Widget w, XEvent *event, String *params, long keyNumber; char *ret; int i; - DtTermData td = tw->vt.td; if (*num_params < 1) { return; diff --git a/cde/lib/DtTerm/Term/TermBuffer.c b/cde/lib/DtTerm/Term/TermBuffer.c index 5325b9f5e..fd5cf8836 100644 --- a/cde/lib/DtTerm/Term/TermBuffer.c +++ b/cde/lib/DtTerm/Term/TermBuffer.c @@ -624,12 +624,7 @@ _DtTermDeleteEnhancement } /* - ** get a copy of the current enhancement - */ - fillEnh = enh[col]; - - /* - ** move all of the enhancement blocks between col + width and and the + ** move all of the enhancement blocks between col + width and the ** end of the line to col */ copyCount = WIDTH(line) - (col + width); @@ -736,19 +731,19 @@ _DtTermSetEnhancement switch (id) { case enhVideo: - enhState->video = (value &= VIDEO_MASK); + enhState->video = value & VIDEO_MASK; break; case enhField: - enhState->field = (value &= FIELD_MASK); + enhState->field = value & FIELD_MASK; break; case enhFgColor: - enhState->fgColor = (value &= COLOR_MASK); + enhState->fgColor = value & COLOR_MASK; break; case enhBgColor: - enhState->bgColor = (value &= COLOR_MASK); + enhState->bgColor = value & COLOR_MASK; break; case enhFont: - enhState->font = (value &= FONT_MASK); + enhState->font = value & FONT_MASK; break; default: return(-1); diff --git a/cde/lib/DtTerm/Term/TermFunction.c b/cde/lib/DtTerm/Term/TermFunction.c index dfc425af5..f661662a3 100644 --- a/cde/lib/DtTerm/Term/TermFunction.c +++ b/cde/lib/DtTerm/Term/TermFunction.c @@ -90,7 +90,6 @@ void _DtTermFuncScroll(Widget w, int count, FunctionSource functionSource) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - struct termData *tpd = tw->term.tpd; /* make sure the cursor is off... */ (void) _DtTermPrimCursorOff(w); @@ -120,7 +119,6 @@ void _DtTermFuncEndOfBuffer(Widget w, int count, FunctionSource functionSource) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - struct termData *tpd = tw->term.tpd; EXIT_IF_MARGINS_SET(tw) (void) _DtTermPrimCursorOff(w); @@ -220,13 +218,9 @@ termFuncErase { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; DtTermPrimData tpd = tw->term.tpd; - TermBuffer tb = tpd->termBuffer; short row; short col; - row = tpd->cursorRow + tpd->topRow; - col = tpd->cursorColumn; - switch(eraseSwitch) { case eraseToEOL: @@ -339,8 +333,6 @@ void _DtTermFuncClearToEndOfBuffer(Widget w, int count, FunctionSource functionSource) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - DtTermPrimData tpd = tw->term.tpd; - short trow ; /* turn the cursor off... */ (void) _DtTermPrimCursorOff(w); @@ -855,7 +847,6 @@ _DtTermFuncInsertLine(Widget w, int count, FunctionSource functionSource) } /* update screen info and counts... */ - count -= moveCount; insertedRows += moveCount; } } @@ -954,7 +945,6 @@ _DtTermVideoEnhancement(Widget w,int value) DtTermPrimData tpd = tw->term.tpd; DtTermWidget vtw = (DtTermWidget) w; DtTermData td = vtw->vt.td; - ParserContext context = GetParserContext(w); switch(value) { case 0: @@ -1075,8 +1065,6 @@ _DtTermFontEnhancement(Widget w,int value) DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; DtTermPrimData tpd = tw->term.tpd; DtTermWidget vtw = (DtTermWidget) w; - DtTermData td = vtw->vt.td; - ParserContext context = GetParserContext(w); (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer, tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFont, value); diff --git a/cde/lib/DtTerm/Term/TermFunctionKey.c b/cde/lib/DtTerm/Term/TermFunctionKey.c index 27a87d4c4..2dc475c0c 100644 --- a/cde/lib/DtTerm/Term/TermFunctionKey.c +++ b/cde/lib/DtTerm/Term/TermFunctionKey.c @@ -54,7 +54,6 @@ _DtTermFunctionKeyExecute( ) { DtTermWidget tw = (DtTermWidget) w; - DtTermData td = tw->vt.td; if (!shift || tw->vt.sunFunctionKeys == True ) { if ( tw->vt.sunFunctionKeys == True ) { diff --git a/cde/lib/DtTerm/Term/TermParse.c b/cde/lib/DtTerm/Term/TermParse.c index 7649ce84c..747363234 100644 --- a/cde/lib/DtTerm/Term/TermParse.c +++ b/cde/lib/DtTerm/Term/TermParse.c @@ -536,11 +536,10 @@ _DtTermEraseChars(Widget w) /* ECH CSIpX */ { ParserContext context ; DtTermWidget vtw = (DtTermWidget) w; - int row,col,cnt ; + int col,cnt ; Debug('P', fprintf(stderr,">>In func _DtTermEraseChars\n")) ; KILLWRAP(vtw) ; context = GetParserContext(w) ; - row = vtw->term.tpd->cursorRow ; col = vtw->term.tpd->cursorColumn ; STORELASTARG(context) ; cnt = context->parms[1] ; @@ -596,12 +595,11 @@ _DtTermCursorUp(Widget w) /* CUU CISpA */ { ParserContext context ; DtTermWidget vtw = (DtTermWidget) w; - int trow, row, tmargin, cnt; + int row, tmargin, cnt; Debug('P', fprintf(stderr,">>In func _DtTermCursorUp\n")) ; context = GetParserContext(w) ; KILLWRAP(vtw) ; tmargin = TOPMARGIN(vtw) ; - trow = TOPROW(vtw) ; STORELASTARG(context) ; cnt = context->parms[1] ; if (!(cnt))cnt=1; @@ -659,13 +657,12 @@ _DtTermCursorBack(Widget w) /* CUB CISpD */ { ParserContext context ; DtTermWidget vtw = (DtTermWidget) w; - int i,k,j,row,col,fcol,cnt ; + int i,k,j,row,col,cnt ; Debug('P', fprintf(stderr,">>In func _DtTermCursorBack\n")) ; KILLWRAP(vtw) ; context = GetParserContext(w) ; STORELASTARG(context) ; cnt = context->parms[1] ; - fcol = FIRSTCOLUMN(vtw) ; row = vtw->term.tpd->cursorRow; col = vtw->term.tpd->cursorColumn; if (!cnt) cnt=1; @@ -693,10 +690,8 @@ void _DtTermCursorToLineUp(Widget w) /* CPL CSIpF */ { DtTermWidget vtw = (DtTermWidget) w; - ParserContext context ; Debug('P', fprintf(stderr,">>In func _DtTermCursorToLineUp\n")) ; KILLWRAP(vtw) ; - context = GetParserContext(w) ; vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ; _DtTermCursorUp(w) ; } @@ -887,7 +882,6 @@ _DtTermCharAttributes(Widget w) /* SGR CSIpm */ Debug('P', fprintf(stderr,">>In func _DtTermCharAttributes\n")) ; context = GetParserContext(w) ; STORELASTARG(context) ; - cnt = PCOUNT(context) ; if(PCOUNT(context)) { for (cnt=1; cnt <= PCOUNT(context); cnt++) _DtTermVideoEnhancement(w,context->parms[cnt]) ; @@ -936,7 +930,6 @@ _DtTermChangeTextParam(Widget w) /* xterm CSIp;pcCtrl-G */ { ParserContext context ; DtTermWidget tw = (DtTermWidget) w; - DtTermData vtd = tw->vt.td; Widget sw; int i ; Arg arg[5]; @@ -1033,7 +1026,6 @@ _DtTermSaveCursor(Widget w) /* DECSC ESC7 */ { DtTermWidget vtw = (DtTermWidget) w; DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - DtTermBuffer tb = (DtTermBuffer)tw->term.tpd->termBuffer ; DtTermData vtd = vtw->vt.td; Debug('P', fprintf(stderr,">>In func _DtTermSaveCursor\n")) ; @@ -1168,19 +1160,13 @@ _DtTermSetCompatLevel(Widget w) /* DECSCL CSI p;p"p (last p literal) */ void _DtTermInvokeG3(Widget w) /* LS3R ESC| */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermInvokeG3\n")) ; - context = GetParserContext(w) ; } void _DtTermInvokeG2(Widget w) /* LS3R ESC} */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermInvokeG2\n")) ; - context = GetParserContext(w) ; } void @@ -1441,10 +1427,7 @@ _DtTermAlignTest(Widget w) /* DECALN ESC#8 */ void _DtTermInvokeG1(Widget w) /* ESC~ESC */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermInvokeG1\n")) ; - context = GetParserContext(w) ; } void @@ -1538,7 +1521,6 @@ _DtTermSelEraseInDisplay(Widget w) /* DECSED ESC?pJ */ { DtTermWidget vtw = (DtTermWidget) w; DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - TermBuffer tb = tw->term.tpd->termBuffer ; ParserContext context ; enhValues evalues; int r,col1,col2,row1,row2,col,row ; @@ -1689,10 +1671,7 @@ _DtTermParseHexDigit(Widget w) /* vt220 DECUDK store hex digit*/ void _DtTermReset(Widget w) /* RIS ESCc */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermReset\n")) ; - context = GetParserContext(w) ; _DtTermFuncHardReset(w,0 ,fromParser) ; } @@ -1766,28 +1745,19 @@ _DtTermSetCharEraseMode(Widget w) /* DECSCA ESCp"q */ void _DtTermSingleWide(Widget w) /* DECSWL ESC#5 */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermSingleWide\n")) ; - context = GetParserContext(w) ; } void _DtTermDoubleWide(Widget w) /* DECDWL ESC#6 */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermDoubleWide\n")) ; - context = GetParserContext(w) ; } void _DtTermDoubleHigh(Widget w) /* DECWHL ESC#4 */ { - ParserContext context ; - int cnt ; Debug('P', fprintf(stderr,">>In func _DtTermDoubleHigh\n")) ; - context = GetParserContext(w) ; } void @@ -1990,11 +1960,9 @@ _DtTermParseBackspace /* Ctrl-H */ Widget w ) { - ParserContext context ; DtTermWidget vtw = (DtTermWidget) w; int row,col,fcol,cnt ; Debug('P', fprintf(stderr,">>In func _DtTermParseBackspace\n")) ; - context = GetParserContext(w) ; fcol = FIRSTCOLUMN(vtw) ; row = vtw->term.tpd->cursorRow; col = vtw->term.tpd->cursorColumn; @@ -2098,7 +2066,6 @@ _DtTermParseSunMisc /* Misc sun esc seqs */ DtTermWidget vtw = (DtTermWidget) w; Display *display = XtDisplay(w); int i, scr_num = XScreenNumberOfScreen(XtScreen(w)); - Window win = XtWindow(w); Window sh_win; Widget sw; XWindowChanges values; @@ -2189,18 +2156,18 @@ _DtTermParseSunMisc /* Misc sun esc seqs */ s = XtMalloc(strlen(icon) + strlen(fmt) + 1); else s = buf; - sprintf(s, "%s", fmt); + sprintf(s, fmt, icon); sendEscSequence(w,s) ; if (s != buf) XtFree(s); break ; case 21: XtVaGetValues(sw,XmNtitle, &title, NULL); fmt = "\033]l%s\033\\"; - if (strlen(icon) + strlen(fmt) + 1 >= sizeof(buf)) - s = XtMalloc(strlen(icon) + strlen(fmt) + 1); + if (strlen(title) + strlen(fmt) + 1 >= sizeof(buf)) + s = XtMalloc(strlen(title) + strlen(fmt) + 1); else s = buf; - sprintf(s, "%s", fmt); + sprintf(s, fmt, title); sendEscSequence(w,s) ; if (s != buf) XtFree(s); break ; @@ -2233,8 +2200,6 @@ Widget w void _DtTermParserSunIconFile(Widget w) /* Sun set icon to pixmap in file */ { - DtTermBuffer tb = - (DtTermBuffer)((DtTermPrimitiveWidget)w)->term.tpd->termBuffer ; ParserContext context ; int fg, bg; Widget sw; diff --git a/cde/lib/DtTerm/TermPrim/TermPrim.c b/cde/lib/DtTerm/TermPrim/TermPrim.c index f4d79c90f..2221afd3e 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrim.c +++ b/cde/lib/DtTerm/TermPrim/TermPrim.c @@ -1344,7 +1344,7 @@ Initialize(Widget ref_w, Widget w, Arg *args, Cardinal *num_args) tw->term.log_on = False ; if (tw->term.logging) { - _DtTermPrimStartLog(tw) ; + _DtTermPrimStartLog((Widget) tw); } Debug('T', timeStamp("TermPrim Initialize() finished")); @@ -2355,7 +2355,6 @@ static void Realize(Widget w, XtValueMask *p_valueMask, XSetWindowAttributes *attributes) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - DtTermPrimData tpd = tw->term.tpd; Mask valueMask = *p_valueMask; sigset_t sigNew; char buffer[BUFSIZ]; @@ -2676,7 +2675,7 @@ Destroy(Widget w) /* flush the log file */ if (tw->term.logging ) { - _DtTermPrimCloseLog(tw) ; + _DtTermPrimCloseLog((Widget) tw); } if (tw->term.boldFont) { @@ -3891,7 +3890,7 @@ PreeditHighlight( TermSelectInfo selectInfo = tw->term.tpd->selectInfo; /* check for null feedback */ - if (call_data->text->feedback) { + if (call_data && call_data->text && call_data->text->feedback) { switch (*call_data->text->feedback) { case XIMReverse: case XIMUnderline: diff --git a/cde/lib/DtTerm/TermPrim/TermPrimAction.c b/cde/lib/DtTerm/TermPrim/TermPrimAction.c index 4287e3e81..b6b2953a9 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimAction.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimAction.c @@ -157,7 +157,6 @@ _DtTermPrimActionTab(Widget w, XEvent *event, String *params, Cardinal *num_params) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - struct termData *tpd = tw->term.tpd; Boolean shiftedTab = False; Boolean numericTab = False; int i; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimDebug.c b/cde/lib/DtTerm/TermPrim/TermPrimDebug.c index 119fc56d4..f80dcf91f 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimDebug.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimDebug.c @@ -68,13 +68,6 @@ static void catchExit(void) { - int a; - int b; - - a = 1; - b = a; - a = b; - return; } typedef struct _argArray { diff --git a/cde/lib/DtTerm/TermPrim/TermPrimFunction.c b/cde/lib/DtTerm/TermPrim/TermPrimFunction.c index dad8e3518..d9755542c 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimFunction.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimFunction.c @@ -389,7 +389,6 @@ void _DtTermPrimFuncRedrawDisplay(Widget w, int count, FunctionSource functionSource) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - struct termData *tpd = tw->term.tpd; (void) XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0, True); return; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimLineDraw.c b/cde/lib/DtTerm/TermPrim/TermPrimLineDraw.c index 1a5417b60..70e6e45de 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimLineDraw.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimLineDraw.c @@ -263,6 +263,7 @@ ScaleCharacter( #endif /* USE_PIXMAPS */ } +#ifdef USE_PIXMAPS /* stipple in the rectangle... */ for (j = 0; j < glyph->numStipples; j++) { @@ -272,10 +273,8 @@ ScaleCharacter( int y1; int y2; int stippleSize; -#ifdef USE_PIXMAPS int xIndex; int yIndex; -#endif /* USE_PIXMAPS */ /* scale x1 and x2 to our width... */ x1 = ((width - 1) * glyph->stipples[j].x1) / 100; @@ -293,7 +292,6 @@ ScaleCharacter( y1 += glyph->stipples[j].y1Offset; y2 += glyph->stipples[j].y2Offset; -#ifdef USE_PIXMAPS /* fill in the area... */ for (yIndex = y1; yIndex < y2; yIndex += stippleSize) { for (xIndex = x1; xIndex < x2; xIndex += stippleSize) { @@ -321,8 +319,8 @@ ScaleCharacter( } } } -#endif /* USE_PIXMAPS */ } +#endif /* USE_PIXMAPS */ /* mark this character as completed... */ #ifdef USE_PIXMAPS @@ -374,7 +372,6 @@ _DtTermPrimLineDrawCreateFont(Widget w, GlyphInfo glyphInfo, int numGlyphs, int width, int ascent, int descent) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - struct termData *tpd = tw->term.tpd; int fontNumber; LineDrawFont lineDrawFont; int i; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimRender.c b/cde/lib/DtTerm/TermPrim/TermPrimRender.c index 040e5a254..6c02de6c7 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimRender.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimRender.c @@ -795,7 +795,6 @@ _DtTermPrimFillScreenGap(Widget w) /* the lines are now freed, adjust the used count... */ tpd->lastUsedHistoryRow -= historyLinesNeeded; if (tpd->lastUsedHistoryRow < 0) { - historyLinesNeeded += tpd->lastUsedHistoryRow; tpd->lastUsedHistoryRow = 0; } } @@ -824,9 +823,6 @@ _DtTermPrimFillScreenGap(Widget w) enhValue *eValues = (enhValue *)NULL; overflowChars = (termChar *) XtMalloc(BUFSIZ * sizeof (termChar)); - c1 = _DtTermPrimBufferGetCharacterPointer( - tBuffer, i1, 0); - /* Perpetuate the enhancements. */ for (eCol = 0; eCol < length; eCol += eCount) { @@ -1095,7 +1091,6 @@ _DtTermPrimInsertText(Widget w, unsigned char *buffer, int length) * character count... */ pmb = (char *)buffer; - pwc = wcBuffer; wcBufferLen = i; i = 0; while (i < wcBufferLen) @@ -1270,7 +1265,6 @@ _DtTermPrimInsertText(Widget w, unsigned char *buffer, int length) newWidth = DoInsert(w, &buffer[insertStartX], insertCharCount, &wrapped); tpd->cursorColumn += insertCharCount; - insertCharCount = 0; if (tpd->insertCharMode != DtTERM_INSERT_CHAR_OFF) { renderEndX = newWidth; } else { @@ -1289,8 +1283,6 @@ _DtTermPrimInsertText(Widget w, unsigned char *buffer, int length) (void) _DtTermPrimRefreshText(w, 0, tpd->cursorRow + 1, renderEndX, tpd->cursorRow + 1); } - wrapped = False; - needToRender = False; } return(i); @@ -1336,7 +1328,6 @@ _DtTermPrimParseInput struct termData *tpd = tw->term.tpd; DtTermPrimitiveClassPart *termClassPart = &(((DtTermPrimitiveClassRec *) (tw->core.widget_class))->term_primitive_class); - TermBuffer tBuffer = tpd->termBuffer; int i; short insertStart; short insertByteCount; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimRenderMb.c b/cde/lib/DtTerm/TermPrim/TermPrimRenderMb.c index 26f51edf0..1c0c9c73e 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimRenderMb.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimRenderMb.c @@ -621,7 +621,7 @@ DoInsertWc(Widget w, wchar_t *wcBuffer, int wcBufferLen, Boolean *wrapped) wcBuffer, /* newChars */ wcBufferLen, /* numChars */ tpd->insertCharMode != DtTERM_INSERT_CHAR_OFF, /* insert flag */ - &returnChars, /* return char ptr */ + (termChar **) (&returnChars), /* return char ptr */ &returnCount); /* return count ptr */ if ((tpd->insertCharMode != DtTERM_INSERT_CHAR_ON_WRAP) || (returnCount <= 0)) { @@ -659,7 +659,7 @@ DoInsertWc(Widget w, wchar_t *wcBuffer, int wcBufferLen, Boolean *wrapped) wcBuffer, /* newChars */ wcBufferLen, /* numChars */ tpd->insertCharMode != DtTERM_INSERT_CHAR_OFF, /* insert flag */ - &returnChars, /* return char ptr */ + (termChar **) (&returnChars), /* return char ptr */ &returnCount); /* return count ptr */ (void) XtFree((char *) wcBuffer); (void) XtFree((char *) returnChars); @@ -880,7 +880,6 @@ _DtTermPrimInsertTextWc newWidth = DoInsertWc(w, &wcBuffer[insertStartX], insertCharCount, &wrapped); tpd->cursorColumn += insertCharWidth; - insertCharCount = 0; if (tpd->insertCharMode == DtTERM_INSERT_CHAR_OFF) { renderEndX = MAX(renderEndX, tpd->cursorColumn); } else { @@ -899,8 +898,6 @@ _DtTermPrimInsertTextWc (void) _DtTermPrimRefreshTextWc(w, 0, tpd->cursorRow + 1, renderEndX + 1, tpd->cursorRow + 1); } - wrapped = False; - needToRender = False; } return(i); } diff --git a/cde/lib/DtTerm/TermPrim/TermPrimScroll.c b/cde/lib/DtTerm/TermPrim/TermPrimScroll.c index f142f3fe8..e90756d37 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimScroll.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimScroll.c @@ -105,7 +105,6 @@ _DtTermPrimScrollWait(Widget w) int i; int exposeY; int exposeHeight; - int scrolledLines; Debug('s', fprintf(stderr, ">>_DtTermPrimScrollWait() starting\n")); Debug('s', fprintf(stderr, @@ -232,7 +231,6 @@ _DtTermPrimScrollWait(Widget w) exposeHeight)); /* set scrollLines == 0, or renderText will not render them... */ - scrolledLines = tpd->scroll.jump.scrollLines; tpd->scroll.jump.scrollLines = 0; /* clear the scrolled flag... */ tpd->scroll.jump.scrolled = False; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimSelect.c b/cde/lib/DtTerm/TermPrim/TermPrimSelect.c index 3701db6ad..20271fb94 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimSelect.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimSelect.c @@ -372,7 +372,6 @@ bufferRowColToPos ) { DtTermPrimData tpd = tw->term.tpd; - TermSelectInfo selectInfo = tpd->selectInfo; short lrow, lcol; XmTextPosition pos; @@ -1369,7 +1368,7 @@ doExtendedSelection if (position == scan (tw, begin, selectInfo->scanType, scanRight, 1, FALSE)) { - begin = cursorPos = position; + begin = position; } } } @@ -1505,8 +1504,6 @@ doHandleTargets { _TermSelectPrimaryRec *primSelect = (_TermSelectPrimaryRec *) closure; DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget)w; - DtTermPrimData tpd = tw->term.tpd; - TermSelectInfo selectInfo = tpd->selectInfo; XTextProperty tmpProp; XmTextBlockRec block; int i, status; @@ -2240,9 +2237,8 @@ _DtTermPrimSelectDeleteLines return; } - /* figure out what the begin and end lines are... */ + /* figure out what the begin line is... */ selectLineBegin = selectInfo->begin / (selectInfo->columns + 1); - selectLineEnd = (selectInfo->end - 1) / (selectInfo->columns + 1); /* if the beginning of the selection is after the source, we need to * move the selection up... @@ -2274,9 +2270,8 @@ _DtTermPrimSelectInsertLines return; } - /* figure out what the begin and end lines are... */ + /* figure out what the begin line is... */ selectLineBegin = selectInfo->begin / (selectInfo->columns + 1); - selectLineEnd = (selectInfo->end - 1) / (selectInfo->columns + 1); /* if the beginning of the selection is at or after the source, we need to * move the selection up... @@ -2328,8 +2323,6 @@ _DtTermPrimSelectPage ) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget)w; - DtTermPrimData tpd = tw->term.tpd; - TermSelectInfo selectInfo = tpd->selectInfo; XButtonEvent *btnEvent = (XButtonEvent *) event; XmTextPosition begin, end; short lastRow, width; @@ -2365,8 +2358,6 @@ DropTransferCallback( { _DtTermDropTransferRec *transfer_rec = (_DtTermDropTransferRec *) closure; DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget)transfer_rec->widget; - DtTermPrimData tpd = tw->term.tpd; - TermSelectInfo selectInfo = tpd->selectInfo; /* When type = NULL, we are assuming a DELETE request has been requested */ if (*type == 0) { @@ -2384,7 +2375,6 @@ DropTransferCallback( transferEntries[0].client_data = (XtPointer) transfer_rec; transferEntries[0].target = XmInternAtom(XtDisplay(w),"DELETE", False); - transferList = transferEntries; XmDropTransferAdd(w, transferEntries, 1); } } @@ -2444,8 +2434,6 @@ HandleDrop( Widget w, XmDropProcCallbackStruct *cb ) Widget drag_cont, initiator; /* XmTextWidget tw = (XmTextWidget) w; */ DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget)w; - DtTermPrimData tpd = tw->term.tpd; - TermSelectInfo selectInfo = tpd->selectInfo; Cardinal numExportTargets, n; Atom *exportTargets; Arg args[10]; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimSetUtmp.c b/cde/lib/DtTerm/TermPrim/TermPrimSetUtmp.c index df2574d17..f74ccc8e3 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimSetUtmp.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimSetUtmp.c @@ -324,7 +324,6 @@ UtmpEntryCreate(Widget w, pid_t pid, char *utmpLine) { #if !defined(CSRG_BASED) /* XXX */ DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; - struct termData *tpd = tw->term.tpd; struct utmp ut; struct utmp *utPtr; char *c; diff --git a/cde/lib/DtTerm/TermPrim/TermPrimUtil.c b/cde/lib/DtTerm/TermPrim/TermPrimUtil.c index 0184b88ca..a89367e7f 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimUtil.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimUtil.c @@ -404,16 +404,17 @@ _DtTermPrimStartLog(Widget w) if ( tw->term.log_on || tw->term.logInhibit ) { return; } if (!tw->term.logFile || !*tw->term.logFile) { - tw->term.logFile = "DttermLogXXXXX"; + tw->term.logFile = "DttermLogXXXXXX"; } - if (!strcmp(tw->term.logFile + strlen(tw->term.logFile) - 5, "XXXXX")) { + if (!strcmp(tw->term.logFile + strlen(tw->term.logFile) - 6, "XXXXXX")) { /* make a local copy in case we are going to change it... */ cp = XtMalloc(strlen(tw->term.logFile) + 1); (void) strcpy(cp, tw->term.logFile); - (void) mktemp(cp); - if (cp && *cp) { + int logStream = mkstemp(cp); + if (logStream != -1) { + tpd->logStream = fdopen(logStream, "w+"); tw->term.logFile = cp; } else { (void) XtFree(cp); @@ -421,7 +422,7 @@ _DtTermPrimStartLog(Widget w) } } - if ('|' == *tw->term.logFile ) { + else if ('|' == *tw->term.logFile ) { /* ** pipe logfile into command */ diff --git a/cde/lib/DtTerm/TermView/TermView.c b/cde/lib/DtTerm/TermView/TermView.c index fd1a5c302..b933e5073 100644 --- a/cde/lib/DtTerm/TermView/TermView.c +++ b/cde/lib/DtTerm/TermView/TermView.c @@ -898,7 +898,7 @@ Initialize(Widget rw, Widget w, Arg *args, Cardinal *num_args) if (geometry && *geometry) { hints.flags = 0; - flags = XWMGeometry(XtDisplay(w), + (void) XWMGeometry(XtDisplay(w), XScreenNumberOfScreen(XtScreen(w)), geometry, "80x24", @@ -1183,7 +1183,6 @@ Initialize(Widget rw, Widget w, Arg *args, Cardinal *num_args) /* create the function key form... */ - i = 0; /* Add an event handler for enter and leave events to allow us to * modify the "CAPS LOCK" indicator... */ diff --git a/cde/lib/DtTerm/TermView/TermViewMenu.c b/cde/lib/DtTerm/TermView/TermViewMenu.c index 753c536ea..f73b61b21 100644 --- a/cde/lib/DtTerm/TermView/TermViewMenu.c +++ b/cde/lib/DtTerm/TermView/TermViewMenu.c @@ -545,7 +545,6 @@ createFontMenu /* clear out mnemonics string... */ *mnemonics = '\0'; - c1 = mnemonics; /* create the font buttons... */ fontSizeToggles = (Widget *) XtMalloc((fontArrayCount + 1) * sizeof(Widget)); @@ -626,9 +625,9 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, i); } menu = popupMenu; - button = _DtTermViewCreateLabel(menu, + (void) _DtTermViewCreateLabel(menu, (GETMESSAGE(NL_SETN_ViewMenu,83, "Terminal"))); - button = _DtTermViewCreateSeparator(menu, "Separator"); + (void) _DtTermViewCreateSeparator(menu, "Separator"); } (void) XtFree((char *) newArglist); @@ -659,7 +658,7 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,19, "C")); accelerator = mallocGETMESSAGE(NL_SETN_ViewMenu,62, "Alt F4"); acceleratorText = mallocGETMESSAGE(NL_SETN_ViewMenu,62, "Alt+F4"); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void) _DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,18, "Close")), ks, accelerator, @@ -671,12 +670,12 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, if (menuBar || (!menuBar && firstPopup)) #ifdef PULLDOWN_ACCELERATORS ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,21, "W")); - cascade = _DtTermViewCreateCascadeButton(menu, pulldown[pc], + (void) _DtTermViewCreateCascadeButton(menu, pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,20, "Window")), ks, NULL, NULL, NULL, NULL); #else /* PULLDOWN_ACCELERATORS */ - cascade = _DtTermViewCreateCascadeButton(menu, pulldown[pc], + (void) _DtTermViewCreateCascadeButton(menu, pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,20, "Window")), NoSymbol, NULL, NULL, NULL, NULL); #endif /* PULLDOWN_ACCELERATORS */ @@ -689,7 +688,7 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, "Ctrl osfInsert"); acceleratorText = mallocGETMESSAGE(NL_SETN_ViewMenu,25, "Ctrl+Insert"); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,23, "C")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void) _DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,22, "Copy")), ks, accelerator, @@ -702,7 +701,7 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, accelerator = mallocGETMESSAGE(NL_SETN_ViewMenu,28, "Shift osfInsert"); acceleratorText = mallocGETMESSAGE(NL_SETN_ViewMenu,29, "Shift+Insert"); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void) _DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,26, "Paste")), ks, accelerator, @@ -714,12 +713,12 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, if (menuBar || (!menuBar && firstPopup)) #ifdef PULLDOWN_ACCELERATORS ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,31, "E")); - cascade = _DtTermViewCreateCascadeButton(menu, pulldown[pc], + (void) _DtTermViewCreateCascadeButton(menu, pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,30, "Edit")), ks, NULL, NULL, NULL, NULL); #else /* PULLDOWN_ACCELERATORS */ - cascade = _DtTermViewCreateCascadeButton(menu, pulldown[pc], + (void) _DtTermViewCreateCascadeButton(menu, pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,30, "Edit")), NoSymbol, NULL, NULL, NULL, NULL); #endif /* PULLDOWN_ACCELERATORS */ @@ -742,13 +741,13 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, NULL, NULL, scrollBarToggleCallback, NULL); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,37, "G")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void) _DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,36, "Global...")), ks, NULL, NULL, globalOptionsCallback, NULL); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,39, "T")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void) _DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,38, "Terminal...")), ks, NULL, NULL, terminalOptionsCallback, NULL); @@ -761,13 +760,13 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, submenu = createPulldown(pulldown[pc], "Reset", arglist, i); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,41, "S")); - button = _DtTermViewCreatePushButton(submenu, + (void)_DtTermViewCreatePushButton(submenu, (GETMESSAGE(NL_SETN_ViewMenu,40, "Soft Reset")), ks, NULL, NULL, softResetCallback, NULL); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,43, "H")); - button = _DtTermViewCreatePushButton(submenu, + (void)_DtTermViewCreatePushButton(submenu, (GETMESSAGE(NL_SETN_ViewMenu,42, "Hard Reset")), ks, NULL, NULL, hardResetCallback, NULL); @@ -781,12 +780,12 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, if (menuBar || (!menuBar && firstPopup)) #ifdef PULLDOWN_ACCELERATORS ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,47, "O")); - cascade = _DtTermViewCreateCascadeButton(menu, pulldown[pc], + (void) _DtTermViewCreateCascadeButton(menu, pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,46, "Options")), ks, NULL, NULL, NULL, NULL); #else /* PULLDOWN_ACCELERATORS */ - cascade = _DtTermViewCreateCascadeButton(menu, pulldown[pc], + (void) _DtTermViewCreateCascadeButton(menu, pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,46, "Options")), NoSymbol, NULL, NULL, NULL, NULL); #endif /* PULLDOWN_ACCELERATORS */ @@ -858,49 +857,49 @@ CreateMenu(Widget termView, Widget parent, Boolean menuBar, #else /* HPVUE */ ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,65, "v")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,64, "Overview")), ks, NULL, NULL, helpOverviewCallback, NULL); - button = _DtTermViewCreateSeparator(pulldown[pc], "Separator"); + (void)_DtTermViewCreateSeparator(pulldown[pc], "Separator"); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,69,"C")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,68, "Table Of Contents")), ks, NULL, NULL, helpTableOfContentsCallback, NULL); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,71,"T")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,70, "Tasks")), ks, NULL, NULL, helpTasksCallback, NULL); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,73,"R")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,72, "Reference")), ks, NULL, NULL, helpReferenceCallback, NULL) ; ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,75,"K")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,74, "Keyboard")), ks, NULL, NULL, helpKeyboardCallback, NULL) ; - button = _DtTermViewCreateSeparator(pulldown[pc], "Separator"); + (void)_DtTermViewCreateSeparator(pulldown[pc], "Separator"); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,77,"U")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,76, "Using Help")), ks, NULL, NULL, helpUsingHelpCallback, NULL); - button = _DtTermViewCreateSeparator(pulldown[pc], "Separator"); + (void)_DtTermViewCreateSeparator(pulldown[pc], "Separator"); ks = XStringToKeysym(GETMESSAGE(NL_SETN_ViewMenu,79,"A")); - button = _DtTermViewCreatePushButton(pulldown[pc], + (void)_DtTermViewCreatePushButton(pulldown[pc], (GETMESSAGE(NL_SETN_ViewMenu,83, "About Terminal")), ks, NULL, NULL, helpAboutDttermCallback, NULL); diff --git a/cde/lib/DtTerm/util/lineToData.c b/cde/lib/DtTerm/util/lineToData.c index 5813ba41c..1a3e7a249 100644 --- a/cde/lib/DtTerm/util/lineToData.c +++ b/cde/lib/DtTerm/util/lineToData.c @@ -280,10 +280,6 @@ main(int argc, char **argv) (void) DumpChar(stdout, charCount++, charList, charListMax, rectList, rectListMax, lineList, lineListMax, stippleList, stippleListMax); - lineListMax = 0; - rectListMax = 0; - stippleListMax = 0; - charListMax = 0; } /* build the final structure... */ diff --git a/cde/programs/dtappbuilder/src/ab/appfw_stubs.c b/cde/programs/dtappbuilder/src/ab/appfw_stubs.c index 15dfbc737..6856a6529 100644 --- a/cde/programs/dtappbuilder/src/ab/appfw_stubs.c +++ b/cde/programs/dtappbuilder/src/ab/appfw_stubs.c @@ -166,7 +166,7 @@ appfw_editor_init( ) { Widget item[10]; - int item_val[10]; + XtArgVal item_val[10]; int n; /* diff --git a/cde/programs/dtappbuilder/src/ab/dnd_ed_stubs.c b/cde/programs/dtappbuilder/src/ab/dnd_ed_stubs.c index e5c52fba3..ddf995a8d 100644 --- a/cde/programs/dtappbuilder/src/ab/dnd_ed_stubs.c +++ b/cde/programs/dtappbuilder/src/ab/dnd_ed_stubs.c @@ -210,7 +210,7 @@ dnd_ed_editor_init( { DndEditorSettings dds = &dndEdInfo; Widget item[10]; - int item_val[10]; + XtArgVal item_val[10]; int n = 0; /* diff --git a/cde/programs/dtappbuilder/src/ab/message_ed_stubs.c b/cde/programs/dtappbuilder/src/ab/message_ed_stubs.c index 7840fa960..778c53f1d 100644 --- a/cde/programs/dtappbuilder/src/ab/message_ed_stubs.c +++ b/cde/programs/dtappbuilder/src/ab/message_ed_stubs.c @@ -360,7 +360,7 @@ msg_editor_init( { MsgEditorSettingsRec *mes = &msg_editor_settings_rec; Widget item[6]; - int item_val[6]; + XtArgVal item_val[6]; int i, n; /* diff --git a/cde/programs/dtappbuilder/src/ab/pal_panedwin.c b/cde/programs/dtappbuilder/src/ab/pal_panedwin.c index 17d72820c..c40bdb950 100644 --- a/cde/programs/dtappbuilder/src/ab/pal_panedwin.c +++ b/cde/programs/dtappbuilder/src/ab/pal_panedwin.c @@ -218,7 +218,7 @@ panedwin_prop_init( DtbRevolvPropDialogInfo rpd = &(dtb_revolv_prop_dialog); PropPanedWinSettingsRec *pws = &(prop_pw_settings_rec[type]); Widget item[2]; - int item_val[2]; + XtArgVal item_val[2]; int n = 0; if (type == AB_PROP_REVOLVING) diff --git a/cde/programs/dtappbuilder/src/libABil/bil_parse.y b/cde/programs/dtappbuilder/src/libABil/bil_parse.y index 6856554ef..55aefb6bc 100644 --- a/cde/programs/dtappbuilder/src/libABil/bil_parse.y +++ b/cde/programs/dtappbuilder/src/libABil/bil_parse.y @@ -25,6 +25,8 @@ #define TOK (bilP_load_get_token()) +void yyerror(char *); +int yylex(void); %} /* * We assume that yacc spits out the symbols in the order they are diff --git a/cde/programs/dtcalc/calctool.c b/cde/programs/dtcalc/calctool.c index 279582000..756e728a4 100644 --- a/cde/programs/dtcalc/calctool.c +++ b/cde/programs/dtcalc/calctool.c @@ -46,7 +46,6 @@ #include "patchlevel.h" #include "calctool.h" #include "ds_common.h" -#include "calctool.h" #include "text.h" static double max_fix[4] = { @@ -1203,8 +1202,8 @@ make_number(int *MPnumber, BOOLEAN mkFix) /*ARGSUSED*/ /* Default math library exception handling routine. */ -int -matherr(struct exception *exc) +void +math_err(void) { #if 0 char msg[100]; @@ -1232,7 +1231,6 @@ matherr(struct exception *exc) #endif doerr(vstrs[(int) V_ERROR]) ; - return(1) ; /* Value ignored. */ } /* Convert string into an MP number. */ diff --git a/cde/programs/dtcalc/calctool.h b/cde/programs/dtcalc/calctool.h index e5b7fa66d..a6b631562 100644 --- a/cde/programs/dtcalc/calctool.h +++ b/cde/programs/dtcalc/calctool.h @@ -636,6 +636,7 @@ void make_items(void); void make_modewin(void); void make_fin_registers(void); void make_registers(int); +void math_err(void); void MPstr_to_num(char *, enum base_type, int *); void paren_disp(char); void process_event(int); diff --git a/cde/programs/dtcalc/functions.c b/cde/programs/dtcalc/functions.c index fa96fe484..8bcaaf618 100644 --- a/cde/programs/dtcalc/functions.c +++ b/cde/programs/dtcalc/functions.c @@ -677,7 +677,7 @@ do_factorial(int *MPval, int *MPres) /* Calculate the factorial of MPval. */ } mpcim(&i, MPa) ; mpcmi(MP1, &i) ; - if (!i) matherr((struct exception *) NULL) ; + if (!i) math_err() ; else while (i > 0) { @@ -687,7 +687,7 @@ do_factorial(int *MPval, int *MPres) /* Calculate the factorial of MPval. */ i-- ; } } - else matherr((struct exception *) NULL) ; + else math_err() ; mpstr(MPa, MPres) ; } diff --git a/cde/programs/dtcm/dtcm/Makefile.am b/cde/programs/dtcm/dtcm/Makefile.am index 93fbbf3a1..60ccc8d7b 100644 --- a/cde/programs/dtcm/dtcm/Makefile.am +++ b/cde/programs/dtcm/dtcm/Makefile.am @@ -8,7 +8,7 @@ AM_CFLAGS = $(DT_INCDIR) $(CSA_INCDIR) -I../../../lib/csa \ LDADD = ../libDtCmP/libDtCmP.a $(LIBCSA) $(DTCLIENTLIBS) $(XTOOLLIB) if FREEBSD -LDADD += -lcompat +LDADD += -lcompat -lutil endif if NETBSD diff --git a/cde/programs/dtcm/dtcm/browser.c b/cde/programs/dtcm/dtcm/browser.c index 8de446cd8..09f948986 100644 --- a/cde/programs/dtcm/dtcm/browser.c +++ b/cde/programs/dtcm/dtcm/browser.c @@ -1323,7 +1323,7 @@ mb_clear_selected_calendar( if (geditor_showing(e)) remove_from_gaccess_list(name, e); mb_deregister_names(name, c); - mb_refresh_canvas(c->browser, c); + mb_refresh_canvas(b, c); } extern void diff --git a/cde/programs/dtcm/dtcm/rfp.c b/cde/programs/dtcm/dtcm/rfp.c index 460aee2d9..5c9319976 100644 --- a/cde/programs/dtcm/dtcm/rfp.c +++ b/cde/programs/dtcm/dtcm/rfp.c @@ -942,7 +942,7 @@ rfp_form_flags_to_appt(RFP *rfp, Dtcm_appointment *a, char *name, int *flagsP) memset(a->repeat_type, 0, sizeof(CSA_attribute)); _DtCm_set_sint32_attrval(rfp->repeat_type, - &a->repeat_type->value); + (cms_attribute_value **) &a->repeat_type->value); } else a->repeat_type->value->item.sint32_value = rfp->repeat_type; } @@ -958,7 +958,7 @@ rfp_form_flags_to_appt(RFP *rfp, Dtcm_appointment *a, char *name, int *flagsP) memset(a->repeat_type, 0, sizeof(CSA_attribute)); - _DtCm_set_sint32_attrval(rfp->repeat_type,&a->repeat_type->value); + _DtCm_set_sint32_attrval(rfp->repeat_type, (cms_attribute_value **) &a->repeat_type->value); } else a->repeat_type->value->item.sint32_value = rfp->repeat_type; } diff --git a/cde/programs/dtcm/dtcm/x_graphics.c b/cde/programs/dtcm/dtcm/x_graphics.c index 7233d3c67..bfe295516 100644 --- a/cde/programs/dtcm/dtcm/x_graphics.c +++ b/cde/programs/dtcm/dtcm/x_graphics.c @@ -1351,7 +1351,7 @@ cm_print_appt_text(CMGraphicsInfo *gInfo, char *str, unsigned long _len; _len = strlen(str); - _converter_( str, _len, &to, &to_len ); + _converter_( str, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) str = to; @@ -1578,7 +1578,7 @@ cm_print_todo_text(CMGraphicsInfo *gInfo, char *str1, CSA_sint32 as, unsigned long _len; _len = strlen(str1); - _converter_( str1, _len, &to, &to_len ); + _converter_( str1, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) str1 = to; } @@ -2009,7 +2009,7 @@ local_dayname(Calendar *c, char **array_place, int dayNum) dayCatIndex[dayNum], defaultDays[dayNum]); _len = strlen( source ); - _converter_( source, _len, &to, &to_len ); + _converter_( source, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = euc_to_octal(to); } else { @@ -2041,7 +2041,7 @@ local_dayname3(Calendar *c, char **array_place, int dayNum) dayCatIndex[dayNum], defaultDays[dayNum]); _len = strlen( source ); - _converter_( source, _len, &to, &to_len ); + _converter_( source, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = euc_to_octal(to); } else { @@ -2089,7 +2089,7 @@ get_report_type_string(CMGraphicsInfo *gInfo) defaultStrs[reportType]); _len = strlen( str ); - _converter_( str, _len, &to, &to_len ); + _converter_( str, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = to; } @@ -2367,7 +2367,7 @@ x_open_file(Calendar *c) unsigned long _len; _len = strlen( gInfo->timestamp ); - _converter_( gInfo->timestamp, _len, &to, &to_len ); + _converter_( gInfo->timestamp, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) strncpy( gInfo->timestamp, to, ( BUFFERSIZE > to_len ) ? to_len : BUFFERSIZE - 1 ); @@ -2610,7 +2610,7 @@ x_print_header(void *gInfoP, char *buf, int pageNum, int numPages) unsigned long _len; _len = strlen( buf ); - _converter_( buf, _len, &to, &to_len ); + _converter_( buf, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = euc_to_octal(to); } else { @@ -2639,7 +2639,7 @@ x_print_header(void *gInfoP, char *buf, int pageNum, int numPages) unsigned long _len; _len = strlen( str2 ); - _converter_( str2, _len, &to, &to_len ); + _converter_( str2, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { strncpy( str2, to, ( BUFFERSIZE > to_len ) ? to_len : BUFFERSIZE ); @@ -2654,7 +2654,7 @@ x_print_header(void *gInfoP, char *buf, int pageNum, int numPages) unsigned long _len; _len = strlen( str ); - _converter_( str, _len, &to, &to_len ); + _converter_( str, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = to; } @@ -2717,7 +2717,7 @@ x_day_header (void *gInfoP) unsigned long _len; _len = strlen( str ); - _converter_( str, _len, &to, &to_len ); + _converter_( str, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = to; } @@ -2737,7 +2737,7 @@ x_day_header (void *gInfoP) unsigned long _len; _len = strlen( str ); - _converter_( str, _len, &to, &to_len ); + _converter_( str, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { str = to; } @@ -3249,7 +3249,7 @@ x_print_month(void *gInfoP, int mon, int yr, int x1, unsigned long _len; _len = strlen(str); - _converter_( str, _len, &to, &to_len ); + _converter_( str, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { cm_strcpy(str, to); } @@ -3574,7 +3574,7 @@ x_week_daynames(void *gInfoP, char *dayName, int dayIndex, Boolean more) unsigned long _len; _len = strlen(dayName); - _converter_( dayName, _len, &to, &to_len ); + _converter_( dayName, _len, (void **) &to, &to_len ); if ( ( to != NULL ) && ( to_len != 0 ) ) { dayName = to; } diff --git a/cde/programs/dtcreate/ErrorDialog.c b/cde/programs/dtcreate/ErrorDialog.c index 677ee6003..fc20062b1 100644 --- a/cde/programs/dtcreate/ErrorDialog.c +++ b/cde/programs/dtcreate/ErrorDialog.c @@ -47,6 +47,7 @@ void activateCB_ErrorDialog_OkButton( Widget UxWidget, { XtDestroyWidget(XtParent(UxWidget)); + *(Widget **)UxClientData = NULL; } /******************************************************************************/ @@ -63,7 +64,7 @@ void display_error_message (Widget parent, char *message) XtAddCallback( ErrorDialog, XmNokCallback, (XtCallbackProc) activateCB_ErrorDialog_OkButton, - (XtPointer) NULL ); + (XtPointer) &ErrorDialog ); XtVaSetValues (ErrorDialog, RES_CONVERT(XmNdialogTitle, GETMESSAGE(6, 31, "Create Action - Error")), diff --git a/cde/programs/dtcreate/cmncbs.c b/cde/programs/dtcreate/cmncbs.c index b9fd1fb2d..90e32a57b 100644 --- a/cde/programs/dtcreate/cmncbs.c +++ b/cde/programs/dtcreate/cmncbs.c @@ -158,10 +158,8 @@ void activateCB_open_FindSet (Widget find_set_button, XtPointer cdata, XtFree(container_title); XtFree(directory_title); XtFree(dialog_title); - FreeIconSearchPathList(directories_list); XtVaSetValues (IconSelector, XmNuserData, cdata, NULL); UxPopupInterface (IconSelector, no_grab); - XmProcessTraversal(ISD_SelectedIconTextField, XmTRAVERSE_CURRENT); return; } diff --git a/cde/programs/dtcreate/icon_selection_dialog.c b/cde/programs/dtcreate/icon_selection_dialog.c index d60105025..f27862c7f 100644 --- a/cde/programs/dtcreate/icon_selection_dialog.c +++ b/cde/programs/dtcreate/icon_selection_dialog.c @@ -50,6 +50,7 @@ #include #include
+#include
#include "dtcreate.h" #include "UxXt.h" @@ -144,7 +145,7 @@ int myscandir(char *pszDirName, struct dirent ***NameList, int Select(), int Com errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) + strlen(pszDirName) + 1) * sizeof(char)); sprintf(errPtr, fmtPtr, msgPtr, pszDirName); - display_error_message(CreateActionAppShell, errPtr); + display_error_message(IconSelector, errPtr); XtFree(errPtr); return(0); } @@ -245,7 +246,7 @@ struct dirent **build_dirent_list (char *filter, int *filecount) errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) + strlen(dirname) + 1) * sizeof(char)); sprintf(errPtr, fmtPtr, msgPtr, dirname); - display_error_message(CreateActionAppShell, errPtr); + display_error_message(IconSelector, errPtr); XtFree(errPtr); namelist = NULL; } @@ -1327,13 +1328,94 @@ void resizeCB_clipWindow( Widget UxWidget, printf("icon_count = %d\n", icon_count); #endif - increment = (int)height / icon_count; + increment = icon_count > 0 ? (int)height / icon_count : height; XtVaSetValues(widvScrollbar, XmNincrement, increment, NULL); return; } +static void mapCB_icon_selection_dialog(Widget UxWidget, + XtPointer UxClientData, + XtPointer UxCallbackArg) +{ + DtWsmRemoveWorkspaceFunctions(UxDisplay, XtWindow(XtParent(UxWidget))); +} + +static void focusCB_icon_selection_dialog(Widget UxWidget, + XtPointer UxClientData, + XtPointer UxCallbackArg) +{ + char *initial_filter; + Widget descendant; + + XtRemoveCallback(UxWidget, XmNfocusCallback, focusCB_icon_selection_dialog, + NULL); + + TurnOnHourGlassAllWindows(); + + XmProcessTraversal(ISD_SelectedIconTextField, XmTRAVERSE_CURRENT); + + /******************************************************************/ + /* save file_filter */ + /******************************************************************/ + file_filter_global = (char *)calloc(strlen((char *)file_filter)+1, + sizeof(char)); + +#ifdef DEBUG + if (!file_filter_global) + printf("Calloc error for file_filter_global, in mapCB_icon_selection_dialog.\n"); +#endif + + if (file_filter[0] == '*') + file_filter_global = strcpy(file_filter_global, (char *)&file_filter[1]); + else + file_filter_global = strcpy(file_filter_global, (char *)file_filter); + + load_directories_list((char **)directories_list); + initial_filter = initialize_filter((char *)file_filter); + FreeIconSearchPathList((char **)directories_list); + + /******************************************************************/ + /* save main_filter */ + /******************************************************************/ + main_filter = (char *)calloc(strlen(initial_filter)+1, sizeof(char)); + +#ifdef DEBUG + if (!main_filter) + printf("Calloc error for main_filter, in mapCB_icon_selection_dialog.\n"); +#endif + + main_filter = strcpy(main_filter, initial_filter); + + icons_in_container = NULL; + icon_count = 0; + + update_container_contents (initial_filter); + + /******************************************************************/ + /* set selected_icon_name to first name in list */ + /******************************************************************/ +#if 0 + if (icons_in_container) { + XtVaGetValues (icons_in_container[0], XmNimageName, &icon_file_name, NULL); + XmTextFieldSetString (icon_name_text_field, icon_file_name); + selected_icon_name = XtMalloc(strlen(icon_file_name) + 1); + if (selected_icon_name) + selected_icon_name = strcpy(selected_icon_name, icon_file_name); + } +#endif + + load_filter_text_field(initial_filter); + + if (ErrorDialog && XtParent(ErrorDialog) == UxWidget) { + descendant = XtNameToWidget(ErrorDialog, "OK"); + XtSetKeyboardFocus(ErrorDialog, descendant ? descendant : ErrorDialog); + } + + TurnOffHourGlassAllWindows(); +} + /***************************************************************************/ /* */ /* _Uxbuild_icon_selection_dialog */ @@ -1391,6 +1473,11 @@ static Widget _Uxbuild_icon_selection_dialog(void) (XtCallbackProc) helpCB_general, (XtPointer) HELP_ICONSELECTOR ); + XtAddCallback(icon_selection_dialog, XmNmapCallback, + mapCB_icon_selection_dialog, NULL); + + XtAddCallback(icon_selection_dialog, XmNfocusCallback, + focusCB_icon_selection_dialog, NULL); /* Creation of bottom_button_form */ bottom_button_form = XtVaCreateManagedWidget( "bottom_button_form", @@ -1857,7 +1944,6 @@ Widget create_icon_selection_dialog(swidget _UxUxParent, { - char *initial_filter; char *icon_file_name; Widget rtrn; int lcv; @@ -1914,57 +2000,5 @@ Widget create_icon_selection_dialog(swidget _UxUxParent, XtUnmanageChild (icon_name_text_field); } - TurnOnHourGlassAllWindows(); - - /******************************************************************/ - /* save file_filter */ - /******************************************************************/ - file_filter_global = (char *)calloc(strlen((char *)file_filter)+1, sizeof(char)); - -#ifdef DEBUG - if (!file_filter_global) printf("Calloc error for file_filter_global, in create_icon_selection_dialog.\n"); -#endif - - if (file_filter[0] == '*') - file_filter_global = strcpy(file_filter_global, (char *)&file_filter[1]); - else - file_filter_global = strcpy(file_filter_global, (char *)file_filter); - - load_directories_list ((char **)directories_list); - initial_filter = initialize_filter ((char *)file_filter); - - /******************************************************************/ - /* save main_filter */ - /******************************************************************/ - main_filter = (char *)calloc(strlen(initial_filter)+1, sizeof(char)); - -#ifdef DEBUG - if (!main_filter) printf("Calloc error for main_filter, in create_icon_selection_dialog.\n"); -#endif - - main_filter = strcpy(main_filter, initial_filter);; - - icons_in_container = NULL; - icon_count = 0; - - update_container_contents (initial_filter); - - /******************************************************************/ - /* set selected_icon_name to first name in list */ - /******************************************************************/ -#if 0 - if (icons_in_container) { - XtVaGetValues (icons_in_container[0], XmNimageName, &icon_file_name, NULL); - XmTextFieldSetString (icon_name_text_field, icon_file_name); - selected_icon_name = XtMalloc(strlen(icon_file_name) + 1); - if (selected_icon_name) - selected_icon_name = strcpy(selected_icon_name, icon_file_name); - } -#endif - - load_filter_text_field (initial_filter); - - TurnOffHourGlassAllWindows(); - return(rtrn); } diff --git a/cde/programs/dtdocbook/doc_utils/Makefile.am b/cde/programs/dtdocbook/doc_utils/Makefile.am index 1377074ae..9c69a9331 100644 --- a/cde/programs/dtdocbook/doc_utils/Makefile.am +++ b/cde/programs/dtdocbook/doc_utils/Makefile.am @@ -19,7 +19,7 @@ noinst_PROGRAMS = \ noinst_SCRIPTS = dtdocbook2man dtdocbook2sdl AM_CXXFLAGS = -DCDE_NEXT -I$(top_builddir)/lib/DtMmdb -AM_LDFLAGS = $(DTCLIENTLIBS) $(XTOOLLIB) +AM_LDFLAGS = $(DTCLIENTLIBS) $(XTOOLLIB) dtdcbk_datarootdir = $(abs_top_srcdir)/programs/dtdocbook @@ -28,7 +28,7 @@ AM_CPPFLAGS = \ -DINFOLIB_LIBEXECDIR=\"$(PWD)\" validator_SOURCES = validator.C -validator_LDFLAGS = $(LIBMMDB) +validator_LDFLAGS = $(LIBMMDB) $(LMDBLIB) CLEANFILES = $(noinst_SCRIPTS) $(validator_SOURCES) dtdocbook2infolib.c diff --git a/cde/programs/dtdocbook/infolib/Makefile.am b/cde/programs/dtdocbook/infolib/Makefile.am index daf7dec3a..a9634bc03 100644 --- a/cde/programs/dtdocbook/infolib/Makefile.am +++ b/cde/programs/dtdocbook/infolib/Makefile.am @@ -28,7 +28,7 @@ AM_CXXFLAGS = \ -DEXPAND_TEMPLATES \ -I$(top_builddir)/lib/DtMmdb -AM_LDFLAGS = $(XTOOLLIB) $(LIBMMDB) $(DTCLIENTLIBS) +AM_LDFLAGS = $(XTOOLLIB) $(LIBMMDB) $(DTCLIENTLIBS) $(LMDBLIB) MixedGen_SOURCES = \ MixedGen.C \ diff --git a/cde/programs/dthelp/parser/canon1/helptag/help.c b/cde/programs/dthelp/parser/canon1/helptag/help.c index 4479c1619..8e3a68628 100644 --- a/cde/programs/dthelp/parser/canon1/helptag/help.c +++ b/cde/programs/dthelp/parser/canon1/helptag/help.c @@ -29,8 +29,6 @@ #include "userinc.h" #include "globdec.h" -void m_mberr1(char *text, const char *arg); - void assert_hometopic_exists(void) { static const char hometopic[] = "-HOMETOPIC"; diff --git a/cde/programs/dthelp/parser/canon1/helptag/help.if b/cde/programs/dthelp/parser/canon1/helptag/help.if index 1e31834b0..7241d124f 100644 --- a/cde/programs/dthelp/parser/canon1/helptag/help.if +++ b/cde/programs/dthelp/parser/canon1/helptag/help.if @@ -165,8 +165,8 @@ m_free(wc_2,"wide character string"); } #else - m_piaction("UNDEFINED MACHINE", - "m-machine", + m_piaction((M_WCHAR *) "UNDEFINED MACHINE", + (M_WCHAR *) "m-machine", M_SDATA) ; #endif diff --git a/cde/programs/dthelp/parser/canon1/helptag/option.c b/cde/programs/dthelp/parser/canon1/helptag/option.c index 513c512b4..a0382d66a 100644 --- a/cde/programs/dthelp/parser/canon1/helptag/option.c +++ b/cde/programs/dthelp/parser/canon1/helptag/option.c @@ -37,8 +37,6 @@ #define TAGDOTOPT "helptag.opt" #define DOTOPT ".opt" -void m_mberr1(char *text, const char *arg); - void options(LOGICAL filelenonly) { int i; diff --git a/cde/programs/dthelp/parser/canon1/parser/proto.h b/cde/programs/dthelp/parser/canon1/parser/proto.h index e9acf1926..9f2900e2c 100644 --- a/cde/programs/dthelp/parser/canon1/parser/proto.h +++ b/cde/programs/dthelp/parser/canon1/parser/proto.h @@ -21,6 +21,8 @@ * Floor, Boston, MA 02110-1301 USA */ /* $XConsortium: proto.h /main/3 1995/11/08 09:42:21 rswiston $ */ +void chksnb(void); + int m_actgetc(void); void m_adjuststate(void); @@ -31,6 +33,8 @@ void m_attval(M_WCHAR *string); LOGICAL m_attvonly(M_WCHAR *string); +void m_mberr1(const char *text, const char *arg); + int m_checkstart(M_ELEMENT val); LOGICAL m_ckend(M_ELEMENT val, LOGICAL neednet); diff --git a/cde/programs/dthelp/parser/canon1/parser/scan.c b/cde/programs/dthelp/parser/canon1/parser/scan.c index 7c08595f8..19c988d51 100644 --- a/cde/programs/dthelp/parser/canon1/parser/scan.c +++ b/cde/programs/dthelp/parser/canon1/parser/scan.c @@ -47,8 +47,6 @@ This product and information is proprietary of Tandem Computers Incorporated. #include "entity2.h" #include "sref.h" -void m_mberr1(char *text, const char *arg); - /* Actually read a character from an input stream */ int m_actgetc(void) { diff --git a/cde/programs/dthelp/parser/pass1/helptag/help.c b/cde/programs/dthelp/parser/pass1/helptag/help.c index 48c43af5d..6af835d4c 100644 --- a/cde/programs/dthelp/parser/pass1/helptag/help.c +++ b/cde/programs/dthelp/parser/pass1/helptag/help.c @@ -30,8 +30,6 @@ #include "globdec.h" #include "proto.h" -void m_mberr1(char *text, const char *arg); - void assert_hometopic_exists(void) { static const char hometopic[] = "-HOMETOPIC"; diff --git a/cde/programs/dthelp/parser/pass1/helptag/help.if b/cde/programs/dthelp/parser/pass1/helptag/help.if index 78d7d0c77..b48523096 100644 --- a/cde/programs/dthelp/parser/pass1/helptag/help.if +++ b/cde/programs/dthelp/parser/pass1/helptag/help.if @@ -154,8 +154,8 @@ m_free(wc_2,"wide character string"); } #else - m_piaction("UNDEFINED MACHINE", - "m-machine", + m_piaction((M_WCHAR *) "UNDEFINED MACHINE", + (M_WCHAR *) "m-machine", M_SDATA) ; #endif <\CODE> diff --git a/cde/programs/dthelp/parser/pass1/helptag/option.c b/cde/programs/dthelp/parser/pass1/helptag/option.c index 87eac3397..260c29409 100644 --- a/cde/programs/dthelp/parser/pass1/helptag/option.c +++ b/cde/programs/dthelp/parser/pass1/helptag/option.c @@ -26,8 +26,6 @@ #include "userinc.h" #include "globdec.h" -void m_mberr1(char *text, const char *arg); - #if defined(_AIX) || defined(sun) /* get definition of getenv(3c) for getting of environment variables */ #include diff --git a/cde/programs/dthelp/parser/pass1/parser/proto.h b/cde/programs/dthelp/parser/pass1/parser/proto.h index 690b12479..3d6908859 100644 --- a/cde/programs/dthelp/parser/pass1/parser/proto.h +++ b/cde/programs/dthelp/parser/pass1/parser/proto.h @@ -21,6 +21,8 @@ * Floor, Boston, MA 02110-1301 USA */ /* $XConsortium: proto.h /main/3 1995/11/08 10:24:42 rswiston $ */ +void chksnb(void); + int m_actgetc(void); void m_adjuststate(void); @@ -172,6 +174,8 @@ int main(int argc, char **argv); void *m_malloc(int size, char *msg); +void m_mberr1(const char *text, const char *arg); + void m_missingtagc(int c, M_HOLDTYPE dchar, LOGICAL start); LOGICAL m_nextand(M_OPENFSA *thisfsa, M_ELEMENT label); diff --git a/cde/programs/dthelp/parser/pass1/parser/scan.c b/cde/programs/dthelp/parser/pass1/parser/scan.c index 5cb04e6b4..bc20a3b73 100644 --- a/cde/programs/dthelp/parser/pass1/parser/scan.c +++ b/cde/programs/dthelp/parser/pass1/parser/scan.c @@ -47,8 +47,6 @@ This product and information is proprietary of Tandem Computers Incorporated. #include "entity2.h" #include "sref.h" -void m_mberr1(char *text, const char *arg); - /* Actually read a character from an input stream */ int m_actgetc(void) { diff --git a/cde/programs/dthelp/parser/pass2/htag2/fproto.h b/cde/programs/dthelp/parser/pass2/htag2/fproto.h index 8633db31b..63994de82 100644 --- a/cde/programs/dthelp/parser/pass2/htag2/fproto.h +++ b/cde/programs/dthelp/parser/pass2/htag2/fproto.h @@ -54,7 +54,7 @@ void OpenTag(LOGICAL hasAttributes, void CloseTag(LOGICAL newlineOK); -void ImpliedlAttribute(char *name, +void ImpliedAttribute(char *name, M_WCHAR *value); void RequiredAttribute(char *name, diff --git a/cde/programs/dthelp/parser/pass2/htag2/option.c b/cde/programs/dthelp/parser/pass2/htag2/option.c index b6e33f45c..b47be68bc 100644 --- a/cde/programs/dthelp/parser/pass2/htag2/option.c +++ b/cde/programs/dthelp/parser/pass2/htag2/option.c @@ -31,9 +31,6 @@ #include #endif -void m_mberr1(char *text, const char *arg); - - /* Interpret options from command line and specified files */ #define OPTLEN 512 /* If OPTLEN changes, change fscanf call below */ #define TAGDOTOPT "helptag.opt" diff --git a/cde/programs/dthelp/parser/pass2/parser/parser.c b/cde/programs/dthelp/parser/pass2/parser/parser.c index 65277caa8..dce00f751 100644 --- a/cde/programs/dthelp/parser/pass2/parser/parser.c +++ b/cde/programs/dthelp/parser/pass2/parser/parser.c @@ -72,8 +72,8 @@ void main(int argc, char **argv) if (! m_curcon) { if (m_token != M_ENDFILE) { m_error("Parsing table error") ; - sprintf(buffer, parserr, m_token, m_prevcon, m_scanval) ; - m_errline(buffer) ; + sprintf((char *) buffer, parserr, m_token, m_prevcon, m_scanval) ; + m_errline((char *) buffer) ; } else { m_error("Unexpected end of document") ; @@ -92,17 +92,17 @@ void main(int argc, char **argv) m_aftereod = TRUE ; } if (m_scantrace) { - sprintf(buffer, sopt, + sprintf((char *) buffer, sopt, m_prevcon, m_token, m_curcon, m_scanval ? m_scanval : ' ', m_scanval, m_line[m_sysecnt], m_netlevel) ; - m_trace(buffer) ; + m_trace((char *) buffer) ; if (m_token == M_NAME) { - sprintf(buffer, name, m_name) ; - m_trace(buffer) ; + sprintf((char *) buffer, name, m_name) ; + m_trace((char *) buffer) ; } if (m_token == M_LITERAL) { - sprintf(buffer, literal, m_literal) ; - m_trace(buffer) ; + sprintf((char *) buffer, literal, m_literal) ; + m_trace((char *) buffer) ; } } #include "case.c" diff --git a/cde/programs/dthelp/parser/pass2/parser/proto.h b/cde/programs/dthelp/parser/pass2/parser/proto.h index 2e0f0371b..3755b762b 100644 --- a/cde/programs/dthelp/parser/pass2/parser/proto.h +++ b/cde/programs/dthelp/parser/pass2/parser/proto.h @@ -172,6 +172,8 @@ void main(int argc, char **argv); void *m_malloc(int size, char *msg); +void m_mberr1(const char *text, const char *arg); + void m_missingtagc(int c, M_HOLDTYPE dchar, LOGICAL start); LOGICAL m_nextand(M_OPENFSA *thisfsa, M_ELEMENT label); diff --git a/cde/programs/dthelp/parser/pass2/parser/scan.c b/cde/programs/dthelp/parser/pass2/parser/scan.c index add43bde2..3bc16ced8 100644 --- a/cde/programs/dthelp/parser/pass2/parser/scan.c +++ b/cde/programs/dthelp/parser/pass2/parser/scan.c @@ -47,8 +47,6 @@ This product and information is proprietary of Tandem Computers Incorporated. #include "entity2.h" #include "sref.h" -void m_mberr1(char *text, const char *arg); - /* Actually read a character from an input stream */ int m_actgetc(void) { diff --git a/cde/programs/dtinfo/dtinfo/src/Makefile.am b/cde/programs/dtinfo/dtinfo/src/Makefile.am index 8b18891e2..62fbfb9fc 100644 --- a/cde/programs/dtinfo/dtinfo/src/Makefile.am +++ b/cde/programs/dtinfo/dtinfo/src/Makefile.am @@ -67,6 +67,6 @@ bin_PROGRAMS = dtinfo dtinfo_CXXFLAGS = $(DTINFO_DEFINES) $(DTINFO_INCLUDES) dtinfo_LDADD = $(OLIASNORMALLIBS) $(LIBSEARCH) $(MMDB_LIBS) $(WWL_LIBS) \ - $(DTCLIENTLIBS) $(XTOOLLIB) + $(DTCLIENTLIBS) $(XTOOLLIB) $(LMDBLIB) dtinfo_SOURCES = main.C Support/InputNotifier.C diff --git a/cde/programs/dtksh/dtkcmds.c b/cde/programs/dtksh/dtkcmds.c index 48d547fa7..dd7b55c85 100644 --- a/cde/programs/dtksh/dtkcmds.c +++ b/cde/programs/dtksh/dtkcmds.c @@ -33,6 +33,8 @@ #include "name.h" #include "shell.h" +#undef access +#include #include #include #include diff --git a/cde/programs/dtksh/dtkcvt.c b/cde/programs/dtksh/dtkcvt.c index 81064051e..9479ab3f4 100644 --- a/cde/programs/dtksh/dtkcvt.c +++ b/cde/programs/dtksh/dtkcvt.c @@ -33,6 +33,8 @@ /* X includes */ #include "shell.h" +#undef access +#include #include #include #include diff --git a/cde/programs/dtksh/ksh93/src/lib/libast/aso/aso.c b/cde/programs/dtksh/ksh93/src/lib/libast/aso/aso.c index bc08508e7..27986e172 100644 --- a/cde/programs/dtksh/ksh93/src/lib/libast/aso/aso.c +++ b/cde/programs/dtksh/ksh93/src/lib/libast/aso/aso.c @@ -835,7 +835,7 @@ asocasptr(void volatile* p, void* o, void* n) #if defined(_aso_casptr) if (!state.lockf) - return _aso_cas64((void**)p, o, n); + return _aso_casptr((void**)p, o, n); #endif k = lock(state.data, 0, p); if (*(void* volatile*)p == o) diff --git a/cde/programs/dtksh/ksh93/src/lib/libast/features/aso b/cde/programs/dtksh/ksh93/src/lib/libast/features/aso index 9b0ed523e..b95cd5fc5 100644 --- a/cde/programs/dtksh/ksh93/src/lib/libast/features/aso +++ b/cde/programs/dtksh/ksh93/src/lib/libast/features/aso @@ -24,9 +24,9 @@ if aso note{ gcc 4.1+ 64 bit memory atomic operations model }end link{ #define _aso_inc64(p) __sync_fetch_and_add(p,1) #define _aso_dec64(p) __sync_fetch_and_sub(p,1) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,o,n)) #endif } elif aso note{ gcc 4.1+ 32 bit memory atomic operations model }end link{ @@ -48,7 +48,7 @@ elif aso note{ gcc 4.1+ 32 bit memory atomic operations model }end link{ #define _aso_cas32(p,o,n) __sync_val_compare_and_swap(p,o,n) #define _aso_inc32(p) __sync_fetch_and_add(p,1) #define _aso_dec32(p) __sync_fetch_and_sub(p,1) - #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,o,n)) } elif aso note{ atomic_cas_64 }end link{ #include "FEATURE/common" @@ -74,9 +74,9 @@ elif aso note{ atomic_cas_64 }end link{ #define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) #define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,o,n)) #endif } elif aso note{ atomic_cas_32 }end link{ @@ -98,7 +98,7 @@ elif aso note{ atomic_cas_32 }end link{ #define _aso_cas32(p,o,n) atomic_cas_32(p,o,n) #define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) #define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) - #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,o,n)) } elif aso -latomic note{ atomic_cas_64 with -latomic }end link{ #include "FEATURE/common" @@ -125,9 +125,9 @@ elif aso -latomic note{ atomic_cas_64 with -latomic }end link{ #define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) #define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,o,n)) #endif } elif aso note{ atomic_cas_32 with -latomic }end link{ @@ -150,7 +150,7 @@ elif aso note{ atomic_cas_32 with -latomic }end link{ #define _aso_cas32(p,o,n) atomic_cas_32(p,o,n) #define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) #define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) - #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,o,n)) } elif aso note{ cas64 }end link{ #include "FEATURE/common" @@ -176,9 +176,9 @@ elif aso note{ cas64 }end link{ #define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) #define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) #endif } elif aso note{ just cas64 }end link{ @@ -199,9 +199,9 @@ elif aso note{ just cas64 }end link{ #define _aso_cas32(p,o,n) cas32(p,o,n) #define _aso_cas64(p,o,n) cas64(p,o,n) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) #endif } elif aso note{ cas32 }end link{ @@ -223,7 +223,7 @@ elif aso note{ cas32 }end link{ #define _aso_cas32(p,o,n) cas32(p,o,n) #define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) #define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) } elif aso note{ just cas32 }end link{ #include "FEATURE/common" @@ -240,7 +240,7 @@ elif aso note{ just cas32 }end link{ #define _aso_cas8(p,o,n) cas8(p,o,n) #define _aso_cas16(p,o,n) cas16(p,o,n) #define _aso_cas32(p,o,n) cas32(p,o,n) - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) } elif aso note{ winix Interlocked }end link{ #include @@ -261,7 +261,7 @@ elif aso note{ winix Interlocked }end link{ #define _aso_cas64(p,o,n) InterlockedCompareExchange64((LONGLONG volatile*)p,n,o) #define _aso_inc64(p) (InterlockedIncrement64((LONGLONG volatile*)p)-1) #define _aso_dec64(p) (InterlockedDecrement64((LONGLONG volatile*)p)+1) - #define _aso_casptr(p,o,n) ((void*)InterlockedCompareExchange64((LONGLONG volatile*)p,(LONGLONG)n,(LONGLONG)o)) + #define _aso_casptr(p,o,n) ((void*)InterlockedCompareExchange64((LONGLONG volatile*)p,n,o)) #else #if _BLD_posix #include "dl.h" @@ -345,7 +345,7 @@ elif aso note{ winix Interlocked }end link{ return _aso_InterlockedDecrement64(p); } #endif - #define _aso_casptr(p,o,n) ((void*)InterlockedCompareExchange((LONG volatile*)p,(LONG)n,(LONG)o)) + #define _aso_casptr(p,o,n) ((void*)InterlockedCompareExchange((LONG volatile*)p,n,o)) #endif } elif aso note{ AIX fetch and add }end link{ @@ -361,9 +361,9 @@ elif aso note{ AIX fetch and add }end link{ #define _aso_decint(p) fetch_and_add((atomic_p)p,-1) #define _aso_casint(p,o,n) (compare_and_swap((atomic_p)p,(int*)&o,(int)n) ? o : *p) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) (compare_and_swaplp((atomic_l)p,(long*)&o,(long)n) ? o : *(void**)p) + #define _aso_casptr(p,o,n) (compare_and_swaplp((atomic_l)p,(long*)&o,n) ? o : *(void**)p) #else - #define _aso_casptr(p,o,n) (compare_and_swap((atomic_p)p,(int*)&o,(int)n) ? o : *(void**)p) + #define _aso_casptr(p,o,n) (compare_and_swap((atomic_p)p,(int*)&o,n) ? o : *(void**)p) #endif } elif aso note{ MIPS compare and swap }end link{ @@ -374,7 +374,7 @@ elif aso note{ MIPS compare and swap }end link{ } }end && { #define _aso_cas32(p,o,n) (__compare_and_swap(p,o,n) ? o : *p) - #define _aso_casptr(p,o,n) (__compare_and_swap((long*)p,(long)o,(long)n) ? o : *(void**)p) + #define _aso_casptr(p,o,n) (__compare_and_swap((long*)p,o,n) ? o : *(void**)p) } elif aso note{ i386|i386-64 asm compare and swap }end link{ #include "FEATURE/common" @@ -457,9 +457,9 @@ elif aso note{ i386|i386-64 asm compare and swap }end link{ #define _aso_cas32(p,o,n) cas32(p,o,n) #if _ast_sizeof_pointer == 8 #define _aso_cas64(p,o,n) cas64(p,o,n) - #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) #endif } elif aso note{ ia64 asm compare and swap }end link{ @@ -527,9 +527,9 @@ elif aso note{ ia64 asm compare and swap }end link{ #define _aso_cas32(p,o,n) cas32(p,o,n) #define _aso_cas64(p,o,n) cas64(p,o,n) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) #endif } elif aso note{ ppc asm compare and swap }end link{ @@ -625,9 +625,9 @@ elif aso note{ ppc asm compare and swap }end link{ #define _aso_cas32(p,o,n) cas32(p,o,n) #define _aso_cas64(p,o,n) cas64(p,o,n) #if _ast_sizeof_pointer == 8 - #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas64((uint64_t*)p,o,n)) #else - #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + #define _aso_casptr(p,o,n) ((void*)cas32((uint32_t*)p,o,n)) #endif } endif diff --git a/cde/programs/dtksh/widget.c b/cde/programs/dtksh/widget.c index 364c96e97..12d025b52 100644 --- a/cde/programs/dtksh/widget.c +++ b/cde/programs/dtksh/widget.c @@ -32,6 +32,8 @@ #include "name.h" #include "shell.h" +#undef access +#include #include #include #include diff --git a/cde/programs/dtksh/xmcmds.c b/cde/programs/dtksh/xmcmds.c index f3d0e7712..20be6f70f 100644 --- a/cde/programs/dtksh/xmcmds.c +++ b/cde/programs/dtksh/xmcmds.c @@ -30,6 +30,8 @@ /* actual or intended publication of such source code. */ #include "shell.h" +#undef access +#include #include #include #include diff --git a/cde/programs/dtksh/xmcvt.c b/cde/programs/dtksh/xmcvt.c index f178b6a0b..01a7b1cce 100644 --- a/cde/programs/dtksh/xmcvt.c +++ b/cde/programs/dtksh/xmcvt.c @@ -32,6 +32,8 @@ #include "shell.h" +#undef access +#include #include #include #include diff --git a/cde/programs/dtksh/xmwidgets.c b/cde/programs/dtksh/xmwidgets.c index de08d8fb3..a02cc3053 100644 --- a/cde/programs/dtksh/xmwidgets.c +++ b/cde/programs/dtksh/xmwidgets.c @@ -32,6 +32,8 @@ #include "name.h" #include "shell.h" +#undef access +#include #include #include #include diff --git a/cde/programs/dtlogin/access.c b/cde/programs/dtlogin/access.c index 03676974a..f1dc26d77 100644 --- a/cde/programs/dtlogin/access.c +++ b/cde/programs/dtlogin/access.c @@ -147,7 +147,7 @@ static int scanHostlist( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure, int depth, int broadcast) ; @@ -162,7 +162,7 @@ static int indirectAlias( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure, int depth, int broadcast) ; @@ -625,7 +625,7 @@ scanHostlist( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure, int depth, int broadcast ) @@ -675,7 +675,7 @@ indirectAlias( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure, int depth, int broadcast ) @@ -709,7 +709,7 @@ ForEachMatchingIndirectHost( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(CARD16, struct _ARRAY8 *, char *), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure ) { int haveLocalhost = 0; @@ -828,7 +828,7 @@ ForEachChooserHost( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure ) { int haveLocalhost = 0; diff --git a/cde/programs/dtlogin/auth.c b/cde/programs/dtlogin/auth.c index ebbe51598..333be04ff 100644 --- a/cde/programs/dtlogin/auth.c +++ b/cde/programs/dtlogin/auth.c @@ -152,7 +152,7 @@ struct AuthProtocol { unsigned short name_length; char *name; - int (*InitAuth)( + void (*InitAuth)( #if NeedWidePrototypes unsigned int name_len, #else @@ -168,7 +168,10 @@ struct AuthProtocol { #endif /* NeedWidePrototypes */ char *name) ; - void (*GetXdmcpAuth)(); + void (*GetXdmcpAuth)( + struct protoDisplay *pdpy, + unsigned short authorizationNameLen, + char *authorizationName); int inited; }; diff --git a/cde/programs/dtlogin/choose.c b/cde/programs/dtlogin/choose.c index 57ac9219e..8d1299e4f 100644 --- a/cde/programs/dtlogin/choose.c +++ b/cde/programs/dtlogin/choose.c @@ -428,7 +428,7 @@ RunChooser ( args = parseArgs (args, buf); ForEachChooserHost (&d->clientAddr, d->connectionType, - (int (*)()) AddChooserHost, + AddChooserHost, (char *) &args); env = systemEnv (d, (char *) 0, (char *) 0); if (d->authFile) diff --git a/cde/programs/dtlogin/dm.h b/cde/programs/dtlogin/dm.h index 57cc1b5a5..345c56cb1 100644 --- a/cde/programs/dtlogin/dm.h +++ b/cde/programs/dtlogin/dm.h @@ -314,7 +314,7 @@ struct display { /* XDMCP state */ CARD32 sessionID; /* ID of active session */ - struct sockaddr *peer; /* sockaddr of display peer */ + XdmcpNetaddr peer; /* sockaddr of display peer */ int peerlen; /* length of peer name */ struct sockaddr *from; /* XDMCP port of display */ int fromlen; @@ -519,7 +519,7 @@ extern void ForEachChooserHost( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure) ; extern int ForEachMatchingIndirectHost( ARRAY8Ptr clientAddress, @@ -528,7 +528,7 @@ extern int ForEachMatchingIndirectHost( #else CARD16 connectionType, #endif /* NeedWidePrototypes */ - int (*function)(CARD16, struct _ARRAY8 *, char *), + void (*function)(CARD16, struct _ARRAY8 *, char *), char *closure) ; extern int ScanAccessDatabase( void ) ; extern int UseChooser( @@ -703,7 +703,7 @@ extern Xauth * MitGetAuth( #endif /* NeedWidePrototypes */ char *name) ; -extern int MitInitAuth( +extern void MitInitAuth( #if NeedWidePrototypes unsigned int name_len, #else diff --git a/cde/programs/dtlogin/mitauth.c b/cde/programs/dtlogin/mitauth.c index 264d9ea31..6acb31dc0 100644 --- a/cde/programs/dtlogin/mitauth.c +++ b/cde/programs/dtlogin/mitauth.c @@ -95,16 +95,15 @@ static int auth_name_len; void GenerateAuthData (char *auth, int len); // genauth.c #if NeedWidePrototypes -int MitInitAuth (unsigned int name_len, char *name) +void MitInitAuth (unsigned int name_len, char *name) #else -int MitInitAuth (unsigned short name_len, char *name) +void MitInitAuth (unsigned short name_len, char *name) #endif /* NeedWidePrototypes */ { if (name_len > 256) name_len = 256; auth_name_len = name_len; memmove( auth_name, name, name_len); - return(0); } #if NeedWidePrototypes diff --git a/cde/programs/dtlogin/server.c b/cde/programs/dtlogin/server.c index f88deec90..1853f070b 100644 --- a/cde/programs/dtlogin/server.c +++ b/cde/programs/dtlogin/server.c @@ -333,7 +333,7 @@ GetRemoteAddress( struct display *d, int fd ) d->peerlen = 0; if (len) { - d->peer = (struct sockaddr *) malloc (len); + d->peer = malloc (len); if (d->peer) { bcopy (buf, (char *) d->peer, len); diff --git a/cde/programs/dtlogin/xdmauth.c b/cde/programs/dtlogin/xdmauth.c index d809dc944..c3d7bb5df 100644 --- a/cde/programs/dtlogin/xdmauth.c +++ b/cde/programs/dtlogin/xdmauth.c @@ -239,7 +239,8 @@ void XdmGetXdmcpAuth (struct protoDisplay *pdpy, unsigned short authorizationNam XdmPrintDataHex ("Accept packet auth", xdmcpauth->data, xdmcpauth->data_length); XdmPrintDataHex ("Auth file auth", fileauth->data, fileauth->data_length); /* encrypt the session key for its trip back to the server */ - XdmcpWrap (xdmcpauth->data, &pdpy->key, xdmcpauth->data, 8); + XdmcpWrap ((unsigned char *)xdmcpauth->data, (unsigned char *)&pdpy->key, + (unsigned char *)xdmcpauth->data, 8); pdpy->fileAuthorization = fileauth; pdpy->xdmcpAuthorization = xdmcpauth; } @@ -326,14 +327,14 @@ int XdmCheckAuthentication (struct protoDisplay *pdpy, ARRAY8Ptr displayID, return FALSE; if (authenticationData->length != 8) return FALSE; - XdmcpUnwrap (authenticationData->data, &pdpy->key, + XdmcpUnwrap (authenticationData->data, (unsigned char *)&pdpy->key, authenticationData->data, 8); XdmPrintArray8Hex ("Request packet auth", authenticationData); if (!XdmcpCopyARRAY8(authenticationData, &pdpy->authenticationData)) return FALSE; incoming = (XdmAuthKeyPtr) authenticationData->data; XdmcpIncrementKey (incoming); - XdmcpWrap (authenticationData->data, &pdpy->key, + XdmcpWrap (authenticationData->data, (unsigned char *)&pdpy->key, authenticationData->data, 8); return TRUE; } diff --git a/cde/programs/dtlogin/xdmcp.c b/cde/programs/dtlogin/xdmcp.c index 84b489df9..bc055155a 100644 --- a/cde/programs/dtlogin/xdmcp.c +++ b/cde/programs/dtlogin/xdmcp.c @@ -175,7 +175,7 @@ AnyWellKnownSockets (void) static XdmcpBuffer buffer; /*ARGSUSED*/ -static int +static void sendForward (CARD16 connectionType, ARRAY8Ptr address, char *closure) { #ifdef AF_INET @@ -198,7 +198,7 @@ sendForward (CARD16 connectionType, ARRAY8Ptr address, char *closure) in_addr.sin_family = AF_INET; in_addr.sin_port = htons ((short) XDM_UDP_PORT); if (address->length != 4) - return 0; + return; memmove( (char *) &in_addr.sin_addr, address->data, address->length); addrlen = sizeof (struct sockaddr_in); break; @@ -207,10 +207,10 @@ sendForward (CARD16 connectionType, ARRAY8Ptr address, char *closure) case FamilyDECnet: #endif default: - return 0; + return; } XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr)addr, addrlen); - return 0; + return; } extern char *NetaddrAddress(); diff --git a/cde/programs/ttsnoop/Makefile.am b/cde/programs/ttsnoop/Makefile.am index 7448c2223..3783388de 100644 --- a/cde/programs/ttsnoop/Makefile.am +++ b/cde/programs/ttsnoop/Makefile.am @@ -167,7 +167,7 @@ ttsnoop.C ttsnoop.h dtb_utils.c dtb_utils.h: ttsnoop.bip ttsnoop.C.src $(SED) \ -e 's/\(MoreButton;\)/\1Boolean _DtCanHelp( const char * );/' \ -e 's/\(XtManageChild(Quick_help\)/XtSetSensitive(MoreButton,_DtCanHelp(help_data->help_text));\1/' \ - -e 's/\(buffer, vol, loc;\)/\1Boolean _DtHelped( Widget );/' \ + -e 's/\(buffer, vol = NULL, loc = NULL;\)/\1Boolean _DtHelped( Widget );/' \ -e 's/\(if( (cp=strrchr\)/if (_DtHelped( help_dialog)) return;\1/' \ dtb_utils.c > dtb_utils.c.patched mv dtb_utils.c.patched dtb_utils.c