X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-z3950.c;h=5fc7c25d878b570f1316d7eaf8e324e265d23552;hp=bf31a7c4e84bbe20ee294ca88b4b2981967948c6;hb=120d41020531bb15a771971e9287b2f8f2b072ae;hpb=b7ac19e96f5e53975064b3dec2be6cbd2c1eccb8 diff --git a/src/zoom-z3950.c b/src/zoom-z3950.c index bf31a7c..5fc7c25 100644 --- a/src/zoom-z3950.c +++ b/src/zoom-z3950.c @@ -21,9 +21,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -676,14 +673,14 @@ zoom_ret ZOOM_connection_Z3950_send_search(ZOOM_connection c) assert(r->query); /* prepare query for the search request */ - search_req->query = r->query->z_query; + search_req->query = ZOOM_query_get_Z_Query(r->query); if (!search_req->query) { ZOOM_set_error(c, ZOOM_ERROR_INVALID_QUERY, 0); return zoom_complete; } - if (r->query->z_query->which == Z_Query_type_1 || - r->query->z_query->which == Z_Query_type_101) + if (search_req->query->which == Z_Query_type_1 || + search_req->query->which == Z_Query_type_101) { const char *cp = ZOOM_options_get(r->options, "rpnCharset"); if (cp) @@ -811,6 +808,7 @@ zoom_ret ZOOM_connection_Z3950_send_scan(ZOOM_connection c) ZOOM_scanset scan; Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_scanRequest); Z_ScanRequest *req = apdu->u.scanRequest; + Z_Query *z_query; yaz_log(c->log_details, "%p send_scan", c); if (!c->tasks) @@ -818,11 +816,13 @@ zoom_ret ZOOM_connection_Z3950_send_scan(ZOOM_connection c) assert (c->tasks->which == ZOOM_TASK_SCAN); scan = c->tasks->u.scan.scan; + z_query = ZOOM_query_get_Z_Query(scan->query); + /* Z39.50 scan can only carry RPN */ - if (scan->query->z_query->which == Z_Query_type_1 || - scan->query->z_query->which == Z_Query_type_101) + if (z_query->which == Z_Query_type_1 || + z_query->which == Z_Query_type_101) { - Z_RPNQuery *rpn = scan->query->z_query->u.type_1; + Z_RPNQuery *rpn = z_query->u.type_1; const char *cp = ZOOM_options_get(scan->options, "rpnCharset"); if (cp) { @@ -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); } } }