-/*
- * 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 <stdlib.h>
#include <assert.h>
}
}
+/* 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,
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);
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;
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)
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)
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)
{
if (adjust_num)
{
zei->dirty = 1;
- yaz_log (LOG_LOG, "zinfo run number=%d", zei->runNumber+adjust_num);
}
return zei->runNumber += adjust_num;
}