X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-c.c;h=cb16f924a67a0e237a09e55930702fbec27e28e4;hp=1888229dbabffce343f16085d3676843b4daa5d3;hb=e4ef95b2ccfe88d7049543664f00e5fda957dd0c;hpb=951fce6496397a6d8c11e15ab5b60b46abc43467 diff --git a/src/zoom-c.c b/src/zoom-c.c index 1888229..cb16f92 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.105 2007-01-09 13:56:48 adam Exp $ + * $Id: zoom-c.c,v 1.113 2007-02-21 09:19:26 adam Exp $ */ /** * \file zoom-c.c @@ -27,6 +27,8 @@ #include #include +#define TASK_FIX 1 + static int log_api = 0; static int log_details = 0; @@ -39,6 +41,21 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c); static zoom_ret do_write_ex(ZOOM_connection c, char *buf_out, int len_out); static char *cql2pqf(ZOOM_connection c, const char *cql); + +/* + * This wrapper is just for logging failed lookups. It would be nicer + * if it could cause failure when a lookup fails, but that's hard. + */ +static Odr_oid *zoom_yaz_str_to_z3950oid(ZOOM_connection c, + int oid_class, const char *str) { + Odr_oid *res = yaz_str_to_z3950oid(c->odr_out, oid_class, str); + if (res == 0) + yaz_log(YLOG_WARN, "%p OID lookup (%d, '%s') failed", + c, (int) oid_class, str); + return res; +} + + static void initlog(void) { static int log_level_initialized = 0; @@ -103,6 +120,14 @@ static ZOOM_Event ZOOM_connection_get_event(ZOOM_connection c) return event; } +ZOOM_API(int) ZOOM_connection_peek_event(ZOOM_connection c) +{ + ZOOM_Event event = c->m_queue_front; + + return event ? event->kind : ZOOM_EVENT_NONE; +} + +void ZOOM_connection_remove_tasks(ZOOM_connection c); static void set_dset_error(ZOOM_connection c, int error, const char *dset, @@ -129,11 +154,16 @@ static void set_dset_error(ZOOM_connection c, int error, } else if (addinfo) c->addinfo = xstrdup(addinfo); - if (error) + if (error != ZOOM_ERROR_NONE) + { yaz_log(log_api, "%p set_dset_error %s %s:%d %s %s", c, c->host_port ? c->host_port : "<>", dset, error, addinfo ? addinfo : "", addinfo2 ? addinfo2 : ""); +#if TASK_FIX + ZOOM_connection_remove_tasks(c); +#endif + } } #if YAZ_HAVE_XML2 @@ -144,6 +174,7 @@ static void set_HTTP_error(ZOOM_connection c, int error, } #endif + static void set_ZOOM_error(ZOOM_connection c, int error, const char *addinfo) { @@ -1244,7 +1275,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.105 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.113 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -1546,7 +1577,7 @@ static zoom_ret ZOOM_connection_send_search(ZOOM_connection c) } if (syntax) search_req->preferredRecordSyntax = - yaz_str_to_z3950oid(c->odr_out, CLASS_RECSYN, syntax); + zoom_yaz_str_to_z3950oid(c, CLASS_RECSYN, syntax); if (!r->setname) { @@ -2386,6 +2417,16 @@ static void handle_search_response(ZOOM_connection c, Z_SearchResponse *sr) resultset = c->tasks->u.search.resultset; + if (sr->resultSetStatus) + { + ZOOM_options_set_int(resultset->options, "resultSetStatus", + *sr->resultSetStatus); + } + if (sr->presentStatus) + { + ZOOM_options_set_int(resultset->options, "presentStatus", + *sr->presentStatus); + } handle_searchResult(c, resultset, sr->additionalSearchInfo); resultset->size = *sr->resultCount; @@ -2531,7 +2572,7 @@ static zoom_ret send_present(ZOOM_connection c) if (syntax && *syntax) req->preferredRecordSyntax = - yaz_str_to_z3950oid(c->odr_out, CLASS_RECSYN, syntax); + zoom_yaz_str_to_z3950oid(c, CLASS_RECSYN, syntax); if (resultset->schema && *resultset->schema) { @@ -2551,14 +2592,14 @@ static zoom_ret send_present(ZOOM_connection c) compo->u.complex->generic->which = Z_Schema_oid; compo->u.complex->generic->schema.oid = (Odr_oid *) - yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, resultset->schema); + zoom_yaz_str_to_z3950oid (c, CLASS_SCHEMA, resultset->schema); if (!compo->u.complex->generic->schema.oid) { /* OID wasn't a schema! Try record syntax instead. */ compo->u.complex->generic->schema.oid = (Odr_oid *) - yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, resultset->schema); + zoom_yaz_str_to_z3950oid (c, CLASS_RECSYN, resultset->schema); } if (elementSetName && *elementSetName) { @@ -2952,7 +2993,13 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p) *req->u.esRequest->notToKeep->resultSetItem->item = (str ? atoi(str) : 1); } - req->u.esRequest->notToKeep->itemRequest = encode_ill_request(p); + + str = ZOOM_options_get(p->options, "doc"); + if (str) + req->u.esRequest->notToKeep->itemRequest = + z_ext_record(p->odr_out, VAL_TEXT_XML, str, strlen(str)); + else + req->u.esRequest->notToKeep->itemRequest = encode_ill_request(p); return req; } @@ -4119,41 +4166,41 @@ ZOOM_API(int) ZOOM_connection_fire_event_timeout(ZOOM_connection c) } ZOOM_API(int) - ZOOM_process_event(int no, ZOOM_connection *cs) + ZOOM_connection_process(ZOOM_connection c) +{ + ZOOM_Event event; + if (!c) + return 0; + + event = ZOOM_connection_get_event(c); + if (event) + { + ZOOM_Event_destroy(event); + return 1; + } + ZOOM_connection_exec_task(c); + event = ZOOM_connection_get_event(c); + if (event) + { + ZOOM_Event_destroy(event); + return 1; + } + return 0; +} + +ZOOM_API(int) + ZOOM_event_nonblock(int no, ZOOM_connection *cs) { int i; - yaz_log(log_details, "ZOOM_event_poll(no=%d,cs=%p)", no, cs); + yaz_log(log_details, "ZOOM_process_event(no=%d,cs=%p)", no, cs); for (i = 0; i