X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-z3950.c;h=d13b336fd547b0c1bae4e5bcea96e86adbcf92c5;hb=31c5e5fa92f5980deac3c042b765e4148329cd1b;hp=bbd2e2a29198f9e82dfbec1054bcd358b39d4d30;hpb=63c48920fd45817bf28177279f65099670fe258b;p=yaz-moved-to-github.git diff --git a/src/zoom-z3950.c b/src/zoom-z3950.c index bbd2e2a..d13b336 100644 --- a/src/zoom-z3950.c +++ b/src/zoom-z3950.c @@ -663,10 +663,10 @@ zoom_ret ZOOM_connection_Z3950_send_search(ZOOM_connection c) if (facet_list) { Z_OtherInformation **oi; yaz_oi_APDU(apdu, &oi); - if (facet_list) { - yaz_oi_set_facetlist(oi, c->odr_out, facet_list); - } + yaz_oi_set_facetlist(oi, c->odr_out, facet_list); } + else + yaz_log(YLOG_WARN, "Unable to parse facets: %s", facets); } assert(r); @@ -1136,6 +1136,22 @@ static ZOOM_facet_field get_zoom_facet_field(ODR odr, Z_FacetField *facet) { return facet_field; } +/* Can be share with SOLR/SRU/SRW requests */ +void handle_facet_list(ZOOM_resultset r, Z_FacetList *fl) { + int j; + r->num_facets = fl->num; + yaz_log(YLOG_DEBUG, "Facets found: %d", fl->num); + r->facets = odr_malloc(r->odr, r->num_facets * sizeof(*r->facets)); + r->facets_names = odr_malloc(r->odr, r->num_facets * sizeof(*r->facets_names)); + for (j = 0; j < fl->num; j++) + { + r->facets[j] = get_zoom_facet_field(r->odr, fl->elements[j]); + if (!r->facets[j]) + yaz_log(YLOG_DEBUG, "Facet field missing on index %d !", j); + r->facets_names[j] = (char *) ZOOM_facet_field_name(r->facets[j]); + } +} + static void handle_facet_result(ZOOM_connection c, ZOOM_resultset r, Z_OtherInformation *o) { @@ -1147,19 +1163,7 @@ static void handle_facet_result(ZOOM_connection c, ZOOM_resultset r, Z_External *ext = o->list[i]->information.externallyDefinedInfo; if (ext->which == Z_External_userFacets) { - int j; - Z_FacetList *fl = ext->u.facetList; - r->num_facets = fl->num; - yaz_log(YLOG_DEBUG, "Facets found: %d", fl->num); - r->facets = odr_malloc(r->odr, r->num_facets * sizeof(*r->facets)); - r->facets_names = odr_malloc(r->odr, r->num_facets * sizeof(*r->facets_names)); - for (j = 0; j < fl->num; j++) - { - r->facets[j] = get_zoom_facet_field(r->odr, fl->elements[j]); - if (!r->facets[j]) - yaz_log(YLOG_DEBUG, "Facet field missing on index %d !", j); - r->facets_names[j] = (char *) ZOOM_facet_field_name(r->facets[j]); - } + handle_facet_list(r, ext->u.facetList); } } }