summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Steinmann <steinm@php.net>2000-02-02 11:18:06 +0000
committerUwe Steinmann <steinm@php.net>2000-02-02 11:18:06 +0000
commit22c5c021f026034ad638addf68cfd39f0e4eeeed (patch)
treea5fc9849c9d4b030f3e479a99d8b910b82d287e3
parentf0f00daa9269bb0415aa6d7f20ceff3d05a7c804 (diff)
downloadphp-git-22c5c021f026034ad638addf68cfd39f0e4eeeed.tar.gz
- several minor cleanups like removing unused variables
-rw-r--r--ext/cpdf/cpdf.c5
-rw-r--r--ext/fdf/fdf.c5
-rw-r--r--ext/hyperwave/hg_comm.c16
-rw-r--r--ext/hyperwave/hw.c4
-rw-r--r--ext/pdf/config.m421
-rw-r--r--ext/pdf/pdf.c89
6 files changed, 119 insertions, 21 deletions
diff --git a/ext/cpdf/cpdf.c b/ext/cpdf/cpdf.c
index 404bc5001f..c6d74e7248 100644
--- a/ext/cpdf/cpdf.c
+++ b/ext/cpdf/cpdf.c
@@ -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 @@ PHP_FUNCTION(cpdf_set_action_url) {
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;
diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c
index 78650e23ca..34e3aaca0f 100644
--- a/ext/fdf/fdf.c
+++ b/ext/fdf/fdf.c
@@ -123,7 +123,7 @@ PHP_MSHUTDOWN_FUNCTION(fdf)
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 @@ PHP_FUNCTION(fdf_close) {
/* {{{ 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_ap) {
PHP_FUNCTION(fdf_set_status) {
pval **arg1, **arg2;
int id, type;
- ASInt32 nr;
FDFDoc fdf;
FDFErc err;
FDF_TLS_VARS;
diff --git a/ext/hyperwave/hg_comm.c b/ext/hyperwave/hg_comm.c
index 7a454e52fd..1138df59b6 100644
--- a/ext/hyperwave/hg_comm.c
+++ b/ext/hyperwave/hg_comm.c
@@ -776,9 +776,9 @@ static int set_noblock(int fd)
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 @@ int write_to(int fd, void *buffer, int n, int timeout)
(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 write_to(int fd, void *buffer, int n, int timeout)
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_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *object
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_getsrcbydest(int sockfd, hw_objectID objectID, char ***childrec, int *c
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);
diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c
index 6448431917..5ade1d45d4 100644
--- a/ext/hyperwave/hw.c
+++ b/ext/hyperwave/hw.c
@@ -283,7 +283,6 @@ int make_return_objrec(pval **return_value, char **objrecs, int count)
*/
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 @@ PHP_FUNCTION(hw_changeobject) {
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 @@ PHP_FUNCTION(hw_docbyanchor) {
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);
diff --git a/ext/pdf/config.m4 b/ext/pdf/config.m4
index 7d479d3460..861bc166f0 100644
--- a/ext/pdf/config.m4
+++ b/ext/pdf/config.m4
@@ -15,13 +15,14 @@ echo $withval
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)
;;
@@ -73,6 +74,24 @@ echo $withval
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)])
AC_ARG_WITH(tiff-dir,
[ --with-tiff-dir[=DIR] tiff dir for pdflib 2.x],[
diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c
index 4497da9cb0..9b4900edb1 100644
--- a/ext/pdf/pdf.c
+++ b/ext/pdf/pdf.c
@@ -183,6 +183,49 @@ static void _free_outline(int *outline)
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 @@ PHP_FUNCTION(pdf_set_info_keywords) {
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 @@ PHP_FUNCTION(pdf_set_font) {
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 @@ PHP_FUNCTION(pdf_get_font) {
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 @@ PHP_FUNCTION(pdf_get_fontname) {
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 @@ PHP_FUNCTION(pdf_place_image) {
/* {{{ 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 @@ PHP_FUNCTION(pdf_put_image) {
/* {{{ 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!");