home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / pst / part05 < prev    next >
Encoding:
Text File  |  1993-11-26  |  53.8 KB  |  2,029 lines

  1. Newsgroups: comp.sources.misc
  2. From: Panos Tsirigotis (panos@cs.colorado.edu)
  3. Subject: v40i176:  pst - extract text from a postscript file, Part05/06
  4. Message-ID: <1993Nov26.170823.6636@sparky.sterling.com>
  5. X-Md4-Signature: 99de9b72e3cd6cac54e2366315ec0a36
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 26 Nov 1993 17:08:23 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: Panos Tsirigotis (panos@cs.colorado.edu)
  12. Posting-number: Volume 40, Issue 176
  13. Archive-name: pst/part05
  14. Environment: BSD, SUNOS, ULTRIX, SYSVR4, SYSVR3, POSIX
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  INSTALL Makefile libs/src/sio/CHANGELOG
  21. #   libs/src/sio/COPYRIGHT libs/src/sio/suite/Makefile
  22. #   libs/src/sio/suite/README libs/src/sio/suite/buftest.c
  23. #   libs/src/sio/suite/example.c libs/src/sio/suite/fdtest.c
  24. #   libs/src/sio/suite/sprint_test libs/src/sio/suite/testlib
  25. #   libs/src/sio/suite/tietest.c libs/src/str/CHANGELOG
  26. #   libs/src/str/COPYRIGHT libs/src/str/ss_bf.c libs/src/str/ss_bmh.c
  27. #   libs/src/str/ss_kmp.h libs/src/str/ss_rk.c libs/src/str/ss_rk.h
  28. #   libs/src/str/ss_sbm.c libs/src/str/ss_sbm.h
  29. #   libs/src/str/strparse.h libs/src/str/strutil.3 pst/CHANGELOG
  30. #   pst/defs.h pst/dit.c pst/options.c pst/pst.man pst/wp.c
  31. # Wrapped by kent@sparky on Fri Nov 26 11:02:47 1993
  32. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  33. echo If this archive is complete, you will see the following message:
  34. echo '          "shar: End of archive 5 (of 6)."'
  35. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  36.   echo shar: Will not clobber existing file \"'INSTALL'\"
  37. else
  38.   echo shar: Extracting \"'INSTALL'\" \(2452 characters\)
  39.   sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  40. X---------------------------------------------------------------------------
  41. XNOTE: You may want to set your tabstop to 3; this will make everything
  42. X      look properly indented.
  43. X---------------------------------------------------------------------------
  44. X
  45. X
  46. X1. Distribution
  47. X
  48. Xpst comes as a group of shar archive kits. When you unshar all of
  49. Xthe kits you should have the following directory structure:
  50. X
  51. X    README                  :        what pst is about
  52. X    INSTALL                  :        this file
  53. X    Makefile                    :        top level Makefile
  54. X    ./pst                    :        program source
  55. X   ./libs/src/{sio,str} :     source of libraries
  56. X   ./libs/include       :     library include files will be placed here
  57. X   ./libs/man           :     library man pages will be placed here
  58. X   ./libs/lib           :     library .a files will be placed here
  59. X
  60. X----------------------------------------------------------------------
  61. X
  62. X2. Compiling pst
  63. X
  64. XThe top level makefile can be used to compile the libraries, and
  65. Xthe program. All you need to do is type "make", after setting
  66. Xcertain variables appropriately in that makefile. Although the
  67. Xpst program should compile on all systems, the libraries it
  68. Xdepends on may need to be customized (via compile-time flags)
  69. Xfor your system. The makefile contains information about what
  70. Xflags need to be set.
  71. X
  72. XTo install the program, you should first set the makefile variables
  73. XINSTALLDIR and MANPATHDIR, and then type "make install".
  74. XINSTALLDIR is the directory where the program will be installed.
  75. XThe manpage for the program will be installed in $(MANPATHDIR)/man1
  76. XIf you want to uninstall the program, use "make uninstall".
  77. XTo clean up after installation is complete, use "make clean".
  78. X
  79. XOn systems that don't need the 'ranlib' command to create a library
  80. Xarchive, set the RANLIB variable of the Makefile to 'true' (an easy
  81. Xway to tell if 'ranlib' is needed is to use the command 'man ranlib';
  82. Xif there is a man page for 'ranlib', then it is probably needed).
  83. X
  84. XThe INSTALL variable in the Makefile determines the 'install' command
  85. Xto use. A BSD-compatible install command is needed. On systems like
  86. XSunOS 4.x (aka, Solaris 1.x), or Ultrix 4.x, this is the default
  87. Xinstall command. On other systems there may be a BSD-compatible install
  88. Xcommand in a special directory (for example, on Solaris 2.x, the
  89. XBSD-compatible install command is in the /usr/ucb directory).  If your
  90. Xsystem system does not have the appropriate install command, you can
  91. Xalways set the INSTALL variable to 'cp'.
  92. X
  93. END_OF_FILE
  94.   if test 2452 -ne `wc -c <'INSTALL'`; then
  95.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  96.   fi
  97.   # end of 'INSTALL'
  98. fi
  99. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  100.   echo shar: Will not clobber existing file \"'Makefile'\"
  101. else
  102.   echo shar: Extracting \"'Makefile'\" \(2163 characters\)
  103.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  104. X
  105. X#
  106. X# You may want to customize the following variables
  107. X#
  108. X# INSTALLDIR    :    where the program will be installed
  109. X# MANPATHDIR    :    the program man page will be installed in the directory
  110. X#                        $(MANPATHDIR)/man1
  111. X# INSTALL        :    the pathname of the 'install' command to use for installation
  112. X# RANLIB            :    set this to 'true' if the ranlib command is not required
  113. X#                        in creating a library archive
  114. X#
  115. XINSTALLDIR        =             # /usr/local/bin
  116. XMANPATHDIR        =             # /usr/local/man
  117. X
  118. XDEBUG                = -O        # should be -g or -O
  119. X
  120. XRANLIB            = ranlib
  121. XINSTALL            = install -c
  122. X
  123. X#
  124. X# LIBDEFS is used to specify compile-time flags for the SIO and STR libraries.
  125. X#
  126. X# If the native word size of your machine is 32 bits, you don't need to set 
  127. X# any flags in LIBDEFS for the STR library. If that is not the case, please 
  128. X# read the Makefile of the STR library for what flags you need to set.
  129. X#
  130. X# For the SIO library, I have included appropriate flags for some popular
  131. X# operating systems. If your system is not among these, please read the
  132. X# README file of the SIO library for additional information on how to
  133. X# configure that library.
  134. X#        1) SunOS 4.x
  135. X#                -DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY
  136. X#        2) SunOS 5.x (aka, Solaris 2.x)
  137. X#                -DHAS_MMAP -DHAS_ATEXIT -DHAS_MEMOPS -DHAS_ISATTY
  138. X#        3) Ultrix 4.x
  139. X#                -DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY
  140. X#        4) Any posix-compatible operating system
  141. X#                -DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY
  142. X#
  143. X
  144. XLIBDEFS            =
  145. X
  146. X
  147. X#
  148. X# Do not change the following variables
  149. X#
  150. XINCLUDEDIR        = -I../libs/include
  151. XLIBDIR            = ../libs/lib
  152. X
  153. Xall: makelibs
  154. X    cd pst ; make LIBDIR=$(LIBDIR) "INCLUDEDIR=$(INCLUDEDIR)" "DEBUG=$(DEBUG)"
  155. X
  156. X
  157. Xmakelibs:
  158. X    cd libs/src ;\
  159. X    for i in * ; do ( cd $$i ; rm -f lib$$i.a ; make "DEFS=$(LIBDEFS)" "DEBUG=$(DEBUG)" MANDIR=../../man INCLUDEDIR=../../include LIBDIR=../../lib "INSTALL=$(INSTALL)" RANLIB=$(RANLIB) install ) ; done
  160. X
  161. X
  162. Xinstall:
  163. X    cd pst ;\
  164. X    make INSTALLDIR=$(INSTALLDIR) "INSTALL=$(INSTALL)" install ;\
  165. X    make MANPATHDIR=$(MANPATHDIR) "INSTALL=$(INSTALL)" install.man
  166. X
  167. Xuninstall:
  168. X    cd pst ;\
  169. X    make INSTALLDIR=$(INSTALLDIR) MANPATHDIR=$(MANPATHDIR) uninstall
  170. X
  171. Xclean:
  172. X    cd libs/src ; for i in * ; do ( cd $$i ; make clean ) ; done
  173. X    cd pst ; make clean
  174. X
  175. END_OF_FILE
  176.   if test 2163 -ne `wc -c <'Makefile'`; then
  177.     echo shar: \"'Makefile'\" unpacked with wrong size!
  178.   fi
  179.   # end of 'Makefile'
  180. fi
  181. if test -f 'libs/src/sio/CHANGELOG' -a "${1}" != "-c" ; then 
  182.   echo shar: Will not clobber existing file \"'libs/src/sio/CHANGELOG'\"
  183. else
  184.   echo shar: Extracting \"'libs/src/sio/CHANGELOG'\" \(1106 characters\)
  185.   sed "s/^X//" >'libs/src/sio/CHANGELOG' <<'END_OF_FILE'
  186. X
  187. X1.0.x-1.4.x:
  188. X    -    These version have not been released.
  189. X
  190. X1.5.0:
  191. X    -    Added the function Smorefds
  192. X    -    Improved the handling of pointers in Sprint
  193. X
  194. X1.5.3:
  195. X    -    Fixed a bug in Srdline
  196. X
  197. X1.5.6:
  198. X    -    Added multiple ways of determining the number of available fds
  199. X
  200. X1.6.0:
  201. X    -    Updated the way SIO is configured. Instead of multiple configuration
  202. X        files, one per OS/machine, there is now a single configuration header
  203. X        file where the user can define via preprocessor flags the features
  204. X        supported by the particular OS/machine.
  205. X
  206. X1.6.1:
  207. X    -    Simplified the Sprint-related configuration flags
  208. X    -    Fixed a bug in the events code
  209. X    -    Replaced all uses of memcpy with sio_memcopy
  210. X
  211. X1.6.2:
  212. X    -    Fixed a bug in the INS_CHAR macro: the buffer size was not respected
  213. X        when printing to strings. This had no effect on the SIO library,
  214. X        but it did affect the strx_* functions of the STR library
  215. X
  216. X1.6.3:
  217. X    -    The values for INCLUDEDIR and MANDIR in the Makefile were reversed
  218. X        (this might have been confusing to people trying to install the
  219. X        library).
  220. X    -    Updated the sio manpage with respect to the handling of interrupted
  221. X        system calls.
  222. X
  223. END_OF_FILE
  224.   if test 1106 -ne `wc -c <'libs/src/sio/CHANGELOG'`; then
  225.     echo shar: \"'libs/src/sio/CHANGELOG'\" unpacked with wrong size!
  226.   fi
  227.   # end of 'libs/src/sio/CHANGELOG'
  228. fi
  229. if test -f 'libs/src/sio/COPYRIGHT' -a "${1}" != "-c" ; then 
  230.   echo shar: Will not clobber existing file \"'libs/src/sio/COPYRIGHT'\"
  231. else
  232.   echo shar: Extracting \"'libs/src/sio/COPYRIGHT'\" \(1332 characters\)
  233.   sed "s/^X//" >'libs/src/sio/COPYRIGHT' <<'END_OF_FILE'
  234. XThis software is
  235. X
  236. X(c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  237. X
  238. XThe author (Panagiotis Tsirigotis) grants permission to use, copy,
  239. Xand distribute this software and its documentation for any purpose 
  240. Xand without fee, provided that a) the above copyright notice extant in
  241. Xfiles in this distribution is not removed from files included in any
  242. Xredistribution, and b) this file is also included in any redistribution.
  243. X
  244. XModifications to this software may be distributed, either by distributing
  245. Xthe modified software or by distributing patches to the original software,
  246. Xunder the following additional terms:
  247. X
  248. X1. The version number will be modified as follows:
  249. X      a. The first 3 components of the version number
  250. X         (i.e. <number>.<number>.<number>) will remain unchanged.
  251. X      b. A new component will be appended to the version number to indicate
  252. X         the modification level. The form of this component is up to the 
  253. X         author of the modifications.
  254. X
  255. X2. The author of the modifications will include his/her name by appending it 
  256. X   along with the new version number to this file and will be responsible for 
  257. X   any wrong behavior of the modified software.
  258. X
  259. XThe author makes no representations about the suitability of this 
  260. Xsoftware for any purpose.  It is provided "as is" without any express 
  261. Xor implied warranty.
  262. X
  263. END_OF_FILE
  264.   if test 1332 -ne `wc -c <'libs/src/sio/COPYRIGHT'`; then
  265.     echo shar: \"'libs/src/sio/COPYRIGHT'\" unpacked with wrong size!
  266.   fi
  267.   # end of 'libs/src/sio/COPYRIGHT'
  268. fi
  269. if test -f 'libs/src/sio/suite/Makefile' -a "${1}" != "-c" ; then 
  270.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/Makefile'\"
  271. else
  272.   echo shar: Extracting \"'libs/src/sio/suite/Makefile'\" \(2571 characters\)
  273.   sed "s/^X//" >'libs/src/sio/suite/Makefile' <<'END_OF_FILE'
  274. X# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  275. X# All rights reserved.  The file named COPYRIGHT specifies the terms 
  276. X# and conditions for redistribution.
  277. X
  278. X#
  279. X# $Id: Makefile,v 8.2 1993/09/08 06:00:25 panos Exp $
  280. X#
  281. X
  282. XCC                    = cc -I..
  283. X
  284. X#
  285. X# NOTE: When using the test scripts, DEFS is provided as an
  286. X#          argument to make, the setting of it here has no effect.
  287. X#
  288. XDEFS                =
  289. XCFLAGS            = -g $(DEFS) $(MORE_DEFS)
  290. XLIBOBJS            = ../libsio.a
  291. X
  292. XDISTRIBUTION_FILES=copytest.c example.c print.c tietest.c buftest.c fdtest.c tester sprint_test testlib README
  293. X
  294. XALL=Sread Swrite Sputchar Sgetchar Srdline \
  295. X     Sgetc Sputc Sfetch Sflush Sundo switch \
  296. X     Sprint buftest tietest switch2 example fdtest evtest
  297. X
  298. Xevtest: evtest.c $(LIBOBJS)
  299. X    $(CC) $(CFLAGS) -o $@ evtest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  300. X
  301. Xfdtest: fdtest.c $(LIBOBJS)
  302. X    $(CC) $(CFLAGS) -o $@ fdtest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  303. X
  304. Xbuftest: buftest.c $(LIBOBJS)
  305. X    $(CC) $(CFLAGS) -o $@ buftest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  306. X
  307. XSprint: print.c $(LIBOBJS)
  308. X    $(CC) $(CFLAGS) -o $@ print.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  309. X
  310. XSputchar: copytest.c $(LIBOBJS)
  311. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  312. X
  313. XSgetchar: copytest.c $(LIBOBJS)
  314. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  315. X
  316. XSrdline: copytest.c $(LIBOBJS)
  317. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) || rm -f $@
  318. X
  319. XSread: copytest.c $(LIBOBJS)
  320. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  321. X
  322. XSwrite: copytest.c $(LIBOBJS)
  323. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  324. X
  325. XSgetc: copytest.c $(LIBOBJS)
  326. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  327. X
  328. XSputc: copytest.c $(LIBOBJS)
  329. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  330. X
  331. XSfetch: copytest.c $(LIBOBJS)
  332. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  333. X
  334. XSflush: copytest.c $(LIBOBJS)
  335. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  336. X
  337. XSundo: copytest.c $(LIBOBJS)
  338. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  339. X
  340. Xswitch: copytest.c $(LIBOBJS)
  341. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  342. X
  343. Xswitch2: copytest.c $(LIBOBJS)
  344. X    $(CC) $(CFLAGS) -o $@ copytest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  345. X
  346. Xtietest: tietest.c $(LIBOBJS)
  347. X    $(CC) $(CFLAGS) -o $@ tietest.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  348. X
  349. Xexample: example.c $(LIBOBJS)
  350. X    $(CC) $(CFLAGS) -o $@ example.c $(LIBOBJS) $(LDFLAGS) || rm -f $@
  351. X
  352. Xclean:
  353. X    rm -f $(ALL) core
  354. X
  355. Xcheckout: $(DISTRIBUTION_FILES)
  356. X
  357. X$(DISTRIBUTION_FILES):
  358. X    co $@
  359. X
  360. Xdist:
  361. X    -co -q $(DISTRIBUTION_FILES)
  362. END_OF_FILE
  363.   if test 2571 -ne `wc -c <'libs/src/sio/suite/Makefile'`; then
  364.     echo shar: \"'libs/src/sio/suite/Makefile'\" unpacked with wrong size!
  365.   fi
  366.   # end of 'libs/src/sio/suite/Makefile'
  367. fi
  368. if test -f 'libs/src/sio/suite/README' -a "${1}" != "-c" ; then 
  369.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/README'\"
  370. else
  371.   echo shar: Extracting \"'libs/src/sio/suite/README'\" \(1753 characters\)
  372.   sed "s/^X//" >'libs/src/sio/suite/README' <<'END_OF_FILE'
  373. X
  374. XThe 'testlib' script will exercise most of the functions in the SIO
  375. Xlibrary.  It invokes the 'tester' script which does the real work.
  376. X'tester' is a Bourne shell script. However, it expects that the shell
  377. Xsupports functions and /bin/sh does not support functions on all
  378. Xoperating systems. Therefore, 'testlib' decides what shell to use to
  379. Xexecute 'tester'. On Suns, it uses /bin/sh. On DECstations, it uses
  380. X/usr/bin/ksh. The decision is made by checking the ARCH environment
  381. Xvariable.
  382. X
  383. XExercising some of the SIO functions in an automatic fashion is a
  384. Xdifficult task, so you will have to do it manually by visually
  385. Xinspecting the results of programs that exercise them.  The following
  386. Xis a list of functions and programs testing them (with a description of
  387. Xthe expected behavior):
  388. X
  389. X1. Sbuftype
  390. X
  391. X    PROGRAM: buftest.c
  392. X    DESCRIPTION:
  393. X        This program prints two groups of lines. The first group is printed
  394. X        using line-buffering while the second group is printed using
  395. X        full-buffering.
  396. X        The first group of lines should appear one line at a time every
  397. X        3 seconds. The second group of lines should appear all lines together
  398. X        after about 10 seconds.
  399. X
  400. X2. Stie, Suntie
  401. X    
  402. X    PROGRAM: tietest.c
  403. X    DESCRIPTION:
  404. X        This program ties stdin to stdout and then prompts for input.
  405. X        The prompts do *not* include a NEWLINE. Since the stdout is
  406. X        *line buffered* when connected to a terminal, the Stie call
  407. X        is what causes the prompt to appear.
  408. X        The first 2 prompts happen with tied stdin, stdout. For the
  409. X        3rd prompt, stdin is untied from stdout. This will cause
  410. X        the prompt to appear *after* you type something and hit RETURN.
  411. X
  412. X
  413. X
  414. XPS. If you can make testing of these functions automatic, please send
  415. X     me your code so that I can include in a future SIO distribution.
  416. X
  417. END_OF_FILE
  418.   if test 1753 -ne `wc -c <'libs/src/sio/suite/README'`; then
  419.     echo shar: \"'libs/src/sio/suite/README'\" unpacked with wrong size!
  420.   fi
  421.   # end of 'libs/src/sio/suite/README'
  422. fi
  423. if test -f 'libs/src/sio/suite/buftest.c' -a "${1}" != "-c" ; then 
  424.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/buftest.c'\"
  425. else
  426.   echo shar: Extracting \"'libs/src/sio/suite/buftest.c'\" \(748 characters\)
  427.   sed "s/^X//" >'libs/src/sio/suite/buftest.c' <<'END_OF_FILE'
  428. X/*
  429. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  430. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  431. X * and conditions for redistribution.
  432. X */
  433. X
  434. Xstatic char RCSid[] = "$Id: buftest.c,v 8.1 1993/03/13 01:23:09 panos Exp $" ;
  435. X
  436. X#include "sio.h"
  437. X
  438. Xmain()
  439. X{
  440. X    int i ;
  441. X    int sleep_interval = 3 ;
  442. X
  443. X    if ( Sbuftype( 1, SIO_LINEBUF ) == SIO_ERR )
  444. X    {
  445. X        Sprint( 2, "Sbuftype failed\n" ) ;
  446. X        exit( 1 ) ;
  447. X    }
  448. X
  449. X    for ( i = 0 ; i < 10 ; i++ )
  450. X    {
  451. X        Sprint( 1, "Line %d\n", i ) ;
  452. X        if ( i == 5 )
  453. X        {
  454. X            Sprint( 1, "Now switching to full buffering\n" ) ;
  455. X            sleep_interval = 2 ;
  456. X            if ( Sbuftype( 1, SIO_FULLBUF ) == SIO_ERR )
  457. X            {
  458. X                Sprint( 2, "2nd Sbuftype failed\n" ) ;
  459. X                exit( 1 ) ;
  460. X            }
  461. X        }
  462. X        sleep( sleep_interval ) ;
  463. X    }
  464. X    exit( 0 ) ;
  465. X}
  466. X
  467. END_OF_FILE
  468.   if test 748 -ne `wc -c <'libs/src/sio/suite/buftest.c'`; then
  469.     echo shar: \"'libs/src/sio/suite/buftest.c'\" unpacked with wrong size!
  470.   fi
  471.   # end of 'libs/src/sio/suite/buftest.c'
  472. fi
  473. if test -f 'libs/src/sio/suite/example.c' -a "${1}" != "-c" ; then 
  474.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/example.c'\"
  475. else
  476.   echo shar: Extracting \"'libs/src/sio/suite/example.c'\" \(569 characters\)
  477.   sed "s/^X//" >'libs/src/sio/suite/example.c' <<'END_OF_FILE'
  478. X/*
  479. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  480. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  481. X * and conditions for redistribution.
  482. X */
  483. X
  484. Xstatic char RCSid[] = "$Id: example.c,v 8.1 1993/03/13 01:21:48 panos Exp $" ;
  485. X
  486. X#include "sio.h"
  487. X
  488. Xmain( argc, argv )
  489. X   int argc ;
  490. X   char *argv[] ;
  491. X{
  492. X   char *file = (argc > 1) ? argv[ 1 ] : "tee.file" ;
  493. X   int fd = creat( file, 0644 ) ;
  494. X   long length ;
  495. X   char *s ;
  496. X
  497. X   while ( s = Sfetch( 0, &length ) )
  498. X   {
  499. X      Swrite( 1, s, length ) ;
  500. X      Swrite( fd, s, length ) ;
  501. X   }
  502. X   exit( 0 ) ;
  503. X}
  504. X
  505. END_OF_FILE
  506.   if test 569 -ne `wc -c <'libs/src/sio/suite/example.c'`; then
  507.     echo shar: \"'libs/src/sio/suite/example.c'\" unpacked with wrong size!
  508.   fi
  509.   # end of 'libs/src/sio/suite/example.c'
  510. fi
  511. if test -f 'libs/src/sio/suite/fdtest.c' -a "${1}" != "-c" ; then 
  512.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/fdtest.c'\"
  513. else
  514.   echo shar: Extracting \"'libs/src/sio/suite/fdtest.c'\" \(1150 characters\)
  515.   sed "s/^X//" >'libs/src/sio/suite/fdtest.c' <<'END_OF_FILE'
  516. X/*
  517. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  518. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  519. X * and conditions for redistribution.
  520. X */
  521. X
  522. X
  523. X#include <sys/time.h>
  524. X#include <sys/resource.h>
  525. X
  526. X#include "sio.h"
  527. X
  528. X#ifndef NULL
  529. X#define NULL 0
  530. X#endif
  531. X
  532. Xint main( argc, argv )
  533. X    int argc ;
  534. X    char *argv[] ;
  535. X{
  536. X#ifdef RLIMIT_NOFILE
  537. X    struct rlimit rl ;
  538. X    int fd ;
  539. X    int duped_fd ;
  540. X    char *s ;
  541. X
  542. X    if ( getrlimit( RLIMIT_NOFILE, &rl ) == -1 )
  543. X    {
  544. X        perror( "getrlimit" ) ;
  545. X        exit( 1 ) ;
  546. X    }
  547. X    if ( rl.rlim_cur != getdtablesize() )
  548. X    {
  549. X        printf( "rl.rlim_cur != getdtablesize()\n" ) ;
  550. X        exit( 1 ) ;
  551. X    }
  552. X    if ( rl.rlim_cur == rl.rlim_max )
  553. X        exit( 0 ) ;
  554. X
  555. X    rl.rlim_cur++ ;
  556. X    if ( setrlimit( RLIMIT_NOFILE, &rl ) == -1 )
  557. X    {
  558. X        perror( "setrlimit" ) ;
  559. X        exit( 1 ) ;
  560. X    }
  561. X    if ( Smorefds() == SIO_ERR )
  562. X    {
  563. X        perror( "Smorefds" ) ;
  564. X        exit( 1 ) ;
  565. X    }
  566. X    fd = open( "/etc/passwd", 0 ) ;
  567. X    if ( fd == -1 )
  568. X    {
  569. X        perror( "open" ) ;
  570. X        exit( 1 ) ;
  571. X    }
  572. X    duped_fd = getdtablesize()-1 ;
  573. X    if ( dup2( fd, duped_fd ) == -1 )
  574. X    {
  575. X        perror( "dup2" ) ;
  576. X        exit( 1 ) ;
  577. X    }
  578. X    s = Srdline( duped_fd ) ;
  579. X    if ( s == NULL )
  580. X    {
  581. X        perror( "Srdline" ) ;
  582. X        exit( 1 ) ;
  583. X    }
  584. X#endif
  585. X    exit( 0 ) ;
  586. X}
  587. END_OF_FILE
  588.   if test 1150 -ne `wc -c <'libs/src/sio/suite/fdtest.c'`; then
  589.     echo shar: \"'libs/src/sio/suite/fdtest.c'\" unpacked with wrong size!
  590.   fi
  591.   # end of 'libs/src/sio/suite/fdtest.c'
  592. fi
  593. if test -f 'libs/src/sio/suite/sprint_test' -a "${1}" != "-c" ; then 
  594.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/sprint_test'\"
  595. else
  596.   echo shar: Extracting \"'libs/src/sio/suite/sprint_test'\" \(1146 characters\)
  597.   sed "s/^X//" >'libs/src/sio/suite/sprint_test' <<'END_OF_FILE'
  598. X#!/bin/sh
  599. X
  600. X# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  601. X# All rights reserved.  The file named COPYRIGHT specifies the terms 
  602. X# and conditions for redistribution.
  603. X
  604. X
  605. X#
  606. X# $Id: sprint_test,v 8.1 1993/03/13 01:21:48 panos Exp $
  607. X#
  608. X
  609. Xcompare()
  610. X{
  611. X    cmp -s PRINTF.DATA SPRINT.DATA
  612. X    if [ $? -ne 0 ]
  613. X    then
  614. X        echo TEST $1 FAILED
  615. X        echo Check files PRINTF.DATA and SPRINT.DATA for differences
  616. X        exit 1
  617. X    else
  618. X        echo TEST $1 PASSED
  619. X        rm -f PRINTF.DATA SPRINT.DATA
  620. X    fi
  621. X}
  622. X
  623. Xformat_test()
  624. X{
  625. X    Sprint $@ 1>PRINTF.DATA 2>SPRINT.DATA
  626. X    compare "$*"
  627. X}
  628. X
  629. Xformat_test ALL
  630. X
  631. Xformat_test -W10 -F0 -c
  632. Xformat_test -W10 -F- -c
  633. X
  634. Xecho
  635. Xecho PRECISION TEST
  636. Xi=13
  637. Xwhile test $i -ne 0
  638. Xdo
  639. X    format_test -P$i -F# -X
  640. X    i=`expr $i - 1`
  641. Xdone
  642. Xecho END OF PRECISION TEST
  643. Xecho
  644. X
  645. Xformat_test -Vi -4 4 1 -o "-F#"
  646. X
  647. Xformat_test -Vf -1.0 1.0 0.3 -W30 -P13 -F+ -f
  648. Xformat_test -Vf -1.0 1.0 0.3 -W30 -P13 -F+ -e
  649. Xformat_test -Vf -1.0 2.0 0.3 -W30 -P13 -F+ -g
  650. X
  651. Xformat_test -Vf -1.0 1.0 0.3 -W30 -P13 -F+- -f
  652. Xformat_test -Vf -1.0 1.0 0.3 -W30 -P13 -F+- -e
  653. Xformat_test -Vf -1.0 2.0 0.3 -W30 -P13 -F+- -g
  654. X
  655. Xformat_test -W10 "-F " -x
  656. X
  657. Xformat_test -W40 -u -Vi 8 100 3 -F0
  658. X
  659. Xformat_test -b
  660. Xformat_test -b -P10
  661. END_OF_FILE
  662.   if test 1146 -ne `wc -c <'libs/src/sio/suite/sprint_test'`; then
  663.     echo shar: \"'libs/src/sio/suite/sprint_test'\" unpacked with wrong size!
  664.   fi
  665.   # end of 'libs/src/sio/suite/sprint_test'
  666. fi
  667. if test -f 'libs/src/sio/suite/testlib' -a "${1}" != "-c" ; then 
  668.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/testlib'\"
  669. else
  670.   echo shar: Extracting \"'libs/src/sio/suite/testlib'\" \(1172 characters\)
  671.   sed "s/^X//" >'libs/src/sio/suite/testlib' <<'END_OF_FILE'
  672. X#!/bin/sh
  673. X
  674. X# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  675. X# All rights reserved.  The file named COPYRIGHT specifies the terms 
  676. X# and conditions for redistribution.
  677. X
  678. X
  679. X#
  680. X# $Id: testlib,v 8.2 1993/09/08 05:59:01 panos Exp $
  681. X#
  682. X
  683. X#
  684. X# Purpose:
  685. X#        Invoke the tester script. This is necessary because the tester
  686. X#        script requires functions and /bin/sh does not support functions
  687. X#        on all OS's. This script decides what shell to use to execute
  688. X#        tester. On Suns, it uses /bin/sh. On DECstations, it uses
  689. X#        /usr/bin/ksh
  690. X#        The decision is made by checking $ARCH
  691. X#        
  692. X
  693. Xcase "$ARCH" in
  694. X    "")
  695. X        echo "ARCH not defined. Please define it."
  696. X        exit 1
  697. X        ;;
  698. X    
  699. X    sun4|sun3)
  700. X        TESTSHELL=/bin/sh
  701. X        LDFLAGS="-Bstatic -lm"
  702. X        ;;
  703. X
  704. X    dec-mips)
  705. X        TESTSHELL=/usr/bin/ksh
  706. X        LDFLAGS=
  707. X        ;;
  708. X    
  709. X    #
  710. X    # The following case was provided by Stephen House.
  711. X    # It applies to HP-UX 8.0 (and later, probably).
  712. X    #
  713. X    # The addition of MORE_DEFS was by me (Panos Tsirigotis)
  714. X    #
  715. X    hp)
  716. X        TESTSHELL=/bin/ksh
  717. X        LDFLAGS=
  718. X        MORE_DEFS="-DRANDOM=lrand48"
  719. X        ;;
  720. X
  721. X    *) echo "Unknown architecture: $ARCH"
  722. X        exit 2
  723. X        ;;
  724. Xesac
  725. X
  726. Xexport LDFLAGS
  727. Xexport TESTSHELL
  728. Xif test "$MORE_DEFS" ; then export MORE_DEFS ; fi
  729. X$TESTSHELL tester $*
  730. X
  731. END_OF_FILE
  732.   if test 1172 -ne `wc -c <'libs/src/sio/suite/testlib'`; then
  733.     echo shar: \"'libs/src/sio/suite/testlib'\" unpacked with wrong size!
  734.   fi
  735.   # end of 'libs/src/sio/suite/testlib'
  736. fi
  737. if test -f 'libs/src/sio/suite/tietest.c' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'libs/src/sio/suite/tietest.c'\"
  739. else
  740.   echo shar: Extracting \"'libs/src/sio/suite/tietest.c'\" \(669 characters\)
  741.   sed "s/^X//" >'libs/src/sio/suite/tietest.c' <<'END_OF_FILE'
  742. X/*
  743. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  744. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  745. X * and conditions for redistribution.
  746. X */
  747. X
  748. Xstatic char RCSid[] = "$Id: tietest.c,v 8.1 1993/03/13 01:24:07 panos Exp $" ;
  749. X
  750. X#include "sio.h"
  751. X#include <stdio.h>
  752. X
  753. Xmain()
  754. X{
  755. X    char *s ;
  756. X
  757. X    Stie( 0, 1 ) ;
  758. X    Sprint( 1, "Enter 1st command --> " ) ;
  759. X    s = Srdline( 0 ) ;
  760. X    Sprint( 1, "Received command: %s\n", s ) ;
  761. X    Sprint( 1, "Enter 2nd command --> " ) ;
  762. X    s = Srdline( 0 ) ;
  763. X    Sprint( 1, "Received command: %s\n", s ) ;
  764. X    Suntie( 0 ) ;
  765. X    Sprint( 1, "Enter 3rd command --> " ) ;
  766. X    s = Srdline( 0 ) ;
  767. X    Sprint( 1, "Received command: %s\n", s ) ;
  768. X    exit( 0 ) ;
  769. X}
  770. END_OF_FILE
  771.   if test 669 -ne `wc -c <'libs/src/sio/suite/tietest.c'`; then
  772.     echo shar: \"'libs/src/sio/suite/tietest.c'\" unpacked with wrong size!
  773.   fi
  774.   # end of 'libs/src/sio/suite/tietest.c'
  775. fi
  776. if test -f 'libs/src/str/CHANGELOG' -a "${1}" != "-c" ; then 
  777.   echo shar: Will not clobber existing file \"'libs/src/str/CHANGELOG'\"
  778. else
  779.   echo shar: Extracting \"'libs/src/str/CHANGELOG'\" \(507 characters\)
  780.   sed "s/^X//" >'libs/src/str/CHANGELOG' <<'END_OF_FILE'
  781. X
  782. X1.2.0: 
  783. X    First release (as part of xinetd 1.3)
  784. X
  785. X1.3.2:
  786. X    Added the string matching functions
  787. X
  788. X1.3.3: (posted to alt.sources)
  789. X    Changed the way the library is configured
  790. X
  791. X1.4.0:
  792. X    Added the shift-or string matching algorithm
  793. X    Implemented the automatic switching to the proper search algorithm
  794. X    Added the STRS_NOSWITCH flag to disallow switching
  795. X    Added the STRS_PATLEN flag
  796. X
  797. X1.4.1:
  798. X    Moved definition of u_wide_int from ss_rk.h to ss_impl.h
  799. X
  800. X1.4.2:
  801. X    Update the README file to remove all references to mystique.
  802. X
  803. END_OF_FILE
  804.   if test 507 -ne `wc -c <'libs/src/str/CHANGELOG'`; then
  805.     echo shar: \"'libs/src/str/CHANGELOG'\" unpacked with wrong size!
  806.   fi
  807.   # end of 'libs/src/str/CHANGELOG'
  808. fi
  809. if test -f 'libs/src/str/COPYRIGHT' -a "${1}" != "-c" ; then 
  810.   echo shar: Will not clobber existing file \"'libs/src/str/COPYRIGHT'\"
  811. else
  812.   echo shar: Extracting \"'libs/src/str/COPYRIGHT'\" \(1329 characters\)
  813.   sed "s/^X//" >'libs/src/str/COPYRIGHT' <<'END_OF_FILE'
  814. XThis software is
  815. X
  816. X(c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  817. X
  818. XThe author (Panagiotis Tsirigotis) grants permission to use, copy,
  819. Xand distribute this software and its documentation for any purpose 
  820. Xand without fee, provided that the above copyright notice extant in
  821. Xfiles in this distribution is not removed from files included in any
  822. Xredistribution and that this file is also included in any redistribution.
  823. X
  824. XModifications to this software may be distributed, either by distributing
  825. Xthe modified software or by distributing patches to the original software,
  826. Xunder the following additional terms:
  827. X
  828. X1. The version number will be modified as follows:
  829. X      a. The first 3 components of the version number
  830. X         (i.e <number>.<number>.<number>) will remain unchanged.
  831. X      b. A new component will be appended to the version number to indicate
  832. X         the modification level. The form of this component is up to the 
  833. X         author of the modifications.
  834. X
  835. X2. The author of the modifications will include his/her name by appending it 
  836. X   along with the new version number to this file and will be responsible for 
  837. X   any wrong behavior of the modified software.
  838. X
  839. XThe author makes no representations about the suitability of this 
  840. Xsoftware for any purpose.  It is provided "as is" without any express 
  841. Xor implied warranty.
  842. X
  843. END_OF_FILE
  844.   if test 1329 -ne `wc -c <'libs/src/str/COPYRIGHT'`; then
  845.     echo shar: \"'libs/src/str/COPYRIGHT'\" unpacked with wrong size!
  846.   fi
  847.   # end of 'libs/src/str/COPYRIGHT'
  848. fi
  849. if test -f 'libs/src/str/ss_bf.c' -a "${1}" != "-c" ; then 
  850.   echo shar: Will not clobber existing file \"'libs/src/str/ss_bf.c'\"
  851. else
  852.   echo shar: Extracting \"'libs/src/str/ss_bf.c'\" \(1305 characters\)
  853.   sed "s/^X//" >'libs/src/str/ss_bf.c' <<'END_OF_FILE'
  854. X/*
  855. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  856. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  857. X * and conditions for redistribution.
  858. X */
  859. X
  860. Xstatic char RCSid[] = "$Id" ;
  861. X
  862. X#include "ss_impl.h"
  863. X
  864. XPRIVATE int bf_setup() ;
  865. XPRIVATE char *bf_match() ;
  866. XPRIVATE void bf_done() ;
  867. X
  868. Xstruct ss_ops __strs_bfops = { bf_setup, bf_match, bf_done } ;
  869. X
  870. X
  871. XPRIVATE int bf_setup( hp )
  872. X    header_s *hp ;
  873. X{
  874. X#ifdef lint
  875. X    hp = hp ;
  876. X#endif
  877. X    return( SS_OK ) ;
  878. X}
  879. X
  880. X
  881. XPRIVATE char *bf_match( hp, str, len )
  882. X    header_s        *hp ;
  883. X    char            *str ;
  884. X    int            len ;
  885. X{
  886. X    register int    pfc        = SS_PATTERN( hp )[ 0 ] ;    /* pattern first char */
  887. X    register char    *pos        = str ;
  888. X    register char    *endpos    = &str[ len - SS_PATLEN( hp ) + 1 ] ;
  889. X    char                *endpat    = &SS_PATTERN( hp )[ SS_PATLEN( hp ) ] ;
  890. X
  891. X    while ( pos < endpos )
  892. X    {
  893. X        register int strc = SS_MAP( hp, *pos ) ;
  894. X        register char *pp ;                                    /* pattern pointer */
  895. X        register char *sp ;                                    /* string pointer */
  896. X
  897. X        pos++ ;
  898. X        if ( strc != pfc )
  899. X            continue ;
  900. X
  901. X        for ( pp = &SS_PATTERN( hp )[ 1 ], sp = pos ;; sp++, pp++ )
  902. X        {
  903. X            if ( pp == endpat )            /* we are guaranteed a non-empty pattern */
  904. X                return( pos-1 ) ;
  905. X            if ( *pp != SS_MAP( hp, *sp ) )
  906. X                break ;
  907. X        }
  908. X    }
  909. X    return( CHAR_NULL ) ;
  910. X}
  911. X
  912. X
  913. XPRIVATE void bf_done( hp )
  914. X    header_s *hp ;
  915. X{
  916. X#ifdef lint
  917. X    hp = hp ;
  918. X#endif
  919. X}
  920. X
  921. END_OF_FILE
  922.   if test 1305 -ne `wc -c <'libs/src/str/ss_bf.c'`; then
  923.     echo shar: \"'libs/src/str/ss_bf.c'\" unpacked with wrong size!
  924.   fi
  925.   # end of 'libs/src/str/ss_bf.c'
  926. fi
  927. if test -f 'libs/src/str/ss_bmh.c' -a "${1}" != "-c" ; then 
  928.   echo shar: Will not clobber existing file \"'libs/src/str/ss_bmh.c'\"
  929. else
  930.   echo shar: Extracting \"'libs/src/str/ss_bmh.c'\" \(1721 characters\)
  931.   sed "s/^X//" >'libs/src/str/ss_bmh.c' <<'END_OF_FILE'
  932. X/*
  933. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  934. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  935. X * and conditions for redistribution.
  936. X */
  937. X
  938. Xstatic char RCSid[] = "$Id" ;
  939. X
  940. Xchar *malloc() ;
  941. X
  942. X#include "ss_impl.h"
  943. X
  944. XPRIVATE int bmh_setup() ;
  945. XPRIVATE char *bmh_match() ;
  946. XPRIVATE void bmh_done() ;
  947. X
  948. Xstruct ss_ops __strs_bmhops = { bmh_setup, bmh_match, bmh_done } ;
  949. X
  950. X
  951. XPRIVATE int bmh_setup( hp )
  952. X    header_s *hp ;
  953. X{
  954. X    register int    patlen    = SS_PATLEN( hp ) ;
  955. X    register int    limit        = patlen - 1 ;            /* patlen is > 0 */
  956. X    register char    *pattern = SS_PATTERN( hp ) ;
  957. X    register int    i ;
  958. X    shift_int        *shift ;
  959. X
  960. X    shift = (shift_int *) malloc( ALPHABET_SIZE * sizeof( shift_int ) ) ;
  961. X    if ( shift == (shift_int *)NULL )
  962. X        return( SS_ERR ) ;
  963. X
  964. X    for ( i = 0 ; i < ALPHABET_SIZE ; i++ )
  965. X        shift[ i ] = patlen ;
  966. X    
  967. X    for ( i = 0 ; i < limit ; i++ )
  968. X        shift[ (unsigned char) pattern[ i ] ] = limit - i ;
  969. X
  970. X    BMH_HEADER( hp )->shift = shift ;
  971. X    return( SS_OK ) ;
  972. X}
  973. X
  974. X
  975. XPRIVATE char *bmh_match( hp, str, len )
  976. X    header_s            *hp ;
  977. X    register char    *str ;
  978. X    int                len ;
  979. X{
  980. X    register int    i ;
  981. X    int                patlen    = SS_PATLEN( hp ) ;
  982. X    char                *pattern = SS_PATTERN( hp ) ;
  983. X    register char    lpc        = pattern[ patlen-1 ] ;    /* last pattern character */
  984. X    shift_int        *shift    = BMH_HEADER( hp )->shift ;
  985. X
  986. X    i = patlen - 1 ;
  987. X    while ( i < len )
  988. X    {
  989. X        char c = SS_MAP( hp, str[ i ] ) ;
  990. X
  991. X        if ( c == lpc )
  992. X        {
  993. X            int j, k ;
  994. X
  995. X            for ( j = patlen-1, k = i ;; )
  996. X            {
  997. X                if ( j == 0 )
  998. X                    return( &str[ k ] ) ;
  999. X                j--, k-- ;
  1000. X                if ( pattern[ j ] != SS_MAP( hp, str[ k ] ) )
  1001. X                    break ;
  1002. X            }
  1003. X        }
  1004. X        i += shift[ (unsigned char) c ] ;
  1005. X    }
  1006. X    return( CHAR_NULL ) ;
  1007. X}
  1008. X
  1009. X
  1010. XPRIVATE void bmh_done( hp )
  1011. X    header_s *hp ;
  1012. X{
  1013. X    (void) free( (char *)BMH_HEADER( hp )->shift ) ;
  1014. X}
  1015. X
  1016. END_OF_FILE
  1017.   if test 1721 -ne `wc -c <'libs/src/str/ss_bmh.c'`; then
  1018.     echo shar: \"'libs/src/str/ss_bmh.c'\" unpacked with wrong size!
  1019.   fi
  1020.   # end of 'libs/src/str/ss_bmh.c'
  1021. fi
  1022. if test -f 'libs/src/str/ss_kmp.h' -a "${1}" != "-c" ; then 
  1023.   echo shar: Will not clobber existing file \"'libs/src/str/ss_kmp.h'\"
  1024. else
  1025.   echo shar: Extracting \"'libs/src/str/ss_kmp.h'\" \(381 characters\)
  1026.   sed "s/^X//" >'libs/src/str/ss_kmp.h' <<'END_OF_FILE'
  1027. X/*
  1028. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1029. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1030. X * and conditions for redistribution.
  1031. X */
  1032. X
  1033. X#ifndef SS_KMP_H
  1034. X#define SS_KMP_H
  1035. X
  1036. X/*
  1037. X * $Id: ss_kmp.h,v 3.1 1993/06/13 02:44:52 panos Exp $
  1038. X */
  1039. X
  1040. Xtypedef int next_int ;            /* must be signed */
  1041. X
  1042. Xstruct kmp_header
  1043. X{
  1044. X    next_int *next ;
  1045. X} ;
  1046. X
  1047. X#endif    /* SS_KMP_H */
  1048. X
  1049. END_OF_FILE
  1050.   if test 381 -ne `wc -c <'libs/src/str/ss_kmp.h'`; then
  1051.     echo shar: \"'libs/src/str/ss_kmp.h'\" unpacked with wrong size!
  1052.   fi
  1053.   # end of 'libs/src/str/ss_kmp.h'
  1054. fi
  1055. if test -f 'libs/src/str/ss_rk.c' -a "${1}" != "-c" ; then 
  1056.   echo shar: Will not clobber existing file \"'libs/src/str/ss_rk.c'\"
  1057. else
  1058.   echo shar: Extracting \"'libs/src/str/ss_rk.c'\" \(2625 characters\)
  1059.   sed "s/^X//" >'libs/src/str/ss_rk.c' <<'END_OF_FILE'
  1060. X/*
  1061. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1062. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1063. X * and conditions for redistribution.
  1064. X */
  1065. X
  1066. Xstatic char RCSid[] = "$Id: ss_rk.c,v 3.1 1993/06/13 02:45:04 panos Exp $" ;
  1067. X
  1068. X#include "ss_impl.h"
  1069. X
  1070. X/*
  1071. X * Multiply a number by the radix we are using
  1072. X */
  1073. X#define RADIX_MULT( n )                        ( (n) << NBIC )
  1074. X
  1075. X#define UCHAR( c )                            ((unsigned char)(c))
  1076. X
  1077. X
  1078. XPRIVATE int rk_setup() ;
  1079. XPRIVATE char *rk_match() ;
  1080. XPRIVATE void rk_done() ;
  1081. X
  1082. Xstruct ss_ops __strs_rkops = { rk_setup, rk_match, rk_done } ;
  1083. X
  1084. X
  1085. XPRIVATE int rk_setup( hp )
  1086. X    register header_s *hp ;
  1087. X{
  1088. X    register int        i ;
  1089. X    struct rk_header    *rkp        = RK_HEADER( hp ) ;
  1090. X    u_wide_int            patval    = 0 ;
  1091. X    u_wide_int            digit_1    = 1 ;
  1092. X
  1093. X    /*
  1094. X     * Compute pattern value
  1095. X     */
  1096. X    for ( i = 0 ; i < SS_PATLEN( hp ) ; i++ )
  1097. X        patval = ( RADIX_MULT( patval ) + UCHAR( SS_PATTERN( hp )[i] ) ) % PRIME ;
  1098. X    
  1099. X    for ( i = 0 ; i < SS_PATLEN( hp )-1 ; i++ )
  1100. X        digit_1 = RADIX_MULT( digit_1 ) % PRIME ;
  1101. X
  1102. X    rkp->rk_patval = patval ;
  1103. X    rkp->rk_digit1 = digit_1 ;
  1104. X    return( SS_OK ) ;
  1105. X}
  1106. X
  1107. X
  1108. XPRIVATE void rk_done( hp ) 
  1109. X    header_s *hp ;
  1110. X{
  1111. X#ifdef lint
  1112. X    hp = hp ;
  1113. X#endif
  1114. X}
  1115. X
  1116. X
  1117. XPRIVATE char *rk_match( hp, str, len )
  1118. X    register header_s        *hp ;
  1119. X    char                        *str ;
  1120. X    int                        len ;
  1121. X{
  1122. X    register int                i ;
  1123. X    register unsigned char    uc ;
  1124. X    register u_wide_int        strval    = 0 ;
  1125. X    register u_wide_int        patval    = RK_HEADER( hp )->rk_patval ;
  1126. X    register u_wide_int        digit_1    = RK_HEADER( hp )->rk_digit1 ;
  1127. X    int                            patlen    = SS_PATLEN( hp ) ;
  1128. X    char                            *endpat    = &SS_PATTERN( hp )[ patlen ] ;
  1129. X
  1130. X    /*
  1131. X     * Calculate initial value of 'str'
  1132. X     * Note that we are guaranteed that len >= pattern length
  1133. X     */
  1134. X    for ( i = 0 ; i < patlen ; i++ )
  1135. X    {
  1136. X        uc = UCHAR( SS_MAP( hp, str[i] ) ) ;
  1137. X        strval = ( RADIX_MULT( strval ) + uc ) % PRIME ;
  1138. X    }
  1139. X
  1140. X    for ( i = 0 ;; i++ )
  1141. X    {
  1142. X        register u_wide_int t1 ;
  1143. X
  1144. X        if ( strval == patval )
  1145. X        {
  1146. X            char *pp, *sp ;
  1147. X
  1148. X            for ( pp = SS_PATTERN( hp ), sp = &str[i] ;; sp++, pp++ )
  1149. X            {
  1150. X                if ( pp == endpat )
  1151. X                    return( &str[i] ) ;
  1152. X                if ( *pp != SS_MAP( hp, *sp ) )
  1153. X                    break ;
  1154. X            }
  1155. X        }
  1156. X
  1157. X        if ( i == len-patlen+1 )
  1158. X            break ;
  1159. X
  1160. X        /*
  1161. X         * The formula we evaluate is:
  1162. X         *
  1163. X         *    strval = ( RADIX_MULT( ( strval - UCHAR( str[i] )*digit_1 ) ) + 
  1164. X         *                        UCHAR( str[i+patlen] ) ) % PRIME ;
  1165. X         *
  1166. X         * We have to make sure that the subtraction does not produce
  1167. X         * a negative number since that causes strval to be wrong.
  1168. X         */
  1169. X        uc = UCHAR( SS_MAP( hp, str[i] ) ) ;
  1170. X        t1 = ( uc * digit_1 ) % PRIME ;
  1171. X        if ( t1 > strval )
  1172. X            strval += PRIME ;
  1173. X        uc = UCHAR( SS_MAP( hp, str[i+patlen] ) ) ;
  1174. X        strval = ( RADIX_MULT( strval - t1 ) + uc ) % PRIME ;
  1175. X    }
  1176. X    return( NULL ) ;
  1177. X}
  1178. X
  1179. X
  1180. END_OF_FILE
  1181.   if test 2625 -ne `wc -c <'libs/src/str/ss_rk.c'`; then
  1182.     echo shar: \"'libs/src/str/ss_rk.c'\" unpacked with wrong size!
  1183.   fi
  1184.   # end of 'libs/src/str/ss_rk.c'
  1185. fi
  1186. if test -f 'libs/src/str/ss_rk.h' -a "${1}" != "-c" ; then 
  1187.   echo shar: Will not clobber existing file \"'libs/src/str/ss_rk.h'\"
  1188. else
  1189.   echo shar: Extracting \"'libs/src/str/ss_rk.h'\" \(579 characters\)
  1190.   sed "s/^X//" >'libs/src/str/ss_rk.h' <<'END_OF_FILE'
  1191. X/*
  1192. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1193. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1194. X * and conditions for redistribution.
  1195. X */
  1196. X
  1197. X#ifndef SS_RK_H
  1198. X#define SS_RK_H
  1199. X
  1200. X/*
  1201. X * $Id: ss_rk.h,v 3.2 1993/06/16 00:06:34 panos Exp $
  1202. X */
  1203. X
  1204. Xstruct rk_header
  1205. X{
  1206. X    u_wide_int rk_digit1 ;                /* in the appropriate radix */
  1207. X    u_wide_int rk_patval ;
  1208. X} ;
  1209. X
  1210. X#if WIDE_INT_SIZE == 32
  1211. X#    define PRIME                        16777213
  1212. X#else
  1213. X#    if WIDE_INT_SIZE == 16
  1214. X#        define PRIME                    251
  1215. X#    else
  1216. X        int WIDE_INT_SIZE_has_bad_value = or_is_undefined ;
  1217. X#    endif 
  1218. X#endif
  1219. X
  1220. X#endif    /* SS_RK_H */
  1221. X
  1222. END_OF_FILE
  1223.   if test 579 -ne `wc -c <'libs/src/str/ss_rk.h'`; then
  1224.     echo shar: \"'libs/src/str/ss_rk.h'\" unpacked with wrong size!
  1225.   fi
  1226.   # end of 'libs/src/str/ss_rk.h'
  1227. fi
  1228. if test -f 'libs/src/str/ss_sbm.c' -a "${1}" != "-c" ; then 
  1229.   echo shar: Will not clobber existing file \"'libs/src/str/ss_sbm.c'\"
  1230. else
  1231.   echo shar: Extracting \"'libs/src/str/ss_sbm.c'\" \(1825 characters\)
  1232.   sed "s/^X//" >'libs/src/str/ss_sbm.c' <<'END_OF_FILE'
  1233. X/*
  1234. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1235. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1236. X * and conditions for redistribution.
  1237. X */
  1238. X
  1239. Xstatic char RCSid[] = "$Id: ss_sbm.c,v 3.1 1993/06/13 02:45:45 panos Exp $" ;
  1240. X
  1241. Xchar *malloc() ;
  1242. X
  1243. X#include "ss_impl.h"
  1244. X#include "ss_sbm.h"
  1245. X
  1246. XPRIVATE int sbm_setup() ;
  1247. XPRIVATE char *sbm_match() ;
  1248. XPRIVATE void sbm_done() ;
  1249. X
  1250. X
  1251. Xstruct ss_ops __strs_sbmops = { sbm_setup, sbm_match, sbm_done } ;
  1252. X
  1253. X
  1254. XPRIVATE int sbm_setup( hp )
  1255. X    header_s *hp ;
  1256. X{
  1257. X    last_int            *last_occurrence ;
  1258. X    register int    i ;
  1259. X    int                patlen    = SS_PATLEN( hp ) ;
  1260. X    char                *pattern = SS_PATTERN( hp ) ;
  1261. X
  1262. X    last_occurrence = (last_int *) malloc( ALPHABET_SIZE * sizeof( last_int ) ) ;
  1263. X    if ( last_occurrence == (last_int *)0 )
  1264. X        return( SS_ERR ) ;
  1265. X    
  1266. X    for ( i = 0 ; i < ALPHABET_SIZE ; i++ )
  1267. X        last_occurrence[ i ] = -1 ;
  1268. X    for ( i = 0 ; i < patlen ; i++ )
  1269. X        last_occurrence[ (unsigned char) pattern[ i ] ] = i ;
  1270. X
  1271. X    SBM_HEADER( hp )->last_occurrence = last_occurrence ;
  1272. X    return( SS_OK ) ;
  1273. X}
  1274. X
  1275. X
  1276. X
  1277. XPRIVATE char *sbm_match( hp, str, len )
  1278. X    header_s        *hp ;
  1279. X    char            *str ;
  1280. X    int            len ;
  1281. X{
  1282. X    register int    j ;
  1283. X    register int    s                        = 0 ;
  1284. X    char                *pattern                = SS_PATTERN( hp ) ;
  1285. X    int                patlen                = SS_PATLEN( hp ) ;
  1286. X    last_int            *last_occurrence    = SBM_HEADER( hp )->last_occurrence ;
  1287. X
  1288. X    while ( s <= len - patlen )
  1289. X    {
  1290. X        register char c ;
  1291. X        last_int lo ;
  1292. X
  1293. X        /*
  1294. X         * Try matching pattern right-to-left
  1295. X         */
  1296. X        for ( j = patlen-1 ;; )
  1297. X        {
  1298. X            c = SS_MAP( hp, str[ s+j ] ) ;
  1299. X            if ( pattern[ j ] == c )
  1300. X                if ( j )
  1301. X                    j-- ;
  1302. X                else
  1303. X                    return( &str[ s ] ) ;
  1304. X            else
  1305. X                break ;
  1306. X        }
  1307. X        lo = last_occurrence[ (unsigned char) c ] ;
  1308. X        if ( j > lo )
  1309. X            s += j - lo ;
  1310. X        else
  1311. X            s++ ;
  1312. X    }
  1313. X    return( CHAR_NULL ) ;
  1314. X}
  1315. X
  1316. X
  1317. XPRIVATE void sbm_done( hp )
  1318. X    header_s *hp ;
  1319. X{
  1320. X    (void) free( (char *) SBM_HEADER( hp )->last_occurrence ) ;
  1321. X}
  1322. X
  1323. END_OF_FILE
  1324.   if test 1825 -ne `wc -c <'libs/src/str/ss_sbm.c'`; then
  1325.     echo shar: \"'libs/src/str/ss_sbm.c'\" unpacked with wrong size!
  1326.   fi
  1327.   # end of 'libs/src/str/ss_sbm.c'
  1328. fi
  1329. if test -f 'libs/src/str/ss_sbm.h' -a "${1}" != "-c" ; then 
  1330.   echo shar: Will not clobber existing file \"'libs/src/str/ss_sbm.h'\"
  1331. else
  1332.   echo shar: Extracting \"'libs/src/str/ss_sbm.h'\" \(393 characters\)
  1333.   sed "s/^X//" >'libs/src/str/ss_sbm.h' <<'END_OF_FILE'
  1334. X/*
  1335. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1336. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1337. X * and conditions for redistribution.
  1338. X */
  1339. X
  1340. X
  1341. X#ifndef SS_SBM_H
  1342. X#define SS_SBM_H
  1343. X
  1344. X/*
  1345. X * $Id: ss_sbm.h,v 3.1 1993/06/13 02:46:00 panos Exp $
  1346. X */
  1347. X
  1348. Xtypedef int last_int ;            /* must be signed */
  1349. X
  1350. Xstruct sbm_header
  1351. X{
  1352. X    last_int *last_occurrence ;
  1353. X} ;
  1354. X
  1355. X#endif    /* SS_SBM_H */
  1356. X
  1357. END_OF_FILE
  1358.   if test 393 -ne `wc -c <'libs/src/str/ss_sbm.h'`; then
  1359.     echo shar: \"'libs/src/str/ss_sbm.h'\" unpacked with wrong size!
  1360.   fi
  1361.   # end of 'libs/src/str/ss_sbm.h'
  1362. fi
  1363. if test -f 'libs/src/str/strparse.h' -a "${1}" != "-c" ; then 
  1364.   echo shar: Will not clobber existing file \"'libs/src/str/strparse.h'\"
  1365. else
  1366.   echo shar: Extracting \"'libs/src/str/strparse.h'\" \(1514 characters\)
  1367.   sed "s/^X//" >'libs/src/str/strparse.h' <<'END_OF_FILE'
  1368. X/*
  1369. X * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1370. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1371. X * and conditions for redistribution.
  1372. X */
  1373. X
  1374. X
  1375. X/*
  1376. X * $Id: strparse.h,v 3.1 1993/06/13 02:48:35 panos Exp $
  1377. X */
  1378. X
  1379. Xstruct str_handle
  1380. X{
  1381. X   char *string ;
  1382. X   char *separator ;
  1383. X   char *pos ;
  1384. X   int flags ;
  1385. X   int *errnop ;
  1386. X   int no_more ;
  1387. X} ;
  1388. X
  1389. Xint str_errno ;
  1390. X
  1391. X#ifndef NULL
  1392. X#define NULL         0
  1393. X#endif
  1394. X
  1395. X#ifndef FALSE
  1396. X#define FALSE        0
  1397. X#define TRUE         1
  1398. X#endif
  1399. X
  1400. X#define PRIVATE        static
  1401. X
  1402. X#define TERMINATE( msg )   {                                         \
  1403. X                              char *s = msg ;                        \
  1404. X                                                                     \
  1405. X                              (void) write( 2, s, strlen( s ) ) ;    \
  1406. X                              (void) abort() ;                       \
  1407. X                              _exit( 1 ) ;                           \
  1408. X                              /* NOTREACHED */                       \
  1409. X                           }
  1410. X
  1411. X
  1412. X#define HANDLE_ERROR( flags, retval, errp, errval, msg )    \
  1413. X            if ( flags & STR_RETURN_ERROR )                 \
  1414. X            {                                               \
  1415. X               *errp = errval ;                             \
  1416. X               return( retval ) ;                           \
  1417. X            }                                               \
  1418. X            else                                            \
  1419. X               TERMINATE( msg )
  1420. X
  1421. X
  1422. END_OF_FILE
  1423.   if test 1514 -ne `wc -c <'libs/src/str/strparse.h'`; then
  1424.     echo shar: \"'libs/src/str/strparse.h'\" unpacked with wrong size!
  1425.   fi
  1426.   # end of 'libs/src/str/strparse.h'
  1427. fi
  1428. if test -f 'libs/src/str/strutil.3' -a "${1}" != "-c" ; then 
  1429.   echo shar: Will not clobber existing file \"'libs/src/str/strutil.3'\"
  1430. else
  1431.   echo shar: Extracting \"'libs/src/str/strutil.3'\" \(1367 characters\)
  1432.   sed "s/^X//" >'libs/src/str/strutil.3' <<'END_OF_FILE'
  1433. X.\"(c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  1434. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  1435. X.\"and conditions for redistribution.
  1436. X.\"
  1437. X.\" $Id: strutil.3,v 3.1 1993/06/13 02:49:23 panos Exp $
  1438. X.TH STRUTIL 3X "30 September 1992"
  1439. X.SH NAME
  1440. Xstr_find, str_casefind, str_fill, str_lower, str_upper -- string utility functions
  1441. X.SH SYNOPSIS
  1442. X.LP
  1443. X.nf
  1444. X.ft B
  1445. X#include "str.h"
  1446. X.LP
  1447. X.ft B
  1448. Xchar *str_find( s1, s2 )
  1449. Xchar *s1, *s2 ;
  1450. X.LP
  1451. X.ft B
  1452. Xchar *str_casefind( s1, s2 )
  1453. Xchar *s1, *s2 ;
  1454. X.LP
  1455. X.ft B
  1456. Xvoid str_fill( s, c )
  1457. Xchar *s ;
  1458. Xchar c ;
  1459. X.LP
  1460. X.ft B
  1461. Xchar *str_lower( s )
  1462. Xchar *s ;
  1463. X.LP
  1464. X.ft B
  1465. Xchar *str_upper( s )
  1466. Xchar *s ;
  1467. X.SH DESCRIPTION
  1468. X.B str_find()
  1469. Xreturns a pointer to the first instance of string \fIs2\fR in string \fIs1\fR.
  1470. XIf \fIs2\fR is the empty string a pointer to \fIs1\fR is returned.
  1471. X.LP
  1472. X.B str_casefind()
  1473. Xperforms the same function as
  1474. X.B str_find()
  1475. Xexcept that it performs case insensitive character comparisons.
  1476. X.LP
  1477. X.B str_fill()
  1478. Xfills the string \fIs\fR with the character \fIc\fR.
  1479. X.LP
  1480. X.B str_lower()
  1481. Xand
  1482. X.B str_upper()
  1483. Xconvert their argument in place to a lower or upper case string respectively.
  1484. X.SH "RETURN VALUES"
  1485. X.LP
  1486. X\fBstr_find()\fR 
  1487. Xand
  1488. X.B str_casefind()
  1489. Xreturn a pointer to the first occurrence of \fIs2\fR
  1490. Xin \fIs1\fR or
  1491. X.SM NULL
  1492. Xif \fIs2\fR does not exist in \fIs1\fR.
  1493. X.LP
  1494. X\fBstr_lower()\fR and \fBstr_upper()\fR return \fIs\fR.
  1495. END_OF_FILE
  1496.   if test 1367 -ne `wc -c <'libs/src/str/strutil.3'`; then
  1497.     echo shar: \"'libs/src/str/strutil.3'\" unpacked with wrong size!
  1498.   fi
  1499.   # end of 'libs/src/str/strutil.3'
  1500. fi
  1501. if test -f 'pst/CHANGELOG' -a "${1}" != "-c" ; then 
  1502.   echo shar: Will not clobber existing file \"'pst/CHANGELOG'\"
  1503. else
  1504.   echo shar: Extracting \"'pst/CHANGELOG'\" \(38 characters\)
  1505.   sed "s/^X//" >'pst/CHANGELOG' <<'END_OF_FILE'
  1506. X
  1507. X1.0.0:
  1508. X    Posted to comp.sources.misc
  1509. X
  1510. END_OF_FILE
  1511.   if test 38 -ne `wc -c <'pst/CHANGELOG'`; then
  1512.     echo shar: \"'pst/CHANGELOG'\" unpacked with wrong size!
  1513.   fi
  1514.   # end of 'pst/CHANGELOG'
  1515. fi
  1516. if test -f 'pst/defs.h' -a "${1}" != "-c" ; then 
  1517.   echo shar: Will not clobber existing file \"'pst/defs.h'\"
  1518. else
  1519.   echo shar: Extracting \"'pst/defs.h'\" \(1426 characters\)
  1520.   sed "s/^X//" >'pst/defs.h' <<'END_OF_FILE'
  1521. X/*
  1522. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  1523. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1524. X * and conditions for redistribution.
  1525. X */
  1526. X
  1527. X/*
  1528. X * $Id: defs.h,v 1.1 1993/02/05 01:25:53 panos Exp $
  1529. X */
  1530. X
  1531. X#define PRIVATE                            static
  1532. X
  1533. X#define FALSE                                0
  1534. X#define TRUE                                1
  1535. X
  1536. X#define NULL                                0
  1537. X
  1538. X#define NUL                                    '\0'
  1539. X#define SPACE                                ' '
  1540. X#define NEWLINE                            '\n'
  1541. X#define CARRIAGE_RETURN                    '\015'
  1542. X#define TAB                                    '\t'
  1543. X#define BACKSLASH                            '\\'
  1544. X#define OPEN_PAREN                        '('
  1545. X#define CLOSE_PAREN                        ')'
  1546. X#define OPEN_CURLY_BRACKET                '{'
  1547. X#define CLOSED_CURLY_BRACKET            '}'
  1548. X#define OPEN_BRACKET                        '['
  1549. X#define CLOSED_BRACKET                    ']'
  1550. X#define LESS_THAN                            '<'
  1551. X#define GREATER_THAN                        '>'
  1552. X#define MINUS                                '-'
  1553. X#define SLASH                                '/'
  1554. X
  1555. Xtypedef enum { TOK_STRING, TOK_NUMBER, TOK_OTHER, TOK_CMD } token_e ;
  1556. X
  1557. Xvoid error() ;
  1558. Xvoid printout() ;
  1559. X
  1560. Xextern int line_count ;
  1561. X
  1562. X#define NUM( c )                            ( (c) - '0' )
  1563. X
  1564. X#define NEXT_CHAR( fd, c )                {                                    \
  1565. X                                                    c = Sgetchar( fd ) ;        \
  1566. X                                                    if ( c == NEWLINE )        \
  1567. X                                                        line_count++ ;            \
  1568. X                                                }
  1569. X
  1570. X#define PUTBACK( fd, c )         {                                \
  1571. X                                    Sundo( fd, SIO_UNDO_CHAR ) ;  \
  1572. X                                    if ( c == NEWLINE )           \
  1573. X                                       line_count-- ;             \
  1574. X                                 }
  1575. X
  1576. X
  1577. END_OF_FILE
  1578.   if test 1426 -ne `wc -c <'pst/defs.h'`; then
  1579.     echo shar: \"'pst/defs.h'\" unpacked with wrong size!
  1580.   fi
  1581.   # end of 'pst/defs.h'
  1582. fi
  1583. if test -f 'pst/dit.c' -a "${1}" != "-c" ; then 
  1584.   echo shar: Will not clobber existing file \"'pst/dit.c'\"
  1585. else
  1586.   echo shar: Extracting \"'pst/dit.c'\" \(2838 characters\)
  1587.   sed "s/^X//" >'pst/dit.c' <<'END_OF_FILE'
  1588. X/*
  1589. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  1590. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1591. X * and conditions for redistribution.
  1592. X */
  1593. X
  1594. Xstatic char RCSid[] = "$Id: dit.c,v 1.3 1993/09/14 23:05:28 panos Exp $" ;
  1595. X
  1596. X#include "string.h"
  1597. X
  1598. X#include "sio.h"
  1599. X
  1600. X#define PAGE_ID                        "%%Page:"
  1601. X
  1602. X#include "defs.h"
  1603. X
  1604. Xvoid decode_string() ;
  1605. X
  1606. X
  1607. XPRIVATE void skip_to_first_page( fd )
  1608. X    int fd ;
  1609. X{
  1610. X    char *line ;
  1611. X    char *page_id = PAGE_ID ;
  1612. X    int len = strlen( PAGE_ID ) ;
  1613. X
  1614. X    while ( line = Srdline( fd ) )
  1615. X    {
  1616. X        line_count++ ;
  1617. X        if ( strncmp( line, page_id, len ) == 0 )
  1618. X            return ;
  1619. X    }
  1620. X    error( "Failed to find 1st page\n" ) ;
  1621. X}
  1622. X
  1623. X
  1624. Xint get_line_char( sp )
  1625. X    char **sp ;
  1626. X{
  1627. X    char *p = *sp ;
  1628. X    char c = *p++ ;
  1629. X
  1630. X    if ( c == NUL )
  1631. X        error( "Reached end of line while reading string\n" ) ;
  1632. X    *sp = p ;
  1633. X    return( c ) ;
  1634. X}
  1635. X
  1636. X
  1637. X/*
  1638. X * Assumptions:
  1639. X *        2 consecutive numbers ==> new line
  1640. X *        first char of each line is a number
  1641. X */
  1642. Xvoid psdit_process( fd )
  1643. X    int fd ;
  1644. X{
  1645. X    char *line ;
  1646. X    char *p ;
  1647. X    int output_string = FALSE ;
  1648. X
  1649. X    skip_to_first_page( fd ) ;
  1650. X
  1651. X    while ( line = Srdline( fd ) )
  1652. X    {
  1653. X        if ( isdigit( line[ 0 ] ) )
  1654. X        {
  1655. X            for ( p = &line[ 1 ] ; isdigit( *p ) ; p++ ) ;
  1656. X
  1657. X            while ( isspace( *p ) ) p++ ;
  1658. X
  1659. X            if ( isdigit( *p ) )
  1660. X            {
  1661. X                for ( p++ ; isdigit( *p ) ; p++ ) ;
  1662. X                if ( output_string )
  1663. X                {
  1664. X                    printout( NEWLINE ) ;
  1665. X                    output_string = FALSE ;
  1666. X                }
  1667. X            }
  1668. X        }
  1669. X        else
  1670. X            p = line ;
  1671. X
  1672. X        p = strchr( p, OPEN_PAREN ) ;
  1673. X        if ( p == NULL )
  1674. X            continue ;
  1675. X        p++ ;
  1676. X        decode_string( get_line_char, (void *)&p ) ;
  1677. X        output_string = TRUE ;
  1678. X        if ( isalpha( *p ) )
  1679. X            printout( SPACE ) ;
  1680. X    }
  1681. X}
  1682. X
  1683. X
  1684. Xvoid ditroff_process( fd )
  1685. X    int fd ;
  1686. X{
  1687. X    char *line ;
  1688. X    char *page_id = PAGE_ID ;
  1689. X    int len = strlen( PAGE_ID ) ;
  1690. X
  1691. X    skip_to_first_page( fd ) ;
  1692. X
  1693. X    while ( line = Srdline( fd ) )
  1694. X    {
  1695. X        char *p ;
  1696. X
  1697. X        if ( line[0] == '%' )
  1698. X        {
  1699. X            if ( strncmp( page_id, line, len ) == 0 )
  1700. X                start_paragraph() ;
  1701. X            continue ;
  1702. X        }
  1703. X        
  1704. X        p = strchr( line, OPEN_PAREN ) ;
  1705. X        if ( p == NULL )
  1706. X            continue ;
  1707. X        if ( p[-1] == 'Y' )
  1708. X            printout( NEWLINE ) ;
  1709. X        else if ( p[-1] == 'Z' )
  1710. X            start_paragraph() ;
  1711. X        p++ ;
  1712. X        decode_string( get_line_char, (void *)&p ) ;
  1713. X        printout( SPACE ) ;
  1714. X    }
  1715. X}
  1716. X
  1717. Xvoid troff_process( fd )
  1718. X    int fd ;
  1719. X{
  1720. X    char *line ;
  1721. X    int output_string = FALSE ;
  1722. X
  1723. X    skip_to_first_page( fd ) ;
  1724. X
  1725. X    while ( line = Srdline( fd ) )
  1726. X    {
  1727. X        char *p ;
  1728. X
  1729. X        if ( line[0] == '%' )
  1730. X            continue ;
  1731. X
  1732. X        for ( p = line ; *p ; )
  1733. X        {
  1734. X            if ( *p == OPEN_PAREN )
  1735. X            {
  1736. X                p++ ;
  1737. X                decode_string( get_line_char, (void *)&p ) ;
  1738. X                output_string = TRUE ;
  1739. X            }
  1740. X            else if ( isdigit( *p ) )
  1741. X            {
  1742. X                while ( isdigit( *p ) ) p++ ;
  1743. X                if ( isspace( *p ) )
  1744. X                {
  1745. X                    while ( isspace( *p ) ) p++ ;
  1746. X                    if ( isdigit( *p ) )
  1747. X                    {
  1748. X                        while ( isdigit( *p ) ) p++ ;
  1749. X                        if ( output_string )
  1750. X                        {
  1751. X                            printout( NEWLINE ) ;
  1752. X                            output_string = FALSE ;
  1753. X                        }
  1754. X                    }
  1755. X                }
  1756. X            }
  1757. X            else
  1758. X                p++ ;
  1759. X        }
  1760. X    }
  1761. X}
  1762. X
  1763. X
  1764. END_OF_FILE
  1765.   if test 2838 -ne `wc -c <'pst/dit.c'`; then
  1766.     echo shar: \"'pst/dit.c'\" unpacked with wrong size!
  1767.   fi
  1768.   # end of 'pst/dit.c'
  1769. fi
  1770. if test -f 'pst/options.c' -a "${1}" != "-c" ; then 
  1771.   echo shar: Will not clobber existing file \"'pst/options.c'\"
  1772. else
  1773.   echo shar: Extracting \"'pst/options.c'\" \(1354 characters\)
  1774.   sed "s/^X//" >'pst/options.c' <<'END_OF_FILE'
  1775. X/*
  1776. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  1777. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1778. X * and conditions for redistribution.
  1779. X */
  1780. X
  1781. X#include "options.h"
  1782. X
  1783. X/*
  1784. X * $Id: options.opt,v 1.4 1993/11/14 05:24:11 panos Exp $
  1785. X */
  1786. X
  1787. X#define NULL         0
  1788. X
  1789. Xvoid exit() ;
  1790. X
  1791. Xint l_option ;
  1792. Xint v_option ;
  1793. Xint n_option ;
  1794. Xint d_option ;
  1795. Xint a_option ;
  1796. Xchar * a_option_arg_1 ;
  1797. X
  1798. Xchar *program_name ;
  1799. X
  1800. Xint opt_recognize( argc, argv )
  1801. X    int argc ;
  1802. X    char *argv[] ;
  1803. X{
  1804. X    int arg ;
  1805. X    char *strrchr() ;
  1806. X
  1807. X    program_name = strrchr( argv[ 0 ], '/' ) ;
  1808. X    program_name = ( program_name == NULL ) ? argv[ 0 ] : program_name + 1 ;
  1809. X
  1810. X    for ( arg = 1 ; arg < argc ; arg++ )
  1811. X        if ( argv[ arg ][ 0 ] == '-' && argv[ arg ][ 1 ] != 0 )
  1812. X        {
  1813. X            if ( strcmp( &argv[ arg ][ 1 ], "l" ) == 0 ) 
  1814. X                l_option = 1 ;
  1815. X            else if ( strcmp( &argv[ arg ][ 1 ], "v" ) == 0 ) 
  1816. X                v_option = 1 ;
  1817. X            else if ( strcmp( &argv[ arg ][ 1 ], "n" ) == 0 ) 
  1818. X                n_option = 1 ;
  1819. X            else if ( strcmp( &argv[ arg ][ 1 ], "d" ) == 0 ) 
  1820. X                d_option = 1 ;
  1821. X            else if ( strcmp( &argv[ arg ][ 1 ], "a" ) == 0 ) 
  1822. X            {
  1823. X                if ( ++arg == argc )
  1824. X                    usage() ;
  1825. X                a_option_arg_1 = ( argv[ arg ] ) ;
  1826. X                a_option = 1 ;
  1827. X            }
  1828. X            else
  1829. X                usage() ;
  1830. X        }
  1831. X        else
  1832. X            break ;
  1833. X
  1834. X
  1835. X    return( arg ) ;
  1836. X}
  1837. X
  1838. Xvoid usage()
  1839. X{
  1840. X    Sprint( 2, "Usage: %s [-l] [-v] [-n] [-d] [-a algorithm] file\n", program_name ) ;
  1841. X    exit( 1 ) ;
  1842. X}
  1843. END_OF_FILE
  1844.   if test 1354 -ne `wc -c <'pst/options.c'`; then
  1845.     echo shar: \"'pst/options.c'\" unpacked with wrong size!
  1846.   fi
  1847.   # end of 'pst/options.c'
  1848. fi
  1849. if test -f 'pst/pst.man' -a "${1}" != "-c" ; then 
  1850.   echo shar: Will not clobber existing file \"'pst/pst.man'\"
  1851. else
  1852.   echo shar: Extracting \"'pst/pst.man'\" \(1560 characters\)
  1853.   sed "s/^X//" >'pst/pst.man' <<'END_OF_FILE'
  1854. X.\"(c) Copyright 1993 by Panagiotis Tsirigotis
  1855. X.\"All rights reserved.  The file named COPYRIGHT specifies the terms 
  1856. X.\"and conditions for redistribution.
  1857. X.\"
  1858. X.\" $Id: pst.man,v 1.4 1993/11/14 05:24:41 panos Exp $
  1859. X.TH PST 1L "4 February 1993"
  1860. X.SH NAME
  1861. Xpst \- extract the text of a postscript file
  1862. X.SH SYNOPSIS
  1863. X.B pst
  1864. X[\fB-l\fP]
  1865. X[\fB-v\fP]
  1866. X[\fB-d\fP]
  1867. X[\fB-n\fP]
  1868. X[\fB-a algorithm\fP]
  1869. X.IR "file"
  1870. X.SH DESCRIPTION
  1871. XThis program extracts the text contained in the specified postscript
  1872. X.I file.
  1873. XSuch files are typically produced by other programs.
  1874. X.I pst
  1875. Xneeds to identify how the file was produced in order to successfully
  1876. Xextract the text from it.
  1877. XIt currently understands files generated by the following programs:
  1878. X.RS
  1879. X.IP dvips
  1880. X.IP "ditroff through psdit"
  1881. X.IP WordPerfect
  1882. X.IP idraw
  1883. X.RE
  1884. X.LP
  1885. XIf
  1886. X.I file
  1887. Xis missing, the standard input is used.
  1888. X.SH OPTIONS
  1889. X.TP 12
  1890. X.SB "-v"
  1891. XPrint to standard error how the postscript file was derived
  1892. X.TP
  1893. X.SB "-n"
  1894. XDo nothing
  1895. X.TP
  1896. X.SB "-d"
  1897. XEnable debugging. Currently this option has no effect.
  1898. X.TP
  1899. X.SB "-a algorithm"
  1900. XThis option directs
  1901. X.I pst 
  1902. Xto use the specified
  1903. X.I algorithm
  1904. Xto parse the file.
  1905. XAvailable algorithms include:
  1906. X.RS
  1907. X.RS
  1908. X.TP 10
  1909. X.SB dvi
  1910. X.TP
  1911. X.SB psdit
  1912. Xditroff through psdit
  1913. X.TP
  1914. X.SB dit
  1915. Xditroff
  1916. X.TP
  1917. X.SB troff
  1918. X.TP
  1919. X.SB wp
  1920. Xwordperfect
  1921. X.RE
  1922. X.RE
  1923. X.TP
  1924. X.SB "-l"
  1925. XLists the name of available algorithms (those are the names that can be used
  1926. Xas arguments to the
  1927. X.I "-a"
  1928. Xoption).
  1929. X.SH AUTHOR
  1930. XPanos Tsirigotis, CS dept, University of Colorado, Boulder
  1931. X.SH BUGS
  1932. X.I pst
  1933. Xwill extract nothing if it can't determine how the file was generated.
  1934. END_OF_FILE
  1935.   if test 1560 -ne `wc -c <'pst/pst.man'`; then
  1936.     echo shar: \"'pst/pst.man'\" unpacked with wrong size!
  1937.   fi
  1938.   # end of 'pst/pst.man'
  1939. fi
  1940. if test -f 'pst/wp.c' -a "${1}" != "-c" ; then 
  1941.   echo shar: Will not clobber existing file \"'pst/wp.c'\"
  1942. else
  1943.   echo shar: Extracting \"'pst/wp.c'\" \(1076 characters\)
  1944.   sed "s/^X//" >'pst/wp.c' <<'END_OF_FILE'
  1945. X/*
  1946. X * (c) Copyright 1993 by Panagiotis Tsirigotis
  1947. X * All rights reserved.  The file named COPYRIGHT specifies the terms 
  1948. X * and conditions for redistribution.
  1949. X */
  1950. X
  1951. Xstatic char RCSid[] = "$Id: wp.c,v 1.2 1993/02/07 02:02:27 panos Exp $" ;
  1952. X
  1953. X#include "sio.h"
  1954. X
  1955. X#include "defs.h"
  1956. X
  1957. Xvoid wordperfect_process( fd )
  1958. X    int fd ;
  1959. X{
  1960. X    char *line ;
  1961. X    int output_string = FALSE ;
  1962. X    void decode_string() ;
  1963. X    int get_line_char() ;
  1964. X
  1965. X    while ( line = Srdline( fd ) )
  1966. X    {
  1967. X        char *p ;
  1968. X
  1969. X        if ( line[0] == '%' )
  1970. X            continue ;
  1971. X
  1972. X        for ( p = line ; *p ; )
  1973. X        {
  1974. X            if ( *p == OPEN_PAREN )
  1975. X            {
  1976. X                if ( p > line && p[-1] == CARRIAGE_RETURN )
  1977. X                    printout( SPACE ) ;
  1978. X                p++ ;
  1979. X                decode_string( get_line_char, (void *)&p ) ;
  1980. X                output_string = TRUE ;
  1981. X            }
  1982. X            else if ( isdigit( *p ) )
  1983. X            {
  1984. X                while ( isdigit( *p ) ) p++ ;
  1985. X                if ( isspace( *p ) )
  1986. X                {
  1987. X                    while ( isspace( *p ) ) p++ ;
  1988. X                    if ( isdigit( *p ) )
  1989. X                    {
  1990. X                        while ( isdigit( *p ) ) p++ ;
  1991. X                        if ( output_string )
  1992. X                        {
  1993. X                            printout( NEWLINE ) ;
  1994. X                            output_string = FALSE ;
  1995. X                        }
  1996. X                    }
  1997. X                }
  1998. X            }
  1999. X            else
  2000. X                p++ ;
  2001. X        }
  2002. X    }
  2003. X}
  2004. X
  2005. X
  2006. END_OF_FILE
  2007.   if test 1076 -ne `wc -c <'pst/wp.c'`; then
  2008.     echo shar: \"'pst/wp.c'\" unpacked with wrong size!
  2009.   fi
  2010.   # end of 'pst/wp.c'
  2011. fi
  2012. echo shar: End of archive 5 \(of 6\).
  2013. cp /dev/null ark5isdone
  2014. MISSING=""
  2015. for I in 1 2 3 4 5 6 ; do
  2016.     if test ! -f ark${I}isdone ; then
  2017.     MISSING="${MISSING} ${I}"
  2018.     fi
  2019. done
  2020. if test "${MISSING}" = "" ; then
  2021.     echo You have unpacked all 6 archives.
  2022.     rm -f ark[1-9]isdone
  2023. else
  2024.     echo You still must unpack the following archives:
  2025.     echo "        " ${MISSING}
  2026. fi
  2027. exit 0
  2028. exit 0 # Just in case...
  2029.