X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fmain.c;h=60384699468a345a9ee2915fc44f67531df0d7dd;hb=6cb032fd2ece4742e3516e0941507143f677e5cd;hp=52a7ab0605a6b7a77c20b403197072900b8e4bb4;hpb=8add234f71c852fd95ca3aef168e3563265c93b9;p=idzebra-moved-to-github.git diff --git a/index/main.c b/index/main.c index 52a7ab0..6038469 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.122 2005-01-16 23:14:57 adam Exp $ +/* $Id: main.c,v 1.124 2005-05-11 12:39:36 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -59,7 +59,7 @@ int main (int argc, char **argv) char *configName = 0; int nsections = 0; int enable_commit = 1; - char *database = "Default"; + char *database = 0; Res res = res_open(0, 0, 0); int trans_started=0; @@ -113,8 +113,7 @@ int main (int argc, char **argv) ); exit (1); } - while ((ret = options ("sVt:c:g:d:m:v:nf:l:L" - , argv, argc, &arg)) != -2) + while ((ret = options("sVt:c:g:d:m:v:nf:l:L", argv, argc, &arg)) != -2) { if (ret == 0) { @@ -135,10 +134,12 @@ int main (int argc, char **argv) zebra_shadow_enable (zh, enable_commit); } - if (zebra_select_database (zh, database)) + if (database && + zebra_select_database (zh, database) == ZEBRA_FAIL) { - yaz_log(YLOG_FATAL, "Could not select database %s errCode=%d", - database, zebra_errCode(zh) ); + yaz_log(YLOG_FATAL, "Could not select database %s " + "errCode=%d", + database, zebra_errCode(zh) ); exit (1); } if (!strcmp (arg, "update")) @@ -195,40 +196,46 @@ int main (int argc, char **argv) } else { + ZEBRA_RES res = ZEBRA_OK; if (!trans_started) { trans_started=1; - if (zebra_begin_trans (zh, 1)) + if (zebra_begin_trans (zh, 1) != ZEBRA_OK) exit(1); } switch (cmd) { case 'u': - zebra_repository_update (zh, arg); + res = zebra_repository_update (zh, arg); break; case 'd': - zebra_repository_delete (zh, arg); + res = zebra_repository_delete (zh, arg); break; case 's': - zebra_repository_show (zh, arg); + res = zebra_repository_show (zh, arg); nsections = 0; break; case 'C': - zebra_create_database(zh, arg); + res = zebra_create_database(zh, arg); break; case 'D': - zebra_drop_database(zh, arg); + res = zebra_drop_database(zh, arg); break; default: nsections = 0; } + if (res != ZEBRA_OK) + { + yaz_log(YLOG_WARN, "Operation failed"); + exit(1); + } log_event_end (NULL, NULL); } } else if (ret == 'V') { printf("Zebra %s %s\n", ZEBRAVER, ZEBRADATE); - printf(" (C) 1994-2004, Index Data ApS\n"); + printf(" (C) 1994-2005, Index Data ApS\n"); #ifdef WIN32 #ifdef _DEBUG printf(" WIN32 Debug\n");