From 79a521770393bd301230668a5ce950b754bd39c7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 30 Nov 1995 17:01:38 +0000 Subject: [PATCH] New setting commitCache: points to commit directories/files. New command commit: commits at the end of a zebraidx run. --- index/main.c | 60 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/index/main.c b/index/main.c index 5ff01a4..c81c149 100644 --- a/index/main.c +++ b/index/main.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: main.c,v $ - * Revision 1.23 1995-11-30 08:34:31 adam + * Revision 1.24 1995-11-30 17:01:38 adam + * New setting commitCache: points to commit directories/files. + * New command commit: commits at the end of a zebraidx run. + * + * Revision 1.23 1995/11/30 08:34:31 adam * Started work on commit facility. * Changed a few malloc/free to xmalloc/xfree. * @@ -97,6 +101,7 @@ extern char *data1_tabpath; int main (int argc, char **argv) { + int commit_at_end = 0; int ret; int cmd = 0; char *arg; @@ -131,16 +136,31 @@ int main (int argc, char **argv) " -v Set logging to .\n"); exit (1); } - while ((ret = options ("t:c:g:d:m:v:l:", argv, argc, &arg)) != -2) + while ((ret = options ("t:c:g:d:m:v:", argv, argc, &arg)) != -2) { if (ret == 0) { if(cmd == 0) /* command */ { + if (!common_resource) + { + common_resource = res_open (configName ? + configName : FNAME_CONFIG); + if (!common_resource) + { + logf (LOG_FATAL, "Cannot open resource `%s'", + configName); + exit (1); + } + data1_tabpath = res_get (common_resource, "profilePath"); + bf_cache (res_get (common_resource, "commitCache")); + } if (!strcmp (arg, "update")) cmd = 'u'; else if (!strcmp (arg, "del") || !strcmp(arg, "delete")) cmd = 'd'; + else if (!strcmp (arg, "commit")) + commit_at_end = 1; else { logf (LOG_FATAL, "Unknown command: %s", arg); @@ -152,19 +172,6 @@ int main (int argc, char **argv) struct recordGroup rGroup; memcpy (&rGroup, &rGroupDef, sizeof(rGroup)); - if (!common_resource) - { - common_resource = res_open (configName ? - configName : FNAME_CONFIG); - if (!common_resource) - { - logf (LOG_FATAL, "Cannot open resource `%s'", - configName); - exit (1); - } - data1_tabpath = res_get (common_resource, "profilePath"); - assert (data1_tabpath); - } if (!key_open_flag) { key_open (mem_max); @@ -198,21 +205,26 @@ int main (int argc, char **argv) configName = arg; else if (ret == 't') rGroupDef.recordType = arg; - else if (ret == 'l') - bf_cache (arg); else { logf (LOG_FATAL, "Unknown option '-%s'", arg); exit (1); } } - if (!key_open_flag) - exit (0); - nsections = key_close (); - if (!nsections) - exit (0); - logf (LOG_LOG, "Merging with index"); - key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections, 60); + if (key_open_flag) + { + nsections = key_close (); + if (nsections) + { + logf (LOG_LOG, "Merging with index"); + key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections, 60); + } + } + if (commit_at_end) + { + logf (LOG_LOG, "commiting"); + bf_commit (res_get (common_resource, "commitCache")); + } exit (0); } -- 1.7.10.4