cvs: php4 /ext/yaz php_yaz.c php_yaz.h
| From: | Adam Dickmeiss | Date: | Thu, 17 Jan 2002 23:21:27 +0000 |
| Subject: | cvs: php4 /ext/yaz php_yaz.c php_yaz.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9081@lists.php.net to get a copy of this message | ||
dickmeiss Thu Jan 17 18:21:27 2002 EDT
Modified files:
/php4/ext/yaz php_yaz.c php_yaz.h
Log:
New function yaz_es_result: Z395.0 Extended Services Result.
----------------------------------------------------------------------
Index: php4/ext/yaz/php_yaz.c
diff -u php4/ext/yaz/php_yaz.c:1.37 php4/ext/yaz/php_yaz.c:1.38
--- php4/ext/yaz/php_yaz.c:1.37 Tue Jan 1 09:09:02 2002
+++ php4/ext/yaz/php_yaz.c Thu Jan 17 18:21:27 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_yaz.c,v 1.37 2002/01/01 14:09:02 dickmeiss Exp $ */
+/* $Id: php_yaz.c,v 1.38 2002/01/17 23:21:27 dickmeiss Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -109,7 +109,9 @@
ODR odr_in;
ODR odr_out;
ODR odr_scan;
+ ODR odr_es;
Z_ScanResponse *scan_response;
+ Z_ExtendedServicesResponse *es_response;
char *buf_out;
int len_out;
char *buf_in;
@@ -150,7 +152,9 @@
p->odr_in = odr_createmem (ODR_DECODE);
p->odr_out = odr_createmem (ODR_ENCODE);
p->odr_scan = odr_createmem (ODR_ENCODE);
+ p->odr_es = odr_createmem (ODR_ENCODE);
p->scan_response = 0;
+ p->es_response = 0;
p->buf_out = 0;
p->len_out = 0;
p->buf_in = 0;
@@ -191,6 +195,7 @@
odr_destroy (p->odr_in);
odr_destroy (p->odr_out);
odr_destroy (p->odr_scan);
+ odr_destroy (p->odr_es);
/* buf_out */
/* buf_in */
/* action */
@@ -256,6 +261,7 @@
PHP_FE(yaz_itemorder, NULL)
PHP_FE(yaz_scan, NULL)
PHP_FE(yaz_scan_result, second_argument_force_ref)
+ PHP_FE(yaz_es_result, NULL)
PHP_FE(yaz_present, NULL)
PHP_FE(yaz_ccl_conf, NULL)
PHP_FE(yaz_ccl_parse, third_argument_force_ref)
@@ -515,8 +521,12 @@
static void es_response (Yaz_Association t,
Z_ExtendedServicesResponse *res)
{
- if (res->diagnostics && res->num_diagnostics > 0)
+ NMEM nmem = odr_extract_mem (t->odr_in);
+ if (res->diagnostics && res->num_diagnostics > 0)
response_diag(t, res->diagnostics[0]);
+ t->es_response = res;
+ nmem_transfer (t->odr_es->mem, nmem);
+ nmem_destroy (nmem);
}
static void handle_apdu (Yaz_Association t, Z_APDU *apdu)
@@ -2238,6 +2248,10 @@
{
Z_APDU *apdu;
p->action = 0;
+
+ odr_reset (p->odr_es);
+ p->es_response = 0;
+
apdu = encode_es_itemorder (p, Z_ARRVAL_PP(pval_package));
if (apdu)
{
@@ -2358,6 +2372,49 @@
}
release_assoc (p);
}
+/* }}} */
+
+/* {{{ proto int yaz_es_result(int id)
+ Inspects Extended Services Result */
+PHP_FUNCTION(yaz_es_result)
+{
+ pval **pval_id;
+ Yaz_Association p;
+ if (ZEND_NUM_ARGS() == 1)
+ {
+ if (zend_get_parameters_ex(1, &pval_id) == FAILURE)
+ {
+ WRONG_PARAM_COUNT;
+ }
+ }
+ else
+ {
+ WRONG_PARAM_COUNT;
+ }
+ if (array_init(return_value) == FAILURE)
+ {
+ RETURN_FALSE;
+ }
+ get_assoc (INTERNAL_FUNCTION_PARAM_PASSTHRU, pval_id, &p);
+ if (p && p->es_response)
+ {
+ int i;
+ Z_ExtendedServicesResponse *res = p->es_response;
+
+ if (res->taskPackage &&
+ res->taskPackage->which == Z_External_extendedService)
+ {
+ Z_TaskPackage *taskPackage = res->taskPackage->u.extendedService;
+ Odr_oct *id = taskPackage->targetReference;
+
+ if (id)
+ add_assoc_stringl (return_value, "targetReference",
+ id->buf, id->len, 1);
+ }
+ }
+ release_assoc (p);
+}
+
/* }}} */
/* {{{ proto int yaz_scan_result(int id, array options)
Index: php4/ext/yaz/php_yaz.h
diff -u php4/ext/yaz/php_yaz.h:1.8 php4/ext/yaz/php_yaz.h:1.9
--- php4/ext/yaz/php_yaz.h:1.8 Tue Dec 11 10:30:55 2001
+++ php4/ext/yaz/php_yaz.h Thu Jan 17 18:21:27 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_yaz.h,v 1.8 2001/12/11 15:30:55 sebastian Exp $ */
+/* $Id: php_yaz.h,v 1.9 2002/01/17 23:21:27 dickmeiss Exp $ */
#ifndef PHP_YAZ_H
#define PHP_YAZ_H
@@ -45,6 +45,7 @@
PHP_FUNCTION(yaz_itemorder);
PHP_FUNCTION(yaz_scan);
PHP_FUNCTION(yaz_scan_result);
+PHP_FUNCTION(yaz_es_result);
PHP_FUNCTION(yaz_present);
PHP_FUNCTION(yaz_ccl_conf);
PHP_FUNCTION(yaz_ccl_parse);