cvs: /php4 NEWS /php4/ext/pdf config.m4 pdf.c
| From: | Uwe Steinmann | Date: | Thu, 09 Mar 2000 14:41:44 +0000 |
| Subject: | cvs: /php4 NEWS /php4/ext/pdf config.m4 pdf.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11803@lists.php.net to get a copy of this message | ||
steinm Thu Mar 9 06:41:44 2000 EDT
Modified files:
/php4 NEWS
/php4/ext/pdf config.m4 pdf.c
Log:
- dropped support for version of pdflib < 3.0
- better detection of libs required for pdflib
Index: php4/NEWS
diff -u php4/NEWS:1.163 php4/NEWS:1.164
--- php4/NEWS:1.163 Wed Mar 8 07:04:19 2000
+++ php4/NEWS Thu Mar 9 06:41:14 2000
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
???, Version 4.0 Beta 5
+- Removed support for pdflib < 3.0 (Uwe)
- Added auto-registration of everything in $HTTP_SESSION_VARS[] if
register_globals is turned off. (Andrei)
- Cleaned up extension namespace (Stig)
Index: php4/ext/pdf/config.m4
diff -u php4/ext/pdf/config.m4:1.10 php4/ext/pdf/config.m4:1.11
--- php4/ext/pdf/config.m4:1.10 Wed Feb 2 03:18:01 2000
+++ php4/ext/pdf/config.m4 Thu Mar 9 06:41:14 2000
@@ -1,8 +1,8 @@
-dnl $Id: config.m4,v 1.10 2000/02/02 11:18:01 steinm Exp $
+dnl $Id: config.m4,v 1.11 2000/03/09 14:41:14 steinm Exp $
-AC_MSG_CHECKING(whether to include Pdflib 2.x support)
+AC_MSG_CHECKING(whether to include Pdflib 3.x support)
AC_ARG_WITH(pdflib,
-[ --with-pdflib[=DIR] Include pdflib 2.x support.
+[ --with-pdflib[=DIR] Include pdflib 3.x support.
DIR is the pdflib install directory,
defaults to /usr/local.],
[
@@ -16,8 +16,8 @@
old_LDFLAGS=$LDFLAGS
old_LIBS=$LIBS
LIBS="$LIBS -ltiff -ljpeg -lpng -lz"
- AC_CHECK_LIB(pdf, PDF_close, [AC_DEFINE(HAVE_PDFLIB,1,[ ])],
- [AC_MSG_ERROR(pdflib extension requires pdflib 2.x. You may as well need libtiff and
libjpeg. In such a case use the options --with-tiff-dir=<DIR> and
--with-jpeg-dir=<DIR>)])
+ AC_CHECK_LIB(pdf, PDF_show_boxed, [AC_DEFINE(HAVE_PDFLIB,1,[ ])],
+ [AC_MSG_ERROR(pdflib extension requires at least pdflib 3.x. You may as well need libtiff
and libjpeg. In such a case use the options --with-tiff-dir=<DIR> and
--with-jpeg-dir=<DIR>)])
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
AC_ADD_LIBRARY(pdf)
@@ -34,10 +34,9 @@
old_withval=$withval
if test $HAVE_ZLIB; then
- AC_MSG_CHECKING([for zlib (needed by pdflib 2.x)])
+ AC_MSG_CHECKING([for zlib (needed by pdflib 3.x)])
AC_ARG_WITH(zlib-dir,
- [ --with-zlib-dir[=DIR] zlib dir for pdflib 2.x or include zlib support],[
- AC_MSG_RESULT( )
+ [ --with-zlib-dir[=DIR] zlib dir for pdflib 3.x or include zlib support],[
if test -z $withval; then
withval="/usr/local"
fi
@@ -47,19 +46,18 @@
LIBS=$old_LIBS
AC_ADD_LIBRARY_WITH_PATH(z, $withval/lib)
],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-zlib=<DIR>)
+ AC_CHECK_LIB(z,deflate, ,[AC_MSG_RESULT(no, try --with-zlib=<DIR>)],)
+ AC_ADD_LIBRARY(z)
+ LIBS="$LIBS -lz"
])
else
- echo "checking for libz needed by pdflib 2.x... already zlib support"
+ echo "checking for libz needed by pdflib 3.x... already zlib support"
PDFLIB_LIBS="$ZLIB_LIBS"
LIBS="$LIBS -lz"
fi
- AC_MSG_CHECKING([for libjpeg (needed by pdflib 2.x)])
AC_ARG_WITH(jpeg-dir,
- [ --with-jpeg-dir[=DIR] jpeg dir for pdflib 2.x],[
- AC_MSG_RESULT(yes)
+ [ --with-jpeg-dir[=DIR] jpeg dir for pdflib 3.x],[
if test -z $withval; then
withval="/usr/local"
fi
@@ -70,14 +68,13 @@
AC_ADD_LIBRARY_WITH_PATH(jpeg, $withval/lib)
LIBS="$LIBS -L$withval/lib -ljpeg"
],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>)
+ AC_CHECK_LIB(jpeg,jpeg_read_header, ,[AC_MSG_RESULT(no, try
--with-jpeg-dir=<DIR>)],)
+ AC_ADD_LIBRARY(jpeg)
+ LIBS="$LIBS -ljpeg"
])
- AC_MSG_CHECKING([for libpng (needed by pdflib 2.x)])
AC_ARG_WITH(png-dir,
- [ --with-png-dir[=DIR] png dir for pdflib 2.x],[
- AC_MSG_RESULT(yes)
+ [ --with-png-dir[=DIR] png dir for pdflib 3.x],[
if test -z $withval; then
withval="/usr/local"
fi
@@ -88,14 +85,13 @@
AC_ADD_LIBRARY_WITH_PATH(png, $withval/lib)
LIBS="$LIBS -L$withval/lib -lpng"
],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-png-dir=<DIR>)
+ AC_CHECK_LIB(png,png_create_info_struct, ,[AC_MSG_RESULT(no, try
--with-png-dir=<DIR>)],)
+ AC_ADD_LIBRARY(png)
+ LIBS="$LIBS -lpng"
])
- AC_MSG_CHECKING([for libtiff (needed by pdflib 2.x)])
AC_ARG_WITH(tiff-dir,
- [ --with-tiff-dir[=DIR] tiff dir for pdflib 2.x],[
- AC_MSG_RESULT(yes)
+ [ --with-tiff-dir[=DIR] tiff dir for pdflib 3.x],[
if test -z $withval; then
withval="/usr/local"
fi
@@ -106,15 +102,16 @@
AC_ADD_LIBRARY_WITH_PATH(tiff, $withval/lib)
LIBS="$LIBS -L$withval/lib -ltiff"
],[
- AC_MSG_RESULT(no)
- AC_MSG_WARN(If configure fails try --with-tiff-dir=<DIR>)
+ AC_CHECK_LIB(tiff,TIFFOpen, ,[AC_MSG_RESULT(no, Try --with-tiff-dir=<DIR>)],)
+ AC_ADD_LIBRARY(tiff)
+ LIBS="$LIBS -ltiff"
])
withval=$old_withval
old_LIBS=$LIBS
LIBS="$LIBS -L$withval/lib"
- AC_CHECK_LIB(pdf, PDF_close, [AC_DEFINE(HAVE_PDFLIB,1,[ ]) PDFLIB_LIBS="$PDFLIB_LIBS
-L$withval/lib -lpdf"],
- [AC_MSG_ERROR(pdflib extension requires pdflib 2.x.)])
+ AC_CHECK_LIB(pdf, PDF_show_boxed, [AC_DEFINE(HAVE_PDFLIB,1,[ ])
PDFLIB_LIBS="$PDFLIB_LIBS -L$withval/lib -lpdf"],
+ [AC_MSG_ERROR(pdflib extension requires pdflib 3.x.)])
LIBS=$old_LIBS
AC_ADD_LIBRARY_WITH_PATH(pdf, $withval/lib)
AC_ADD_INCLUDE($PDFLIB_INCLUDE)
Index: php4/ext/pdf/pdf.c
diff -u php4/ext/pdf/pdf.c:1.29 php4/ext/pdf/pdf.c:1.30
--- php4/ext/pdf/pdf.c:1.29 Tue Mar 7 12:51:14 2000
+++ php4/ext/pdf/pdf.c Thu Mar 9 06:41:14 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdf.c,v 1.29 2000/03/07 20:51:14 steinm Exp $ */
+/* $Id: pdf.c,v 1.30 2000/03/09 14:41:14 steinm Exp $ */
/* pdflib 2.01 is subject to the ALADDIN FREE PUBLIC LICENSE.
Copyright (C) 1997 Thomas Merz. */
@@ -93,18 +93,13 @@
PHP_FE(pdf_end_page, NULL)
PHP_FE(pdf_show, NULL)
PHP_FE(pdf_show_xy, NULL)
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20)
PHP_FE(pdf_show_boxed, NULL)
PHP_FE(pdf_skew, NULL)
-#endif
PHP_FE(pdf_set_font, NULL)
PHP_FE(pdf_set_leading, NULL)
PHP_FE(pdf_set_text_rendering, NULL)
PHP_FE(pdf_set_horiz_scaling, NULL)
PHP_FE(pdf_set_text_rise, NULL)
-#if PDFLIB_MAJORVERSION < 3 & PDFLIB_MINORVERSION < 30
- PHP_FE(pdf_set_text_matrix, NULL)
-#endif
PHP_FE(pdf_set_text_pos, NULL)
PHP_FE(pdf_set_char_spacing, NULL)
PHP_FE(pdf_set_word_spacing, NULL)
@@ -226,13 +221,11 @@
return(efree(mem));
}
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10)
static size_t pdf_flushwrite(PDF *p, void *data, size_t size){
if(php_header())
return(php_write(data, size));
return 0;
}
-#endif
PHP_MINIT_FUNCTION(pdf)
{
@@ -245,18 +238,11 @@
PHP_MINFO_FUNCTION(pdf) {
/* need to use a PHPAPI function here because it is external module in windows */
php_printf("pdflib %d.%02d<BR>", PDF_get_majorversion(), PDF_get_minorversion());
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20)
php_printf("The CJK fonts supported.");
-#endif
#ifdef PDF_OPEN_MEM_SUPPORTED
php_printf("Support for in memory pdf creation.");
#endif
-#if PDFLIB_MAJORVERSION >= 3 | PDFLIB_MINORVERSION > 0
- php_printf("The function pdf_put_image() and pdf_execute_image() are <B>not</B>
available");
-#else
- php_printf("The function pdf_put_image() and pdf_execute_image() are available");
-#endif
}
PHP_MSHUTDOWN_FUNCTION(pdf){
@@ -418,45 +404,31 @@
int argc;
PDF_TLS_VARS;
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10)
argc = ARG_COUNT(ht);
if(argc > 1)
WRONG_PARAM_COUNT;
if (argc != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
+#if defined PDF_OPEN_MEM_SUPPORTED
fp = NULL;
- } else {
- ZEND_FETCH_RESOURCE(fp, FILE *, file, -1, "File-Handle", php_file_le_fopen());
- /* XXX should do anzend_list_addref for <fp> here! */
- }
#else
- if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
php3_error(E_WARNING, "Your version of pdflib does not support in memory creation of PDF
documents. You have to pass a file handle to pdf_open()");
WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(fp, FILE *, file, -1, "File-Handle", php_file_le_fopen());
- /* XXX should do anzend_list_addref for <fp> here! */
#endif
+ } else {
+ ZEND_FETCH_RESOURCE(fp, FILE *, file, -1, "File-Handle", php_file_le_fopen());
+ /* XXX should do anzend_list_addref for <fp> here! */
+ }
pdf = PDF_new2(custom_errorhandler, pdf_emalloc, pdf_realloc, pdf_efree, NULL);
-#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10 & defined
PDF_OPEN_MEM_SUPPORTED
if(fp) {
if (0 > PDF_open_fp(pdf, fp))
RETURN_FALSE;
} else {
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20)
& defined PDF_OPEN_MEM_SUPPORTED
- PDF_open_mem(pdf, pdf_flushwrite);
-#else
if (0 > PDF_open_mem(pdf, pdf_flushwrite))
RETURN_FALSE;
-#endif
- }
-#else
- if (0 > PDF_open_fp(pdf, fp)) {
- RETURN_FALSE;
}
-#endif
+
id = zend_list_insert(pdf,PDF_GLOBAL(le_pdf));
RETURN_LONG(id);
}
@@ -603,7 +575,6 @@
/* {{{ proto void pdf_show_boxed(int pdfdoc, string text, double x-koor, double y-koor, double
width, double height, string mode)
Output text formated in a boxed */
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20)
PHP_FUNCTION(pdf_show_boxed) {
pval *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7;
int id, type;
@@ -631,7 +602,6 @@
RETURN_TRUE;
}
-#endif
/* }}} */
@@ -664,11 +634,7 @@
convert_to_long(arg1);
convert_to_string(arg2);
convert_to_double(arg3);
-#if PDFLIB_MAJORVERSION >= 2
convert_to_string(arg4);
-#else
- convert_to_long(arg4);
-#endif
id=arg1->value.lval;
pdf = zend_list_find(id,&type);
@@ -677,35 +643,7 @@
RETURN_FALSE;
}
-#if PDFLIB_MAJORVERSION >= 2
font = PDF_findfont(pdf, arg2->value.str.val, arg4->value.str.val, embed);
-#else
- if((arg4->value.lval > 5) || (arg4->value.lval < 0)) {
- php_error(E_WARNING,"Font encoding set to 4");
- arg4->value.lval = 4;
- }
-
- switch(arg4->value.lval) {
- case 0:
- font = PDF_findfont(pdf, arg2->value.str.val, "builtin", embed);
- break;
- case 1:
- font = PDF_findfont(pdf, arg2->value.str.val, "pdfdoc", embed);
- break;
- case 2:
- font = PDF_findfont(pdf, arg2->value.str.val, "macroman", embed);
- break;
- case 3:
- font = PDF_findfont(pdf, arg2->value.str.val, "macexpert", embed);
- break;
- case 4:
- font = PDF_findfont(pdf, arg2->value.str.val, "winansi", embed);
- break;
- default:
- php_error(E_WARNING,"Encoding out of range, using 0");
- font = PDF_findfont(pdf, arg2->value.str.val, "builtin", embed);
- }
-#endif
if (font < 0) {
php_error(E_WARNING,"Font %s not found", arg2->value.str.val);
RETURN_FALSE;
@@ -905,7 +843,7 @@
}
/* }}} */
-#if PDFLIB_MAJORVERSION < 3 & PDFLIB_MINORVERSION < 30
+#if 0
/* {{{ proto void pdf_set_text_matrix(int pdfdoc, arry matrix)
Sets the text matrix */
PHP_FUNCTION(pdf_set_text_matrix) {
@@ -1233,7 +1171,6 @@
/* {{{ proto void pdf_skew(int pdfdoc, double xangle, double yangle)
Skew the coordinate system */
-#if PDFLIB_MAJORVERSION >= 3 | (PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 20)
PHP_FUNCTION(pdf_skew) {
pval *arg1, *arg2, *arg3;
int id, type;
@@ -1258,7 +1195,6 @@
RETURN_TRUE;
}
-#endif
/* }}} */
/* {{{ proto void pdf_setflat(int pdfdoc, double value)
@@ -2338,11 +2274,7 @@
}
-#if PDFLIB_MAJORVERSION < 3 & PDFLIB_MINORVERSION == 0
- pdf_image = PDF_open_memory_image(pdf, buffer, im->sx, im->sy, 3, 8);
-#else
- pdf_image = PDF_open_image(pdf, "raw", "memory", buffer,
im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL);
-#endif
+ pdf_image = PDF_open_image(pdf, "raw", "memory", buffer,
im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL);
efree(buffer);
if(-1 == pdf_image) {
@@ -2427,93 +2359,6 @@
PDF_place_image(pdf, pdf_image, (float) arg3->value.dval, (float) arg4->value.dval,
arg5->value.dval);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_put_image(int pdf, int pdfimage)
- Stores image in the pdf document for later use */
-PHP_FUNCTION(pdf_put_image) {
-#if PDFLIB_MINORVERSION > 0 | PDFLIB_MAJORVERSION > 2
-#else
- pval *arg1, *arg2;
- int id, type;
- int pdf_image;
- PDF *pdf;
-#endif
- PDF_TLS_VARS;
-
-#if PDFLIB_MINORVERSION > 0 | PDFLIB_MAJORVERSION > 2
- php_error(E_WARNING, "Version 2.01 and higher of pdflib does not need the pdf_put_image()
anymore, check the docs!");
-#else
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = zend_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) zend_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- PDF_put_image(pdf, pdf_image);
-#endif
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void pdf_execute_image(int pdf, int pdfimage, int x, int y, int scale)
- Places stored image in the pdf document */
-PHP_FUNCTION(pdf_execute_image) {
-#if PDFLIB_MINORVERSION >= 01 | PDFLIB_MAJORVERSION > 2
-#else
- pval *arg1, *arg2, *arg3, *arg4, *arg5;
- int id, type;
- int pdf_image;
- PDF *pdf;
- PDF_TLS_VARS;
-#endif
-
-#if PDFLIB_MINORVERSION >= 01 | PDFLIB_MAJORVERSION > 2
- php_error(E_WARNING, "Version 2.01 and higher of pdflib does not need the pdf_execute_image()
anymore, check the docs!");
-#else
- if (ARG_COUNT(ht) != 5 || getParameters(ht, 5, &arg1, &arg2, &arg3, &arg4,
&arg5) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(arg1);
- id=arg1->value.lval;
- pdf = zend_list_find(id,&type);
- if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_long(arg2);
- id=arg2->value.lval;
- pdf_image = (int) zend_list_find(id,&type);
- if(pdf_image < 0 || type!=PDF_GLOBAL(le_pdf_image)) {
- php_error(E_WARNING,"Unable to find file identifier %d",id);
- RETURN_FALSE;
- }
-
- convert_to_double(arg3);
- convert_to_double(arg4);
- convert_to_double(arg5);
-
- PDF_execute_image(pdf, pdf_image, (float) arg3->value.dval, (float) arg4->value.dval,
arg5->value.dval);
-#endif
RETURN_TRUE;
}
/* }}} */