#endif
#include "php.h"
+#include "php_ini.h"
#if HAVE_YAZ
Yaz_Association *assocp)
{
Yaz_Association *as = 0;
- YAZSLS_FETCH();
*assocp = 0;
#ifdef ZTS
int no = 0;
int max_fd = 0;
struct timeval tv;
- YAZSLS_FETCH();
tv.tv_sec = timeout;
tv.tv_usec = 0;
#endif
FD_ZERO (&input);
FD_ZERO (&output);
- for (i = 0; i < MAX_ASSOC; i++)
+ for (i = 0; i < YAZSG(max_links); i++)
{
Yaz_Association p = shared_associations[i];
int fd;
#ifdef ZTS
tsrm_mutex_lock (yaz_mutex);
#endif
- for (i = 0; i<MAX_ASSOC; i++)
+ for (i = 0; i<YAZSG(max_links); i++)
{
int fd;
Yaz_Association p = shared_associations[i];
const char *user_str = 0, *group_str = 0, *pass_str = 0;
const char *cookie_str = 0, *proxy_str = 0;
const char *client_IP = 0;
+ const char *otherInfo[3];
int persistent = 1;
int piggyback = 1;
pval **zurl, **user = 0;
Yaz_Association as;
- YAZSLS_FETCH();
+ otherInfo[0] = otherInfo[1] = otherInfo[2] = 0;
if (ZEND_NUM_ARGS() == 1)
{
if (zend_get_parameters_ex (1, &zurl) == FAILURE)
piggyback_val = array_lookup_bool(ht, "piggyback");
if (piggyback_val)
piggyback = *piggyback_val;
- client_IP = array_lookup_string(ht, "clientIP");
+ otherInfo[0] = array_lookup_string(ht, "otherInfo0");
+ otherInfo[1] = array_lookup_string(ht, "otherInfo1");
+ otherInfo[2] = array_lookup_string(ht, "otherInfo2");
}
else
{
#ifdef ZTS
tsrm_mutex_lock (yaz_mutex);
#endif
- for (i = 0; i<MAX_ASSOC; i++)
+ for (i = 0; i<YAZSG(max_links); i++)
{
as = shared_associations[i];
#if USE_ZOOM
!strcmp_null(option_get(as, "cookie"), cookie_str))
{
option_set (as, "clientIP", client_IP);
+ option_set (as, "otherInfo0", otherInfo[0]);
+ option_set (as, "otherInfo1", otherInfo[1]);
+ option_set (as, "otherInfo2", otherInfo[2]);
ZOOM_connection_connect (as->zoom_conn, zurl_str, 0);
break;
}
break;
#endif
}
- if (i == MAX_ASSOC)
+ if (i == YAZSG(max_links))
{
/* we didn't have it (or already in use) */
int i0 = -1;
int min_order = 2000000000;
/* find completely free slot or the oldest one */
- for (i = 0; i<MAX_ASSOC && shared_associations[i]; i++)
+ for (i = 0; i<YAZSG(max_links) && shared_associations[i]; i++)
{
as = shared_associations[i];
if (persistent && !as->in_use && as->order < min_order)
i0 = i;
}
}
- if (i == MAX_ASSOC)
+ if (i == YAZSG(max_links))
{
i = i0;
if (i == -1)
option_set (as, "pass", pass_str);
option_set (as, "cookie", cookie_str);
option_set (as, "clientIP", client_IP);
+
+ option_set (as, "otherInfo0", otherInfo[0]);
+ option_set (as, "otherInfo1", otherInfo[1]);
+ option_set (as, "otherInfo2", otherInfo[2]);
+
ZOOM_connection_connect (as->zoom_conn, zurl_str, 0);
#else
as->host_port = xstrdup (zurl_str);
ZOOM_connection conn_ar[MAX_ASSOC];
#endif
int i, id, timeout = 15;
- YAZSLS_FETCH();
if (ZEND_NUM_ARGS() == 1)
{
#ifdef ZTS
tsrm_mutex_lock (yaz_mutex);
#endif
- for (i = 0; i<MAX_ASSOC; i++)
+ for (i = 0; i<YAZSG(max_links); i++)
{
#if USE_ZOOM
Yaz_Association p = shared_associations[i];
void yaz_close_session(Yaz_Association *as)
{
- YAZSLS_FETCH();
-
if (*as && (*as)->order == YAZSG(assoc_seq))
{
if ((*as)->persistent)
yaz_close_session (as);
}
+/* {{{ PHP_INI_BEGIN
+ */
+PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("yaz.max_links", "100", PHP_INI_ALL,
+ OnUpdateInt, max_links,
+ zend_yaz_globals, yaz_globals)
+ STD_PHP_INI_ENTRY("yaz.log_file", "", PHP_INI_ALL,
+ OnUpdateString, log_file,
+ zend_yaz_globals, yaz_globals)
+ PHP_INI_END()
+/* }}} */
+
PHP_MINIT_FUNCTION(yaz)
{
int i;
#ifdef ZTS
yaz_mutex = tsrm_mutex_alloc();
#endif
+ yaz_log_init_file ("/dev/null");
ZEND_INIT_MODULE_GLOBALS(yaz, php_yaz_init_globals, NULL);
+ REGISTER_INI_ENTRIES();
+
+ if (YAZSG(log_file))
+ {
+ yaz_log_init_file(YAZSG(log_file));
+ yaz_log_init_level (LOG_ALL);
+ }
le_link = zend_register_list_destructors_ex (yaz_close_link, 0,
"YAZ link", module_number);
order_associations = 1;
php_info_print_table_start();
php_info_print_table_row(2, "YAZ Support", "enabled");
php_info_print_table_row(2, "YAZ Version", YAZ_VERSION);
+#if USE_ZOOM
+ php_info_print_table_row(2, "ZOOM", "enabled");
+#endif
php_info_print_table_end();
}
PHP_RINIT_FUNCTION(yaz)
{
- YAZSLS_FETCH();
+ char pidstr[20];
+ sprintf (pidstr, "%ld", (long) getpid());
#ifdef ZTS
tsrm_mutex_lock (yaz_mutex);
#endif
#ifdef ZTS
tsrm_mutex_unlock (yaz_mutex);
#endif
+ yaz_log_init_prefix(pidstr);
return SUCCESS;
}