2 *******************************************************************************
5 * RCS: $Header: /home/matthew/cvs/bible-kjv-4.10/tsl.h,v 2.4 2005/01/22 00:25:08 matthew Exp $
6 * Description: Text Storage Library header file
7 * Author: Chip Chapin, Hewlett Packard Company
9 * Modified: Mon Apr 26 11:12:13 1993 (Chip Chapin) chip@hpclbis
11 * Package: Bible Retrieval System
12 * Status: Experimental (Do Not Distribute)
14 *******************************************************************************
18 * Fri Apr 23 09:38:02 1993 (Chip Chapin) chip@hpclbis
19 * Revised headers to use Univ_Int byte-portable integers.
20 * Thu Jan 7 11:56:21 1993 (Chip Chapin) chip@hpclbis
21 * Revised concordance file header to match bible file header.
22 *******************************************************************************
25 * Revision 2.4 2005/01/22 00:25:08 matthew
28 * Revision 2.3 2003/07/26 11:44:56 matthew
29 * add function prototypes to the tsl header file (and add some const modifiers)
31 * Revision 2.2 2003/07/26 09:25:05 matthew
32 * Move tsl_error declaration to tsl.h
34 * Revision 2.1 2003/01/08 15:50:53 matthew
35 * applied debian patch
37 * Revision 2.0 2003/01/08 15:29:52 matthew
38 * versions collected from the net
40 * Revision 1.8 93/04/26 11:18:26 11:18:26 chip (Chip Chapin)
42 * Public release of portable datafile version.
44 * Revision 1.7 93/04/23 13:08:10 13:08:10 chip (Chip Chapin)
46 * This version supports portable data files, usable on machines with
47 * differing native byte-orders.
48 * Also, this version compiles and runs on non-HPUX systems. It has been
49 * tested on SunOS 4.? and ULTRIX 4.?, using SPARC and DEC 3100 hardware
50 * respectively. Note that the data file format has rolled again.
52 * Revision 1.6 93/01/07 12:18:08 12:18:08 chip (Chip Chapin)
53 * Release 3.01: Greatly improved compression of concordance data file.
55 * Revision 1.5 93/01/04 16:21:03 16:21:03 chip (Chip Chapin)
56 * Release 2.1, implements ?in and ?or commands.
58 * Revision 1.4 92/12/21 20:01:43 20:01:43 chip (Chip Chapin)
59 * Release 2.0. This release adds the concordance, and some small fixes.
61 * Revision 1.3 90/01/02 12:12:12 12:12:12 chip (Chip Chapin)
62 * Fix typo in comment regarding "tsl-index.c"
64 * Revision 1.2 89/09/14 20:34:18 20:34:18 chip (Chip Chapin)
65 * Release 1-2. Supports -f and -l options for formatting the output.
66 * Updates primarily brl.c, bible.c, and bible.1.
68 * Revision 1.1 89/09/05 17:49:50 17:49:50 chip (Chip Chapin)
76 #define TSL_MAGIC1 'E' /* Magic number: two ASCII chars EC */
77 #define TSL_MAGIC2 'C'
78 #define TSL_CONCMAGIC1 'E' /* Magic number: two ASCII chars EF */
79 #define TSL_CONCMAGIC2 'F'
80 #define TSL_FVERSION1 '0' /* File structure version: '01' */
81 #define TSL_FVERSION2 '2'
82 #define TSL_CONCFVERSION1 '0' /* File structure version: '01' */
83 #define TSL_CONCFVERSION2 '2'
85 #define TSL_DESCRSZ 80 /* Size of name field in Concordance header */
88 extern int line_locator[]; /* Defined in "xxx-index.c" (xxx == progname) */
91 Structure of Text Data File.
93 File includes a header section that identifies its nature, and an
94 index (from the statistics provided by squish) to the starting
95 location of every compression window.
101 4,83 description: null terminated ASCII string
102 --- remaining fields assume the file has been compressed with windows ---
103 84-87 window size (bytes)
104 88-91 number of windows
105 92-95 starting location (byte in file) of window #0
106 96-99 starting location (byte in file) of window #1
108 xxxx compressed data begins
111 struct tsl_fileheader {
114 char description[TSL_DESCRSZ];
121 Structure of Concordance Data File.
123 The concordance data file is designed so that retrieval software
124 can either search the file directly, or create efficient runtime
127 Various compression strategies are used on the reference index and
128 reference data pool. For details, see makeconcfile.c and tsl.c.
130 <file header> See structure definition below.
131 <word list> All the words, in order, separated by null
132 bytes. The order implies a unique index
133 number for each word.
134 <reference index> A table, indexed by word number, of pointers
135 into the reference data. To save space,
136 these are actually cumulative offsets.
137 <reference data> Pool of reference data.
141 typedef int file_ptr_t; /* File-relative pointers */
142 typedef unsigned short ref_t; /* Representation of a <ref>. */
143 #define SELECTSZ 32000 /* There are 31102 verses in KJV Bible. */
145 struct tsl_conc_fileheader {
146 char magic[2]; /* Magic number */
147 char version[2]; /* For versioning */
148 char name[TSL_DESCRSZ]; /* String describing file contents */
149 Univ_Int word_cnt; /* Number of entries in concordance */
150 Univ_Int word_ptr; /* File-relative pointer to word list */
151 Univ_Int index_ptr; /* File-relative pointer to reference index */
152 Univ_Int data_ptr; /* File-relative pointer to reference data */
155 /*Function prototypes*/
158 void tsl_error(const int fatal, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
160 void tsl_error(const int fatal, const char *format, ...);
162 int tsl_scan_concordance(const char *target, ref_t *sbuf, ref_t range_start,
164 int tsl_gettext(const int vn, const int vc, char *vb, const int vbsize );
165 int tsl_printtext(const int vn, const int vc);
166 int tsl_textread(int start, const int vsize, char *vb);
167 void tsl_init(char *dfname,char *path, const int memlimit);
168 void tsl_close(void);