From bcc7864a32072306a84a70ef9bd0f11175a82603 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 28 May 2011 08:07:03 +0200 Subject: [PATCH] Tweak source to work with both YAZ 3 and YAZ 4 --- php_yaz.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/php_yaz.c b/php_yaz.c index fbbbef0..ba68d93 100644 --- a/php_yaz.c +++ b/php_yaz.c @@ -33,9 +33,9 @@ #include #ifndef YAZ_VERSIONL -#error YAZ version 4.0 or later must be used. -#elif YAZ_VERSIONL < 0x040000 -#error YAZ version 4.0 or later must be used. +#error YAZ version 3.0 or later must be used. +#elif YAZ_VERSIONL < 0x030000 +#error YAZ version 3.0 or later must be used. #endif #ifdef PHP_WIN32 @@ -50,6 +50,10 @@ #include #include +#ifndef ODR_INT_PRINTF +#define ODR_INT_PRINTF %d +#endif + #define MAX_ASSOC 200 typedef struct Yaz_AssociationInfo *Yaz_Association; @@ -1072,7 +1076,7 @@ static void retval_array3_grs1(zval *return_value, Z_GenericRecord *p, if (e->tagValue->which == Z_StringOrNumeric_numeric) { - sprintf(tagstr, "%d", *e->tagValue->u.numeric); + sprintf(tagstr, ODR_INT_PRINTF, *e->tagValue->u.numeric); tag = tagstr; } else if (e->tagValue->which == Z_StringOrNumeric_string) @@ -1115,7 +1119,7 @@ static void retval_array3_grs1(zval *return_value, Z_GenericRecord *p, const char *tag = 0; if (e->tagValue->which == Z_StringOrNumeric_numeric) { - sprintf(tagstr, "%d", *e->tagValue->u.numeric); + sprintf(tagstr, ODR_INT_PRINTF, *e->tagValue->u.numeric); tag = tagstr; } else if (e->tagValue->which == Z_StringOrNumeric_string) @@ -1142,7 +1146,7 @@ static void retval_array3_grs1(zval *return_value, Z_GenericRecord *p, const char *tag = 0; if (e->tagValue->which == Z_StringOrNumeric_numeric) { - sprintf(tagstr, "%d", *e->tagValue->u.numeric); + sprintf(tagstr, ODR_INT_PRINTF, *e->tagValue->u.numeric); tag = tagstr; } else if (e->tagValue->which == Z_StringOrNumeric_string) @@ -1257,7 +1261,7 @@ static void retval_array1_grs1(zval *return_value, Z_GenericRecord *p, memcpy(tag + taglen, e->tagValue->u.string, len); tag[taglen+len] = '\0'; } else if (e->tagValue->which == Z_StringOrNumeric_numeric) { - sprintf(tag + taglen, "%d", *e->tagValue->u.numeric); + sprintf(tag + taglen, ODR_INT_PRINTF, *e->tagValue->u.numeric); } taglen = strlen(tag); strcpy(tag + taglen, ")"); @@ -1755,7 +1759,12 @@ PHP_FUNCTION(yaz_scan_result) get_assoc(INTERNAL_FUNCTION_PARAM_PASSTHRU, pval_id, &p); if (p && p->zoom_scan) { int pos = 0; + /* ZOOM_scanset_term changed from YAZ 3 to YAZ 4 */ +#if YAZ_VERSIONL >= 0x040000 size_t occ, len; +#else + int occ, len; +#endif int size = ZOOM_scanset_size(p->zoom_scan); for (pos = 0; pos < size; pos++) { -- 1.7.10.4