* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.127 2007-04-30 08:29:07 adam Exp $
+ * $Id: zoom-c.c,v 1.130 2007-05-08 08:22:36 adam Exp $
*/
/**
* \file zoom-c.c
* 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 int *zoom_yaz_str_to_z3950oid(ZOOM_connection c,
+static Odr_oid *zoom_yaz_str_to_z3950oid(ZOOM_connection c,
int oid_class, const char *str) {
- int *res = yaz_string_to_oid_odr(yaz_oid_std(), oid_class, str,
+ Odr_oid *res = yaz_string_to_oid_odr(yaz_oid_std(), oid_class, str,
c->odr_out);
if (res == 0)
yaz_log(YLOG_WARN, "%p OID lookup (%d, '%s') failed",
c->client_IP = 0;
c->tasks = 0;
+ c->user = 0;
+ c->group = 0;
+ c->password = 0;
+
+ c->maximum_record_size = 0;
+ c->preferred_message_size = 0;
+
c->odr_in = odr_createmem(ODR_DECODE);
c->odr_out = odr_createmem(ODR_ENCODE);
}
yaz_log(log_details, "%p ZOOM_connection_connect connect", c);
xfree(c->proxy);
+ c->proxy = 0;
val = ZOOM_options_get(c->options, "proxy");
if (val && *val)
{
yaz_log(log_details, "%p ZOOM_connection_connect proxy=%s", c, val);
c->proxy = xstrdup(val);
}
- else
- c->proxy = 0;
xfree(c->charset);
+ c->charset = 0;
val = ZOOM_options_get(c->options, "charset");
if (val && *val)
{
yaz_log(log_details, "%p ZOOM_connection_connect charset=%s", c, val);
c->charset = xstrdup(val);
}
- else
- c->charset = 0;
xfree(c->lang);
val = ZOOM_options_get(c->options, "lang");
ZOOM_options_set(c->options, "host", c->host_port);
+ xfree(c->cookie_out);
+ c->cookie_out = 0;
val = ZOOM_options_get(c->options, "cookie");
if (val && *val)
{
c->cookie_out = xstrdup(val);
}
+ xfree(c->client_IP);
+ c->client_IP = 0;
val = ZOOM_options_get(c->options, "clientIP");
if (val && *val)
{
c->client_IP = xstrdup(val);
}
+ xfree(c->group);
+ c->group = 0;
+ val = ZOOM_options_get(c->options, "group");
+ if (val && *val)
+ c->group = xstrdup(val);
+
+ xfree(c->user);
+ c->user = 0;
+ val = ZOOM_options_get(c->options, "user");
+ if (val && *val)
+ c->user = xstrdup(val);
+
+ xfree(c->password);
+ c->password = 0;
+ val = ZOOM_options_get(c->options, "password");
+ if (!val)
+ val = ZOOM_options_get(c->options, "pass");
+
+ if (val && *val)
+ c->password = xstrdup(val);
+
+ c->maximum_record_size =
+ ZOOM_options_get_int(c->options, "maximumRecordSize", 1024*1024);
+ c->preferred_message_size =
+ ZOOM_options_get_int(c->options, "preferredMessageSize", 1024*1024);
+
c->async = ZOOM_options_get_bool(c->options, "async", 0);
yaz_log(log_details, "%p ZOOM_connection_connect async=%d", c, c->async);
xfree(c->cookie_out);
xfree(c->cookie_in);
xfree(c->client_IP);
+ xfree(c->user);
+ xfree(c->group);
+ xfree(c->password);
xfree(c);
}
for (i = 0; i<200; i++)
{
size_t len;
- int *oid;
+ Odr_oid *oid;
Z_OtherInformation **oi;
char buf[80];
const char *val;
Z_InitRequest *ireq = apdu->u.initRequest;
Z_IdAuthentication *auth = (Z_IdAuthentication *)
odr_malloc(c->odr_out, sizeof(*auth));
- const char *auth_groupId = ZOOM_options_get(c->options, "group");
- const char *auth_userId = ZOOM_options_get(c->options, "user");
- const char *auth_password = ZOOM_options_get(c->options, "password");
char *version;
- /* support the pass for backwards compatibility */
- if (!auth_password)
- auth_password = ZOOM_options_get(c->options, "pass");
-
ODR_MASK_SET(ireq->options, Z_Options_search);
ODR_MASK_SET(ireq->options, Z_Options_present);
ODR_MASK_SET(ireq->options, Z_Options_scan);
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.127 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.130 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion =
odr_prepend(c->odr_out, &version[11],
ireq->implementationVersion));
- *ireq->maximumRecordSize =
- ZOOM_options_get_int(c->options, "maximumRecordSize", 1024*1024);
- *ireq->preferredMessageSize =
- ZOOM_options_get_int(c->options, "preferredMessageSize", 1024*1024);
+ *ireq->maximumRecordSize = c->maximum_record_size;
+ *ireq->preferredMessageSize = c->preferred_message_size;
- if (auth_groupId || auth_password)
+ if (c->group || c->password)
{
Z_IdPass *pass = (Z_IdPass *) odr_malloc(c->odr_out, sizeof(*pass));
- int i = 0;
pass->groupId = 0;
- if (auth_groupId && *auth_groupId)
- {
- pass->groupId = (char *)
- odr_malloc(c->odr_out, strlen(auth_groupId)+1);
- strcpy(pass->groupId, auth_groupId);
- i++;
- }
+ if (c->group)
+ pass->groupId = odr_strdup(c->odr_out, c->group);
pass->userId = 0;
- if (auth_userId && *auth_userId)
- {
- pass->userId = (char *)
- odr_malloc(c->odr_out, strlen(auth_userId)+1);
- strcpy(pass->userId, auth_userId);
- i++;
- }
+ if (c->user)
+ pass->userId = odr_strdup(c->odr_out, c->user);
pass->password = 0;
- if (auth_password && *auth_password)
- {
- pass->password = (char *)
- odr_malloc(c->odr_out, strlen(auth_password)+1);
- strcpy(pass->password, auth_password);
- i++;
- }
- if (i)
- {
- auth->which = Z_IdAuthentication_idPass;
- auth->u.idPass = pass;
- ireq->idAuthentication = auth;
- }
+ if (c->password)
+ pass->password = odr_strdup(c->odr_out, c->password);
+ auth->which = Z_IdAuthentication_idPass;
+ auth->u.idPass = pass;
+ ireq->idAuthentication = auth;
}
- else if (auth_userId)
+ else if (c->user)
{
auth->which = Z_IdAuthentication_open;
- auth->u.open = (char *)
- odr_malloc(c->odr_out, strlen(auth_userId)+1);
- strcpy(auth->u.open, auth_userId);
+ auth->u.open = odr_strdup(c->odr_out, c->user);
ireq->idAuthentication = auth;
}
if (c->proxy)
static void response_default_diag(ZOOM_connection c, Z_DefaultDiagFormat *r)
{
- int oclass;
+ oid_class oclass;
char *addinfo = 0;
switch (r->which)
if (diag_rec->which == Z_DiagRec_defaultFormat)
{
Z_DefaultDiagFormat *ddf = diag_rec->u.defaultFormat;
- int oclass;
+ oid_class oclass;
error = *ddf->condition;
switch (ddf->which)
if (!strcmp(type, "render"))
{
Z_External *r = (Z_External *) npr->u.databaseRecord;
- const int *oid = r->direct_reference;
+ const Odr_oid *oid = r->direct_reference;
/* render bibliographic record .. */
if (r->which == Z_External_OPAC)
else if (!strcmp(type, "xml"))
{
Z_External *r = (Z_External *) npr->u.databaseRecord;
- const int *oid = r->direct_reference;
+ const Odr_oid *oid = r->direct_reference;
/* render bibliographic record .. */
if (r->which == Z_External_OPAC)
ZOOM_options_set(scan->options, key, val);
}
-static Z_APDU *create_es_package(ZOOM_package p, const int *oid)
+static Z_APDU *create_es_package(ZOOM_package p, const Odr_oid *oid)
{
const char *str;
Z_APDU *apdu = zget_APDU(p->odr_out, Z_APDU_extendedServicesRequest);
const char *record_buf = ZOOM_options_get(p->options, "record");
const char *syntax_str = ZOOM_options_get(p->options, "syntax");
int action_no = -1;
- int *syntax_oid = 0;
+ Odr_oid *syntax_oid = 0;
if (!syntax_str)
syntax_str = "xml";
static void set_init_option(const char *name, void *clientData) {
- ZOOM_connection c = clientData;
+ ZOOM_connection c = (ZOOM_connection) clientData;
char buf[80];
sprintf(buf, "init_opt_%.70s", name);
static void cql2pqf_wrbuf_puts(const char *buf, void *client_data)
{
- WRBUF wrbuf = client_data;
+ WRBUF wrbuf = (WRBUF) client_data;
wrbuf_puts(wrbuf, buf);
}