X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=4e5d2fdeca61be0c4e614bd123f8e2dbdb8d9842;hb=75573f447b51a5d666a115fbf445af3d2717be48;hp=ce2a017b1f2922997a1becef527480a525adb8d9;hpb=ce3907338568fce46c5751e7e1091a5ad1c8e291;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index ce2a017..4e5d2fd 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -4,7 +4,28 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.c,v $ - * Revision 1.1 1998-03-05 08:45:13 adam + * Revision 1.7 1998-06-24 12:16:13 adam + * Support for relations on text operands. Open range support in + * DFA module (i.e. [-j], [g-]). + * + * Revision 1.6 1998/06/22 11:36:47 adam + * Added authentication check facility to zebra. + * + * Revision 1.5 1998/06/13 00:14:08 adam + * Minor changes. + * + * Revision 1.4 1998/06/12 12:22:12 adam + * Work on Zebra API. + * + * Revision 1.3 1998/05/27 16:57:44 adam + * Zebra returns surrogate diagnostic for single records when + * appropriate. + * + * Revision 1.2 1998/05/20 10:12:19 adam + * Implemented automatic EXPLAIN database maintenance. + * Modified Zebra to work with ASN.1 compiled version of YAZ. + * + * Revision 1.1 1998/03/05 08:45:13 adam * New result set model and modular ranking system. Moved towards * descent server API. System information stored as "SGML" records. * @@ -18,6 +39,7 @@ #include #endif +#include #include "zserver.h" static int zebra_register_lock (ZebraHandle zh) @@ -52,7 +74,7 @@ static int zebra_register_lock (ZebraHandle zh) zh->registerChange = lastChange; if (zh->records) { - zebraExplain_close (zh->zei, 0); + zebraExplain_close (zh->zei, 0, 0); dict_close (zh->dict); sortIdx_close (zh->sortIdx); if (zh->isam) @@ -83,7 +105,7 @@ static int zebra_register_lock (ZebraHandle zh) sizeof (struct it_key), zh->res))) return -1; } - zh->zei = zebraExplain_open (zh->records, zh->dh, 0); + zh->zei = zebraExplain_open (zh->records, zh->dh, zh->res, 0, 0, 0); return 0; } @@ -115,7 +137,7 @@ static void zebra_register_unlock (ZebraHandle zh) zebra_server_unlock (zh, zh->registerState); } -ZebraHandle zebra_open (const char *host, const char *configName) +ZebraHandle zebra_open (const char *configName) { ZebraHandle zh = xmalloc (sizeof(*zh)); @@ -134,11 +156,27 @@ ZebraHandle zebra_open (const char *host, const char *configName) zh->registerChange = 0; zh->records = NULL; - zh->registered_sets = NULL; zh->zebra_maps = zebra_maps_open (zh->res); zh->rank_classes = NULL; + zh->errCode = 0; + zh->errString = 0; zebraRankInstall (zh, rank1_class); + + if (!res_get (zh->res, "passwd")) + zh->passwd_db = NULL; + else + { + zh->passwd_db = passwd_db_open (); + if (!zh->passwd_db) + logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed"); + else + passwd_db_file (zh->passwd_db, res_get (zh->res, "passwd")); + } + zh->bfs = bfs_create (res_get (zh->res, "register")); + bf_lockDir (zh->bfs, res_get (zh->res, "lockDir")); + data1_set_tabpath (zh->dh, res_get(zh->res, "profilePath")); + return zh; } @@ -147,7 +185,7 @@ void zebra_close (ZebraHandle zh) if (zh->records) { resultSetDestroy (zh); - zebraExplain_close (zh->zei, 0); + zebraExplain_close (zh->zei, 0, 0); dict_close (zh->dict); sortIdx_close (zh->sortIdx); if (zh->isam) @@ -163,6 +201,8 @@ void zebra_close (ZebraHandle zh) data1_destroy (zh->dh); zebra_server_lock_destroy (zh); + if (zh->passwd_db) + passwd_db_close (zh->passwd_db); res_close (zh->res); xfree (zh); } @@ -187,7 +227,9 @@ void zebra_records_retrieve (ZebraHandle zh, ODR stream, ZebraPosSet poset; int i, *pos_array; - pos_array = xmalloc (sizeof(*pos_array)); + zh->errCode = 0; + zh->errString = NULL; + pos_array = xmalloc (num_recs * sizeof(*pos_array)); for (i = 0; ierrCode = + recs[i].errCode = zebra_record_fetch (zh, poset[i].sysno, poset[i].score, stream, input_format, comp, &recs[i].format, &recs[i].buf, &recs[i].len, &recs[i].base); + recs[i].errString = NULL; } } zebraPosSetDestroy (zh, poset, num_recs); @@ -230,6 +273,8 @@ void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial) { + zh->errCode = 0; + zh->errString = NULL; zebra_register_lock (zh); rpn_scan (zh, stream, zapt, attributeset, num_bases, basenames, position, @@ -238,16 +283,45 @@ void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, } void zebra_sort (ZebraHandle zh, ODR stream, - int num_input_setnames, char **input_setnames, - char *output_setname, Z_SortKeySpecList *sort_sequence, + int num_input_setnames, const char **input_setnames, + const char *output_setname, Z_SortKeySpecList *sort_sequence, int *sort_status) { + zh->errCode = 0; + zh->errString = NULL; zebra_register_lock (zh); resultSetSort (zh, stream, num_input_setnames, input_setnames, output_setname, sort_sequence, sort_status); zebra_register_unlock (zh); } +int zebra_errCode (ZebraHandle zh) +{ + return zh->errCode; +} + +const char *zebra_errString (ZebraHandle zh) +{ + return diagbib1_str (zh->errCode); +} + +char *zebra_errAdd (ZebraHandle zh) +{ + return zh->errString; +} + +int zebra_hits (ZebraHandle zh) +{ + return zh->hits; +} + +int zebra_auth (ZebraHandle zh, const char *user, const char *pass) +{ + if (!zh->passwd_db || !passwd_db_auth (zh->passwd_db, user, pass)) + return 0; + return 1; +} + void zebra_setDB (ZebraHandle zh, int num_bases, char **basenames) {