2 * Copyright (C) 1995-1997, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.52 1997-09-22 12:39:06 adam
8 * Added get_pos method for the ranked result sets.
10 * Revision 1.51 1997/09/18 08:59:19 adam
11 * Extra generic handle for the character mapping routines.
13 * Revision 1.50 1997/09/17 12:19:13 adam
14 * Zebra version corresponds to YAZ version 1.4.
15 * Changed Zebra server so that it doesn't depend on global common_resource.
17 * Revision 1.49 1997/09/05 15:30:08 adam
18 * Changed prototype for chr_map_input - added const.
19 * Added support for C++, headers uses extern "C" for public definitions.
21 * Revision 1.48 1997/02/12 20:39:45 adam
22 * Implemented options -f <n> that limits the log to the first <n>
24 * Changed some log messages also.
26 * Revision 1.47 1996/12/23 15:30:44 adam
28 * Bug fix: result sets weren't deleted after server shut down.
30 * Revision 1.46 1996/11/08 11:10:19 adam
31 * Buffers used during file match got bigger.
32 * Compressed ISAM support everywhere.
33 * Bug fixes regarding masking characters in queries.
34 * Redesigned Regexp-2 queries.
36 * Revision 1.45 1996/10/29 14:09:42 adam
37 * Use of cisam system - enabled if setting isamc is 1.
39 * Revision 1.44 1996/06/06 12:08:40 quinn
40 * Added showRecord function
42 * Revision 1.43 1996/06/04 10:18:12 adam
43 * Search/scan uses character mapping module.
45 * Revision 1.42 1996/06/04 08:20:16 quinn
48 * Revision 1.41 1996/06/04 07:54:55 quinn
51 * Revision 1.40 1996/05/31 09:06:58 quinn
52 * Work on character-set handling
54 * Revision 1.39 1996/05/14 14:04:33 adam
55 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
58 * Revision 1.38 1996/04/12 07:02:23 adam
59 * File update of single files.
61 * Revision 1.37 1996/03/26 16:01:13 adam
62 * New setting lockPath: directory of various lock files.
64 * Revision 1.36 1996/03/21 14:50:09 adam
65 * File update uses modify-time instead of change-time.
67 * Revision 1.35 1996/02/12 18:45:36 adam
68 * New fileVerboseFlag in record group control.
70 * Revision 1.34 1995/12/11 11:43:29 adam
71 * Locking based on fcntl instead of flock.
72 * Setting commitEnable removed. Command line option -n can be used to
73 * prevent commit if commit setting is defined in the configuration file.
75 * Revision 1.33 1995/12/08 16:22:53 adam
76 * Work on update while servers are running. Three lock files introduced.
77 * The servers reload their registers when necessary, but they don't
78 * reestablish result sets yet.
80 * Revision 1.32 1995/12/07 17:38:46 adam
81 * Work locking mechanisms for concurrent updates/commit.
83 * Revision 1.31 1995/12/06 12:41:22 adam
84 * New command 'stat' for the index program.
85 * Filenames can be read from stdin by specifying '-'.
86 * Bug fix/enhancement of the transformation from terms to regular
87 * expressons in the search engine.
89 * Revision 1.30 1995/12/05 11:25:02 adam
90 * Include of zebraver.h.
92 * Revision 1.29 1995/11/28 09:09:40 adam
93 * Zebra config renamed.
94 * Use setting 'recordId' to identify record now.
95 * Bug fix in recindex.c: rec_release_blocks was invokeded even
96 * though the blocks were already released.
97 * File traversal properly deletes records when needed.
99 * Revision 1.28 1995/11/27 13:58:53 adam
100 * New option -t. storeStore data implemented in server.
102 * Revision 1.27 1995/11/25 10:24:06 adam
103 * More record fields - they are enumerated now.
104 * New options: flagStoreData flagStoreKey.
106 * Revision 1.26 1995/11/22 17:19:17 adam
107 * Record management uses the bfile system.
109 * Revision 1.25 1995/11/21 15:29:12 adam
110 * Config file 'base' read by default by both indexer and server.
112 * Revision 1.24 1995/11/21 15:01:15 adam
113 * New general match criteria implemented.
114 * New feature: document groups.
116 * Revision 1.23 1995/11/20 16:59:45 adam
117 * New update method: the 'old' keys are saved for each records.
119 * Revision 1.22 1995/11/20 11:56:26 adam
120 * Work on new traversal.
122 * Revision 1.21 1995/11/16 15:34:55 adam
123 * Uses new record management system in both indexer and server.
125 * Revision 1.20 1995/11/15 14:46:18 adam
126 * Started work on better record management system.
128 * Revision 1.19 1995/10/27 14:00:11 adam
129 * Implemented detection of database availability.
131 * Revision 1.18 1995/10/17 18:02:08 adam
132 * New feature: databases. Implemented as prefix to words in dictionary.
134 * Revision 1.17 1995/10/13 16:01:49 adam
137 * Revision 1.16 1995/10/10 12:24:38 adam
138 * Temporary sort files are compressed.
140 * Revision 1.15 1995/10/04 16:57:19 adam
141 * Key input and merge sort in one pass.
143 * Revision 1.14 1995/09/29 14:01:40 adam
146 * Revision 1.13 1995/09/28 14:22:56 adam
147 * Sort uses smaller temporary files.
149 * Revision 1.12 1995/09/28 12:10:32 adam
150 * Bug fixes. Field prefix used in queries.
152 * Revision 1.11 1995/09/27 12:22:28 adam
153 * More work on extract in record control.
154 * Field name is not in isam keys but in prefix in dictionary words.
156 * Revision 1.10 1995/09/14 07:48:23 adam
157 * Record control management.
159 * Revision 1.9 1995/09/11 13:09:33 adam
160 * More work on relevance feedback.
162 * Revision 1.8 1995/09/08 14:52:27 adam
163 * Minor changes. Dictionary is lower case now.
165 * Revision 1.7 1995/09/06 16:11:16 adam
166 * Option: only one word key per file.
168 * Revision 1.6 1995/09/05 15:28:39 adam
169 * More work on search engine.
171 * Revision 1.5 1995/09/04 12:33:42 adam
172 * Various cleanup. YAZ util used instead.
174 * Revision 1.4 1995/09/04 09:10:35 adam
175 * More work on index add/del/update.
176 * Merge sort implemented.
177 * Initial work on z39 server.
179 * Revision 1.3 1995/09/01 14:06:35 adam
180 * Split of work into more files.
182 * Revision 1.2 1995/09/01 10:30:24 adam
183 * More work on indexing. Not working yet.
185 * Revision 1.1 1995/08/31 14:50:24 adam
186 * New simple file index tool.
190 #include <zebraver.h>
191 #include <zebrautl.h>
198 #define IT_MAX_WORD 256
199 #define IT_KEY_HAVE_SEQNO 1
200 #define IT_KEY_HAVE_FIELD 0
209 enum dirsKind { dirs_dir, dirs_file };
233 int fileVerboseLimit;
238 void getFnameTmp (char *fname, int no);
240 struct dirs_info *dirs_open (Dict dict, const char *rep);
241 struct dirs_info *dirs_fopen (Dict dict, const char *path);
242 struct dirs_entry *dirs_read (struct dirs_info *p);
243 struct dirs_entry *dirs_last (struct dirs_info *p);
244 void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime);
245 void dirs_rmdir (struct dirs_info *p, const char *src);
246 void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime);
247 void dirs_del (struct dirs_info *p, const char *src);
248 void dirs_free (struct dirs_info **pp);
250 struct dir_entry *dir_open (const char *rep);
251 void dir_sort (struct dir_entry *e);
252 void dir_free (struct dir_entry **e_p);
254 void repositoryUpdate (struct recordGroup *rGroup);
255 void repositoryAdd (struct recordGroup *rGroup);
256 void repositoryDelete (struct recordGroup *rGroup);
257 void repositoryShow (struct recordGroup *rGroup);
259 void key_open (BFiles bfs, int mem);
260 int key_close (void);
261 int key_compare (const void *p1, const void *p2);
262 int key_get_pos (const void *p);
263 int key_compare_it (const void *p1, const void *p2);
264 int key_qsort_compare (const void *p1, const void *p2);
265 void key_logdump (int mask, const void *p);
266 void inv_prstat (BFiles bfs);
267 void key_input (BFiles bfs, int nkeys, int cache);
268 ISAMC_M key_isamc_m (Res res);
269 int merge_sort (char **buf, int from, int to);
271 #define FNAME_DICT "dict"
272 #define FNAME_ISAM "isam"
273 #define FNAME_ISAMC "isamc"
274 #define FNAME_CONFIG "zebra.cfg"
276 #define GMATCH_DICT "gmatch"
277 #define FMATCH_DICT "fmatch"
279 struct strtab *strtab_mk (void);
280 int strtab_src (struct strtab *t, const char *name, void ***infop);
281 void strtab_del (struct strtab *t,
282 void (*func)(const char *name, void *info, void *data),
284 int index_char_cvt (int c);
285 int index_word_prefix (char *string, int attset_ordinal,
286 int local_attribute, const char *databaseName);
288 int fileExtract (SYSNO *sysno, const char *fname,
289 const struct recordGroup *rGroup, int deleteFlag);
291 void rec_prstat (void);
293 void zebraLockPrefix (Res res, char *pathPrefix);
295 void zebraIndexLockMsg (const char *str);
296 void zebraIndexUnlock (void);
297 void zebraIndexLock (BFiles bfs, int commitNow, const char *rval);
298 int zebraIndexWait (int commitPhase);
300 #define FNAME_MAIN_LOCK "zebraidx.LCK"
301 #define FNAME_COMMIT_LOCK "zebracmt.LCK"
302 #define FNAME_ORG_LOCK "zebraorg.LCK"
303 #define FNAME_TOUCH_TIME "zebraidx.time"
305 int zebraLock (int fd, int wr);
306 int zebraLockNB (int fd, int wr);
307 int zebraUnlock (int fd);
309 void init_charmap(Res res);
310 const char **map_chrs_input(void *vp, const char **from, int len);
311 const char *map_chrs_output(const char **from);
313 extern Res common_resource;