2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.23 1995-11-30 08:34:31 adam
8 * Started work on commit facility.
9 * Changed a few malloc/free to xmalloc/xfree.
11 * Revision 1.22 1995/11/28 09:09:42 adam
12 * Zebra config renamed.
13 * Use setting 'recordId' to identify record now.
14 * Bug fix in recindex.c: rec_release_blocks was invokeded even
15 * though the blocks were already released.
16 * File traversal properly deletes records when needed.
18 * Revision 1.21 1995/11/27 14:27:39 adam
19 * Renamed 'update' command to 'dir'.
21 * Revision 1.20 1995/11/27 13:58:53 adam
22 * New option -t. storeStore data implemented in server.
24 * Revision 1.19 1995/11/25 10:24:06 adam
25 * More record fields - they are enumerated now.
26 * New options: flagStoreData flagStoreKey.
28 * Revision 1.18 1995/11/22 17:19:17 adam
29 * Record management uses the bfile system.
31 * Revision 1.17 1995/11/21 15:01:16 adam
32 * New general match criteria implemented.
33 * New feature: document groups.
35 * Revision 1.16 1995/11/20 11:56:27 adam
36 * Work on new traversal.
38 * Revision 1.15 1995/11/01 16:25:51 quinn
39 * *** empty log message ***
41 * Revision 1.14 1995/10/17 18:02:09 adam
42 * New feature: databases. Implemented as prefix to words in dictionary.
44 * Revision 1.13 1995/10/10 12:24:39 adam
45 * Temporary sort files are compressed.
47 * Revision 1.12 1995/10/04 16:57:20 adam
48 * Key input and merge sort in one pass.
50 * Revision 1.11 1995/09/29 14:01:45 adam
53 * Revision 1.10 1995/09/28 14:22:57 adam
54 * Sort uses smaller temporary files.
56 * Revision 1.9 1995/09/14 07:48:24 adam
57 * Record control management.
59 * Revision 1.8 1995/09/06 16:11:18 adam
60 * Option: only one word key per file.
62 * Revision 1.7 1995/09/05 15:28:39 adam
63 * More work on search engine.
65 * Revision 1.6 1995/09/04 12:33:43 adam
66 * Various cleanup. YAZ util used instead.
68 * Revision 1.5 1995/09/04 09:10:39 adam
69 * More work on index add/del/update.
70 * Merge sort implemented.
71 * Initial work on z39 server.
73 * Revision 1.4 1995/09/01 14:06:36 adam
74 * Split of work into more files.
76 * Revision 1.3 1995/09/01 10:57:07 adam
79 * Revision 1.2 1995/09/01 10:30:24 adam
80 * More work on indexing. Not working yet.
82 * Revision 1.1 1995/08/31 14:50:24 adam
83 * New simple file index tool.
95 size_t mem_max = 4*1024*1024;
96 extern char *data1_tabpath;
98 int main (int argc, char **argv)
103 char *configName = NULL;
105 int key_open_flag = 0;
107 struct recordGroup rGroupDef;
109 rGroupDef.groupName = NULL;
110 rGroupDef.databaseName = NULL;
111 rGroupDef.path = NULL;
112 rGroupDef.recordId = NULL;
113 rGroupDef.recordType = NULL;
114 rGroupDef.flagStoreData = -1;
115 rGroupDef.flagStoreKeys = -1;
120 fprintf (stderr, "zebraidx [options] command <dir> ...\n"
122 " update <dir> Update index with files below <dir>.\n"
123 " If <dir> is empty filenames are read from stdin.\n"
124 " delete <dir> Delete index with files below <dir>.\n"
126 " -t <type> Index files as <type> (grs or text).\n"
127 " -c <config> Read configuration file <config>.\n"
128 " -g <group> Index files according to group settings.\n"
129 " -d <database> Records belong to Z39.50 database <database>.\n"
130 " -m <mbytes> Use <mbytes> before flushing keys to disk.\n"
131 " -v <level> Set logging to <level>.\n");
134 while ((ret = options ("t:c:g:d:m:v:l:", argv, argc, &arg)) != -2)
138 if(cmd == 0) /* command */
140 if (!strcmp (arg, "update"))
142 else if (!strcmp (arg, "del") || !strcmp(arg, "delete"))
146 logf (LOG_FATAL, "Unknown command: %s", arg);
152 struct recordGroup rGroup;
154 memcpy (&rGroup, &rGroupDef, sizeof(rGroup));
155 if (!common_resource)
157 common_resource = res_open (configName ?
158 configName : FNAME_CONFIG);
159 if (!common_resource)
161 logf (LOG_FATAL, "Cannot open resource `%s'",
165 data1_tabpath = res_get (common_resource, "profilePath");
166 assert (data1_tabpath);
175 repositoryUpdate (&rGroup);
177 repositoryDelete (&rGroup);
183 log_init (log_mask_str(arg), prog, NULL);
187 mem_max = 1024*1024*atoi(arg);
191 rGroupDef.databaseName = arg;
195 rGroupDef.groupName = arg;
200 rGroupDef.recordType = arg;
205 logf (LOG_FATAL, "Unknown option '-%s'", arg);
211 nsections = key_close ();
214 logf (LOG_LOG, "Merging with index");
215 key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections, 60);