2 * Copyright (C) 1994-2002, Index Data
5 * $Id: main.c,v 1.86 2002-04-15 13:48:10 adam Exp $
16 #include <yaz/data1.h>
21 int main (int argc, char **argv)
28 int disableCommit = 0;
33 struct recordGroup rGroupDef;
41 sprintf(nbuf, "%.40s(%d)", *argv, getpid());
42 yaz_log_init_prefix (nbuf);
45 rGroupDef.groupName = NULL;
46 rGroupDef.databaseName = NULL;
47 rGroupDef.path = NULL;
48 rGroupDef.recordId = NULL;
49 rGroupDef.recordType = NULL;
50 rGroupDef.flagStoreData = -1;
51 rGroupDef.flagStoreKeys = -1;
53 rGroupDef.databaseNamePath = 0;
54 rGroupDef.explainDatabase = 0;
55 rGroupDef.fileVerboseLimit = 100000;
60 fprintf (stderr, "%s [options] command <dir> ...\n"
62 " update <dir> Update index with files below <dir>.\n"
63 " If <dir> is empty filenames are read from stdin.\n"
64 " delete <dir> Delete index with files below <dir>.\n"
65 " commit Commit changes\n"
66 " clean Clean shadow files\n"
68 " -t <type> Index files as <type> (grs or text).\n"
69 " -c <config> Read configuration file <config>.\n"
70 " -g <group> Index files according to group settings.\n"
71 " -d <database> Records belong to Z39.50 database <database>.\n"
72 " -m <mbytes> Use <mbytes> before flushing keys to disk.\n"
73 " -n Don't use shadow system.\n"
74 " -s Show analysis on stdout, but do no work.\n"
75 " -v <level> Set logging to <level>.\n"
76 " -l <file> Write log to <file>.\n"
77 " -f <n> Display information for the first <n> records.\n"
78 " -V Show version.\n", *argv
82 while ((ret = options ("sVt:c:g:d:m:v:nf:l:"
83 , argv, argc, &arg)) != -2)
87 if(cmd == 0) /* command */
92 logf (LOG_LOG, "Z'mbol version %s %s",
95 logf (LOG_LOG, "Zebra version %s %s",
98 zs = zebra_start (configName ? configName : "zebra.cfg");
101 zh = zebra_open (zs);
103 zebra_shadow_enable (zh, 0);
105 if (rGroupDef.databaseName)
107 if (zebra_select_database (zh, rGroupDef.databaseName))
112 if (zebra_select_database (zh, "Default"))
116 if (!strcmp (arg, "update"))
118 else if (!strcmp (arg, "update1"))
120 else if (!strcmp (arg, "update2"))
122 else if (!strcmp (arg, "dump"))
124 else if (!strcmp (arg, "del") || !strcmp(arg, "delete"))
126 else if (!strcmp (arg, "init"))
130 else if (!strcmp (arg, "commit"))
134 else if (!strcmp (arg, "clean"))
138 else if (!strcmp (arg, "stat") || !strcmp (arg, "status"))
142 else if (!strcmp (arg, "compact"))
148 logf (LOG_FATAL, "unknown command: %s", arg);
154 rGroupDef.path = arg;
155 zebra_set_group (zh, &rGroupDef);
156 zebra_begin_trans (zh);
161 zebra_repository_update (zh);
164 zebra_repository_delete (zh);
167 logf (LOG_LOG, "dumping %s", rGroupDef.path);
168 zebra_repository_show (zh);
175 zebra_end_trans (zh);
176 log_event_end (NULL, NULL);
182 fprintf (stderr, "Z'mbol %s %s\n", ZEBRAVER, ZEBRADATE);
184 fprintf (stderr, "Zebra %s %s\n", ZEBRAVER, ZEBRADATE);
186 fprintf (stderr, " (C) 1994-2002, Index Data ApS\n");
189 fprintf (stderr, " WIN32 Debug\n");
191 fprintf (stderr, " WIN32 Release\n");
195 fprintf (stderr, "libbzip2\n"
196 " (C) 1996-1999 Julian R Seward. All rights reserved.\n");
200 yaz_log_init_level (yaz_log_mask_str(arg));
202 yaz_log_init_file (arg);
204 mem_max = 1024*1024*atoi(arg);
206 rGroupDef.databaseName = arg;
208 rGroupDef.flagRw = 0;
210 rGroupDef.groupName = arg;
212 rGroupDef.fileVerboseLimit = atoi(arg);
216 rGroupDef.recordType = arg;
220 logf (LOG_WARN, "unknown option '-%s'", arg);