cvs: /php4/ext/cpdf cpdf.c /php4/ext/fdf fdf.c /php4/ext/hyperwave hg_comm.c hw.c /php4/ext/pdf config.m4 pdf.c
| From: | Uwe Steinmann | Date: | Wed, 02 Feb 2000 11:18:02 +0000 |
| Subject: | cvs: /php4/ext/cpdf cpdf.c /php4/ext/fdf fdf.c /php4/ext/hyperwave hg_comm.c hw.c /php4/ext/pdf config.m4 pdf.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-9660@lists.php.net to get a copy of this message | ||
steinm Wed Feb 2 12:18:02 2000 EDT
Modified files:
/php4/ext/cpdf cpdf.c
/php4/ext/fdf fdf.c
/php4/ext/hyperwave hg_comm.c hw.c
/php4/ext/pdf config.m4 pdf.c
Log:
- several minor cleanups like removing unused variables
Index: php4/ext/cpdf/cpdf.c
diff -u php4/ext/cpdf/cpdf.c:1.9 php4/ext/cpdf/cpdf.c:1.10
--- php4/ext/cpdf/cpdf.c:1.9 Mon Jan 10 13:42:05 2000
+++ php4/ext/cpdf/cpdf.c Wed Feb 2 12:18:00 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cpdf.c,v 1.9 2000/01/10 12:42:05 steinm Exp $ */
+/* $Id: cpdf.c,v 1.10 2000/02/02 11:18:00 steinm Exp $ */
/* cpdflib.h -- C language API definitions for ClibPDF library
* Copyright (C) 1998 FastIO Systems, All Rights Reserved.
*/
@@ -40,6 +40,9 @@
#include "php.h"
#include "php_globals.h"
+#include "ext/standard/php_standard.h"
+#include "ext/standard/head.h"
+#include "ext/standard/info.h"
#include <math.h>
#if HAVE_LIBGD13
#include <gd.h>
@@ -2531,7 +2534,7 @@
Add outline */
PHP_FUNCTION(cpdf_add_outline) {
pval *argv[11];
- int id, oid, type, argc, mode=0;
+ int id, oid, type, argc;
CPDFdoc *pdf;
CPDFoutlineEntry *lastoutline;
CPDF_TLS_VARS;
Index: php4/ext/fdf/fdf.c
diff -u php4/ext/fdf/fdf.c:1.16 php4/ext/fdf/fdf.c:1.17
--- php4/ext/fdf/fdf.c:1.16 Sat Jan 1 02:31:32 2000
+++ php4/ext/fdf/fdf.c Wed Feb 2 12:18:01 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fdf.c,v 1.16 2000/01/01 01:31:32 sas Exp $ */
+/* $Id: fdf.c,v 1.17 2000/02/02 11:18:01 steinm Exp $ */
/* FdfTk lib 2.0 is a Complete C/C++ FDF Toolkit available from
http://beta1.adobe.com/ada/acrosdk/forms.html.
*/
@@ -123,7 +123,7 @@
Opens a new fdf document */
PHP_FUNCTION(fdf_open) {
pval **file;
- int id, type;
+ int id;
FDFDoc fdf;
FDFErc err;
FDF_TLS_VARS;
@@ -174,7 +174,7 @@
/* {{{ proto void fdf_create(void)
Creates a new fdf document */
PHP_FUNCTION(fdf_create) {
- int id, type;
+ int id;
FDFDoc fdf;
FDFErc err;
FDF_TLS_VARS;
@@ -367,7 +367,6 @@
PHP_FUNCTION(fdf_set_status) {
pval **arg1, **arg2;
int id, type;
- ASInt32 nr;
FDFDoc fdf;
FDFErc err;
FDF_TLS_VARS;
Index: php4/ext/hyperwave/hg_comm.c
diff -u php4/ext/hyperwave/hg_comm.c:1.17 php4/ext/hyperwave/hg_comm.c:1.18
--- php4/ext/hyperwave/hg_comm.c:1.17 Sat Jan 1 02:31:34 2000
+++ php4/ext/hyperwave/hg_comm.c Wed Feb 2 12:18:01 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.17 2000/01/01 01:31:34 sas Exp $ */
+/* $Id: hg_comm.c,v 1.18 2000/02/02 11:18:01 steinm Exp $ */
/* #define HW_DEBUG */
@@ -776,9 +776,9 @@
int write_to(int fd, void *buffer, int n, int timeout)
{
- int nrem, nw;
+ int nrem, nw=0;
char *bptr;
- int error;
+ int error=0;
#if defined(SYSV) || (WIN32|WINNT)
int width = 20;
#else
@@ -812,7 +812,7 @@
(fd_set *) 0,
&select_timeout)) <= 0 && errno != EINTR) break;
- if(errno != EINTR && ( nw = write(fd, bptr, nrem)) <= 0) {
+ if(errno != EINTR && ( nw = write(fd, bptr, nrem)) <= 0) {
/*
* check for error number - and keep trying to
* write
@@ -846,9 +846,9 @@
int read_to(int fd, char *buffer, int n, int timeout)
{
- int nrem, nread, nr;
+ int nrem, nread, nr=0;
char *bptr;
- int error;
+ int error=0;
#if defined(SYSV) || (WIN32|WINNT)
int width = 20;
@@ -1608,7 +1608,7 @@
int send_unlock(int sockfd, hw_objectID objectID)
{
hg_msg msg;
- int length, error;
+ int length;
char *tmp;
length = HEADER_LENGTH + sizeof(hw_objectID);
@@ -4691,9 +4691,9 @@
int send_mapid(int sockfd, int servid, hw_objectID id, int *virtid)
{
hg_msg msg, *retmsg;
- int length, i, error;
+ int length, error;
char *tmp;
- int *ptr, *ptr1;
+ int *ptr;
length = HEADER_LENGTH + 2 * sizeof(hw_objectID);
Index: php4/ext/hyperwave/hw.c
diff -u php4/ext/hyperwave/hw.c:1.37 php4/ext/hyperwave/hw.c:1.38
--- php4/ext/hyperwave/hw.c:1.37 Sat Jan 1 02:31:34 2000
+++ php4/ext/hyperwave/hw.c Wed Feb 2 12:18:01 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.37 2000/01/01 01:31:34 sas Exp $ */
+/* $Id: hw.c,v 1.38 2000/02/02 11:18:01 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
@@ -283,7 +283,6 @@
*/
int make2_return_array_from_objrec(pval **return_value, char *objrec, zval *sarr) {
char *attrname, *str, *temp, language[3];
- int i, count;
zval *spec_arr;
char *strtok_buf = NULL;
@@ -1500,7 +1499,6 @@
int link, id, type, i;
hw_connection *ptr;
char *modification, *oldobjrec, buf[BUFFERLEN];
- char *tmp;
HashTable *newobjarr;
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
@@ -2926,7 +2924,7 @@
int link, id, type;
hw_connection *ptr;
- if (ARG_COUNT(ht) != 2 || getParameters(2, &arg1, &arg2) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(arg1);
Index: php4/ext/pdf/config.m4
diff -u php4/ext/pdf/config.m4:1.9 php4/ext/pdf/config.m4:1.10
--- php4/ext/pdf/config.m4:1.9 Thu Dec 30 05:52:10 1999
+++ php4/ext/pdf/config.m4 Wed Feb 2 12:18:01 2000
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.9 1999/12/30 04:52:10 sas Exp $
+dnl $Id: config.m4,v 1.10 2000/02/02 11:18:01 steinm Exp $
AC_MSG_CHECKING(whether to include Pdflib 2.x support)
AC_ARG_WITH(pdflib,
@@ -15,13 +15,14 @@
PHP_EXTENSION(pdf)
old_LDFLAGS=$LDFLAGS
old_LIBS=$LIBS
- LIBS="$LIBS -ltiff -ljpeg -lz"
+ 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>)])
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
AC_ADD_LIBRARY(pdf)
AC_ADD_LIBRARY(tiff)
+ AC_ADD_LIBRARY(png)
AC_ADD_LIBRARY(jpeg)
AC_ADD_LIBRARY(z)
;;
@@ -71,6 +72,24 @@
],[
AC_MSG_RESULT(no)
AC_MSG_WARN(If configure fails try --with-jpeg-dir=<DIR>)
+ ])
+
+ 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)
+ if test -z $withval; then
+ withval="/usr/local"
+ fi
+ old_LIBS=$LIBS
+ LIBS="$LIBS -L$withval/lib"
+ AC_CHECK_LIB(png,png_create_info_struct, [PDFLIB_LIBS="$PDFLIB_LIBS -L$withval/lib
-lpng"],[AC_MSG_RESULT(no)],)
+ LIBS=$old_LIBS
+ 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_MSG_CHECKING([for libtiff (needed by pdflib 2.x)])
Index: php4/ext/pdf/pdf.c
diff -u php4/ext/pdf/pdf.c:1.20 php4/ext/pdf/pdf.c:1.21
--- php4/ext/pdf/pdf.c:1.20 Sat Dec 18 23:35:21 1999
+++ php4/ext/pdf/pdf.c Wed Feb 2 12:18:01 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdf.c,v 1.20 1999/12/18 22:35:21 zeev Exp $ */
+/* $Id: pdf.c,v 1.21 2000/02/02 11:18:01 steinm Exp $ */
/* pdflib 2.01 is subject to the ALADDIN FREE PUBLIC LICENSE.
Copyright (C) 1997 Thomas Merz. */
@@ -183,6 +183,49 @@
if(outline) efree(outline);
}
+#if PDFLIB_MAJORVERSION > 1 & PDFLIB_MINORVERSION > 0
+static void custom_errorhandler(PDF *p, int type, const char*shortmsg) {
+ switch (type){
+ case PDF_NonfatalError:
+ return;
+ case PDF_MemoryError:/*give up in all other cases */
+ case PDF_IOError:
+ case PDF_RuntimeError:
+ case PDF_IndexError:
+ case PDF_TypeError:
+ case PDF_DivisionByZero:
+ case PDF_OverflowError:
+ case PDF_SyntaxError:
+ case PDF_ValueError:
+ case PDF_SystemError:
+ case PDF_UnknownError:
+ default:
+ if (p !=NULL)
+ PDF_delete(p);/*clean up PDFlib */
+ php3_error(E_ERROR,"Internal pdflib error: %s", shortmsg);
+ }
+}
+
+static void *pdf_emalloc(PDF *p, size_t size, const char *caller) {
+ return(emalloc(size));
+}
+
+static void *pdf_realloc(PDF *p, void *mem, size_t size, const char *caller) {
+ return(erealloc(mem, size));
+}
+
+static void pdf_efree(PDF *p, void *mem) {
+ return(efree(mem));
+}
+#endif
+
+#if 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));
+}
+#endif
+
PHP_MINIT_FUNCTION(pdf)
{
PDF_GLOBAL(le_pdf_image) = register_list_destructors(_free_pdf_image, NULL);
@@ -359,23 +402,53 @@
Opens a new pdf document */
PHP_FUNCTION(pdf_open) {
pval **file;
- pval *info;
- int id, type;
+ int id;
FILE *fp;
PDF *pdf;
+ int argc;
PDF_TLS_VARS;
+#if 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) {
+ fp = NULL;
+ php3_printf("No File\n");
+ } else {
+ php3_printf("With File\n");
+ 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
+#if PDFLIB_MAJORVERSION > 1 & PDFLIB_MINORVERSION > 0
+ pdf = PDF_new2(custom_errorhandler, pdf_emalloc, pdf_realloc, pdf_efree, NULL);
+#else
pdf = PDF_new();
+#endif
+
+#if PDFLIB_MAJORVERSION >= 2 & PDFLIB_MINORVERSION >= 10
+ if(fp) {
+ if (0 > PDF_open_fp(pdf, fp))
+ RETURN_FALSE;
+ } else {
+ if (0 > PDF_open_mem(pdf, pdf_flushwrite))
+ RETURN_FALSE;
+ }
+#else
if (0 > PDF_open_fp(pdf, fp)) {
RETURN_FALSE;
}
+#endif
id = zend_list_insert(pdf,PDF_GLOBAL(le_pdf));
RETURN_LONG(id);
}
@@ -598,7 +671,7 @@
Gets the current font */
PHP_FUNCTION(pdf_get_font) {
pval *arg1;
- int id, type, font, embed;
+ int id, type, font;
PDF *pdf;
PDF_TLS_VARS;
@@ -624,7 +697,7 @@
Gets the current font name */
PHP_FUNCTION(pdf_get_fontname) {
pval *arg1;
- int id, type, embed;
+ int id, type;
char *fontname;
PDF *pdf;
PDF_TLS_VARS;
@@ -651,7 +724,7 @@
Gets the current font size */
PHP_FUNCTION(pdf_get_fontsize) {
pval *arg1;
- int id, type, embed;
+ int id, type;
float fontsize;
PDF *pdf;
PDF_TLS_VARS;
@@ -2217,10 +2290,13 @@
/* {{{ 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
+#else
pval *arg1, *arg2;
int id, type;
int pdf_image;
PDF *pdf;
+#endif
PDF_TLS_VARS;
#if PDFLIB_MINORVERSION > 0
@@ -2256,11 +2332,14 @@
/* {{{ 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
+#else
pval *arg1, *arg2, *arg3, *arg4, *arg5;
int id, type;
int pdf_image;
PDF *pdf;
PDF_TLS_VARS;
+#endif
#if PDFLIB_MINORVERSION >= 01
php_error(E_WARNING, "Version 2.01 of pdflib does not need the pdf_execute_image() anymore,
check the docs!");