home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-03-13 | 32.6 KB | 1,218 lines |
- From decwrl!athertn!sander.cupertino.ca.us!paul@cs.purdue.edu Wed Jan 6 13:53:09 EST 1993
- Submit chipset-2 02/10
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 10)."
- # Contents: rules.mk src/btree/Makefile src/btree/bt_last.c
- # src/btree/btdata.c src/btree/btfirst.c src/btree/btree.h
- # src/list/Makefile src/list/dldata.c src/list/dldump.c
- # src/list/dlpopf.c src/list/dlprev.c src/list/dlpriv.h
- # src/list/dlrank.c src/list/dlsetup.c src/list/dlutil.c
- # Wrapped by paul@sander on Sun Nov 22 15:41:47 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f rules.mk -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"rules.mk\"
- else
- echo shar: Extracting \"rules.mk\" \(1465 characters\)
- sed "s/^X//" >rules.mk <<'END_OF_rules.mk'
- X# rules.mk -- This file contains rules that are used by all of the components
- X# comprising the Software ChipSet component library.
- X
- X# This file is part of a suite of programs called Software Chipset.
- X# The source code for Software Chipset has been released into the
- X# public domain by its author, Paul Sander.
- X
- X# Default rule, just in case
- X
- Xall:
- X
- X# Install the libraries in $(LIBDIR), which is passed on the command line
- X# or set in common.mk
- X
- XinstallLib:
- X for x in $?; \
- X do \
- X cp $$x $(LIBDIR); \
- X if [ -x "$(RANLIB)" ]; then $(RANLIB) $(LIBDIR)/$$x; fi;\
- X chmod 644 $(LIBDIR)/$$x; \
- X done
- X
- X# Install the include files in $(INCDIR), which is passed on the command line
- X# or set in common.mk
- X
- XinstallInclude:
- X for x in $?; \
- X do \
- X cp $$x $(INCDIR); \
- X chmod 644 $(INCDIR)/$$x; \
- X done
- X
- X# Install the documentation
- X
- XinstallDocs:
- X for x in $?; \
- X do \
- X dest=`expr $$x : '\(.*\)\.[^.]*'`.$(MANSUFF)$(INSTALLSUFF); \
- X < $$x $(INSTALLMAN) > $(MANDIR)/$$dest; \
- X chmod 644 $(MANDIR)/$$dest; \
- X done
- X
- X# Make all products locally
- X
- Xeverything: all docs
- X
- X# Install everything
- X
- Xinstall: installInclude installLib installDocs
- X
- X# Clean-up
- X
- Xclean:
- X rm -f *.o test core
- X
- Xspotless clobber realclean veryclean: clean
- X rm -f *.doc *.ps *$(ZSUFF) *.$(MANSUFF) *.a
- X
- X# Create the MANIFEST file
- X
- XMANIFEST: clobber
- X find . -type f -print | sed -e 's/^\.\///' -e /CVS/d | sort > MANIFEST
- X
- X### End of File ###
- END_OF_rules.mk
- if test 1465 -ne `wc -c <rules.mk`; then
- echo shar: \"rules.mk\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/btree/Makefile -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/btree/Makefile\"
- else
- echo shar: Extracting \"src/btree/Makefile\" \(1610 characters\)
- sed "s/^X//" >src/btree/Makefile <<'END_OF_src/btree/Makefile'
- X# Makefile -- This file contains instructions to build the in-memory B-tree
- X# implementation and its related files. Edit this as needed
- X# for your system. This makefile works properly with brain-dead
- X# SVR2 make, so it should work with your tool, too.
- X
- X# This file is part of a suite of programs called Software Chipset.
- X# The source code for Software Chipset has been released into the
- X# public domain by its author, Paul Sander.
- X
- X# Pick up the standard macros and rules.
- X
- Xinclude ../../common.mk
- Xinclude ../../rules.mk
- X
- X# Miscellaneous
- XTARGET = libbtree.a
- X
- X# These are the object files that implement the B-tree.
- XOBJECTS = btmalloc.o btutil.o bt_last.o bt_next.o bt_prev.o \
- X btdelete.o btdestroy.o btdump.o btfirst.o btinsert.o btnew.o \
- X btsearch.o bttraverse.o btrank.o btdelutl.o btdelrank.o btdata.o
- X
- X# Default target, library and test program
- Xall: $(TARGET) test
- X
- X# Documentation
- Xdocs: btree.ps btree.doc
- X
- X# Install just the header file
- XinstallInclude: btree.h
- X
- X# Install the library
- XinstallLib: $(TARGET)
- X
- X# Install the documentation.
- XinstallDocs: btree.man
- X
- X# This produces the library. Should work for both System V and BSD
- X$(TARGET): $(OBJECTS)
- X ar r $@ `lorder $? | tsort`
- X if [ -x "$(RANLIB)" ]; then $(RANLIB) $@; fi
- X
- X# This produces the object code.
- X$(OBJECTS): btpriv.h
- X
- X# This produces the test program.
- Xtest: test.o $(TARGET)
- X $(CC) $(CFLAGS) $(LFLAGS) -o test test.o $(TARGET) $(TESTLIBS)
- X
- X# This produces the ASCII plaintext documentation.
- Xbtree.doc: btree.man
- X
- X# This produces the PostScript documentation.
- Xbtree.ps: btree.man
- X
- X### End of file ###
- X
- END_OF_src/btree/Makefile
- if test 1610 -ne `wc -c <src/btree/Makefile`; then
- echo shar: \"src/btree/Makefile\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/btree/bt_last.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/btree/bt_last.c\"
- else
- echo shar: Extracting \"src/btree/bt_last.c\" \(1631 characters\)
- sed "s/^X//" >src/btree/bt_last.c <<'END_OF_src/btree/bt_last.c'
- X/********************************************************************
- X *
- X * bt_last.c -- This file contains functions needed to find the
- X * key that is highest in the lexical order of keys
- X * stored in an in-memory B-tree.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ********************************************************************/
- X
- X
- X#include <stdio.h>
- X#include "btpriv.h"
- X
- X/********************************************************************
- X *
- X * bt_last -- This function returns the key that appears last in
- X * the lexical order of the items stored in the tree.
- X * NULL is returned if the tree is empty.
- X *
- X *******************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *bt_last(void *ptree, void **data)
- X#else
- Xvoid *bt_last(ptree,data)
- Xvoid *ptree;
- Xvoid **data;
- X#endif
- X{
- X BTREE tree;
- X BTNODE *node;
- X
- X tree = (BTREE) ptree;
- X if (tree == NULL)
- X {
- X COVER("bt_last.c",1);
- X return NULL;
- X }
- X node = tree->root;
- X if (node->nkeys == 0)
- X {
- X COVER("bt_last.c",2);
- X return NULL;
- X }
- X COVER("bt_last.c",3);
- X while (node->children != NULL)
- X {
- X COVER("bt_last.c",4);
- X node->currKey = node->nkeys;
- X node = node->children[node->nkeys];
- X }
- X COVER("bt_last.c",5);
- X node->currKey = node->nkeys - 1;
- X tree->currNode = node;
- X tree->nextOk = 1;
- X if (data != NULL)
- X {
- X COVER("bt_last.c",6);
- X *data = node->data[node->nkeys - 1];
- X }
- X return node->keys[node->nkeys - 1];
- X}
- X
- X/************ End of file *************/
- X
- END_OF_src/btree/bt_last.c
- if test 1631 -ne `wc -c <src/btree/bt_last.c`; then
- echo shar: \"src/btree/bt_last.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/btree/btdata.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/btree/btdata.c\"
- else
- echo shar: Extracting \"src/btree/btdata.c\" \(1684 characters\)
- sed "s/^X//" >src/btree/btdata.c <<'END_OF_src/btree/btdata.c'
- X/***********************************************************************
- X *
- X * btdata.c -- This file contains functions to access and modify a
- X * a user-defined data structure that can be stored with
- X * a B-tree.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ***********************************************************************/
- X
- X#include <stdio.h>
- X#include "btpriv.h"
- X
- X/***********************************************************************
- X *
- X * bt_data -- Given a B-tree, returns a pointer to a user-defined
- X * structure. This pointer can be set by bt_new(), or
- X * with bt_setData().
- X *
- X ***********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *bt_data(void *ptree)
- X#else
- Xvoid *bt_data(ptree)
- Xvoid *ptree;
- X#endif
- X{
- X BTREE tree;
- X
- X if (ptree == NULL)
- X {
- X COVER("btdata.c",1);
- X return NULL;
- X }
- X COVER("btdata.c",2);
- X tree = (BTREE) ptree;
- X return tree->data;
- X}
- X
- X/***********************************************************************
- X *
- X * bt_setData -- This function modifies a pointer to a user-defined
- X * structure that is kept with the tree.
- X *
- X ***********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid bt_setData(void *ptree, void *data)
- X#else
- Xvoid bt_setData(ptree,data)
- Xvoid *ptree;
- Xvoid *data;
- X#endif
- X{
- X BTREE tree;
- X
- X if (ptree != NULL)
- X {
- X COVER("btdata.c",3);
- X tree = (BTREE) ptree;
- X tree->data = data;
- X }
- X COVER("btdata.c",4);
- X return;
- X}
- X
- X/************ End of file *************/
- X
- END_OF_src/btree/btdata.c
- if test 1684 -ne `wc -c <src/btree/btdata.c`; then
- echo shar: \"src/btree/btdata.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/btree/btfirst.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/btree/btfirst.c\"
- else
- echo shar: Extracting \"src/btree/btfirst.c\" \(1544 characters\)
- sed "s/^X//" >src/btree/btfirst.c <<'END_OF_src/btree/btfirst.c'
- X/********************************************************************
- X *
- X * btfirst.c -- This file contains functions to locate the key
- X * falling first in the lexical order of items stored
- X * in an in-memory B-tree.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ********************************************************************/
- X
- X#include <stdio.h>
- X#include "btpriv.h"
- X
- X/********************************************************************
- X *
- X * bt_first -- This function returns the key that appears first in
- X * the lexical order of the items stored in the tree.
- X * NULL is returned if the tree is empty.
- X *
- X *******************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *bt_first(void *ptree, void **data)
- X#else
- Xvoid *bt_first(ptree,data)
- Xvoid *ptree;
- Xvoid **data;
- X#endif
- X{
- X BTNODE *node;
- X BTREE tree;
- X
- X tree = (BTREE) ptree;
- X if (tree == NULL)
- X {
- X COVER("btfirst.c",1);
- X return NULL;
- X }
- X node = tree->root;
- X if (node->nkeys == 0)
- X {
- X COVER("btfirst.c",2);
- X return NULL;
- X }
- X while (node->children != NULL)
- X {
- X COVER("btfirst.c",3);
- X node->currKey = 0;
- X node = node->children[0];
- X }
- X COVER("btfirst.c",4);
- X node->currKey = 0;
- X tree->currNode = node;
- X tree->nextOk = 1;
- X if (data != NULL)
- X {
- X COVER("btfirst.c",5);
- X *data = node->data[0];
- X }
- X return node->keys[0];
- X}
- X
- X/*********** End of file ************/
- X
- END_OF_src/btree/btfirst.c
- if test 1544 -ne `wc -c <src/btree/btfirst.c`; then
- echo shar: \"src/btree/btfirst.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/btree/btree.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/btree/btree.h\"
- else
- echo shar: Extracting \"src/btree/btree.h\" \(1874 characters\)
- sed "s/^X//" >src/btree/btree.h <<'END_OF_src/btree/btree.h'
- X/*********************************************************************
- X *
- X * btree.h -- This file contains public declarations and definitions
- X * used by the in-memory B-tree implementation.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X *********************************************************************/
- X
- X/* Header file for in-memory B-tree implementation */
- X
- Xtypedef void *BTREE;
- Xtypedef void *BT_SETUP;
- X
- X#ifdef __STDC__
- Xextern void bt_dump(BTREE, void (*)(void*,void*,void*), void*);
- Xextern void *bt_search(BTREE, void*, void**);
- Xextern BTREE bt_new(BT_SETUP);
- Xextern void bt_destroy(BTREE, void(*)(void*,void*),
- X void(*)(void*,void*), void*);
- Xextern int bt_insert(BTREE, void*, void*);
- Xextern void bt_traverse(BTREE, void (*)(void*,void*,void*),void*);
- Xextern void *bt_delete(BTREE, void*, void**);
- Xextern void *bt_first(BTREE, void**);
- Xextern void *bt_next(BTREE, void**);
- Xextern void *bt_last(BTREE, void**);
- Xextern void *bt_prev(BTREE, void**);
- Xextern BT_SETUP bt_setup(int, int(*)(void*,void*), void*);
- Xextern void bt_freeSetup(BT_SETUP);
- Xextern void *bt_rank(BTREE, int, void*);
- Xextern void *bt_delRank(BTREE, int, void**);
- Xextern void *bt_data(BTREE);
- Xextern void bt_setData(BTREE, void*);
- X#else
- Xextern void bt_dump();
- Xextern void *bt_search();
- Xextern BTREE bt_new();
- Xextern void bt_destroy();
- Xextern int bt_insert();
- Xextern void bt_traverse();
- Xextern void *bt_delete();
- Xextern void *bt_first();
- Xextern void *bt_next();
- Xextern void *bt_last();
- Xextern void *bt_prev();
- Xextern BT_SETUP bt_setup();
- Xextern void bt_freeSetup();
- Xextern void *bt_rank();
- Xextern void *bt_delRank();
- Xextern void *bt_data();
- Xextern void bt_setData();
- X#endif
- X
- X/****** end of file ******/
- X
- X
- END_OF_src/btree/btree.h
- if test 1874 -ne `wc -c <src/btree/btree.h`; then
- echo shar: \"src/btree/btree.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/Makefile -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/Makefile\"
- else
- echo shar: Extracting \"src/list/Makefile\" \(1647 characters\)
- sed "s/^X//" >src/list/Makefile <<'END_OF_src/list/Makefile'
- X# Makefile -- This file contains instructions to build the doubly-linked
- X# list implementation and its related files. Edit this as
- X# needed for your system.
- X#
- X# This file is part of a suite of programs called Software Chipset.
- X# The source code for Software Chipset has been released into the
- X# public domain by its author, Paul Sander.
- X#
- X
- X# Pick up the standard macros and rules.
- X
- Xinclude ../../common.mk
- Xinclude ../../rules.mk
- X
- X# Miscellaneous
- XTARGET = libdlist.a
- X
- X# These are the object files that implement the doubly-linked list.
- XOBJECTS = dlsetup.o dlnew.o dldestroy.o dlinsutl.o dlinsert.o dldump.o \
- X dldelutl.o dldelete.o dlutil.o dlsearch.o dltrav.o dlfirst.o dlnext.o \
- X dllast.o dlprev.o dlrankutl.o dlrank.o dldelrank.o dldata.o dlpushf.o \
- X dlpushr.o dlpush.o dlpopf.o dlpopr.o dlpop.o dlpeekf.o dlpeekr.o \
- X dlpeek.o dljoin.o
- X
- X# Default target, library and test program
- Xall: $(TARGET) test
- X
- X# Documentation
- Xdocs: dlist.ps dlist.doc
- X
- X# Install just the header file
- XinstallInclude: dlist.h
- X
- X# Install the library
- XinstallLib: $(TARGET)
- X
- X# Install the documentation
- XinstallDocs: dlist.man
- X
- X# This produces the library. ranlib is desireable on BSD-derived systems.
- X$(TARGET): $(OBJECTS)
- X ar r $@ `lorder $? | tsort`
- X if [ -x "$(RANLIB)" ]; then $(RANLIB) $@; fi
- X
- X# This produces the object code.
- X$(OBJECTS): dlpriv.h dlist.h
- X
- X# This produces the test program.
- Xtest: test.o $(TARGET)
- X $(CC) $(CFLAGS) $(LFLAGS) -o test test.o $(TARGET) $(TESTLIBS)
- X
- X# This produces the ASCII plaintext documentation.
- Xdlist.doc: dlist.man
- X
- X# This produces the PostScript documentation.
- Xdlist.ps: dlist.man
- X
- X### End of file ###
- X
- END_OF_src/list/Makefile
- if test 1647 -ne `wc -c <src/list/Makefile`; then
- echo shar: \"src/list/Makefile\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dldata.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dldata.c\"
- else
- echo shar: Extracting \"src/list/dldata.c\" \(1584 characters\)
- sed "s/^X//" >src/list/dldata.c <<'END_OF_src/list/dldata.c'
- X/***********************************************************************
- X *
- X * dldata.c -- This file contains functions used for storing and
- X * retrieving the global list object data field.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ***********************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X/***********************************************************************
- X *
- X * dll_data -- This function retrieves the list's global client-defined
- X * data pointer.
- X *
- X ***********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *dll_data(DL_LIST plist)
- X#else
- Xvoid *dll_data(plist)
- XDL_LIST plist;
- X#endif
- X{
- X LIST *list;
- X
- X list = (LIST*) plist;
- X if (list == NULL)
- X {
- X COVER("dldata.c",1);
- X return NULL;
- X }
- X COVER("dldata.c",2);
- X return list->data;
- X}
- X
- X/***********************************************************************
- X *
- X * dll_setData -- This function sets the list's global client-defined
- X * data pointer.
- X *
- X ***********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid dll_setData(DL_LIST plist, void *data)
- X#else
- Xvoid dll_setData(plist,data)
- XDL_LIST plist;
- Xvoid *data;
- X#endif
- X{
- X LIST *list;
- X
- X list = (LIST*) plist;
- X if (list != NULL)
- X {
- X COVER("dldata.c",3);
- X list->data = data;
- X }
- X COVER("dldata.c",4);
- X return;
- X}
- X
- X/****************** End of file ******************/
- X
- END_OF_src/list/dldata.c
- if test 1584 -ne `wc -c <src/list/dldata.c`; then
- echo shar: \"src/list/dldata.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dldump.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dldump.c\"
- else
- echo shar: Extracting \"src/list/dldump.c\" \(1554 characters\)
- sed "s/^X//" >src/list/dldump.c <<'END_OF_src/list/dldump.c'
- X/***********************************************************************
- X *
- X * dldump.c -- This file contains debugging code to dump the contents
- X * of a doubly-linked list.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ***********************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X#ifdef __STDC__
- Xvoid dll_dump(DL_LIST plist,void (*key_dump)(void*,void*,void*),void *info)
- X#else
- Xvoid dll_dump(plist,key_dump,info)
- XDL_LIST plist;
- Xvoid (*key_dump)();
- Xvoid *info;
- X#endif
- X{
- X LIST *list;
- X NODE *this;
- X
- X if (plist == NULL)
- X {
- X printf("ERROR: Trying to dump null list\n");
- X return;
- X }
- X
- X list = (LIST*) plist;
- X printf("List handle located at %08x\n",(int) list);
- X printf("last = %08x\n",(int) list->last);
- X printf("current = %08x\n",(int) list->current);
- X printf("data = %08x\n", (int) list->data);
- X printf("nextOk = %d\n", list->nextOk);
- X printf("size = %d\n", list->size);
- X printf("changed = %d\n", list->changed);
- X printf("-----------\n");
- X if (list->last != NULL)
- X {
- X this = list->last->next;
- X do
- X {
- X printf("Node at %08x:\n",(int) this);
- X printf(" next = %08x\n",(int) this->next);
- X printf(" prev = %08x\n",(int) this->prev);
- X if (key_dump != NULL)
- X {
- X key_dump(this->key,this->data,info);
- X }
- X printf("\n");
- X this = this->next;
- X } while (this != list->last->next);
- X }
- X return;
- X}
- X
- X/************* End of file ************/
- X
- END_OF_src/list/dldump.c
- if test 1554 -ne `wc -c <src/list/dldump.c`; then
- echo shar: \"src/list/dldump.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dlpopf.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dlpopf.c\"
- else
- echo shar: Extracting \"src/list/dlpopf.c\" \(1410 characters\)
- sed "s/^X//" >src/list/dlpopf.c <<'END_OF_src/list/dlpopf.c'
- X/***********************************************************************
- X *
- X * dlpopf.c -- This file contains the dll_popf function.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ***********************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X/***********************************************************************
- X *
- X * dll_popf -- This function deletes an item from the front of a
- X * doubly-linked list.
- X *
- X ***********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *dll_popf(DL_LIST plist, void **data)
- X#else
- Xvoid *dll_popf(plist,data)
- XDL_LIST plist;
- Xvoid **data;
- X#endif
- X{
- X LIST *list;
- X NODE *node;
- X void *retval;
- X
- X COVER("dlpopf.c",1);
- X if (plist == NULL)
- X {
- X COVER("dlpopf.c",2);
- X return NULL;
- X }
- X list = (LIST*) plist;
- X if (list->last == NULL)
- X {
- X COVER("dlpopf.c",3);
- X return NULL;
- X }
- X
- X node = list->last->next;
- X retval = node->key;
- X if (data != NULL)
- X {
- X COVER("dlpopf.c",4);
- X *data = node->data;
- X }
- X if (node == list->last)
- X {
- X COVER("dlpopf.c",5);
- X list->last = NULL;
- X }
- X else
- X {
- X COVER("dlpopf.c",6);
- X dll_unlink(node);
- X }
- X dll_freeNode(node);
- X list->size -= 1;
- X dll_touch(list);
- X return retval;
- X}
- X
- X/*************** End of file ***************/
- X
- END_OF_src/list/dlpopf.c
- if test 1410 -ne `wc -c <src/list/dlpopf.c`; then
- echo shar: \"src/list/dlpopf.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dlprev.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dlprev.c\"
- else
- echo shar: Extracting \"src/list/dlprev.c\" \(1814 characters\)
- sed "s/^X//" >src/list/dlprev.c <<'END_OF_src/list/dlprev.c'
- X/***********************************************************************
- X *
- X * dlprev.c -- This file contains the dll_prev function.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ***********************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X/***********************************************************************
- X *
- X * dll_prev -- This function returns the previous key stored in the list.
- X * If the list is sorted, this key is the next lowest in
- X * the lexical order of keys stored in the tree.
- X *
- X ***********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *dll_prev(DL_LIST plist, void **data)
- X#else
- Xvoid *dll_prev(plist,data)
- XDL_LIST plist;
- Xvoid **data;
- X#endif
- X{
- X LIST *list;
- X
- X COVER("dlprev.c",1);
- X
- X /* Validate parameters */
- X list = (LIST*) plist;
- X if (list == NULL)
- X {
- X COVER("dlprev.c",2);
- X return NULL;
- X }
- X if (list->last == NULL)
- X {
- X COVER("dlprev.c",3);
- X return NULL;
- X }
- X
- X /* Require a search, first, or next */
- X if (list->changed)
- X {
- X COVER("dlprev.c",4);
- X return NULL;
- X }
- X
- X /* Last search was for a key that was beyond the end of the list */
- X if (list->current == NULL)
- X {
- X COVER("dlprev.c",5);
- X return dll_last(plist,data);
- X }
- X
- X /* Indicate error if list is overrun */
- X if (list->current == list->last->next)
- X {
- X COVER("dlprev.c",6);
- X list->nextOk = 1;
- X return NULL;
- X }
- X
- X /* Return next item in list */
- X COVER("dlprev.c",7);
- X list->current = list->current->prev;
- X list->nextOk = 0;
- X if (data != NULL)
- X {
- X COVER("dlprev.c",8);
- X *data = list->current->data;
- X }
- X return list->current->key;
- X}
- X
- X/************ End of file ************/
- X
- END_OF_src/list/dlprev.c
- if test 1814 -ne `wc -c <src/list/dlprev.c`; then
- echo shar: \"src/list/dlprev.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dlpriv.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dlpriv.h\"
- else
- echo shar: Extracting \"src/list/dlpriv.h\" \(1584 characters\)
- sed "s/^X//" >src/list/dlpriv.h <<'END_OF_src/list/dlpriv.h'
- X/*****************************************************************
- X *
- X * dlpriv.h -- This file contains private declarations and
- X * definitions used by the in-memory doubly-linked
- X * list implemenation.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X *****************************************************************/
- X
- X#include "dlist.h"
- X
- X#ifdef __STDC__
- Xtypedef int (*COMPFN)(void*,void*);
- X#else
- Xtypedef int (*COMPFN)();
- X#endif
- X
- Xstruct node {
- X struct node *next;
- X struct node *prev;
- X void *key;
- X void *data;
- X};
- X
- Xstruct list {
- X struct node *last;
- X struct node *current;
- X void *data;
- X COMPFN comp;
- X int nextOk;
- X int size;
- X int changed;
- X};
- X
- Xstruct setup {
- X COMPFN comp;
- X void *data;
- X};
- X
- Xtypedef struct node NODE;
- Xtypedef struct list LIST;
- Xtypedef struct setup SETUP;
- X
- X#ifdef __STDC__
- X
- Xextern NODE *dll_newNode(void*,void*);
- Xextern void dll_store(NODE*,NODE*);
- Xextern void dll_unlink(NODE*);
- Xextern void dll_freeNode(NODE*);
- Xextern int dll_locate(LIST*,void*,NODE**);
- Xextern void dll_touch(LIST*);
- Xextern NODE *dll_locRank(LIST*,int);
- X
- X#else
- X
- Xextern NODE *dll_newNode();
- Xextern void dll_store();
- Xextern void dll_unlink();
- Xextern void dll_freeNode();
- Xextern int dll_locate();
- Xextern void dll_touch();
- Xextern NODE *dll_locRank();
- X
- X#endif
- X
- X#ifdef COVERAGE
- X#define COVER(fn,loc) printf("Coverage: file %s, location %03d\n",fn,loc)
- X#else
- X#define COVER(file,loc)
- X#endif
- X
- X/************** End of file ***************/
- X
- END_OF_src/list/dlpriv.h
- if test 1584 -ne `wc -c <src/list/dlpriv.h`; then
- echo shar: \"src/list/dlpriv.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dlrank.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dlrank.c\"
- else
- echo shar: Extracting \"src/list/dlrank.c\" \(1564 characters\)
- sed "s/^X//" >src/list/dlrank.c <<'END_OF_src/list/dlrank.c'
- X/************************************************************************
- X *
- X * dlrank.c -- This file contains the dll_rank function.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ************************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X/************************************************************************
- X *
- X * dll_rank -- This function returns the specified item stored in the list,
- X * as specified by rank .
- X *
- X ************************************************************************/
- X
- X#ifdef __STDC__
- Xvoid *dll_rank(DL_LIST plist, int rank, void **data)
- X#else
- Xvoid *dll_rank(plist,rank,data)
- XDL_LIST plist;
- Xint rank;
- Xvoid **data;
- X#endif
- X{
- X LIST *list;
- X NODE *node;
- X void *retval;
- X
- X COVER("dlrank.c",1);
- X if (plist == NULL)
- X {
- X COVER("dlrank.c",2);
- X return NULL;
- X }
- X list = (LIST*) plist;
- X if (rank < 0)
- X {
- X COVER("dlrank.c",3);
- X return NULL;
- X }
- X if (rank >= list->size)
- X {
- X COVER("dlrank.c",4);
- X return NULL;
- X }
- X
- X node = dll_locRank(list,rank);
- X list->nextOk = 0;
- X list->current = node;
- X list->changed = 0;
- X if (node != NULL)
- X {
- X COVER("dlrank.c",5);
- X if (data != NULL) *data = node->data;
- X retval = node->key;
- X }
- X else
- X {
- X /*
- X * This code is never reached because earlier tests on rank
- X * insure that a node is found.
- X */
- X COVER("dlrank.c",6);
- X retval = NULL;
- X }
- X return retval;
- X}
- X
- X/************ End of file ***********/
- X
- END_OF_src/list/dlrank.c
- if test 1564 -ne `wc -c <src/list/dlrank.c`; then
- echo shar: \"src/list/dlrank.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dlsetup.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dlsetup.c\"
- else
- echo shar: Extracting \"src/list/dlsetup.c\" \(1855 characters\)
- sed "s/^X//" >src/list/dlsetup.c <<'END_OF_src/list/dlsetup.c'
- X/************************************************************************
- X *
- X * dlsetup.c -- This file contains routines needed for manipulating
- X * setup structures for doubly-linked lists.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ************************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X/************************************************************************
- X *
- X * dll_setup -- This function creates a doubly-linked list setup structure,
- X * and returns it to the caller. The parameter is an
- X * optional comparison function (used in case the contents of
- X * the list are sorted). The setup structure is then passed
- X * to dll_new when a new list is created.
- X *
- X ************************************************************************/
- X
- X#ifdef __STDC__
- XDLL_SETUP dll_setup(int (*comp)(void*,void*),void *data)
- X#else
- XDLL_SETUP dll_setup(comp,data)
- Xint (*comp)();
- Xvoid *data;
- X#endif
- X{
- X SETUP *retval;
- X
- X COVER("dlsetup.c",1);
- X retval = (SETUP*) malloc(sizeof(SETUP));
- X if (retval != NULL)
- X {
- X COVER("dlsetup.c",2);
- X retval->comp = comp;
- X retval->data = data;
- X }
- X return (DLL_SETUP) retval;
- X}
- X
- X/************************************************************************
- X *
- X * dll_freeSetup -- This function frees a doubly-linked list setup structure.
- X *
- X ************************************************************************/
- X
- X#ifdef __STDC__
- Xvoid dll_freeSetup(DLL_SETUP setup)
- X#else
- Xvoid dll_freeSetup(setup)
- XDLL_SETUP setup;
- X#endif
- X{
- X COVER("dlsetup.c",3);
- X if (setup != NULL)
- X {
- X COVER("dlsetup.c",4);
- X free(setup);
- X }
- X return;
- X}
- X
- X/************* End of file **************/
- X
- END_OF_src/list/dlsetup.c
- if test 1855 -ne `wc -c <src/list/dlsetup.c`; then
- echo shar: \"src/list/dlsetup.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f src/list/dlutil.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"src/list/dlutil.c\"
- else
- echo shar: Extracting \"src/list/dlutil.c\" \(1792 characters\)
- sed "s/^X//" >src/list/dlutil.c <<'END_OF_src/list/dlutil.c'
- X/********************************************************************
- X *
- X * dlutil.c -- This file contains general-purpose utility functions
- X * needed by the doubly-linked list implementation.
- X *
- X * This file is part of a suite of programs called Software Chipset.
- X * The source code for Software Chipset has been released into the
- X * public domain by its author, Paul Sander.
- X *
- X ********************************************************************/
- X
- X#include <stdio.h>
- X#include "dlpriv.h"
- X
- X/********************************************************************
- X *
- X * dll_locate -- This function performs a sequential search of a
- X * doubly-linked list for a specified key. This function
- X * assumes the list is sorted.
- X *
- X ********************************************************************/
- X
- X#ifdef __STDC__
- Xint dll_locate(LIST *list, void *key, NODE **node)
- X#else
- Xint dll_locate(list,key,node)
- XLIST *list;
- Xvoid *key;
- XNODE **node;
- X#endif
- X{
- X int res;
- X NODE *this;
- X
- X COVER("dlutil.c",1);
- X this = list->last->next;
- X res = (*list->comp)(this->key,key);
- X while ((res < 0) && (this != list->last))
- X {
- X COVER("dlutil.c",2);
- X this = this->next;
- X res = (*list->comp)(this->key,key);
- X }
- X COVER("dlutil.c",3);
- X *node = this;
- X return res;
- X}
- X
- X/********************************************************************
- X *
- X * dll_touch -- This function marks a list as having been modified.
- X * This affects the behavior of dll_next and dll_prev.
- X *
- X ********************************************************************/
- X
- X#ifdef __STDC__
- Xvoid dll_touch(LIST *list)
- X#else
- Xvoid dll_touch(list)
- XLIST *list;
- X#endif
- X{
- X COVER("dlutil.c",4);
- X list->current = NULL;
- X list->nextOk = 0;
- X list->changed = 1;
- X return;
- X}
- X
- X/************** End of file *************/
- X
- END_OF_src/list/dlutil.c
- if test 1792 -ne `wc -c <src/list/dlutil.c`; then
- echo shar: \"src/list/dlutil.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of archive 2 \(of 10\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 10 archives.
- echo "Now edit common.mk and do a 'make all'"
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-