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

  1. From: lee@sq.sq.com (Liam R. E. Quin)
  2. Newsgroups: alt.sources
  3. Subject: lq-text Full Text Retrieval Database Part 01/13
  4. Message-ID: <1991Mar4.020026.16059@sq.sq.com>
  5. Date: 4 Mar 91 02:00:26 GMT
  6.  
  7. : cut here --- cut here --
  8. : To unbundle, sh this file
  9. #! /bin/sh
  10. # make the directory structure:
  11. test -d lq-text || mkdir lq-text
  12. test -d lq-text/doc || mkdir lq-text/doc
  13. test -d lq-text/Sample || mkdir lq-text/Sample
  14. test -d lq-text/src || mkdir lq-text/src
  15. test -d lq-text/src/filters || mkdir lq-text/src/filters
  16. test -d lq-text/src/h || mkdir lq-text/src/h
  17. test -d lq-text/src/liblqtext || mkdir lq-text/src/liblqtext
  18. test -d lq-text/src/lqtext || mkdir lq-text/src/lqtext
  19. test -d lq-text/src/menu || mkdir lq-text/src/menu
  20. test -d lq-text/src/test || mkdir lq-text/src/test
  21. test -d lq-text/src/ozmahash || mkdir lq-text/src/ozmahash
  22.  
  23. echo x - lq-text/README 1>&2
  24. sed 's/^X//' >lq-text/README <<'@@@End of lq-text/README'
  25. XLiam Quin's text retrieval package (lq-text) Sun Mar  3 17:18:26 EST 1991
  26. Xsrc/h/Revision.h defines this as Revision 1.10.
  27. X
  28. Xlq-text is copyright 1990, 1991 Liam R. E. Quin; see src/COPYRIGHT for details.
  29. X
  30. X
  31. XWhat It Does:
  32. X    Lets you search for phrases in text that you previously indexed.
  33. X    The necessary indexing program (lqaddfile) is enclosed.  Indexes are
  34. X    usually less than the size of the data, and sometimes half that.
  35. X    There is a browser (lqtext) for System V, and a shell script (lq) for
  36. X    any Unix system.  There is also a program (lqkwik) that turns the
  37. X    output of lqphrase or "lqword -l" into a keyword in context-style list.
  38. X
  39. XHow to Install It
  40. X    unpack this tar
  41. X    cd lq-text/src
  42. X    edit h/globals.h (following the instructions in there.  Use ozmahash)
  43. X    edit Makefile
  44. X    make depend # If you have mkdep.  If you don't, and you can't get it
  45. X        # -- e.g. from the tahoe BSD distribution -- you'll have
  46. X        # to edit all of the makefiles to delete everything
  47. X        # below the DO NOT DELETE pair of lines (leave the ones
  48. X        # that say "DO NOT DELETE", though).
  49. X    make all # this will put things in src/bin and src/lib
  50. X    make install # This will put things in $BINDIR and $LIBDIR.
  51. X
  52. X    You might want to try
  53. X    make local   # This will put stripped executables in src/bin and src/lib;
  54. X         # I find this convenient for testing.
  55. X    before doing a make install.
  56. X
  57. X    See below for possible problems.
  58. X
  59. X
  60. XHow to Use It
  61. X    (see doc/*)
  62. X    Make a directory $HOME/LQTEXTDIR (or set $LQTEXTDIR to point to the
  63. X    (currently empty) directory  you want to put there.
  64. X    Make lq-text/src/bin and lq-text/src/lib be in your path
  65. X    Put a README file in $LQTEXTDIR:
  66. X    docpath /my/login/directory:/or/somewhere/else
  67. X    common Common
  68. X    and make an empty file called Common (or include words like "uucp"
  69. X    that you don't want indexed) in the same directory.
  70. X    Find some files (e.g. your mailbox) and say
  71. X    lqaddfile -t2 file [...]
  72. X    You should see some diagnostic output... (this is what -t2 does).
  73. X    lqaddfile may take several minutes to write out its data, depending
  74. X    on the system.  Try a small file first -- you can add more later!
  75. X    Another fun thing to try is setting DOCPATH to /usr/man and running
  76. X    cd /usr/man
  77. X    find man* -type f -print | lqaddfile -t2 -f -
  78. X    to make an index of the manual pages (use cat* instead of man* if you
  79. X    prefer).  If you have less than 10 meg or so of RAM, give lqaddfile the
  80. X    -w100000 option -- this is the number of words to keep in memory before
  81. X    writing to the database.  The idea is that the number should be small
  82. X    enough to prevent frantic paging activity!
  83. X
  84. X
  85. X    Now try
  86. X    lqword        ---> an unsorted list of all known words
  87. X    lq        ---> type phrases and browse through them
  88. X    lqtext        ---> curses-based browser, if it compiled.
  89. X
  90. X    lqshow `lqphrase "floppy disk"`   ---> lq does this for you
  91. X    lqkwik `lqphrase "floppy disk"`   ---> this is the most fun.
  92. X
  93. X
  94. X    If the files you are indexing have pathnmames with leading bits in
  95. X    common (e.g. indexing a directory such as  /usr/spool/news, or
  96. X    /home/lee/text/humour), make use of DOCPATH.  This is searched
  97. X    linearly, so a dozen or so entries is the practical limit at the
  98. X    moment.
  99. X
  100. X    Every indexed pathname must fit into a dbm page, which is 4KBytes
  101. X    with sdbm but probably much less (e.g. 512) with dbm.  With ozmahash
  102. X    this problem has gone away.
  103. X
  104. X
  105. XKnown Problems
  106. X    lqaddfile runs extraordinarily slowly if the database directory is
  107. X    mounted over a network with NFS.  Run lqaddfile on the NFS server --
  108. X    there's no problem with having the data files on a remote system.
  109. X
  110. X    With this distribution I am including both Ozan Yigit's sdbm package
  111. X    and the BSD hash package written by Ozan Yigit and Margo Seltzer.  The
  112. X    latter is called "ozmahash" here, to avoid confusion with System V hash.
  113. X    Try using ozmahash first, and if that doesn't work use sdbm.  The hash
  114. X    package seems to work on all the systems here, but it might not do so
  115. X    well on system V.  Sdbm has been ported extensively, but is slower.
  116. X
  117. X    If you end up with one or more empty .dir or .pag files in the
  118. X    LQTEXTDIR directory, you probably have a broken sdbm/ndbm/dbm.  Try
  119. X    recompiling with a different dbm package if possible.  In particular,
  120. X    early versions of sdbm had this problem.
  121. X
  122. X    There are some tests, but it is not always
  123. X    clear how to run them.  I intend to make a little test suite...
  124. X    If you get strange error messages, try
  125. X    testbin/dbmtry 5000
  126. X    (this will make and leave behind either one or two files in /tmp).
  127. X    Then try testbin/dbmtry 10000.  If that gives errors, the most likely
  128. X    problem is that you have a faulty bcopy.  I have included a version
  129. X    of bcopy() that is linked in by default -- perhaps you aren't using
  130. X    it?  Do _not_ use memcpy(), as it doesn't handle overlapping regions
  131. X    correctly.
  132. X
  133. X    If -lmalloc fails, simply remove it in Makefile.
  134. X    If you don't have <malloc.h>, you can make an empty file called
  135. X    h/malloc.h (ugh).  I ship a Makefile with -lmalloc because it's such a
  136. X    big win when it is available, and I wouldn't want anyone to forget it!
  137. X
  138. X    On a sun, gcc might have some strange problems with libraries.  If so,
  139. X    use cc.  Sorry.
  140. X    You can use -O on all systems I've tried, and -O4 seems OK on the Sun --
  141. X    at any rate I have done this on my Sun 4/110 under SunOS 4.0.3 here.
  142. X
  143. X    In ancient history, I used gcc -Wall under 386/ix.  I still port
  144. X    lq-text to 386/ix (2.0.2 most recently, October 1990), but can no
  145. X    longer use gcc there because of disk space, so I don't know if gcc
  146. X    will produce messages.  Versions of Unix predating the Norman Conquest
  147. X    may cause problems too.
  148. X
  149. X    For serious debugging, I have included "saber.project", so Saber-C
  150. X    users can get started quickly.  If you are debugging without Saber-C,
  151. X    the first thing to do is to buy it.  It's worth it...
  152. X
  153. X
  154. X    Otherwise, compile with -DASCIITRACE.  You could also use
  155. X    -DMALLOCTRACE, which makes the malloc() routines print messages to
  156. X    stderr, which can be processed with awk -- see test/malloctrace.
  157. X
  158. X
  159. X    Oh, and the common word list is searched linearly, so it is worth
  160. X    keeping it fairly short.  Usually about a dozen words is plenty.
  161. X
  162. X
  163. XLee
  164. X
  165. Xlee@sq.com
  166. Xlee%sq.com@cs.toronto.edu
  167. X{uunet,utzoo,cs.toronto.edu}!sq!lee
  168. @@@End of lq-text/README
  169. echo x - lq-text/doc/lqtext.1 1>&2
  170. sed 's/^X//' >lq-text/doc/lqtext.1 <<'@@@End of lq-text/doc/lqtext.1'
  171. X.\" use sqtbl % | troff -man
  172. X.de r2
  173. X.RS
  174. X.RS
  175. X..
  176. X.de re
  177. X.RE
  178. X.RE
  179. X..
  180. X.TH LQ-TEXT 1 "\(co copyright Liam Quin 1989, 1990"
  181. X.SH NAME
  182. Xlqtext, lqword, lqphrase, lqaddfile, lqfile, lqkwik, lqshow, lq \- text retrieval package
  183. X.SH SYNOPSIS
  184. X.B lqtext
  185. X[
  186. X.B \-vVx
  187. X] [
  188. X.BI \-c cfile
  189. X] [
  190. X.BI \-d dir
  191. X] [
  192. X.BI \-m c
  193. X]
  194. X.br
  195. X.B lqword
  196. X[
  197. X.B \-aAlsvVx
  198. X] [
  199. X.BI \-c cfile
  200. X] [
  201. X.BI \-d dir
  202. X] [
  203. X.BI \-m c
  204. X] [
  205. X.BI \-t n
  206. X]
  207. X.I word
  208. X\&.\|.\|.
  209. X.br
  210. X.B lqphrase
  211. X[
  212. X.B \-lsvVx
  213. X] [
  214. X.BI \-c cfile
  215. X] [
  216. X.BI \-d dir
  217. X] [
  218. X.BI \-t n
  219. X] [
  220. X.BI \-m c
  221. X]
  222. X.I phrase
  223. X\&.\|.\|.
  224. X.br
  225. X.B lqaddfile
  226. X[
  227. X.BI \-xvV
  228. X] [
  229. X.BI \-d dir
  230. X] [
  231. X.BI \-c cfile
  232. X] [
  233. X.BI \-t n
  234. X]
  235. X.I file
  236. X\&.\|.\|.
  237. X.br
  238. X.B lqfile
  239. X[
  240. X.BI \-aAxvV
  241. X] [
  242. X.I file
  243. X]
  244. X\&.\|.\|.
  245. X.br
  246. X.B lqshow
  247. X.I match
  248. X\&.\|.\|.
  249. X.br
  250. X.B lq
  251. X.SH DESCRIPTION
  252. X.I lq-text
  253. Xis a text retrieval database.
  254. XYou can retrieve files based on words (with
  255. X.IR lqword )
  256. Xor phrases (with
  257. X.IR lqphrase ).
  258. X.I Lq-text
  259. Xkeeps a database containing all of the known words and listing the
  260. Xfiles in which they are found.
  261. XThis database is typically between half and three-quarters of the total
  262. Xsize of the actual data, and enables searching to be rapid.
  263. XFiles can be added to the database at any time (with
  264. X.IR lqaddfile ).
  265. X.PP
  266. XThe retrieval programs will give you the names of files containing the
  267. Xwords about which you enquired, but will not show the actual text.
  268. XThis means that you can archive or remove files, and
  269. X.I lq-text
  270. Xcan still find them.
  271. X.I lqshow
  272. Xwill display the matches directly.
  273. XIf it is installed on your system,
  274. X.I lqtext
  275. Xprogram provides an interactive front end.  (This program is generally
  276. Xonly available under System V Release 3.2 or later at the time of writing).
  277. XIf not, there is a shell-script called
  278. X.I lq
  279. Xwhich is rather slower but which provides much of the same functionality.
  280. X.I Lqkwik
  281. Xtakes a list of matches as produced by
  282. X.I lqword
  283. Xor
  284. X.I lqphrase
  285. Xand prints a few words either side of each match, formatted so that the
  286. Xmatched phrases are all in the same column.
  287. XThere are options to alter the sizes of the various columns.
  288. XSince
  289. X.I lqkwik
  290. Xis new and experimentatl it is not yet otherwise documented here.
  291. X.SH "OPTIONS (all programs)"
  292. X.TP
  293. X.BI \-m c
  294. XSet the matching level.  If
  295. X.I c
  296. Xis
  297. X.BR p ,
  298. Xprecise matching is used;
  299. X.B \-mh
  300. Xinvokes heuristic matching, and
  301. X.B \-ma
  302. Xallows approximate matching.
  303. XSee below for more explanation of word and phrase matching.
  304. X.TP
  305. X.BI \-t n
  306. XSet the trace-level to
  307. X.IR n .
  308. XThis is mainly used for debugging.
  309. XThe default trace level is zero, giving no debugging trace at all.
  310. X.TP
  311. X.B \-v
  312. Xverbose mode \- this is exactly the same as using
  313. X.BR \-t1 .
  314. X.TP
  315. X.B \-V
  316. Xprint version information.
  317. X.TP
  318. X.B \-x
  319. XPrint an explanation of options.  This is the single most important
  320. Xoption to remember (and arguably the
  321. X.I only
  322. Xone worth remembering!), as the programs may get updated more
  323. Xoften than the documentation.
  324. X.br
  325. XThe
  326. X.B \-x
  327. Xand
  328. X.B \-v
  329. Xoptions can be combined, so that
  330. X.B \-xv
  331. Xgives a slightly longer explanation.
  332. X.TP
  333. X.BI \-d dir
  334. XLook in the named directory
  335. Xfor the database files.
  336. XIf this is not given, the environment variable
  337. X.SM LQTEXTDIR
  338. Xis inspected, and either this or a built-in default is used.
  339. X.TP
  340. X.BI \-c file
  341. XThe named file should contain a list of words that will not
  342. Xbe included in the index.  A good starting point might
  343. Xbe
  344. X.I /usr/lib/eign
  345. Xif your system has it.  If not, see the
  346. X.I FindCommon
  347. Xscript for a way to generate one.
  348. XIf this option is not given, the programs search for the file named
  349. Xin the
  350. X.SM LQCOMMON
  351. Xenvironment variable, and then look in the file
  352. X.SM README
  353. Xin the
  354. X.I lq-text
  355. Xdatabase directory for a line of the form
  356. X.br \" is this .br needed?
  357. X.r2
  358. X.B common
  359. X.I " filename"
  360. X.re
  361. X.br\" and this one too?
  362. Xbefore the first
  363. X.I end
  364. Xkeyword.
  365. X.SH "LQADDFILE OPTIONS"
  366. X.TP
  367. X.BI \-w n
  368. XNormally
  369. X.I lqaddfile
  370. Xkeeps a cache of the words it has seen, and writes them out only
  371. Xoccasionally.  The less often the cache is written, the faster the
  372. Xprogram will run.  On the other hand, as soon as
  373. X.I lqaddfle
  374. Xgrows large enough to fill all of available physical memory, it starts
  375. Xto run very, very slpwly and to impose a noticeable system overhead.
  376. X.PP
  377. XThe total number of words in the cache determines (approximetely) the
  378. Xtotal size of
  379. X.I lqtext
  380. Xwhen it runs.  Allow about twenty bytes per word.
  381. XValues of from 30,000 to 100,000 appear suitable for machines with from
  382. Xfour to twelve megabytes of memory, as a rough guide.
  383. X.TP
  384. X.BI \-f \^file
  385. XThe list of files to index is read from the named
  386. X.IR file .
  387. XIf this file is `\-', standard input is read.
  388. X.SH "LQFILE OPTIONS"
  389. X.TP
  390. X.B \-a
  391. Xproduces a list of all files in the database
  392. X.TP
  393. X.B \-A
  394. Xtreats each of the remaining arguments as files to add to the file list.
  395. XNo indexing is done, so the main effect of this is that the named files
  396. Xwill not be added to the database until they have changed.
  397. X.SH "LQSHOW OPTIONS"
  398. X.TP
  399. X.BI \-a above
  400. XDisplay
  401. X.I above
  402. Xlines of text above each match.
  403. XThe default is to display up to six lines preceding each match from each file.
  404. X.TP
  405. X.BI \-b below
  406. XDisplay
  407. X.I below
  408. Xlines of text following each match.
  409. XThe default is to display an extra six lines.
  410. XIf there are too many lines to fit on the screen, they will wrap around
  411. Xto the top of the screen.
  412. XThe default is to display six lines of text after the line containing
  413. Xthe first matched keyword in a phrase.
  414. X.TP
  415. X.BI \-f \^file
  416. XThe named
  417. X.I file
  418. Xis assumed to contain a list of matches in the form produced
  419. Xby
  420. X.I lqtext
  421. X.IR \-l ,
  422. Xand allows browsing of a much longer list of matches than the form given below.
  423. X.PP
  424. XRemaining arguments are taken to be matches.
  425. XThese are groups of three strings:
  426. Xa number representing the block in the file, another representing the
  427. Xword in the block, and finally a file name (or path).
  428. XFiles will be found if they are absolute (starting with a /), or if they
  429. Xare in a directory which is specified in
  430. Xthe
  431. X.SM DOCPATH
  432. Xenvironment variable, as described under `environment' below.
  433. X.PP
  434. XThere are also some (deliberately) undocumented options used by the
  435. X.I lq
  436. Xshell script.
  437. X.SH "LQWORD OPTIONS"
  438. XWith no options at all,
  439. X.I lqword
  440. Xwill list all of the words in the database, one per line.
  441. XIf it is given the
  442. X.B \-a
  443. Xflag, it will print statistics about each word as well as the word itself.
  444. XIf given the
  445. X.B \-a
  446. Xoption, it will print out the pathname, block and word-in-block of every
  447. Xoccurrence of every word in the database.
  448. XThis can take some time (from one to two minutes per megabyte of database
  449. Xon a typical 386/ix system, for example).
  450. X.PP
  451. XOther options are
  452. X.TP
  453. X.B \-l
  454. Xlist format \- list matches without attempting to format them for human
  455. Xreadability.  This allows one to use
  456. X.r2
  457. Xlqshow  \`lqword  \-l  word1  word2 ...\`
  458. X.re
  459. Xto view files immediately.
  460. X.PP
  461. XOther options to
  462. X.I lqword
  463. Xare:
  464. X.TP
  465. X.BI \-d word
  466. Xdelete mode \- delete the given
  467. X.I word
  468. Xfrom the database.
  469. XThis should be used with caution, and will be removed to the
  470. Xnew (and unreleased)
  471. X.I lqadmin
  472. Xcommand in the next release.
  473. X.TP
  474. X.B \-s
  475. Xsilent mode.
  476. XIn this mode,
  477. X.I lqword
  478. Xdoes not produce any output, but the exit status is zero if at least
  479. Xone of the given words was found, and one otherwise.
  480. XIf no words are given in this mode,
  481. X.I lqword
  482. Xwill exit with non-zero status.
  483. X.SH MATCHING
  484. XThe
  485. X.I "matching level"
  486. Xwas mentioned briefly under
  487. X.SM OPTIONS
  488. Xabove.
  489. XThe following table summarises the differences between the three available
  490. Xlevels.
  491. X.br
  492. X.\" the .ne lines are for broken versions of tbl...
  493. X.TS
  494. Xallbox doublebox;
  495. XlB lB lB
  496. Xl l l.
  497. X\-m Option    Meaning    Description
  498. X=
  499. X.ne 4
  500. X\-m\^p    Precise    T{
  501. X.ll 3i
  502. XPhrases in the data must have the same
  503. XCapitalisation as you type, and words must be the same distance apart.
  504. X.br
  505. XUse this only if you get too many matches otherwise.
  506. XT}
  507. X.ne 4
  508. X\-m\^h    Heuristic    T{
  509. X.ll 3i
  510. XWords that you give starting with Capital Letters will only match
  511. Xsimilar words in the database; lower case words will match either.
  512. X.br
  513. XPlurals that you give will only match plurals in the data, but
  514. Xa singular word will match either.  For example, if you type `sock',
  515. Xyou will find both `sock' and `socks'.
  516. XT}
  517. X.ne 4
  518. X\-m\^\&a    Any    T{
  519. X.ll 3i
  520. XWith this option, \&\fIlq-text\fP
  521. Xmatching programs will try as hard as possible to match words.
  522. X.br
  523. XPlurals, possessives, case and word separation are all treated loosely.
  524. XT}
  525. X.TE
  526. X.SH EXAMPLES
  527. X.r2
  528. Xlqword martin
  529. X.re
  530. Xfinds all matches of the word `martin' in the default database
  531. X.r2
  532. Xlqphrase -d sources/unix "text retrieval" "word searching"
  533. X.re
  534. Xlooks for the two named phrases.
  535. X.SH ENVIRONMENT
  536. XAll of the programs recognise the environment variables
  537. X.BR LQTEXTDIR ,
  538. X.B  DOCPATH
  539. Xand
  540. X.BR LQCOMMON .
  541. XThe first of these contains the directory in which to look for the
  542. Xdatabase files.  If this is not given, you may find that there is
  543. Xa further default built in to the programs when they were compiled.
  544. XThe
  545. X.B -d
  546. Xoption overrides the
  547. X.SM LQTEXTDIR
  548. Xvariable.
  549. X.br
  550. XThe second,
  551. X.SM DOCPATH ,
  552. Xis a colon-separated list of places to look for files when adding or
  553. Xdisplaying.
  554. XThis is normally set in the file
  555. X.SM README
  556. Xin the database directory.
  557. X.br
  558. XFinally,
  559. X.SM LQCOMMON
  560. Xcan be set to a list of words to ignore when adding or retrieving files.
  561. XAgain, this is usually set in the
  562. X.SM README
  563. Xfile, but you might want to treat certain files differently.
  564. XThe default Common Word List is called `Common', and lives in the
  565. Xdatabase directory.
  566. X.SM LQCOMMON
  567. Xstarts with a `/', it will be taken to be an absolute pathname;
  568. Xotherwise, it is assumed to name a file in the database directory.
  569. X.SH BUGS
  570. XThis is a beta (test) release.
  571. XPlease don't hesitate to fix bugs and let me know what you did\^.\^.\^.
  572. X.sp
  573. XThis documentation is at best preliminary.
  574. X.SH AUTHOR
  575. XLiam R. Quin, 1990
  576. X.
  577. X.\" $Log:    lqtext.1,v $
  578. X.\" Revision 1.3  91/03/03  00:23:19  lee
  579. X.\" Mentioned lqkwik
  580. X.\" 
  581. X.\" Revision 1.2  90/10/06  02:32:22  lee
  582. X.\" Prepared for first beta release.
  583. X.\" 
  584. X.\" Revision 1.1  90/10/04  17:38:34  lee
  585. X.\" Initial revision
  586. X.\" 
  587. X.\"
  588. @@@End of lq-text/doc/lqtext.1
  589. echo x - lq-text/Sample/CommonWords 1>&2
  590. sed 's/^X//' >lq-text/Sample/CommonWords <<'@@@End of lq-text/Sample/CommonWords'
  591. X# lq-text common word stop-list
  592. X
  593. X# Keep this list short -- at most 50 words --  or you will pay a penalty
  594. X# in performance when you add documents to the index -- the list is
  595. X# searched linearly (but is kept sorted internally, so it's OK to have
  596. X# duplicated in here). 
  597. X
  598. X# First index some text with everything commented out, and then use
  599. X# FindCommon to determine which are very common words.  You don't gain
  600. X# all that much space by deleting them, so I don't usually bother.
  601. X
  602. X# the    # 27880 <-- number of times this word appeared in a sample run
  603. X# and    # 23857 <-- on part (or all? I forget) of the King James Bible..
  604. X# that    # 4705
  605. X# for    # 3011
  606. @@@End of lq-text/Sample/CommonWords
  607. echo x - lq-text/Sample/README 1>&2
  608. sed 's/^X//' >lq-text/Sample/README <<'@@@End of lq-text/Sample/README'
  609. X# This file is read (up to "end") by all lq-text programs.
  610. X
  611. Xcommon CommonWords
  612. X
  613. X# where to find documents:
  614. Xdocpath /usr/spool/news:/home/lee/text:
  615. X
  616. Xend
  617. X# end of machine-readable configuration (the computer reads no further! --
  618. X# this is an optimisation for start-up speed...!)
  619. X
  620. X# Common common-file
  621. X#     --- giving the name of a file of common words
  622. X# Docpath "path" (the quotes are optional)
  623. X#    --- giving a list of places to look for files, separated by ":"
  624. X#        Useful tip: avoid putting :: or "." in DOCPATH, as you'll
  625. X#        then get files that might or might not be found, depending
  626. X#        on where you happen to be.  $HOME is NOT understood in here.
  627. X#
  628. X#        Docpath can be replaced by the environment variable $DOCPATH.
  629. X#
  630. X# I'll be adding other keywords soon...  and I am open to suggestions!
  631. X# Lee
  632. X# Liam R. E. Quin    lee@sq.com
  633. X
  634. X/*
  635. X * LQ-TEXT Copyright 1990 Liam Russell Eric Quin.  All rights reserved.
  636. X * Written by Liam Quin.
  637. X *
  638. X * This software is not subject to any license of the American Telephone
  639. X * and Telegraph Company or of the Regents of the University of California,
  640. X * or of the X Consortium, or of the Free Software Foundation.
  641. X *
  642. X * Permission is granted to anyone to use this software for any purpose on
  643. X * any computer system, and to alter it and redistribute it freely, subject
  644. X * to the following restrictions:
  645. X *
  646. X * 1. The author is not responsible for the consequences of use of this
  647. X *    software, no matter how awful, even if they arise from flaws in it.
  648. X *
  649. X * 2. The origin of this software must not be misrepresented, either by
  650. X *    explicit claim or by omission.  Since few users ever read sources,
  651. X *    credits must appear in the documentation.
  652. X *
  653. X * 3. Altered versions must be plainly marked as such, and must not be
  654. X *    misrepresented as being the original software.  Since few users
  655. X *    ever read sources, credits must appear in the documentation.
  656. X *
  657. X * 4. Permission must be obtained for any commercial use of this software
  658. X *    which involves resale of all or part of the software, whether
  659. X *    modified or not.
  660. X *
  661. X * 5. This notice may not be removed or altered.
  662. X *
  663. X */
  664. X
  665. X/*
  666. X * Acknowledgements to Henry Spencer for permission to modify and use his
  667. X * and Geoff Collyer's C News copyright notice.
  668. X *
  669. X */
  670. X
  671. X
  672. @@@End of lq-text/Sample/README
  673. echo x - lq-text/src/COPYRIGHT 1>&2
  674. sed 's/^X//' >lq-text/src/COPYRIGHT <<'@@@End of lq-text/src/COPYRIGHT'
  675. X/*
  676. X * Copyright 1989 Liam Russell Eric Quin.  All rights reserved.
  677. X * Written by Liam Quin.
  678. X *
  679. X * This software is not subject to any license of the American Telephone
  680. X * and Telegraph Company or of the Regents of the University of California,
  681. X * or of the X Consortium, or of the Free Software Foundation.
  682. X *
  683. X * Permission is granted to anyone to use this software for any purpose on
  684. X * any computer system, and to alter it and redistribute it freely, subject
  685. X * to the following restrictions:
  686. X *
  687. X * 1. The author is not responsible for the consequences of use of this
  688. X *    software, no matter how awful, even if they arise from flaws in it.
  689. X *
  690. X * 2. The origin of this software must not be misrepresented, either by
  691. X *    explicit claim or by omission.  Since few users ever read sources,
  692. X *    credits must appear in the documentation.
  693. X *
  694. X * 3. Altered versions must be plainly marked as such, and must not be
  695. X *    misrepresented as being the original software.  Since few users
  696. X *    ever read sources, credits must appear in the documentation.
  697. X *
  698. X * 4. Permission must be obtained for any commercial use of this software
  699. X *    which involves resale of all or part of the software, whether
  700. X *    modified or not.
  701. X *
  702. X * 5. This notice may not be removed or altered.
  703. X *
  704. X */
  705. X
  706. X/*
  707. X * Acknowledgements to Henry Spencer for permission to modify and use his
  708. X * and Geoff Collyer's C News copyright notice.
  709. X *
  710. X */
  711. X
  712. X
  713. @@@End of lq-text/src/COPYRIGHT
  714. echo x - lq-text/src/Makefile 1>&2
  715. sed 's/^X//' >lq-text/src/Makefile <<'@@@End of lq-text/src/Makefile'
  716. X# Makefile for LQ-Text, a full text retrieval package by Liam R. Quin
  717. X#
  718. X# $Id: Makefile,v 1.13 91/03/02 20:23:02 lee Exp $
  719. X#
  720. X
  721. X# Do this first for sanity...:
  722. XSHELL=/bin/sh
  723. X
  724. X### Some global configuration options.
  725. X
  726. X# You should also look at h/globals.h for more things to change.
  727. X#
  728. X# DEFS are included in CFLAGS, passed to the C compiler:
  729. X# If ASCIITRACE is defined, you can get extra debugging output using -t99
  730. X# (or some other number), but there is a slight performance penalty for
  731. X# including this, and you'd need to understand the code.
  732. X
  733. X# DEFS:
  734. X# Use either -UBSD -DSYSV or -USYSV -DBSD as appropriate...
  735. X# This affects
  736. X# * the choice of default pager ($PAGER) in globals.h
  737. X# * whether some extra declarations are used to make lint and gcc -Wall
  738. X#   happy about SysV stdio.h
  739. X# It isn't very important... if you have System V stdio and curses, you
  740. X# might as well use -DSYSV -UBSD even on SysV.  Ultrix diffs are included
  741. X# inside #ifdef ultrix; use BSD on Ultrix.
  742. X# Lqtext doesn't do explicit locking or signal handling at the moment.
  743. X# If you are using sdbm (this is what I use) and get messages about L_SET
  744. X# or L_SEEK being undefined, add -DSVID (there are other changes, but
  745. X# this is a useful symptom...)
  746. X#
  747. X# -DMALLCTRACE makes malloc.c produce masses of output...
  748. X#
  749. X# -DCURSESX, if present, says that we have the System V.3.1 or later
  750. X# curses that has A_STANDOUT and in which box(win, 0, 0) draws a neat box
  751. X# with vt100 characters.  If you're not sure, if the string ACS appears
  752. X# in /usr/include/curses.h you should probably use -DCURSESX.
  753. X#
  754. X# DEFS= -DASCIITRACE -UBSD -DSYSV -DMALLOCTRACE -DCURSESX ### for BIG testing
  755. XDEFS= -UASCIITRACE -DBSD -USYSV   ### Try this on BSD-like Unix ...
  756. X# DEFS= -UASCIITRACE -UBSD -DSYSV -DCURSESX -DSVID ### ...and this on Sys V
  757. X
  758. X# Who owns the installed binaries?
  759. XOWNER=lee
  760. X# and what group are they in?
  761. XGROUP=other
  762. X# and where do they go?
  763. XBINDIR=/usr/local/bin
  764. XLIBDIR=/usr/local/lib/lqtext
  765. X# and the file mode for executables?
  766. XMODE=751
  767. X
  768. X# NewsFilter and MailFilter are programs which read news/mail files and
  769. X# turn unwanted words (e.g. Received-By lines inside mail headers) into
  770. X# "qxxxxx", with the right number of x's so that the total byte count is
  771. X# unchanged....
  772. X# Lqshow is the document browser.
  773. XMAILFILTER=$(LIBDIR)/MailFilter
  774. XNEWSFILTER=$(LIBDIR)/NewsFilter
  775. XLQSHOW=$(BINDIR)/lqshow
  776. XLQFILE=$(BINDIR)/lqfile
  777. X
  778. X# If you have -lmalloc, use it...
  779. XMALLOC=-lmalloc # faster version of malloc
  780. X# MALLOC= # BSD Unix doesn't have malloc(3X), only malloc(3)
  781. X
  782. X# Choose between ozmahash, ndbm, sdbm, gdbm or dbm -- if you only have dbm,
  783. X# you'll have some work to do -- see PORTING for gdbm or dbm.
  784. X# The necessary changes are in h/smalldb.h and h/Liamdbm.h if you need them.
  785. X# If you use ozmahash or sdbm you must use the fixed versions -- sdbm was
  786. X# posted to netnews in 1991, and ozmahash is included with this distribution.
  787. X# If you use ozmahash, copy ozmahash/*.h into h.
  788. X
  789. X# WHICHDBM=ndbm
  790. X# DBMLIBS=-lndbm
  791. X# MKDBM= # this is the target if we have to build ndbm...
  792. XWHICHDBM=ozmahash
  793. XDBMLIBS=../lib/libhash.a
  794. XMKDBM=mkozmahash # this is the target if we have to build ndbm...
  795. X
  796. X# On BSD systems you need -ltermcap as well as libcurses for "lqshow".
  797. X# TERMCAP=-lcursesX -ltermcap # ultrix -- cursesx
  798. XTERMCAP=-lcurses -ltermcap
  799. X# TERMCAP=-lcurses
  800. X
  801. X# on SYSV ranlib is usually "echo"
  802. X# RANLIB=echo
  803. XRANLIB=ranlib
  804. X
  805. X# Choose a C compiler -- GNU's gcc if you have it, or the standard cc.
  806. X# GNU cc won't compile lqaddfile.c on some machines, but I don't know why.
  807. X## for gcc:
  808. X#CC=gcc
  809. X#GCCF= -Fwriteable-strings -Wall -I/usr/include
  810. X## for anything else:
  811. XCC=cc
  812. XGCCF=
  813. X##
  814. X# Use -O or -O -g for the optimiser.  Or -ql or -p for profiling (sysV)
  815. X# -O3 (or -O4 if you are feeling brave) is for SunOS
  816. X# With gcc or recent System V compilers, you can use OPT=-O -g
  817. X# NOTE to profilers: do not mix -g with -p -- this is often broken!
  818. XOPT=-O
  819. X
  820. XCFLAGS= $(OPT) $(DEFS) $(GCCF) -D$(WHICHDBM) $$(EXTRA)
  821. X
  822. X# Lint flags vary wildly between systems.
  823. X# LINTFLAGS=-xv
  824. XLINTFLAGS=-a -b -c -h -x 
  825. X
  826. X
  827. X### End of configuration section.  See also PORTING in this directory.
  828. X
  829. XTARGETS=mklib mkbin libs mkfilters mktest mkmenu
  830. XDIRS=mkfilters mkliblqtext mklqtext mktest mkmenu
  831. XMKTARGETS=$(MKDBM) $(DIRS)
  832. X
  833. X# Make all does a local install (in src/bin src/lib src/testbin) too...
  834. Xall: local
  835. X
  836. X.SUFFIXES: .c .o .src .obj
  837. X
  838. X.c.src:
  839. X    #load $(CFLAGS) $<
  840. X
  841. X.o.obj:
  842. X    #load $(CFLAGS) $<
  843. X
  844. Xsaber_src:
  845. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=saber_src $(MKTARGETS)
  846. X
  847. Xsaber_obj:
  848. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=saber_obj $(MKTARGETS)
  849. X
  850. Xlqaddfile.src:
  851. X    #cd lqtext
  852. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' CFLAGS='$(CFLAGS)' CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' lqaddfile.src
  853. X    #cd ..
  854. X
  855. Xtidy:
  856. X    $(MAKE) -i$(MAKEFLAGS) MAKEWHAT=tidy $(MKTARGETS)
  857. X
  858. Xclean:
  859. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=clean $(MKTARGETS)
  860. X    rm -f lib/* bin/* testbin/* core *.o m.log
  861. X
  862. Xdepend:
  863. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=depend $(MKTARGETS)
  864. X
  865. Xlocal: mklib mkbin libs
  866. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=install $(MKTARGETS)
  867. X
  868. Xinstall: libs
  869. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=install $(MKTARGETS)
  870. X    ( cd bin ; for i in *; do \
  871. X        test -f ${BINDIR}/$$i && /bin/mv ${BINDIR}/$$i ${BINDIR}/$$i.old; \
  872. X        /bin/cp $$i ${BINDIR}; \
  873. X        chmod 711 ${BINDIR}/$$i; chgrp ${GROUP} ${BINDIR}/$$i; \
  874. X        chown ${OWNER} ${BINDIR}/$$i;\
  875. X      done; \
  876. X    )
  877. X    ( cd lib ; for i in `ls | grep -v '\.a$'`; do \
  878. X        test -f ${LIBDIR}/$$i && /bin/mv ${LIBDIR}/$$i ${LIBDIR}/$$i.old; \
  879. X        /bin/cp $$i ${LIBDIR}; \
  880. X        chmod 711 ${LIBDIR}/$$i; chgrp ${GROUP} ${LIBDIR}/$$i; \
  881. X        chown ${OWNER} ${LIBDIR}/$$i; \
  882. X      done; \
  883. X    )
  884. X    @-echo Binary Installation complete
  885. X    @-echo Now install manual pages from ../doc if appropriate.
  886. X
  887. Xlint:
  888. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=lint $(MKTARGETS)
  889. X
  890. Xlibs:
  891. X    -/bin/test -d ${LIBDIR} || mkdir ${LIBDIR}
  892. X    $(MAKE) -$(MAKEFLAGS) MAKEWHAT=install $(MKDBM) mkliblqtext
  893. X    -@echo libraries up to date
  894. X
  895. X# Note to mklib and mkbin:
  896. X# If the mkdir -p bombs out, there is a shell-script mkdir you can use
  897. X# in the utils directory.  The -p means to create parent directores as needed.
  898. X
  899. Xmklib: # see note above about mkdir
  900. X    -@test -d lib || mkdir lib
  901. X    -@test -d $(LIBDIR) || mkdir -p $(LIBDIR)
  902. X
  903. Xmkbin:  # see note above about mkdir
  904. X    -@test -d bin || mkdir bin
  905. X    -@test -d $(BINDIR) || mkdir -p $(BINDIR)
  906. X
  907. Xmkfilters:
  908. X    cd filters; \
  909. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' \
  910. X    CFLAGS='$(CFLAGS) -DMAILFILTER=\"$(MAILFILTER)\" -DNEWSFILTER=\"$(NEWSFILTER)\" ' \
  911. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  912. X    RANLIB='$(RANLIB)' \
  913. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT) 
  914. X
  915. Xmkliblqtext:
  916. X    cd liblqtext; \
  917. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' \
  918. X    CFLAGS='$(CFLAGS) -DMAILFILTER=\"$(MAILFILTER)\" -DNEWSFILTER=\"$(NEWSFILTER)\" ' \
  919. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  920. X    RANLIB='$(RANLIB)' \
  921. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)
  922. X
  923. Xmklqtext:
  924. X    cd lqtext; \
  925. X    RANLIB='$(RANLIB)' \
  926. X    CFLAGS='$(CFLAGS) -DMAILFILTER=\"$(MAILFILTER)\" -DNEWSFILTER=\"$(NEWSFILTER)\" ' \
  927. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  928. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' \
  929. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)
  930. X
  931. Xmksdbm:
  932. X    cd sdbm; \
  933. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' CFLAGS='$(CFLAGS)' \
  934. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  935. X    RANLIB='$(RANLIB)' \
  936. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)
  937. X
  938. Xmkozmahash:
  939. X    cd ozmahash; \
  940. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' CFLAGS='-I. $(CFLAGS)' \
  941. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  942. X    RANLIB='$(RANLIB)' \
  943. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)
  944. X
  945. Xmktest:
  946. X    cd test; \
  947. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' CFLAGS='$(CFLAGS)' \
  948. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  949. X    OWNER='$(OWNER)' RANLIB='$(RANLIB)' \
  950. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)
  951. X
  952. Xmkmenu:
  953. X    cd menu; \
  954. X    $(MAKE) -$(MAKEFLAGS) MALLOC='$(MALLOC)' RANLIB='$(RANLIB)' \
  955. X    CFLAGS='$(CFLAGS) -DLQSHOW=\"$(LQSHOW)\" -DLQFILE=\"$(LQFILE)\" ' \
  956. X    CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
  957. X    DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)
  958. X
  959. X
  960. X#
  961. X# $Log:    Makefile,v $
  962. X# Revision 1.13  91/03/02  20:23:02  lee
  963. X# Improved install entry.
  964. X# 
  965. X# Revision 1.12  91/03/02  19:34:13  lee
  966. X# More comments and changed some defaults.
  967. X# 
  968. X# Revision 1.11  91/03/02  19:16:27  lee
  969. X# Now makes ozmahash if necessary, and uses SHELL=/bin/sh.
  970. X# 
  971. X# Revision 1.10  91/02/20  19:33:37  lee
  972. X# Removed duplicate definitions of LIB/LIBDIR, BIB/BINDIR and OWNER;
  973. X# OWNER now passed down in mktest correctly.
  974. X# 
  975. X# Revision 1.9  90/10/05  23:40:41  lee
  976. X# More comments for easier configuration -- and added more examples.
  977. X# 
  978. X# Revision 1.8  90/10/03  21:39:41  lee
  979. X# added CURSESX and more comments.
  980. X# ;.
  981. X# 
  982. X# Revision 1.7  90/10/03  21:14:08  lee
  983. X# Now passes MAILFILTER and NEWSFILTER.
  984. X# 
  985. X# Revision 1.6  90/10/01  18:28:43  lee
  986. X# Added MAILFLTER and NEWSFILTER to mkfilter
  987. X# 
  988. X# Revision 1.5  90/09/28  21:52:14  lee
  989. X# Now does installation itself...
  990. X# 
  991. X# Revision 1.4  90/09/10  13:25:31  lee
  992. X# Added some saber-C hooks.
  993. X# 
  994. X# Revision 1.3  90/07/27  17:50:51  lee
  995. X# alpha test version shipped
  996. X# 
  997. X# Revision 1.2  90/03/23  18:57:13  lee
  998. X# Added entries for lint and depend.
  999. X# 
  1000. X# Revision 1.1  90/03/23  15:11:30  lee
  1001. X# Initial revision
  1002. X# 
  1003. X#
  1004. @@@End of lq-text/src/Makefile
  1005. echo x - lq-text/src/PORTING 1>&2
  1006. sed 's/^X//' >lq-text/src/PORTING <<'@@@End of lq-text/src/PORTING'
  1007. XNotes for porting lq-text.
  1008. X
  1009. XThis is the free version.  It is not public domain, but you can use it
  1010. Xfreely for non-commercial purposes.
  1011. XIf you want to sell it, or something derived from it, you should get in
  1012. Xtouch with the author (me!), who will almost always give permission.
  1013. X
  1014. XYou can contact me as follows:
  1015. X  lee@sq.com,
  1016. X  Liam Quin, SoftQuad Inc. 720 Spadina Ave., Toronto, ONT., Canada
  1017. X  (+1) 416 963-8337
  1018. X
  1019. X==============================
  1020. X
  1021. XPORTING NOTES
  1022. X
  1023. XWell, I haven't done much porting.
  1024. XCurrently the stuff works on
  1025. X* System V Release 3.2 (Interactive's 386/ix 2.0.2), 80386
  1026. X* System V Release 2 (Honeywell Bull XPX 100 X20), 68020
  1027. X* SunOS 3 and 4 (Sun 3/60 and 3/75), 68020
  1028. X
  1029. XSince the 68020 and 80386 differ radically, most of the work has probably
  1030. Xbeen done.  Don't even *think* about non-Unix systems, though.
  1031. X
  1032. XLikely problems:
  1033. X* the calls to lockf() in FileList.c and WordInfo.c
  1034. X  You could comment them out on a single-user system.
  1035. X  On BSD you could use flock() instead.  It should be mandatory locking.
  1036. X  Actually, since the individual word entries are not locked, you could
  1037. X  simply delete the locking code.
  1038. X
  1039. X* if you have multiple machines sharing the same database, and they do not
  1040. X  all use the same byte-ordering, you will need to do some hacking.
  1041. X  The headers in pblock.{c,h}, and Filelist/WordInfo.c will all need
  1042. X  changing.  They have to read and write fixed-length unsigned longs,
  1043. X  and very quickly too!
  1044. X  Alternatively, use sReadNumber() and sWriteNumber(), and always allow
  1045. X  four bytes.
  1046. X
  1047. X* you need ndbm.  If you don't have it, you can use sdbm.
  1048. X  Look at  Liamdb.h and smalldb.h, and compile without -DNDBM.
  1049. X  If you are on Xenix, you can buy 386/ix from your nearest Interactive
  1050. X  dealer... Or use dbm().
  1051. X  If you are on 386/ix, well, as 386/ix doesn't include dbm,
  1052. X  use sdbm or gdbm.
  1053. X
  1054. X* On mixed model architectures, make sure that you can have arrays larger
  1055. X  then 64KBytes (if poss.), that a pointer (char *) fits into an unsigned
  1056. X  long, and that you have a good supply of coffee.
  1057. X
  1058. XBy all means mail me with questions, providing that you have at least tried
  1059. Xto get somewhere youself.
  1060. X
  1061. XLee
  1062. Xutzoo!sq!lee
  1063. Xlee@sq.com
  1064. @@@End of lq-text/src/PORTING
  1065. echo x - lq-text/src/TODO 1>&2
  1066. sed 's/^X//' >lq-text/src/TODO <<'@@@End of lq-text/src/TODO'
  1067. XKEY:
  1068. X* -- easy change
  1069. X** - harder, needs more understanding
  1070. X@ -- needs understanding of internals
  1071. X@@ - mail me if you need this!
  1072. X
  1073. X* give lqshow the ability to page a file
  1074. X
  1075. X** make a list of matches showing words nearby in a KWIC style
  1076. X   so that lqtext can show (say) a dozen at a time...
  1077. X   (see lqkwik... this will appear fairlysoon, I expect)
  1078. X
  1079. X@@ special treatment of dates
  1080. X
  1081. X** table of pagers for browsing by file/type
  1082. X
  1083. X**@@ Better ranking of queries
  1084. X
  1085. X**@@ write a manual :-(
  1086. X
  1087. X**@ "this" can't be accessed by lqword, but can be by lqshow[???].  The
  1088. X   entire plural code (Root.c) needs a rethink.
  1089. X   I have started Plurals.c, but it's not ready yet.  Yell if you have any
  1090. X   ideas, I need them!
  1091. X
  1092. X* The various Filter routines should be incorporated into showfile. 
  1093. X* Automatic uncompression should be added.  Should look at the magic number
  1094. X  as well as the file extension
  1095. X  ** -- lqshow would need big changes in one (obvious) routine... as it
  1096. X    currently uses lseek...
  1097. X
  1098. X** Showfile should be made a routine (BrowseList() I suppose) that takes
  1099. X** a list of Phrases with their matches...
  1100. X
  1101. X**@ should abandon dbm for the list of filenames.  A better approach would
  1102. X   be to store path components as words in the database!  This would make
  1103. X   / a common-word, though.  Needs some thought.
  1104. X   A btree might be a good comprimise.  For now, at least ozmahash doesn't
  1105. X   have overflow problems.
  1106. X
  1107. X*@ should use six-bit encoding for strings.  This would save a lot of space
  1108. X   with relatively little overhead.
  1109. X   Actually it doesn't save space at all, based on my experiments.  Sigh.
  1110. X
  1111. X**@@ the ability to delete a file.  Two ways:
  1112. X     1) read the file -- could be an option to addfile, in fact.  This
  1113. X    would have to check the time-stamps, of course.
  1114. X     2) schedule (perhaps overnight) a process to go through the entire
  1115. X    database and delete old files.
  1116. X    Also, addfile (and SortWordPlaces()) could remove deleted FIDs 
  1117. X    automatically, which would help.
  1118. X
  1119. X*@ the algorithm to add a new entry to a WID is too slow, because of the
  1120. X  requirement that the list be kept sorted.  I should instead keep a
  1121. X  SortedToHere counter in the header, and simply append new words.
  1122. X  The next time someone does a getpblock() and a sort, it could be written
  1123. X  back sorted.  Or there could be a daemon sorter!!
  1124. X
  1125. X* need better documentation!
  1126. X
  1127. X* README should be used more, allowing more configuration.
  1128. X  (README can now be called something else by recompiling)
  1129. X
  1130. X** allow dynamic definition of word start/mid/end, in README.
  1131. X   Must be at least as fast as isupper() etc.
  1132. X   Perhaps per-file-type rules, though?  Makes Phrase Matching hard.
  1133. X
  1134. X** Better file locking
  1135. X   (no file locking or signal handling at all at the moment -- I ripped it
  1136. X    all out when I discovered that it was broken on many systems, and
  1137. X    this gave a false sense of security.)
  1138. X
  1139. X* Finish the ReadAhead daemon.   See if it makes an improvement.
  1140. X  The idea is that whenever ReadBlock reads a block, it should ask the
  1141. X  daemon to read the next block, thus ensuring that it is in the buffer
  1142. X  cache.
  1143. X  It might be better simply to give it the WID and have it read the entire
  1144. X  chain itself.
  1145. X
  1146. X* Phrase Matching would be orders of magnitude faster if it did not involve
  1147. X  reading the tables of matches until they are needed, as many of them
  1148. X  won't be!  It should extend the lists of matches for each word in the
  1149. X  phrase only as necessary.
  1150. X
  1151. X** save large FIDs for large files.
  1152. X
  1153. X** Use a better number scheme (numbers.c)
  1154. X   make some more of the number routines inline -- especially use
  1155. X   a #define for the common case of sReadNumber ad sWriteNumber, eliminating
  1156. X   millions (!) of funtion calls when the numbers are only 1 byte long.
  1157. X   Note that most numbers turn out to fit in one byte (more than 90%) at
  1158. X   the moment, so if I had another bit I could improve the flags stuff..
  1159. X   The current scheme sets the top bit in each byte if there is more to
  1160. X   follow.  Another alternative would be to use magic values (e.g.
  1161. X   256 - (number of bytes)) for the first byte if there's more than one
  1162. X   byte. Hence 255 255 would be used to store 255.  This would roughly
  1163. X   double the number of numbers (!) fitting into one byte... hmm...
  1164. X
  1165. XKnown Bugs
  1166. X==========
  1167. X* lqshow only marks the first word of the phrase.
  1168. X* lqshow does not know about file types!!!
  1169. X* there is no troff (or sqtroff) file type
  1170. X* the C filter got lost in history (sigh)
  1171. X* I cannot distribute the CDMS and Uniplex filters
  1172. @@@End of lq-text/src/TODO
  1173. echo x - lq-text/src/filters/FilterMain.c 1>&2
  1174. sed 's/^X//' >lq-text/src/filters/FilterMain.c <<'@@@End of lq-text/src/filters/FilterMain.c'
  1175. X/* FilterMain.c -- Copyright 1989, 1990 Liam R. Quin.  All Rights Reserved.
  1176. X * This code is NOT in the public domain.
  1177. X * See the file COPYRIGHT for full details.
  1178. X */
  1179. X
  1180. X/* $Id: FilterMain.c,v 1.3 90/10/06 00:57:16 lee Rel1-10 $
  1181. X */
  1182. X
  1183. X/* FilterMain is intended to make writing filters easier; one
  1184. X * simply writes the Filter() routine and links with FilterMain.o to
  1185. X * produce a new filter.
  1186. X *
  1187. X * The filter should use "wordrules.h", and should transform its input
  1188. X * into words, spaces and newlines, with all other characters turnded into
  1189. X * spaces.
  1190. X *
  1191. X * A simple filter might be something like (on System V):
  1192. X *
  1193. X *    system("tr -c '[a-z][A-Z][0-9]_' '[ *]'");
  1194. X *
  1195. X * except that a word shouldn't start with a digit or _.
  1196. X *
  1197. X * Addfile itself maps upper case to lower, and may also check on the length
  1198. X * of words (min is currently 3, max 20, for example).
  1199. X *
  1200. X * A News or Mail filter might delete things from the header (turning them
  1201. X * into spaces to preserve file offsets), so that the index doesn't fill
  1202. X * up with ihnp4!decwrl!seismo!utzoo!henry everwhere.  Of course, it
  1203. X * would retain the utzoo!henry at the end of the From line.
  1204. X *
  1205. X * A filter for the Crystal Word Processor might turn accented characters
  1206. X * into their ASCII non-accented equivalents, (although NX-Text is 8-bit
  1207. X * transparent, so one could also decide to use an 8-bit character set),
  1208. X * and remove style information, non-local object banners, etc.
  1209. X *
  1210. X * This file must fork "compress -d" if appropriate, to read compressed files.
  1211. X * Note -- compress -d is the same as uncompress, but more likely to work.
  1212. X * Some sites also have zcat, but this is even rarer.
  1213. X *
  1214. X */
  1215. X
  1216. X/** Unix system calls used in this file: **/
  1217. Xextern void exit();
  1218. X/** C Library functions used in this file: **/
  1219. Xextern void perror();
  1220. X
  1221. X#include <stdio.h>
  1222. X
  1223. Xchar *progname;
  1224. Xvoid Filter();
  1225. X
  1226. Xextern int AsciiTrace;
  1227. X
  1228. Xint
  1229. Xmain(ac, av)
  1230. X    int ac;
  1231. X    char *av[];
  1232. X{
  1233. X    progname = av[0];
  1234. X
  1235. X    if (ac ==1) {
  1236. X    Filter(stdin, "(standard input)");
  1237. X    } else {
  1238. X    while (--ac) {
  1239. X        FILE *f = fopen(*++av, "r");
  1240. X
  1241. X        if (f == (FILE *) 0) {
  1242. X        fprintf(stderr, "%s: can't open ", progname);
  1243. X        perror(*av);
  1244. X        exit(1);
  1245. X        }
  1246. X
  1247. X        Filter(f, *av);
  1248. X
  1249. X        (void) fclose(f);
  1250. X    }
  1251. X    }
  1252. X    return 0;
  1253. X}
  1254. X
  1255. X/*
  1256. X * $Log:    FilterMain.c,v $
  1257. X * Revision 1.3  90/10/06  00:57:16  lee
  1258. X * Prepared for first beta release.
  1259. X * 
  1260. X * Revision 1.2  90/09/20  18:32:39  lee
  1261. X * Removed extra variable declarations...
  1262. X * 
  1263. X * Revision 1.1  90/08/09  19:17:54  lee
  1264. X * Initial revision
  1265. X * 
  1266. X * Revision 1.2  89/09/16  21:15:58  lee
  1267. X * First demonstratable version.
  1268. X * 
  1269. X * Revision 1.1  89/09/07  21:01:54  lee
  1270. X * Initial revision
  1271. X * 
  1272. X */
  1273. @@@End of lq-text/src/filters/FilterMain.c
  1274. echo x - lq-text/src/filters/MailFilter.c 1>&2
  1275. sed 's/^X//' >lq-text/src/filters/MailFilter.c <<'@@@End of lq-text/src/filters/MailFilter.c'
  1276. X/* MailFilter.c -- Copyright 1989 Liam R. Quin.  All Rights Reserved.
  1277. X * This code is NOT in the public domain.
  1278. X * See the file COPYRIGHT for full details.
  1279. X */
  1280. X
  1281. X/* $Id: MailFilter.c,v 1.5 90/10/06 00:57:24 lee Rel1-10 $
  1282. X */
  1283. X
  1284. X/* Filter for mail articles.
  1285. X * Throw away all of the header except
  1286. X *    Subject
  1287. X *    From
  1288. X *    Date
  1289. X *    Cc:
  1290. X *    Organi[sz]ation
  1291. X *    To:
  1292. X *
  1293. X * See FilterMain and wordrules.h for more info.
  1294. X *
  1295. X */
  1296. X
  1297. X#ifdef SYSV
  1298. X extern int _filbuf(), _flsbuf();
  1299. X#endif
  1300. X#include <stdio.h>
  1301. X#include <malloc.h>
  1302. X#include <ctype.h>
  1303. X#include "wordrules.h"
  1304. X
  1305. X#include "emalloc.h"
  1306. X
  1307. X#define STREQ(boy, girl) ((*(boy) == *(girl)) && !strcmp(boy, girl))
  1308. X
  1309. Xextern char *progname;
  1310. X
  1311. X/** Unix system calls used in this file **/
  1312. X    /* (none) */
  1313. X/** Unix Library Functions used in this file: **/
  1314. X#ifndef tolower
  1315. X extern int tolower();
  1316. X#endif
  1317. Xextern int strcmp();
  1318. X
  1319. X/** Functions within this file used before they're defined: **/
  1320. Xvoid Header(), Body();
  1321. Xint GetChar();
  1322. X
  1323. X/** **/
  1324. X
  1325. Xvoid Filter();
  1326. X
  1327. Xchar *KeepThese[] = { /* keep this list in lower case, sorted! */
  1328. X    "cc",
  1329. X    "date",
  1330. X    "from",
  1331. X    "organisation",
  1332. X    "organization",
  1333. X    "subject",
  1334. X    "to",
  1335. X    0
  1336. X};
  1337. X
  1338. Xint icstreq(s1, s2) /* case insensitive strcmp */
  1339. X    char *s1, *s2;
  1340. X{
  1341. X    register char ch1, ch2;
  1342. X
  1343. X    while (*s1 && *s2) {
  1344. X    if (*s1 != *s2) {
  1345. X        if (isupper(*s1)) {
  1346. X        ch1 = tolower(*s1);
  1347. X        ch2 = (*s2);
  1348. X        } else  if (isupper(*s2)) {
  1349. X        /* Note that we only have to test one character for case! */
  1350. X        ch1 = (*s1);
  1351. X        ch2 = tolower(*s2);
  1352. X        } else {
  1353. X        return 0; /* not the same */
  1354. X        }
  1355. X        if (ch1 != ch2) return 0; /* the strings differ */
  1356. X    }
  1357. X    s1++; s2++;
  1358. X    }
  1359. X    if (!*s1 && !*s2) {
  1360. X    return 1;
  1361. X    }
  1362. X    return 0; /* they are different */
  1363. X}
  1364. X
  1365. Xint
  1366. XIsWanted(String)
  1367. X    char *String;
  1368. X{
  1369. X    char **pp;
  1370. X    int ch = String[0];
  1371. X
  1372. X    if (isupper(ch)) ch = tolower(ch);
  1373. X
  1374. X    for (pp = KeepThese; *pp && **pp; pp++) {
  1375. X    if (**pp > ch) break; /* gone too far */
  1376. X    else if (icstreq(String, *pp)) return 1;
  1377. X    }
  1378. X    return 0;
  1379. X}
  1380. X
  1381. Xvoid
  1382. XFilter(InputFile, Name)
  1383. X    FILE *InputFile;
  1384. X    char *Name;
  1385. X{
  1386. X    Header(InputFile, Name);
  1387. X    Body(InputFile, Name);
  1388. X}
  1389. X
  1390. Xtypedef enum {
  1391. X    F_NotSeenAnythingYet,
  1392. X    F_InTheFirstWord,
  1393. X    F_AfterTheFirstWord
  1394. X} t_FirstWord;
  1395. X
  1396. Xint InWord = 0;
  1397. X
  1398. X/* For a mail article, the Header ends at the first line which is not
  1399. X * a valid mail header -- i.e., is not indented and doesn't start with
  1400. X * a capitalised word followed by a single space (uucp) or colon (RFC822).
  1401. X * A blank line also ends the header.
  1402. X */
  1403. Xvoid
  1404. XHeader(InputFile, Name)
  1405. X    FILE *InputFile;
  1406. X    char *Name;
  1407. X{
  1408. X    int AtStartOfLine = 1;
  1409. X    int IgnoreLine = 0; /* initialised for lint... */
  1410. X    t_FirstWord FirstWord = F_NotSeenAnythingYet;
  1411. X    int ch;
  1412. X    static int BufLen;
  1413. X    static char *Buffer = 0;
  1414. X    int AtStartOfWord;
  1415. X    register char *q;
  1416. X
  1417. X    if (Buffer == 0) {
  1418. X    BufLen = 24;
  1419. X    Buffer = emalloc(BufLen);
  1420. X    }
  1421. X
  1422. X    q = Buffer;
  1423. X    InWord = 0;
  1424. X
  1425. X    while ((ch = GetChar(InputFile)) != EOF) {
  1426. X    if (ch == '\n') {
  1427. X        if (AtStartOfLine) { /* a blank line */
  1428. X        putchar('\n');
  1429. X        return;
  1430. X        }
  1431. X    }
  1432. X
  1433. X    InWord = InWord ? WithinWord(ch) : StartsWord(ch);
  1434. X
  1435. X    switch (FirstWord) {
  1436. X    case F_NotSeenAnythingYet:
  1437. X        if (InWord) {
  1438. X        FirstWord = F_InTheFirstWord;
  1439. X        if (q - Buffer >= BufLen - 1) {
  1440. X            int where = q - Buffer;
  1441. X
  1442. X            BufLen += 24;
  1443. X            Buffer = erealloc(Buffer, BufLen);
  1444. X            q = &Buffer[where];
  1445. X        }
  1446. X        *q++ = ch;
  1447. X        } else {
  1448. X        if (AtStartOfLine && ch != ' ' && ch != '\t') {
  1449. X            putchar(ch);
  1450. X            return;
  1451. X        }
  1452. X        putchar(' ');
  1453. X        }
  1454. X        break;
  1455. X    case F_InTheFirstWord:
  1456. X        if (InWord) {
  1457. X        if (q - Buffer >= BufLen - 1) {
  1458. X            int where = q - Buffer;
  1459. X
  1460. X            BufLen += 24;
  1461. X            Buffer = erealloc(Buffer, BufLen);
  1462. X            q = &Buffer[where];
  1463. X        }
  1464. X        *q++ = ch;
  1465. X        break;
  1466. X        } else { /* reached the end of the first word on the line */
  1467. X        *q = '\0';
  1468. X        /* See if it's a keyword */
  1469. X        if ((IgnoreLine = !IsWanted(Buffer)) != 0) {
  1470. X            /* Turn the word into one that won't get indexed,
  1471. X             * so that word counmts are unaffected:
  1472. X             * We use qxxxxxxx (any number of x's) for this.
  1473. X             */
  1474. X            for (q = Buffer; *q; q++) {
  1475. X            putchar((q == Buffer) ? 'q' : 'x');
  1476. X            }
  1477. X            putchar (ch == '\n' ? '\n' : ' ');
  1478. X        } else {
  1479. X            printf("%s%c", Buffer, ch == '\n' ? ch : ' ');
  1480. X        }
  1481. X        FirstWord = F_AfterTheFirstWord;
  1482. X        }
  1483. X        break;
  1484. X    default:
  1485. X        if ((AtStartOfLine = (ch == '\n'))) {
  1486. X        IgnoreLine = 0;
  1487. X        q = Buffer;
  1488. X        FirstWord = F_NotSeenAnythingYet;
  1489. X        AtStartOfWord = 1;
  1490. X        }
  1491. X        if (InWord && !IgnoreLine) {
  1492. X        putchar(ch);
  1493. X        } else {
  1494. X        if (AtStartOfWord && InWord) {
  1495. X            putchar('q');
  1496. X            AtStartOfWord = 0;
  1497. X        } else if (InWord) {
  1498. X            putchar('x');
  1499. X        } else if (isspace(ch)) {
  1500. X            putchar(ch);
  1501. X        } else {
  1502. X            putchar(' ');
  1503. X        }
  1504. X        }
  1505. X        if (!InWord) AtStartOfWord = 1;
  1506. X    }
  1507. X    if ((AtStartOfLine = (ch == '\n'))) {
  1508. X        IgnoreLine = 0;
  1509. X        q = Buffer;
  1510. X        FirstWord = F_NotSeenAnythingYet;
  1511. X        AtStartOfWord = 1;
  1512. X    }
  1513. X    }
  1514. X    if (ch == EOF) {
  1515. X    fprintf(stderr, "%s: warning: Mail folder %s has no message body\n",
  1516. X            progname, Name);
  1517. X    }
  1518. X}
  1519. X
  1520. Xvoid
  1521. XBody(InputFile, Name)
  1522. X    FILE *InputFile;
  1523. X    char *Name;
  1524. X{
  1525. X    int ch;
  1526. X
  1527. X    while ((ch = GetChar(InputFile)) != EOF) {
  1528. X    if (InWord = InWord ? WithinWord(ch) : StartsWord(ch)) {
  1529. X        putchar(ch);
  1530. X    } else {
  1531. X        putchar((ch == '\n') ? '\n' : ' ');
  1532. X    }
  1533. X    }
  1534. X}
  1535. X
  1536. X#ifdef __GNU__
  1537. Xinline
  1538. X#endif
  1539. Xint
  1540. XGetChar(fd)
  1541. X    FILE *fd;
  1542. X{
  1543. X    static int LastChar = 0;
  1544. X
  1545. X    if (LastChar) {
  1546. X    int ch = LastChar;
  1547. X    LastChar = 0;
  1548. X    return ch;
  1549. X    }
  1550. X
  1551. X    /* Only return a single quote if it is surrounded by letters */
  1552. X    if ((LastChar = getc(fd)) == '\'') {
  1553. X    LastChar = getc(fd);
  1554. X    if (InWord && isalpha(LastChar)) return '\'';
  1555. X    else return ' ';
  1556. X    } else {
  1557. X    int ch = LastChar;
  1558. X    LastChar = 0;
  1559. X    return ch;
  1560. X    }
  1561. X}
  1562. X
  1563. X/*
  1564. X * $Log:    MailFilter.c,v $
  1565. X * Revision 1.5  90/10/06  00:57:24  lee
  1566. X * Prepared for first beta release.
  1567. X * 
  1568. X * Revision 1.4  90/09/20  16:35:40  lee
  1569. X * Fixed icstrcmp() and IsWanted() so that the unwanted parts of headers
  1570. X * get deleted again.... (oops!)
  1571. X * 
  1572. X * Revision 1.3  90/09/19  21:11:54  lee
  1573. X * Improved end-of-header detection.
  1574. X * Now supports turning unindexed stuff into qxxxxx-words.
  1575. X * 
  1576. X * Revision 1.2  90/08/29  21:55:57  lee
  1577. X * Now handles mh mail better.
  1578. X * 
  1579. X * Revision 1.1  90/08/09  19:17:56  lee
  1580. X * Initial revision
  1581. X * 
  1582. X * Revision 1.2  89/09/16  21:16:01  lee
  1583. X * First demonstratable version.
  1584. X * 
  1585. X * Revision 1.1  89/09/07  21:05:48  lee
  1586. X * Initial revision
  1587. X * 
  1588. X */
  1589. @@@End of lq-text/src/filters/MailFilter.c
  1590. echo end of part 01
  1591. -- 
  1592. Liam R. E. Quin,  lee@sq.com, SoftQuad Inc., Toronto, +1 (416) 963-8337
  1593.