X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ffacet.c;h=b83972c323cdd3f62e637b0e57fabc6ab6042547;hp=82a8365eef9ac65275c3f169126b8dcf68a2f6d6;hb=43a9d38d20c1b1bcd1a03b2445a501d27526bd35;hpb=76b807cf7d5aeff484005ab3168f3193da110f1f diff --git a/src/facet.c b/src/facet.c index 82a8365..b83972c 100644 --- a/src/facet.c +++ b/src/facet.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ @@ -19,11 +19,49 @@ #include #include +void yaz_oi_set_facetlist( + Z_OtherInformation **otherInformation, ODR odr, + Z_FacetList *facet_list) +{ + int categoryValue = 1; + Z_External *z_external = 0; + Z_OtherInformationUnit *oi = + yaz_oi_update(otherInformation, odr, yaz_oid_userinfo_facet_1, + categoryValue, 0); + if (!oi) + return; + oi->which = Z_OtherInfo_externallyDefinedInfo; + z_external = odr_malloc(odr, sizeof(*z_external)); + z_external->which = Z_External_userFacets; + z_external->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_facet_1); + z_external->indirect_reference = 0; + z_external->descriptor = 0; + z_external->u.facetList = facet_list; + oi->information.externallyDefinedInfo = z_external; +} + +Z_FacetList *yaz_oi_get_facetlist(Z_OtherInformation **otherInformation) +{ + int categoryValue = 1; + Z_External *z_external = 0; + Z_OtherInformationUnit *oi = + yaz_oi_update(otherInformation, 0, yaz_oid_userinfo_facet_1, + categoryValue, 0); + if (!oi) + return 0; + z_external = oi->information.externallyDefinedInfo; + + if (z_external && z_external->which == Z_External_userFacets) { + return z_external->u.facetList; + } + return 0; +} + /* Little helper to extract a string attribute */ /* Gets the first string, there is usually only one */ /* in case of errors, returns null */ -void facet_struct_init(struct yaz_facet_attr *attr_values) +void yaz_facet_attr_init(struct yaz_facet_attr *attr_values) { attr_values->errcode = 0; attr_values->errstring = 0; @@ -33,7 +71,7 @@ void facet_struct_init(struct yaz_facet_attr *attr_values) attr_values->limit = 0; } -const char *stringattr(Z_ComplexAttribute *c) +static const char *stringattr(Z_ComplexAttribute *c) { int i; Z_StringOrNumeric *son; @@ -47,7 +85,7 @@ const char *stringattr(Z_ComplexAttribute *c) } /* Use attribute, @attr1, can be numeric or string */ -void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) +static void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) { const char *s; if (ae->which == Z_AttributeValue_complex) @@ -79,7 +117,7 @@ void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) /* TODO rename to sortorder attr */ -void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) +static void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) { if (ae->which == Z_AttributeValue_numeric) { @@ -104,7 +142,7 @@ void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) } } /* relationattr */ -void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) +static void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) { if (ae->which == Z_AttributeValue_numeric) { @@ -128,7 +166,8 @@ void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av) so no need to free that string! */ -void facetattrs(Z_AttributeList *attributes, struct yaz_facet_attr *av) +void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, + struct yaz_facet_attr *av) { int i; Z_AttributeElement *ae; @@ -166,15 +205,6 @@ void facetattrs(Z_AttributeList *attributes, struct yaz_facet_attr *av) return; } /* facetattrs */ - -Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input) -{ - Z_FacetList *facet_list = - yaz_oi_get_facetlist_oid(&search_input, odr, - yaz_oid_userinfo_facet_1, 1, 0); - return facet_list; -} - Z_Term *term_create(ODR odr, const char *cstr) { Z_Term *term = odr_malloc(odr, sizeof(*term));