X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=6e2461bab3c406f5f8b1691bcd983e4931910c4a;hb=d9c86c0fb916851a641fd17bda58a1fa3045d95e;hp=b8181a5177ac027d93ab77fea68a70b3589e71ef;hpb=297ba5c5c265a5f869f43a0a211bf9f48f700add;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index b8181a5..6e2461b 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -3,7 +3,16 @@ * All rights reserved. * * $Log: zebraapi.c,v $ - * Revision 1.33 2000-05-18 12:01:36 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 + * Added some logging on Authentication and searches. + * + * Revision 1.33 2000/05/18 12:01:36 adam * System call times(2) used again. More 64-bit fixes. * * Revision 1.32 2000/04/19 14:35:59 adam @@ -204,10 +213,13 @@ ZebraHandle zebra_open (ZebraService zs) zs->sessions = zh; zebra_mutex_cond_unlock (&zs->session_lock); + + logf(LOG_APP,"CONNECT:"); + 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) @@ -221,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; @@ -280,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; @@ -298,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"); @@ -308,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"); @@ -319,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; @@ -330,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; @@ -338,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) { @@ -368,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); } @@ -381,7 +393,7 @@ static int zebra_register_deactivate (ZebraService zh) zebra_chdir (zh); if (zh->records) { - zebraExplain_close (zh->zei, 1); + zebraExplain_close (zh->zei, 0); dict_close (zh->dict); sortIdx_close (zh->sortIdx); if (zh->isams) @@ -535,6 +547,8 @@ void zebra_search_rpn (ZebraHandle zh, ODR stream, ODR decode, resultSetAddRPN (zh, stream, decode, query, num_bases, basenames, setname); zebra_register_unlock (zh); + + logf(LOG_APP,"SEARCH:%d:",zh->hits); } void zebra_records_retrieve (ZebraHandle zh, ODR stream, @@ -665,7 +679,12 @@ int zebra_hits (ZebraHandle zh) int zebra_auth (ZebraService zh, const char *user, const char *pass) { if (!zh->passwd_db || !passwd_db_auth (zh->passwd_db, user, pass)) + { + logf(LOG_APP,"AUTHOK:%s", user?user:"ANONYMOUS"); return 0; + } + + logf(LOG_APP,"AUTHFAIL:%s", user?user:"ANONYMOUS"); return 1; }