2 * Copyright (C) 1994-2002, Index Data
5 * $Id: main.c,v 1.82 2002-02-20 17:30:01 adam Exp $
16 #include <yaz/data1.h>
24 int main (int argc, char **argv)
31 int disableCommit = 0;
36 struct recordGroup rGroupDef;
44 sprintf(nbuf, "%.40s(%d)", *argv, getpid());
45 yaz_log_init_prefix (nbuf);
48 rGroupDef.groupName = NULL;
49 rGroupDef.databaseName = NULL;
50 rGroupDef.path = NULL;
51 rGroupDef.recordId = NULL;
52 rGroupDef.recordType = NULL;
53 rGroupDef.flagStoreData = -1;
54 rGroupDef.flagStoreKeys = -1;
56 rGroupDef.databaseNamePath = 0;
57 rGroupDef.explainDatabase = 0;
58 rGroupDef.fileVerboseLimit = 100000;
63 fprintf (stderr, "%s [options] command <dir> ...\n"
65 " update <dir> Update index with files below <dir>.\n"
66 " If <dir> is empty filenames are read from stdin.\n"
67 " delete <dir> Delete index with files below <dir>.\n"
68 " commit Commit changes\n"
69 " clean Clean shadow files\n"
71 " -t <type> Index files as <type> (grs or text).\n"
72 " -c <config> Read configuration file <config>.\n"
73 " -g <group> Index files according to group settings.\n"
74 " -d <database> Records belong to Z39.50 database <database>.\n"
75 " -m <mbytes> Use <mbytes> before flushing keys to disk.\n"
76 " -n Don't use shadow system.\n"
77 " -s Show analysis on stdout, but do no work.\n"
78 " -v <level> Set logging to <level>.\n"
79 " -l <file> Write log to <file>.\n"
80 " -f <n> Display information for the first <n> records.\n"
81 " -V Show version.\n", *argv
85 while ((ret = options ("sVt:c:g:d:m:v:nf:l:"
86 , argv, argc, &arg)) != -2)
90 if(cmd == 0) /* command */
95 logf (LOG_LOG, "zmbol version %s %s",
98 logf (LOG_LOG, "zebra version %s %s",
101 zs = zebra_start (configName ? configName : FNAME_CONFIG);
103 zh = zebra_open (zs);
105 if (!strcmp (arg, "update"))
107 else if (!strcmp (arg, "update1"))
109 else if (!strcmp (arg, "update2"))
111 else if (!strcmp (arg, "dump"))
113 else if (!strcmp (arg, "del") || !strcmp(arg, "delete"))
115 else if (!strcmp (arg, "init"))
119 else if (!strcmp (arg, "commit"))
123 else if (!strcmp (arg, "clean"))
127 else if (!strcmp (arg, "stat") || !strcmp (arg, "status"))
131 else if (!strcmp (arg, "compact"))
137 logf (LOG_FATAL, "unknown command: %s", arg);
143 memcpy (&zh->rGroup, &rGroupDef, sizeof(rGroupDef));
144 zebra_begin_trans (zh);
146 zh->rGroup.path = arg;
150 zebra_repository_update (zh);
153 zebra_repository_delete (zh);
156 logf (LOG_LOG, "dumping %s", zh->rGroup.path);
157 zebra_repository_show (zh);
164 zebra_end_trans (zh);
165 log_event_end (NULL, NULL);
171 fprintf (stderr, "Z'mbol %s %s\n", ZEBRAVER, ZEBRADATE);
173 fprintf (stderr, "Zebra %s %s\n", ZEBRAVER, ZEBRADATE);
175 fprintf (stderr, " (C) 1994-2002, Index Data ApS\n");
178 fprintf (stderr, " WIN32 Debug\n");
180 fprintf (stderr, " WIN32 Release\n");
184 fprintf (stderr, "libbzip2\n"
185 " (C) 1996-1999 Julian R Seward. All rights reserved.\n");
189 yaz_log_init_level (yaz_log_mask_str(arg));
191 yaz_log_init_file (arg);
193 mem_max = 1024*1024*atoi(arg);
195 rGroupDef.databaseName = arg;
197 rGroupDef.flagRw = 0;
199 rGroupDef.groupName = arg;
201 rGroupDef.fileVerboseLimit = atoi(arg);
205 rGroupDef.recordType = arg;
209 logf (LOG_WARN, "unknown option '-%s'", arg);