X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=fa596e44bf0cdf903a1399d586d02eb7f93881af;hb=83533000f9456dcab2fc171abafd84d6104d4087;hp=50b998883151ae48ac58c9f26ab3a844e694b9d5;hpb=b718b0a9f4aaf52d38031bfb82d0d539e50332d6;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 50b9988..fa596e4 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.c,v $ - * Revision 1.25 1999-11-04 15:00:45 adam + * Revision 1.27 2000-02-24 12:31:17 adam + * Added zebra_string_norm. + * + * Revision 1.26 1999/11/30 13:48:03 adam + * Improved installation. Updated for inclusion of YAZ header files. + * + * Revision 1.25 1999/11/04 15:00:45 adam * Implemented delete result set(s). * * Revision 1.24 1999/10/14 14:33:50 adam @@ -99,7 +105,7 @@ #include #endif -#include +#include #include "zserver.h" static void zebra_chdir (ZebraHandle zh) @@ -161,20 +167,24 @@ static int zebra_register_lock (ZebraHandle zh) dict_close (zh->dict); if (zh->sortIdx) sortIdx_close (zh->sortIdx); + if (zh->isams) + isams_close (zh->isams); +#if ZMBOL if (zh->isam) is_close (zh->isam); if (zh->isamc) isc_close (zh->isamc); - if (zh->isams) - isams_close (zh->isams); +#endif rec_close (&zh->records); } bf_cache (zh->bfs, state ? res_get (zh->res, "shadow") : NULL); zh->registerState = state; + zh->isams = NULL; +#if ZMBOL zh->isam = NULL; zh->isamc = NULL; - zh->isams = NULL; +#endif zh->dict = NULL; zh->sortIdx = NULL; zh->zei = NULL; @@ -196,26 +206,27 @@ static int zebra_register_lock (ZebraHandle zh) logf (LOG_WARN, "sortIdx_open"); zh->errCode = 2; } - if (res_get_match (zh->res, "isam", "i", NULL)) + if (res_get_match (zh->res, "isam", "s", ISAM_DEFAULT)) { - if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, 0, - sizeof (struct it_key), zh->res))) + struct ISAMS_M_s isams_m; + if (!(zh->isams = isams_open (zh->bfs, FNAME_ISAMS, 0, + key_isams_m(zh->res, &isams_m)))) { - logf (LOG_WARN, "is_open"); + logf (LOG_WARN, "isams_open"); zh->errCode = 2; } } - else if (res_get_match (zh->res, "isam", "s", NULL)) +#if ZMBOL + else if (res_get_match (zh->res, "isam", "i", ISAM_DEFAULT)) { - struct ISAMS_M_s isams_m; - if (!(zh->isams = isams_open (zh->bfs, FNAME_ISAMS, 0, - key_isams_m(zh->res, &isams_m)))) + if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, 0, + sizeof (struct it_key), zh->res))) { - logf (LOG_WARN, "isams_open"); + logf (LOG_WARN, "is_open"); zh->errCode = 2; } } - else + else if (res_get_match (zh->res, "isam", "c", ISAM_DEFAULT)) { struct ISAMC_M_s isamc_m; if (!(zh->isamc = isc_open (zh->bfs, FNAME_ISAMC, @@ -225,6 +236,7 @@ static int zebra_register_lock (ZebraHandle zh) zh->errCode = 2; } } +#endif zh->zei = zebraExplain_open (zh->records, zh->dh, zh->res, 0, 0, 0); if (!zh->zei) { @@ -335,12 +347,14 @@ void zebra_close (ZebraHandle zh) zebraExplain_close (zh->zei, 0, 0); dict_close (zh->dict); sortIdx_close (zh->sortIdx); + if (zh->isams) + isams_close (zh->isams); +#if ZMBOL if (zh->isam) is_close (zh->isam); if (zh->isamc) isc_close (zh->isamc); - if (zh->isams) - isams_close (zh->isams); +#endif rec_close (&zh->records); zebra_register_unlock (zh); } @@ -589,3 +603,22 @@ void zebra_admin (ZebraHandle zh, const char *command) { } + +int zebra_string_norm (ZebraHandle zh, unsigned reg_id, + const char *input_str, int input_len, + char *output_str, int output_len) +{ + WRBUF wrbuf; + if (!zh->zebra_maps) + return -1; + wrbuf = zebra_replace(zh->zebra_maps, reg_id, "", + input_str, input_len); + if (!wrbuf) + return -2; + if (wrbuf_len(wrbuf) >= output_len) + return -3; + if (wrbuf_len(wrbuf)) + memcpy (output_str, wrbuf_buf(wrbuf), wrbuf_len(wrbuf)); + output_str[wrbuf_len(wrbuf)] = '\0'; + return wrbuf_len(wrbuf); +}