X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzinfo.c;h=f69af06956aba9d4d991676777620816dfabba6c;hb=3f1ccb1a5d47e99a07c4236f149f199dfebd21d0;hp=72245838cd03a35dbc3427e13b42d293ecc87078;hpb=1ccf2613ceef2359f589cb3dd7e72a899c618b2f;p=idzebra-moved-to-github.git diff --git a/index/zinfo.c b/index/zinfo.c index 7224583..f69af06 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,82 +1,9 @@ /* - * Copyright (C) 1994-2000, Index Data + * Copyright (C) 1994-2002, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Log: zinfo.c,v $ - * Revision 1.21 2000-12-05 10:01:44 adam - * Fixed bug regarding user-defined attribute sets. - * - * Revision 1.20 2000/11/29 14:24:01 adam - * Script configure uses yaz pthreads options. Added locking for - * zebra_register_{lock,unlock}. - * - * Revision 1.19 2000/07/07 12:49:20 adam - * Optimized resultSetInsert{Rank,Sort}. - * - * Revision 1.18 2000/03/20 19:08:36 adam - * Added remote record import using Z39.50 extended services and Segment - * Requests. - * - * Revision 1.17 1999/07/14 10:53:51 adam - * Updated various routines to handle missing explain schema. - * - * Revision 1.16 1999/05/26 07:49:13 adam - * C++ compilation. - * - * Revision 1.15 1999/01/25 13:47:54 adam - * Fixed bug. - * - * Revision 1.14 1998/11/04 16:31:32 adam - * Fixed bug regarding recordBytes in databaseInfo. - * - * Revision 1.13 1998/11/03 10:17:09 adam - * Fixed bug regarding creation of some data1 nodes for Explain records. - * - * Revision 1.12 1998/10/13 20:37:11 adam - * Changed the way attribute sets are saved in Explain database to - * reflect "dynamic" OIDs. - * - * Revision 1.11 1998/06/09 12:16:48 adam - * Implemented auto-generation of CategoryList records. - * - * Revision 1.10 1998/06/08 14:43:15 adam - * Added suport for EXPLAIN Proxy servers - added settings databasePath - * and explainDatabase to facilitate this. Increased maximum number - * of databases and attributes in one register. - * - * Revision 1.9 1998/06/02 12:10:27 adam - * Fixed bug related to attributeDetails. - * - * Revision 1.8 1998/05/20 10:12:20 adam - * Implemented automatic EXPLAIN database maintenance. - * Modified Zebra to work with ASN.1 compiled version of YAZ. - * - * Revision 1.7 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. - * - * Revision 1.6 1998/02/17 10:29:27 adam - * Moved towards 'automatic' EXPLAIN database. - * - * Revision 1.5 1997/10/27 14:33:05 adam - * Moved towards generic character mapping depending on "structure" - * field in abstract syntax file. Fixed a few memory leaks. Fixed - * bug with negative integers when doing searches with relational - * operators. - * - * Revision 1.4 1997/09/25 14:57:08 adam - * Added string.h. - * - * Revision 1.3 1996/05/22 08:21:59 adam - * Added public ZebDatabaseInfo structure. - * - * Revision 1.2 1996/05/14 06:16:41 adam - * Compact use/set bytes used in search service. - * - * Revision 1.1 1996/05/13 14:23:07 adam - * Work on compaction of set/use bytes in dictionary. - * + * $Id: zinfo.c,v 1.27 2002-04-15 09:07:10 adam Exp $ */ #include @@ -342,6 +269,8 @@ static Record createRecord (Records records, int *sysno) void zebraExplain_flush (ZebraExplainInfo zei, int writeFlag, void *handle) { + if (!zei) + return; zei->updateHandle = handle; if (writeFlag) { @@ -506,7 +435,11 @@ ZebraExplainInfo zebraExplain_open ( data1_node *node_tgtinfo, *node_zebra, *node_list, *np; zei->data1_target = read_sgml_rec (zei->dh, zei->nmem, trec); +#if 0 if (!zei->data1_target || !zei->data1_target->u.root.absyn) +#else + if (!zei->data1_target) +#endif { logf (LOG_FATAL, "Explain schema missing. Check profilePath"); nmem_destroy (zei->nmem); @@ -612,7 +545,7 @@ ZebraExplainInfo zebraExplain_open ( "1\n" "Zebra\n" "\n" ); - if (!zei->data1_target || !zei->data1_target->u.root.absyn) + if (!zei->data1_target) { logf (LOG_FATAL, "Explain schema missing. Check profilePath"); nmem_destroy (zei->nmem); @@ -773,6 +706,12 @@ static void zebraExplain_readDatabase (ZebraExplainInfo zei, int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database) { struct zebDatabaseInfoB *zdi; + const char *database_n = strrchr (database, '/'); + + if (database_n) + database_n++; + else + database_n = database; assert (zei); if (zei->curDatabaseInfo && @@ -780,7 +719,7 @@ int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database) return 0; for (zdi = zei->databaseInfo; zdi; zdi=zdi->next) { - if (!strcmp (zdi->databaseName, database)) + if (!strcmp (zdi->databaseName, database_n)) break; } if (!zdi) @@ -857,6 +796,12 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, { struct zebDatabaseInfoB *zdi; data1_node *node_dbinfo, *node_adinfo; + const char *database_n = strrchr (database, '/'); + + if (database_n) + database_n++; + else + database_n = database; #if ZINFO_DEBUG logf (LOG_LOG, "zebraExplain_newDatabase: %s", database); @@ -864,7 +809,7 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, assert (zei); for (zdi = zei->databaseInfo; zdi; zdi=zdi->next) { - if (!strcmp (zdi->databaseName, database)) + if (!strcmp (zdi->databaseName, database_n)) break; } if (zdi) @@ -877,7 +822,7 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, zdi->recordCount = 0; zdi->recordBytes = 0; zdi->readFlag = 0; - zdi->databaseName = nmem_strdup (zei->nmem, database); + zdi->databaseName = nmem_strdup (zei->nmem, database_n); zebraExplain_mergeAccessInfo (zei, 0, &zdi->accessInfo); @@ -1372,6 +1317,25 @@ int zebraExplain_lookupSU (ZebraExplainInfo zei, int set, int use) return -1; } +int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, + const char **db, int *set, int *use) +{ + struct zebDatabaseInfoB *zdb; + for (zdb = zei->databaseInfo; zdb; zdb = zdb->next) + { + struct zebSUInfoB *zsui = zdb->attributeDetails->SUInfo; + for ( ;zsui; zsui = zsui->next) + if (zsui->info.ordinal == ord) + { + *db = zdb->databaseName; + *set = zsui->info.set; + *use = zsui->info.use; + return 0; + } + } + return -1; +} + zebAccessObject zebraExplain_announceOid (ZebraExplainInfo zei, zebAccessObject *op, Odr_oid *oid) @@ -1487,7 +1451,7 @@ static void att_loadset(void *p, const char *n, const char *name) { data1_handle dh = (data1_handle) p; if (!data1_get_attset (dh, name)) - logf (LOG_WARN, "Couldn't load attribute set %s", name); + logf (LOG_WARN, "Directive attset failed for %s", name); } void zebraExplain_loadAttsets (data1_handle dh, Res res)