source: tags/greenstone-3_01-distribution/mgpp/text/mg_files.h@ 10896

Last change on this file since 10896 was 10896, checked in by (none), 18 years ago

This commit was manufactured by cvs2svn to create tag
'greenstone-3_01-distribution'.

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