X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Fattribute.c;h=92f7fc0661da4f39cebf5dfd4626d10c223626e6;hp=2b55081017b4f627224a8cef123a03e3d037ae9b;hb=c3ff843e467932c6027a8b3b2ebda7b44612447e;hpb=89d3a004b7c651fd5673abfc192e1472dc4d4197 diff --git a/index/attribute.c b/index/attribute.c index 2b55081..92f7fc0 100644 --- a/index/attribute.c +++ b/index/attribute.c @@ -1,8 +1,5 @@ -/* $Id: attribute.c,v 1.28 2007-01-15 15:10:16 adam Exp $ - Copyright (C) 1995-2007 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) Index Data 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 @@ -20,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include "index.h" +#include static data1_att *getatt(data1_attset *p, int att) { @@ -45,7 +46,7 @@ static data1_att *getatt(data1_attset *p, int att) return 0; } -static int att_getentbyatt(ZebraHandle zi, oid_value set, int att, +static int att_getentbyatt(ZebraHandle zi, const Odr_oid *set, int att, const char **name) { data1_att *r; @@ -68,8 +69,8 @@ static int att_getentbyatt(ZebraHandle zi, oid_value set, int att, ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, Z_AttributeList *attr_list, zinfo_index_category_t cat, - int index_type, - oid_value curAttributeSet, + const char *index_type, + const Odr_oid *curAttributeSet, int *ord) { int use_value = -1; @@ -88,7 +89,7 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, { /* we have a use attribute and attribute set */ int r; - + r = att_getentbyatt(zh, curAttributeSet, use_value, &use_string); if (r == -2) { @@ -97,7 +98,7 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, } if (r == -1) { - zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value); + zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value); return ZEBRA_FAIL; } } @@ -106,24 +107,36 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); return ZEBRA_FAIL; } - *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, + *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, index_type, use_string); if (*ord == -1) { - if (use_value < 0) - zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_string); - else - zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value); - return ZEBRA_FAIL; + /* attribute 14=1 does not issue a diagnostic even + 1) the attribute is numeric but listed in .att + 2) the use attribute is string + */ + AttrType unsup; + int unsup_value = 0; + attr_init_AttrList(&unsup, attr_list, 14); + unsup_value = attr_find(&unsup, 0); + + if (unsup_value != 1) + { + if (use_value < 0) + zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_string); + else + zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value); + return ZEBRA_FAIL; + } } return ZEBRA_OK; } ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - int index_type, + const char *index_type, const char *xpath_use, - oid_value curAttributeSet, + const Odr_oid *curAttributeSet, int *ord) { ZEBRA_RES res = ZEBRA_OK; @@ -136,7 +149,7 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, if (relation_value == 103) /* always matches */ cat = zinfo_index_category_alwaysmatches; - + if (!xpath_use) { res = zebra_attr_list_get_ord(zh, zapt->attributes, @@ -145,10 +158,10 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, /* use attribute not found. But it the relation is always matches and the regulare index attribute is found return a different diagnostic */ - if (res != ZEBRA_OK && + if (res != ZEBRA_OK && relation_value == 103 && zebra_attr_list_get_ord( - zh, zapt->attributes, + zh, zapt->attributes, zinfo_index_category_index, index_type, curAttributeSet, ord) == ZEBRA_OK) zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE, 103); @@ -159,16 +172,16 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, xpath_use); if (*ord == -1) { - yaz_log(YLOG_LOG, "zebra_apt_get_ord FAILED xpath=%s index_type=%c", + yaz_log(YLOG_LOG, "zebra_apt_get_ord FAILED xpath=%s index_type=%s", xpath_use, index_type); zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0); res = ZEBRA_FAIL; } else { - yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%c", + yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%s", xpath_use, index_type); - + } } return res; @@ -181,16 +194,18 @@ ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh, { AttrType structure; int structure_value; + attr_init_AttrList(&structure, sortAttributes->list, 4); *numerical = 0; structure_value = attr_find(&structure, 0); if (structure_value == 109) *numerical = 1; - - if (zebra_attr_list_get_ord(zh, sortAttributes->list, - zinfo_index_category_sort, - -1 /* any index */, VAL_BIB1, ord)== ZEBRA_OK) + + if (zebra_attr_list_get_ord( + zh, sortAttributes->list, + zinfo_index_category_sort, + 0 /* any index */, yaz_oid_attset_bib_1, ord) == ZEBRA_OK) return ZEBRA_OK; return ZEBRA_FAIL; } @@ -199,6 +214,7 @@ ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab