X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=zutil%2Fzoom-c.c;h=0515eb5ea94745c54c0864362fd16e7a8bb72fcc;hp=2d299c1c3eb887f20aa60d7726765a38fb069fd6;hb=7d414d938ccbd98fc71383c356fec70ae269b2f5;hpb=db585d7fcb8319fa86543eb062df7fdaf16858c6 diff --git a/zutil/zoom-c.c b/zutil/zoom-c.c index 2d299c1..0515eb5 100644 --- a/zutil/zoom-c.c +++ b/zutil/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (c) 2000-2003, Index Data * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.21 2003-02-17 21:23:32 adam Exp $ + * $Id: zoom-c.c,v 1.26 2003-02-20 15:11:38 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -100,7 +100,7 @@ static void set_dset_error (ZOOM_connection c, int error, else if (addinfo) c->addinfo = xstrdup(addinfo); if (error) - yaz_log(LOG_LOG, "Error %s %s:%d %s %s", + yaz_log(LOG_DEBUG, "Error %s %s:%d %s %s", c->host_port ? c->host_port : "<>", dset, error, addinfo ? addinfo : "", addinfo2 ? addinfo2 : ""); @@ -109,13 +109,13 @@ static void set_dset_error (ZOOM_connection c, int error, static void set_HTTP_error (ZOOM_connection c, int error, const char *addinfo, const char *addinfo2) { - return set_dset_error(c, error, "HTTP", addinfo, addinfo2); + set_dset_error(c, error, "HTTP", addinfo, addinfo2); } static void set_ZOOM_error (ZOOM_connection c, int error, const char *addinfo) { - return set_dset_error(c, error, "ZOOM", addinfo, 0); + set_dset_error(c, error, "ZOOM", addinfo, 0); } static void clear_error (ZOOM_connection c) @@ -388,6 +388,7 @@ ZOOM_query_create(void) s->z_query = 0; s->sort_spec = 0; s->odr = odr_createmem (ODR_ENCODE); + s->query_string = 0; return s; } @@ -410,6 +411,7 @@ ZOOM_query_destroy(ZOOM_query s) ZOOM_API(int) ZOOM_query_prefix(ZOOM_query s, const char *str) { + s->query_string = odr_strdup(s->odr, str); s->z_query = (Z_Query *) odr_malloc (s->odr, sizeof(*s->z_query)); s->z_query->which = Z_Query_type_1; s->z_query->u.type_1 = p_query_rpn(s->odr, PROTO_Z3950, str); @@ -423,16 +425,19 @@ ZOOM_query_cql(ZOOM_query s, const char *str) { Z_External *ext; + s->query_string = odr_strdup(s->odr, str); + ext = (Z_External *) odr_malloc(s->odr, sizeof(*ext)); ext->direct_reference = odr_getoidbystr(s->odr, "1.2.840.10003.16.2"); ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_CQL; - ext->u.cql = odr_strdup(s->odr, str); + ext->u.cql = s->query_string; s->z_query = (Z_Query *) odr_malloc (s->odr, sizeof(*s->z_query)); s->z_query->which = Z_Query_type_104; s->z_query->u.type_104 = ext; + return 0; } @@ -499,8 +504,7 @@ ZOOM_resultset ZOOM_resultset_create () r->count = 0; r->record_cache = 0; r->r_sort_spec = 0; - r->z_query = 0; - r->search = 0; + r->query = 0; r->connection = 0; r->next = 0; return r; @@ -527,8 +531,7 @@ ZOOM_connection_search(ZOOM_connection c, ZOOM_query q) const char *cp; r->r_sort_spec = q->sort_spec; - r->z_query = q->z_query; - r->search = q; + r->query = q; r->options = ZOOM_options_create_with_parent(c->options); @@ -605,7 +608,7 @@ ZOOM_resultset_destroy(ZOOM_resultset r) rp = &(*rp)->next; } } - ZOOM_query_destroy (r->search); + ZOOM_query_destroy (r->query); ZOOM_options_destroy (r->options); odr_destroy (r->odr); xfree (r->setname); @@ -712,7 +715,7 @@ static zoom_ret do_connect (ZOOM_connection c) if (memcmp(c->host_port, "http:", 5) == 0) { -#if HAVE_XSLT +#if HAVE_XML2 const char *path; c->proto = PROTO_SRW; effective_host = c->host_port + 5; @@ -975,7 +978,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) return send_APDU (c, apdu); } -#if HAVE_XSLT +#if HAVE_XML2 static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr) { Z_SOAP_Handler h[2] = { @@ -1018,7 +1021,7 @@ static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr) } #endif -#if HAVE_XSLT +#if HAVE_XML2 static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) { int i; @@ -1056,17 +1059,19 @@ static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) if (i == resultset->count) return zoom_complete; } - assert(resultset->z_query); + assert(resultset->query); sr = yaz_srw_get(c->odr_out, Z_SRW_searchRetrieve_request); - if (resultset->z_query->which == Z_Query_type_104 - && resultset->z_query->u.type_104->which == Z_External_CQL) - sr->u.request->query = resultset->z_query->u.type_104->u.cql; - else if (resultset->z_query->which == Z_Query_type_1) - { - set_ZOOM_error(c, ZOOM_ERROR_UNSUPPORTED_QUERY, "Type-1"); - return zoom_complete; + if (resultset->query->z_query->which == Z_Query_type_104 + && resultset->query->z_query->u.type_104->which == Z_External_CQL) + { + sr->u.request->query = resultset->query->z_query->u.type_104->u.cql; + } + else if (resultset->query->z_query->which == Z_Query_type_1 && + resultset->query->z_query->u.type_1) + { + sr->u.request->pQuery = resultset->query->query_string; } else { @@ -1117,10 +1122,10 @@ static zoom_ret ZOOM_connection_send_search (ZOOM_connection c) mediumSetElementSetName = elementSetName; assert (r); - assert (r->z_query); + assert (r->query); /* prepare query for the search request */ - search_req->query = r->z_query; + search_req->query = r->query->z_query; search_req->databaseNames = set_DatabaseNames (c, r->options, &search_req->num_databaseNames); @@ -2391,7 +2396,7 @@ static void handle_apdu (ZOOM_connection c, Z_APDU *apdu) } } -#if HAVE_XSLT +#if HAVE_XML2 static void handle_srw_response(ZOOM_connection c, Z_SRW_searchRetrieveResponse *res) { @@ -2411,7 +2416,7 @@ static void handle_srw_response(ZOOM_connection c, resultset->size = 0; - yaz_log(LOG_LOG, "got SRW response OK"); + yaz_log(LOG_DEBUG, "got SRW response OK"); if (res->numberOfRecords) resultset->size = *res->numberOfRecords; @@ -2445,7 +2450,6 @@ static void handle_srw_response(ZOOM_connection c, npr->u.databaseRecord->u.octet_aligned->size = res->records[i].recordData_len; record_cache_add (resultset, npr, pos); - yaz_log(LOG_LOG, "add SRW record to cache to pos %d", pos); } if (res->num_diagnostics > 0) { @@ -2458,7 +2462,7 @@ static void handle_srw_response(ZOOM_connection c, } #endif -#if HAVE_XSLT +#if HAVE_XML2 static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres) { int ret = -1; @@ -2572,7 +2576,7 @@ static int do_read (ZOOM_connection c) handle_apdu (c, gdu->u.z3950); else if (gdu->which == Z_GDU_HTTP_Response) { -#if HAVE_XSLT +#if HAVE_XML2 handle_http (c, gdu->u.HTTP_Response); #else set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0); @@ -2729,7 +2733,7 @@ ZOOM_connection_error_x (ZOOM_connection c, const char **cp, else if (!strcmp(c->diagset, "Bib-1")) *cp = ZOOM_diag_str(error); else if (!strcmp(c->diagset, "SRW")) - *cp = yaz_srw_error_str(c->error); + *cp = yaz_diag_srw_str(c->error); else *cp = "Unknown error and diagnostic set"; }