From d9c86c0fb916851a641fd17bda58a1fa3045d95e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 6 Sep 2000 08:59:36 +0000 Subject: [PATCH] Using read-only (for now) for server. --- index/apitest.c | 30 ++++++++++++++++++++---------- index/zebraapi.c | 29 ++++++++++++++++------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/index/apitest.c b/index/apitest.c index 3047044..c9eac7f 100644 --- a/index/apitest.c +++ b/index/apitest.c @@ -1,3 +1,9 @@ +/* + * Copyright (C) 1995-2000, Index Data + * All rights reserved. + * + * $Header: /home/cvsroot/idis/index/Attic/apitest.c,v 1.10 2000-09-06 08:59:36 adam Exp $ + */ #include @@ -100,7 +106,10 @@ int main (int argc, char **argv) various functions */ ODR odr_input, odr_output; - /* zh is our Zebra Handle - describes the server as a whole */ + /* zs is our Zebra Service - decribes whole server */ + ZebraService zs; + + /* zh is our Zebra Handle - describes database session */ ZebraHandle zh; /* the database we specify in our example */ @@ -114,19 +123,19 @@ int main (int argc, char **argv) odr_input = odr_createmem (ODR_DECODE); odr_output = odr_createmem (ODR_ENCODE); - /* open Zebra */ - zh = zebra_open ("zebra.cfg"); + zs = zebra_start ("zebra.cfg"); + if (!zs) + { + printf ("zebra_start failed; missing zebra.cfg?\n"); + exit (1); + } + /* open Zebra */ + zh = zebra_open (zs); if (!zh) { - printf ("Couldn't init zebra\n"); + printf ("zebras_open failed\n"); exit (1); } - - /* This call controls the logging facility in YAZ/Zebra */ -#if 0 - log_init(LOG_ALL, "", "out.log"); -#endif - /* Each argument to main will be a query */ for (argno = 1; argno < argc; argno++) { @@ -257,5 +266,6 @@ int main (int argc, char **argv) odr_destroy (odr_input); odr_destroy (odr_output); zebra_close (zh); + zebra_stop (zs); return 0; } diff --git a/index/zebraapi.c b/index/zebraapi.c index 21784de..6e2461b 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -3,7 +3,10 @@ * All rights reserved. * * $Log: zebraapi.c,v $ - * Revision 1.35 2000-07-07 12:49:20 adam + * Revision 1.36 2000-09-06 08:59:36 adam + * Using read-only (for now) for server. + * + * Revision 1.35 2000/07/07 12:49:20 adam * Optimized resultSetInsert{Rank,Sort}. * * Revision 1.34 2000/06/09 13:56:38 ian @@ -216,7 +219,7 @@ ZebraHandle zebra_open (ZebraService zs) return zh; } -static int zebra_register_activate (ZebraService zh); +static int zebra_register_activate (ZebraService zh, int rw); static int zebra_register_deactivate (ZebraService zh); ZebraService zebra_start (const char *configName) @@ -230,11 +233,11 @@ ZebraService zebra_start (const char *configName) zh->stop_flag = 0; zh->active = 0; zebra_mutex_cond_init (&zh->session_lock); - zebra_register_activate (zh); + zebra_register_activate (zh, 0); return zh; } -static int zebra_register_activate (ZebraService zh) +static int zebra_register_activate (ZebraService zh, int rw) { if (zh->active) return 0; @@ -289,17 +292,17 @@ static int zebra_register_activate (ZebraService zh) passwd_db_file (zh->passwd_db, res_get (zh->res, "passwd")); } - if (!(zh->records = rec_open (zh->bfs, 1, 0))) + if (!(zh->records = rec_open (zh->bfs, rw, 0))) { logf (LOG_WARN, "rec_open"); return -1; } - if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 80, 1, 0))) + if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 80, rw, 0))) { logf (LOG_WARN, "dict_open"); return -1; } - if (!(zh->sortIdx = sortIdx_open (zh->bfs, 0))) + if (!(zh->sortIdx = sortIdx_open (zh->bfs, rw))) { logf (LOG_WARN, "sortIdx_open"); return -1; @@ -307,7 +310,7 @@ static int zebra_register_activate (ZebraService zh) if (res_get_match (zh->res, "isam", "s", ISAM_DEFAULT)) { struct ISAMS_M_s isams_m; - if (!(zh->isams = isams_open (zh->bfs, FNAME_ISAMS, 1, + if (!(zh->isams = isams_open (zh->bfs, FNAME_ISAMS, rw, key_isams_m(zh->res, &isams_m)))) { logf (LOG_WARN, "isams_open"); @@ -317,7 +320,7 @@ static int zebra_register_activate (ZebraService zh) #if ZMBOL else if (res_get_match (zh->res, "isam", "i", ISAM_DEFAULT)) { - if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, 1, + if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, rw, sizeof (struct it_key), zh->res))) { logf (LOG_WARN, "is_open"); @@ -328,7 +331,7 @@ static int zebra_register_activate (ZebraService zh) { struct ISAMC_M_s isamc_m; if (!(zh->isamc = isc_open (zh->bfs, FNAME_ISAMC, - 1, key_isamc_m(zh->res, &isamc_m)))) + rw, key_isamc_m(zh->res, &isamc_m)))) { logf (LOG_WARN, "isc_open"); return -1; @@ -339,7 +342,7 @@ static int zebra_register_activate (ZebraService zh) struct ISAMD_M_s isamd_m; if (!(zh->isamd = isamd_open (zh->bfs, FNAME_ISAMD, - 1, key_isamd_m(zh->res, &isamd_m)))) + rw, key_isamd_m(zh->res, &isamd_m)))) { logf (LOG_WARN, "isamd_open"); return -1; @@ -347,7 +350,7 @@ static int zebra_register_activate (ZebraService zh) } #endif zh->zei = zebraExplain_open (zh->records, zh->dh, - zh->res, 1, 0 /* rGroup */, + zh->res, rw, 0 /* rGroup */, explain_extract); if (!zh->zei) { @@ -377,7 +380,7 @@ void zebra_admin_start (ZebraHandle zh) zh->errCode = 0; zebra_mutex_cond_lock (&zs->session_lock); if (!zs->stop_flag) - zebra_register_activate(zs); + zebra_register_activate(zs, 0); zebra_mutex_cond_unlock (&zs->session_lock); } -- 1.7.10.4