X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-c.c;h=fe7971dfe0889755cc7b26f2a5437c41e760337e;hp=202e6641e4745952c326ec8d17d88527e7faaa9f;hb=c92a1e74838a25214df478878806c7fb48167db5;hpb=fd6a4db386252ed1b777ad2900ea26a0a9513662 diff --git a/src/zoom-c.c b/src/zoom-c.c index 202e664..fe7971d 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -41,7 +41,7 @@ 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); -const char *ZOOM_get_event_str(int event) +ZOOM_API(const char *) ZOOM_get_event_str(int event) { static const char *ar[] = { "NONE", @@ -479,6 +479,14 @@ ZOOM_API(void) set_ZOOM_error(c, ZOOM_ERROR_NONE, 0); ZOOM_connection_remove_tasks(c); + if (ZOOM_options_get_bool(c->options, "apdulog", 0)) + { + c->odr_print = odr_createmem(ODR_PRINT); + odr_setprint(c->odr_print, yaz_log_file()); + } + else + c->odr_print = 0; + if (c->cs) { yaz_log(log_details, "%p ZOOM_connection_connect reconnect ok", c); @@ -613,13 +621,6 @@ ZOOM_API(void) ZOOM_options_get_int(c->options, "preferredMessageSize", 1024*1024); c->async = ZOOM_options_get_bool(c->options, "async", 0); - if (ZOOM_options_get_bool(c->options, "apdulog", 0)) - { - c->odr_print = odr_createmem(ODR_PRINT); - odr_setprint(c->odr_print, yaz_log_file()); - } - else - c->odr_print = 0; yaz_log(log_details, "%p ZOOM_connection_connect async=%d", c, c->async); task = ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT); @@ -929,6 +930,7 @@ ZOOM_API(ZOOM_resultset) task->u.search.resultset = r; task->u.search.start = start; task->u.search.count = count; + task->u.search.recv_search_fired = 0; syntax = ZOOM_options_get(r->options, "preferredRecordSyntax"); task->u.search.syntax = syntax ? xstrdup(syntax) : 0; @@ -1360,7 +1362,6 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) Z_InitRequest *ireq = apdu->u.initRequest; Z_IdAuthentication *auth = (Z_IdAuthentication *) odr_malloc(c->odr_out, sizeof(*auth)); - char *version; ODR_MASK_SET(ireq->options, Z_Options_search); ODR_MASK_SET(ireq->options, Z_Options_present); @@ -1373,11 +1374,10 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3); - /* Index Data's Z39.50 Implementor Id is 81 */ ireq->implementationId = odr_prepend(c->odr_out, ZOOM_options_get(c->options, "implementationId"), - odr_prepend(c->odr_out, "81", ireq->implementationId)); + ireq->implementationId); ireq->implementationName = odr_prepend(c->odr_out, @@ -1385,14 +1385,10 @@ 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.154 $"); - if (strlen(version) > 10) /* check for unexpanded CVS strings */ - version[strlen(version)-2] = '\0'; ireq->implementationVersion = odr_prepend(c->odr_out, ZOOM_options_get(c->options, "implementationVersion"), - odr_prepend(c->odr_out, &version[11], - ireq->implementationVersion)); + ireq->implementationVersion); *ireq->maximumRecordSize = c->maximum_record_size; *ireq->preferredMessageSize = c->preferred_message_size; @@ -1443,8 +1439,17 @@ static zoom_ret send_srw(ZOOM_connection c, Z_SRW_PDU *sr) { Z_GDU *gdu; ZOOM_Event event; - - gdu = z_get_HTTP_Request_host_path(c->odr_out, c->host_port, c->path); + const char *database = ZOOM_options_get(c->options, "databaseName"); + char *fdatabase = 0; + + if (database) + { + fdatabase = (char *) odr_malloc(c->odr_out, strlen(database)+2); + strcpy(fdatabase, "/"); + strcat(fdatabase, database); + } + gdu = z_get_HTTP_Request_host_path(c->odr_out, c->host_port, + fdatabase ? fdatabase : c->path); if (c->sru_mode == zoom_sru_get) { @@ -3985,9 +3990,12 @@ static zoom_ret handle_srw_response(ZOOM_connection c, syntax = c->tasks->u.search.syntax; elementSetName = c->tasks->u.search.elementSetName; - event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH); - ZOOM_connection_put_event(c, event); - + if (!c->tasks->u.search.recv_search_fired) + { + event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH); + ZOOM_connection_put_event(c, event); + c->tasks->u.search.recv_search_fired = 1; + } break; case ZOOM_TASK_RETRIEVE: resultset = c->tasks->u.retrieve.resultset; @@ -4015,8 +4023,6 @@ static zoom_ret handle_srw_response(ZOOM_connection c, { if (res->numberOfRecords) resultset->size = *res->numberOfRecords; - - yaz_log(YLOG_LOG, "resultset->size=%d", resultset->size); for (i = 0; inum_records; i++) { int pos;