hholzgra Tue Oct 22 21:11:06 2002 EDT
Modified files:
/php4/ext/fdf config.m4 fdf.c
Log:
make it work with pre-v5 fdftk again
Index: php4/ext/fdf/config.m4
diff -u php4/ext/fdf/config.m4:1.20 php4/ext/fdf/config.m4:1.21
--- php4/ext/fdf/config.m4:1.20 Mon Oct 21 18:58:52 2002
+++ php4/ext/fdf/config.m4 Tue Oct 22 21:11:06 2002
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.20 2002/10/21 22:58:52 sniper Exp $
+dnl $Id: config.m4,v 1.21 2002/10/23 01:11:06 hholzgra Exp $
dnl
PHP_ARG_WITH(fdftk, for FDF support,
@@ -23,11 +23,12 @@
esac
if test "$PHP_FDFTK" = "yes"; then
- PHP_FDFTK="/usr /usr/local ../FDFToolkitForUNIX ext/fdf/FDFToolkitForUNIX"
+ PHP_FDFTK="/usr /usr/local ../FDFToolkitForUNIX ext/fdf/FDFToolkitForUNIX
+../fdftk ext/fdf/fdftk"
fi
for dir in $PHP_FDFTK; do
for subdir in include HeadersAndLibraries/headers; do
+ echo checking for $dir/$subdir/FdfTk.h
if test -r $dir/$subdir/FdfTk.h; then
FDFTK_DIR=$dir
FDFTK_H_DIR=$dir/$subdir
@@ -53,18 +54,22 @@
if test -r $dir/lib$file.so; then
PHP_CHECK_LIBRARY($file, FDFOpen, [FDFLIBRARY=$file], [], [-L$dir -lm])
if test "$FDFLIBRARY"; then
+ PHP_CHECK_LIBRARY($file, FDFGetFDFVersion, [HAVE_FDFTK_5=yes], [],
+[-L$dir -lm])
FDFTK_LIB_DIR=$dir
break 2
fi
fi
done
done
-
+
if test -z "$FDFLIBRARY"; then
AC_MSG_ERROR(no usable fdf library found)
fi
AC_DEFINE(HAVE_FDFLIB,1,[ ])
+ if test "$HAVE_FDFTK_5" = "yes"; then
+ AC_DEFINE(HAVE_FDFTK_5,1,[ ])
+ fi
PHP_ADD_LIBRARY_WITH_PATH($FDFLIBRARY, $FDFTK_LIB_DIR, FDFTK_SHARED_LIBADD)
PHP_SUBST(FDFTK_SHARED_LIBADD)
Index: php4/ext/fdf/fdf.c
diff -u php4/ext/fdf/fdf.c:1.65 php4/ext/fdf/fdf.c:1.66
--- php4/ext/fdf/fdf.c:1.65 Mon Oct 21 15:55:28 2002
+++ php4/ext/fdf/fdf.c Tue Oct 22 21:11:06 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fdf.c,v 1.65 2002/10/21 19:55:28 hholzgra Exp $ */
+/* $Id: fdf.c,v 1.66 2002/10/23 01:11:06 hholzgra Exp $ */
/* FdfTk lib 2.0 is a Complete C/C++ FDF Toolkit available from
http://beta1.adobe.com/ada/acrosdk/forms.html. */
@@ -46,7 +46,6 @@
/* {{{ fdf_functions[]
*/
function_entry fdf_functions[] = {
- PHP_FE(fdf_add_doc_javascript, NULL)
PHP_FE(fdf_add_template, NULL)
PHP_FE(fdf_close,
NULL)
PHP_FE(fdf_create,
NULL)
@@ -54,7 +53,6 @@
PHP_FE(fdf_errno, NULL)
PHP_FE(fdf_error, NULL)
PHP_FE(fdf_get_ap,
NULL)
- PHP_FE(fdf_get_attachment, NULL)
PHP_FE(fdf_get_encoding, NULL)
PHP_FE(fdf_get_file, NULL)
PHP_FE(fdf_get_flags, NULL)
@@ -73,14 +71,18 @@
PHP_FE(fdf_set_file, NULL)
PHP_FE(fdf_set_flags, NULL)
PHP_FE(fdf_set_javascript_action, NULL)
- PHP_FE(fdf_set_on_import_javascript, NULL)
PHP_FE(fdf_set_opt,
NULL)
PHP_FE(fdf_set_status, NULL)
PHP_FE(fdf_set_submit_form_action, NULL)
- PHP_FE(fdf_set_target_frame, NULL)
PHP_FE(fdf_set_value, NULL)
- PHP_FE(fdf_set_version, NULL)
PHP_FE(fdf_header, NULL)
+#ifdef HAVE_FDFTK_5
+ PHP_FE(fdf_add_doc_javascript, NULL)
+ PHP_FE(fdf_get_attachment, NULL)
+ PHP_FE(fdf_set_on_import_javascript, NULL)
+ PHP_FE(fdf_set_target_frame, NULL)
+ PHP_FE(fdf_set_version, NULL)
+#endif
{NULL, NULL, NULL}
};
/* }}} */
@@ -336,17 +338,25 @@
buffer = emalloc(size);
if(which >= 0) {
+#if HAVE_FDFTK_5
err = FDFGetNthValue(fdf, fieldname, which, buffer, size-2, &nr);
+#else
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "the optional 'which'
+parameter requires FDF toolkit 5.0 or above, it will be ignored for now");
+ which = -1;
+#endif
} else {
err = FDFGetValue(fdf, fieldname, buffer, size-2, &nr);
}
if(err == FDFErcBufTooShort && nr > 0 ) {
buffer = erealloc(buffer, nr+2);
if(which >= 0) {
+#if HAVE_FDFTK_5
err = FDFGetNthValue(fdf, fieldname, which, buffer, nr, &nr);
+#endif
} else {
err = FDFGetValue(fdf, fieldname, buffer, nr, &nr);
}
+#if HAVE_FDFTK_5
} else if((err == FDFErcValueIsArray) && (which == -1)) {
if (array_init(return_value) == FAILURE) {
efree(buffer);
@@ -367,6 +377,7 @@
if(err == FDFErcNoValue) err = FDFErcOK;
efree(buffer);
buffer = NULL;
+#endif
}
if(err != FDFErcOK) {
@@ -411,6 +422,7 @@
convert_to_string_ex(fieldname);
if (Z_TYPE_PP(value) == IS_ARRAY) {
+#ifdef HAVE_FDFTK_5
ASInt32 nValues = zend_hash_num_elements(Z_ARRVAL_PP(value));
char **newValues = ecalloc(nValues, sizeof(char *)), **next;
HashPosition pos;
@@ -427,12 +439,15 @@
}
err = FDFSetValues(fdf, Z_STRVAL_PP(fieldname), nValues, (const char
**)newValues);
-
for(next = newValues; nValues; nValues--) {
efree(*next++);
}
efree(newValues);
+#else
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "setting array values is
+only possible with FDF toolkit 5.0 and above");
+ RETURN_FALSE;
+#endif
} else {
convert_to_string_ex(value);
@@ -696,10 +711,14 @@
FDF_FAILURE(err);
}
if(target_frame) {
+#ifdef HAVE_FDFTK_5
err = FDFSetTargetFrame(fdf, target_frame);
if(err != FDFErcOK) {
FDF_FAILURE(err);
}
+#else
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "setting the target frame
+is only possible with FDF toolkit 5.0 and above, ignoring it for now");
+#endif
}
FDF_SUCCESS;
@@ -1228,6 +1247,7 @@
RETURN_STRING("The field has no /AP key", 1);
case FDFErcIncompatibleFDF:
RETURN_STRING("An attempt to mix classic and template-based FDF files
was made", 1);
+#ifdef HAVE_FDFTK_5
case FDFErcNoAppendSaves:
RETURN_STRING("The FDF does not include a /Difference key", 1);
case FDFErcValueIsArray:
@@ -1238,6 +1258,7 @@
RETURN_STRING("Returned by FDFOpenFromEmbedded when parameter iWhich
>= the number of embedded FDFs (including the case when the passed FDF does not
contain any embedded FDFs)", 1);
case FDFErcInvalidPassword:
RETURN_STRING("Returned by FDFOpenFromEmbedded when the embedded FDF
is encrypted, and you did not provide the correct password", 1);
+#endif
case FDFErcLast:
RETURN_STRING("Reserved for future use", 1);
default:
@@ -1257,12 +1278,16 @@
}
if(r_fdf) {
+#if HAVE_FDFTK_5
const char *fdf_version;
FDFDoc fdf;
ZEND_FETCH_RESOURCE(fdf, FDFDoc *, &r_fdf, -1, "fdf", le_fdf);
fdf_version = FDFGetFDFVersion(fdf);
RETURN_STRING((char *)fdf_version, 1);
+#else
+ RETURN_STRING("1.2",1);
+#endif
} else {
const char *api_version = FDFGetVersion();
RETURN_STRING((char *)api_version, 1);
@@ -1270,6 +1295,7 @@
}
/* }}} */
+#ifdef HAVE_FDFTK_5
/* {{{ proto bool fdf_set_version(resourece fdfdoc, string version)
Sets FDF version for a file*/
PHP_FUNCTION(fdf_set_version) {
@@ -1377,6 +1403,7 @@
FDF_SUCCESS;
}
/* }}} */
+#endif
/* {{{ proto bool fdf_remove_item(resource fdfdoc, string fieldname, int item)
Sets target frame for form */
@@ -1406,6 +1433,7 @@
}
/* }}} */
+#ifdef HAVE_FDFTK_5
/* {{{ proto array fdf_get_attachment(resource fdfdoc, string fieldname, string
savepath)
Get attached uploaded file */
PHP_FUNCTION(fdf_get_attachment) {
@@ -1450,6 +1478,7 @@
add_assoc_long(return_value, "size", statBuf.st_size);
}
/* }}} */
+#endif
/* {{{ enum_values_callback */
static ASBool enum_values_callback(char *name, char *value, void *userdata) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php