home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2737 < prev    next >
Internet Message Format  |  1991-02-09  |  41KB

  1. From: tron1@tronsbox.xei.com (Kenneth Jamieson)
  2. Newsgroups: alt.sources
  3. Subject: X_List 01/02
  4. Message-ID: <1363@tronsbox.xei.com>
  5. Date: 10 Feb 91 03:33:55 GMT
  6.  
  7.  
  8.     X_List is a library of doubly linked list routines in C and
  9. C++. C++ is fully supported with classes and overloaded [] operators.
  10.  
  11.     This source has makefiles for Amiga, DOS, SYSV and SUNOS and
  12. Berkley. It is VERY portable.
  13.  
  14.     In addition, there is a tutorial on lists and an example.
  15.  
  16.  
  17. Submitted by: tron1@tronsbox
  18. Archive-name: X_List/part01
  19.  
  20. ---- Cut Here and unpack ----
  21. #!/bin/sh
  22. # This is X_List, a shell archive (shar 3.10)
  23. # made 02/10/1991 02:43 UTC by tron1@tronsbox
  24. # Source directory /u1/home/tron1/src/tron1/shareware
  25. #
  26. # existing files WILL be overwritten
  27. #
  28. # This is part 1 of a multipart archive                                    
  29. # do not concatenate these parts, unpack them in order with /bin/sh        
  30. #
  31. # This shar contains:
  32. # length  mode       name
  33. # ------ ---------- ------------------------------------------
  34. #      0 -rw-r----- lib/foo
  35. #      0 -rw-r----- include/foo
  36. #    234 -r--r----- x_list/src/copyr.h
  37. #   3101 -r--r----- x_list/src/make.cpp
  38. #   1359 -r--r----- x_list/src/make.sas
  39. #   1393 -r--r----- x_list/src/make.tcc
  40. #   1453 -r--r----- x_list/src/make.unx
  41. #   3480 -r--r----- x_list/src/sharew.h
  42. #   9151 -r--r----- x_list/src/testit.c
  43. #   9468 -r--r----- x_list/src/x_list.c
  44. #   3423 -r--r----- x_list/src/x_list.h
  45. #   3602 -rw-r----- x_list/distrib
  46. #  10905 -rw-r----- x_list/docs
  47. #   5022 -rw-r----- x_list/install
  48. #   2856 -rw-r----- x_list/readme
  49. #   9972 -rw-r----- x_list/lists
  50. #
  51. touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
  52. if [ -s /tmp/s3_touch$$ ]
  53. then
  54.     TOUCH=can
  55. else
  56.     TOUCH=cannot
  57. fi
  58. rm -f /tmp/s3_touch$$
  59. if test -r s3_seq_.tmp
  60. then echo "Must unpack archives in sequence!"
  61.      next=`cat s3_seq_.tmp`; echo "Please unpack part $next next"
  62.      exit 1; fi
  63. # ============= lib/foo ==============
  64. if test ! -d 'lib' ; then
  65.     echo "x - creating directory lib"
  66.     mkdir 'lib'
  67. fi
  68. echo "x - extracting lib/foo (Binary)"
  69. sed 's/^X//' << 'SHAR_EOF' > s3_temp_.tmp &&
  70. Xbegin 600 lib/foo
  71. X`
  72. Xend
  73. SHAR_EOF
  74. echo "uudecoding file lib/foo"
  75. uudecode < s3_temp_.tmp && rm -f s3_temp_.tmp &&
  76. chmod 0640 lib/foo || echo "restore of lib/foo fails"
  77. if [ $TOUCH = can ]
  78. then
  79.     touch -am 0209185491 lib/foo
  80. fi
  81. set `wc -c lib/foo`;Wc_c=$1
  82. if test "$Wc_c" != "0"
  83. then echo original size 0, current size $Wc_c;fi
  84. # ============= include/foo ==============
  85. if test ! -d 'include' ; then
  86.     echo "x - creating directory include"
  87.     mkdir 'include'
  88. fi
  89. echo "x - extracting include/foo (Binary)"
  90. sed 's/^X//' << 'SHAR_EOF' > s3_temp_.tmp &&
  91. Xbegin 600 include/foo
  92. X`
  93. Xend
  94. SHAR_EOF
  95. echo "uudecoding file include/foo"
  96. uudecode < s3_temp_.tmp && rm -f s3_temp_.tmp &&
  97. chmod 0640 include/foo || echo "restore of include/foo fails"
  98. if [ $TOUCH = can ]
  99. then
  100.     touch -am 0209185391 include/foo
  101. fi
  102. set `wc -c include/foo`;Wc_c=$1
  103. if test "$Wc_c" != "0"
  104. then echo original size 0, current size $Wc_c;fi
  105. # ============= x_list/src/copyr.h ==============
  106. if test ! -d 'x_list' ; then
  107.     echo "x - creating directory x_list"
  108.     mkdir 'x_list'
  109. fi
  110. if test ! -d 'x_list/src' ; then
  111.     echo "x - creating directory x_list/src"
  112.     mkdir 'x_list/src'
  113. fi
  114. echo "x - extracting x_list/src/copyr.h (Text)"
  115. sed 's/^X//' << 'SHAR_EOF' > x_list/src/copyr.h &&
  116. X/* 
  117. X         Copyright include notice :    copyr.h 1.2 2/9/91 
  118. X*/
  119. X
  120. X/* 
  121. XAll text in this file is copyright (c) 1991 by Kenneth Jamieson
  122. X*/
  123. X#ifndef X_COPYRIGHT
  124. X#define X_COPYRIGHT "Compiled from source (c) 1991 Kenneth Jamieson"
  125. X#endif
  126. SHAR_EOF
  127. chmod 0440 x_list/src/copyr.h || echo "restore of x_list/src/copyr.h fails"
  128. if [ $TOUCH = can ]
  129. then
  130.     touch -am 0209182491 x_list/src/copyr.h
  131. fi
  132. set `wc -c x_list/src/copyr.h`;Wc_c=$1
  133. if test "$Wc_c" != "234"
  134. then echo original size 234, current size $Wc_c;fi
  135. # ============= x_list/src/make.cpp ==============
  136. echo "x - extracting x_list/src/make.cpp (Text)"
  137. sed 's/^X//' << 'SHAR_EOF' > x_list/src/make.cpp &&
  138. X# Amiga "C++" Makefile for the x_list library
  139. X#
  140. X#     Amiga "C++" Makefile for x_list functions.  make.cpp 1.2 2/9/91 
  141. X#
  142. X# Set the CC variable to any compiler that can take ANSI C
  143. XCC=lc
  144. X# Set the CPP variable to the C++ pre-processor
  145. XCPP=cpp
  146. X# Set the CFRONT variable to the C++ to C translator
  147. XCFRONT=cfront
  148. X
  149. X# Set any other flags you want the C compiler to honor
  150. XCFLAGS=-O -i//include -i/src -i/include -dNULL=0 -c+
  151. X
  152. X# Set any other flags you want the CPP to honor
  153. XCPPFLAGS= -i//include -i/src -i/include -iCPINCLUDE: -iINCLUDE: -dNULL=0
  154. X
  155. X# The command that is used to make an archive 
  156. XARCHIVE=oml 
  157. X
  158. X# Un-comment this if you DO want to build the C++ routines as well
  159. XBUILD_CPP=-dIS_CPP
  160. X
  161. Xall: x_list.lib testit
  162. X    @echo " "
  163. X    @echo "======================================================="
  164. X    @echo "= Done building x_list list manager system...         ="
  165. X    @echo "= Run the program 'testit' to see if it works.        ="
  166. X    @echo "= Remember to type 'lmk install' if all went well.    ="
  167. X    @echo "= Then you can 'lmk clean' to get rid of temp files.  ="
  168. X    @echo "= - - - - - - - - - - - - - - - - - - - - - - - - - - ="
  169. X    @echo "= Please don't forget that this is is shareware!      ="
  170. X    @echo "======================================================="
  171. X    @echo " "
  172. X
  173. Xinstall:
  174. X    copy x_list.lib //lib
  175. X    copy x_list.h //include
  176. X
  177. Xx_list.lib: _x_list.o 
  178. X    $(ARCHIVE) x_list.lib r _x_list.o
  179. X
  180. X_x_list.o: x_list.cp x_list.h
  181. X    @echo " "
  182. X    @echo "======================================================="
  183. X    @echo "= We have to take the long way around for this...     ="
  184. X    @echo "= the 'cc' command alone did not give enough control. ="
  185. X    @echo "= Please ignore the warnings, they are ok.            ="
  186. X    @echo "= They ONLY show up under C++, and ONLY on the Amiga! ="
  187. X    @echo "= I suspect it is a C++ bug in Lattice.               ="
  188. X    @echo "======================================================="
  189. X    @echo " "
  190. X    -delete x_list.p
  191. X    $(CPP) <x_list.cp >x_list.p $(CPPFLAGS) $(BUILD_CPP)
  192. X    $(CFRONT) <x_list.p >_x_list.c +L
  193. X    $(CC) $(CFLAGS) $(BUILD_CPP) _x_list.c  
  194. X
  195. Xtestit: testit.cp x_list.lib x_list.h
  196. X    @echo " "
  197. X    @echo "======================================================="
  198. X    @echo "= We have to take the long way around for this...     ="
  199. X    @echo "= the 'cc' command alone did not give enough control. ="
  200. X    @echo "= Please ignore the warnings, they are ok.            ="
  201. X    @echo "= They ONLY show up under C++, and ONLY on the Amiga! ="
  202. X    @echo "= I suspect it is a C++ bug in Lattice.               ="
  203. X    @echo "======================================================="
  204. X    @echo " "
  205. X    -delete testit.p
  206. X    $(CPP) <testit.cp >testit.p $(CPPFLAGS) $(BUILD_CPP)
  207. X    $(CFRONT) <testit.p >_testit.c +L
  208. X    $(CC) $(CFLAGS) $(BUILD_CPP) -L+LIB:CPLUS.lib+x_list.lib _testit.c
  209. X    rename _testit testit
  210. X    rename _testit.info testit.info
  211. X
  212. Xx_list.cp: x_list.c
  213. X    copy x_list.c x_list.cp
  214. X
  215. Xtestit.cp: testit.c
  216. X    copy testit.c testit.cp
  217. X
  218. Xclean: 
  219. X    -delete _x_list.o
  220. X    -delete _testit.o
  221. X    -delete _x_list.c
  222. X    -delete x_list.p
  223. X    -delete testit.p
  224. X    -delete x_list.cp
  225. X    -delete testit.cp
  226. X    -delete x_list.lib
  227. X    -delete testit
  228. X    -delete testit.info
  229. X    -delete _testit.lnk
  230. X    -delete _testit.c
  231. SHAR_EOF
  232. chmod 0440 x_list/src/make.cpp || echo "restore of x_list/src/make.cpp fails"
  233. if [ $TOUCH = can ]
  234. then
  235.     touch -am 0209182491 x_list/src/make.cpp
  236. fi
  237. set `wc -c x_list/src/make.cpp`;Wc_c=$1
  238. if test "$Wc_c" != "3101"
  239. then echo original size 3101, current size $Wc_c;fi
  240. # ============= x_list/src/make.sas ==============
  241. echo "x - extracting x_list/src/make.sas (Text)"
  242. sed 's/^X//' << 'SHAR_EOF' > x_list/src/make.sas &&
  243. X# Amiga "C" Makefile for the x_list library
  244. X#
  245. X#     Amiga "C" Makefile for x_list functions.  make.sas 1.2 2/9/91 
  246. X#
  247. X# Set the CC variable to any compiler that can take ANSI C
  248. XCC=lc
  249. X
  250. X# Set any other flags you want the compiler to honor
  251. XCFLAGS=-O -i//include -i/src -i/include
  252. X
  253. X# The command that is used to make an archive 
  254. XARCHIVE=oml 
  255. X
  256. X# Un-comment this if you DO NOT want to build the C++ routines as well
  257. X#BUILD_CPP=
  258. X
  259. Xall: x_list.lib testit
  260. X    @echo " "
  261. X    @echo "======================================================="
  262. X    @echo "= Done building x_list list manager system...         ="
  263. X    @echo "= Run the program 'testit' to see if it works.        ="
  264. X    @echo "= Remember to type 'lmk install' if all went well.    ="
  265. X    @echo "= Then you can 'lmk clean' to get rid of temp files.  ="
  266. X    @echo "= - - - - - - - - - - - - - - - - - - - - - - - - - - ="
  267. X    @echo "= Please don't forget that this is is shareware!      ="
  268. X    @echo "======================================================="
  269. X    @echo " "
  270. X
  271. Xinstall:
  272. X    copy x_list.lib //lib
  273. X    copy x_list.h //include
  274. X
  275. Xx_list.lib: x_list.o 
  276. X    $(ARCHIVE) x_list.lib r x_list.o
  277. X
  278. Xx_list.o: x_list.c x_list.h
  279. X    $(CC) $(CFLAGS) $(BUILD_CPP) x_list.c
  280. X
  281. Xtestit: testit.c x_list.lib x_list.h
  282. X    $(CC) $(CFLAGS) $(BUILD_CPP) -L+x_list.lib testit.c
  283. X
  284. Xclean: 
  285. X    -delete x_list.o
  286. X    -delete x_list.lib
  287. X    -delete testit.o
  288. X    -delete testit
  289. X    -delete testit.lnk
  290. SHAR_EOF
  291. chmod 0440 x_list/src/make.sas || echo "restore of x_list/src/make.sas fails"
  292. if [ $TOUCH = can ]
  293. then
  294.     touch -am 0209182491 x_list/src/make.sas
  295. fi
  296. set `wc -c x_list/src/make.sas`;Wc_c=$1
  297. if test "$Wc_c" != "1359"
  298. then echo original size 1359, current size $Wc_c;fi
  299. # ============= x_list/src/make.tcc ==============
  300. echo "x - extracting x_list/src/make.tcc (Text)"
  301. sed 's/^X//' << 'SHAR_EOF' > x_list/src/make.tcc &&
  302. X# Turbo C++ Makefile for the x_list library
  303. X#
  304. X#     Turbo C++ Makefile for x_list functions.  make.tcc 1.3 2/9/91 
  305. X#
  306. X# Set the CC variable to any compiler that can take ANSI C
  307. XCC=tcc.exe
  308. X# Set any other flags you want the compiler to honor
  309. XCFLAGS=-O -P -I. -Qx
  310. X# The command that is used to make an archive 
  311. XARCHIVE=tlib 
  312. X# Un-comment this if you want to build the C++ routines as well
  313. XBUILD_CPP=-DIS_CPP
  314. X# Un-comment this if you DO NOT want to build the C++ routines as well
  315. X#BUILD_CPP=
  316. Xall: x_list.lib testit.exe
  317. X    @echo .
  318. X    @echo =======================================================
  319. X    @echo = Done building x_list list manager system...         =
  320. X    @echo = Run the program 'testit' to see if it works.        =
  321. X    @echo = Remember to type 'make install' if all went well.   =
  322. X    @echo = Then you can 'make clean' to get rid of temp files. =
  323. X    @echo = - - - - - - - - - - - - - - - - - - - - - - - - - - =
  324. X    @echo = Please don't forget that this is is shareware!      =
  325. X    @echo =======================================================
  326. X    @echo .
  327. X
  328. Xinstall:
  329. X    copy x_list.lib ..\..\lib
  330. X    copy *.h ..\..\include
  331. X
  332. Xx_list.lib: x_list.obj
  333. X    $(ARCHIVE) x_list.lib +x_list.obj
  334. X
  335. Xx_list.obj: x_list.c x_list.h
  336. X    $(CC) $(CFLAGS) $(BUILD_CPP) -c x_list.c
  337. X
  338. Xtestit.exe: testit.c x_list.lib x_list.h
  339. X    $(CC) $(CFLAGS) $(BUILD_CPP) testit.c x_list.lib
  340. X
  341. Xclean: 
  342. X    del x_list.obj
  343. X    del testit.obj
  344. X    del x_list.lib
  345. X    del testit.exe
  346. X
  347. SHAR_EOF
  348. chmod 0440 x_list/src/make.tcc || echo "restore of x_list/src/make.tcc fails"
  349. if [ $TOUCH = can ]
  350. then
  351.     touch -am 0209205991 x_list/src/make.tcc
  352. fi
  353. set `wc -c x_list/src/make.tcc`;Wc_c=$1
  354. if test "$Wc_c" != "1393"
  355. then echo original size 1393, current size $Wc_c;fi
  356. # ============= x_list/src/make.unx ==============
  357. echo "x - extracting x_list/src/make.unx (Text)"
  358. sed 's/^X//' << 'SHAR_EOF' > x_list/src/make.unx &&
  359. X# UNIX Makefile for the x_list library
  360. X#
  361. X#     Unix Makefile for x_list functions.  make.unx 1.2 2/9/91 
  362. X#
  363. X# Set the CC variable to any compiler that can take ANSI C
  364. XCC=CC
  365. X
  366. X# Set any other flags you want the compiler to honor
  367. XCFLAGS=-O -I.. -I. -I../include
  368. X
  369. X# The command that is used to make an archive 
  370. XARCHIVE=ar -cr 
  371. X
  372. X# Un-comment this if you want to build the C++ routines as well
  373. XBUILD_CPP=-DIS_CPP
  374. X# Un-comment this if you DO NOT want to build the C++ routines as well
  375. X#BUILD_CPP=
  376. X
  377. Xall: x_list.a testit
  378. X    @echo " "
  379. X    @echo "======================================================="
  380. X    @echo "= Done building x_list list manager system...         ="
  381. X    @echo "= Run the program 'testit' to see if it works.        ="
  382. X    @echo "= Remember to type 'make install' if all went well.   ="
  383. X    @echo "= Then you can 'make clean' to get rid of temp files. ="
  384. X    @echo "= - - - - - - - - - - - - - - - - - - - - - - - - - - ="
  385. X    @echo "= Please don't forget that this is is shareware!      ="
  386. X    @echo "======================================================="
  387. X    @echo " "
  388. X
  389. Xinstall:
  390. X    cp x_list.a ../../lib
  391. X    chmod 644 ../../lib/x_list.a
  392. X    cp x_list.h ../../include
  393. X    chmod 644 ../../include/x_list.h
  394. X
  395. Xx_list.a: x_list.o 
  396. X    $(ARCHIVE) x_list.a x_list.o
  397. X
  398. Xx_list.o: x_list.c x_list.h
  399. X    $(CC) $(CFLAGS) $(BUILD_CPP) -c x_list.c
  400. X
  401. Xtestit: testit.c x_list.a x_list.h
  402. X    $(CC) $(CFLAGS) $(BUILD_CPP) -o testit testit.c x_list.a
  403. X
  404. Xclean: 
  405. X    -rm x_list.o
  406. X    -rm x_list.a
  407. X    -rm testit.o
  408. X    -rm testit
  409. SHAR_EOF
  410. chmod 0440 x_list/src/make.unx || echo "restore of x_list/src/make.unx fails"
  411. if [ $TOUCH = can ]
  412. then
  413.     touch -am 0209182491 x_list/src/make.unx
  414. fi
  415. set `wc -c x_list/src/make.unx`;Wc_c=$1
  416. if test "$Wc_c" != "1453"
  417. then echo original size 1453, current size $Wc_c;fi
  418. # ============= x_list/src/sharew.h ==============
  419. echo "x - extracting x_list/src/sharew.h (Text)"
  420. sed 's/^X//' << 'SHAR_EOF' > x_list/src/sharew.h &&
  421. X/* 
  422. X         Shareware license document :    sharew.h 1.1 2/3/91 
  423. X*/
  424. X/*
  425. X
  426. XThis text in this file is copyright (c) 1991 by Kenneth Jamieson.
  427. X
  428. XThe author may be reached at the US MAIL address listed below, or
  429. Xby sending unix mail to ...
  430. X
  431. X           tron1@tronsbox.xei.com            or
  432. X       ...!uunet!tronsbox.xei.com!tron1  or
  433. X       yelling "Hey Ken!" if you happen to be close enough.
  434. X
  435. X
  436. XAll rights are reserved by Kenneth Jamieson.
  437. X
  438. XYou are granted permission to use this code under the following 
  439. Xrestrictions:
  440. X
  441. XNOTE: All occurrences of the word "code" below will apply to
  442. X      all files, text, program source code and documentation.
  443. X
  444. X1) This code cannot be used in any program that is to be distributed 
  445. X   to anyone other than that program's author without the
  446. X   written permission of Kenneth Jamieson. This permission will be granted 
  447. X   under the terms of registration listed below.
  448. X
  449. X2) This code may be used for a trial period of thirty (30) days.
  450. X   At that time, you mus either register the code as below or
  451. X   discontinue it's use.
  452. X   
  453. X3) UNDER NO CIRCUMSTANCES may this code (registered or not) be used or 
  454. X   distributed in any way that will prevent it's future distribution 
  455. X   under the terms of this license.
  456. X
  457. X   This specifically includes (but is not limited to) any code that
  458. X   is to be distributed under the terms of the Free Software 
  459. X   Foundation's General Public License.
  460. X
  461. X4) Kenneth Jamieson reserves all rights to this code.
  462. X
  463. X5) NO WARRANTY is given or implied as to the usefulness or correctness of 
  464. X   this code for any purpose at all, whether this code is registered or not.
  465. X
  466. X
  467. XREGISTRATION:
  468. X
  469. X   You are encouraged to register this code no matter what you use it for,
  470. X   but you MUST register this code if you need written permission under
  471. X   the terms above for distribution or intend to use it after the
  472. X   trial period expires.
  473. X
  474. X   In order to register this code, just send $15 US to the author at the
  475. X   address listed below. 
  476. X
  477. X   Kenneth Jamieson
  478. X   P.o. Box 387 
  479. X   Kearny NJ 07023
  480. X   USA
  481. X   
  482. X   Once registered you will receive permission to use this code in your own
  483. X   programs under the following restrictions:
  484. X
  485. X   1) Your program or documentation must mention that this code is in use,
  486. X      and provide your user with information about where to obtain this
  487. X      code. This information must be provided as part of the initial
  488. X      cost (if any) of your software.
  489. X
  490. X   2) If you distribute the source to your program, then the source 
  491. X      for this code must accompany your code complete and unaltered.
  492. X
  493. X   3) UNDER NO CIRCUMSTANCES may this code (registered or not) be used or 
  494. X      distributed in any way that will prevent it's future distribution 
  495. X      under the terms of this license except by Kenneth Jamieson.
  496. X
  497. X      This specifically includes (but is not limited to) any code that
  498. X      is to be distributed under the terms of the Free Software 
  499. X      Foundation's General Public License.
  500. X
  501. X   4) Kenneth Jamieson reserves all rights to this code.
  502. X
  503. X   5) NO WARRANTY is given or implied as to the usefulness or correctness of 
  504. X      this code for any purpose at all, whether this code is registered or not.
  505. X
  506. X   In addition, you will get a list of any known bugs and work-arounds,
  507. X   notice of the next update (if any), and at least one "thank you".
  508. X
  509. X
  510. X
  511. X-----------------------------------------------------
  512. X* UNIX is a trademark of AT&T
  513. X* Amiga is a trademark of Commodore Business Machines
  514. X* MS-DOS is a trademark of Microsoft Inc 
  515. X
  516. X*/
  517. SHAR_EOF
  518. chmod 0440 x_list/src/sharew.h || echo "restore of x_list/src/sharew.h fails"
  519. if [ $TOUCH = can ]
  520. then
  521.     touch -am 0209182491 x_list/src/sharew.h
  522. fi
  523. set `wc -c x_list/src/sharew.h`;Wc_c=$1
  524. if test "$Wc_c" != "3480"
  525. then echo original size 3480, current size $Wc_c;fi
  526. # ============= x_list/src/testit.c ==============
  527. echo "x - extracting x_list/src/testit.c (Text)"
  528. sed 's/^X//' << 'SHAR_EOF' > x_list/src/testit.c &&
  529. X/* 
  530. X
  531. X   Doubly linked list test file : 
  532. X
  533. X         testit.c :    testit.c 1.2 2/9/91 
  534. X
  535. X*/
  536. X
  537. X/*
  538. X
  539. XThis text in this file is copyright (c) 1991 by Kenneth Jamieson.
  540. X
  541. XThe author may be reached at the US MAIL address listed below, or
  542. Xby sending unix mail to ...
  543. X
  544. X           tron1@tronsbox.xei.com            or
  545. X       ...!uunet!tronsbox.xei.com!tron1  or
  546. X       yelling "Hey Ken!" if you happen to be close enough.
  547. X
  548. X
  549. X       SEE THE FILE "sharew.h" for details before you
  550. X       use this code !!!
  551. X
  552. X*/
  553. X
  554. X#include <copyr.h>
  555. X#include <x_list.h>
  556. X#include <stdio.h>
  557. X#include <stdlib.h>
  558. X
  559. X#ifndef IS_CPP
  560. X
  561. X/* Not C++ -- so test the regular C functions */
  562. X
  563. Xint main(){
  564. X  struct x_list * test_xlist;
  565. X  int loop;
  566. X  int * foo;
  567. X
  568. X  printf("\ntestit - a testing program for the x_list list\n");
  569. X  printf("         manager. testit.c  testit.c 1.2 2/9/91 \n\n");
  570. X
  571. X
  572. X  /* Let's create the list that we will play with */
  573. X  test_xlist = init_xlist();
  574. X  if( test_xlist == NULL ){
  575. X    fprintf(stderr,"There is an error in the init_xlist() function!\n");
  576. X    return( FALSE );
  577. X  }else{
  578. X    printf("\nOk.... init_xlist() seems to be working ok!\n");
  579. X  }
  580. X
  581. X  /* Let's set the user pointer just to play with !    */
  582. X  if( set_user_xlist( test_xlist, "User data test!" ) == FALSE ){
  583. X    fprintf(stderr,"Error in the set_user_xlist() function!\n");
  584. X  }else{
  585. X    printf("Ok.... set_user_xlist() seems to be working ok!\n");
  586. X  }
  587. X
  588. X  /* Let's get the user pointer just to play with !    */
  589. X  if( get_user_xlist( test_xlist ) == NULL ){
  590. X    fprintf(stderr,"Error in the get_user_xlist() function!\n");
  591. X    return( FALSE );
  592. X  }else{
  593. X    printf("Ok.... get_user_xlist() seems to be working ok!\n");
  594. X  }
  595. X
  596. X  /* Add 100 integers to the list just for fun !    */
  597. X  for( loop = 0; loop < 100; loop++ ){
  598. X    foo = (int *)malloc( sizeof(int) );
  599. X    if( foo == NULL ){
  600. X      fprintf(stderr,"Malloc error on test insert #%d !\n", loop);
  601. X      return( FALSE );
  602. X    }
  603. X    *foo = loop;
  604. X    if( add_xlist( test_xlist, foo ) == FALSE ){
  605. X      fprintf(stderr,"add_xlist() error on test insert #%d !\n", loop);
  606. X      return( FALSE );
  607. X    }
  608. X  }
  609. X  
  610. X  /* Now .. see that the counter got set right! */
  611. X  if( get_count_xlist( test_xlist ) != 100 ){
  612. X    fprintf(stderr,"get_count_xlist() error! Said #%d, should be 100 !\n",
  613. X        get_count_xlist( test_xlist ) );
  614. X    return( FALSE );
  615. X  }else{
  616. X    printf("Ok.... get_count_xlist() seams to be working ok!\n");
  617. X  }
  618. X
  619. X  /* Now, reset the list to the end ! */
  620. X  if( tail_xlist( test_xlist ) == FALSE ){
  621. X    fprintf(stderr,"tail_xlist() error !\n", loop);
  622. X    return( FALSE );
  623. X  }else{
  624. X    printf("Ok.... tail_xlist() seems to be working!\n");
  625. X  }
  626. X
  627. X  /* Now, reset the list to the top ! */
  628. X  if( head_xlist( test_xlist ) == FALSE ){
  629. X    fprintf(stderr,"head_xlist() error !\n", loop);
  630. X    return( FALSE );
  631. X  }else{
  632. X    printf("Ok.... head_xlist() seems to be working!\n");
  633. X  }
  634. X
  635. X  /* Now, let's retrieve all that data and make sure that it is right ! */
  636. X  for( loop = 0; loop < 100; loop++ ){
  637. X    foo = (int *)get_xlist( test_xlist ); 
  638. X    if( foo == NULL ){
  639. X      fprintf(stderr,"get_xlist() error on test retrieve #%d !\n", loop);
  640. X      return( FALSE );
  641. X    }
  642. X    if( *foo != loop ){
  643. X      fprintf(stderr,"get_xlist() error on test retrieve #%d !\n", loop);
  644. X      return( FALSE );
  645. X    }
  646. X    if( get_nodenum_xlist( test_xlist ) != loop ){
  647. X      fprintf(stderr,
  648. X          "get_nodenum_xlist() error on test retrieve #%d !\n", loop);
  649. X    }
  650. X    if( next_xlist( test_xlist ) == FALSE && loop != 99 ){
  651. X      fprintf(stderr,"next_xlist() error on test retrieve #%d !\n", loop);
  652. X      return( FALSE );
  653. X    }
  654. X  }
  655. X  
  656. X  printf("Ok.... 100 retrieves went ok, next_xlist() is working fine !\n");
  657. X
  658. X  /* Now, let's retrieve all that data and make sure that it is right ! */
  659. X  for( loop = 99; loop > -1; loop-- ){
  660. X    foo = (int *)get_xlist( test_xlist ); 
  661. X    if( foo == NULL ){
  662. X      fprintf(stderr,"get_xlist() error on test retrieve #%d !\n", loop);
  663. X      return( FALSE );
  664. X    }
  665. X    if( *foo != loop ){
  666. X      fprintf(stderr,"get_xlist() error on test retrieve #%d !\n", loop);
  667. X      return( FALSE );
  668. X    }
  669. X    if( get_nodenum_xlist( test_xlist ) != loop ){
  670. X      fprintf(stderr,
  671. X          "get_nodenum_xlist() error on test retrieve #%d !\n", loop);
  672. X    }
  673. X    if( prev_xlist( test_xlist ) == FALSE && loop != 0 ){
  674. X      fprintf(stderr,"prev_xlist() error on test retrieve #%d !\n", loop);
  675. X      return( FALSE );
  676. X    }
  677. X  }
  678. X  
  679. X  printf("Ok.... 100 retrieves went ok, prev_xlist() is working fine !\n");
  680. X
  681. X  if( goto_xlist( test_xlist, 50 ) == FALSE ){
  682. X      fprintf(stderr,"goto_xlist() error  !\n");
  683. X      return( FALSE );    
  684. X  }
  685. X  foo = (int *)get_xlist( test_xlist ); 
  686. X  if( foo == NULL ){
  687. X    fprintf(stderr,
  688. X        "get_xlist() error on retrieve for goto_xlist() !\n");
  689. X    return( FALSE );
  690. X  }
  691. X  if( *foo != 50 ){
  692. X    fprintf(stderr,
  693. X        "get_xlist() error on retrieve for goto_xlist() !\n");
  694. X    return( FALSE );
  695. X  }  
  696. X  printf("Ok.... goto_xlist() seems to be working fine !\n");
  697. X
  698. X  if( get_nodenum_xlist( test_xlist ) != 50 ){
  699. X    fprintf(stderr,
  700. X        "get_nodenum_xlist() error (does not match)! \n");
  701. X    return( FALSE );
  702. X  }
  703. X  printf("Ok.... get_nodenum_xlist() seems to be working ok! \n");
  704. X
  705. X
  706. X  if( free_xlist( test_xlist ) == FALSE ){
  707. X    fprintf(stderr,"free_xlist() error !!! \n");
  708. X    return( FALSE );
  709. X  }else{
  710. X    printf("Ok.... free_xlist() seems to be working! \n");
  711. X  }
  712. X
  713. X  printf("\nAll tests passed ! Congratulations !\n\n");
  714. X  return( TRUE );
  715. X}
  716. X
  717. X#endif
  718. X
  719. X#ifdef IS_CPP
  720. X
  721. X/*  C++ -- so test the C++ functions */
  722. X
  723. Xint main(){
  724. X  X_List test_xlist;
  725. X  int loop;
  726. X  int * foo;
  727. X
  728. X  printf("\ntestit - a testing program for the x_list list\n");
  729. X  printf("         manager (C++ version). testit.c testit.c 1.2 2/9/91\n\n");
  730. X
  731. X  /* Let's set the user pointer just to play with !    */
  732. X  if( test_xlist.set_user( "User data test!" ) == FALSE ){
  733. X    fprintf(stderr,"Error in the X_List.set_user() function!\n");
  734. X  }else{
  735. X    printf("Ok.... X_List.set_user() seems to be working ok!\n");
  736. X  }
  737. X
  738. X  /* Let's get the user pointer just to play with !    */
  739. X  if( test_xlist.get_user() == NULL ){
  740. X    fprintf(stderr,"Error in the X_List.get_user() function!\n");
  741. X    return( FALSE );
  742. X  }else{
  743. X    printf("Ok.... X_List.get_user() seems to be working ok!\n");
  744. X  }
  745. X
  746. X  /* Add 100 integers to the list just for fun !    */
  747. X  for( loop = 0; loop < 100; loop++ ){
  748. X    foo = (int *)malloc( sizeof(int) );
  749. X    if( foo == NULL ){
  750. X      fprintf(stderr,"Malloc error on test insert #%d !\n", loop);
  751. X      return( FALSE );
  752. X    }
  753. X    *foo = loop;
  754. X    if( test_xlist.add( foo ) == FALSE ){
  755. X      fprintf(stderr,"X_List.add() error on test insert #%d !\n", loop);
  756. X      return( FALSE );
  757. X    }
  758. X  }
  759. X  
  760. X  /* Now .. see that the counter got set right! */
  761. X  if( test_xlist.count() != 100 ){
  762. X    fprintf(stderr,"X_List.count() error! Said #%d, should be 100 !\n",
  763. X        test_xlist.count() );
  764. X    return( FALSE );
  765. X  }else{
  766. X    printf("Ok.... X_List.count() seams to be working ok!\n");
  767. X  }
  768. X
  769. X  /* Now, reset the list to the top ! */
  770. X  if( test_xlist.head() == FALSE ){
  771. X    fprintf(stderr,"X_List.head() error !\n", loop);
  772. X    return( FALSE );
  773. X  }else{
  774. X    printf("Ok.... X_List.head() seems to be working!\n");
  775. X  }
  776. X
  777. X  /* Now, let's retrieve all that data and make sure that it is right ! */
  778. X  for( loop = 0; loop < 100; loop++ ){
  779. X    foo = (int *)test_xlist.get(); 
  780. X    if( foo == NULL ){
  781. X      fprintf(stderr,"X_List.get() error on test retrieve #%d !\n", loop);
  782. X      return( FALSE );
  783. X    }
  784. X    if( *foo != loop ){
  785. X      fprintf(stderr,"X_List.get() error on test retrieve #%d !\n", loop);
  786. X      return( FALSE );
  787. X    }
  788. X    if( test_xlist.next() == FALSE && loop != 99 ){
  789. X      fprintf(stderr,"X_List.next() error on test retrieve #%d !\n", loop);
  790. X      return( FALSE );
  791. X    }
  792. X  }
  793. X  
  794. X  printf("Ok.... 100 retrieves went ok, X_List.next() is working fine !\n");
  795. X
  796. X  /* Now, let's retrieve all that data and make sure that it is right ! */
  797. X  for( loop = 99; loop > -1; loop-- ){
  798. X    foo = (int *)test_xlist.get(); 
  799. X    if( foo == NULL ){
  800. X      fprintf(stderr,"X_List.get() error on test retrieve #%d !\n", loop);
  801. X      return( FALSE );
  802. X    }
  803. X    if( *foo != loop ){
  804. X      fprintf(stderr,"X_List.get() error on test retrieve #%d !\n", loop);
  805. X      return( FALSE );
  806. X    }
  807. X    if( test_xlist.prev() == FALSE && loop != 0 ){
  808. X      fprintf(stderr,"X_List.prev() error on test retrieve #%d !\n", loop);
  809. X      return( FALSE );
  810. X    }
  811. X  }
  812. X  
  813. X  printf("Ok.... 100 retrieves went ok, X_List.prev() is working fine !\n");
  814. X
  815. X  /* Now, let's retrieve it with the [] operator ! */
  816. X  for( loop = 99; loop > -1; loop-- ){
  817. X    foo = (int *)test_xlist[loop]; 
  818. X    if( foo == NULL ){
  819. X      fprintf(stderr,"X_List operator [] error on #%d !\n", loop);
  820. X      return( FALSE );
  821. X    }
  822. X    if( *foo != loop ){
  823. X      fprintf(stderr,"X_List operator [] error on #%d !\n", loop);
  824. X      return( FALSE );
  825. X    }
  826. X    if( test_xlist.nodenum() != loop ){
  827. X      fprintf(stderr,"X_List.nodenum() error on #%d!\n", loop);
  828. X    }
  829. X  }
  830. X  printf("Ok.... X_List.goto_node() seems to work ok!\n");
  831. X  printf("Ok.... X_List.nodenum() seems to work ok!\n");
  832. X  printf("Ok.... the operator [] seems to work ok!\n");
  833. X  
  834. X  printf("\nAll tests passed ! Congratulations !\n\n");
  835. X  return( TRUE );
  836. X}
  837. X
  838. X#endif
  839. X
  840. X
  841. SHAR_EOF
  842. chmod 0440 x_list/src/testit.c || echo "restore of x_list/src/testit.c fails"
  843. if [ $TOUCH = can ]
  844. then
  845.     touch -am 0209182491 x_list/src/testit.c
  846. fi
  847. set `wc -c x_list/src/testit.c`;Wc_c=$1
  848. if test "$Wc_c" != "9151"
  849. then echo original size 9151, current size $Wc_c;fi
  850. # ============= x_list/src/x_list.c ==============
  851. echo "x - extracting x_list/src/x_list.c (Text)"
  852. sed 's/^X//' << 'SHAR_EOF' > x_list/src/x_list.c &&
  853. X/* 
  854. X
  855. X   Doubly linked list function file : 
  856. X
  857. X         x_list.c :    x_list.c 1.2 2/9/91 
  858. X
  859. X*/
  860. X
  861. X/*
  862. X
  863. XThis text in this file is copyright (c) 1991 by Kenneth Jamieson.
  864. X
  865. XThe author may be reached at the US MAIL address listed below, or
  866. Xby sending unix mail to ...
  867. X
  868. X           tron1@tronsbox.xei.com            or
  869. X       ...!uunet!tronsbox.xei.com!tron1  or
  870. X       yelling "Hey Ken!" if you happen to be close enough.
  871. X
  872. X
  873. X       SEE THE FILE "sharew.h" for details before you
  874. X       use this code !!!
  875. X
  876. X*/
  877. X
  878. X
  879. X#include <copyr.h>
  880. X#include <sharew.h>
  881. X#include <x_list.h>
  882. X#include <stdlib.h>
  883. X
  884. Xstruct x_list_entry * init_xlist_entry(){
  885. X  struct x_list_entry * foo;
  886. X  foo = (struct x_list_entry *)malloc( sizeof(struct x_list_entry) );
  887. X  if( foo == NULL ){
  888. X    return( foo );
  889. X  }
  890. X  foo->data = NULL;
  891. X  foo->prev = NULL;
  892. X  foo->next = NULL;
  893. X  
  894. X  return( foo );
  895. X}
  896. X
  897. Xstruct x_list * init_xlist(){
  898. X  struct x_list * foo;
  899. X  foo = (struct x_list *)malloc( sizeof(struct x_list) );
  900. X  if( foo == NULL ){
  901. X    return( foo );
  902. X  }
  903. X  foo->data = NULL;
  904. X  foo->first = NULL;
  905. X  foo->current = NULL;
  906. X  foo->last = NULL;
  907. X  foo->count = 0;
  908. X  foo->node = 0;
  909. X  
  910. X  return( foo );
  911. X}
  912. X
  913. Xint add_xlist( struct x_list * xlist, void * new_data ){
  914. X  if( xlist == NULL ){
  915. X    return( (int)FALSE );
  916. X  }
  917. X  if( xlist->first == NULL ){        /* Is this the first entry ??? */
  918. X    xlist->first = init_xlist_entry();  /* Create a entry to add to list */
  919. X    if( xlist->first == NULL ){         
  920. X      return( (int)FALSE );                  /* If we can't, fail             */
  921. X    }
  922. X    xlist->first->data = new_data;    /* Set the data pointer for the user */
  923. X    xlist->current = xlist->first;    /* The first item is the current one!*/
  924. X    xlist->last = xlist->first;        /* It is also the last !!          */
  925. X    xlist->count = 1;            /* There is one item in the list     */
  926. X    xlist->node = 0;            /* Just to be sure !             */
  927. X    return( (int)TRUE );
  928. X  }
  929. X
  930. X  xlist->last->next = init_xlist_entry(); /* Add a new node at end of list */
  931. X  if( xlist->first == NULL ){
  932. X    return( (int)FALSE );              /* If we can't, fail */
  933. X  }  
  934. X  xlist->last->next->prev = xlist->last;    /* Set parent of new node */
  935. X  xlist->last->next->data = new_data;        /* Set data of new node   */
  936. X  xlist->last = xlist->last->next;        /* Set pointer to last node*/
  937. X  xlist->current = xlist->last;            /* Set the current pointer */
  938. X  xlist->count = xlist->count+1;        /* Set the counter      */
  939. X  xlist->node = xlist->count - 1;        /* Hehehehe        */
  940. X  return( (int)TRUE );
  941. X}
  942. X
  943. Xvoid * get_xlist( struct x_list * xlist ){
  944. X  if( xlist == NULL ){
  945. X    return( NULL );                /* if list pointer is bad */
  946. X  }
  947. X  if( xlist->current == NULL ){
  948. X    return( NULL );                /* if list is empty       */
  949. X  }
  950. X  return( xlist->current->data );               /* Return the data        */
  951. X}
  952. X
  953. Xint head_xlist( struct x_list * xlist ){
  954. X  if( xlist == NULL ){
  955. X    return( (int)FALSE );                /* if list pointer is bad */
  956. X  }                                                    
  957. X  if( xlist->first == NULL ){                                        
  958. X    return( (int)FALSE );                /* if list is empty       */
  959. X  }                                                    
  960. X  xlist->current = xlist->first;        /* reset the current pointer*/
  961. X  xlist->node = 0;                /* Reset node number */
  962. X  return( (int)TRUE );
  963. X}
  964. X
  965. Xint put_xlist( struct x_list * xlist, void * new_data ){
  966. X  if( xlist == NULL ){
  967. X    return( (int)FALSE );                /* if list pointer is bad */
  968. X  }                                                    
  969. X  if( xlist->current == NULL ){                                        
  970. X    return( (int)FALSE );                /* if list is empty       */
  971. X  }                                                    
  972. X  xlist->current->data = new_data;        /* replace the data        */
  973. X  return( (int)TRUE );
  974. X}
  975. X
  976. Xint del_xlist( struct x_list * xlist ){
  977. X  struct x_list_entry * foo;
  978. X  if( xlist == NULL ){
  979. X    return( (int)FALSE );                        /* if list pointer is bad */
  980. X  }                                                    
  981. X  if( xlist->current == NULL ){                                        
  982. X    return( (int)FALSE );                /* if list is empty       */
  983. X  }                                                    
  984. X  foo = xlist->current;                
  985. X  if( foo->prev != NULL ){            /* Is this the head ? */
  986. X    foo->prev->next = foo->next; /* Set the child of our parent to pur child */
  987. X  }else{            
  988. X    xlist->first = foo->next;    /* We are the head, reset first when we go  */
  989. X  }
  990. X  if( foo->next != NULL ){        /* Are we the tail ?  */
  991. X    foo->next->prev = foo->prev;    /* Set childs parent to our parent  */
  992. X    xlist->current = foo->next;        /* Set the current to our child        */
  993. X  }else{
  994. X    xlist->current = foo->prev;        /* Set current to parent if no child*/
  995. X    xlist->last = foo->next;        /* Reset the last pointer           */
  996. X  }
  997. X  xlist->count = xlist->count -1;    /* Decrement the counter            */
  998. X  free((char *)foo);                /* Free the data            */
  999. X  return( (int)TRUE );
  1000. X}
  1001. X
  1002. Xint next_xlist( struct x_list * xlist ){
  1003. X  if( xlist == NULL ){
  1004. X    return( (int)FALSE );             /* if list pointer is bad */
  1005. X  }                                                 
  1006. X  if( xlist->current == NULL ){                                     
  1007. X    return( (int)FALSE );             /* if list is empty       */
  1008. X  }
  1009. X  if( xlist->current->next == NULL ){
  1010. X    return( (int)FALSE );         /* At end of list, can't advance */
  1011. X  }
  1012. X  xlist->current = xlist->current->next; /* Advance current pointer       */
  1013. X  xlist->node = xlist->node + 1; 
  1014. X  return( (int)TRUE );
  1015. X}
  1016. X
  1017. Xint prev_xlist( struct x_list * xlist ){
  1018. X  if( xlist == NULL ){
  1019. X    return( (int)FALSE );             /* if list pointer is bad */
  1020. X  }                                                 
  1021. X  if( xlist->current == NULL ){                                     
  1022. X    return( (int)FALSE );             /* if list is empty       */
  1023. X  }
  1024. X  if( xlist->current->prev == NULL ){
  1025. X    return( (int)FALSE );             /* If we are at the start */
  1026. X  }
  1027. X  xlist->current = xlist->current->prev; /* Move the pointer back  */
  1028. X  xlist->node = xlist->node - 1;         /* Decrement the node */
  1029. X  return( (int)TRUE );
  1030. X}
  1031. X  
  1032. Xint get_count_xlist( struct x_list * xlist ){
  1033. X  if( xlist == NULL ){                     /* If the list pointer is bad */
  1034. X    return( 0 );
  1035. X  }
  1036. X  return( xlist->count );        /* Return the current count    */
  1037. X}
  1038. X
  1039. Xint free_xlist( struct x_list * xlist ){
  1040. X  if( xlist == NULL ){                     /* If the list pointer is bad */
  1041. X    return( (int)FALSE );
  1042. X  }
  1043. X  while( get_count_xlist( xlist ) != 0 ){
  1044. X    del_xlist( xlist );
  1045. X  }
  1046. X  free((char *) xlist );
  1047. X  return( (int)TRUE );
  1048. X}
  1049. X
  1050. Xint set_user_xlist( struct x_list * xlist, void * data ){
  1051. X  if( xlist == NULL ){                     /* If the list pointer is bad */
  1052. X    return( (int)FALSE );
  1053. X  }
  1054. X  xlist->data = data;
  1055. X  return( (int)TRUE );
  1056. X}
  1057. X
  1058. Xvoid * get_user_xlist( struct x_list * xlist ){
  1059. X  if( xlist == NULL ){                     /* If the list pointer is bad */
  1060. X    return( (int)FALSE );
  1061. X  }
  1062. X  return( xlist->data );
  1063. X}
  1064. X
  1065. Xint tail_xlist( struct x_list * xlist ){
  1066. X  if( xlist == NULL ){
  1067. X    return( (int)FALSE );            /* if list pointer is bad */
  1068. X  }                                                    
  1069. X  if( xlist->last == NULL ){                           
  1070. X    return( (int)FALSE );            /* if list is empty       */
  1071. X  }                                                    
  1072. X  xlist->current = xlist->last;        /* reset the current pointer*/
  1073. X  xlist->node = xlist->count - 1;        /* Reset node number */
  1074. X  return( (int)TRUE );
  1075. X}
  1076. X
  1077. Xint get_nodenum_xlist( struct x_list * xlist ){
  1078. X  if( xlist == NULL ){                     /* If the list pointer is bad */
  1079. X    return( (int)FALSE );
  1080. X  }  
  1081. X  return( xlist->node );
  1082. X}
  1083. X
  1084. Xint goto_xlist( struct x_list * xlist, int target ){
  1085. X  int count;
  1086. X  if( xlist == NULL ){                     /* If the list pointer is bad */
  1087. X    return( (int)FALSE );
  1088. X  }
  1089. X  if( target < 0 ){
  1090. X    return( (int)FALSE );
  1091. X  }
  1092. X  count = get_count_xlist( xlist );
  1093. X  if( target > count ){
  1094. X    return( (int)FALSE );
  1095. X  }
  1096. X  count = get_nodenum_xlist( xlist );    /* Re-use the count integer */
  1097. X  if( target > count ){
  1098. X    while( target > get_nodenum_xlist( xlist ) ){
  1099. X      if( next_xlist( xlist ) == FALSE ){
  1100. X    return( (int)FALSE );        /* Error ? */
  1101. X      }
  1102. X    }
  1103. X    return( (int)TRUE );
  1104. X  }
  1105. X  if( target < count ){
  1106. X    while( target < get_nodenum_xlist( xlist ) ){
  1107. X      if( prev_xlist( xlist ) == FALSE ){
  1108. X    return( (int)FALSE );        /* Error ? */
  1109. X      }
  1110. X    }
  1111. X    return( (int)TRUE );
  1112. X  }
  1113. X  if( target == count ){
  1114. X    return( (int)TRUE );        /* Error ? */
  1115. X  }
  1116. X  return( (int)FALSE );            /* No idea what happened!          */
  1117. X                                        /* I mean, if it is not > < or = ! */
  1118. X}
  1119. X
  1120. X#ifdef IS_CPP
  1121. X
  1122. XX_List::X_List(){
  1123. X  list = init_xlist();
  1124. X}
  1125. X
  1126. XX_List::X_List( void * name ){
  1127. X  list = init_xlist();
  1128. X  set_user( name );
  1129. X}
  1130. X
  1131. Xint X_List::add( void * data ){
  1132. X  return( add_xlist( list, data ) );
  1133. X}
  1134. X
  1135. Xvoid * X_List::get(){
  1136. X  return( get_xlist( list ) );
  1137. X}
  1138. X
  1139. Xint X_List::head(){
  1140. X  return( head_xlist( list ) );
  1141. X}
  1142. X
  1143. Xint X_List::tail(){
  1144. X  return( tail_xlist( list ) );
  1145. X}
  1146. X
  1147. Xint X_List::put( void * data ){
  1148. X  return( put_xlist( list, data ) );
  1149. X}
  1150. X
  1151. Xint X_List::del(){
  1152. X  return( del_xlist( list ) );
  1153. X}
  1154. X
  1155. Xint X_List::next(){
  1156. X  return( next_xlist( list ) );
  1157. X}
  1158. X
  1159. Xint X_List::prev(){
  1160. X  return( prev_xlist( list ) );
  1161. X}
  1162. X
  1163. Xint X_List::count(){
  1164. X  return( get_count_xlist( list ) );
  1165. X}
  1166. X
  1167. Xint X_List::set_user( void * name ){
  1168. X  return( set_user_xlist( list, name ) );
  1169. X}
  1170. X
  1171. Xvoid * X_List::get_user(){
  1172. X  return( get_user_xlist( list ) );
  1173. X}
  1174. X
  1175. Xint X_List::nodenum(){
  1176. X  return( (int)get_nodenum_xlist( list ) );
  1177. X}
  1178. X
  1179. Xint X_List::goto_node( int target ){
  1180. X  return( goto_xlist( list, target ) );
  1181. X}
  1182. X
  1183. Xvoid * X_List::operator[]( int target ){
  1184. X  if( this->goto_node( target ) == FALSE ){
  1185. X    return( NULL );
  1186. X  }
  1187. X  return( this->get() );
  1188. X}
  1189. X
  1190. XX_List::~X_List(){
  1191. X  free_xlist( list );
  1192. X}
  1193. X
  1194. X
  1195. X
  1196. X#endif
  1197. X
  1198. X
  1199. SHAR_EOF
  1200. chmod 0440 x_list/src/x_list.c || echo "restore of x_list/src/x_list.c fails"
  1201. if [ $TOUCH = can ]
  1202. then
  1203.     touch -am 0209182491 x_list/src/x_list.c
  1204. fi
  1205. set `wc -c x_list/src/x_list.c`;Wc_c=$1
  1206. if test "$Wc_c" != "9468"
  1207. then echo original size 9468, current size $Wc_c;fi
  1208. # ============= x_list/src/x_list.h ==============
  1209. echo "x - extracting x_list/src/x_list.h (Text)"
  1210. sed 's/^X//' << 'SHAR_EOF' > x_list/src/x_list.h &&
  1211. X/* 
  1212. X
  1213. X   Doubly linked list header file : 
  1214. X
  1215. X         x_list.h :    x_list.h 1.2 2/9/91 
  1216. X
  1217. X*/
  1218. X
  1219. X/*
  1220. X
  1221. XThis text in this file is copyright (c) 1991 by Kenneth Jamieson.
  1222. X
  1223. XThe author may be reached at the US MAIL address listed below, or
  1224. Xby sending unix mail to ...
  1225. X
  1226. X           tron1@tronsbox.xei.com            or
  1227. X       ...!uunet!tronsbox.xei.com!tron1  or
  1228. X       yelling "Hey Ken!" if you happen to be close enough.
  1229. X
  1230. X
  1231. X       SEE THE FILE "sharew.h" for details before you
  1232. X       use this code !!!
  1233. X
  1234. X*/
  1235. X
  1236. X
  1237. X
  1238. X#ifndef _x_list_h    /* To solve any double defined errors */
  1239. X#define _x_list_h 
  1240. X
  1241. X#ifndef TRUE        /* Just a standard define of mine */
  1242. X#define TRUE 1
  1243. X#endif
  1244. X#ifndef FALSE        /* Just a standard define of mine */
  1245. X#define FALSE 0
  1246. X#endif
  1247. X
  1248. X/* Below, we will define the structures we need for this code.... */
  1249. X
  1250. Xstruct x_list_entry {             /* Just a generic entry in out list  */
  1251. X  void * data;             /* The data pointer to store         */
  1252. X  struct x_list_entry * prev;    /* The pointer to the previous entry */
  1253. X  struct x_list_entry * next;    /* The pointer to the next entry     */
  1254. X};
  1255. X
  1256. Xstruct x_list {             /* The header that will start every list */
  1257. X  void * data;             /* A user pointer so you can name it     */
  1258. X  struct x_list_entry * first;     /* Pointer to the first entry in list    */
  1259. X  struct x_list_entry * current; /* Pointer to the current entry in list  */
  1260. X  struct x_list_entry * last;    /* Pointer to the last entry in the list */
  1261. X  int node;             /* The number of the current node        */
  1262. X  int count;             /* A count of the number of nodes in list*/
  1263. X};
  1264. X
  1265. X
  1266. Xstruct x_list_entry * init_xlist_entry();            
  1267. X/* Create and init a new entry struct */
  1268. X
  1269. Xstruct x_list * init_xlist();                    
  1270. X/* create and init a new list head    */
  1271. X
  1272. Xint add_xlist( struct x_list * xlist , void * new_data );    
  1273. X/* Add a new data item to the list    */
  1274. X
  1275. Xvoid * get_xlist(struct x_list * xlist );            
  1276. X/* Get the data pointer from current entry in the list */
  1277. X
  1278. Xint head_xlist( struct x_list * xlist );            
  1279. X/* Go to the top of the list          */
  1280. X
  1281. Xint put_xlist( struct x_list * xlist, void * new_data );    
  1282. X/* Replace data for current node      */
  1283. X
  1284. Xint del_xlist( struct x_list * xlist );                
  1285. X/* Kill the current item and re-weave the list   */
  1286. X
  1287. Xint next_xlist( struct x_list * xlist );            
  1288. X/* Goto next node              */
  1289. X
  1290. Xint prev_xlist( struct x_list * xlist );            
  1291. X/* Go to prev node              */
  1292. X
  1293. Xint get_count_xlist( struct x_list * xlist );            
  1294. X/* get the counter               */
  1295. X
  1296. Xint free_xlist( struct x_list * xlist );
  1297. X/* Delete the entire list             */
  1298. X
  1299. Xint set_user_xlist( struct x_list * xlist, void * data );
  1300. X/* Set the user pointer for a xlist   */
  1301. X
  1302. Xvoid * get_user_xlist( struct x_list * xlist );
  1303. X/* Get the user pointer for a xlist   */
  1304. X
  1305. Xint tail_xlist( struct x_list * );
  1306. X/* Sets the current node to the last node in list */
  1307. X
  1308. Xint goto_xlist( struct x_list * xlist, int target );
  1309. X/* Sets the current node to the target'th node in list if possible */
  1310. X
  1311. Xint get_nodenum_xlist( struct x_list * xlist );
  1312. SHAR_EOF
  1313. echo "End of X_List part 1"
  1314. echo "File x_list/src/x_list.h is continued in part 2"
  1315. echo "2" > s3_seq_.tmp
  1316. exit 0
  1317. -- 
  1318. ========[ Xanadu Enterprises Inc. Amiga & Unix Software Development]=======
  1319. = "I know how you feel, you don't know if you want to hit me or kiss me - =
  1320. =  --- I get a lot of that."  Madonna as Breathless Mahoney (Dick Tracy)  =
  1321. =========== Ken Jamieson: uunet!tronsbox.xei.com!tron1  ===================
  1322. =     NONE of the opinions represented here are endorsed by anybody.      =
  1323. === The Romantic Encounters BBS 201-759-8450(PEP) / 201-759-8568(2400) ==== 
  1324.