X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzinfo.c;h=67060efa6b5bfd103f4ef693fe3df5e2b0da63fc;hb=d66990c38540b6196ede05d4b5636a9b51609134;hp=bb8ae33c685bb5d2df4a995c6cc6131f64d74024;hpb=eb675b4bc920ee55a2b94ce7c9febe558d2ae2ab;p=idzebra-moved-to-github.git diff --git a/index/zinfo.c b/index/zinfo.c index bb8ae33..67060ef 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,10 +1,24 @@ -/* - * Copyright (C) 1994-2002, Index Data - * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Id: zinfo.c,v 1.32 2002-07-11 13:15:57 heikki Exp $ - */ +/* $Id: zinfo.c,v 1.37 2003-06-30 19:37:12 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 + Index Data Aps + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ #include #include @@ -257,6 +271,52 @@ void zebraExplain_mergeAccessInfo (ZebraExplainInfo zei, data1_node *n, } } +/* Explain structure + root record + of type targetInfo + and has sysno = 1 + + databaseList (list of databases) +*/ +/* +Example root: +explain: + targetInfo: TargetInfo + name: Zebra + namedResultSets: 1 + multipleDbSearch: 1 + nicknames: + name: Zebra + commonInfo: + dateAdded: 20030630190601 + dateChanged: 20030630190601 + languageCode: EN + accessinfo: + unitSystems: + string: ISO + attributeSetIds: + oid: 1.2.840.10003.3.2 + oid: 1.2.840.10003.3.5 + oid: 1.2.840.10003.3.1 + schemas: + oid: 1.2.840.10003.13.1000.81.2 + oid: 1.2.840.10003.13.2 + zebraInfo: + version: 1.3.12 + databaseList: + database: + name: Default + id: 50 + attributeDetailsId: 51 + database: + name: IR-Explain-1 + id: 52 + attributeDetailsId: 53 + ordinalSU: 38 + runNumber: 1 +nextResultSetPosition = 2 +*/ + ZebraExplainInfo zebraExplain_open ( Records records, data1_handle dh, Res res, @@ -402,7 +462,7 @@ ZebraExplainInfo zebraExplain_open ( np = np->child; assert (np && np->which == DATA1N_data); zei->runNumber = atoi_n (np->u.data.data, np->u.data.len); - yaz_log (LOG_LOG, "READ runnumber = %d", zei->runNumber); + yaz_log (LOG_DEBUG, "read runnumber = %d", zei->runNumber); *zdip = NULL; } rec_rm (&trec); @@ -582,6 +642,45 @@ static void zebraExplain_readDatabase (ZebraExplainInfo zei, rec_rm (&rec); } +int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle) +{ + struct zebDatabaseInfoB **zdip = &zei->databaseInfo; + + while (*zdip) + { + if (*zdip == zei->curDatabaseInfo) + { + struct zebDatabaseInfoB *zdi = *zdip; + Record rec; + + zei->dirty = 1; + zei->updateHandle = update_handle; + + if (zdi->attributeDetails) + { + /* remove attribute details keys and delete it */ + zebAttributeDetails zad = zdi->attributeDetails; + + rec = rec_get(zei->records, zad->sysno); + (*zei->updateFunc)(zei->updateHandle, rec, 0); + rec_rm(&rec); + } + /* remove database record keys and delete it */ + rec = rec_get (zei->records, zdi->sysno); + (*zei->updateFunc)(zei->updateHandle, rec, 0); + rec_rm(&rec); + + /* remove from list */ + *zdip = zdi->next; + + /* current database is IR-Explain-1 */ + return 0; + } + zdip = &(*zdip)->next; + } + return -1; +} + int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database) { struct zebDatabaseInfoB *zdi; @@ -594,11 +693,11 @@ int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database) assert (zei); if (zei->curDatabaseInfo && - !strcmp (zei->curDatabaseInfo->databaseName, database)) + !STRCASECMP (zei->curDatabaseInfo->databaseName, database)) return 0; for (zdi = zei->databaseInfo; zdi; zdi=zdi->next) { - if (!strcmp (zdi->databaseName, database_n)) + if (!STRCASECMP (zdi->databaseName, database_n)) break; } if (!zdi) @@ -693,7 +792,7 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, assert (zei); for (zdi = zei->databaseInfo; zdi; zdi=zdi->next) { - if (!strcmp (zdi->databaseName, database_n)) + if (!STRCASECMP (zdi->databaseName, database_n)) break; } if (zdi) @@ -1211,6 +1310,19 @@ int zebraExplain_lookupSU (ZebraExplainInfo zei, int set, int use) return -1; } +int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle, + int (*f)(void *handle, int ord)) +{ + struct zebDatabaseInfoB *zdb = zei->curDatabaseInfo; + if (zdb) + { + struct zebSUInfoB *zsui = zdb->attributeDetails->SUInfo; + for ( ;zsui; zsui = zsui->next) + (*f)(handle, zsui->info.ordinal); + } + return 0; +} + int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, const char **db, int *set, int *use) { @@ -1323,7 +1435,6 @@ int zebraExplain_runNumberIncrement (ZebraExplainInfo zei, int adjust_num) if (adjust_num) { zei->dirty = 1; - yaz_log (LOG_LOG, "zinfo run number=%d", zei->runNumber+adjust_num); } return zei->runNumber += adjust_num; }