2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.26 1995-12-06 12:41:23 adam
8 * New command 'stat' for the index program.
9 * Filenames can be read from stdin by specifying '-'.
10 * Bug fix/enhancement of the transformation from terms to regular
11 * expressons in the search engine.
13 * Revision 1.25 1995/12/01 16:24:39 adam
14 * Commit files use separate meta file area.
16 * Revision 1.24 1995/11/30 17:01:38 adam
17 * New setting commitCache: points to commit directories/files.
18 * New command commit: commits at the end of a zebraidx run.
20 * Revision 1.23 1995/11/30 08:34:31 adam
21 * Started work on commit facility.
22 * Changed a few malloc/free to xmalloc/xfree.
24 * Revision 1.22 1995/11/28 09:09:42 adam
25 * Zebra config renamed.
26 * Use setting 'recordId' to identify record now.
27 * Bug fix in recindex.c: rec_release_blocks was invokeded even
28 * though the blocks were already released.
29 * File traversal properly deletes records when needed.
31 * Revision 1.21 1995/11/27 14:27:39 adam
32 * Renamed 'update' command to 'dir'.
34 * Revision 1.20 1995/11/27 13:58:53 adam
35 * New option -t. storeStore data implemented in server.
37 * Revision 1.19 1995/11/25 10:24:06 adam
38 * More record fields - they are enumerated now.
39 * New options: flagStoreData flagStoreKey.
41 * Revision 1.18 1995/11/22 17:19:17 adam
42 * Record management uses the bfile system.
44 * Revision 1.17 1995/11/21 15:01:16 adam
45 * New general match criteria implemented.
46 * New feature: document groups.
48 * Revision 1.16 1995/11/20 11:56:27 adam
49 * Work on new traversal.
51 * Revision 1.15 1995/11/01 16:25:51 quinn
52 * *** empty log message ***
54 * Revision 1.14 1995/10/17 18:02:09 adam
55 * New feature: databases. Implemented as prefix to words in dictionary.
57 * Revision 1.13 1995/10/10 12:24:39 adam
58 * Temporary sort files are compressed.
60 * Revision 1.12 1995/10/04 16:57:20 adam
61 * Key input and merge sort in one pass.
63 * Revision 1.11 1995/09/29 14:01:45 adam
66 * Revision 1.10 1995/09/28 14:22:57 adam
67 * Sort uses smaller temporary files.
69 * Revision 1.9 1995/09/14 07:48:24 adam
70 * Record control management.
72 * Revision 1.8 1995/09/06 16:11:18 adam
73 * Option: only one word key per file.
75 * Revision 1.7 1995/09/05 15:28:39 adam
76 * More work on search engine.
78 * Revision 1.6 1995/09/04 12:33:43 adam
79 * Various cleanup. YAZ util used instead.
81 * Revision 1.5 1995/09/04 09:10:39 adam
82 * More work on index add/del/update.
83 * Merge sort implemented.
84 * Initial work on z39 server.
86 * Revision 1.4 1995/09/01 14:06:36 adam
87 * Split of work into more files.
89 * Revision 1.3 1995/09/01 10:57:07 adam
92 * Revision 1.2 1995/09/01 10:30:24 adam
93 * More work on indexing. Not working yet.
95 * Revision 1.1 1995/08/31 14:50:24 adam
96 * New simple file index tool.
103 #include <alexutil.h>
108 size_t mem_max = 4*1024*1024;
109 extern char *data1_tabpath;
111 int main (int argc, char **argv)
116 char *configName = NULL;
119 struct recordGroup rGroupDef;
121 rGroupDef.groupName = NULL;
122 rGroupDef.databaseName = NULL;
123 rGroupDef.path = NULL;
124 rGroupDef.recordId = NULL;
125 rGroupDef.recordType = NULL;
126 rGroupDef.flagStoreData = -1;
127 rGroupDef.flagStoreKeys = -1;
132 fprintf (stderr, "zebraidx [options] command <dir> ...\n"
134 " update <dir> Update index with files below <dir>.\n"
135 " If <dir> is empty filenames are read from stdin.\n"
136 " delete <dir> Delete index with files below <dir>.\n"
138 " -t <type> Index files as <type> (grs or text).\n"
139 " -c <config> Read configuration file <config>.\n"
140 " -g <group> Index files according to group settings.\n"
141 " -d <database> Records belong to Z39.50 database <database>.\n"
142 " -m <mbytes> Use <mbytes> before flushing keys to disk.\n"
143 " -v <level> Set logging to <level>.\n");
146 while ((ret = options ("t:c:g:d:m:v:", argv, argc, &arg)) != -2)
150 if(cmd == 0) /* command */
152 if (!common_resource)
155 common_resource = res_open (configName ?
156 configName : FNAME_CONFIG);
157 if (!common_resource)
159 logf (LOG_FATAL, "Cannot open resource `%s'",
163 data1_tabpath = res_get (common_resource, "profilePath");
164 rval = res_get (common_resource, "commitEnable");
165 if (rval && atoi(rval))
168 if (!strcmp (arg, "update"))
170 else if (!strcmp (arg, "del") || !strcmp(arg, "delete"))
172 else if (!strcmp (arg, "commit"))
174 logf (LOG_LOG, "Commit");
177 else if (!strcmp (arg, "stat") || !strcmp (arg, "status"))
183 logf (LOG_FATAL, "Unknown command: %s", arg);
189 struct recordGroup rGroup;
191 memcpy (&rGroup, &rGroupDef, sizeof(rGroup));
196 logf (LOG_LOG, "Updating %s", rGroup.path);
197 repositoryUpdate (&rGroup);
201 logf (LOG_LOG, "Deleting %s", rGroup.path);
202 repositoryDelete (&rGroup);
205 nsections = key_close ();
208 logf (LOG_LOG, "Merging with index");
209 key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections,
216 log_init (log_mask_str(arg), prog, NULL);
220 mem_max = 1024*1024*atoi(arg);
224 rGroupDef.databaseName = arg;
228 rGroupDef.groupName = arg;
233 rGroupDef.recordType = arg;
236 logf (LOG_FATAL, "Unknown option '-%s'", arg);