2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.24 1995-11-30 17:01:38 adam
8 * New setting commitCache: points to commit directories/files.
9 * New command commit: commits at the end of a zebraidx run.
11 * Revision 1.23 1995/11/30 08:34:31 adam
12 * Started work on commit facility.
13 * Changed a few malloc/free to xmalloc/xfree.
15 * Revision 1.22 1995/11/28 09:09:42 adam
16 * Zebra config renamed.
17 * Use setting 'recordId' to identify record now.
18 * Bug fix in recindex.c: rec_release_blocks was invokeded even
19 * though the blocks were already released.
20 * File traversal properly deletes records when needed.
22 * Revision 1.21 1995/11/27 14:27:39 adam
23 * Renamed 'update' command to 'dir'.
25 * Revision 1.20 1995/11/27 13:58:53 adam
26 * New option -t. storeStore data implemented in server.
28 * Revision 1.19 1995/11/25 10:24:06 adam
29 * More record fields - they are enumerated now.
30 * New options: flagStoreData flagStoreKey.
32 * Revision 1.18 1995/11/22 17:19:17 adam
33 * Record management uses the bfile system.
35 * Revision 1.17 1995/11/21 15:01:16 adam
36 * New general match criteria implemented.
37 * New feature: document groups.
39 * Revision 1.16 1995/11/20 11:56:27 adam
40 * Work on new traversal.
42 * Revision 1.15 1995/11/01 16:25:51 quinn
43 * *** empty log message ***
45 * Revision 1.14 1995/10/17 18:02:09 adam
46 * New feature: databases. Implemented as prefix to words in dictionary.
48 * Revision 1.13 1995/10/10 12:24:39 adam
49 * Temporary sort files are compressed.
51 * Revision 1.12 1995/10/04 16:57:20 adam
52 * Key input and merge sort in one pass.
54 * Revision 1.11 1995/09/29 14:01:45 adam
57 * Revision 1.10 1995/09/28 14:22:57 adam
58 * Sort uses smaller temporary files.
60 * Revision 1.9 1995/09/14 07:48:24 adam
61 * Record control management.
63 * Revision 1.8 1995/09/06 16:11:18 adam
64 * Option: only one word key per file.
66 * Revision 1.7 1995/09/05 15:28:39 adam
67 * More work on search engine.
69 * Revision 1.6 1995/09/04 12:33:43 adam
70 * Various cleanup. YAZ util used instead.
72 * Revision 1.5 1995/09/04 09:10:39 adam
73 * More work on index add/del/update.
74 * Merge sort implemented.
75 * Initial work on z39 server.
77 * Revision 1.4 1995/09/01 14:06:36 adam
78 * Split of work into more files.
80 * Revision 1.3 1995/09/01 10:57:07 adam
83 * Revision 1.2 1995/09/01 10:30:24 adam
84 * More work on indexing. Not working yet.
86 * Revision 1.1 1995/08/31 14:50:24 adam
87 * New simple file index tool.
99 size_t mem_max = 4*1024*1024;
100 extern char *data1_tabpath;
102 int main (int argc, char **argv)
104 int commit_at_end = 0;
108 char *configName = NULL;
110 int key_open_flag = 0;
112 struct recordGroup rGroupDef;
114 rGroupDef.groupName = NULL;
115 rGroupDef.databaseName = NULL;
116 rGroupDef.path = NULL;
117 rGroupDef.recordId = NULL;
118 rGroupDef.recordType = NULL;
119 rGroupDef.flagStoreData = -1;
120 rGroupDef.flagStoreKeys = -1;
125 fprintf (stderr, "zebraidx [options] command <dir> ...\n"
127 " update <dir> Update index with files below <dir>.\n"
128 " If <dir> is empty filenames are read from stdin.\n"
129 " delete <dir> Delete index with files below <dir>.\n"
131 " -t <type> Index files as <type> (grs or text).\n"
132 " -c <config> Read configuration file <config>.\n"
133 " -g <group> Index files according to group settings.\n"
134 " -d <database> Records belong to Z39.50 database <database>.\n"
135 " -m <mbytes> Use <mbytes> before flushing keys to disk.\n"
136 " -v <level> Set logging to <level>.\n");
139 while ((ret = options ("t:c:g:d:m:v:", argv, argc, &arg)) != -2)
143 if(cmd == 0) /* command */
145 if (!common_resource)
147 common_resource = res_open (configName ?
148 configName : FNAME_CONFIG);
149 if (!common_resource)
151 logf (LOG_FATAL, "Cannot open resource `%s'",
155 data1_tabpath = res_get (common_resource, "profilePath");
156 bf_cache (res_get (common_resource, "commitCache"));
158 if (!strcmp (arg, "update"))
160 else if (!strcmp (arg, "del") || !strcmp(arg, "delete"))
162 else if (!strcmp (arg, "commit"))
166 logf (LOG_FATAL, "Unknown command: %s", arg);
172 struct recordGroup rGroup;
174 memcpy (&rGroup, &rGroupDef, sizeof(rGroup));
182 repositoryUpdate (&rGroup);
184 repositoryDelete (&rGroup);
190 log_init (log_mask_str(arg), prog, NULL);
194 mem_max = 1024*1024*atoi(arg);
198 rGroupDef.databaseName = arg;
202 rGroupDef.groupName = arg;
207 rGroupDef.recordType = arg;
210 logf (LOG_FATAL, "Unknown option '-%s'", arg);
216 nsections = key_close ();
219 logf (LOG_LOG, "Merging with index");
220 key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections, 60);
225 logf (LOG_LOG, "commiting");
226 bf_commit (res_get (common_resource, "commitCache"));