struct client *client;
char *ibuf;
int ibufsize;
- char *authentication; // Empty string or authentication string if set
char *zproxy;
enum {
Conn_Resolving,
static struct connection *connection_freelist = 0;
+static int connection_connect(struct connection *con);
+
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);
new->next = new->host->connections;
new->host->connections = new;
new->client = cl;
- new->authentication = "";
new->zproxy = 0;
client_set_connection(cl, new);
new->link = 0;
}
}
-struct host *connection_get_host(struct connection *con)
+static struct host *connection_get_host(struct connection *con)
{
return con->host;
}
return ZOOM_connection_get_mask(co->link);
}
-int connection_connect(struct connection *con)
+static int connection_connect(struct connection *con)
{
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);
return client_get_url(co->client);
}
-void connection_set_authentication(struct connection *co, char *auth)
-{
- co->authentication = auth;
-}
-
// Ensure that client has a connection associated
int client_prep_connection(struct client *cl)
{
for (co = host->connections; co; co = co->next)
if (connection_is_idle(co) &&
(!co->client || client_get_session(co->client) != se) &&
- !strcmp(co->authentication,
- session_setting_oneval(client_get_database(cl),
- PZ_AUTHENTICATION)))
+ !strcmp(ZOOM_connection_option_get(co->link, "user"),
+ session_setting_oneval(client_get_database(cl),
+ PZ_AUTHENTICATION)))
{
if (zproxy == 0 && co->zproxy == 0)
break;
return 0;
}
-// DELETEME
-
-
-int connection_send_apdu(struct connection *co, Z_APDU *a){return 10;}
-
-
-
/*
* Local variables:
* c-basic-offset: 4