source: trunk/gsdl/src/mgpp/text/mg_files.h@ 856

Last change on this file since 856 was 856, checked in by sjboddie, 24 years ago

Rodgers new C++ mg

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 10.1 KB
Line 
1/**************************************************************************
2 *
3 * mg_files.h -- Routines for handling files for the auxillary programs
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: mg_files.h 856 2000-01-14 02:26:25Z sjboddie $
21 *
22 **************************************************************************/
23
24#ifndef MG_FILES_H
25#define MG_FILES_H
26
27#include "sysfuncs.h"
28
29/* Magic numbers for the different types of files */
30
31#define GEN_MAGIC(a,b,c,d) ((unsigned long)(((a)<<24) + ((b)<<16) + \
32 ((c)<<8) + (d)))
33
34#define MAGIC_XXXX GEN_MAGIC('M','G', 0 , 0)
35#define MAGIC_STATS_DICT GEN_MAGIC('M','G','S','D')
36#define MAGIC_AUX_DICT GEN_MAGIC('M','G','A','D')
37#define MAGIC_FAST_DICT GEN_MAGIC('M','G','F','D')
38#define MAGIC_DICT GEN_MAGIC('M','G','D', 0 )
39#define MAGIC_STEM_BUILD GEN_MAGIC('M','G','S', 0 )
40#define MAGIC_HASH GEN_MAGIC('M','G','H', 0 )
41#define MAGIC_STEM GEN_MAGIC('M','G','s', 0 )
42#define MAGIC_CHUNK GEN_MAGIC('M','G','C', 0 )
43#define MAGIC_CHUNK_TRANS GEN_MAGIC('M','G','c', 0 )
44#define MAGIC_TEXT GEN_MAGIC('M','G','T', 0 )
45#define MAGIC_TEXI GEN_MAGIC('M','G','t', 0 )
46#define MAGIC_TEXT_LEVELS GEN_MAGIC('M','G','t','L')
47#define MAGIC_TEXI_WGT GEN_MAGIC('M','G','t','W')
48#define MAGIC_INVF GEN_MAGIC('M','G','I', 0 )
49#define MAGIC_INVF_LEVELS GEN_MAGIC('M','G','I','L')
50#define MAGIC_INVI GEN_MAGIC('M','G','i', 0 )
51#define MAGIC_WGHT GEN_MAGIC('M','G','W', 0 )
52#define MAGIC_WGHT_APPROX GEN_MAGIC('M','G','w', 0 )
53#define MAGIC_PARAGRAPH GEN_MAGIC('M','G','P', 0 )
54/* [RPAP - Jan 97: Stem Index Change] */
55#define MAGIC_STEM_1 GEN_MAGIC('M','G','s','1')
56#define MAGIC_STEM_2 GEN_MAGIC('M','G','s','2')
57#define MAGIC_STEM_3 GEN_MAGIC('M','G','s','3')
58
59#define IS_MAGIC(a) ((((u_long)(a)) & 0xffff0000) == MAGIC_XXXX)
60
61
62/* err_mode values for open_file and create_file */
63#define MG_ABORT 0
64#define MG_MESSAGE 1
65#define MG_CONTINUE 2
66
67
68
69
70
71/* File suffixes */
72
73
74/* The compression dictionary built by txt.pass1 */
75#ifdef SHORT_SUFFIX
76# define TEXT_STATS_DICT_SUFFIX ".tsd"
77#else
78# define TEXT_STATS_DICT_SUFFIX ".text.stats"
79#endif
80
81/* The compression dictionary built by text.pass1 and comp_dict.process */
82#ifdef SHORT_SUFFIX
83# define TEXT_DICT_SUFFIX ".td"
84#else
85# define TEXT_DICT_SUFFIX ".text.dict"
86#endif
87
88/* The compression dictionary built by mg_make_fast_dict */
89#ifdef SHORT_SUFFIX
90# define TEXT_DICT_FAST_SUFFIX ".tdf"
91#else
92# define TEXT_DICT_FAST_SUFFIX ".text.dict.fast"
93#endif
94
95/* The auxilary dictionary built by text.pass2 */
96#ifdef SHORT_SUFFIX
97# define TEXT_DICT_AUX_SUFFIX ".tda"
98#else
99# define TEXT_DICT_AUX_SUFFIX ".text.dict.aux"
100#endif
101
102/* The compressed text build by text.pass2 */
103#ifdef SHORT_SUFFIX
104# define TEXT_SUFFIX ".t"
105#else
106# define TEXT_SUFFIX ".text"
107#endif
108
109/* The combined compressed text index and document weight file */
110#ifdef SHORT_SUFFIX
111# define TEXT_IDX_WGT_SUFFIX ".tiw"
112#else
113# define TEXT_IDX_WGT_SUFFIX ".text.idx.wgt"
114#endif
115
116/* The compressed text index file */
117#ifdef SHORT_SUFFIX
118# define TEXT_IDX_SUFFIX ".ti"
119#else
120# define TEXT_IDX_SUFFIX ".text.idx"
121#endif
122
123/* The document levels in the text */
124#ifdef SHORT_SUFFIX
125# define TEXT_LEVEL_SUFFIX ".tl"
126#else
127# define TEXT_LEVEL_SUFFIX ".text.level"
128#endif
129
130/* The dictionary of stemmed words build by invf.pass1 and ivf.pass1 */
131#ifdef SHORT_SUFFIX
132# define INVF_DICT_SUFFIX ".id"
133#else
134# define INVF_DICT_SUFFIX ".invf.dict"
135#endif
136
137/* The dictionary of stemmed words build by stem.process */
138#ifdef SHORT_SUFFIX
139# define INVF_DICT_BLOCKED_SUFFIX ".idb"
140#else
141# define INVF_DICT_BLOCKED_SUFFIX ".invf.dict.blocked"
142#endif
143
144/* The exact document weights file build by make.weights, invf.pass2,
145 or ivf.pass2 */
146#ifdef SHORT_SUFFIX
147# define WEIGHTS_SUFFIX ".w"
148#else
149# define WEIGHTS_SUFFIX ".weight"
150#endif
151
152/* The approximate weights file built by make.weights */
153#ifdef SHORT_SUFFIX
154# define APPROX_WEIGHTS_SUFFIX ".wa"
155#else
156# define APPROX_WEIGHTS_SUFFIX ".weight.approx"
157#endif
158
159/* The inverted file build by invf.pass2 or ivf.pass2 */
160#ifdef SHORT_SUFFIX
161# define INVF_SUFFIX ".i"
162#else
163# define INVF_SUFFIX ".invf"
164#endif
165
166/* The level information for the inverted text */
167#ifdef SHORT_SUFFIX
168# define INVF_LEVEL_SUFFIX ".il"
169#else
170# define INVF_LEVEL_SUFFIX ".invf.level"
171#endif
172
173/* The inverted file index build by invf.pass2 or ivf.pass2 */
174#ifdef SHORT_SUFFIX
175# define INVF_IDX_SUFFIX ".ii"
176#else
177# define INVF_IDX_SUFFIX ".invf.idx"
178#endif
179
180/* The inverted file chunk descriptor built by ivf.pass1 */
181#ifdef SHORT_SUFFIX
182# define INVF_CHUNK_SUFFIX ".ic"
183#else
184# define INVF_CHUNK_SUFFIX ".invf.chunk"
185#endif
186
187/* The word index translation file built by ivf.pass1 */
188#ifdef SHORT_SUFFIX
189# define INVF_CHUNK_TRANS_SUFFIX ".ict"
190#else
191# define INVF_CHUNK_TRANS_SUFFIX ".invf.chunk.trans"
192#endif
193
194/* The hashed stemmed dictionary built by make.perf_hash */
195#ifdef SHORT_SUFFIX
196# define INVF_DICT_HASH_SUFFIX ".idh"
197#else
198# define INVF_DICT_HASH_SUFFIX ".invf.dict.hash"
199#endif
200
201/* The paragraph descriptior file built by invf.pass1 or ivf.pass1 */
202#ifdef SHORT_SUFFIX
203# define INVF_PARAGRAPH_SUFFIX ".ip"
204#else
205# define INVF_PARAGRAPH_SUFFIX ".invf.paragraph"
206#endif
207
208/* The trace file build by mg.builder. */
209#ifdef SHORT_SUFFIX
210# define TRACE_SUFFIX ".trc"
211#else
212# define TRACE_SUFFIX ".trace"
213#endif
214
215/* The compression stats file build by mg.builder. */
216#ifdef SHORT_SUFFIX
217# define COMPRESSION_STATS_SUFFIX ".cs"
218#else
219# define COMPRESSION_STATS_SUFFIX ".compression.stats"
220#endif
221
222/* [RPAP - Jan 97: Stem Index Change] */
223/* The casefolded index into the stemmed dictionary */
224#ifdef SHORT_SUFFIX
225# define INVF_DICT_BLOCKED_1_SUFFIX ".ib1"
226#else
227# define INVF_DICT_BLOCKED_1_SUFFIX ".invf.dict.blocked.1"
228#endif
229
230/* [RPAP - Jan 97: Stem Index Change] */
231/* The stemmed index into the stemmed dictionary */
232#ifdef SHORT_SUFFIX
233# define INVF_DICT_BLOCKED_2_SUFFIX ".ib2"
234#else
235# define INVF_DICT_BLOCKED_2_SUFFIX ".invf.dict.blocked.2"
236#endif
237
238/* [RPAP - Jan 97: Stem Index Change] */
239/* The casefolded and stemmed index into the stemmed dictionary */
240#ifdef SHORT_SUFFIX
241# define INVF_DICT_BLOCKED_3_SUFFIX ".ib3"
242#else
243# define INVF_DICT_BLOCKED_3_SUFFIX ".invf.dict.blocked.3"
244#endif
245
246/* [RPAP - Feb 97: WIN32 Port] */
247#ifdef __WIN32__
248#define FILE_NAME_FORMAT "%s%s%s"
249#else
250#define FILE_NAME_FORMAT "%s/%s%s"
251#endif
252
253
254/* This sets the base path for all file operations */
255void set_basepath (const char *bp);
256
257
258/* return the currently defined basepath */
259char *get_basepath (void);
260
261
262
263
264/* This generates the name of a file. It places the name in the buffer
265 specified or if that is NULL it uses a static buffer. */
266char *make_name (const char *name, const char *suffix, char *buffer);
267
268
269
270
271
272
273
274/* This will open the specified file and check its magic number.
275 Mode may take on the following values
276 MG_ABORT : causes an error message to be generated and the
277 program aborted if there is an error.
278 MG_MESSAGE : causes a message to be generated and a NULL value to
279 be returned if there is an error.
280 MG_CONTINUE : causes a NULL value to be returned if there is an error.
281
282 On success if returns the FILE *. On failure it will return a NULL value
283 and possibly generate an error message, or it will exit the program with
284 an error message. */
285FILE *open_named_file (const char *name, const char *mode,
286 u_long magic_num, int err_mode);
287
288
289
290
291/* This will open the specified file and check its magic number.
292
293 err_mode may take on the following values
294 MG_ABORT : causes an error message to be generated and the
295 program aborted if there is an error.
296 MG_MESSAGE : causes a message to be generated and a NULL value to
297 be returned if there is an error.
298 MG_CONTINUE : causes a NULL value to be returned if there is an error.
299
300 On success if returns the FILE *. On failure it will return a NULL value
301 and possibly generate an error message, or it will exit the program with
302 an error message. */
303FILE *open_file (const char *name, const char *suffix, const char *mode,
304 u_long magic_num, int err_mode);
305
306
307
308
309
310/* This will create the specified file and set its magic number.
311
312 Mode may take on the following values
313 MG_ABORT : causes an error message to be generated and the
314 program aborted if there is an error.
315 MG_MESSAGE : causes a message to be generated and a NULL value to
316 be returned if there is an error.
317 MG_CONTINUE : causes a NULL value to be returned if there is an error.
318
319 On success if returns the FILE *. On failure it will return a NULL value
320 and possibly generate an error message, or it will exit the program with
321 an error message. */
322FILE *create_named_file (const char *name, const char *mode,
323 u_long magic_num, int err_mode);
324
325
326
327/* This will create the specified file and set its magic number.
328
329 err_mode may take on the following values
330 MG_ABORT : causes an error message to be generated and the
331 program aborted if there is an error.
332 MG_MESSAGE : causes a message to be generated and a NULL value to
333 be returned if there is an error.
334 MG_CONTINUE : causes a NULL value to be returned if there is an error.
335
336 On success if returns the FILE *. On failure it will return a NULL value
337 and possibly generate an error message, or it will exit the program with
338 an error message. */
339FILE *create_file (const char *name, const char *suffix, const char *mode,
340 u_long magic_num, int err_mode);
341
342
343
344
345#endif
Note: See TracBrowser for help on using the repository browser.