home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / linkedlist / part01 next >
Encoding:
Text File  |  1992-05-30  |  59.9 KB  |  2,403 lines

  1. Newsgroups: comp.sources.misc
  2. From: anita@bouw.tno.nl (Anita Eijs)
  3. Subject:  v30i022:  linkedlist - Generic Linked List Tool, Part01/01
  4. Message-ID: <1992May29.203013.129@sparky.imd.sterling.com>
  5. X-Md4-Signature: 4ae1a71b6b6fd8ab870145ebe504b8b9
  6. Date: Fri, 29 May 1992 20:30:13 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: anita@bouw.tno.nl (Anita Eijs)
  10. Posting-number: Volume 30, Issue 22
  11. Archive-name: linkedlist/part01
  12. Environment: UNIX, MS-DOS, VAX/VMS, Macintosh
  13.  
  14. The subject of 'Generic Linked Lists' has raised several times now, so I
  15. decided to announce my Linked List Tool to the net.
  16.  
  17. The Linked List Tool is a package to define, create, update, query and
  18. delete one or more (nodes of) linked lists. The user doesn't have to take
  19. care of allocating a number of bytes for a node, inserting on the right
  20. place, deleting and freeing a node and so on.
  21.  
  22. Different kind of linked lists can be defined. In a singly linked list
  23. each node points to the next node, in a doubly linked list each node
  24. points also to the previous node. A chain is a list in which the last
  25. node has a NULL-pointer and in a circular linked list the last node
  26. points back to the first node.
  27.  
  28. The package consists of a set of C-functions :
  29.     lDef        define linked list
  30.     lInsNode    insert node
  31.     lGetNode    get node
  32.     lFndNode    find node
  33.     lUpdNode    update current node
  34.     lDelNode    delete node
  35.     lIndxNode    get node by index
  36.     lFlagNode    get node by flag
  37.     lInfo        get information about linked list
  38.     lInfoNode    get information about node
  39.     lDel        delete linked list
  40.     lDelAll        delete all linked lists
  41.     lDump        dump a linked list to a file
  42.     lUndump        undump a linked list from a file
  43.  
  44. Linked List Tool is ported to UNIX, MS-DOS, VAX/VMS and Macintosh.
  45. Please look at README and the manual pages for more detailed information !
  46.  
  47.         Anita
  48.  
  49.     +--------------------------------------------------------+
  50.     | TNO - BOUW, PO-box 49, 2600 AA  Delft, the Netherlands |
  51.     | FAX : +31 15 843990                     |
  52.     | E-MAIL : anita@bouw.tno.nl, Anita.Eijs@bouw.tno.nl     |
  53.     +--------------------------------------------------------+
  54. ---------- cut here ------------------------------------------------------------
  55. #! /bin/sh
  56. # This is a shell archive.  Remove anything before this line, then feed it
  57. # into a shell via "sh file" or similar.  To overwrite existing files,
  58. # type "sh file -c".
  59. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  60. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  61. # Contents:  README Doc Doc/Intro.1 Doc/lDef.1 Doc/lDel.1 Doc/lDelAll.1
  62. #   Doc/lDelNode.1 Doc/lDump.1 Doc/lFlagNode.1 Doc/lFndNode.1
  63. #   Doc/lGetNode.1 Doc/lIndxNode.1 Doc/lInfo.1 Doc/lInfoNode.1
  64. #   Doc/lInsNode.1 Doc/lUndump.1 Doc/lUpdNode.1 Makefile
  65. #   Tools_makerule example.c list.c list.h
  66. # Wrapped by kent@sparky on Fri May 29 15:25:17 1992
  67. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  68. echo If this archive is complete, you will see the following message:
  69. echo '          "shar: End of archive 1 (of 1)."'
  70. if test -f 'README' -a "${1}" != "-c" ; then 
  71.   echo shar: Will not clobber existing file \"'README'\"
  72. else
  73.   echo shar: Extracting \"'README'\" \(1541 characters\)
  74.   sed "s/^X//" >'README' <<'END_OF_FILE'
  75. X                Linked List Tool
  76. X                ================
  77. X
  78. X
  79. XThe distribution of the Linked List Tool (Version 0.7, March 1992) includes
  80. Xthe following files:
  81. X
  82. X    Doc/Intro.1        - [nt]roff manual pages
  83. X    Doc/lDef.1
  84. X    Doc/lDel.1
  85. X    Doc/lDelAll.1
  86. X    Doc/lDelNode.1
  87. X    Doc/lDump.1
  88. X    Doc/lFlagNode.1
  89. X    Doc/lFndNode.1
  90. X    Doc/lGetNode.1
  91. X    Doc/lIndxNode.1
  92. X    Doc/lInfo.1
  93. X    Doc/lInfoNode.1
  94. X    Doc/lInsNode.1
  95. X    Doc/lUndump.1
  96. X    Doc/lUpdNode.1
  97. X    Makefile        - Berkeley or System V Makefile
  98. X    README            - this file !
  99. X    Tools_makerule        - make rules for Makefile
  100. X    example.c        - example of use of Linked List routines
  101. X    list.c            - Linked List sources
  102. X    list.h            - Linked List defines and prototypes
  103. X
  104. X
  105. XThe installation of the Linked List Tool library is pretty simple :
  106. X
  107. X1)    Check the environment settings (TOOLS_HOME, DIR, LIB and RULE) in
  108. X    the Makefile.
  109. X
  110. X2)    Check the environment settings (RANLIB) in the Tools_makerule.
  111. X
  112. X3)    Enter 'make newlib' at the UNIX prompt.
  113. X
  114. X4)    Enter 'make test' or 'make example' to create the executable of
  115. X    the program 'example' at the UNIX prompt.
  116. X
  117. X
  118. XI also ported the Linked List Tool to MSDOS, to VAX-VMS and to Macintosh.
  119. XI didn't create a library on those machines, but I treated list.c and list.h
  120. Xthe same as all the other source-files (*.[ch]) of the program.
  121. X
  122. X
  123. XThe Linked List Tool is in the public domain. If you have any comments,
  124. Xsuggestions, or find any bugs, or make any changes you'd like to share,
  125. Xplease let me know.
  126. X
  127. X
  128. XAnita Eijs    (anita@bouw.tno.nl, Anita.Eijs@bouw.tno.nl)
  129. XTNO - BOUW - BouwInformatica
  130. XP.O. Box 49
  131. X2600 AA Delft
  132. XThe Netherlands
  133. XFAX : +31 15 843990
  134. END_OF_FILE
  135.   if test 1541 -ne `wc -c <'README'`; then
  136.     echo shar: \"'README'\" unpacked with wrong size!
  137.   fi
  138.   # end of 'README'
  139. fi
  140. if test ! -d 'Doc' ; then
  141.     echo shar: Creating directory \"'Doc'\"
  142.     mkdir 'Doc'
  143. fi
  144. if test -f 'Doc/Intro.1' -a "${1}" != "-c" ; then 
  145.   echo shar: Will not clobber existing file \"'Doc/Intro.1'\"
  146. else
  147.   echo shar: Extracting \"'Doc/Intro.1'\" \(6595 characters\)
  148.   sed "s/^X//" >'Doc/Intro.1' <<'END_OF_FILE'
  149. X'.so tmac.clman
  150. X.TH "Intro"
  151. X.IX Intro
  152. X.SH NAME
  153. XIntro - Introduction to Linked List Tool.
  154. X.SH DESCRIPTION
  155. XThe Linked List Tool is a package to define, create, update, query and
  156. Xdelete one or more (nodes of) linked lists. The user doesn't have to take
  157. Xcare of allocating a number of bytes
  158. Xfor a node, inserting on the right place, deleting and freeing a
  159. Xnode and so on.
  160. X.br
  161. XDifferent kind of linked lists can be defined.
  162. XIn a \fIsingly\fP linked list each node
  163. Xpoints to the next node, in a \fIdoubly\fP linked list each node points also to
  164. Xthe previous node. A \fIchain\fP is a list in which the last
  165. Xnode has a NULL-pointer and in a \fIcircular\fP linked list the last node
  166. Xpoints back to the first node.
  167. X.br
  168. XThe package consists of the following routines :
  169. X.nf
  170. X.if t .ta 0.2i 1.3i
  171. X    lDef    define linked list
  172. X    lInsNode    insert node
  173. X    lGetNode    get node
  174. X    lFndNode    find node
  175. X    lUpdNode    update current node
  176. X    lDelNode    delete node
  177. X    lIndxNode    get node by index
  178. X    lFlagNode    get node by flag
  179. X    lInfo    get information about linked list
  180. X    lInfoNode    get information about node
  181. X    lDel    delete linked list
  182. X    lDelAll    delete all linked lists
  183. X    lDump    dump a linked list to a file
  184. X    lUndump    undump a linked list from a file
  185. X.fi
  186. X.SH ERROR CODES
  187. X.if t .ta 0.2i 0.6i
  188. XHere follows an enumeration of the possible error codes, for each
  189. Xfunction-call is specified which error codes could be expected. The marked
  190. Xerrors (*) will also be written to the error-file \fI=listError=\fP.
  191. X.nf
  192. X    -1    parameter \fIsd\fP has wrong value (*)
  193. X    -2    parameter \fIcc\fP has wrong value (*)
  194. X    -3    parameter \fIwhere\fP has wrong value (*)
  195. X    -4    parameter \fIwhich\fP has wrong value (*)
  196. X    -5    list identifier is unknown (*)
  197. X    -6    function name is unknown (*)
  198. X    -7    there are no linked lists defined (*)
  199. X    -8    linked list doesn't contain any nodes
  200. X    -9    end of list reached
  201. X    -10    node not found
  202. X    -11    backward searching / retrieving not possible for singly linked list (*)
  203. X    -12    size of expected data and size of node are not equal (*)
  204. X    -13    index out of range (*)
  205. X    -14    can't open linked list dump file for writing or reading (*)
  206. X.fi
  207. X.SH LIBRARY
  208. X~anita/Tools/Lib/list.a
  209. X.SH INCLUDE FILE
  210. X~anita/Tools/List/list.h
  211. X.SH PORTABILITY
  212. XThe Linked List Tool is a very portable tool. The tool is developed on UNIX
  213. Xand ported to MSDOS, to VAX-VMS and to Macintosh. On those 'ported' machines
  214. Xthe library isn't created, but list.c and list.h were treated the same as
  215. Xall the other source-files (*.[ch]) of the program, which used the Linked
  216. XList Tool.
  217. X.SH EXAMPLE
  218. X.if t .ta 0.3i 0.6i 0.9i 1.2i 3.2i 4.2i 4.5i 4.8i
  219. X.nf
  220. X#include    "list.h"
  221. X
  222. Xint    search();
  223. X
  224. Xtypedef struct rapport {
  225. X    char        nummer[9];
  226. X    char        title[30];
  227. X    char        author[15];
  228. X    int        date;
  229. X} rapport;
  230. X
  231. Xmain()
  232. X{
  233. X    int            id, code, dat, size = sizeof(rapport);
  234. X    rapport        rap;
  235. X
  236. X    id = lDef(SINGLY, CHAIN);
  237. X
  238. X    strcpy(rap.nummer, "B-89-100");
  239. X    strcpy(rap.title, "Book 1");
  240. X    strcpy(rap.author, "People");
  241. X    rap.date = 890129;
  242. X    lInsNode(id, FIRST, &rap, size, 1);
  243. X
  244. X    strcpy(rap.nummer, "B-89-101");
  245. X    strcpy(rap.title, "Book 2");
  246. X    strcpy(rap.author, "More People");
  247. X    rap.date = 890130;
  248. X    lInsNode(id, FIRST, &rap, size, 2);
  249. X
  250. X    strcpy(rap.nummer, "B-89-102");
  251. X    strcpy(rap.title, "Book 3");
  252. X    strcpy(rap.author, "Lots of People");
  253. X    rap.date = 890131;
  254. X    lInsNode(id, LAST, &rap, size, 3);
  255. X
  256. X    printf("lGetNode\\n");
  257. X    code = lGetNode(id, FIRST, &rap, size);
  258. X    prRap(code, &rap);
  259. X    code = lGetNode(id, NEXT, &rap, size);
  260. X    prRap(code, &rap);
  261. X    code = lGetNode(id, NEXT, &rap, size);
  262. X    prRap(code, &rap);
  263. X    code = lGetNode(id, NEXT, &rap, size);
  264. X    prRap(code, &rap);
  265. X
  266. X    printf("lIndxNode\\n");
  267. X    code = lIndxNode(id, 4, &rap, size);
  268. X    prRap(code, &rap);
  269. X    code = lIndxNode(id, 2, &rap, size);
  270. X    prRap(code, &rap);
  271. X    code = lIndxNode(id, -1, &rap, size);
  272. X    prRap(code, &rap);
  273. X    code = lIndxNode(id, 3, &rap, size);
  274. X    prRap(code, &rap);
  275. X
  276. X    printf("lFndNode\\n");
  277. X    dat = 890129;
  278. X    code = lFndNode(id, FIRST, search, &dat, &rap, size);
  279. X    prRap(code, &rap);
  280. X    code = lFndNode(id, NEXT, search, &dat, &rap, size);
  281. X    prRap(code, &rap);
  282. X    code = lFndNode(id, NEXT, search, &dat, &rap, size);
  283. X    prRap(code, &rap);
  284. X
  285. X    code = lDump(id, "/tmp/.dump");
  286. X    printf("lDump : %d\\n", code);
  287. X
  288. X    lDel(id);
  289. X
  290. X    id = lUndump("/tmp/.dump");
  291. X    printf("lUndump : %d\\n", id);
  292. X    
  293. X    strcpy(rap.nummer, "B-89-001");
  294. X    strcpy(rap.title, "Book 4");
  295. X    strcpy(rap.author, "The Author");
  296. X    rap.date = 891127;
  297. X    lInsNode(id, FIRST, &rap, size, 4);
  298. X    
  299. X    printf("lGetNode\n");
  300. X    code = lGetNode(id, FIRST, &rap, size);
  301. X    prRap(code, &rap);
  302. X    code = lGetNode(id, NEXT, &rap, size);
  303. X    prRap(code, &rap);
  304. X    code = lGetNode(id, NEXT, &rap, size);
  305. X    prRap(code, &rap);
  306. X    code = lGetNode(id, NEXT, &rap, size);
  307. X    prRap(code, &rap);
  308. X
  309. X    printf("lFlagNode\n");
  310. X    code = lFlagNode(id, FIRST, &rap, size);
  311. X    prRap(code, &rap);
  312. X    code = lFlagNode(id, NEXT, &rap, size);
  313. X    prRap(code, &rap);
  314. X    code = lFlagNode(id, NEXT, &rap, size);
  315. X    prRap(code, &rap);
  316. X    code = lFlagNode(id, NEXT, &rap, size);
  317. X    prRap(code, &rap);
  318. X
  319. X    lDelAll();
  320. X}
  321. X
  322. Xint
  323. Xsearch(date, rpprt)
  324. Xint            *date;
  325. Xrapport        *rpprt;
  326. X{
  327. X    if (rpprt->date > *date)
  328. X        return(FOUND);
  329. X    else
  330. X        return(NOT_FOUND);
  331. X}
  332. X
  333. XprRap(code, rpprt)
  334. Xint            code;
  335. Xrapport        *rpprt;
  336. X{
  337. X    if (code >= 0)
  338. X        printf("rapport :'%s' '%s' '%s' '%d'\\n", rpprt->nummer, rpprt->title,
  339. X            rpprt->author, rpprt->date);
  340. X    else
  341. X        printf("Return code = %d\\n", code);
  342. X}
  343. X.fi
  344. X.sp 2
  345. XThis example program produces the following output :
  346. X.nf
  347. X    lGetNode
  348. X    rapport :'B-89-101' 'Book 2' 'More People' '890130'
  349. X    rapport :'B-89-100' 'Book 1' 'People' '890129'
  350. X    rapport :'B-89-102' 'Book 3' 'Lots of People' '890131'
  351. X    Return code = -9
  352. X    lIndxNode
  353. X    Return code = -13
  354. X    rapport :'B-89-100' 'Book 1' 'People' '890129'
  355. X    Return code = -13
  356. X    rapport :'B-89-102' 'Book 3' 'Lots of People' '890131'
  357. X    lFndNode
  358. X    rapport :'B-89-101' 'Book 2' 'More People' '890130'
  359. X    rapport :'B-89-102' 'Book 3' 'Lots of People' '890131'
  360. X    Return code = -10
  361. X    lDump : 0
  362. X    lUndump : 1
  363. X    lGetNode
  364. X    rapport :'B-89-001' 'Book 4' 'The Author' '891127'
  365. X    rapport :'B-89-101' 'Book 2' 'More People' '890130'
  366. X    rapport :'B-89-100' 'Book 1' 'People' '890129'
  367. X    rapport :'B-89-102' 'Book 3' 'Lots of People' '890131'
  368. X    lFlagNode
  369. X    rapport :'B-89-100' 'Book 1' 'People' '890129'
  370. X    rapport :'B-89-102' 'Book 3' 'Lots of People' '890131'
  371. X    rapport :'B-89-101' 'Book 2' 'More People' '890130'
  372. X    Return code = -10
  373. X.fi
  374. X.SH VERSION
  375. XLinked List Tool 0.7, March 1992.
  376. X.SH PUBLIC DOMAIN
  377. XThe Linked List Tool is in the public domain. If you have any comments,
  378. Xsuggestions, or find any bugs, or make any changes you'd like to share,
  379. Xplease let me know.
  380. X.SH AUTHOR
  381. XCopyright (c) 1992 by Anita Eijs (anita@bouw.tno.nl, Anita.Eijs@bouw.tno.nl).
  382. X.sp 1
  383. X.nf
  384. XTNO - Bouw - BouwInformatica
  385. XP.O. Box 49
  386. X2600 AA Delft
  387. XThe Netherlands
  388. X.fi
  389. END_OF_FILE
  390.   if test 6595 -ne `wc -c <'Doc/Intro.1'`; then
  391.     echo shar: \"'Doc/Intro.1'\" unpacked with wrong size!
  392.   fi
  393.   # end of 'Doc/Intro.1'
  394. fi
  395. if test -f 'Doc/lDef.1' -a "${1}" != "-c" ; then 
  396.   echo shar: Will not clobber existing file \"'Doc/lDef.1'\"
  397. else
  398.   echo shar: Extracting \"'Doc/lDef.1'\" \(927 characters\)
  399.   sed "s/^X//" >'Doc/lDef.1' <<'END_OF_FILE'
  400. X'.so tmac.clman
  401. X.TH "lDef"
  402. X.IX lDef
  403. X.SH NAME
  404. XlDef - Define linked list.
  405. X.SH SYNOPSIS
  406. Xint
  407. X.BR "lDef" "(sd, cc)"
  408. X.br
  409. X.RT
  410. X.RP
  411. XIn    int    sd    singly or doubly linked list
  412. X.RP
  413. XIn    int    cc    chain or circular linked list
  414. X.DT
  415. X.SH DESCRIPTION
  416. XTo define a linked list use \fBlDef\fP. It is possible to define a
  417. Xsingly or doubly linked list and a chain or circular linked list.
  418. XThe routine returns the identifier of the defined linked list (\(>= 1),
  419. Xwhich must be used in the other routines of the linked list tool.
  420. X.SH PARAMETER DEFINITIONS
  421. X.if t .ta 0.2i 1.5i
  422. X\fIsd\fP :
  423. X.nf
  424. X    SINGLY    singly linked list, each node points to the next node
  425. X    DOUBLY    doubly linked list, each node points to the previous and
  426. X        the next node
  427. X.fi
  428. X\fIcc\fP :
  429. X.nf
  430. X    CHAIN    chain linked list, last node has a NULL-pointer
  431. X    CIRCULAR    circular linked list, last node points back to the first node
  432. X.fi
  433. X.SH ERROR CODES
  434. X-1, -2
  435. X.SH AUTHOR
  436. XAnita Eijs (TNO - Bouw - BouwInformatica)
  437. END_OF_FILE
  438.   if test 927 -ne `wc -c <'Doc/lDef.1'`; then
  439.     echo shar: \"'Doc/lDef.1'\" unpacked with wrong size!
  440.   fi
  441.   # end of 'Doc/lDef.1'
  442. fi
  443. if test -f 'Doc/lDel.1' -a "${1}" != "-c" ; then 
  444.   echo shar: Will not clobber existing file \"'Doc/lDel.1'\"
  445. else
  446.   echo shar: Extracting \"'Doc/lDel.1'\" \(322 characters\)
  447.   sed "s/^X//" >'Doc/lDel.1' <<'END_OF_FILE'
  448. X'.so tmac.clman
  449. X.TH "lDel"
  450. X.IX lDel
  451. X.SH NAME
  452. XlDel - Delete linked list.
  453. X.SH SYNOPSIS
  454. Xint
  455. X.BR "lDel" "(id)"
  456. X.br
  457. X.RT
  458. X.RP
  459. XIn    int    id    identifier of linked list
  460. X.DT
  461. X.SH DESCRIPTION
  462. X\fBlDel\fP deletes a linked list. The routine returns 0 (zero) on success.
  463. X.SH ERROR CODES
  464. X-5
  465. X.SH AUTHOR
  466. XAnita Eijs (TNO - Bouw - BouwInformatica)
  467. END_OF_FILE
  468.   if test 322 -ne `wc -c <'Doc/lDel.1'`; then
  469.     echo shar: \"'Doc/lDel.1'\" unpacked with wrong size!
  470.   fi
  471.   # end of 'Doc/lDel.1'
  472. fi
  473. if test -f 'Doc/lDelAll.1' -a "${1}" != "-c" ; then 
  474.   echo shar: Will not clobber existing file \"'Doc/lDelAll.1'\"
  475. else
  476.   echo shar: Extracting \"'Doc/lDelAll.1'\" \(299 characters\)
  477.   sed "s/^X//" >'Doc/lDelAll.1' <<'END_OF_FILE'
  478. X'.so tmac.clman
  479. X.TH "lDelAll"
  480. X.IX lDelAll
  481. X.SH NAME
  482. XlDelAll - Delete all linked lists.
  483. X.SH SYNOPSIS
  484. Xint
  485. X.BR "lDelAll" "()"
  486. X.br
  487. X.DT
  488. X.SH DESCRIPTION
  489. X\fBlDelAll\fP deletes all linked lists. The routine returns 0 (zero)
  490. Xon success.
  491. X.SH ERROR CODES
  492. X-7
  493. X.SH AUTHOR
  494. XAnita Eijs (TNO - Bouw - BouwInformatica)
  495. END_OF_FILE
  496.   if test 299 -ne `wc -c <'Doc/lDelAll.1'`; then
  497.     echo shar: \"'Doc/lDelAll.1'\" unpacked with wrong size!
  498.   fi
  499.   # end of 'Doc/lDelAll.1'
  500. fi
  501. if test -f 'Doc/lDelNode.1' -a "${1}" != "-c" ; then 
  502.   echo shar: Will not clobber existing file \"'Doc/lDelNode.1'\"
  503. else
  504.   echo shar: Extracting \"'Doc/lDelNode.1'\" \(664 characters\)
  505.   sed "s/^X//" >'Doc/lDelNode.1' <<'END_OF_FILE'
  506. X'.so tmac.clman
  507. X.TH "lDelNode"
  508. X.IX lDelNode
  509. X.SH NAME
  510. XlDelNode - Delete node.
  511. X.SH SYNOPSIS
  512. Xint
  513. X.BR "lDelNode" "(id, which)"
  514. X.br
  515. X.RT
  516. X.RP
  517. XIn    int    id    identifier of linked list
  518. X.RP
  519. XIn    int    which    which node must be deleted
  520. X.DT
  521. X.SH DESCRIPTION
  522. X\fBlDelNode\fP deletes a node from a linked list. Which node must be
  523. Xdeleted can be specified by \fIwhich\fP. The first, the current
  524. Xand the last node of a linked list can be deleted. The routine returns
  525. X0 (zero) on success.
  526. X.SH PARAMETER DEFINITIONS
  527. X.if t .ta 0.2i 1.5i
  528. X\fIwhich\fP :
  529. X.nf
  530. X    FIRST    first node
  531. X    CURRENT    current node
  532. X    LAST    last node
  533. X.fi
  534. X.SH ERROR CODES
  535. X-4, -5, -8
  536. X.SH AUTHOR
  537. XAnita Eijs (TNO - Bouw - BouwInformatica)
  538. END_OF_FILE
  539.   if test 664 -ne `wc -c <'Doc/lDelNode.1'`; then
  540.     echo shar: \"'Doc/lDelNode.1'\" unpacked with wrong size!
  541.   fi
  542.   # end of 'Doc/lDelNode.1'
  543. fi
  544. if test -f 'Doc/lDump.1' -a "${1}" != "-c" ; then 
  545.   echo shar: Will not clobber existing file \"'Doc/lDump.1'\"
  546. else
  547.   echo shar: Extracting \"'Doc/lDump.1'\" \(755 characters\)
  548.   sed "s/^X//" >'Doc/lDump.1' <<'END_OF_FILE'
  549. X'.so tmac.clman
  550. X.TH "lDump"
  551. X.IX lDump
  552. X.SH NAME
  553. XlDump - Dump a linked list to a file.
  554. X.SH SYNOPSIS
  555. Xint
  556. X.BR "lDump" "(id, file)"
  557. X.br
  558. X.RT
  559. X.RP
  560. XIn    int    id    identifier of linked list
  561. X.RP
  562. XIn    char    *file    name of linked list dump file
  563. X.DT
  564. X.SH DESCRIPTION
  565. X\fBlDump\fP is a linked list dumping utility. It allows the user to store
  566. Xlinked list data in a specially formatted file, so the linked list data can
  567. Xbe used within another program session. This file can be read by the linked
  568. Xlist undumping utility lUndump. The routine returns 0 (zero) on success.
  569. X.br
  570. XDon't use pointers within your data structure, because only the pointers
  571. Xwill be written in the dump file, not the data pointed to.
  572. X.SH ERROR CODES
  573. X-5, -14
  574. X.SH AUTHOR
  575. XAnita Eijs (TNO - Bouw - BouwInformatica)
  576. END_OF_FILE
  577.   if test 755 -ne `wc -c <'Doc/lDump.1'`; then
  578.     echo shar: \"'Doc/lDump.1'\" unpacked with wrong size!
  579.   fi
  580.   # end of 'Doc/lDump.1'
  581. fi
  582. if test -f 'Doc/lFlagNode.1' -a "${1}" != "-c" ; then 
  583.   echo shar: Will not clobber existing file \"'Doc/lFlagNode.1'\"
  584. else
  585.   echo shar: Extracting \"'Doc/lFlagNode.1'\" \(725 characters\)
  586.   sed "s/^X//" >'Doc/lFlagNode.1' <<'END_OF_FILE'
  587. X'.so tmac.clman
  588. X.TH "lFlagNode"
  589. X.IX lFlagNode
  590. X.SH NAME
  591. XlFlagNode - Get node by flag.
  592. X.SH SYNOPSIS
  593. Xint
  594. X.BR "lFlagNode" "(id, flag, data, size)"
  595. X.br
  596. X.RT
  597. X.RP
  598. XIn    int    id    identifier of linked list
  599. X.RP
  600. XIn    int    flag    flag of node which must be retrieved
  601. X.RP
  602. XOut    Byte    *data    data of node
  603. X.RP
  604. XIn    int    size    size of data
  605. X.DT
  606. X.SH DESCRIPTION
  607. X\fBlFlagNode\fP gets the data of a 'flagged' node of a linked list. Which
  608. Xnode must be retrieved can be specified by a \fIflag\fP. The first node with
  609. Xthe specified flag will be returned.
  610. X.br
  611. XWhen the retrieved node is the first or the last node, the return code
  612. Xwill have the value FIRST or LAST, otherwise zero.
  613. X.SH ERROR CODES
  614. X-5, -8, -10, -12
  615. X.SH AUTHOR
  616. XAnita Eijs (TNO - Bouw - BouwInformatica)
  617. END_OF_FILE
  618.   if test 725 -ne `wc -c <'Doc/lFlagNode.1'`; then
  619.     echo shar: \"'Doc/lFlagNode.1'\" unpacked with wrong size!
  620.   fi
  621.   # end of 'Doc/lFlagNode.1'
  622. fi
  623. if test -f 'Doc/lFndNode.1' -a "${1}" != "-c" ; then 
  624.   echo shar: Will not clobber existing file \"'Doc/lFndNode.1'\"
  625. else
  626.   echo shar: Extracting \"'Doc/lFndNode.1'\" \(1383 characters\)
  627.   sed "s/^X//" >'Doc/lFndNode.1' <<'END_OF_FILE'
  628. X'.so tmac.clman
  629. X.TH "lFndNode"
  630. X.IX lFndNode
  631. X.SH NAME
  632. XlFndNode - Find node.
  633. X.SH SYNOPSIS
  634. Xint
  635. X.BR "lFndNode" "(id, where, func, ptr, data, size)"
  636. X.br
  637. X.RT
  638. X.RP
  639. XIn    int    id    identifier of linked list
  640. X.RP
  641. XIn    int    where    from where must be searched
  642. X.RP
  643. XIn    int    (*func)()    function for checking the data on conditions
  644. X.RP
  645. XIn    Byte    *ptr    data for comparison in function
  646. X.RP
  647. XOut    Byte    *data    data of node
  648. X.RP
  649. XIn    int    size    size of data
  650. X.DT
  651. X.SH DESCRIPTION
  652. X\fBlFndNode\fP searches a node from the linked list, using the user
  653. Xdefined function \fIfunc\fP, which checks the data of a node on conditions.
  654. XThis function must have two parameters, a pointer to the data to compare with
  655. Xand a pointer to the data of a node. The possible return values are FOUND or
  656. XNOT_FOUND. From where the node must be
  657. Xsearched can be specified by \fIwhere\fP. A node can be searched forward
  658. Xfrom the
  659. Xbeginning of the list or from the current node and backward from the current
  660. Xnode or from the end of the list.
  661. X.br
  662. XWhen a singly linked list is defined only forward searching is possible.
  663. X.br
  664. XWhen the found node is the first or the last node, the return code will
  665. Xhave the value FIRST or LAST.
  666. X.SH PARAMETER DEFINITIONS
  667. X.if t .ta 0.2i 1.5i
  668. X\fIwhere\fP :
  669. X.nf
  670. X    FIRST    first node
  671. X    PREVIOUS    previous node
  672. X    NEXT    next node
  673. X    LAST    last node
  674. X.fi
  675. X.SH ERROR CODES
  676. X-3, -5, -6, -8, -10, -11
  677. X.SH AUTHOR
  678. XAnita Eijs (TNO - Bouw - BouwInformatica)
  679. END_OF_FILE
  680.   if test 1383 -ne `wc -c <'Doc/lFndNode.1'`; then
  681.     echo shar: \"'Doc/lFndNode.1'\" unpacked with wrong size!
  682.   fi
  683.   # end of 'Doc/lFndNode.1'
  684. fi
  685. if test -f 'Doc/lGetNode.1' -a "${1}" != "-c" ; then 
  686.   echo shar: Will not clobber existing file \"'Doc/lGetNode.1'\"
  687. else
  688.   echo shar: Extracting \"'Doc/lGetNode.1'\" \(1095 characters\)
  689.   sed "s/^X//" >'Doc/lGetNode.1' <<'END_OF_FILE'
  690. X'.so tmac.clman
  691. X.TH "lGetNode"
  692. X.IX lGetNode
  693. X.SH NAME
  694. XlGetNode - Get node.
  695. X.SH SYNOPSIS
  696. Xint
  697. X.BR "lGetNode" "(id, which, data, size)"
  698. X.br
  699. X.RT
  700. X.RP
  701. XIn    int    id    identifier of linked list
  702. X.RP
  703. XIn    int    which    which node must be retrieved
  704. X.RP
  705. XOut    Byte    *data    data of node
  706. X.RP
  707. XIn    int    size    size of data
  708. X.DT
  709. X.SH DESCRIPTION
  710. X\fBlGetNode\fP gets the data of a node of a linked list. Which node must be
  711. Xretrieved can be specified by \fIwhich\fP. The first node,
  712. Xthe current node, the node before or after the current node
  713. Xand the node at the end of the list can be retrieved.
  714. X.br
  715. XWhen a singly linked list is defined only forward retrieving is possible,
  716. Xthe previous node can't be get.
  717. X.br
  718. XWhen the retrieved node is the first or the last node, the return code
  719. Xwill have the value FIRST or LAST. For the other nodes the routine returns
  720. X0 (zero) on success.
  721. X.SH PARAMETER DEFINITIONS
  722. X.if t .ta 0.2i 1.5i
  723. X\fIwhich\fP :
  724. X.nf
  725. X    FIRST    first node
  726. X    PREVIOUS    previous node
  727. X    CURRENT    current node
  728. X    NEXT    next node
  729. X    LAST    last node
  730. X.fi
  731. X.SH ERROR CODES
  732. X-4, -5, -8, -9, -11, -12
  733. X.SH AUTHOR
  734. XAnita Eijs (TNO - Bouw - BouwInformatica)
  735. END_OF_FILE
  736.   if test 1095 -ne `wc -c <'Doc/lGetNode.1'`; then
  737.     echo shar: \"'Doc/lGetNode.1'\" unpacked with wrong size!
  738.   fi
  739.   # end of 'Doc/lGetNode.1'
  740. fi
  741. if test -f 'Doc/lIndxNode.1' -a "${1}" != "-c" ; then 
  742.   echo shar: Will not clobber existing file \"'Doc/lIndxNode.1'\"
  743. else
  744.   echo shar: Extracting \"'Doc/lIndxNode.1'\" \(719 characters\)
  745.   sed "s/^X//" >'Doc/lIndxNode.1' <<'END_OF_FILE'
  746. X'.so tmac.clman
  747. X.TH "lIndxNode"
  748. X.IX lIndxNode
  749. X.SH NAME
  750. XlIndxNode - Get node by index.
  751. X.SH SYNOPSIS
  752. Xint
  753. X.BR "lIndxNode" "(id, index, data, size)"
  754. X.br
  755. X.RT
  756. X.RP
  757. XIn    int    id    identifier of linked list
  758. X.RP
  759. XIn    int    index    index of node which must be retrieved
  760. X.RP
  761. XOut    Byte    *data    data of node
  762. X.RP
  763. XIn    int    size    size of data
  764. X.DT
  765. X.SH DESCRIPTION
  766. X\fBlIndxNode\fP gets the data of an indexed node of a linked list. Which
  767. Xnode must be retrieved can be specified by \fIindex\fP (\(>= 1).
  768. X.br
  769. XWhen the retrieved node is the first or the last node, the return code
  770. Xwill have the value FIRST or LAST. For the other nodes the routine returns
  771. X0 (zero) on success.
  772. X.SH ERROR CODES
  773. X-5, -8, -13
  774. X.SH AUTHOR
  775. XAnita Eijs (TNO - Bouw - BouwInformatica)
  776. END_OF_FILE
  777.   if test 719 -ne `wc -c <'Doc/lIndxNode.1'`; then
  778.     echo shar: \"'Doc/lIndxNode.1'\" unpacked with wrong size!
  779.   fi
  780.   # end of 'Doc/lIndxNode.1'
  781. fi
  782. if test -f 'Doc/lInfo.1' -a "${1}" != "-c" ; then 
  783.   echo shar: Will not clobber existing file \"'Doc/lInfo.1'\"
  784. else
  785.   echo shar: Extracting \"'Doc/lInfo.1'\" \(646 characters\)
  786.   sed "s/^X//" >'Doc/lInfo.1' <<'END_OF_FILE'
  787. X'.so tmac.clman
  788. X.TH "lInfo"
  789. X.IX lInfo
  790. X.SH NAME
  791. XlInfo - Get information about linked list.
  792. X.SH SYNOPSIS
  793. Xint
  794. X.BR "lInfo" "(id, sd, cc, n)"
  795. X.br
  796. X.RT
  797. X.RP
  798. XIn    int    id    identifier of linked list
  799. X.RP
  800. XOut    int    *sd    singly or doubly linked list
  801. X.RP
  802. XOut    int    *cc    chain or circular linked list
  803. X.RP
  804. XOut    int    *n    number of nodes
  805. X.DT
  806. X.SH DESCRIPTION
  807. X\fBlInfo\fP returns some information about a linked list. The type of
  808. Xthe linked list (\fIsd\fP and \fIcc\fP, defined by the user)
  809. Xand the number of nodes added
  810. Xto the linked list (\fIn\fP). The routine returns 0 (zero) on success.
  811. X.SH ERROR CODES
  812. X.if t .ta 0.5i
  813. X-5
  814. X.SH AUTHOR
  815. XAnita Eijs (TNO - Bouw - BouwInformatica)
  816. END_OF_FILE
  817.   if test 646 -ne `wc -c <'Doc/lInfo.1'`; then
  818.     echo shar: \"'Doc/lInfo.1'\" unpacked with wrong size!
  819.   fi
  820.   # end of 'Doc/lInfo.1'
  821. fi
  822. if test -f 'Doc/lInfoNode.1' -a "${1}" != "-c" ; then 
  823.   echo shar: Will not clobber existing file \"'Doc/lInfoNode.1'\"
  824. else
  825.   echo shar: Extracting \"'Doc/lInfoNode.1'\" \(1135 characters\)
  826.   sed "s/^X//" >'Doc/lInfoNode.1' <<'END_OF_FILE'
  827. X'.so tmac.clman
  828. X.TH "lInfoNode"
  829. X.IX lInfoNode
  830. X.SH NAME
  831. XlInfoNode - Get information about node.
  832. X.SH SYNOPSIS
  833. Xint
  834. X.BR "lInfoNode" "(id, which, size, flag)"
  835. X.br
  836. X.RT
  837. X.RP
  838. XIn    int    id    identifier of linked list
  839. X.RP
  840. XIn    int    which    which node must be inspected
  841. X.RP
  842. XOut    int    *size    size of data of node
  843. X.RP
  844. XOut    int    *flag    user information flag
  845. X.DT
  846. X.SH DESCRIPTION
  847. X\fBlInfoNode\fP returns some information about a node.
  848. XThe size of the data of the node (\fIsize\fP)
  849. Xand the user information flag (\fIflag\fP).
  850. XOf which node the information must be given can be specified by \fIwhich\fP.
  851. XThe first node, the current node, the node before or
  852. Xafter the current node and the node at the end of the list can be inspected.
  853. XThe routine returns 0 (zero) on success.
  854. X.br
  855. XWhen a singly linked list is defined only forward information retrieving
  856. Xis possible, the previous node can't be inspected.
  857. X.SH PARAMETER DEFINITIONS
  858. X.if t .ta 0.2i 1.5i
  859. X\fIwhich\fP :
  860. X.nf
  861. X    FIRST    first node
  862. X    PREVIOUS    previous node
  863. X    CURRENT    current node
  864. X    NEXT    next node
  865. X    LAST    last node
  866. X.fi
  867. X.SH ERROR CODES
  868. X.if t .ta 0.5i
  869. X-4, -5, -8 -9, -11
  870. X.SH AUTHOR
  871. XAnita Eijs (TNO - Bouw - BouwInformatica)
  872. END_OF_FILE
  873.   if test 1135 -ne `wc -c <'Doc/lInfoNode.1'`; then
  874.     echo shar: \"'Doc/lInfoNode.1'\" unpacked with wrong size!
  875.   fi
  876.   # end of 'Doc/lInfoNode.1'
  877. fi
  878. if test -f 'Doc/lInsNode.1' -a "${1}" != "-c" ; then 
  879.   echo shar: Will not clobber existing file \"'Doc/lInsNode.1'\"
  880. else
  881.   echo shar: Extracting \"'Doc/lInsNode.1'\" \(1031 characters\)
  882.   sed "s/^X//" >'Doc/lInsNode.1' <<'END_OF_FILE'
  883. X'.so tmac.clman
  884. X.TH "lInsNode"
  885. X.IX lInsNode
  886. X.SH NAME
  887. XlInsNode - Insert node.
  888. X.SH SYNOPSIS
  889. Xint
  890. X.BR "lInsNode" "(id, where, data, size, flag)"
  891. X.br
  892. X.RT
  893. X.RP
  894. XIn    int    id    identifier of linked list
  895. X.RP
  896. XIn    int    where    place where node must be inserted
  897. X.RP
  898. XIn    Byte    *data    data of node
  899. X.RP
  900. XIn    int    size    size of data
  901. X.RP
  902. XIn    int    flag    user information flag
  903. X.DT
  904. X.SH DESCRIPTION
  905. X\fBlInsNode\fP inserts a node in a linked list. Where the node must be
  906. Xinserted can be specified by \fIwhere\fP. A node can be added at the
  907. Xfront of the list, before or after the current node
  908. Xand at the end of the list.
  909. XFor each node a flag can be set by the user, e.g. to identify the node or
  910. Xthe type of node. When the flag identifies the node you can retrieve the
  911. Xnodes by flag (lFlagNode). The routine returns 0 (zero) on success.
  912. X.SH PARAMETER DEFINITIONS
  913. X.if t .ta 0.2i 1.5i
  914. X\fIwhere\fP :
  915. X.nf
  916. X    FIRST    as first node
  917. X    BEFORE    before current node
  918. X    AFTER    after current node
  919. X    LAST    as last node
  920. X.fi
  921. X.SH ERROR CODES
  922. X-3, -5
  923. X.SH AUTHOR
  924. XAnita Eijs (TNO - Bouw - BouwInformatica)
  925. END_OF_FILE
  926.   if test 1031 -ne `wc -c <'Doc/lInsNode.1'`; then
  927.     echo shar: \"'Doc/lInsNode.1'\" unpacked with wrong size!
  928.   fi
  929.   # end of 'Doc/lInsNode.1'
  930. fi
  931. if test -f 'Doc/lUndump.1' -a "${1}" != "-c" ; then 
  932.   echo shar: Will not clobber existing file \"'Doc/lUndump.1'\"
  933. else
  934.   echo shar: Extracting \"'Doc/lUndump.1'\" \(719 characters\)
  935.   sed "s/^X//" >'Doc/lUndump.1' <<'END_OF_FILE'
  936. X'.so tmac.clman
  937. X.TH "lUndump"
  938. X.IX lUndump
  939. X.SH NAME
  940. XlUndump - Undump a linked list from a file.
  941. X.SH SYNOPSIS
  942. Xint
  943. X.BR "lUndump" "(file)"
  944. X.br
  945. X.RT
  946. X.RP
  947. XIn    char    *file    name of linked list dump file
  948. X.DT
  949. X.SH DESCRIPTION
  950. X\fBlUndump\fP is a linked list undumping utility. The user will be able to
  951. Xuse linked list data that was saved by lDump in the same or an earlier
  952. Xprogram session. The linked list data was saved in a specially formatted
  953. Xfile by lDump. The routine returns the identifier of the undumped linked
  954. Xlist (\(>= 1), which must be used in the other routines of the linked list
  955. Xtool. This identifier doesn't have to be the same as used by lDump.
  956. X.SH ERROR CODES
  957. X-14
  958. X.SH AUTHOR
  959. XAnita Eijs (TNO - Bouw - BouwInformatica)
  960. END_OF_FILE
  961.   if test 719 -ne `wc -c <'Doc/lUndump.1'`; then
  962.     echo shar: \"'Doc/lUndump.1'\" unpacked with wrong size!
  963.   fi
  964.   # end of 'Doc/lUndump.1'
  965. fi
  966. if test -f 'Doc/lUpdNode.1' -a "${1}" != "-c" ; then 
  967.   echo shar: Will not clobber existing file \"'Doc/lUpdNode.1'\"
  968. else
  969.   echo shar: Extracting \"'Doc/lUpdNode.1'\" \(634 characters\)
  970.   sed "s/^X//" >'Doc/lUpdNode.1' <<'END_OF_FILE'
  971. X'.so tmac.clman
  972. X.TH "lUpdNode"
  973. X.IX lUpdNode
  974. X.SH NAME
  975. XlUpdNode - Update current node.
  976. X.SH SYNOPSIS
  977. Xint
  978. X.BR "lUpdNode" "(id, data, size, flag)"
  979. X.br
  980. X.RT
  981. X.RP
  982. XIn    int    id    identifier of linked list
  983. X.RP
  984. XIn    Byte    *data    updated data of node
  985. X.RP
  986. XIn    int    size    size of data
  987. X.RP
  988. XIn    int    flag    user information flag
  989. X.DT
  990. X.SH DESCRIPTION
  991. X\fBlUpdNode\fP updates the current node in a linked list, in fact
  992. Xthis routine replaces the data of the current node by the data of the
  993. Xupdated node.
  994. XThe flag for user information can also be updated. The routine returns
  995. X0 (zero) on success.
  996. X.SH ERROR CODES
  997. X-5, -8
  998. X.SH AUTHOR
  999. XAnita Eijs (TNO - Bouw - BouwInformatica)
  1000. END_OF_FILE
  1001.   if test 634 -ne `wc -c <'Doc/lUpdNode.1'`; then
  1002.     echo shar: \"'Doc/lUpdNode.1'\" unpacked with wrong size!
  1003.   fi
  1004.   # end of 'Doc/lUpdNode.1'
  1005. fi
  1006. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  1007.   echo shar: Will not clobber existing file \"'Makefile'\"
  1008. else
  1009.   echo shar: Extracting \"'Makefile'\" \(1730 characters\)
  1010.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  1011. X# Linked List Tool
  1012. X#
  1013. X# Anita Eijs, TNO-BOUW, BouwInformatica, September 1989
  1014. X
  1015. XTOOLS_HOME    = /usr1/user/anita/Tools
  1016. X
  1017. X# Name of current directory
  1018. XDIR    = List
  1019. X
  1020. X# Name of library
  1021. XLIB    = $(TOOLS_HOME)/Lib/list.a
  1022. X
  1023. X# Include rules for package
  1024. XMAKERULE= Tools_makerule
  1025. XRULE    = $(TOOLS_HOME)/$(MAKERULE)
  1026. Xinclude $(RULE)
  1027. X
  1028. X# Contents of current directory
  1029. XLIST    = Makefile README example.c list.c list.h
  1030. X
  1031. X# Documentation
  1032. XDOC    = \
  1033. X    Doc/Intro.1        Doc/lDef.1        Doc/lDel.1 \
  1034. X    Doc/lDelAll.1        Doc/lDelNode.1        Doc/lDump.1 \
  1035. X    Doc/lFlagNode.1        Doc/lFndNode.1        Doc/lGetNode.1 \
  1036. X    Doc/lIndxNode.1        Doc/lInfo.1        Doc/lInfoNode.1 \
  1037. X    Doc/lInsNode.1        Doc/lUndump.1        Doc/lUpdNode.1
  1038. X
  1039. XDOC_ALL = \
  1040. X    Doc/list_doc.ps        Doc/*.man
  1041. X
  1042. X# Object dependencies
  1043. XOBJ    = list.o
  1044. X
  1045. XLIB_OBJ    = $(LIB)(list.o)
  1046. X
  1047. X# The targets
  1048. Xusge:
  1049. X        $(ECHO)
  1050. X        $(ECHO) $(USAGE_ID)
  1051. X        $(ECHO) $(USAGE_TARGETS)
  1052. X        $(ECHO) $(USAGE_USAGE)
  1053. X        $(ECHO) $(USAGE_LIB)
  1054. X        $(ECHO) $(USAGE_NEWLIB)
  1055. X        $(ECHO) $(USAGE_OFILES)
  1056. X        $(ECHO) $(USAGE_TEST)
  1057. X        $(ECHO) $(USAGE_TAR)
  1058. X        $(ECHO)
  1059. X        $(ECHO) $(USAGE_DEFLTS1)
  1060. X        $(ECHO) $(USAGE_DEFLTS2)
  1061. X        $(ECHO) $(USAGE_DEFLTS3)
  1062. X
  1063. Xlib:        $(LIB_OBJ)
  1064. X        $(RANLIB) $(LIB)
  1065. X
  1066. Xnewlib:        $(OBJ)
  1067. X        $(AR) r $(LIB) *.o
  1068. X        rm -f *.o
  1069. X        $(RANLIB) $(LIB)
  1070. X
  1071. Xofiles:        $(OBJ)
  1072. X
  1073. Xtest:        example
  1074. X
  1075. Xexample:    $(LIB) example.o
  1076. X        cc -o example example.o $(LIB)
  1077. X
  1078. Xtar:
  1079. X        $(ECHO) "Making tar-file in $(TARFILE)"
  1080. X        cp ../$(MAKERULE) $(MAKERULE)
  1081. X        tar cvf $(TARFILE) $(MAKERULE) $(LIST) $(DOC)
  1082. X        rm $(MAKERULE)
  1083. X
  1084. Xshar:
  1085. X        $(ECHO) "Making shar-file in $(SHARFILE)"
  1086. X        cp ../$(MAKERULE) $(MAKERULE)
  1087. X        shar $(MAKERULE) $(LIST) Doc $(DOC) $(DOC_ALL) > $(SHARFILE)
  1088. X        rm $(MAKERULE)
  1089. X
  1090. Xshort_shar:
  1091. X        $(ECHO) "Making shar-file in $(SHARFILE)"
  1092. X        cp ../$(MAKERULE) $(MAKERULE)
  1093. X        shar $(MAKERULE) $(LIST) Doc $(DOC) > $(SHARFILE)
  1094. X        rm $(MAKERULE)
  1095. END_OF_FILE
  1096.   if test 1730 -ne `wc -c <'Makefile'`; then
  1097.     echo shar: \"'Makefile'\" unpacked with wrong size!
  1098.   fi
  1099.   # end of 'Makefile'
  1100. fi
  1101. if test -f 'Tools_makerule' -a "${1}" != "-c" ; then 
  1102.   echo shar: Will not clobber existing file \"'Tools_makerule'\"
  1103. else
  1104.   echo shar: Extracting \"'Tools_makerule'\" \(826 characters\)
  1105.   sed "s/^X//" >'Tools_makerule' <<'END_OF_FILE'
  1106. XTARFILE        = /tmp/Tools$(DIR).tar
  1107. XSHARFILE    = /tmp/Tools$(DIR).shar
  1108. XAR        = ar
  1109. X# RANLIB should be :
  1110. X# echo :    IRIX System V Release 3.3.1, Silicon Graphics, Inc.
  1111. X# ranlib :    Sun Sparc2 SunOS, Berkeley UNIX
  1112. X#    (AE, Dec 91)
  1113. X#RANLIB        = echo "Ready with"
  1114. XRANLIB        = ranlib
  1115. XCOFLAGS        = -q
  1116. XCFLAGS        = -O
  1117. X
  1118. X# Set defaults for macro's
  1119. XECHO        = echo $(INDNTTN)
  1120. XARG_INDNTTN    = INDNTTN="$(INDNTTN)'    '"
  1121. X
  1122. X# Help macro
  1123. XUSAGE_ID    = "Makefile of directory $(DIR)"
  1124. XUSAGE_TARGETS    = "Targets are:"
  1125. XUSAGE_USAGE    = "usge        = Prints this"
  1126. XUSAGE_LIB    = "lib        = Make objects for LIB"
  1127. XUSAGE_NEWLIB    = "newlib        = Make objects and place them in LIB"
  1128. XUSAGE_OFILES    = "ofiles        = Make objects"
  1129. XUSAGE_TEST    = "test/example    = Make test program"
  1130. XUSAGE_TAR    = "tar        = Make TARFILE"
  1131. XUSAGE_DEFLTS1    = "defaults:"
  1132. XUSAGE_DEFLTS2    = "    TARFILE = $(TARFILE)"
  1133. XUSAGE_DEFLTS3    = "    LIB = $(LIB)"
  1134. END_OF_FILE
  1135.   if test 826 -ne `wc -c <'Tools_makerule'`; then
  1136.     echo shar: \"'Tools_makerule'\" unpacked with wrong size!
  1137.   fi
  1138.   # end of 'Tools_makerule'
  1139. fi
  1140. if test -f 'example.c' -a "${1}" != "-c" ; then 
  1141.   echo shar: Will not clobber existing file \"'example.c'\"
  1142. else
  1143.   echo shar: Extracting \"'example.c'\" \(2666 characters\)
  1144.   sed "s/^X//" >'example.c' <<'END_OF_FILE'
  1145. X#include    "list.h"
  1146. X
  1147. Xint    search();
  1148. X
  1149. Xtypedef struct rapport {
  1150. X    char        nummer[9];
  1151. X    char        title[30];
  1152. X    char        author[15];
  1153. X    int        date;
  1154. X} rapport;
  1155. X
  1156. Xmain()
  1157. X{
  1158. X    int            id, code, dat, size = sizeof(rapport);
  1159. X    rapport        rap;
  1160. X
  1161. X    id = lDef(SINGLY, CHAIN);
  1162. X
  1163. X    strcpy(rap.nummer, "B-89-100");
  1164. X    strcpy(rap.title, "Book 1");
  1165. X    strcpy(rap.author, "People");
  1166. X    rap.date = 890129;
  1167. X    lInsNode(id, FIRST, &rap, size, 1);
  1168. X
  1169. X    strcpy(rap.nummer, "B-89-101");
  1170. X    strcpy(rap.title, "Book 2");
  1171. X    strcpy(rap.author, "More People");
  1172. X    rap.date = 890130;
  1173. X    lInsNode(id, FIRST, &rap, size, 2);
  1174. X
  1175. X    strcpy(rap.nummer, "B-89-102");
  1176. X    strcpy(rap.title, "Book 3");
  1177. X    strcpy(rap.author, "Lots of People");
  1178. X    rap.date = 890131;
  1179. X    lInsNode(id, LAST, &rap, size, 3);
  1180. X
  1181. X    printf("lGetNode\n");
  1182. X    code = lGetNode(id, FIRST, &rap, size);
  1183. X    prRap(code, &rap);
  1184. X    code = lGetNode(id, NEXT, &rap, size);
  1185. X    prRap(code, &rap);
  1186. X    code = lGetNode(id, NEXT, &rap, size);
  1187. X    prRap(code, &rap);
  1188. X    code = lGetNode(id, NEXT, &rap, size);
  1189. X    prRap(code, &rap);
  1190. X
  1191. X    printf("lIndxNode\n");
  1192. X    code = lIndxNode(id, 4, &rap, size);
  1193. X    prRap(code, &rap);
  1194. X    code = lIndxNode(id, 2, &rap, size);
  1195. X    prRap(code, &rap);
  1196. X    code = lIndxNode(id, -1, &rap, size);
  1197. X    prRap(code, &rap);
  1198. X    code = lIndxNode(id, 3, &rap, size);
  1199. X    prRap(code, &rap);
  1200. X
  1201. X    printf("lFndNode\n");
  1202. X    dat = 890129;
  1203. X    code = lFndNode(id, FIRST, search, &dat, &rap, size);
  1204. X    prRap(code, &rap);
  1205. X    code = lFndNode(id, NEXT, search, &dat, &rap, size);
  1206. X    prRap(code, &rap);
  1207. X    code = lFndNode(id, NEXT, search, &dat, &rap, size);
  1208. X    prRap(code, &rap);
  1209. X
  1210. X    code = lDump(id, "/tmp/.dump");
  1211. X    printf("lDump : %d\n", code);
  1212. X
  1213. X    lDel(id);
  1214. X
  1215. X    id = lUndump("/tmp/.dump");
  1216. X    printf("lUndump : %d\n", id);
  1217. X
  1218. X    strcpy(rap.nummer, "B-89-001");
  1219. X    strcpy(rap.title, "Book 4");
  1220. X    strcpy(rap.author, "The Author");
  1221. X    rap.date = 891127;
  1222. X    lInsNode(id, FIRST, &rap, size, 4);
  1223. X
  1224. X    printf("lGetNode\n");
  1225. X    code = lGetNode(id, FIRST, &rap, size);
  1226. X    prRap(code, &rap);
  1227. X    code = lGetNode(id, NEXT, &rap, size);
  1228. X    prRap(code, &rap);
  1229. X    code = lGetNode(id, NEXT, &rap, size);
  1230. X    prRap(code, &rap);
  1231. X    code = lGetNode(id, NEXT, &rap, size);
  1232. X    prRap(code, &rap);
  1233. X
  1234. X    printf("lFlagNode\n");
  1235. X    code = lFlagNode(id, 1, &rap, size);
  1236. X    prRap(code, &rap);
  1237. X    code = lFlagNode(id, 3, &rap, size);
  1238. X    prRap(code, &rap);
  1239. X    code = lFlagNode(id, 2, &rap, size);
  1240. X    prRap(code, &rap);
  1241. X    code = lFlagNode(id, 7, &rap, size);
  1242. X    prRap(code, &rap);
  1243. X
  1244. X    lDelAll();
  1245. X}
  1246. X
  1247. Xint
  1248. Xsearch(date, rpprt)
  1249. Xint            *date;
  1250. Xrapport        *rpprt;
  1251. X{
  1252. X    if (rpprt->date > *date)
  1253. X        return(FOUND);
  1254. X    else
  1255. X        return(NOT_FOUND);
  1256. X}
  1257. X
  1258. XprRap(code, rpprt)
  1259. Xint            code;
  1260. Xrapport        *rpprt;
  1261. X{
  1262. X    if (code >= 0)
  1263. X        printf("rapport :'%s' '%s' '%s' '%d'\n", rpprt->nummer, rpprt->title,
  1264. X            rpprt->author, rpprt->date);
  1265. X    else
  1266. X        printf("Return code = %d\n", code);
  1267. X}
  1268. END_OF_FILE
  1269.   if test 2666 -ne `wc -c <'example.c'`; then
  1270.     echo shar: \"'example.c'\" unpacked with wrong size!
  1271.   fi
  1272.   # end of 'example.c'
  1273. fi
  1274. if test -f 'list.c' -a "${1}" != "-c" ; then 
  1275.   echo shar: Will not clobber existing file \"'list.c'\"
  1276. else
  1277.   echo shar: Extracting \"'list.c'\" \(21105 characters\)
  1278.   sed "s/^X//" >'list.c' <<'END_OF_FILE'
  1279. X/*
  1280. X *    Anita Eijs    TNO-BOUW, BouwInformatica    May 1989
  1281. X *
  1282. X *    Linked List Tool
  1283. X *
  1284. X *    Updates:
  1285. X *    900402    new routine 'lIndxNode' : 'get node by index'
  1286. X *
  1287. X *    900925    new routine 'lError' : 'print error message in ERROR_FILE'
  1288. X *
  1289. X *    901129    new routines 'lDump' : 'dump a linked list to a file'
  1290. X *        and 'lUndump' : 'undump a linked list from a file'
  1291. X *
  1292. X *    910301    'Mac'ed by Vinnie : ListPtr=ListyPtr, Byte = byte, includes and
  1293. X *        typecasts
  1294. X *
  1295. X *    910316    new routine 'lFlagNode' : 'get node by flag'
  1296. X */
  1297. X
  1298. X#ifdef MAC
  1299. X#define    MAC_OR_VAXC
  1300. X#endif
  1301. X#ifdef VAXC
  1302. X#define    MAC_OR_VAXC
  1303. X#endif
  1304. X
  1305. X#ifdef MAC
  1306. X#include    <unix.h>    /* open, creat, write, read, close */
  1307. X#include    <stddef.h>    /* sizeof */
  1308. X#endif
  1309. X
  1310. X#ifdef MAC_OR_VAXC
  1311. X#include    <stdlib.h>
  1312. X#else
  1313. X#include    <malloc.h>
  1314. X#endif
  1315. X
  1316. X#include    <stdio.h>
  1317. X#include    "list.h"
  1318. X
  1319. X#undef    FREE
  1320. X#define FREE(VAR) if (VAR != NULL) free((char *)VAR);
  1321. X#undef    MALLOC
  1322. X#define MALLOC(VAR, TYPE) \
  1323. X    if ((VAR = (TYPE *)malloc(sizeof(TYPE))) == NULL) { \
  1324. X        fprintf(stderr, "No more memory for malloc().\n"); \
  1325. X    }
  1326. X#undef    CALLOC
  1327. X#define CALLOC(VAR, TYPE, NR) \
  1328. X    if ((VAR = (TYPE *)calloc(NR, sizeof(TYPE))) == NULL) {\
  1329. X        fprintf(stderr, "No more memory for calloc().\n"); \
  1330. X    }
  1331. X
  1332. X#undef    BYTE_COPY
  1333. X#define BYTE_COPY(FROM, TO, SIZE) \
  1334. X    { \
  1335. X        register Byte    *frm = FROM, \
  1336. X                *to = TO; \
  1337. X        int        i = SIZE; \
  1338. X        while (i--) *to++ = *frm++; \
  1339. X    }
  1340. X
  1341. X#ifndef ANSI
  1342. Xtypedef    int        (*Func)();
  1343. Xtypedef    unsigned char    Byte;
  1344. X#endif
  1345. X
  1346. Xtypedef struct lnode {
  1347. X    Byte        *data;    /* data of user */
  1348. X    int        size;    /* size (number of bytes) of data */
  1349. X    int        flag;    /* user information flag */
  1350. X    struct lnode    *prv;    /* previous node */
  1351. X    struct lnode    *nxt;    /* next node */
  1352. X} ListNode, *NodePtr;
  1353. X
  1354. Xtypedef struct listhdr {
  1355. X    int        id;        /* identifier of linked list */
  1356. X    int        sd;        /* singly or doubly linked */
  1357. X    int        cc;        /* chain or circular list */
  1358. X    int        n;        /* number of nodes */
  1359. X    NodePtr        first;        /* address of first node */
  1360. X    NodePtr        current;    /* address of current node */
  1361. X    NodePtr        last;        /* address of last node */
  1362. X    struct listhdr    *nxt;        /* next linked list */
  1363. X} ListHdr, *ListPtr;
  1364. X
  1365. Xtypedef struct header {    /* general info of linked list for dump file */
  1366. X    int    sd;
  1367. X    int    cc;
  1368. X    int    n;
  1369. X} Header;
  1370. X
  1371. Xtypedef struct info {    /* general info of node for dump file */
  1372. X    int    size;
  1373. X    int    flag;
  1374. X} Info;
  1375. X
  1376. X#define    BIN_WRITE    1    /* necessary for binary file access */
  1377. X#define    BIN_READ    0
  1378. X#define    PMODE        0666
  1379. X
  1380. Xstatic ListHdr    firstlist = { 1, 0, 0, 0, NULL, NULL, NULL, NULL };
  1381. X
  1382. Xstatic ListPtr    ld = &firstlist;
  1383. Xstatic int    idMax = 2;
  1384. X
  1385. Xstatic ListPtr    getAddress();
  1386. Xstatic void    lError();
  1387. X
  1388. X/* define a new linked list and create info about it */
  1389. X#ifdef ANSI
  1390. Xint
  1391. XlDef(int sd, int cc)
  1392. X#else
  1393. Xint
  1394. XlDef(sd, cc)
  1395. Xint    sd, cc;
  1396. X#endif
  1397. X{
  1398. X    ListPtr    list, new;
  1399. X
  1400. X    if (sd != SINGLY && sd != DOUBLY) {
  1401. X        lError("lDef", WRONG_SD, sd, 0, NULL);
  1402. X        return(WRONG_SD);
  1403. X    }
  1404. X    if (cc != CHAIN && cc != CIRCULAR) {
  1405. X        lError("lDef", WRONG_CC, cc, 0, NULL);
  1406. X        return(WRONG_CC);
  1407. X    }
  1408. X
  1409. X    list = ld;
  1410. X    while (list->nxt != NULL && list->sd != 0)
  1411. X        list = list->nxt;
  1412. X    if (list->sd != 0) {    /* new list */
  1413. X        MALLOC(new, ListHdr);
  1414. X        new->id = idMax++;
  1415. X        new->sd = sd;
  1416. X        new->cc = cc;
  1417. X        new->n = 0;
  1418. X        new->first = new->current = new->last = NULL;
  1419. X        new->nxt = NULL;
  1420. X        list->nxt = new;
  1421. X        return(new->id);
  1422. X    } else {        /* new list on existing place */
  1423. X        list->sd = sd;
  1424. X        list->cc = cc;
  1425. X        return(list->id);
  1426. X    }
  1427. X}
  1428. X
  1429. X/* insert a node in linked list */
  1430. X#ifdef ANSI
  1431. Xint
  1432. XlInsNode(int id, int where, Byte *data, int size, int flag)
  1433. X#else
  1434. Xint
  1435. XlInsNode(id, where, data, size, flag)
  1436. Xint    id, where, size, flag;
  1437. XByte    *data;
  1438. X#endif
  1439. X{
  1440. X    ListPtr    list;
  1441. X    NodePtr    node, new;
  1442. X
  1443. X    if ((list = getAddress(id)) == NULL) {
  1444. X        lError("lInsNode", UNKNOWN_ID, id, 0, NULL);
  1445. X        return(UNKNOWN_ID);
  1446. X    }
  1447. X    if (where != FIRST && where != BEFORE && where != AFTER
  1448. X            && where != LAST) {
  1449. X        lError("lInsNode", WRONG_WHERE, where, 0, NULL);
  1450. X        return(WRONG_WHERE);
  1451. X    }
  1452. X
  1453. X        /* create new node */
  1454. X    MALLOC(new, ListNode);
  1455. X    CALLOC(new->data, Byte, size);
  1456. X    BYTE_COPY(data, new->data, size);
  1457. X    new->size = size;
  1458. X    new->flag = flag;
  1459. X
  1460. X        /* specific insert cases */
  1461. X    if (list->first == NULL)
  1462. X        where = ONE_NODE;    /* first node in list */
  1463. X    else if (list->current == list->first && where == BEFORE)
  1464. X        where = FIRST;        /* before first is like insert first */
  1465. X    else if (list->current == list->last && where == AFTER)
  1466. X        where = LAST;        /* after last is like insert last */
  1467. X
  1468. X    switch (where) {
  1469. X    case ONE_NODE :
  1470. X        if (list->cc == CHAIN)
  1471. X            new->prv = new->nxt = NULL;
  1472. X        else {
  1473. X            if (list->sd == DOUBLY)
  1474. X                new->prv = new;
  1475. X            else
  1476. X                new->prv = NULL;
  1477. X            new->nxt = new;
  1478. X        }
  1479. X        list->first = list->last = new;
  1480. X        break;
  1481. X    case FIRST :
  1482. X        new->prv = (list->first)->prv;
  1483. X        new->nxt = list->first;
  1484. X        if (list->cc == CIRCULAR)
  1485. X            (list->last)->nxt = new;
  1486. X        else
  1487. X            (list->last)->nxt = NULL;
  1488. X        if (list->sd == DOUBLY)
  1489. X            (list->first)->prv = new;
  1490. X        list->first = new;
  1491. X        break;
  1492. X    case BEFORE :
  1493. X        new->prv = (list->current)->prv;    /* == NULL if SINGLY */
  1494. X        new->nxt = list->current;
  1495. X
  1496. X        if (list->sd == DOUBLY) {
  1497. X            ((list->current)->prv)->nxt = new;
  1498. X            (list->current)->prv = new;
  1499. X        } else {
  1500. X            node = list->first;
  1501. X                /* search for last before current */
  1502. X            while (node->nxt != list->current && node != list->last)
  1503. X                node = node->nxt;
  1504. X            node->nxt = new;
  1505. X        }
  1506. X        if (list->current == list->first)
  1507. X            list->first = new;
  1508. X        break;
  1509. X    case AFTER :
  1510. X        if (list->sd == DOUBLY)
  1511. X            new->prv = list->current;
  1512. X        else
  1513. X            new->prv = NULL;
  1514. X        new->nxt = (list->current)->nxt;
  1515. X        if (list->sd == DOUBLY) {
  1516. X            ((list->current)->nxt)->prv = new;
  1517. X            (list->current)->prv = new;
  1518. X        }
  1519. X        (list->current)->nxt = new;
  1520. X        if (list->current == list->last)
  1521. X            list->last = new;
  1522. X        break;
  1523. X    case LAST :
  1524. X        node = list->last;
  1525. X        if (list->sd == DOUBLY)
  1526. X            new->prv = node;
  1527. X        else
  1528. X            new->prv = NULL;
  1529. X        if (list->cc == CIRCULAR)
  1530. X            new->nxt = list->first;
  1531. X        else
  1532. X            new->nxt = NULL;
  1533. X        if (list->sd == DOUBLY && list->cc == CIRCULAR)
  1534. X            (list->first)->prv = new;
  1535. X        node->nxt = new;
  1536. X        list->last = new;
  1537. X        break;
  1538. X    }
  1539. X    list->n++;
  1540. X    list->current = new;
  1541. X    return(0);
  1542. X}
  1543. X
  1544. X/* update current node in linked list */
  1545. X#ifdef ANSI
  1546. Xint
  1547. XlUpdNode(int id, Byte *data, int size, int flag)
  1548. X#else
  1549. Xint
  1550. XlUpdNode(id, data, size, flag)
  1551. Xint    id, size, flag;
  1552. XByte    *data;
  1553. X#endif
  1554. X{
  1555. X    ListPtr    list;
  1556. X
  1557. X    if ((list = getAddress(id)) == NULL) {
  1558. X        lError("lUpdNode", UNKNOWN_ID, id, 0, NULL);
  1559. X        return(UNKNOWN_ID);
  1560. X    }
  1561. X    if (list->current == NULL) {
  1562. X        lError("lUpdNode", EMPTY_LIST, id, 0, NULL);
  1563. X        return(EMPTY_LIST);
  1564. X    }
  1565. X
  1566. X        /* if same size, replace node by updated node */
  1567. X        /* if not same size, insert updated node on current place */
  1568. X    if ((list->current)->size != size) {
  1569. X        FREE((list->current)->data);
  1570. X        CALLOC((list->current)->data, Byte, size);
  1571. X        (list->current)->size = size;
  1572. X    }
  1573. X    (list->current)->flag = flag;
  1574. X    BYTE_COPY(data, (list->current)->data, size);
  1575. X    return(0);
  1576. X}
  1577. X
  1578. X/* get data of node */
  1579. X#ifdef ANSI
  1580. Xint
  1581. XlGetNode(int id, int which, Byte *data, int size)
  1582. X#else
  1583. Xint
  1584. XlGetNode(id, which, data, size)
  1585. Xint    id, which, size;
  1586. XByte    *data;
  1587. X#endif
  1588. X{
  1589. X    ListPtr    list;
  1590. X
  1591. X    if ((list = getAddress(id)) == NULL) {
  1592. X        lError("lGetNode", UNKNOWN_ID, id, 0, NULL);
  1593. X        return(UNKNOWN_ID);
  1594. X    }
  1595. X    if (list->first == NULL) {
  1596. X        lError("lGetNode", EMPTY_LIST, id, 0, NULL);
  1597. X        return(EMPTY_LIST);
  1598. X    }
  1599. X
  1600. X    switch (which) {
  1601. X    case FIRST :
  1602. X        list->current = list->first;
  1603. X        break;
  1604. X    case NEXT :
  1605. X        if ((list->current)->nxt == NULL) {
  1606. X            lError("lGetNode", EOL, id, 0, NULL);
  1607. X            return(EOL);
  1608. X        }
  1609. X        list->current = (list->current)->nxt;
  1610. X        break;
  1611. X    case CURRENT :
  1612. X        break;
  1613. X    case PREVIOUS :
  1614. X        if (list->sd != DOUBLY) {
  1615. X            lError("lGetNode", NOT_DOUBLY, id, 0, NULL);
  1616. X            return(NOT_DOUBLY);
  1617. X        }
  1618. X        if ((list->current)->prv == NULL) {
  1619. X            lError("lGetNode", EOL, id, 0, NULL);
  1620. X            return(EOL);
  1621. X        }
  1622. X        list->current = (list->current)->prv;
  1623. X        break;
  1624. X    case LAST :
  1625. X        list->current = list->last;
  1626. X        break;
  1627. X    default :
  1628. X        lError("lGetNode", WRONG_WHICH, which, 0, NULL);
  1629. X        return(WRONG_WHICH);
  1630. X    }
  1631. X        /* expected data and node must have same size */
  1632. X    if ((list->current)->size != size) {
  1633. X        lError("lGetNode", SIZE_NE, size, (list->current)->size, NULL);
  1634. X        return(SIZE_NE);
  1635. X    } else {
  1636. X        BYTE_COPY((list->current)->data, data, size);
  1637. X        if (list->current == list->last)
  1638. X            return(LAST);
  1639. X        else if (list->current == list->first)
  1640. X            return(FIRST);
  1641. X        else
  1642. X            return(0);
  1643. X    }
  1644. X}
  1645. X
  1646. X/* get data of node 'index' */
  1647. X#ifdef ANSI
  1648. Xint
  1649. XlIndxNode(int id, int index, Byte *data, int size)
  1650. X#else
  1651. Xint
  1652. XlIndxNode(id, index, data, size)
  1653. Xint    id, index, size;
  1654. XByte    *data;
  1655. X#endif
  1656. X{
  1657. X    ListPtr    list;
  1658. X    int    i;
  1659. X
  1660. X    if ((list = getAddress(id)) == NULL) {
  1661. X        lError("lIndxNode", UNKNOWN_ID, id, 0, NULL);
  1662. X        return(UNKNOWN_ID);
  1663. X    }
  1664. X    if (list->first == NULL) {
  1665. X        lError("lIndxNode", EMPTY_LIST, id, 0, NULL);
  1666. X        return(EMPTY_LIST);
  1667. X    }
  1668. X    if (0 >= index || list->n < index) {
  1669. X        lError("lIndxNode", WRONG_INDEX, index, list->n, NULL);
  1670. X        return(WRONG_INDEX);
  1671. X    }
  1672. X
  1673. X    if (index == 1)
  1674. X        list->current = list->first;
  1675. X    else if (index == list->n)
  1676. X        list->current = list->last;
  1677. X    else {
  1678. X        list->current = list->first;
  1679. X        for (i=1; i<index; i++)
  1680. X            list->current = (list->current)->nxt;
  1681. X    }
  1682. X
  1683. X    BYTE_COPY((list->current)->data, data, size);
  1684. X    if (list->current == list->last)
  1685. X        return(LAST);
  1686. X    else if (list->current == list->first)
  1687. X        return(FIRST);
  1688. X    else
  1689. X        return(0);
  1690. X}
  1691. X
  1692. X/* find data of node for which the function returns FOUND */
  1693. X#ifdef ANSI
  1694. Xint
  1695. XlFndNode(int id, int where, Func func, Byte *ptr, Byte *data, int size)
  1696. X#else
  1697. Xint
  1698. XlFndNode(id, where, func, ptr, data, size)
  1699. Xint    id, where, size;
  1700. XFunc    func;
  1701. XByte    *ptr, *data;
  1702. X#endif
  1703. X{
  1704. X    NodePtr    node;
  1705. X    ListPtr    list;
  1706. X    int    code = NOT_FOUND;
  1707. X
  1708. X    if ((list = getAddress(id)) == NULL) {
  1709. X        lError("lFndNode", UNKNOWN_ID, id, 0, NULL);
  1710. X        return(UNKNOWN_ID);
  1711. X    }
  1712. X    if (list->first == NULL) {
  1713. X        lError("lFndNode", EMPTY_LIST, id, 0, NULL);
  1714. X        return(EMPTY_LIST);
  1715. X    }
  1716. X    if (func == NULL) {
  1717. X        lError("lFndNode", UNKNOWN_FUNC, func, 0, NULL);
  1718. X        return(UNKNOWN_FUNC);
  1719. X    }
  1720. X    
  1721. X    switch (where) {
  1722. X    case FIRST :
  1723. X        node = list->first;
  1724. X        break;
  1725. X    case NEXT :
  1726. X    case PREVIOUS :
  1727. X        node = list->current;
  1728. X        break;
  1729. X    case LAST :
  1730. X        node = list->last;
  1731. X        break;
  1732. X    default :
  1733. X        lError("lFndNode", WRONG_WHERE, where, 0, NULL);
  1734. X        return(WRONG_WHERE);
  1735. X    }
  1736. X
  1737. X        /* expected data and node must have same size */
  1738. X    if ((where == FIRST || where == LAST) && node->size == size) {
  1739. X        BYTE_COPY(node->data, data, size);
  1740. X        code = (*func)(ptr, data);
  1741. X    }
  1742. X
  1743. X    switch (where) {
  1744. X    case FIRST :
  1745. X    case NEXT :
  1746. X        while (code != FOUND && node->nxt != NULL
  1747. X                && node != list->last) {
  1748. X            node = node->nxt;
  1749. X                /* expected data and node must have same size */
  1750. X            if (node->size == size) {
  1751. X                BYTE_COPY(node->data, data, size);
  1752. X                code = (*func)(ptr, data);
  1753. X            }
  1754. X        }
  1755. X        if (code == FOUND) {
  1756. X            list->current = node;
  1757. X            if (list->current == list->last)
  1758. X                return(LAST);
  1759. X        }
  1760. X        break;
  1761. X    case PREVIOUS :
  1762. X    case LAST :
  1763. X        if (list->sd != DOUBLY && code == NOT_FOUND) {
  1764. X            lError("lFndNode", NOT_DOUBLY, id, 0, NULL);
  1765. X            return(NOT_DOUBLY);
  1766. X        }
  1767. X        while (code != FOUND && node->prv != NULL
  1768. X                && node->prv != list->first) {
  1769. X            node = node->prv;
  1770. X                /* expected data and node must have same size */
  1771. X            if (node->size == size) {
  1772. X                BYTE_COPY(node->data, data, size);
  1773. X                code = (*func)(ptr, data);
  1774. X            }
  1775. X        }
  1776. X        if (code == FOUND) {
  1777. X            list->current = node;
  1778. X            if (list->current == list->first)
  1779. X                return(FIRST);
  1780. X        }
  1781. X        break;
  1782. X    }
  1783. X    return(code);
  1784. X}
  1785. X
  1786. X/* delete node from linked list */
  1787. X#ifdef ANSI
  1788. Xint
  1789. XlDelNode(int id, int which)
  1790. X#else
  1791. Xint
  1792. XlDelNode(id, which)
  1793. Xint    id, which;
  1794. X#endif
  1795. X{
  1796. X    NodePtr    node, prv, nxt;
  1797. X    ListPtr    list;
  1798. X
  1799. X    if ((list = getAddress(id)) == NULL) {
  1800. X        lError("lDelNode", UNKNOWN_ID, id, 0, NULL);
  1801. X        return(UNKNOWN_ID);
  1802. X    }
  1803. X    if (list->first == NULL) {
  1804. X        lError("lDelNode", EMPTY_LIST, id, 0, NULL);
  1805. X        return(EMPTY_LIST);
  1806. X    }
  1807. X
  1808. X        /* specific delete cases */
  1809. X    if (list->n == 1)
  1810. X        which = ONE_NODE;    /* one node in linked list */
  1811. X        else if (which == CURRENT && list->first == list->current)
  1812. X                which = FIRST;        /* current is also first node */
  1813. X        else if (which == CURRENT && list->last == list->current)
  1814. X                which = LAST;        /* current is also last node */
  1815. X
  1816. X    switch (which) {
  1817. X    case ONE_NODE :
  1818. X        node = list->first;
  1819. X        list->first = list->current = list->last = NULL;
  1820. X        break;
  1821. X    case FIRST :
  1822. X        node = list->first;
  1823. X        nxt = node->nxt;
  1824. X        if (list->cc == CIRCULAR) {
  1825. X            prv = list->last;
  1826. X            prv->nxt = nxt;
  1827. X        } else
  1828. X            prv = node->prv;    /* == NULL if SINGLY */
  1829. X        if (list->sd == DOUBLY)
  1830. X            nxt->prv = prv;
  1831. X        list->first = list->current = nxt;
  1832. X        break;
  1833. X    case CURRENT :
  1834. X        node = list->current;
  1835. X        nxt = node->nxt;
  1836. X        if (list->sd == DOUBLY) {
  1837. X            prv = node->prv;
  1838. X            nxt->prv = prv;
  1839. X        } else {
  1840. X            prv = node = list->first;
  1841. X            while (node != list->current) {
  1842. X                prv = node;
  1843. X                node = node->nxt;
  1844. X            }
  1845. X            if (prv == node)
  1846. X                prv = list->last;
  1847. X        }
  1848. X        prv->nxt = nxt;
  1849. X        list->current = nxt;
  1850. X        break;
  1851. X    case LAST :
  1852. X        node = list->last;
  1853. X        if (list->sd == DOUBLY)
  1854. X            prv = node->prv;
  1855. X        else {
  1856. X            if (list->current != list->last)
  1857. X                prv = node = list->current;
  1858. X            else
  1859. X                prv = node = list->first;
  1860. X            while (node != list->last) {
  1861. X                prv = node;
  1862. X                node = node->nxt;
  1863. X            }
  1864. X        }
  1865. X        nxt = node->nxt;
  1866. X        if (list->sd == DOUBLY && list->cc == CIRCULAR)
  1867. X            nxt->prv = prv;
  1868. X        prv->nxt = nxt;
  1869. X        list->last = list->current = prv;
  1870. X        break;
  1871. X    default :
  1872. X        lError("lDelNode", WRONG_WHICH, which, 0, NULL);
  1873. X        return(WRONG_WHICH);
  1874. X    }
  1875. X    FREE(node->data);
  1876. X    FREE(node);
  1877. X    list->n--;
  1878. X    return(0);
  1879. X}
  1880. X
  1881. X/* get info of linked list */
  1882. X#ifdef ANSI
  1883. Xint
  1884. XlInfo(int id, int *sd, int *cc, int *n)
  1885. X#else
  1886. Xint
  1887. XlInfo(id, sd, cc, n)
  1888. Xint    id, *sd, *cc, *n;
  1889. X#endif
  1890. X{
  1891. X    ListPtr    list;
  1892. X
  1893. X    if ((list = getAddress(id)) == NULL) {
  1894. X        lError("lInfo", UNKNOWN_ID, id, 0, NULL);
  1895. X        return(UNKNOWN_ID);
  1896. X    }
  1897. X
  1898. X    *sd = list->sd;
  1899. X    *cc = list->cc;
  1900. X    *n = list->n;
  1901. X    return(0);
  1902. X}
  1903. X
  1904. X/* get info of node of linked list */
  1905. X#ifdef ANSI
  1906. Xint
  1907. XlInfoNode(int id, int which, int *size, int *flag)
  1908. X#else
  1909. Xint
  1910. XlInfoNode(id, which, size, flag)
  1911. Xint    id, which, *size, *flag;
  1912. X#endif
  1913. X{
  1914. X    ListPtr    list;
  1915. X
  1916. X    if ((list = getAddress(id)) == NULL) {
  1917. X        lError("lInfoNode", UNKNOWN_ID, id, 0, NULL);
  1918. X        return(UNKNOWN_ID);
  1919. X    }
  1920. X    if (list->n == 0) {
  1921. X        lError("lInfoNode", EMPTY_LIST, id, 0, NULL);
  1922. X        return(EMPTY_LIST);
  1923. X    }
  1924. X
  1925. X    switch (which) {
  1926. X    case FIRST :
  1927. X        list->current = list->first;
  1928. X        break;
  1929. X    case NEXT :
  1930. X        if ((list->current)->nxt == NULL) {
  1931. X            lError("lInfoNode", EOL, id, 0, NULL);
  1932. X            return(EOL);
  1933. X        }
  1934. X        list->current = (list->current)->nxt;
  1935. X        break;
  1936. X    case CURRENT :
  1937. X        break;
  1938. X    case PREVIOUS :
  1939. X        if (list->sd != DOUBLY) {
  1940. X            lError("lInfoNode", NOT_DOUBLY, id, 0, NULL);
  1941. X            return(NOT_DOUBLY);
  1942. X        }
  1943. X        if ((list->current)->prv == NULL) {
  1944. X            lError("lInfoNode", EOL, id, 0, NULL);
  1945. X            return(EOL);
  1946. X        }
  1947. X        list->current = (list->current)->prv;
  1948. X        break;
  1949. X    case LAST :
  1950. X        list->current = list->last;
  1951. X        break;
  1952. X    default :
  1953. X        lError("lInfoNode", WRONG_WHICH, which, 0, NULL);
  1954. X        return(WRONG_WHICH);
  1955. X    }
  1956. X    *size = (list->current)->size;
  1957. X    *flag = (list->current)->flag;
  1958. X    return(0);
  1959. X}
  1960. X
  1961. X/* delete a linked list and clear info about it */
  1962. X#ifdef ANSI
  1963. Xint
  1964. XlDel(int id)
  1965. X#else
  1966. Xint
  1967. XlDel(id)
  1968. Xint    id;
  1969. X#endif
  1970. X{
  1971. X    static void    delNodes();
  1972. X
  1973. X    ListPtr    list;
  1974. X
  1975. X    if ((list = getAddress(id)) == NULL) {
  1976. X        lError("lDel", UNKNOWN_ID, id, 0, NULL);
  1977. X        return(UNKNOWN_ID);
  1978. X    }
  1979. X
  1980. X    delNodes(list->first, list->n);
  1981. X    list->sd = list->cc = list->n = 0;
  1982. X    list->first = list->current = list->last = NULL;
  1983. X    return(0);
  1984. X}
  1985. X
  1986. X/* delete all linked list and all info about those lists */
  1987. X#ifdef ANSI
  1988. Xint
  1989. XlDelAll(void)
  1990. X#else
  1991. Xint
  1992. XlDelAll()
  1993. X#endif
  1994. X{
  1995. X    static void    delListInfo();
  1996. X
  1997. X    ListPtr    list, nxt;
  1998. X
  1999. X    if (ld == NULL) {
  2000. X        lError("lDelAll", NO_LIST, 0, 0, NULL);
  2001. X        return(NO_LIST);
  2002. X    }
  2003. X
  2004. X    list = ld;
  2005. X    while (list != NULL) {
  2006. X        nxt = list->nxt;
  2007. X        lDel(list->id);
  2008. X        list = nxt;
  2009. X    }
  2010. X    delListInfo(ld->nxt);
  2011. X        /* save info of initial list */
  2012. X    firstlist.id = 1;
  2013. X    firstlist.sd = firstlist.cc = firstlist.n = 0;
  2014. X    firstlist.first = firstlist.current = firstlist.last = NULL;
  2015. X    firstlist.nxt = NULL;
  2016. X    ld = &firstlist;
  2017. X    idMax = 2;
  2018. X    return(0);
  2019. X}
  2020. X
  2021. X/* get address of list data */
  2022. X#ifdef ANSI
  2023. Xstatic ListPtr
  2024. XgetAddress(int id)
  2025. X#else
  2026. Xstatic ListPtr
  2027. XgetAddress(id)
  2028. Xint    id;
  2029. X#endif
  2030. X{
  2031. X    ListPtr    list;
  2032. X
  2033. X    list = ld;
  2034. X    while (list != NULL && list->id != id)
  2035. X        list = list->nxt;
  2036. X    return(list);
  2037. X}
  2038. X
  2039. X/* delete nodes of a linked list */
  2040. X#ifdef ANSI
  2041. Xstatic void
  2042. XdelNodes(NodePtr node, int n)
  2043. X#else
  2044. Xstatic void
  2045. XdelNodes(node, n)
  2046. XNodePtr    node;
  2047. Xint    n;
  2048. X#endif
  2049. X{
  2050. X    NodePtr    nxt;
  2051. X    int    i;
  2052. X
  2053. X    for (i=0; i<n; i++) {
  2054. X        nxt = node->nxt;
  2055. X        FREE(node->data);
  2056. X        FREE(node);
  2057. X        node = nxt;
  2058. X    }
  2059. X}
  2060. X
  2061. X/* delete info about linked list */
  2062. X#ifdef ANSI
  2063. Xstatic void
  2064. XdelListInfo(ListPtr list)
  2065. X#else
  2066. Xstatic void
  2067. XdelListInfo(list)
  2068. XListPtr    list;
  2069. X#endif
  2070. X{
  2071. X    ListPtr    nxt;
  2072. X
  2073. X    while (list != NULL) {
  2074. X        nxt = list->nxt;
  2075. X        FREE(list);
  2076. X        list = nxt;
  2077. X    }
  2078. X}
  2079. X
  2080. X/* print error message in ERROR_FILE */
  2081. X#ifdef ANSI
  2082. Xstatic void
  2083. XlError(char *str, int code, int int1, int int2, char *str1)
  2084. X#else
  2085. Xstatic void
  2086. XlError(str, code, int1, int2, str1)
  2087. Xchar    *str, *str1;
  2088. Xint    code, int1, int2;
  2089. X#endif
  2090. X{
  2091. X#ifndef MSDOS
  2092. X    char    mess[60];
  2093. X    FILE    *fpError, *fopen();
  2094. X
  2095. X    switch (code) {
  2096. X    case WRONG_SD :
  2097. X        sprintf(mess, "Parameter 'sd' has wrong value : %d", int1);
  2098. X        break;
  2099. X    case WRONG_CC :
  2100. X        sprintf(mess, "Parameter 'cc' has wrong value : %d", int1);
  2101. X        break;
  2102. X    case WRONG_WHERE :
  2103. X        sprintf(mess, "Parameter 'where' has wrong value : %d", int1);
  2104. X        break;
  2105. X    case WRONG_WHICH :
  2106. X        sprintf(mess, "Parameter 'which' has wrong value : %d", int1);
  2107. X        break;
  2108. X    case UNKNOWN_ID :
  2109. X        sprintf(mess, "List id '%d' is unknown", int1);
  2110. X        break;
  2111. X    case UNKNOWN_FUNC :
  2112. X        sprintf(mess, "Function '%d' is unknown", int1);
  2113. X        break;
  2114. X    case NO_LIST :
  2115. X        sprintf(mess, "There are no lists defined");
  2116. X        break;
  2117. X    case EMPTY_LIST :
  2118. X#ifdef DEBUG
  2119. X        sprintf(mess, "List '%d' is empty", int1);
  2120. X        break;
  2121. X#else
  2122. X        return;
  2123. X#endif
  2124. X    case EOL :
  2125. X#ifdef DEBUG
  2126. X        sprintf(mess, "End of list '%d' reached", int1);
  2127. X        break;
  2128. X#else
  2129. X        return;
  2130. X#endif
  2131. X    case NOT_FOUND :
  2132. X#ifdef DEBUG
  2133. X        sprintf(mess, "Node not found in list '%d'", int1);
  2134. X        break;
  2135. X#else
  2136. X        return;
  2137. X#endif
  2138. X    case NOT_DOUBLY :
  2139. X        sprintf(mess, "List '%d' is not doubly linked", int1);
  2140. X        break;
  2141. X    case SIZE_NE :
  2142. X        sprintf(mess,
  2143. X            "Size of expected data '%d' and node '%d' not equal",
  2144. X            int1, int2);
  2145. X        break;
  2146. X    case WRONG_INDEX :
  2147. X        sprintf(mess, "Index '%d' out of range [1:%d]", int1, int2);
  2148. X        break;
  2149. X    case OPEN_ERROR :
  2150. X        sprintf(mess, "Can't open dump-file '%s'\n", str1);
  2151. X        break;
  2152. X    }
  2153. X
  2154. X    fpError = fopen(ERROR_FILE, "a");
  2155. X    if (fpError == NULL) {
  2156. X        fprintf(stderr, "Can't open error-file '%s'\n", ERROR_FILE);
  2157. X        fprintf(stderr, "Error, '%s': %s\n", str, mess);
  2158. X    } else {
  2159. X        fprintf(fpError, "Error, '%s': %s\n", str, mess);
  2160. X        fclose(fpError);
  2161. X    }
  2162. X#endif
  2163. X}
  2164. X
  2165. X/* dump a linked list to a file */
  2166. X/* file structure :
  2167. X *    <header> { <info> <data> }
  2168. X *    header.n    number of <info>-<data>-combinations (nodes)
  2169. X *    info.size    size of <data>
  2170. X */
  2171. X#ifdef ANSI
  2172. Xint
  2173. XlDump(int id, char *file)
  2174. X#else
  2175. Xint
  2176. XlDump(id, file)
  2177. Xint    id;
  2178. Xchar    *file;
  2179. X#endif
  2180. X{
  2181. X    int    open(), creat(), write(), close();
  2182. X
  2183. X    int    fdDump, i;
  2184. X    ListPtr    list;
  2185. X    NodePtr    node;
  2186. X    Info    info;
  2187. X    Header    header;
  2188. X
  2189. X    if ((list = getAddress(id)) == NULL) {
  2190. X        lError("lDump", UNKNOWN_ID, id, 0, NULL);
  2191. X        return(UNKNOWN_ID);
  2192. X    }
  2193. X
  2194. X    fdDump = open(file, BIN_WRITE);
  2195. X    if (fdDump == -1) {
  2196. X        fdDump = creat(file, PMODE);
  2197. X        if (fdDump == -1) {
  2198. X            lError("lDump", OPEN_ERROR, 0, 0, file);
  2199. X            return(OPEN_ERROR);
  2200. X        }
  2201. X    }
  2202. X
  2203. X    header.sd = list->sd;
  2204. X    header.cc = list->cc;
  2205. X    header.n = list->n;
  2206. X    write(fdDump, (char *) &header, sizeof(Header));
  2207. X
  2208. X    node = list->first;
  2209. X    for (i=0; i<header.n; i++) {
  2210. X        info.size = node->size;
  2211. X        info.flag = node->flag;
  2212. X        write(fdDump, (char *) &info, sizeof(Info));
  2213. X        write(fdDump, (char *) node->data, node->size);
  2214. X        node = node->nxt;
  2215. X    }
  2216. X
  2217. X    close(fdDump);
  2218. X    return(0);
  2219. X}
  2220. X
  2221. X/* undump a linked list from a file */
  2222. X#ifdef ANSI
  2223. Xint
  2224. XlUndump(char *file)
  2225. X#else
  2226. Xint
  2227. XlUndump(file)
  2228. Xchar    *file;
  2229. X#endif
  2230. X{
  2231. X    int    open(), read(), close();
  2232. X
  2233. X    int    fdDump, i, id;
  2234. X    Info    info;
  2235. X    Header    header;
  2236. X    Byte    *data;
  2237. X
  2238. X    fdDump = open(file, BIN_READ);
  2239. X    if (fdDump == -1) {
  2240. X        lError("lDump", OPEN_ERROR, 0, 0, file);
  2241. X        return(OPEN_ERROR);
  2242. X    }
  2243. X
  2244. X    read(fdDump, (char *) &header, sizeof(Header));
  2245. X    id = lDef(header.sd, header.cc);
  2246. X
  2247. X    for (i=0; i<header.n; i++) {
  2248. X        read(fdDump, (char *) &info, sizeof(Info));
  2249. X        CALLOC(data, Byte, info.size);
  2250. X        read(fdDump, (char *) data, info.size);
  2251. X        lInsNode(id, LAST, data, info.size, info.flag);
  2252. X        FREE(data);
  2253. X    }
  2254. X
  2255. X    close(fdDump);
  2256. X    return(id);
  2257. X}
  2258. X
  2259. X/* get data of node */
  2260. X#ifdef ANSI
  2261. Xint
  2262. XlFlagNode(int id, int flag, Byte *data, int size)
  2263. X#else
  2264. Xint
  2265. XlFlagNode(id, flag, data, size)
  2266. Xint    id, flag, size;
  2267. XByte    *data;
  2268. X#endif
  2269. X{
  2270. X    ListPtr    list;
  2271. X
  2272. X    if ((list = getAddress(id)) == NULL) {
  2273. X        lError("lFlagNode", UNKNOWN_ID, id, 0, NULL);
  2274. X        return(UNKNOWN_ID);
  2275. X    }
  2276. X    if (list->first == NULL) {
  2277. X        lError("lFlagNode", EMPTY_LIST, id, 0, NULL);
  2278. X        return(EMPTY_LIST);
  2279. X    }
  2280. X
  2281. X        /* search till end of list */
  2282. X    list->current = list->first;
  2283. X    while ((list->current)->flag != flag && list->current != list->last) {
  2284. X        list->current = (list->current)->nxt;
  2285. X    }
  2286. X
  2287. X        /* extra flag-check for last node of list */
  2288. X    if ((list->current)->flag != flag) {
  2289. X        lError("lFlagNode", NOT_FOUND, id, 0, NULL);
  2290. X        return(NOT_FOUND);
  2291. X    }
  2292. X
  2293. X        /* expected data and node must have same size */
  2294. X    if ((list->current)->size != size) {
  2295. X        lError("lFlagNode", SIZE_NE, size, (list->current)->size, NULL);
  2296. X        return(SIZE_NE);
  2297. X    } else {
  2298. X        BYTE_COPY((list->current)->data, data, size);
  2299. X        if (list->current == list->last)
  2300. X            return(LAST);
  2301. X        else if (list->current == list->first)
  2302. X            return(FIRST);
  2303. X        else
  2304. X            return(0);
  2305. X    }
  2306. X}
  2307. END_OF_FILE
  2308.   if test 21105 -ne `wc -c <'list.c'`; then
  2309.     echo shar: \"'list.c'\" unpacked with wrong size!
  2310.   fi
  2311.   # end of 'list.c'
  2312. fi
  2313. if test -f 'list.h' -a "${1}" != "-c" ; then 
  2314.   echo shar: Will not clobber existing file \"'list.h'\"
  2315. else
  2316.   echo shar: Extracting \"'list.h'\" \(2301 characters\)
  2317.   sed "s/^X//" >'list.h' <<'END_OF_FILE'
  2318. X#define    SINGLY        1    /* singly linked list */
  2319. X#define    DOUBLY        2    /* doubly linked list */
  2320. X#define    CHAIN        3    /* chain linked list */
  2321. X#define    CIRCULAR    4    /* circular linked list */
  2322. X
  2323. X#define    FIRST        1    /* add at front of list */
  2324. X                /* get/find/delete first node */
  2325. X#define    PREVIOUS    2    /* get/find previous node */
  2326. X#define    BEFORE        3    /* add before current node */
  2327. X#define    CURRENT        4    /* get/delete current node */
  2328. X#define    AFTER        5    /* add after current node */
  2329. X#define    NEXT        6    /* get/find next node */
  2330. X#define    LAST        7    /* add at end of list */
  2331. X                /* get/find/delete last node */
  2332. X
  2333. X#define    ONE_NODE    10    /* add first node to list / delete last node */
  2334. X
  2335. X#ifndef NULL
  2336. X#define    NULL        0
  2337. X#endif
  2338. X
  2339. X#define    WRONG_SD    -1    /* parameter 'sd' has wrong value */
  2340. X#define    WRONG_CC    -2    /* parameter 'cc' has wrong value */
  2341. X#define    WRONG_WHERE    -3    /* parameter 'where' has wrong value */
  2342. X#define    WRONG_WHICH    -4    /* parameter 'which' has wrong value */
  2343. X#define    UNKNOWN_ID    -5    /* list id is unknown */
  2344. X#define    UNKNOWN_FUNC    -6    /* function name is unknown */
  2345. X#define    NO_LIST        -7    /* there are no lists defined */
  2346. X#define    EMPTY_LIST    -8    /* list is empty */
  2347. X#define    EOL        -9    /* end of list reached */
  2348. X#define    NOT_FOUND    -10    /* node not found */
  2349. X#define    NOT_DOUBLY    -11    /* list is not doubly linked */
  2350. X#define    SIZE_NE        -12    /* size of expected data and node not equal */
  2351. X#define    WRONG_INDEX    -13    /* 'index' out of range */
  2352. X#define    OPEN_ERROR    -14    /* can't open dump-file */
  2353. X
  2354. X#define    FOUND        0    /* node found */
  2355. X
  2356. X#define    ERROR_FILE    "=listError="
  2357. X
  2358. X#ifdef ANSI
  2359. Xtypedef    int        (*Func)();
  2360. Xtypedef    unsigned char    Byte;
  2361. Xint    lDef(int sd, int cc),
  2362. X    lInsNode(int id, int where, Byte *data, int size, int flag),
  2363. X    lUpdNode(int id, Byte *data, int size, int flag),
  2364. X    lGetNode(int id, int which, Byte *data, int size),
  2365. X    lIndxNode(int id, int index, Byte *data, int size),
  2366. X    lFndNode(int id, int where, Func func, Byte *ptr, Byte *data, int size),
  2367. X    lDelNode(int id, int which),
  2368. X    lInfo(int id, int *sd, int *cc, int *n),
  2369. X    lInfoNode(int id, int which, int *size, int *flag),
  2370. X    lDel(int id),
  2371. X    lDelAll(void),
  2372. X    lDump(int id, char *file),
  2373. X    lUndump(char *file),
  2374. X    lFlagNode(int id, int flag, Byte *data, int size);
  2375. X#else
  2376. Xint    lDef(), lInsNode(), lUpdNode(), lGetNode(), lIndxNode(), lFndNode(),
  2377. X    lDelNode(), lInfo(), lInfoNode(), lDel(), lDelAll(), lDump(), lUndump(),
  2378. X    lFlagNode();
  2379. X#endif
  2380. END_OF_FILE
  2381.   if test 2301 -ne `wc -c <'list.h'`; then
  2382.     echo shar: \"'list.h'\" unpacked with wrong size!
  2383.   fi
  2384.   # end of 'list.h'
  2385. fi
  2386. echo shar: End of archive 1 \(of 1\).
  2387. cp /dev/null ark1isdone
  2388. MISSING=""
  2389. for I in 1 ; do
  2390.     if test ! -f ark${I}isdone ; then
  2391.     MISSING="${MISSING} ${I}"
  2392.     fi
  2393. done
  2394. if test "${MISSING}" = "" ; then
  2395.     echo You have the archive.
  2396.     rm -f ark[1-9]isdone
  2397. else
  2398.     echo You still must unpack the following archives:
  2399.     echo "        " ${MISSING}
  2400. fi
  2401. exit 0
  2402. exit 0 # Just in case...
  2403.