X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fattribute.c;h=c076de9490da5c727fa6c63c57bd7dc7b19ce890;hb=078a786204b5edef350982c385342f889d37e5ad;hp=fb15f2067f80f87a1dcf6024e9a3b0ab449de1ab;hpb=3679505d0d073f7db6425e597eb559b53e8c4827;p=idzebra-moved-to-github.git diff --git a/index/attribute.c b/index/attribute.c index fb15f20..c076de9 100644 --- a/index/attribute.c +++ b/index/attribute.c @@ -1,92 +1,68 @@ -/* - * Copyright (C) 1994-1997, Index Data I/S - * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: attribute.c,v $ - * Revision 1.7 1997-10-29 12:05:01 adam - * Server produces diagnostic "Unsupported Attribute Set" when appropriate. - * - * Revision 1.6 1997/09/17 12:19:11 adam - * Zebra version corresponds to YAZ version 1.4. - * Changed Zebra server so that it doesn't depend on global common_resource. - * - * Revision 1.5 1997/09/05 15:30:08 adam - * Changed prototype for chr_map_input - added const. - * Added support for C++, headers uses extern "C" for public definitions. - * - * Revision 1.4 1996/10/29 14:06:48 adam - * Include zebrautl.h instead of alexutil.h. - * - * Revision 1.3 1996/05/09 07:28:54 quinn - * Work towards phrases and multiple registers - * - * Revision 1.2 1995/11/15 19:13:07 adam - * Work on record management. - * - * - * This interface is used by other modules (the Z-server in particular) - * to normalize the attributes given in queries. - */ +/* $Id: attribute.c,v 1.16 2004-08-25 09:23:36 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 + Index Data Aps -#include +This file is part of the Zebra server. -#include -#include -#include -#include "zserver.h" +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. -static void att_loadset(void *p, const char *n, const char *name) -{ - data1_attset *cnew; - ZServerInfo *zi = p; +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. - if (!(cnew = data1_read_attset(zi->dh, (char*) name))) - { - logf(LOG_WARN|LOG_ERRNO, "%s", name); - return; - } - cnew->next = zi->registered_sets; - zi->registered_sets = cnew; -} +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. +*/ -static void load_atts(ZServerInfo *zi) -{ - res_trav(zi->res, "attset", zi, att_loadset); -} -static data1_att *getatt(data1_attset *p, int att) + +#include + +#include +#include +#include +#include "index.h" + +static data1_att *getatt(data1_attset *p, int att, const char *sattr) { data1_att *a; + data1_attset_child *c; - for (; p; p = p->next) - { - /* scan local set */ - for (a = p->atts; a; a = a->next) - if (a->value == att) - return a; - /* scan included sets */ - if (p->children && (a = getatt(p->children, att))) + /* scan local set */ + for (a = p->atts; a; a = a->next) + if (sattr && !yaz_matchstr(sattr, a->name)) + return a; + else if (a->value == att) + return a; + /* scan included sets */ + for (c = p->children; c; c = c->next) + if ((a = getatt(c->child, att, sattr))) return a; - } return 0; } -int att_getentbyatt(ZServerInfo *zi, attent *res, oid_value set, int att) +int att_getentbyatt(ZebraHandle zi, attent *res, oid_value set, int att, + const char *sattr) { data1_att *r; data1_attset *p; - if (!zi->registered_sets) - load_atts(zi); - for (p = zi->registered_sets; p; p = p->next) - if (p->reference == set) - break;; + if (!(p = data1_attset_search_id (zi->reg->dh, set))) + { + zebraExplain_loadAttsets (zi->reg->dh, zi->res); + p = data1_attset_search_id (zi->reg->dh, set); + } if (!p) return -2; - if (!(r = getatt(p, att))) + if (!(r = getatt(p, att, sattr))) return -1; - res->attset_ordinal = r->parent->ordinal; + res->attset_ordinal = r->parent->reference; res->local_attributes = r->locals; return 0; }