home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / reviewed / volume03 / chipset2 / 02 < prev    next >
Encoding:
Text File  |  1993-03-13  |  32.6 KB  |  1,218 lines

  1. From decwrl!athertn!sander.cupertino.ca.us!paul@cs.purdue.edu Wed Jan  6 13:53:09 EST 1993
  2. Submit chipset-2 02/10 
  3. #! /bin/sh
  4. # This is a shell archive.  Remove anything before this line, then unpack
  5. # it by saving it into a file and typing "sh file".  To overwrite existing
  6. # files, type "sh file -c".  You can also feed this as standard input via
  7. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  8. # will see the following message at the end:
  9. #        "End of archive 2 (of 10)."
  10. # Contents:  rules.mk src/btree/Makefile src/btree/bt_last.c
  11. #   src/btree/btdata.c src/btree/btfirst.c src/btree/btree.h
  12. #   src/list/Makefile src/list/dldata.c src/list/dldump.c
  13. #   src/list/dlpopf.c src/list/dlprev.c src/list/dlpriv.h
  14. #   src/list/dlrank.c src/list/dlsetup.c src/list/dlutil.c
  15. # Wrapped by paul@sander on Sun Nov 22 15:41:47 1992
  16. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  17. if test -f rules.mk -a "${1}" != "-c" ; then 
  18.   echo shar: Will not over-write existing file \"rules.mk\"
  19. else
  20. echo shar: Extracting \"rules.mk\" \(1465 characters\)
  21. sed "s/^X//" >rules.mk <<'END_OF_rules.mk'
  22. X# rules.mk -- This file contains rules that are used by all of the components
  23. X#             comprising the Software ChipSet component library.
  24. X
  25. X# This file is part of a suite of programs called Software Chipset.
  26. X# The source code for Software Chipset has been released into the
  27. X# public domain by its author, Paul Sander.
  28. X
  29. X# Default rule, just in case
  30. X
  31. Xall:
  32. X
  33. X# Install the libraries in $(LIBDIR), which is passed on the command line
  34. X# or set in common.mk
  35. X
  36. XinstallLib:
  37. X    for x in $?;                            \
  38. X    do                                \
  39. X        cp $$x $(LIBDIR);                    \
  40. X        if [ -x "$(RANLIB)" ]; then $(RANLIB) $(LIBDIR)/$$x; fi;\
  41. X        chmod 644 $(LIBDIR)/$$x;                \
  42. X    done
  43. X
  44. X# Install the include files in $(INCDIR), which is passed on the command line
  45. X# or set in common.mk
  46. X
  47. XinstallInclude:
  48. X    for x in $?;                            \
  49. X    do                                \
  50. X        cp $$x $(INCDIR);                    \
  51. X        chmod 644 $(INCDIR)/$$x;                \
  52. X    done
  53. X
  54. X# Install the documentation
  55. X
  56. XinstallDocs:
  57. X    for x in $?;                            \
  58. X    do                                \
  59. X        dest=`expr $$x : '\(.*\)\.[^.]*'`.$(MANSUFF)$(INSTALLSUFF); \
  60. X        < $$x $(INSTALLMAN) > $(MANDIR)/$$dest;            \
  61. X        chmod 644 $(MANDIR)/$$dest;                \
  62. X    done
  63. X
  64. X# Make all products locally
  65. X
  66. Xeverything: all docs
  67. X
  68. X# Install everything
  69. X
  70. Xinstall: installInclude installLib installDocs
  71. X
  72. X# Clean-up
  73. X
  74. Xclean:
  75. X    rm -f *.o test core
  76. X
  77. Xspotless clobber realclean veryclean: clean
  78. X    rm -f *.doc *.ps *$(ZSUFF) *.$(MANSUFF) *.a
  79. X
  80. X# Create the MANIFEST file
  81. X
  82. XMANIFEST: clobber
  83. X    find . -type f -print | sed -e 's/^\.\///' -e /CVS/d | sort > MANIFEST
  84. X
  85. X### End of File ###
  86. END_OF_rules.mk
  87. if test 1465 -ne `wc -c <rules.mk`; then
  88.     echo shar: \"rules.mk\" unpacked with wrong size!
  89. fi
  90. # end of overwriting check
  91. fi
  92. if test -f src/btree/Makefile -a "${1}" != "-c" ; then 
  93.   echo shar: Will not over-write existing file \"src/btree/Makefile\"
  94. else
  95. echo shar: Extracting \"src/btree/Makefile\" \(1610 characters\)
  96. sed "s/^X//" >src/btree/Makefile <<'END_OF_src/btree/Makefile'
  97. X# Makefile -- This file contains instructions to build the in-memory B-tree
  98. X#             implementation and its related files.  Edit this as needed
  99. X#             for your system.  This makefile works properly with brain-dead
  100. X#             SVR2 make, so it should work with your tool, too.
  101. X
  102. X# This file is part of a suite of programs called Software Chipset.
  103. X# The source code for Software Chipset has been released into the
  104. X# public domain by its author, Paul Sander.
  105. X
  106. X# Pick up the standard macros and rules.
  107. X
  108. Xinclude ../../common.mk
  109. Xinclude ../../rules.mk
  110. X
  111. X# Miscellaneous
  112. XTARGET = libbtree.a
  113. X
  114. X# These are the object files that implement the B-tree.
  115. XOBJECTS = btmalloc.o btutil.o bt_last.o bt_next.o bt_prev.o \
  116. X    btdelete.o btdestroy.o btdump.o btfirst.o btinsert.o btnew.o \
  117. X    btsearch.o bttraverse.o btrank.o btdelutl.o btdelrank.o btdata.o
  118. X
  119. X# Default target, library and test program
  120. Xall:    $(TARGET) test
  121. X
  122. X# Documentation
  123. Xdocs:    btree.ps btree.doc
  124. X
  125. X# Install just the header file
  126. XinstallInclude: btree.h
  127. X
  128. X# Install the library
  129. XinstallLib:    $(TARGET)
  130. X
  131. X# Install the documentation.
  132. XinstallDocs:    btree.man
  133. X
  134. X# This produces the library.  Should work for both System V and BSD
  135. X$(TARGET): $(OBJECTS)
  136. X    ar r $@ `lorder $? | tsort`
  137. X    if [ -x "$(RANLIB)" ]; then $(RANLIB) $@; fi
  138. X
  139. X# This produces the object code.
  140. X$(OBJECTS): btpriv.h
  141. X
  142. X# This produces the test program.
  143. Xtest:    test.o $(TARGET)
  144. X    $(CC) $(CFLAGS) $(LFLAGS) -o test test.o $(TARGET) $(TESTLIBS)
  145. X
  146. X# This produces the ASCII plaintext documentation.
  147. Xbtree.doc: btree.man
  148. X
  149. X# This produces the PostScript documentation.
  150. Xbtree.ps: btree.man
  151. X
  152. X### End of file ###
  153. X
  154. END_OF_src/btree/Makefile
  155. if test 1610 -ne `wc -c <src/btree/Makefile`; then
  156.     echo shar: \"src/btree/Makefile\" unpacked with wrong size!
  157. fi
  158. # end of overwriting check
  159. fi
  160. if test -f src/btree/bt_last.c -a "${1}" != "-c" ; then 
  161.   echo shar: Will not over-write existing file \"src/btree/bt_last.c\"
  162. else
  163. echo shar: Extracting \"src/btree/bt_last.c\" \(1631 characters\)
  164. sed "s/^X//" >src/btree/bt_last.c <<'END_OF_src/btree/bt_last.c'
  165. X/********************************************************************
  166. X *
  167. X * bt_last.c -- This file contains functions needed to find the
  168. X *              key that is highest in the lexical order of keys
  169. X *              stored in an in-memory B-tree.
  170. X *
  171. X * This file is part of a suite of programs called Software Chipset.
  172. X * The source code for Software Chipset has been released into the
  173. X * public domain by its author, Paul Sander.
  174. X *
  175. X ********************************************************************/
  176. X
  177. X
  178. X#include <stdio.h>
  179. X#include "btpriv.h"
  180. X
  181. X/********************************************************************
  182. X *
  183. X * bt_last -- This function returns the key that appears last in
  184. X *            the lexical order of the items stored in the tree.
  185. X *            NULL is returned if the tree is empty.
  186. X *
  187. X *******************************************************************/
  188. X
  189. X#ifdef __STDC__
  190. Xvoid *bt_last(void *ptree, void **data)
  191. X#else
  192. Xvoid *bt_last(ptree,data)
  193. Xvoid    *ptree;
  194. Xvoid    **data;
  195. X#endif
  196. X{
  197. X    BTREE    tree;
  198. X    BTNODE    *node;
  199. X
  200. X    tree = (BTREE) ptree;
  201. X    if (tree == NULL)
  202. X    {
  203. X        COVER("bt_last.c",1);
  204. X        return NULL;
  205. X    }
  206. X    node = tree->root;
  207. X    if (node->nkeys == 0)
  208. X    {
  209. X        COVER("bt_last.c",2);
  210. X        return NULL;
  211. X    }
  212. X    COVER("bt_last.c",3);
  213. X    while (node->children != NULL)
  214. X    {
  215. X        COVER("bt_last.c",4);
  216. X        node->currKey = node->nkeys;
  217. X        node = node->children[node->nkeys];
  218. X    }
  219. X    COVER("bt_last.c",5);
  220. X    node->currKey = node->nkeys - 1;
  221. X    tree->currNode = node;
  222. X    tree->nextOk = 1;
  223. X    if (data != NULL)
  224. X    {
  225. X        COVER("bt_last.c",6);
  226. X        *data = node->data[node->nkeys - 1];
  227. X    }
  228. X    return node->keys[node->nkeys - 1];
  229. X}
  230. X
  231. X/************ End of file *************/
  232. X
  233. END_OF_src/btree/bt_last.c
  234. if test 1631 -ne `wc -c <src/btree/bt_last.c`; then
  235.     echo shar: \"src/btree/bt_last.c\" unpacked with wrong size!
  236. fi
  237. # end of overwriting check
  238. fi
  239. if test -f src/btree/btdata.c -a "${1}" != "-c" ; then 
  240.   echo shar: Will not over-write existing file \"src/btree/btdata.c\"
  241. else
  242. echo shar: Extracting \"src/btree/btdata.c\" \(1684 characters\)
  243. sed "s/^X//" >src/btree/btdata.c <<'END_OF_src/btree/btdata.c'
  244. X/***********************************************************************
  245. X *
  246. X * btdata.c -- This file contains functions to access and modify a
  247. X *             a user-defined data structure that can be stored with
  248. X *             a B-tree.
  249. X *
  250. X * This file is part of a suite of programs called Software Chipset.
  251. X * The source code for Software Chipset has been released into the
  252. X * public domain by its author, Paul Sander.
  253. X *
  254. X ***********************************************************************/
  255. X
  256. X#include <stdio.h>
  257. X#include "btpriv.h"
  258. X
  259. X/***********************************************************************
  260. X *
  261. X * bt_data -- Given a B-tree, returns a pointer to a user-defined
  262. X *            structure.  This pointer can be set by bt_new(), or
  263. X *            with bt_setData().
  264. X *
  265. X ***********************************************************************/
  266. X
  267. X#ifdef __STDC__
  268. Xvoid    *bt_data(void *ptree)
  269. X#else
  270. Xvoid    *bt_data(ptree)
  271. Xvoid    *ptree;
  272. X#endif
  273. X{
  274. X    BTREE    tree;
  275. X
  276. X    if (ptree == NULL)
  277. X    {
  278. X        COVER("btdata.c",1);
  279. X        return NULL;
  280. X    }
  281. X    COVER("btdata.c",2);
  282. X    tree = (BTREE) ptree;
  283. X    return tree->data;
  284. X}
  285. X
  286. X/***********************************************************************
  287. X *
  288. X * bt_setData -- This function modifies a pointer to a user-defined
  289. X *               structure that is kept with the tree.
  290. X *
  291. X ***********************************************************************/
  292. X
  293. X#ifdef __STDC__
  294. Xvoid bt_setData(void *ptree, void *data)
  295. X#else
  296. Xvoid bt_setData(ptree,data)
  297. Xvoid    *ptree;
  298. Xvoid    *data;
  299. X#endif
  300. X{
  301. X    BTREE    tree;
  302. X
  303. X    if (ptree != NULL)
  304. X    {
  305. X        COVER("btdata.c",3);
  306. X        tree = (BTREE) ptree;
  307. X        tree->data = data;
  308. X    }
  309. X    COVER("btdata.c",4);
  310. X    return;
  311. X}
  312. X
  313. X/************ End of file *************/
  314. X
  315. END_OF_src/btree/btdata.c
  316. if test 1684 -ne `wc -c <src/btree/btdata.c`; then
  317.     echo shar: \"src/btree/btdata.c\" unpacked with wrong size!
  318. fi
  319. # end of overwriting check
  320. fi
  321. if test -f src/btree/btfirst.c -a "${1}" != "-c" ; then 
  322.   echo shar: Will not over-write existing file \"src/btree/btfirst.c\"
  323. else
  324. echo shar: Extracting \"src/btree/btfirst.c\" \(1544 characters\)
  325. sed "s/^X//" >src/btree/btfirst.c <<'END_OF_src/btree/btfirst.c'
  326. X/********************************************************************
  327. X *
  328. X * btfirst.c -- This file contains functions to locate the key
  329. X *              falling first in the lexical order of items stored
  330. X *              in an in-memory B-tree.
  331. X *
  332. X * This file is part of a suite of programs called Software Chipset.
  333. X * The source code for Software Chipset has been released into the
  334. X * public domain by its author, Paul Sander.
  335. X *
  336. X ********************************************************************/
  337. X
  338. X#include <stdio.h>
  339. X#include "btpriv.h"
  340. X
  341. X/********************************************************************
  342. X *
  343. X * bt_first -- This function returns the key that appears first in
  344. X *             the lexical order of the items stored in the tree.
  345. X *             NULL is returned if the tree is empty.
  346. X *
  347. X *******************************************************************/
  348. X
  349. X#ifdef __STDC__
  350. Xvoid *bt_first(void *ptree, void **data)
  351. X#else
  352. Xvoid *bt_first(ptree,data)
  353. Xvoid    *ptree;
  354. Xvoid    **data;
  355. X#endif
  356. X{
  357. X    BTNODE    *node;
  358. X    BTREE    tree;
  359. X
  360. X    tree = (BTREE) ptree;
  361. X    if (tree == NULL)
  362. X    {
  363. X        COVER("btfirst.c",1);
  364. X        return NULL;
  365. X    } 
  366. X    node = tree->root;
  367. X    if (node->nkeys == 0)
  368. X    {
  369. X        COVER("btfirst.c",2);
  370. X        return NULL;
  371. X    }
  372. X    while (node->children != NULL)
  373. X    {
  374. X        COVER("btfirst.c",3);
  375. X        node->currKey = 0;
  376. X        node = node->children[0];
  377. X    }
  378. X    COVER("btfirst.c",4);
  379. X    node->currKey = 0;
  380. X    tree->currNode = node;
  381. X    tree->nextOk = 1;
  382. X    if (data != NULL)
  383. X    {
  384. X        COVER("btfirst.c",5);
  385. X        *data = node->data[0];
  386. X    }
  387. X    return node->keys[0];
  388. X}
  389. X
  390. X/*********** End of file ************/
  391. X
  392. END_OF_src/btree/btfirst.c
  393. if test 1544 -ne `wc -c <src/btree/btfirst.c`; then
  394.     echo shar: \"src/btree/btfirst.c\" unpacked with wrong size!
  395. fi
  396. # end of overwriting check
  397. fi
  398. if test -f src/btree/btree.h -a "${1}" != "-c" ; then 
  399.   echo shar: Will not over-write existing file \"src/btree/btree.h\"
  400. else
  401. echo shar: Extracting \"src/btree/btree.h\" \(1874 characters\)
  402. sed "s/^X//" >src/btree/btree.h <<'END_OF_src/btree/btree.h'
  403. X/*********************************************************************
  404. X *
  405. X * btree.h -- This file contains public declarations and definitions
  406. X *            used by the in-memory B-tree implementation.
  407. X *
  408. X * This file is part of a suite of programs called Software Chipset.
  409. X * The source code for Software Chipset has been released into the
  410. X * public domain by its author, Paul Sander.
  411. X *
  412. X *********************************************************************/
  413. X
  414. X/* Header file for in-memory B-tree implementation */
  415. X
  416. Xtypedef void *BTREE;
  417. Xtypedef void *BT_SETUP;
  418. X
  419. X#ifdef __STDC__
  420. Xextern    void        bt_dump(BTREE, void (*)(void*,void*,void*), void*);
  421. Xextern    void        *bt_search(BTREE, void*, void**);
  422. Xextern    BTREE        bt_new(BT_SETUP);
  423. Xextern    void        bt_destroy(BTREE, void(*)(void*,void*),
  424. X                       void(*)(void*,void*), void*);
  425. Xextern    int        bt_insert(BTREE, void*, void*);
  426. Xextern    void        bt_traverse(BTREE, void (*)(void*,void*,void*),void*);
  427. Xextern    void        *bt_delete(BTREE, void*, void**);
  428. Xextern    void        *bt_first(BTREE, void**);
  429. Xextern    void        *bt_next(BTREE, void**);
  430. Xextern    void        *bt_last(BTREE, void**);
  431. Xextern    void        *bt_prev(BTREE, void**);
  432. Xextern    BT_SETUP    bt_setup(int, int(*)(void*,void*), void*);
  433. Xextern    void        bt_freeSetup(BT_SETUP);
  434. Xextern    void        *bt_rank(BTREE, int, void*);
  435. Xextern    void        *bt_delRank(BTREE, int, void**);
  436. Xextern    void        *bt_data(BTREE);
  437. Xextern    void        bt_setData(BTREE, void*);
  438. X#else
  439. Xextern    void        bt_dump();
  440. Xextern    void        *bt_search();
  441. Xextern    BTREE        bt_new();
  442. Xextern    void        bt_destroy();
  443. Xextern    int        bt_insert();
  444. Xextern    void        bt_traverse();
  445. Xextern    void        *bt_delete();
  446. Xextern    void        *bt_first();
  447. Xextern    void        *bt_next();
  448. Xextern    void        *bt_last();
  449. Xextern    void        *bt_prev();
  450. Xextern    BT_SETUP    bt_setup();
  451. Xextern    void        bt_freeSetup();
  452. Xextern    void        *bt_rank();
  453. Xextern    void        *bt_delRank();
  454. Xextern    void        *bt_data();
  455. Xextern    void        bt_setData();
  456. X#endif
  457. X
  458. X/****** end of file ******/
  459. X
  460. X
  461. END_OF_src/btree/btree.h
  462. if test 1874 -ne `wc -c <src/btree/btree.h`; then
  463.     echo shar: \"src/btree/btree.h\" unpacked with wrong size!
  464. fi
  465. # end of overwriting check
  466. fi
  467. if test -f src/list/Makefile -a "${1}" != "-c" ; then 
  468.   echo shar: Will not over-write existing file \"src/list/Makefile\"
  469. else
  470. echo shar: Extracting \"src/list/Makefile\" \(1647 characters\)
  471. sed "s/^X//" >src/list/Makefile <<'END_OF_src/list/Makefile'
  472. X# Makefile -- This file contains instructions to build the doubly-linked
  473. X#             list implementation and its related files.  Edit this as
  474. X#             needed for your system.
  475. X#
  476. X# This file is part of a suite of programs called Software Chipset.
  477. X# The source code for Software Chipset has been released into the
  478. X# public domain by its author, Paul Sander.
  479. X#
  480. X
  481. X# Pick up the standard macros and rules.
  482. X
  483. Xinclude ../../common.mk
  484. Xinclude ../../rules.mk
  485. X
  486. X# Miscellaneous
  487. XTARGET = libdlist.a
  488. X
  489. X# These are the object files that implement the doubly-linked list.
  490. XOBJECTS = dlsetup.o dlnew.o dldestroy.o dlinsutl.o dlinsert.o dldump.o \
  491. X    dldelutl.o dldelete.o dlutil.o dlsearch.o dltrav.o dlfirst.o dlnext.o \
  492. X    dllast.o dlprev.o dlrankutl.o dlrank.o dldelrank.o dldata.o dlpushf.o \
  493. X    dlpushr.o dlpush.o dlpopf.o dlpopr.o dlpop.o dlpeekf.o dlpeekr.o \
  494. X    dlpeek.o dljoin.o
  495. X
  496. X# Default target, library and test program
  497. Xall:    $(TARGET) test
  498. X
  499. X# Documentation
  500. Xdocs:    dlist.ps dlist.doc
  501. X
  502. X# Install just the header file
  503. XinstallInclude: dlist.h
  504. X
  505. X# Install the library
  506. XinstallLib: $(TARGET)
  507. X
  508. X# Install the documentation
  509. XinstallDocs: dlist.man
  510. X
  511. X# This produces the library.  ranlib is desireable on BSD-derived systems.
  512. X$(TARGET): $(OBJECTS)
  513. X    ar r $@ `lorder $? | tsort`
  514. X    if [ -x "$(RANLIB)" ]; then $(RANLIB) $@; fi
  515. X
  516. X# This produces the object code.
  517. X$(OBJECTS): dlpriv.h dlist.h
  518. X
  519. X# This produces the test program.
  520. Xtest:   test.o $(TARGET)
  521. X    $(CC) $(CFLAGS) $(LFLAGS) -o test test.o $(TARGET) $(TESTLIBS)
  522. X
  523. X# This produces the ASCII plaintext documentation.
  524. Xdlist.doc: dlist.man
  525. X
  526. X# This produces the PostScript documentation.
  527. Xdlist.ps: dlist.man
  528. X
  529. X### End of file ###
  530. X
  531. END_OF_src/list/Makefile
  532. if test 1647 -ne `wc -c <src/list/Makefile`; then
  533.     echo shar: \"src/list/Makefile\" unpacked with wrong size!
  534. fi
  535. # end of overwriting check
  536. fi
  537. if test -f src/list/dldata.c -a "${1}" != "-c" ; then 
  538.   echo shar: Will not over-write existing file \"src/list/dldata.c\"
  539. else
  540. echo shar: Extracting \"src/list/dldata.c\" \(1584 characters\)
  541. sed "s/^X//" >src/list/dldata.c <<'END_OF_src/list/dldata.c'
  542. X/***********************************************************************
  543. X *
  544. X * dldata.c -- This file contains functions used for storing and
  545. X *             retrieving the global list object data field.
  546. X *
  547. X * This file is part of a suite of programs called Software Chipset.
  548. X * The source code for Software Chipset has been released into the
  549. X * public domain by its author, Paul Sander.
  550. X *
  551. X ***********************************************************************/
  552. X
  553. X#include <stdio.h>
  554. X#include "dlpriv.h"
  555. X
  556. X/***********************************************************************
  557. X *
  558. X * dll_data -- This function retrieves the list's global client-defined
  559. X *             data pointer.
  560. X *
  561. X ***********************************************************************/
  562. X
  563. X#ifdef __STDC__
  564. Xvoid *dll_data(DL_LIST plist)
  565. X#else
  566. Xvoid *dll_data(plist)
  567. XDL_LIST    plist;
  568. X#endif
  569. X{
  570. X    LIST    *list;
  571. X
  572. X    list = (LIST*) plist;
  573. X    if (list == NULL)
  574. X    {
  575. X        COVER("dldata.c",1);
  576. X        return NULL;
  577. X    }
  578. X    COVER("dldata.c",2);
  579. X    return list->data;
  580. X}
  581. X
  582. X/***********************************************************************
  583. X *
  584. X * dll_setData -- This function sets the list's global client-defined
  585. X *                data pointer.
  586. X *
  587. X ***********************************************************************/
  588. X
  589. X#ifdef __STDC__
  590. Xvoid dll_setData(DL_LIST plist, void *data)
  591. X#else
  592. Xvoid dll_setData(plist,data)
  593. XDL_LIST    plist;
  594. Xvoid    *data;
  595. X#endif
  596. X{
  597. X    LIST    *list;
  598. X
  599. X    list = (LIST*) plist;
  600. X    if (list != NULL)
  601. X    {
  602. X        COVER("dldata.c",3);
  603. X        list->data = data;
  604. X    }
  605. X    COVER("dldata.c",4);
  606. X    return;
  607. X}
  608. X
  609. X/****************** End of file ******************/
  610. X
  611. END_OF_src/list/dldata.c
  612. if test 1584 -ne `wc -c <src/list/dldata.c`; then
  613.     echo shar: \"src/list/dldata.c\" unpacked with wrong size!
  614. fi
  615. # end of overwriting check
  616. fi
  617. if test -f src/list/dldump.c -a "${1}" != "-c" ; then 
  618.   echo shar: Will not over-write existing file \"src/list/dldump.c\"
  619. else
  620. echo shar: Extracting \"src/list/dldump.c\" \(1554 characters\)
  621. sed "s/^X//" >src/list/dldump.c <<'END_OF_src/list/dldump.c'
  622. X/***********************************************************************
  623. X *
  624. X * dldump.c -- This file contains debugging code to dump the contents
  625. X *             of a doubly-linked list.
  626. X *
  627. X * This file is part of a suite of programs called Software Chipset.
  628. X * The source code for Software Chipset has been released into the
  629. X * public domain by its author, Paul Sander.
  630. X *
  631. X ***********************************************************************/
  632. X
  633. X#include <stdio.h>
  634. X#include "dlpriv.h"
  635. X
  636. X#ifdef __STDC__
  637. Xvoid dll_dump(DL_LIST plist,void (*key_dump)(void*,void*,void*),void *info)
  638. X#else
  639. Xvoid dll_dump(plist,key_dump,info)
  640. XDL_LIST    plist;
  641. Xvoid    (*key_dump)();
  642. Xvoid    *info;
  643. X#endif
  644. X{
  645. X    LIST    *list;
  646. X    NODE    *this;
  647. X
  648. X    if (plist == NULL)
  649. X    {
  650. X        printf("ERROR:  Trying to dump null list\n");
  651. X        return;
  652. X    }
  653. X
  654. X    list = (LIST*) plist;
  655. X    printf("List handle located at %08x\n",(int) list);
  656. X    printf("last = %08x\n",(int) list->last);
  657. X    printf("current = %08x\n",(int) list->current);
  658. X    printf("data = %08x\n", (int) list->data);
  659. X    printf("nextOk = %d\n", list->nextOk);
  660. X    printf("size = %d\n", list->size);
  661. X    printf("changed = %d\n", list->changed);
  662. X    printf("-----------\n");
  663. X    if (list->last != NULL)
  664. X    {
  665. X        this = list->last->next;
  666. X        do
  667. X        {
  668. X            printf("Node at %08x:\n",(int) this);
  669. X            printf("  next = %08x\n",(int) this->next);
  670. X            printf("  prev = %08x\n",(int) this->prev);
  671. X            if (key_dump != NULL)
  672. X            {
  673. X                key_dump(this->key,this->data,info);
  674. X            }
  675. X            printf("\n");
  676. X            this = this->next;
  677. X        } while (this != list->last->next);
  678. X    }
  679. X    return;
  680. X}
  681. X
  682. X/************* End of file ************/
  683. X
  684. END_OF_src/list/dldump.c
  685. if test 1554 -ne `wc -c <src/list/dldump.c`; then
  686.     echo shar: \"src/list/dldump.c\" unpacked with wrong size!
  687. fi
  688. # end of overwriting check
  689. fi
  690. if test -f src/list/dlpopf.c -a "${1}" != "-c" ; then 
  691.   echo shar: Will not over-write existing file \"src/list/dlpopf.c\"
  692. else
  693. echo shar: Extracting \"src/list/dlpopf.c\" \(1410 characters\)
  694. sed "s/^X//" >src/list/dlpopf.c <<'END_OF_src/list/dlpopf.c'
  695. X/***********************************************************************
  696. X *
  697. X * dlpopf.c -- This file contains the dll_popf function.
  698. X *
  699. X * This file is part of a suite of programs called Software Chipset.
  700. X * The source code for Software Chipset has been released into the
  701. X * public domain by its author, Paul Sander.
  702. X *
  703. X ***********************************************************************/
  704. X
  705. X#include <stdio.h>
  706. X#include "dlpriv.h"
  707. X
  708. X/***********************************************************************
  709. X *
  710. X * dll_popf -- This function deletes an item from the front of a
  711. X *             doubly-linked list.
  712. X *
  713. X ***********************************************************************/
  714. X
  715. X#ifdef __STDC__
  716. Xvoid *dll_popf(DL_LIST plist, void **data)
  717. X#else
  718. Xvoid *dll_popf(plist,data)
  719. XDL_LIST    plist;
  720. Xvoid    **data;
  721. X#endif
  722. X{
  723. X    LIST    *list;
  724. X    NODE    *node;
  725. X    void    *retval;
  726. X
  727. X    COVER("dlpopf.c",1);
  728. X    if (plist == NULL)
  729. X    {
  730. X        COVER("dlpopf.c",2);
  731. X        return NULL;
  732. X    }
  733. X    list = (LIST*) plist;
  734. X    if (list->last == NULL)
  735. X    {
  736. X        COVER("dlpopf.c",3);
  737. X        return NULL;
  738. X    }
  739. X
  740. X    node = list->last->next;
  741. X    retval = node->key;
  742. X    if (data != NULL)
  743. X    {
  744. X        COVER("dlpopf.c",4);
  745. X        *data = node->data;
  746. X    }
  747. X    if (node == list->last)
  748. X    {
  749. X        COVER("dlpopf.c",5);
  750. X        list->last = NULL;
  751. X    }
  752. X    else
  753. X    {
  754. X        COVER("dlpopf.c",6);
  755. X        dll_unlink(node);
  756. X    }
  757. X    dll_freeNode(node);
  758. X    list->size -= 1;
  759. X    dll_touch(list);
  760. X    return retval;
  761. X}
  762. X
  763. X/*************** End of file ***************/
  764. X
  765. END_OF_src/list/dlpopf.c
  766. if test 1410 -ne `wc -c <src/list/dlpopf.c`; then
  767.     echo shar: \"src/list/dlpopf.c\" unpacked with wrong size!
  768. fi
  769. # end of overwriting check
  770. fi
  771. if test -f src/list/dlprev.c -a "${1}" != "-c" ; then 
  772.   echo shar: Will not over-write existing file \"src/list/dlprev.c\"
  773. else
  774. echo shar: Extracting \"src/list/dlprev.c\" \(1814 characters\)
  775. sed "s/^X//" >src/list/dlprev.c <<'END_OF_src/list/dlprev.c'
  776. X/***********************************************************************
  777. X *
  778. X * dlprev.c -- This file contains the dll_prev function.
  779. X *
  780. X * This file is part of a suite of programs called Software Chipset.
  781. X * The source code for Software Chipset has been released into the
  782. X * public domain by its author, Paul Sander.
  783. X *
  784. X ***********************************************************************/
  785. X
  786. X#include <stdio.h>
  787. X#include "dlpriv.h"
  788. X
  789. X/***********************************************************************
  790. X *
  791. X * dll_prev -- This function returns the previous key stored in the list.
  792. X *             If the list is sorted, this key is the next lowest in
  793. X *             the lexical order of keys stored in the tree.
  794. X *
  795. X ***********************************************************************/
  796. X
  797. X#ifdef __STDC__
  798. Xvoid *dll_prev(DL_LIST plist, void **data)
  799. X#else
  800. Xvoid *dll_prev(plist,data)
  801. XDL_LIST    plist;
  802. Xvoid    **data;
  803. X#endif
  804. X{
  805. X    LIST    *list;
  806. X
  807. X    COVER("dlprev.c",1);
  808. X
  809. X    /* Validate parameters */
  810. X    list = (LIST*) plist;
  811. X    if (list == NULL)
  812. X    {
  813. X        COVER("dlprev.c",2);
  814. X        return NULL;
  815. X    }
  816. X    if (list->last == NULL)
  817. X    {
  818. X        COVER("dlprev.c",3);
  819. X        return NULL;
  820. X    }
  821. X
  822. X    /* Require a search, first, or next */
  823. X    if (list->changed)
  824. X    {
  825. X        COVER("dlprev.c",4);
  826. X        return NULL;
  827. X    }
  828. X
  829. X    /* Last search was for a key that was beyond the end of the list */
  830. X    if (list->current == NULL)
  831. X    {
  832. X        COVER("dlprev.c",5);
  833. X        return dll_last(plist,data);
  834. X    }
  835. X
  836. X    /* Indicate error if list is overrun */
  837. X    if (list->current == list->last->next)
  838. X    {
  839. X        COVER("dlprev.c",6);
  840. X        list->nextOk = 1;
  841. X        return NULL;
  842. X    }
  843. X
  844. X    /* Return next item in list */
  845. X    COVER("dlprev.c",7);
  846. X    list->current = list->current->prev;
  847. X    list->nextOk = 0;
  848. X    if (data != NULL)
  849. X    {
  850. X        COVER("dlprev.c",8);
  851. X        *data = list->current->data;
  852. X    }
  853. X    return list->current->key;
  854. X}
  855. X
  856. X/************ End of file ************/
  857. X
  858. END_OF_src/list/dlprev.c
  859. if test 1814 -ne `wc -c <src/list/dlprev.c`; then
  860.     echo shar: \"src/list/dlprev.c\" unpacked with wrong size!
  861. fi
  862. # end of overwriting check
  863. fi
  864. if test -f src/list/dlpriv.h -a "${1}" != "-c" ; then 
  865.   echo shar: Will not over-write existing file \"src/list/dlpriv.h\"
  866. else
  867. echo shar: Extracting \"src/list/dlpriv.h\" \(1584 characters\)
  868. sed "s/^X//" >src/list/dlpriv.h <<'END_OF_src/list/dlpriv.h'
  869. X/*****************************************************************
  870. X *
  871. X * dlpriv.h -- This file contains private declarations and
  872. X *             definitions used by the in-memory doubly-linked
  873. X *             list implemenation.
  874. X *
  875. X * This file is part of a suite of programs called Software Chipset.
  876. X * The source code for Software Chipset has been released into the
  877. X * public domain by its author, Paul Sander.
  878. X *
  879. X *****************************************************************/
  880. X
  881. X#include "dlist.h"
  882. X
  883. X#ifdef __STDC__
  884. Xtypedef int (*COMPFN)(void*,void*);
  885. X#else
  886. Xtypedef int (*COMPFN)();
  887. X#endif
  888. X
  889. Xstruct node {
  890. X    struct node    *next;
  891. X    struct node    *prev;
  892. X    void        *key;
  893. X    void        *data;
  894. X};
  895. X
  896. Xstruct list {
  897. X    struct node    *last;
  898. X    struct node    *current;
  899. X    void        *data;
  900. X    COMPFN        comp;
  901. X    int        nextOk;
  902. X    int        size;
  903. X    int        changed;
  904. X};
  905. X
  906. Xstruct setup {
  907. X    COMPFN        comp;
  908. X    void        *data;
  909. X};
  910. X
  911. Xtypedef struct node NODE;
  912. Xtypedef struct list LIST;
  913. Xtypedef struct setup SETUP;
  914. X
  915. X#ifdef __STDC__
  916. X
  917. Xextern    NODE    *dll_newNode(void*,void*);
  918. Xextern    void    dll_store(NODE*,NODE*);
  919. Xextern    void    dll_unlink(NODE*);
  920. Xextern    void    dll_freeNode(NODE*);
  921. Xextern    int    dll_locate(LIST*,void*,NODE**);
  922. Xextern    void    dll_touch(LIST*);
  923. Xextern    NODE    *dll_locRank(LIST*,int);
  924. X
  925. X#else
  926. X
  927. Xextern    NODE    *dll_newNode();
  928. Xextern    void    dll_store();
  929. Xextern    void    dll_unlink();
  930. Xextern    void    dll_freeNode();
  931. Xextern    int    dll_locate();
  932. Xextern    void    dll_touch();
  933. Xextern    NODE    *dll_locRank();
  934. X
  935. X#endif
  936. X
  937. X#ifdef COVERAGE
  938. X#define COVER(fn,loc)   printf("Coverage:  file %s, location %03d\n",fn,loc)
  939. X#else
  940. X#define COVER(file,loc)
  941. X#endif
  942. X
  943. X/************** End of file ***************/
  944. X
  945. END_OF_src/list/dlpriv.h
  946. if test 1584 -ne `wc -c <src/list/dlpriv.h`; then
  947.     echo shar: \"src/list/dlpriv.h\" unpacked with wrong size!
  948. fi
  949. # end of overwriting check
  950. fi
  951. if test -f src/list/dlrank.c -a "${1}" != "-c" ; then 
  952.   echo shar: Will not over-write existing file \"src/list/dlrank.c\"
  953. else
  954. echo shar: Extracting \"src/list/dlrank.c\" \(1564 characters\)
  955. sed "s/^X//" >src/list/dlrank.c <<'END_OF_src/list/dlrank.c'
  956. X/************************************************************************
  957. X *
  958. X * dlrank.c -- This file contains the dll_rank function.
  959. X *
  960. X * This file is part of a suite of programs called Software Chipset.
  961. X * The source code for Software Chipset has been released into the
  962. X * public domain by its author, Paul Sander.
  963. X *
  964. X ************************************************************************/
  965. X
  966. X#include <stdio.h>
  967. X#include "dlpriv.h"
  968. X
  969. X/************************************************************************
  970. X *
  971. X * dll_rank -- This function returns the specified item stored in the list,
  972. X *             as specified by rank .
  973. X *
  974. X ************************************************************************/
  975. X
  976. X#ifdef __STDC__
  977. Xvoid *dll_rank(DL_LIST plist, int rank, void **data)
  978. X#else
  979. Xvoid *dll_rank(plist,rank,data)
  980. XDL_LIST    plist;
  981. Xint    rank;
  982. Xvoid    **data;
  983. X#endif
  984. X{
  985. X    LIST    *list;
  986. X    NODE    *node;
  987. X    void    *retval;
  988. X
  989. X    COVER("dlrank.c",1);
  990. X    if (plist == NULL)
  991. X    {
  992. X        COVER("dlrank.c",2);
  993. X        return NULL;
  994. X    }
  995. X    list = (LIST*) plist;
  996. X    if (rank < 0)
  997. X    {
  998. X        COVER("dlrank.c",3);
  999. X        return NULL;
  1000. X    }
  1001. X    if (rank >= list->size)
  1002. X    {
  1003. X        COVER("dlrank.c",4);
  1004. X        return NULL;
  1005. X    }
  1006. X
  1007. X    node = dll_locRank(list,rank);
  1008. X    list->nextOk = 0;
  1009. X    list->current = node;
  1010. X    list->changed = 0;
  1011. X    if (node != NULL)
  1012. X    {
  1013. X        COVER("dlrank.c",5);
  1014. X        if (data != NULL) *data = node->data;
  1015. X        retval = node->key;
  1016. X    }
  1017. X    else
  1018. X    {
  1019. X        /*
  1020. X         * This code is never reached because earlier tests on rank
  1021. X         * insure that a node is found.
  1022. X         */
  1023. X        COVER("dlrank.c",6);
  1024. X        retval = NULL;
  1025. X    }
  1026. X    return retval;
  1027. X}
  1028. X
  1029. X/************ End of file ***********/
  1030. X
  1031. END_OF_src/list/dlrank.c
  1032. if test 1564 -ne `wc -c <src/list/dlrank.c`; then
  1033.     echo shar: \"src/list/dlrank.c\" unpacked with wrong size!
  1034. fi
  1035. # end of overwriting check
  1036. fi
  1037. if test -f src/list/dlsetup.c -a "${1}" != "-c" ; then 
  1038.   echo shar: Will not over-write existing file \"src/list/dlsetup.c\"
  1039. else
  1040. echo shar: Extracting \"src/list/dlsetup.c\" \(1855 characters\)
  1041. sed "s/^X//" >src/list/dlsetup.c <<'END_OF_src/list/dlsetup.c'
  1042. X/************************************************************************
  1043. X *
  1044. X * dlsetup.c -- This file contains routines needed for manipulating
  1045. X *              setup structures for doubly-linked lists.
  1046. X *
  1047. X * This file is part of a suite of programs called Software Chipset.
  1048. X * The source code for Software Chipset has been released into the
  1049. X * public domain by its author, Paul Sander.
  1050. X *
  1051. X ************************************************************************/
  1052. X
  1053. X#include <stdio.h>
  1054. X#include "dlpriv.h"
  1055. X
  1056. X/************************************************************************
  1057. X *
  1058. X * dll_setup -- This function creates a doubly-linked list setup structure,
  1059. X *              and returns it to the caller.  The parameter is an
  1060. X *              optional comparison function (used in case the contents of
  1061. X *              the list are sorted).  The setup structure is then passed
  1062. X *              to dll_new when a new list is created.
  1063. X *
  1064. X ************************************************************************/
  1065. X
  1066. X#ifdef __STDC__
  1067. XDLL_SETUP dll_setup(int (*comp)(void*,void*),void *data)
  1068. X#else
  1069. XDLL_SETUP dll_setup(comp,data)
  1070. Xint    (*comp)();
  1071. Xvoid    *data;
  1072. X#endif
  1073. X{
  1074. X    SETUP    *retval;
  1075. X
  1076. X    COVER("dlsetup.c",1);
  1077. X    retval = (SETUP*) malloc(sizeof(SETUP));
  1078. X    if (retval != NULL)
  1079. X    {
  1080. X        COVER("dlsetup.c",2);
  1081. X        retval->comp = comp;
  1082. X        retval->data = data;
  1083. X    }
  1084. X    return (DLL_SETUP) retval;
  1085. X}
  1086. X
  1087. X/************************************************************************
  1088. X *
  1089. X * dll_freeSetup -- This function frees a doubly-linked list setup structure.
  1090. X *
  1091. X ************************************************************************/
  1092. X
  1093. X#ifdef __STDC__
  1094. Xvoid dll_freeSetup(DLL_SETUP setup)
  1095. X#else
  1096. Xvoid dll_freeSetup(setup)
  1097. XDLL_SETUP    setup;
  1098. X#endif
  1099. X{
  1100. X    COVER("dlsetup.c",3);
  1101. X    if (setup != NULL)
  1102. X    {
  1103. X        COVER("dlsetup.c",4);
  1104. X        free(setup);
  1105. X    }
  1106. X    return;
  1107. X}
  1108. X
  1109. X/************* End of file **************/
  1110. X
  1111. END_OF_src/list/dlsetup.c
  1112. if test 1855 -ne `wc -c <src/list/dlsetup.c`; then
  1113.     echo shar: \"src/list/dlsetup.c\" unpacked with wrong size!
  1114. fi
  1115. # end of overwriting check
  1116. fi
  1117. if test -f src/list/dlutil.c -a "${1}" != "-c" ; then 
  1118.   echo shar: Will not over-write existing file \"src/list/dlutil.c\"
  1119. else
  1120. echo shar: Extracting \"src/list/dlutil.c\" \(1792 characters\)
  1121. sed "s/^X//" >src/list/dlutil.c <<'END_OF_src/list/dlutil.c'
  1122. X/********************************************************************
  1123. X *
  1124. X * dlutil.c -- This file contains general-purpose utility functions
  1125. X *             needed by the doubly-linked list implementation.
  1126. X *
  1127. X * This file is part of a suite of programs called Software Chipset.
  1128. X * The source code for Software Chipset has been released into the
  1129. X * public domain by its author, Paul Sander.
  1130. X *
  1131. X ********************************************************************/
  1132. X
  1133. X#include <stdio.h>
  1134. X#include "dlpriv.h"
  1135. X
  1136. X/********************************************************************
  1137. X *
  1138. X * dll_locate -- This function performs a sequential search of a
  1139. X *               doubly-linked list for a specified key.  This function
  1140. X *               assumes the list is sorted.
  1141. X *
  1142. X ********************************************************************/
  1143. X
  1144. X#ifdef __STDC__
  1145. Xint dll_locate(LIST *list, void *key, NODE **node)
  1146. X#else
  1147. Xint dll_locate(list,key,node)
  1148. XLIST    *list;
  1149. Xvoid    *key;
  1150. XNODE    **node;
  1151. X#endif
  1152. X{
  1153. X    int    res;
  1154. X    NODE    *this;
  1155. X
  1156. X    COVER("dlutil.c",1);
  1157. X    this = list->last->next;
  1158. X    res = (*list->comp)(this->key,key);
  1159. X    while ((res < 0) && (this != list->last))
  1160. X    {
  1161. X        COVER("dlutil.c",2);
  1162. X        this = this->next;
  1163. X        res = (*list->comp)(this->key,key);
  1164. X    }
  1165. X    COVER("dlutil.c",3);
  1166. X    *node = this;
  1167. X    return res;
  1168. X}
  1169. X
  1170. X/********************************************************************
  1171. X *
  1172. X * dll_touch -- This function marks a list as having been modified.
  1173. X *              This affects the behavior of dll_next and dll_prev.
  1174. X *
  1175. X ********************************************************************/
  1176. X
  1177. X#ifdef __STDC__
  1178. Xvoid dll_touch(LIST *list)
  1179. X#else
  1180. Xvoid dll_touch(list)
  1181. XLIST    *list;
  1182. X#endif
  1183. X{
  1184. X    COVER("dlutil.c",4);
  1185. X    list->current = NULL;
  1186. X    list->nextOk = 0;
  1187. X    list->changed = 1;
  1188. X    return;
  1189. X}
  1190. X
  1191. X/************** End of file *************/
  1192. X
  1193. END_OF_src/list/dlutil.c
  1194. if test 1792 -ne `wc -c <src/list/dlutil.c`; then
  1195.     echo shar: \"src/list/dlutil.c\" unpacked with wrong size!
  1196. fi
  1197. # end of overwriting check
  1198. fi
  1199. echo shar: End of archive 2 \(of 10\).
  1200. cp /dev/null ark2isdone
  1201. MISSING=""
  1202. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1203.     if test ! -f ark${I}isdone ; then
  1204.     MISSING="${MISSING} ${I}"
  1205.     fi
  1206. done
  1207. if test "${MISSING}" = "" ; then
  1208.     echo You have unpacked all 10 archives.
  1209.     echo "Now edit common.mk and do a 'make all'"
  1210.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1211. else
  1212.     echo You still need to unpack the following archives:
  1213.     echo "        " ${MISSING}
  1214. fi
  1215. ##  End of shell archive.
  1216. exit 0
  1217.  
  1218.