chiark / gitweb /
update release_version to 4.35
[bible-kjv.git] / tsl.h
1 /* -*-C-*-
2 *******************************************************************************
3 *
4 * File:         tsl.h
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
8 * Created:      Jan 14 1989
9 * Modified:     Mon Apr 26 11:12:13 1993 (Chip Chapin) chip@hpclbis
10 * Language:     C
11 * Package:      Bible Retrieval System
12 * Status:       Experimental (Do Not Distribute)
13 *
14 *******************************************************************************
15 *
16 * Revisions:
17 *
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 *******************************************************************************
23 *
24 * $Log: tsl.h,v $
25 * Revision 2.4  2005/01/22 00:25:08  matthew
26 * these are not const
27 *
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)
30 *
31 * Revision 2.2  2003/07/26 09:25:05  matthew
32 * Move tsl_error declaration to tsl.h
33 *
34 * Revision 2.1  2003/01/08 15:50:53  matthew
35 * applied debian patch
36 *
37 * Revision 2.0  2003/01/08 15:29:52  matthew
38 * versions collected from the net
39 *
40  * Revision 1.8  93/04/26  11:18:26  11:18:26  chip (Chip Chapin)
41  * Release 4.00
42  * Public release of portable datafile version.
43  * 
44  * Revision 1.7  93/04/23  13:08:10  13:08:10  chip (Chip Chapin)
45  * PORTABILITY RELEASE
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.
51  * 
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.
54  * 
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.
57  * 
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.
60  * 
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"
63  * 
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.
67  * 
68  * Revision 1.1  89/09/05  17:49:50  17:49:50  chip (Chip Chapin)
69  * Initial revision
70  * 
71 *
72 */
73
74 #include "util.h"
75
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'
84
85 #define TSL_DESCRSZ     80      /* Size of name field in Concordance header */
86
87
88 extern int line_locator[];      /* Defined in "xxx-index.c" (xxx == progname) */
89
90 /*
91   Structure of Text Data File.
92   
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.
96
97   Output File Layout:
98      bytes  Contents
99      0,1          magic number
100      2,3    file version
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
107      ...    etc.
108      xxxx   compressed data begins
109    
110 */
111 struct tsl_fileheader {
112     char        magic[2];
113     char        version[2];
114     char        description[TSL_DESCRSZ];
115     Univ_Int    wsize;
116     Univ_Int    wnum;
117 };
118
119
120 /*
121   Structure of Concordance Data File.
122
123     The concordance data file is designed so that retrieval software
124     can either search the file directly, or create efficient runtime
125     data structures.
126
127     Various compression strategies are used on the reference index and
128     reference data pool.  For details, see makeconcfile.c and tsl.c.
129
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.
138     
139  */
140
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. */
144
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 */
153 };
154
155 /*Function prototypes*/
156
157 #ifdef __GNUC__
158 void tsl_error(const int fatal, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
159 #else 
160 void tsl_error(const int fatal, const char *format, ...);
161 #endif
162 int tsl_scan_concordance(const char *target, ref_t *sbuf, ref_t range_start, 
163                          ref_t range_end );
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);