X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ffacet.c;h=721b7e3db9307dcb8ba25a6f1e4e59b2e76fbea2;hp=37074feb56da02779a858357c9c86e6631a5c198;hb=fb91dfe5324b8492a8e90ec7c5dbfecad224c2a2;hpb=ac14cea20cab6607b203ec4d0e63b42008d70e6c diff --git a/src/facet.c b/src/facet.c index 37074fe..721b7e3 100644 --- a/src/facet.c +++ b/src/facet.c @@ -10,6 +10,16 @@ /* 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 attrvalues *attr_values) { + attr_values->errcode = 0; + attr_values->errstring = 0; + attr_values->relation = 0; + attr_values->useattr = 0; + attr_values->useattrbuff[0] = 0; + attr_values->limit = 0; +} + const char *stringattr( Z_ComplexAttribute *c ) { int i; Z_StringOrNumeric *son; @@ -28,6 +38,7 @@ void useattr ( Z_AttributeElement *ae, const char *s; if ( ae->which == Z_AttributeValue_complex ) { s = stringattr( ae->value.complex ); + yaz_log(YLOG_DEBUG, "useattr %s %s", s, av->useattr); if (s) { if (!av->useattr) av->useattr = s; @@ -76,6 +87,7 @@ void limitattr ( Z_AttributeElement *ae, /* TODO - check numeric first, then value! */ if ( ae->which == Z_AttributeValue_numeric ) { av->limit = *ae->value.numeric; + yaz_log(YLOG_DEBUG, "limitattr %d ", av->limit); } else { av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE; av->errstring = "non-numeric limit attribute"; @@ -97,9 +109,11 @@ void facetattrs( Z_AttributeList *attributes, { int i; Z_AttributeElement *ae; + yaz_log(YLOG_DEBUG, "Attribute num attributes: %d", attributes->num_attributes); for ( i=0; i < attributes->num_attributes; i++ ) { ae = attributes->attributes[i]; /* ignoring the attributeSet here */ + yaz_log(YLOG_DEBUG, "Attribute type %d", (int) *ae->attributeType); if ( *ae->attributeType == 1 ) { /* use attribute */ useattr(ae, av); } else if ( *ae->attributeType == 2 ) { /* sortorder */ @@ -111,8 +125,7 @@ void facetattrs( Z_AttributeList *attributes, sprintf(av->useattrbuff, ODR_INT_PRINTF, *ae-> attributeType); av->errstring = av->useattrbuff; - yaz_log(YLOG_DEBUG,"Unsupported attribute type %s", - av->useattrbuff); + yaz_log(YLOG_DEBUG, "Unsupported attribute type %s", av->useattrbuff); /* would like to give a better message, but the standard */ /* tells me to return the attribute type */ } @@ -124,9 +137,7 @@ void facetattrs( Z_AttributeList *attributes, Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input) { - Z_OtherInformation **oi; - Z_FacetList *facet_list = yaz_oi_get_facetlist_oid(oi, odr, yaz_oid_userinfo_facet_1, 1, 0); - + Z_FacetList *facet_list = yaz_oi_get_facetlist_oid(&search_input, odr, yaz_oid_userinfo_facet_1, 1, 0); return facet_list; } @@ -140,6 +151,7 @@ Z_Term *term_create(ODR odr, const char *cstr) { Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq) { Z_FacetTerm *facet_term = odr_malloc(odr, sizeof(*facet_term)); facet_term->count = odr_malloc(odr, sizeof(*facet_term->count)); + facet_term->term = term; *facet_term->count = freq; return facet_term; }