projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
No leading spaces in warning comments
[yaz-moved-to-github.git]
/
src
/
zoom-c.c
diff --git
a/src/zoom-c.c
b/src/zoom-c.c
index
c28eca7
..
bf4ef42
100644
(file)
--- a/
src/zoom-c.c
+++ b/
src/zoom-c.c
@@
-1,11
+1,14
@@
/*
/*
- * Copyright (c) 2000-2004, Index Data
+ * Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.27 2004-04-28 22:44:59 adam Exp $
- *
- * ZOOM layer for C, connections, result sets, queries.
+ * $Id: zoom-c.c,v 1.37 2005-01-16 22:01:13 adam Exp $
+ */
+/**
+ * \file zoom-c.c
+ * \brief Implements ZOOM C interface.
*/
*/
+
#include <assert.h>
#include <string.h>
#include "zoom-p.h"
#include <assert.h>
#include <string.h>
#include "zoom-p.h"
@@
-21,9
+24,24
@@
#include <yaz/ill.h>
#include <yaz/srw.h>
#include <yaz/ill.h>
#include <yaz/srw.h>
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
#if HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif
#if HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+#ifdef WIN32
+#include <winsock.h>
+#endif
+
+static int log_level = 0;
+static int log_level_initialized = 0;
typedef enum {
zoom_pending,
typedef enum {
zoom_pending,
@@
-91,6
+109,12
@@
static void set_dset_error (ZOOM_connection c, int error,
const char *addinfo, const char *addinfo2)
{
char *cp;
const char *addinfo, const char *addinfo2)
{
char *cp;
+ if (!log_level_initialized)
+ {
+ log_level = yaz_log_module_level("zoom");
+ log_level_initialized = 1;
+ }
+
xfree (c->addinfo);
c->addinfo = 0;
c->error = error;
xfree (c->addinfo);
c->addinfo = 0;
c->error = error;
@@
-104,14
+128,14
@@
static void set_dset_error (ZOOM_connection c, int error,
}
if (addinfo && addinfo2)
{
}
if (addinfo && addinfo2)
{
- c->addinfo = xmalloc(strlen(addinfo) + strlen(addinfo2) + 2);
+ c->addinfo = (char*) xmalloc(strlen(addinfo) + strlen(addinfo2) + 2);
strcpy(c->addinfo, addinfo);
strcat(c->addinfo, addinfo2);
}
else if (addinfo)
c->addinfo = xstrdup(addinfo);
if (error)
strcpy(c->addinfo, addinfo);
strcat(c->addinfo, addinfo2);
}
else if (addinfo)
c->addinfo = xstrdup(addinfo);
if (error)
- yaz_log(LOG_DEBUG, "Error %s %s:%d %s %s",
+ yaz_log(log_level, "Error %s %s:%d %s %s",
c->host_port ? c->host_port : "<>", dset, error,
addinfo ? addinfo : "",
addinfo2 ? addinfo2 : "");
c->host_port ? c->host_port : "<>", dset, error,
addinfo ? addinfo : "",
addinfo2 ? addinfo2 : "");
@@
-224,6
+248,12
@@
ZOOM_connection_create (ZOOM_options options)
{
ZOOM_connection c = (ZOOM_connection) xmalloc (sizeof(*c));
{
ZOOM_connection c = (ZOOM_connection) xmalloc (sizeof(*c));
+ if (!log_level_initialized)
+ {
+ log_level = yaz_log_module_level("zoom");
+ log_level_initialized = 1;
+ }
+
c->proto = PROTO_Z3950;
c->cs = 0;
c->mask = 0;
c->proto = PROTO_Z3950;
c->cs = 0;
c->mask = 0;
@@
-336,13
+366,19
@@
ZOOM_connection_connect(ZOOM_connection c,
const char *val;
ZOOM_task task;
const char *val;
ZOOM_task task;
+ if (!log_level_initialized)
+ {
+ log_level = yaz_log_module_level("zoom");
+ log_level_initialized = 1;
+ }
+
if (c->cs)
{
if (c->cs)
{
- yaz_log (LOG_DEBUG, "reconnect");
+ yaz_log (log_level, "reconnect");
c->reconnect_ok = 1;
return;
}
c->reconnect_ok = 1;
return;
}
- yaz_log(LOG_DEBUG, "connect");
+ yaz_log(log_level, "connect");
xfree (c->proxy);
val = ZOOM_options_get (c->options, "proxy");
if (val && *val)
xfree (c->proxy);
val = ZOOM_options_get (c->options, "proxy");
if (val && *val)
@@
-418,7
+454,7
@@
ZOOM_query_destroy(ZOOM_query s)
return;
(s->refcount)--;
return;
(s->refcount)--;
- yaz_log (LOG_DEBUG, "ZOOM_query_destroy count=%d", s->refcount);
+ yaz_log (log_level, "ZOOM_query_destroy count=%d", s->refcount);
if (s->refcount == 0)
{
odr_destroy (s->odr);
if (s->refcount == 0)
{
odr_destroy (s->odr);
@@
-507,7
+543,7
@@
void ZOOM_resultset_addref (ZOOM_resultset r)
if (r)
{
(r->refcount)++;
if (r)
{
(r->refcount)++;
- yaz_log (LOG_DEBUG, "ZOOM_resultset_addref r=%p count=%d",
+ yaz_log (log_level, "ZOOM_resultset_addref r=%p count=%d",
r, r->refcount);
}
}
r, r->refcount);
}
}
@@
-516,7
+552,13
@@
ZOOM_resultset ZOOM_resultset_create ()
{
ZOOM_resultset r = (ZOOM_resultset) xmalloc (sizeof(*r));
{
ZOOM_resultset r = (ZOOM_resultset) xmalloc (sizeof(*r));
- yaz_log (LOG_DEBUG, "ZOOM_resultset_create r = %p", r);
+ if (!log_level_initialized)
+ {
+ log_level = yaz_log_module_level("zoom");
+ log_level_initialized = 1;
+ }
+
+ yaz_log (log_level, "ZOOM_resultset_create r = %p", r);
r->refcount = 1;
r->size = 0;
r->odr = odr_createmem (ODR_ENCODE);
r->refcount = 1;
r->size = 0;
r->odr = odr_createmem (ODR_ENCODE);
@@
-584,12
+626,12
@@
ZOOM_connection_search(ZOOM_connection c, ZOOM_query q)
{
if (!c->cs)
{
{
if (!c->cs)
{
- yaz_log(LOG_DEBUG, "NO COMSTACK");
+ yaz_log(log_level, "NO COMSTACK");
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
- yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
c->reconnect_ok = 1;
}
}
c->reconnect_ok = 1;
}
}
@@
-622,12
+664,12
@@
ZOOM_API(void)
{
if (!c->cs)
{
{
if (!c->cs)
{
- yaz_log(LOG_DEBUG, "NO COMSTACK");
+ yaz_log(log_level, "NO COMSTACK");
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
- yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
c->reconnect_ok = 1;
}
}
c->reconnect_ok = 1;
}
}
@@
-670,7
+712,7
@@
ZOOM_resultset_destroy(ZOOM_resultset r)
if (!r)
return;
(r->refcount)--;
if (!r)
return;
(r->refcount)--;
- yaz_log (LOG_DEBUG, "ZOOM_resultset_destroy r = %p count=%d",
+ yaz_log (log_level, "ZOOM_resultset_destroy r = %p count=%d",
r, r->refcount);
if (r->refcount == 0)
{
r, r->refcount);
if (r->refcount == 0)
{
@@
-732,12
+774,12
@@
static void ZOOM_resultset_retrieve (ZOOM_resultset r,
{
if (!c->cs)
{
{
if (!c->cs)
{
- yaz_log(LOG_DEBUG, "NO COMSTACK");
+ yaz_log(log_level, "NO COMSTACK");
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
- yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
c->reconnect_ok = 1;
}
}
c->reconnect_ok = 1;
}
}
@@
-799,15
+841,22
@@
static zoom_ret do_connect (ZOOM_connection c)
{
void *add;
const char *effective_host;
{
void *add;
const char *effective_host;
+ if (!log_level_initialized)
+ {
+ log_level = yaz_log_module_level("zoom");
+ log_level_initialized = 1;
+ }
+
if (c->proxy)
effective_host = c->proxy;
else
effective_host = c->host_port;
if (c->proxy)
effective_host = c->proxy;
else
effective_host = c->host_port;
- yaz_log (LOG_DEBUG, "do_connect host=%s", effective_host);
+ yaz_log (log_level, "do_connect host=%s", effective_host);
- assert (!c->cs);
+ if (c->cs)
+ cs_close(c->cs);
c->cs = cs_create_host (effective_host, 0, &add);
if (c->cs && c->cs->protocol == PROTO_HTTP)
c->cs = cs_create_host (effective_host, 0, &add);
if (c->cs && c->cs->protocol == PROTO_HTTP)
@@
-818,7
+867,7
@@
static zoom_ret do_connect (ZOOM_connection c)
c->proto = PROTO_HTTP;
cs_get_host_args(c->host_port, &path);
xfree(c->path);
c->proto = PROTO_HTTP;
cs_get_host_args(c->host_port, &path);
xfree(c->path);
- c->path = xmalloc(strlen(path)+2);
+ c->path = (char*) xmalloc(strlen(path)+2);
c->path[0] = '/';
strcpy (c->path+1, path);
#else
c->path[0] = '/';
strcpy (c->path+1, path);
#else
@@
-938,7
+987,7
@@
static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out)
z_APDU(odr_pr, &a, 0, 0);
odr_destroy(odr_pr);
}
z_APDU(odr_pr, &a, 0, 0);
odr_destroy(odr_pr);
}
- yaz_log (LOG_DEBUG, "encoding failed");
+ yaz_log (log_level, "encoding failed");
set_ZOOM_error(c, ZOOM_ERROR_ENCODE, 0);
odr_reset(out);
return -1;
set_ZOOM_error(c, ZOOM_ERROR_ENCODE, 0);
odr_reset(out);
return -1;
@@
-953,7
+1002,7
@@
static zoom_ret send_APDU (ZOOM_connection c, Z_APDU *a)
assert (a);
if (encode_APDU(c, a, c->odr_out))
return zoom_complete;
assert (a);
if (encode_APDU(c, a, c->odr_out))
return zoom_complete;
- yaz_log(LOG_DEBUG, "send APDU type=%d", a->which);
+ yaz_log(log_level, "send APDU type=%d", a->which);
c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
event = ZOOM_Event_create (ZOOM_EVENT_SEND_APDU);
ZOOM_connection_put_event (c, event);
c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
event = ZOOM_Event_create (ZOOM_EVENT_SEND_APDU);
ZOOM_connection_put_event (c, event);
@@
-1000,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));
ZOOM_options_get(c->options, "implementationName"),
odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.27 $");
+ 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,
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion = odr_prepend(c->odr_out,
@@
-1091,7
+1140,7
@@
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_PDU *sr)
};
ODR o = odr_createmem(ODR_ENCODE);
int ret;
};
ODR o = odr_createmem(ODR_ENCODE);
int ret;
- Z_SOAP *p = odr_malloc(o, sizeof(*p));
+ Z_SOAP *p = (Z_SOAP*) odr_malloc(o, sizeof(*p));
Z_GDU *gdu;
ZOOM_Event event;
Z_GDU *gdu;
ZOOM_Event event;
@@
-1113,7
+1162,7
@@
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_PDU *sr)
if (cp0 && cp1)
{
if (cp0 && cp1)
{
- char *h = odr_malloc(c->odr_out, cp1 - cp0 + 1);
+ char *h = (char*) odr_malloc(c->odr_out, cp1 - cp0 + 1);
memcpy (h, cp0, cp1 - cp0);
h[cp1-cp0] = '\0';
z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
memcpy (h, cp0, cp1 - cp0);
h[cp1-cp0] = '\0';
z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
@@
-1132,7
+1181,7
@@
static zoom_ret send_srw (ZOOM_connection c, Z_SRW_PDU *sr)
z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
"SOAPAction", "\"\"");
p->which = Z_SOAP_generic;
z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
"SOAPAction", "\"\"");
p->which = Z_SOAP_generic;
- p->u.generic = odr_malloc(o, sizeof(*p->u.generic));
+ p->u.generic = (Z_SOAP_Generic *) odr_malloc(o, sizeof(*p->u.generic));
p->u.generic->no = 0;
p->u.generic->ns = 0;
p->u.generic->p = sr;
p->u.generic->no = 0;
p->u.generic->ns = 0;
p->u.generic->p = sr;
@@
-1348,7
+1397,7
@@
static zoom_ret ZOOM_connection_send_search (ZOOM_connection c)
break;
}
r->setname = xstrdup (setname);
break;
}
r->setname = xstrdup (setname);
- yaz_log (LOG_DEBUG, "allocating set %s", r->setname);
+ yaz_log (log_level, "allocating set %s", r->setname);
}
else
r->setname = xstrdup ("default");
}
else
r->setname = xstrdup ("default");
@@
-1664,7
+1713,8
@@
ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len)
}
if (r->which == Z_External_sutrs)
return record_iconv_return(rec, len,
}
if (r->which == Z_External_sutrs)
return record_iconv_return(rec, len,
- r->u.sutrs->buf, r->u.sutrs->len,
+ (char*) r->u.sutrs->buf,
+ r->u.sutrs->len,
charset);
else if (r->which == Z_External_octet)
{
charset);
else if (r->which == Z_External_octet)
{
@@
-1949,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! */
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! */
}
}
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);
}
}
}
}
}
}
@@
-1970,7
+2028,7
@@
static void handle_search_response (ZOOM_connection c, Z_SearchResponse *sr)
ZOOM_resultset resultset;
ZOOM_Event event;
ZOOM_resultset resultset;
ZOOM_Event event;
- yaz_log (LOG_DEBUG, "got search response");
+ yaz_log (log_level, "got search response");
if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH)
return ;
if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH)
return ;
@@
-2417,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;
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));
req->u.esRequest = (Z_IORequest *)
odr_malloc(p->odr_out,sizeof(Z_IORequest));
@@
-2503,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 = 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->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));
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)
if (toKeepP)
*toKeepP = toKeep;
if (notToKeepP)
@@
-2612,7
+2670,7
@@
static Z_APDU *create_update_package(ZOOM_package p)
odr_malloc (p->odr_out, sizeof(Odr_oct));
notToKeep->elements[0]->u.opaque->size =
notToKeep->elements[0]->u.opaque->len = strlen(recordIdOpaque);
odr_malloc (p->odr_out, sizeof(Odr_oct));
notToKeep->elements[0]->u.opaque->size =
notToKeep->elements[0]->u.opaque->len = strlen(recordIdOpaque);
- notToKeep->elements[0]->u.opaque->buf =
+ notToKeep->elements[0]->u.opaque->buf = (unsigned char*)
odr_strdup(p->odr_out, recordIdOpaque);
}
else if (recordIdNumber)
odr_strdup(p->odr_out, recordIdOpaque);
}
else if (recordIdNumber)
@@
-2669,17
+2727,22
@@
ZOOM_API(void)
apdu->u.extendedServicesRequest->taskSpecificParameters = r;
}
}
apdu->u.extendedServicesRequest->taskSpecificParameters = r;
}
}
- if (!strcmp(type, "create")) /* create database */
+ else if (!strcmp(type, "create")) /* create database */
{
apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_create,
0, 0);
}
{
apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_create,
0, 0);
}
- if (!strcmp(type, "drop")) /* drop database */
+ else if (!strcmp(type, "drop")) /* drop database */
{
apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_drop,
0, 0);
}
{
apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_drop,
0, 0);
}
- if (!strcmp(type, "update")) /* update record(s) */
+ else if (!strcmp(type, "commit")) /* commit changes */
+ {
+ apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_commit,
+ 0, 0);
+ }
+ else if (!strcmp(type, "update")) /* update record(s) */
{
apdu = create_update_package(p);
}
{
apdu = create_update_package(p);
}
@@
-2756,20
+2819,20
@@
static int ZOOM_connection_exec_task (ZOOM_connection c)
if (!task)
{
if (!task)
{
- yaz_log (LOG_DEBUG, "ZOOM_connection_exec_task task=<null>");
+ yaz_log (log_level, "ZOOM_connection_exec_task task=<null>");
return 0;
}
return 0;
}
- yaz_log (LOG_DEBUG, "ZOOM_connection_exec_task type=%d run=%d",
+ yaz_log (log_level, "ZOOM_connection_exec_task type=%d run=%d",
task->which, task->running);
if (c->error != ZOOM_ERROR_NONE)
{
task->which, task->running);
if (c->error != ZOOM_ERROR_NONE)
{
- yaz_log (LOG_DEBUG, "remove tasks because of error = %d", c->error);
+ yaz_log (log_level, "remove tasks because of error = %d", c->error);
ZOOM_connection_remove_tasks (c);
return 0;
}
if (task->running)
{
ZOOM_connection_remove_tasks (c);
return 0;
}
if (task->running)
{
- yaz_log (LOG_DEBUG, "task already running");
+ yaz_log (log_level, "task already running");
return 0;
}
task->running = 1;
return 0;
}
task->running = 1;
@@
-2808,16
+2871,16
@@
static int ZOOM_connection_exec_task (ZOOM_connection c)
}
else
{
}
else
{
- yaz_log (LOG_DEBUG, "remove tasks because no connection exist");
+ yaz_log (log_level, "remove tasks because no connection exist");
ZOOM_connection_remove_tasks (c);
}
if (ret == zoom_complete)
{
ZOOM_connection_remove_tasks (c);
}
if (ret == zoom_complete)
{
- yaz_log (LOG_DEBUG, "task removed (complete)");
+ yaz_log (log_level, "task removed (complete)");
ZOOM_connection_remove_task (c);
return 0;
}
ZOOM_connection_remove_task (c);
return 0;
}
- yaz_log (LOG_DEBUG, "task pending");
+ yaz_log (log_level, "task pending");
return 1;
}
return 1;
}
@@
-2858,7
+2921,7
@@
static void handle_apdu (ZOOM_connection c, Z_APDU *apdu)
Z_InitResponse *initrs;
c->mask = 0;
Z_InitResponse *initrs;
c->mask = 0;
- yaz_log (LOG_DEBUG, "recv APDU type=%d", apdu->which);
+ yaz_log (log_level, "recv APDU type=%d", apdu->which);
switch(apdu->which)
{
case Z_APDU_initResponse:
switch(apdu->which)
{
case Z_APDU_initResponse:
@@
-2913,11
+2976,11
@@
static void handle_apdu (ZOOM_connection c, Z_APDU *apdu)
if (p)
{
if (p)
{
- char *charset=NULL, *lang=NULL;
+ char *charset = NULL, *lang = NULL;
int sel;
yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel);
int sel;
yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel);
- yaz_log(LOG_DEBUG, "Target accepted: charset %s, "
+ yaz_log(log_level, "Target accepted: charset %s, "
"language %s, select %d",
charset ? charset : "none", lang ? lang : "none", sel);
if (charset)
"language %s, select %d",
charset ? charset : "none", lang ? lang : "none", sel);
if (charset)
@@
-2996,7
+3059,7
@@
static void handle_srw_response(ZOOM_connection c,
resultset->size = 0;
resultset->size = 0;
- yaz_log(LOG_DEBUG, "got SRW response OK");
+ yaz_log(log_level, "got SRW response OK");
if (res->numberOfRecords)
resultset->size = *res->numberOfRecords;
if (res->numberOfRecords)
resultset->size = *res->numberOfRecords;
@@
-3024,7
+3087,7
@@
static void handle_srw_response(ZOOM_connection c,
npr->u.databaseRecord->which = Z_External_octet;
npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
odr_malloc(c->odr_in, sizeof(Odr_oct));
npr->u.databaseRecord->which = Z_External_octet;
npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
odr_malloc(c->odr_in, sizeof(Odr_oct));
- npr->u.databaseRecord->u.octet_aligned->buf =
+ npr->u.databaseRecord->u.octet_aligned->buf = (unsigned char*)
res->records[i].recordData_buf;
npr->u.databaseRecord->u.octet_aligned->len =
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_buf;
npr->u.databaseRecord->u.octet_aligned->len =
npr->u.databaseRecord->u.octet_aligned->size =
@@
-3059,7
+3122,7
@@
static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
const char *connection_head = z_HTTP_header_lookup(hres->headers,
"Connection");
c->mask = 0;
const char *connection_head = z_HTTP_header_lookup(hres->headers,
"Connection");
c->mask = 0;
- yaz_log (LOG_DEBUG, "handle_http");
+ yaz_log (log_level, "handle_http");
if (content_type && !yaz_strcmp_del("text/xml", content_type, "; "))
{
if (content_type && !yaz_strcmp_del("text/xml", content_type, "; "))
{
@@
-3076,7
+3139,7
@@
static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
if (!ret && soap_package->which == Z_SOAP_generic &&
soap_package->u.generic->no == 0)
{
if (!ret && soap_package->which == Z_SOAP_generic &&
soap_package->u.generic->no == 0)
{
- Z_SRW_PDU *sr = soap_package->u.generic->p;
+ Z_SRW_PDU *sr = (Z_SRW_PDU*) soap_package->u.generic->p;
if (sr->which == Z_SRW_searchRetrieve_response)
handle_srw_response(c, sr->u.response);
else
if (sr->which == Z_SRW_searchRetrieve_response)
handle_srw_response(c, sr->u.response);
else
@@
-3126,7
+3189,7
@@
static int do_read (ZOOM_connection c)
r = cs_get (c->cs, &c->buf_in, &c->len_in);
more = cs_more(c->cs);
r = cs_get (c->cs, &c->buf_in, &c->len_in);
more = cs_more(c->cs);
- yaz_log (LOG_DEBUG, "do_read len=%d more=%d", r, more);
+ yaz_log (log_level, "do_read len=%d more=%d", r, more);
if (r == 1)
return 0;
if (r <= 0)
if (r == 1)
return 0;
if (r <= 0)
@@
-3135,7
+3198,7
@@
static int do_read (ZOOM_connection c)
{
do_close (c);
c->reconnect_ok = 0;
{
do_close (c);
c->reconnect_ok = 0;
- yaz_log (LOG_DEBUG, "reconnect read");
+ yaz_log (log_level, "reconnect read");
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
}
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
}
@@
-3190,14
+3253,14
@@
static zoom_ret do_write_ex (ZOOM_connection c, char *buf_out, int len_out)
event = ZOOM_Event_create(ZOOM_EVENT_SEND_DATA);
ZOOM_connection_put_event (c, event);
event = ZOOM_Event_create(ZOOM_EVENT_SEND_DATA);
ZOOM_connection_put_event (c, event);
- yaz_log (LOG_DEBUG, "do_write_ex len=%d", len_out);
- if ((r=cs_put (c->cs, buf_out, len_out)) < 0)
+ yaz_log (log_level, "do_write_ex len=%d", len_out);
+ if ((r = cs_put(c->cs, buf_out, len_out)) < 0)
{
if (c->reconnect_ok)
{
do_close (c);
c->reconnect_ok = 0;
{
if (c->reconnect_ok)
{
do_close (c);
c->reconnect_ok = 0;
- yaz_log (LOG_DEBUG, "reconnect write");
+ yaz_log (log_level, "reconnect write");
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
return zoom_pending;
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
return zoom_pending;
@@
-3216,12
+3279,12
@@
static zoom_ret do_write_ex (ZOOM_connection c, char *buf_out, int len_out)
c->mask += ZOOM_SELECT_WRITE;
if (c->cs->io_pending & CS_WANT_READ)
c->mask += ZOOM_SELECT_READ;
c->mask += ZOOM_SELECT_WRITE;
if (c->cs->io_pending & CS_WANT_READ)
c->mask += ZOOM_SELECT_READ;
- yaz_log (LOG_DEBUG, "do_write_ex 1 mask=%d", c->mask);
+ yaz_log (log_level, "do_write_ex 1 mask=%d", c->mask);
}
else
{
c->mask = ZOOM_SELECT_READ|ZOOM_SELECT_EXCEPT;
}
else
{
c->mask = ZOOM_SELECT_READ|ZOOM_SELECT_EXCEPT;
- yaz_log (LOG_DEBUG, "do_write_ex 2 mask=%d", c->mask);
+ yaz_log (log_level, "do_write_ex 2 mask=%d", c->mask);
}
return zoom_pending;
}
}
return zoom_pending;
}
@@
-3358,7
+3421,7
@@
static int ZOOM_connection_do_io(ZOOM_connection c, int mask)
{
ZOOM_Event event = 0;
int r = cs_look(c->cs);
{
ZOOM_Event event = 0;
int r = cs_look(c->cs);
- yaz_log (LOG_DEBUG, "ZOOM_connection_do_io c=%p mask=%d cs_look=%d",
+ yaz_log (log_level, "ZOOM_connection_do_io c=%p mask=%d cs_look=%d",
c, mask, r);
if (r == CS_NONE)
c, mask, r);
if (r == CS_NONE)
@@
-3374,7
+3437,7
@@
static int ZOOM_connection_do_io(ZOOM_connection c, int mask)
event = ZOOM_Event_create (ZOOM_EVENT_CONNECT);
ret = cs_rcvconnect (c->cs);
event = ZOOM_Event_create (ZOOM_EVENT_CONNECT);
ret = cs_rcvconnect (c->cs);
- yaz_log (LOG_DEBUG, "cs_rcvconnect returned %d", ret);
+ yaz_log (log_level, "cs_rcvconnect returned %d", ret);
if (ret == 1)
{
c->mask = ZOOM_SELECT_EXCEPT;
if (ret == 1)
{
c->mask = ZOOM_SELECT_EXCEPT;
@@
-3559,9
+3622,9
@@
ZOOM_event (int no, ZOOM_connection *cs)
#else
tv.tv_sec = timeout;
tv.tv_usec = 0;
#else
tv.tv_sec = timeout;
tv.tv_usec = 0;
- yaz_log (LOG_DEBUG, "select start");
+ yaz_log (log_level, "select start");
r = select (max_fd+1, &input, &output, &except, &tv);
r = select (max_fd+1, &input, &output, &except, &tv);
- yaz_log (LOG_DEBUG, "select stop, returned r=%d", r);
+ yaz_log (log_level, "select stop, returned r=%d", r);
for (i = 0; i<no; i++)
{
ZOOM_connection c = cs[i];
for (i = 0; i<no; i++)
{
ZOOM_connection c = cs[i];
@@
-3589,7
+3652,7
@@
ZOOM_event (int no, ZOOM_connection *cs)
/* timeout and this connection was waiting */
set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
do_close (c);
/* timeout and this connection was waiting */
set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
do_close (c);
- yaz_log (LOG_DEBUG, "timeout");
+ yaz_log (log_level, "timeout");
ZOOM_connection_put_event(c, event);
}
}
ZOOM_connection_put_event(c, event);
}
}