2 * Copyright (C) 1995-0000, Index Data
4 * Sebastian Hammer, Adam Dickmeiss, Heikki Levanto
22 #define ISAM_DEFAULT "c"
24 #define ISAM_DEFAULT "s"
26 #include <yaz/data1.h>
33 #define IT_MAX_WORD 256
34 #define IT_KEY_HAVE_SEQNO 1
35 #define IT_KEY_HAVE_FIELD 0
44 enum dirsKind { dirs_dir, dirs_file };
80 void getFnameTmp (Res res, char *fname, int no);
82 struct dirs_info *dirs_open (Dict dict, const char *rep, int rw);
83 struct dirs_info *dirs_fopen (Dict dict, const char *path);
84 struct dirs_entry *dirs_read (struct dirs_info *p);
85 struct dirs_entry *dirs_last (struct dirs_info *p);
86 void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime);
87 void dirs_rmdir (struct dirs_info *p, const char *src);
88 void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime);
89 void dirs_del (struct dirs_info *p, const char *src);
90 void dirs_free (struct dirs_info **pp);
92 struct dir_entry *dir_open (const char *rep);
93 void dir_sort (struct dir_entry *e);
94 void dir_free (struct dir_entry **e_p);
96 void repositoryUpdate (struct recordGroup *rGroup);
97 void repositoryAdd (struct recordGroup *rGroup);
98 void repositoryDelete (struct recordGroup *rGroup);
99 void repositoryShow (struct recordGroup *rGroup);
101 int key_open (struct recordGroup *rGroup, int mem);
102 int key_close (struct recordGroup *group);
103 int key_compare (const void *p1, const void *p2);
104 int key_get_pos (const void *p);
105 int key_compare_it (const void *p1, const void *p2);
106 int key_qsort_compare (const void *p1, const void *p2);
107 void key_logdump (int mask, const void *p);
108 void inv_prstat (BFiles bfs);
109 void inv_compact (BFiles bfs);
110 void key_input (BFiles bfs, int nkeys, int cache, Res res);
111 ISAMS_M key_isams_m (Res res, ISAMS_M me);
113 ISAMC_M key_isamc_m (Res res, ISAMC_M me);
114 ISAMD_M key_isamd_m (Res res, ISAMD_M me);
116 int merge_sort (char **buf, int from, int to);
117 int key_SU_code (int ch, char *out);
119 #define FNAME_DICT "dict"
120 #define FNAME_ISAM "isam"
121 #define FNAME_ISAMC "isamc"
122 #define FNAME_ISAMS "isams"
123 #define FNAME_ISAMH "isamh"
124 #define FNAME_ISAMD "isamd"
125 #define FNAME_CONFIG "zebra.cfg"
127 #define GMATCH_DICT "gmatch"
128 #define FMATCH_DICT "fmatch"
130 struct strtab *strtab_mk (void);
131 int strtab_src (struct strtab *t, const char *name, void ***infop);
132 void strtab_del (struct strtab *t,
133 void (*func)(const char *name, void *info, void *data),
135 int index_char_cvt (int c);
136 int index_word_prefix (char *string, int attset_ordinal,
137 int local_attribute, const char *databaseName);
139 int fileExtract (SYSNO *sysno, const char *fname,
140 const struct recordGroup *rGroup, int deleteFlag);
142 void zebraIndexLockMsg (const char *str);
143 void zebraIndexUnlock (void);
144 int zebraIndexLock (BFiles bfs, int commitNow, const char *rval);
145 int zebraIndexWait (int commitPhase);
147 #define FNAME_MAIN_LOCK "zebraidx.LCK"
148 #define FNAME_COMMIT_LOCK "zebracmt.LCK"
149 #define FNAME_ORG_LOCK "zebraorg.LCK"
150 #define FNAME_TOUCH_TIME "zebraidx.time"
152 typedef struct zebra_lock_info *ZebraLockHandle;
153 ZebraLockHandle zebra_lock_create(const char *file, int excl_flag);
154 void zebra_lock_destroy (ZebraLockHandle h);
155 int zebra_lock (ZebraLockHandle h);
156 int zebra_lock_nb (ZebraLockHandle h);
157 int zebra_unlock (ZebraLockHandle h);
158 int zebra_lock_fd (ZebraLockHandle h);
159 void zebra_lock_prefix (Res res, char *dst);
161 void zebra_load_atts (data1_handle dh, Res res);
163 int key_SU_decode (int *ch, const unsigned char *out);
164 int key_SU_encode (int ch, char *out);
166 extern Res common_resource;
173 * Revision 1.72 2001-11-19 23:08:29 adam
174 * Added const qualifier for name parameter of key_SU_decode.
176 * Revision 1.71 2001/11/19 23:05:22 adam
177 * Added a few prototypes.
179 * Revision 1.70 2000/12/05 10:01:44 adam
180 * Fixed bug regarding user-defined attribute sets.
182 * Revision 1.69 2000/03/20 19:08:36 adam
183 * Added remote record import using Z39.50 extended services and Segment
186 * Revision 1.68 2000/02/24 11:00:07 adam
187 * Fixed bug: indexer would run forever when lock dir was non-existant.
189 * Revision 1.67 1999/11/30 13:48:03 adam
190 * Improved installation. Updated for inclusion of YAZ header files.
192 * Revision 1.66 1999/07/14 13:21:34 heikki
193 * Added isam-d files. Compiles (almost) clean. Doesn't work at all
195 * Revision 1.65 1999/07/14 10:59:26 adam
196 * Changed functions isc_getmethod, isams_getmethod.
197 * Improved fatal error handling (such as missing EXPLAIN schema).
199 * Revision 1.64 1999/06/30 15:07:23 heikki
202 * Revision 1.63 1999/05/26 07:49:13 adam
205 * Revision 1.62 1999/05/12 13:08:06 adam
206 * First version of ISAMS.
208 * Revision 1.61 1999/03/09 16:27:49 adam
209 * More work on SDRKit integration.
211 * Revision 1.60 1998/10/16 08:14:31 adam
212 * Updated record control system.
214 * Revision 1.59 1998/06/08 14:43:11 adam
215 * Added suport for EXPLAIN Proxy servers - added settings databasePath
216 * and explainDatabase to facilitate this. Increased maximum number
217 * of databases and attributes in one register.
219 * Revision 1.58 1998/05/20 10:12:16 adam
220 * Implemented automatic EXPLAIN database maintenance.
221 * Modified Zebra to work with ASN.1 compiled version of YAZ.
223 * Revision 1.57 1998/03/05 08:45:12 adam
224 * New result set model and modular ranking system. Moved towards
225 * descent server API. System information stored as "SGML" records.
227 * Revision 1.56 1998/01/12 15:04:08 adam
228 * The test option (-s) only uses read-lock (and not write lock).
230 * Revision 1.55 1997/10/27 14:33:04 adam
231 * Moved towards generic character mapping depending on "structure"
232 * field in abstract syntax file. Fixed a few memory leaks. Fixed
233 * bug with negative integers when doing searches with relational
236 * Revision 1.54 1997/09/29 09:08:36 adam
237 * Revised locking system to be thread safe for the server.
239 * Revision 1.53 1997/09/25 14:54:43 adam
240 * WIN32 files lock support.
242 * Revision 1.52 1997/09/22 12:39:06 adam
243 * Added get_pos method for the ranked result sets.
245 * Revision 1.51 1997/09/18 08:59:19 adam
246 * Extra generic handle for the character mapping routines.
248 * Revision 1.50 1997/09/17 12:19:13 adam
249 * Zebra version corresponds to YAZ version 1.4.
250 * Changed Zebra server so that it doesn't depend on global common_resource.
252 * Revision 1.49 1997/09/05 15:30:08 adam
253 * Changed prototype for chr_map_input - added const.
254 * Added support for C++, headers uses extern "C" for public definitions.
256 * Revision 1.48 1997/02/12 20:39:45 adam
257 * Implemented options -f <n> that limits the log to the first <n>
259 * Changed some log messages also.
261 * Revision 1.47 1996/12/23 15:30:44 adam
262 * Work on truncation.
263 * Bug fix: result sets weren't deleted after server shut down.
265 * Revision 1.46 1996/11/08 11:10:19 adam
266 * Buffers used during file match got bigger.
267 * Compressed ISAM support everywhere.
268 * Bug fixes regarding masking characters in queries.
269 * Redesigned Regexp-2 queries.
271 * Revision 1.45 1996/10/29 14:09:42 adam
272 * Use of cisam system - enabled if setting isamc is 1.
274 * Revision 1.44 1996/06/06 12:08:40 quinn
275 * Added showRecord function
277 * Revision 1.43 1996/06/04 10:18:12 adam
278 * Search/scan uses character mapping module.
280 * Revision 1.42 1996/06/04 08:20:16 quinn
283 * Revision 1.41 1996/06/04 07:54:55 quinn
286 * Revision 1.40 1996/05/31 09:06:58 quinn
287 * Work on character-set handling
289 * Revision 1.39 1996/05/14 14:04:33 adam
290 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
293 * Revision 1.38 1996/04/12 07:02:23 adam
294 * File update of single files.
296 * Revision 1.37 1996/03/26 16:01:13 adam
297 * New setting lockPath: directory of various lock files.
299 * Revision 1.36 1996/03/21 14:50:09 adam
300 * File update uses modify-time instead of change-time.
302 * Revision 1.35 1996/02/12 18:45:36 adam
303 * New fileVerboseFlag in record group control.
305 * Revision 1.34 1995/12/11 11:43:29 adam
306 * Locking based on fcntl instead of flock.
307 * Setting commitEnable removed. Command line option -n can be used to
308 * prevent commit if commit setting is defined in the configuration file.
310 * Revision 1.33 1995/12/08 16:22:53 adam
311 * Work on update while servers are running. Three lock files introduced.
312 * The servers reload their registers when necessary, but they don't
313 * reestablish result sets yet.
315 * Revision 1.32 1995/12/07 17:38:46 adam
316 * Work locking mechanisms for concurrent updates/commit.
318 * Revision 1.31 1995/12/06 12:41:22 adam
319 * New command 'stat' for the index program.
320 * Filenames can be read from stdin by specifying '-'.
321 * Bug fix/enhancement of the transformation from terms to regular
322 * expressons in the search engine.
324 * Revision 1.30 1995/12/05 11:25:02 adam
325 * Include of zebraver.h.
327 * Revision 1.29 1995/11/28 09:09:40 adam
328 * Zebra config renamed.
329 * Use setting 'recordId' to identify record now.
330 * Bug fix in recindex.c: rec_release_blocks was invokeded even
331 * though the blocks were already released.
332 * File traversal properly deletes records when needed.
334 * Revision 1.28 1995/11/27 13:58:53 adam
335 * New option -t. storeStore data implemented in server.
337 * Revision 1.27 1995/11/25 10:24:06 adam
338 * More record fields - they are enumerated now.
339 * New options: flagStoreData flagStoreKey.
341 * Revision 1.26 1995/11/22 17:19:17 adam
342 * Record management uses the bfile system.
344 * Revision 1.25 1995/11/21 15:29:12 adam
345 * Config file 'base' read by default by both indexer and server.
347 * Revision 1.24 1995/11/21 15:01:15 adam
348 * New general match criteria implemented.
349 * New feature: document groups.
351 * Revision 1.23 1995/11/20 16:59:45 adam
352 * New update method: the 'old' keys are saved for each records.
354 * Revision 1.22 1995/11/20 11:56:26 adam
355 * Work on new traversal.
357 * Revision 1.21 1995/11/16 15:34:55 adam
358 * Uses new record management system in both indexer and server.
360 * Revision 1.20 1995/11/15 14:46:18 adam
361 * Started work on better record management system.
363 * Revision 1.19 1995/10/27 14:00:11 adam
364 * Implemented detection of database availability.
366 * Revision 1.18 1995/10/17 18:02:08 adam
367 * New feature: databases. Implemented as prefix to words in dictionary.
369 * Revision 1.17 1995/10/13 16:01:49 adam
372 * Revision 1.16 1995/10/10 12:24:38 adam
373 * Temporary sort files are compressed.
375 * Revision 1.15 1995/10/04 16:57:19 adam
376 * Key input and merge sort in one pass.
378 * Revision 1.14 1995/09/29 14:01:40 adam
381 * Revision 1.13 1995/09/28 14:22:56 adam
382 * Sort uses smaller temporary files.
384 * Revision 1.12 1995/09/28 12:10:32 adam
385 * Bug fixes. Field prefix used in queries.
387 * Revision 1.11 1995/09/27 12:22:28 adam
388 * More work on extract in record control.
389 * Field name is not in isam keys but in prefix in dictionary words.
391 * Revision 1.10 1995/09/14 07:48:23 adam
392 * Record control management.
394 * Revision 1.9 1995/09/11 13:09:33 adam
395 * More work on relevance feedback.
397 * Revision 1.8 1995/09/08 14:52:27 adam
398 * Minor changes. Dictionary is lower case now.
400 * Revision 1.7 1995/09/06 16:11:16 adam
401 * Option: only one word key per file.
403 * Revision 1.6 1995/09/05 15:28:39 adam
404 * More work on search engine.
406 * Revision 1.5 1995/09/04 12:33:42 adam
407 * Various cleanup. YAZ util used instead.
409 * Revision 1.4 1995/09/04 09:10:35 adam
410 * More work on index add/del/update.
411 * Merge sort implemented.
412 * Initial work on z39 server.
414 * Revision 1.3 1995/09/01 14:06:35 adam
415 * Split of work into more files.
417 * Revision 1.2 1995/09/01 10:30:24 adam
418 * More work on indexing. Not working yet.
420 * Revision 1.1 1995/08/31 14:50:24 adam
421 * New simple file index tool.