X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-c.c;h=bf4ef42f31a70a1bb75a9806872da26cc83676ad;hb=cd08b51966f34ed2b871f87bc07dd51a0d3fd6a4;hp=cc671a8ebd59e6310692dfabe538eec12658f933;hpb=f4c095a042b1bcccb78136be87944e46412386aa;p=yaz-moved-to-github.git diff --git a/src/zoom-c.c b/src/zoom-c.c index cc671a8..bf4ef42 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2000-2004, Index Data + * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.33 2004-12-13 14:21:56 heikki Exp $ + * $Id: zoom-c.c,v 1.37 2005-01-16 22:01:13 adam Exp $ */ /** * \file zoom-c.c @@ -24,12 +24,24 @@ #include #include +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif #if HAVE_SYS_POLL_H #include #endif +#if HAVE_SYS_SELECT_H +#include +#endif +#ifdef WIN32 +#include +#endif -static int log_level=0; -static int log_level_initialized=0; +static int log_level = 0; +static int log_level_initialized = 0; typedef enum { zoom_pending, @@ -99,8 +111,8 @@ static void set_dset_error (ZOOM_connection c, int error, char *cp; if (!log_level_initialized) { - log_level=yaz_log_module_level("zoom"); - log_level_initialized=1; + log_level = yaz_log_module_level("zoom"); + log_level_initialized = 1; } xfree (c->addinfo); @@ -238,8 +250,8 @@ ZOOM_connection_create (ZOOM_options options) if (!log_level_initialized) { - log_level=yaz_log_module_level("zoom"); - log_level_initialized=1; + log_level = yaz_log_module_level("zoom"); + log_level_initialized = 1; } c->proto = PROTO_Z3950; @@ -356,8 +368,8 @@ ZOOM_connection_connect(ZOOM_connection c, if (!log_level_initialized) { - log_level=yaz_log_module_level("zoom"); - log_level_initialized=1; + log_level = yaz_log_module_level("zoom"); + log_level_initialized = 1; } if (c->cs) @@ -542,8 +554,8 @@ ZOOM_resultset ZOOM_resultset_create () if (!log_level_initialized) { - log_level=yaz_log_module_level("zoom"); - log_level_initialized=1; + log_level = yaz_log_module_level("zoom"); + log_level_initialized = 1; } yaz_log (log_level, "ZOOM_resultset_create r = %p", r); @@ -831,8 +843,8 @@ static zoom_ret do_connect (ZOOM_connection c) const char *effective_host; if (!log_level_initialized) { - log_level=yaz_log_module_level("zoom"); - log_level_initialized=1; + log_level = yaz_log_module_level("zoom"); + log_level_initialized = 1; } @@ -1037,7 +1049,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) ZOOM_options_get(c->options, "implementationName"), odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.33 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.37 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = odr_prepend(c->odr_out, @@ -1987,13 +1999,21 @@ static void handle_records (ZOOM_connection c, Z_Records *sr, if (present_phase && p->num_records == 0) { /* present response and we didn't get any records! */ - set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0); + Z_NamePlusRecord *myrec = + zget_surrogateDiagRec(resultset->odr, 0, 14, 0); + record_cache_add(resultset, myrec, resultset->start); + yaz_log(YLOG_LOG, "pseudo record 1, at pos %d", + resultset->start); } } else if (present_phase) { /* present response and we didn't get any records! */ - set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0); + Z_NamePlusRecord *myrec = + zget_surrogateDiagRec(resultset->odr, 0, 14, 0); + record_cache_add(resultset, myrec, resultset->start); + yaz_log(YLOG_LOG, "pseudo record 1, at pos %d", + resultset->start); } } } @@ -2455,7 +2475,7 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p) Z_ItemOrder *req = (Z_ItemOrder *) odr_malloc (p->odr_out, sizeof(*req)); const char *str; - req->which=Z_IOItemOrder_esRequest; + req->which = Z_IOItemOrder_esRequest; req->u.esRequest = (Z_IORequest *) odr_malloc(p->odr_out,sizeof(Z_IORequest)); @@ -2541,17 +2561,17 @@ Z_APDU *create_admin_package(ZOOM_package p, int type, toKeep = r->u.adminService->u.esRequest->toKeep = (Z_ESAdminOriginPartToKeep *) odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest->toKeep)); - toKeep->which=type; + toKeep->which = type; toKeep->databaseName = odr_strdup(p->odr_out, first_db); - toKeep->u.create=odr_nullval(); + toKeep->u.create = odr_nullval(); apdu->u.extendedServicesRequest->taskSpecificParameters = r; r->u.adminService->u.esRequest->notToKeep = notToKeep = (Z_ESAdminOriginPartNotToKeep *) odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest->notToKeep)); - notToKeep->which=Z_ESAdminOriginPartNotToKeep_recordsWillFollow; - notToKeep->u.recordsWillFollow=odr_nullval(); + notToKeep->which = Z_ESAdminOriginPartNotToKeep_recordsWillFollow; + notToKeep->u.recordsWillFollow = odr_nullval(); if (toKeepP) *toKeepP = toKeep; if (notToKeepP) @@ -2956,7 +2976,7 @@ static void handle_apdu (ZOOM_connection c, Z_APDU *apdu) if (p) { - char *charset=NULL, *lang=NULL; + char *charset = NULL, *lang = NULL; int sel; yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel); @@ -3234,7 +3254,7 @@ static zoom_ret do_write_ex (ZOOM_connection c, char *buf_out, int len_out) ZOOM_connection_put_event (c, event); yaz_log (log_level, "do_write_ex len=%d", len_out); - if ((r=cs_put (c->cs, buf_out, len_out)) < 0) + if ((r = cs_put(c->cs, buf_out, len_out)) < 0) { if (c->reconnect_ok) {