static int connection_is_idle(struct connection *co)
{
ZOOM_connection link = co->link;
- int event = ZOOM_connection_peek_event(link);
+ int event;
- if (co->state != Conn_Open)
+ if (co->state != Conn_Open || !link)
return 0;
- link = co->link;
event = ZOOM_connection_peek_event(link);
if (event == ZOOM_EVENT_NONE ||
event == ZOOM_EVENT_END)
void connection_continue(struct connection *co)
{
-#if 1
yaz_log(YLOG_LOG, "connection_continue");
iochan_setevent(co->iochan, EVENT_OUTPUT);
-#endif
}
// Close connection and recycle structure
// Creates a new connection for client, associated with the host of
// client's database
-struct connection *connection_create(struct client *cl)
+static struct connection *connection_create(struct client *cl)
{
struct connection *new;
struct host *host = client_get_host(cl);
client_set_connection(cl, new);
new->link = 0;
new->resultset = 0;
- new->state = Conn_Connecting;
+ new->state = Conn_Resolving;
if (host->ipport)
connection_connect(new);
return new;
else
{
connection_connect(con);
+ client_start_search(con->client);
}
}
else
}
}
-struct host *connection_get_host(struct connection *con)
+static struct host *connection_get_host(struct connection *con)
{
return con->host;
}
ZOOM_connection link = 0;
struct host *host = connection_get_host(con);
ZOOM_options zoptions = ZOOM_options_create();
- char *auth;
+ const char *auth;
+ const char *sru;
+ const char *sru_version = 0;
+ char ipport[512] = "";
struct session_database *sdb = client_get_database(con->client);
const char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY);
if (apdulog && *apdulog)
ZOOM_options_set(zoptions, "apdulog", apdulog);
- if ((auth = (char*) session_setting_oneval(sdb, PZ_AUTHENTICATION)))
+ if ((auth = session_setting_oneval(sdb, PZ_AUTHENTICATION)))
ZOOM_options_set(zoptions, "user", auth);
+ if ((sru = session_setting_oneval(sdb, PZ_SRU)) && *sru)
+ ZOOM_options_set(zoptions, "sru", sru);
+ if ((sru_version = session_setting_oneval(sdb, PZ_SRU_VERSION))
+ && *sru_version)
+ ZOOM_options_set(zoptions, "sru_version", sru_version);
if (!(link = ZOOM_connection_create(zoptions)))
{
ZOOM_options_destroy(zoptions);
return -1;
}
- ZOOM_connection_connect(link, host->ipport, 0);
+
+ if (sru && *sru)
+ strcpy(ipport, "http://");
+ strcat(ipport, host->ipport);
+ /* deal with SRU path here because databaseName option is not read in
+ ZOOM in SRU mode */
+ if (sru && *sru)
+ {
+ if (*sdb->database->databases[0])
+ {
+ strcat(ipport, "/");
+ strcat(ipport, sdb->database->databases[0]);
+ }
+ }
+ ZOOM_connection_connect(link, ipport, 0);
con->link = link;
con->iochan = iochan_create(0, connection_handler, 0);
co = connection_create(cl);
}
- if (co)
+ if (co && co->link)
return 1;
else
return 0;
}
-// DELETEME
-
-
-int connection_send_apdu(struct connection *co, Z_APDU *a){return 10;}
-
-
-
/*
* Local variables:
* c-basic-offset: 4