2 * Copyright (C) 1995-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.47 1996-12-23 15:30:44 adam
9 * Bug fix: result sets weren't deleted after server shut down.
11 * Revision 1.46 1996/11/08 11:10:19 adam
12 * Buffers used during file match got bigger.
13 * Compressed ISAM support everywhere.
14 * Bug fixes regarding masking characters in queries.
15 * Redesigned Regexp-2 queries.
17 * Revision 1.45 1996/10/29 14:09:42 adam
18 * Use of cisam system - enabled if setting isamc is 1.
20 * Revision 1.44 1996/06/06 12:08:40 quinn
21 * Added showRecord function
23 * Revision 1.43 1996/06/04 10:18:12 adam
24 * Search/scan uses character mapping module.
26 * Revision 1.42 1996/06/04 08:20:16 quinn
29 * Revision 1.41 1996/06/04 07:54:55 quinn
32 * Revision 1.40 1996/05/31 09:06:58 quinn
33 * Work on character-set handling
35 * Revision 1.39 1996/05/14 14:04:33 adam
36 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
39 * Revision 1.38 1996/04/12 07:02:23 adam
40 * File update of single files.
42 * Revision 1.37 1996/03/26 16:01:13 adam
43 * New setting lockPath: directory of various lock files.
45 * Revision 1.36 1996/03/21 14:50:09 adam
46 * File update uses modify-time instead of change-time.
48 * Revision 1.35 1996/02/12 18:45:36 adam
49 * New fileVerboseFlag in record group control.
51 * Revision 1.34 1995/12/11 11:43:29 adam
52 * Locking based on fcntl instead of flock.
53 * Setting commitEnable removed. Command line option -n can be used to
54 * prevent commit if commit setting is defined in the configuration file.
56 * Revision 1.33 1995/12/08 16:22:53 adam
57 * Work on update while servers are running. Three lock files introduced.
58 * The servers reload their registers when necessary, but they don't
59 * reestablish result sets yet.
61 * Revision 1.32 1995/12/07 17:38:46 adam
62 * Work locking mechanisms for concurrent updates/commit.
64 * Revision 1.31 1995/12/06 12:41:22 adam
65 * New command 'stat' for the index program.
66 * Filenames can be read from stdin by specifying '-'.
67 * Bug fix/enhancement of the transformation from terms to regular
68 * expressons in the search engine.
70 * Revision 1.30 1995/12/05 11:25:02 adam
71 * Include of zebraver.h.
73 * Revision 1.29 1995/11/28 09:09:40 adam
74 * Zebra config renamed.
75 * Use setting 'recordId' to identify record now.
76 * Bug fix in recindex.c: rec_release_blocks was invokeded even
77 * though the blocks were already released.
78 * File traversal properly deletes records when needed.
80 * Revision 1.28 1995/11/27 13:58:53 adam
81 * New option -t. storeStore data implemented in server.
83 * Revision 1.27 1995/11/25 10:24:06 adam
84 * More record fields - they are enumerated now.
85 * New options: flagStoreData flagStoreKey.
87 * Revision 1.26 1995/11/22 17:19:17 adam
88 * Record management uses the bfile system.
90 * Revision 1.25 1995/11/21 15:29:12 adam
91 * Config file 'base' read by default by both indexer and server.
93 * Revision 1.24 1995/11/21 15:01:15 adam
94 * New general match criteria implemented.
95 * New feature: document groups.
97 * Revision 1.23 1995/11/20 16:59:45 adam
98 * New update method: the 'old' keys are saved for each records.
100 * Revision 1.22 1995/11/20 11:56:26 adam
101 * Work on new traversal.
103 * Revision 1.21 1995/11/16 15:34:55 adam
104 * Uses new record management system in both indexer and server.
106 * Revision 1.20 1995/11/15 14:46:18 adam
107 * Started work on better record management system.
109 * Revision 1.19 1995/10/27 14:00:11 adam
110 * Implemented detection of database availability.
112 * Revision 1.18 1995/10/17 18:02:08 adam
113 * New feature: databases. Implemented as prefix to words in dictionary.
115 * Revision 1.17 1995/10/13 16:01:49 adam
118 * Revision 1.16 1995/10/10 12:24:38 adam
119 * Temporary sort files are compressed.
121 * Revision 1.15 1995/10/04 16:57:19 adam
122 * Key input and merge sort in one pass.
124 * Revision 1.14 1995/09/29 14:01:40 adam
127 * Revision 1.13 1995/09/28 14:22:56 adam
128 * Sort uses smaller temporary files.
130 * Revision 1.12 1995/09/28 12:10:32 adam
131 * Bug fixes. Field prefix used in queries.
133 * Revision 1.11 1995/09/27 12:22:28 adam
134 * More work on extract in record control.
135 * Field name is not in isam keys but in prefix in dictionary words.
137 * Revision 1.10 1995/09/14 07:48:23 adam
138 * Record control management.
140 * Revision 1.9 1995/09/11 13:09:33 adam
141 * More work on relevance feedback.
143 * Revision 1.8 1995/09/08 14:52:27 adam
144 * Minor changes. Dictionary is lower case now.
146 * Revision 1.7 1995/09/06 16:11:16 adam
147 * Option: only one word key per file.
149 * Revision 1.6 1995/09/05 15:28:39 adam
150 * More work on search engine.
152 * Revision 1.5 1995/09/04 12:33:42 adam
153 * Various cleanup. YAZ util used instead.
155 * Revision 1.4 1995/09/04 09:10:35 adam
156 * More work on index add/del/update.
157 * Merge sort implemented.
158 * Initial work on z39 server.
160 * Revision 1.3 1995/09/01 14:06:35 adam
161 * Split of work into more files.
163 * Revision 1.2 1995/09/01 10:30:24 adam
164 * More work on indexing. Not working yet.
166 * Revision 1.1 1995/08/31 14:50:24 adam
167 * New simple file index tool.
171 #include <zebraver.h>
172 #include <zebrautl.h>
178 #define IT_MAX_WORD 256
179 #define IT_KEY_HAVE_SEQNO 1
180 #define IT_KEY_HAVE_FIELD 0
189 enum dirsKind { dirs_dir, dirs_file };
216 void getFnameTmp (char *fname, int no);
218 struct dirs_info *dirs_open (Dict dict, const char *rep);
219 struct dirs_info *dirs_fopen (Dict dict, const char *path);
220 struct dirs_entry *dirs_read (struct dirs_info *p);
221 struct dirs_entry *dirs_last (struct dirs_info *p);
222 void dirs_mkdir (struct dirs_info *p, const char *src, time_t mtime);
223 void dirs_rmdir (struct dirs_info *p, const char *src);
224 void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime);
225 void dirs_del (struct dirs_info *p, const char *src);
226 void dirs_free (struct dirs_info **pp);
228 struct dir_entry *dir_open (const char *rep);
229 void dir_sort (struct dir_entry *e);
230 void dir_free (struct dir_entry **e_p);
232 void repositoryUpdate (struct recordGroup *rGroup);
233 void repositoryAdd (struct recordGroup *rGroup);
234 void repositoryDelete (struct recordGroup *rGroup);
235 void repositoryShow (struct recordGroup *rGroup);
237 void key_open (int mem);
238 int key_close (void);
239 int key_compare (const void *p1, const void *p2);
240 int key_compare_it (const void *p1, const void *p2);
241 int key_qsort_compare (const void *p1, const void *p2);
242 void key_logdump (int mask, const void *p);
243 void inv_prstat (void);
244 void key_input (int nkeys, int cache);
245 ISAMC_M key_isamc_m (void);
246 int merge_sort (char **buf, int from, int to);
248 #define FNAME_DICT "dict"
249 #define FNAME_ISAM "isam"
250 #define FNAME_ISAMC "isamc"
251 #define FNAME_CONFIG "zebra.cfg"
253 #define GMATCH_DICT "gmatch"
254 #define FMATCH_DICT "fmatch"
256 struct strtab *strtab_mk (void);
257 int strtab_src (struct strtab *t, const char *name, void ***infop);
258 void strtab_del (struct strtab *t,
259 void (*func)(const char *name, void *info, void *data),
261 int index_char_cvt (int c);
262 int index_word_prefix (char *string, int attset_ordinal,
263 int local_attribute, const char *databaseName);
265 int fileExtract (SYSNO *sysno, const char *fname,
266 const struct recordGroup *rGroup, int deleteFlag);
268 void rec_prstat (void);
270 void zebraLockPrefix (char *pathPrefix);
272 void zebraIndexLockMsg (const char *str);
273 void zebraIndexUnlock (void);
274 void zebraIndexLock (int commitNow);
275 int zebraIndexWait (int commitPhase);
277 #define FNAME_MAIN_LOCK "zebraidx.LCK"
278 #define FNAME_COMMIT_LOCK "zebracmt.LCK"
279 #define FNAME_ORG_LOCK "zebraorg.LCK"
280 #define FNAME_TOUCH_TIME "zebraidx.time"
282 int zebraLock (int fd, int wr);
283 int zebraLockNB (int fd, int wr);
284 int zebraUnlock (int fd);
286 void init_charmap(void);
287 char **map_chrs_input(char **from, int len);
288 const char *map_chrs_output(const char **from);