X-Git-Url: http://git.indexdata.com/?p=phpyaz-moved-to-github.git;a=blobdiff_plain;f=php_yaz.c;h=b32af022445998b95aeaeb8323f674242a5f4ad1;hp=925836565d5c7fa5ad150a8302cd21c9e64b737c;hb=196eba7293913dade00b5d7425f15ea40ff0b315;hpb=9579761f9d426395914c2cc276f8d639cdf81832 diff --git a/php_yaz.c b/php_yaz.c index 9258365..b32af02 100644 --- a/php_yaz.c +++ b/php_yaz.c @@ -1,19 +1,6 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Adam Dickmeiss | - +----------------------------------------------------------------------+ +/* This file is part of PHP YAZ. + * Copyright (C) Index Data 2004-2014 + * See the file LICENSE for details. */ #ifdef HAVE_CONFIG_H @@ -26,14 +13,15 @@ #if HAVE_YAZ #include "ext/standard/info.h" -#include "php_yaz.h" #include +#include "php_yaz.h" + #ifndef YAZ_VERSIONL -#error YAZ version 3.0 or later must be used. -#elif YAZ_VERSIONL < 0x030000 -#error YAZ version 3.0 or later must be used. +#error YAZ version 3.0.2 or later must be used. +#elif YAZ_VERSIONL < 0x030020 +#error YAZ version 3.0.2 or later must be used. #endif #ifdef PHP_WIN32 @@ -50,6 +38,10 @@ #include #include +#if YAZ_VERSIONL >= 0x050100 +#include +#endif + #ifndef ODR_INT_PRINTF #define ODR_INT_PRINTF "%d" #endif @@ -60,7 +52,9 @@ typedef struct Yaz_AssociationInfo *Yaz_Association; struct Yaz_AssociationInfo { CCL_bibset bibset; +#if YAZ_VERSIONL >= 0x050100 cql_transform_t ct; +#endif ZOOM_connection zoom_conn; ZOOM_resultset zoom_set; ZOOM_scanset zoom_scan; @@ -88,7 +82,9 @@ static Yaz_Association yaz_association_mk() p->order = 0; p->persistent = 0; p->bibset = ccl_qual_mk(); +#if YAZ_VERSIONL >= 0x050100 p->ct = cql_transform_create(); +#endif p->time_stamp = 0; return p; } @@ -99,7 +95,9 @@ static void yaz_association_destroy(Yaz_Association p) return; } +#if YAZ_VERSIONL >= 0x050100 cql_transform_close(p->ct); +#endif ZOOM_resultset_destroy(p->zoom_set); ZOOM_scanset_destroy(p->zoom_scan); ZOOM_package_destroy(p->zoom_package); @@ -168,8 +166,10 @@ zend_function_entry yaz_functions [] = { PHP_FE(yaz_present, NULL) PHP_FE(yaz_ccl_conf, NULL) PHP_FE(yaz_ccl_parse, third_argument_force_ref) +#if YAZ_VERSIONL >= 0x050100 PHP_FE(yaz_cql_parse, third_argument_force_ref) PHP_FE(yaz_cql_conf, NULL) +#endif PHP_FE(yaz_database, NULL) PHP_FE(yaz_sort, NULL) PHP_FE(yaz_schema, NULL) @@ -312,7 +312,7 @@ PHP_FUNCTION(yaz_connect) const char *preferredMessageSize = 0; int persistent = 1; int piggyback = 1; - Yaz_Association as; + Yaz_Association as = 0; int max_links = YAZSG(max_links); otherInfo[0] = otherInfo[1] = otherInfo[2] = 0; @@ -815,7 +815,6 @@ static Z_GenericRecord *marc_to_grs1(const char *buf, ODR o) int base_address; int length_data_entry; int length_starting; - int length_implementation; int max_elements = 256; Z_GenericRecord *r = odr_malloc(o, sizeof(*r)); r->elements = odr_malloc(o, sizeof(*r->elements) * max_elements); @@ -831,7 +830,6 @@ static Z_GenericRecord *marc_to_grs1(const char *buf, ODR o) length_data_entry = atoi_n(buf + 20, 1); length_starting = atoi_n(buf + 21, 1); - length_implementation = atoi_n(buf + 22, 1); for (entry_p = 24; buf[entry_p] != ISO2709_FS; ) { entry_p += 3 + length_data_entry + length_starting; @@ -1529,7 +1527,7 @@ PHP_FUNCTION(yaz_get_option) } get_assoc(INTERNAL_FUNCTION_PARAM_PASSTHRU, pval_id, &p); if (p) { - const char *name_str, *v; + const char *v; v = option_get(p, name); if (!v) { v = ""; @@ -1941,6 +1939,8 @@ PHP_FUNCTION(yaz_ccl_parse) /* }}} */ +#if YAZ_VERSIONL >= 0x050100 + /* {{{ proto bool yaz_cql_parse(resource id, string cql, array res, bool rev) Parse a CQL query */ PHP_FUNCTION(yaz_cql_parse) @@ -2022,6 +2022,9 @@ PHP_FUNCTION(yaz_cql_parse) } /* }}} */ +#endif + +#if YAZ_VERSIONL >= 0x050100 /* {{{ proto void yaz_cql_conf(resource id, array package) Configure CQL package */ PHP_FUNCTION(yaz_cql_conf) @@ -2064,7 +2067,7 @@ PHP_FUNCTION(yaz_cql_conf) release_assoc(p); } /* }}} */ - +#endif /* {{{ proto bool yaz_database (resource id, string databases) Specify the databases within a session */