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