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
(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
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;
int send_unlock(int sockfd, hw_objectID objectID)
{
hg_msg msg;
- int length, error;
+ int length;
char *tmp;
length = HEADER_LENGTH + sizeof(hw_objectID);
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);
*/
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;
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) {
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);
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)
;;
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],[
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);
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);
}
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;
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;
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;
/* {{{ 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
/* {{{ 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!");