38 #include <yaz/snprintf.h>
39 #include <yaz/options.h>
55 int main(
int argc,
char **argv)
61 int enable_commit = 1;
66 int trans_started = 0;
75 yaz_snprintf(nbuf,
sizeof(nbuf),
"%s(%ld)", *argv, (
long) getpid());
76 yaz_log_init_prefix(nbuf);
81 fprintf(stderr,
"%s [options] command <dir> ...\n"
83 " update <dir> Update index with files below <dir>.\n"
84 " If <dir> is empty filenames are read from stdin.\n"
85 " delete <dir> Delete index with files below <dir>.\n"
86 " create <db> Create database <db>\n"
87 " drop <db> Drop database <db>\n"
88 " commit Commit changes\n"
89 " clean Clean shadow files\n"
90 " check mode Check register; mode is one of: default, full, quick\n"
92 " -t <type> Index files as <type> (grs or text).\n"
93 " -c <config> Read configuration file <config>.\n"
94 " -g <group> Index files according to group settings.\n"
95 " -d <database> Records belong to Z39.50 database <database>.\n"
96 " -m <mbytes> Use <mbytes> before flushing keys to disk.\n"
97 " -n Don't use shadow system.\n"
98 " -s Show analysis on stdout, but do no work.\n"
99 " -v <level> Set logging to <level>.\n"
100 " -l <file> Write log to <file>.\n"
101 " -L Don't follow symbolic links.\n"
102 " -f <n> Display information for the first <n> records.\n"
103 " -V Show version.\n", *argv
107 res_set(default_res,
"profilePath", DEFAULT_PROFILE_PATH);
108 res_set(default_res,
"modulePath", DEFAULT_MODULE_PATH);
109 while ((ret = options(
"sVt:c:g:d:m:v:nf:l:L", argv, argc, &arg)) != -2)
117 const char *config = configName ? configName :
"zebra.cfg";
121 yaz_log(YLOG_FATAL,
"Cannot read config %s", config);
131 yaz_log(YLOG_FATAL,
"Could not select database %s "
136 if (!strcmp(arg,
"update"))
138 else if (!strcmp(arg,
"update1"))
140 else if (!strcmp(arg,
"update2"))
142 else if (!strcmp(arg,
"dump"))
144 else if (!strcmp(arg,
"del") || !strcmp(arg,
"delete"))
146 else if (!strcmp(arg,
"adelete"))
148 else if (!strcmp(arg,
"init"))
152 else if (!strcmp(arg,
"drop"))
156 else if (!strcmp(arg,
"create"))
160 else if (!strcmp(arg,
"commit"))
164 else if (!strcmp(arg,
"clean"))
168 else if (!strcmp(arg,
"stat") || !strcmp(arg,
"status"))
172 else if (!strcmp(arg,
"dumpdict"))
176 else if (!strcmp(arg,
"compact"))
180 else if (!strcmp(arg,
"filters"))
184 else if (!strcmp(arg,
"check"))
190 yaz_log(YLOG_FATAL,
"unknown command: %s", arg);
230 yaz_log(YLOG_FATAL,
"Operation failed: %s %s",
235 yaz_log(YLOG_WARN,
"zebra_end_trans failed");
242 log_event_end(NULL, NULL);
247 char version_str[20];
251 printf(
"Zebra %s\n", version_str);
252 printf(
"(C) 1994-2023, Index Data\n");
253 printf(
"Zebra is free software, covered by the GNU General Public License, and you are\n");
254 printf(
"welcome to change it and/or distribute copies of it under certain conditions.\n");
255 printf(
"SHA1 ID: %s\n", sys_str);
257 printf(
"zebraidx compiled version %s\n",
ZEBRAVER);
259 printf(
"Using ICU\n");
263 yaz_log_init_level(yaz_log_mask_str(arg));
265 yaz_log_init_file(arg);
275 res_set(res,
"fileVerboseLimit", arg);
279 res_set(res,
"recordType", arg);
283 res_set(res,
"followLinks",
"0");
285 yaz_log(YLOG_WARN,
"unknown option '-%s'", arg);
292 yaz_log(YLOG_WARN,
"zebra_end_trans failed");
ZEBRA_RES zebra_compact(ZebraHandle zh)
ZEBRA_RES zebra_init(ZebraHandle zh)
ZEBRA_RES zebra_end_trans(ZebraHandle zh) ZEBRA_GCC_ATTR((warn_unused_result))
ZEBRA_RES zebra_close(ZebraHandle zh)
Destroys Zebra session handle.
ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) ZEBRA_GCC_ATTR((warn_unused_result))
Creates a Zebra service with resources.
ZEBRA_RES zebra_register_check(ZebraHandle zh, const char *spec)
ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db)
Deletes a database (drop)
int zebra_register_statistics(ZebraHandle zh, int dumpdict)
ZEBRA_RES zebra_clean(ZebraHandle zh)
ZEBRA_RES zebra_commit(ZebraHandle zh)
ZEBRA_RES zebra_create_database(ZebraHandle zh, const char *db)
Creates a database.
ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) ZEBRA_GCC_ATTR((warn_unused_result))
int zebra_errCode(ZebraHandle zh)
Returns error code for last error.
ZEBRA_RES zebra_select_database(ZebraHandle zh, const char *basename) ZEBRA_GCC_ATTR((warn_unused_result))
const char * zebra_errString(ZebraHandle zh)
Returns error string for last error.
ZEBRA_RES zebra_repository_index(ZebraHandle zh, const char *path, enum zebra_recctrl_action_t action)
ZEBRA_RES zebra_stop(ZebraService zs)
stops a Zebra service.
void zebra_filter_info(ZebraService zs, void *cd, void(*cb)(void *cd, const char *name))
Lists enabled Zebra filters.
char * zebra_errAdd(ZebraHandle zh)
Returns additional info for last error.
ZebraHandle zebra_open(ZebraService zs, Res res) ZEBRA_GCC_ATTR((warn_unused_result))
Creates a Zebra session handle within service.
void zebra_shadow_enable(ZebraHandle zh, int value)
ZEBRA_RES zebra_repository_show(ZebraHandle zh, const char *path)
static void add(void *set_handle, int seqno, TERMID term)
void res_set(Res r, const char *name, const char *value)
Res res_open(Res res_def, Res over_res)
short ZEBRA_RES
Common return type for Zebra API.
#define ZEBRAVER
Version as string.
void zebra_get_version(char *version_str, char *sha1_str)
Returns Zebra version and SHA1 ID as generated by Git.
int main(int argc, char **argv)
static void show_filters(ZebraService zs)
static void filter_cb(void *cd, const char *name)