cvs: pecl /yaz php_yaz.c
| From: | Adam Dickmeiss | Date: | Mon, 06 Jun 2005 19:09:55 +0000 |
| Subject: | cvs: pecl /yaz php_yaz.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-3234@lists.php.net to get a copy of this message | ||
dickmeiss Mon Jun 6 15:09:55 2005 EDT
Modified files:
/pecl/yaz php_yaz.c
Log:
Produce warning with reason, if yaz_connect cannot return a handle.
Fix yaz_search so it returns FALSE/TRUE correctly.
http://cvs.php.net/diff.php/pecl/yaz/php_yaz.c?r1=1.94&r2=1.95&ty=u
Index: pecl/yaz/php_yaz.c
diff -u pecl/yaz/php_yaz.c:1.94 pecl/yaz/php_yaz.c:1.95
--- pecl/yaz/php_yaz.c:1.94 Tue Feb 8 08:27:22 2005
+++ pecl/yaz/php_yaz.c Mon Jun 6 15:09:54 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_yaz.c,v 1.94 2005/02/08 13:27:22 dickmeiss Exp $ */
+/* $Id: php_yaz.c,v 1.95 2005/06/06 19:09:54 dickmeiss Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -301,6 +301,7 @@
int piggyback = 1;
pval **zurl, **user = 0;
Yaz_Association as;
+ int max_links = YAZSG(max_links);
otherInfo[0] = otherInfo[1] = otherInfo[2] = 0;
@@ -347,13 +348,14 @@
zurl_str = (*zurl)->value.str.val;
for (cp = zurl_str; *cp && strchr("\t\n ", *cp); cp++);
if (!*cp) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty zurl");
RETURN_LONG(0);
}
/* see if we have it already ... */
#ifdef ZTS
tsrm_mutex_lock(yaz_mutex);
#endif
- for (i = 0; i < YAZSG(max_links); i++) {
+ for (i = 0; i < max_links; i++) {
as = shared_associations[i];
if (persistent && as && !as->in_use &&
!strcmp_null(option_get(as, "host"), zurl_str) &&
@@ -365,13 +367,13 @@
!strcmp_null(option_get(as, "charset"), charset_str))
break;
}
- if (i == YAZSG(max_links)) {
+ if (i == 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 < YAZSG(max_links) && shared_associations[i]; i++) {
+ for (i = 0; i < max_links && shared_associations[i]; i++) {
as = shared_associations[i];
if (persistent && !as->in_use && as->order < min_order) {
min_order = as->order;
@@ -379,12 +381,16 @@
}
}
- if (i == YAZSG(max_links)) {
+ if (i == max_links) {
i = i0;
if (i == -1) {
+ char msg[80];
#ifdef ZTS
tsrm_mutex_unlock (yaz_mutex);
#endif
+ sprintf(msg, "No YAZ handles available. max_links=%d",
+ max_links);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, msg);
RETURN_LONG(0); /* no free slot */
} else { /* "best" free slot */
yaz_association_destroy(shared_associations[i]);
@@ -477,31 +483,41 @@
ZOOM_resultset_destroy(p->zoom_set);
p->zoom_set = 0;
+ RETVAL_FALSE;
+
if (!strcmp(type_str, "rpn")) {
ZOOM_query q = ZOOM_query_create();
- ZOOM_query_prefix(q, query_str);
- if (p->sort_criteria) {
- ZOOM_query_sortby(q, p->sort_criteria);
+ if (ZOOM_query_prefix(q, query_str) == 0)
+ {
+ if (p->sort_criteria) {
+ ZOOM_query_sortby(q, p->sort_criteria);
+ }
+ xfree(p->sort_criteria);
+ p->sort_criteria = 0;
+ p->zoom_set = ZOOM_connection_search(p->zoom_conn, q);
+ RETVAL_TRUE;
}
- xfree(p->sort_criteria);
- p->sort_criteria = 0;
- p->zoom_set = ZOOM_connection_search(p->zoom_conn, q);
ZOOM_query_destroy(q);
- RETVAL_TRUE;
}
- if (!strcmp(type_str, "cql")) {
+ else if (!strcmp(type_str, "cql")) {
ZOOM_query q = ZOOM_query_create();
- ZOOM_query_cql(q, query_str);
- if (p->sort_criteria) {
- ZOOM_query_sortby(q, p->sort_criteria);
- }
- xfree (p->sort_criteria);
- p->sort_criteria = 0;
- p->zoom_set = ZOOM_connection_search(p->zoom_conn, q);
+ if (ZOOM_query_cql(q, query_str) == 0)
+ {
+ if (p->sort_criteria) {
+ ZOOM_query_sortby(q, p->sort_criteria);
+ }
+ xfree (p->sort_criteria);
+ p->sort_criteria = 0;
+ p->zoom_set = ZOOM_connection_search(p->zoom_conn, q);
+ RETVAL_TRUE;
+ }
ZOOM_query_destroy(q);
- RETVAL_TRUE;
- } else {
- RETVAL_FALSE;
+ }
+ else
+ {
+ char msg[80];
+ sprintf(msg, "Invalid query type %.40s", type_str);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, msg);
}
release_assoc(p);
}