X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=30e84a791428f1ae189531cdaed22aa7d6a3b134;hb=0481a9d462ba15064121ecd84a5d59b70fb000a4;hp=5907725d467edb3228afa2dd85e51f7ac740f327;hpb=d0276ba178f8bdd1ccad216d8b4ec9af832b0cf7;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 5907725..30e84a7 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,10 +1,23 @@ /* - * Copyright (C) 1995-1998, Index Data I/S + * Copyright (C) 1995-1998, Index Data ApS * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.c,v $ - * Revision 1.4 1998-06-12 12:22:12 adam + * Revision 1.8 1998-08-24 17:29:23 adam + * Minor changes. + * + * 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 @@ -77,23 +90,35 @@ static int zebra_register_lock (ZebraHandle zh) zh->registerState = state; zh->records = rec_open (zh->bfs, 0); if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 40, 0))) + { + logf (LOG_WARN, "dict_open"); return -1; + } if (!(zh->sortIdx = sortIdx_open (zh->bfs, 0))) + { + logf (LOG_WARN, "sortIdx_open"); return -1; + } zh->isam = NULL; zh->isamc = NULL; if (!res_get_match (zh->res, "isam", "i", NULL)) { if (!(zh->isamc = isc_open (zh->bfs, FNAME_ISAMC, 0, key_isamc_m(zh->res)))) + { + logf (LOG_WARN, "isc_open"); return -1; + } } else { if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, 0, sizeof (struct it_key), zh->res))) + { + logf (LOG_WARN, "is_open"); return -1; + } } zh->zei = zebraExplain_open (zh->records, zh->dh, zh->res, 0, 0, 0); @@ -148,8 +173,21 @@ ZebraHandle zebra_open (const char *configName) zh->records = 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")); + } return zh; } @@ -174,6 +212,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); } @@ -199,6 +239,7 @@ void zebra_records_retrieve (ZebraHandle zh, ODR stream, int i, *pos_array; zh->errCode = 0; + zh->errString = NULL; pos_array = xmalloc (num_recs * sizeof(*pos_array)); for (i = 0; ierrCode = 0; + zh->errString = NULL; zebra_register_lock (zh); rpn_scan (zh, stream, zapt, attributeset, num_bases, basenames, position, @@ -252,10 +294,12 @@ 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); @@ -282,6 +326,13 @@ 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) {