helly Sun Dec 1 06:43:55 2002 EDT Modified files: /php4/ext/gd/libgd gd.c gd.h gd_arc_f_buggy.c gd_gd2.c gd_gif_in.c gd_jpeg.c gd_png.c gd_ss.c gd_wbmp.c gdkanji.c gdxpm.c Log: No more (f)printf for errors and warnings instead use php_error_docref.
Index: php4/ext/gd/libgd/gd.c diff -u php4/ext/gd/libgd/gd.c:1.30 php4/ext/gd/libgd/gd.c:1.31 --- php4/ext/gd/libgd/gd.c:1.30 Thu Nov 28 20:44:19 2002 +++ php4/ext/gd/libgd/gd.c Sun Dec 1 06:43:54 2002 @@ -92,6 +92,28 @@ static int gdAlphaOverlayColor(int src, int dst, int max); static int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y); +void php_gd_error_ex(int type, const char *format, ...) +{ + va_list args; + + TSRMLS_FETCH(); + + va_start(args, format); + php_verror(NULL, "", type, format, args TSRMLS_CC); + va_end(args); +} + +void php_gd_error(const char *format, ...) +{ + va_list args; + + TSRMLS_FETCH(); + + va_start(args, format); + php_verror(NULL, "", E_WARNING, format, args TSRMLS_CC); + va_end(args); +} + gdImagePtr gdImageCreate (int sx, int sy) { @@ -2780,7 +2802,7 @@ } } /* Shouldn't happen */ - fprintf (stderr, "Error: bug in gdImageCreateFromXbm!\n"); + php_gd_error("Error: bug in gdImageCreateFromXbm\n"); return 0; fail: gdImageDestroy (im); Index: php4/ext/gd/libgd/gd.h diff -u php4/ext/gd/libgd/gd.h:1.9 php4/ext/gd/libgd/gd.h:1.10 --- php4/ext/gd/libgd/gd.h:1.9 Sun Nov 24 20:51:53 2002 +++ php4/ext/gd/libgd/gd.h Sun Dec 1 06:43:54 2002 @@ -30,6 +30,11 @@ #include <stdio.h> #include "gd_io.h" +void php_gd_error_ex(int type, const char *format, ...); + +void php_gd_error(const char *format, ...); + + /* The maximum number of palette entries in palette-based images. In the wonderful new world of gd 2.0, you can of course have many more colors when using truecolor mode. */ Index: php4/ext/gd/libgd/gd_arc_f_buggy.c diff -u php4/ext/gd/libgd/gd_arc_f_buggy.c:1.1 php4/ext/gd/libgd/gd_arc_f_buggy.c:1.2 --- php4/ext/gd/libgd/gd_arc_f_buggy.c:1.1 Fri Apr 12 22:03:08 2002 +++ php4/ext/gd/libgd/gd_arc_f_buggy.c Sun Dec 1 06:43:54 2002 @@ -726,12 +726,12 @@ out = fopen ("test/arctest.png", "wb"); if (!out) { - fprintf (stderr, "Can't create test/arctest.png\n"); + php_gd_error("Can't create test/arctest.png\n"); exit (1); } gdImagePng (im, out); fclose (out); - fprintf (stderr, "Test image written to test/arctest.png\n"); + php_gd_error("Test image written to test/arctest.png\n"); /* Destroy it */ gdImageDestroy (im); Index: php4/ext/gd/libgd/gd_gd2.c diff -u php4/ext/gd/libgd/gd_gd2.c:1.7 php4/ext/gd/libgd/gd_gd2.c:1.8 --- php4/ext/gd/libgd/gd_gd2.c:1.7 Thu Nov 28 17:48:19 2002 +++ php4/ext/gd/libgd/gd_gd2.c Sun Dec 1 06:43:54 2002 @@ -25,8 +25,8 @@ /* Use this for commenting out debug-print statements. */ /* Just use the first '#define' to allow all the prints... */ -/*#define GD2_DBG(s) (s) */ -#define GD2_DBG(s) +#define GD2_DBG(s) (s) +//#define GD2_DBG(s) typedef struct { @@ -53,7 +53,7 @@ int sidx; int nc; - GD2_DBG (printf ("Reading gd2 header info\n")); + GD2_DBG(php_gd_error("Reading gd2 header info\n")); for (i = 0; i < 4; i++) { @@ -66,12 +66,12 @@ }; id[4] = 0; - GD2_DBG (printf ("Got file code: %s\n", id)); + GD2_DBG(php_gd_error("Got file code: %s\n", id)); /* Equiv. of 'magick'. */ if (strcmp (id, GD2_ID) != 0) { - GD2_DBG (printf ("Not a valid gd2 file\n")); + GD2_DBG(php_gd_error("Not a valid gd2 file\n")); goto fail1; }; @@ -80,37 +80,37 @@ { goto fail1; }; - GD2_DBG (printf ("Version: %d\n", *vers)); + GD2_DBG(php_gd_error("Version: %d\n", *vers)); if ((*vers != 1) && (*vers != 2)) { - GD2_DBG (printf ("Bad version: %d\n", *vers)); + GD2_DBG(php_gd_error("Bad version: %d\n", *vers)); goto fail1; }; /* Image Size */ if (!gdGetWord (sx, in)) { - GD2_DBG (printf ("Could not get x-size\n")); + GD2_DBG(php_gd_error("Could not get x-size\n")); goto fail1; } if (!gdGetWord (sy, in)) { - GD2_DBG (printf ("Could not get y-size\n")); + GD2_DBG(php_gd_error("Could not get y-size\n")); goto fail1; } - GD2_DBG (printf ("Image is %dx%d\n", *sx, *sy)); + GD2_DBG(php_gd_error("Image is %dx%d\n", *sx, *sy)); /* Chunk Size (pixels, not bytes!) */ if (gdGetWord (cs, in) != 1) { goto fail1; }; - GD2_DBG (printf ("ChunkSize: %d\n", *cs)); + GD2_DBG(php_gd_error("ChunkSize: %d\n", *cs)); if ((*cs < GD2_CHUNKSIZE_MIN) || (*cs > GD2_CHUNKSIZE_MAX)) { - GD2_DBG (printf ("Bad chunk size: %d\n", *cs)); + GD2_DBG(php_gd_error("Bad chunk size: %d\n", *cs)); goto fail1; }; @@ -119,11 +119,11 @@ { goto fail1; }; - GD2_DBG (printf ("Format: %d\n", *fmt)); + GD2_DBG(php_gd_error("Format: %d\n", *fmt)); if ((*fmt != GD2_FMT_RAW) && (*fmt != GD2_FMT_COMPRESSED)) { - GD2_DBG (printf ("Bad data format: %d\n", *fmt)); + GD2_DBG(php_gd_error("Bad data format: %d\n", *fmt)); goto fail1; }; @@ -133,19 +133,19 @@ { goto fail1; }; - GD2_DBG (printf ("%d Chunks Wide\n", *ncx)); + GD2_DBG(php_gd_error("%d Chunks Wide\n", *ncx)); /* # of chunks high */ if (gdGetWord (ncy, in) != 1) { goto fail1; }; - GD2_DBG (printf ("%d Chunks vertically\n", *ncy)); + GD2_DBG(php_gd_error("%d Chunks vertically\n", *ncy)); if ((*fmt) == GD2_FMT_COMPRESSED) { nc = (*ncx) * (*ncy); - GD2_DBG (printf ("Reading %d chunk index entries\n", nc)); + GD2_DBG(php_gd_error("Reading %d chunk index entries\n", nc)); sidx = sizeof (t_chunk_info) * nc; cidx = gdCalloc (sidx, 1); for (i = 0; i < nc; i++) @@ -162,7 +162,7 @@ *chunkIdx = cidx; }; - GD2_DBG (printf ("gd2 header complete\n")); + GD2_DBG(php_gd_error("gd2 header complete\n")); return 1; @@ -180,23 +180,23 @@ if (_gd2GetHeader (in, sx, sy, cs, vers, fmt, ncx, ncy, cidx) != 1) { - GD2_DBG (printf ("Bad GD2 header\n")); + GD2_DBG(php_gd_error("Bad GD2 header\n")); goto fail1; } im = gdImageCreate (*sx, *sy); if (im == NULL) { - GD2_DBG (printf ("Could not create gdImage\n")); + GD2_DBG(php_gd_error("Could not create gdImage\n")); goto fail1; }; if (!_gdGetColors (in, im, (*vers) == 2)) { - GD2_DBG (printf ("Could not read color palette\n")); + GD2_DBG(php_gd_error("Could not read color palette\n")); goto fail2; } - GD2_DBG (printf ("Image palette completed: %d colours\n", im->colorsTotal)); + GD2_DBG(php_gd_error("Image palette completed: %d colours\n", im->colorsTotal)); return im; @@ -217,29 +217,29 @@ if (gdTell (in) != offset) { - GD2_DBG (printf ("Positioning in file to %d\n", offset)); + GD2_DBG(php_gd_error("Positioning in file to %d\n", offset)); gdSeek (in, offset); } else { - GD2_DBG (printf ("Already Positioned in file to %d\n", offset)); + GD2_DBG(php_gd_error("Already Positioned in file to %d\n", offset)); }; /* Read and uncompress an entire chunk. */ - GD2_DBG (printf ("Reading file\n")); + GD2_DBG(php_gd_error("Reading file\n")); if (gdGetBuf (compBuf, compSize, in) != compSize) { return FALSE; }; - GD2_DBG (printf ("Got %d bytes. Uncompressing into buffer of %d bytes\n", compSize, *chunkLen)); + GD2_DBG(php_gd_error("Got %d bytes. Uncompressing into buffer of %d bytes\n", +compSize, (int)*chunkLen)); zerr = uncompress ((unsigned char *) chunkBuf, chunkLen, (unsigned char *) compBuf, compSize); if (zerr != Z_OK) { - GD2_DBG (printf ("Error %d from uncompress\n", zerr)); + GD2_DBG(php_gd_error("Error %d from uncompress\n", zerr)); return FALSE; }; - GD2_DBG (printf ("Got chunk\n")); + GD2_DBG(php_gd_error("Got chunk\n")); return TRUE; } @@ -303,7 +303,7 @@ chunkMax = cs * bytesPerPixel * cs; chunkBuf = gdCalloc (chunkMax, 1); compBuf = gdCalloc (compMax, 1); - GD2_DBG (printf ("Largest compressed chunk is %d bytes\n", compMax)); + GD2_DBG(php_gd_error("Largest compressed chunk is %d bytes\n", compMax)); }; /* if ( (ncx != sx / cs) || (ncy != sy / cs)) { */ @@ -323,7 +323,7 @@ yhi = im->sy; }; - GD2_DBG (printf ("Processing Chunk %d (%d, %d), y from %d to %d\n", chunkNum, cx, cy, ylo, yhi)); + GD2_DBG(php_gd_error("Processing Chunk %d (%d, %d), y from %d to %d\n", +chunkNum, cx, cy, ylo, yhi)); if (fmt == GD2_FMT_COMPRESSED) { @@ -335,7 +335,7 @@ chunkIdx[chunkNum].size, chunkBuf, &chunkLen, in)) { - GD2_DBG (printf ("Error reading comproessed chunk\n")); + GD2_DBG(php_gd_error("Error reading comproessed chunk\n")); goto fail2; }; @@ -351,7 +351,7 @@ { xhi = im->sx; }; - /*GD2_DBG(printf("y=%d: ",y)); */ + /*GD2_DBG(php_gd_error("y=%d: ",y)); */ if (fmt == GD2_FMT_RAW) { for (x = xlo; x < xhi; x++) @@ -361,7 +361,7 @@ { if (!gdGetInt (&im->tpixels[y][x], in)) { - /*printf("EOF while reading\n"); */ + /*php_gd_error("EOF while reading\n"); */ /*gdImageDestroy(im); */ /*return 0; */ im->tpixels[y][x] = 0; @@ -372,7 +372,7 @@ int ch; if (!gdGetByte (&ch, in)) { - /*printf("EOF while reading\n"); */ + /*php_gd_error("EOF while reading\n"); */ /*gdImageDestroy(im); */ /*return 0; */ ch = 0; @@ -401,19 +401,19 @@ } }; }; - /*GD2_DBG(printf("\n")); */ + /*GD2_DBG(php_gd_error("\n")); */ }; chunkNum++; }; }; - GD2_DBG (printf ("Freeing memory\n")); + GD2_DBG(php_gd_error("Freeing memory\n")); gdFree (chunkBuf); gdFree (compBuf); gdFree (chunkIdx); - GD2_DBG (printf ("Done\n")); + GD2_DBG(php_gd_error("Done\n")); return im; @@ -469,7 +469,7 @@ goto fail1; } - GD2_DBG (printf ("File size is %dx%d\n", fsx, fsy)); + GD2_DBG(php_gd_error("File size is %dx%d\n", fsx, fsy)); /* This is the difference - make a file based on size of chunks. */ im = gdImageCreate (w, h); @@ -482,7 +482,7 @@ { goto fail2; } - GD2_DBG (printf ("Image palette completed: %d colours\n", im->colorsTotal)); + GD2_DBG(php_gd_error("Image palette completed: %d colours\n", im->colorsTotal)); /* Process the header info */ nc = ncx * ncy; @@ -543,7 +543,7 @@ /* Remember file position of image data. */ dstart = gdTell (in); - GD2_DBG (printf ("Data starts at %d\n", dstart)); + GD2_DBG(php_gd_error("Data starts at %d\n", dstart)); /* Loop through the chunks. */ for (cy = scy; (cy <= ecy); cy++) @@ -566,11 +566,11 @@ xhi = fsx; }; - GD2_DBG (printf ("Processing Chunk (%d, %d), from %d to %d\n", cx, cy, ylo, yhi)); + GD2_DBG(php_gd_error("Processing Chunk (%d, %d), from %d to %d\n", cx, cy, +ylo, yhi)); if (fmt == GD2_FMT_RAW) { - GD2_DBG (printf ("Using raw format data\n")); + GD2_DBG(php_gd_error("Using raw format data\n")); if (im->trueColor) { dpos = (cy * (cs * fsx) + cx * cs * (yhi - ylo) * 4) + dstart; @@ -582,10 +582,10 @@ if (gdSeek (in, dpos) != 0) { - printf ("Error from seek: %d\n", errno); + php_gd_error_ex(E_WARNING, "Error from seek: %d\n", errno); goto fail2; }; - GD2_DBG (printf ("Reading (%d, %d) from position %d\n", cx, cy, dpos - dstart)); + GD2_DBG(php_gd_error("Reading (%d, %d) from position %d\n", cx, cy, dpos +- dstart)); } else { @@ -597,14 +597,14 @@ chunkIdx[chunkNum].size, chunkBuf, &chunkLen, in)) { - printf ("Error reading comproessed chunk\n"); + php_gd_error("Error reading comproessed chunk\n"); goto fail2; }; chunkPos = 0; - GD2_DBG (printf ("Reading (%d, %d) from chunk %d\n", cx, cy, chunkNum)); + GD2_DBG(php_gd_error("Reading (%d, %d) from chunk %d\n", cx, cy, +chunkNum)); }; - GD2_DBG (printf (" into (%d, %d) - (%d, %d)\n", xlo, ylo, xhi, yhi)); + GD2_DBG(php_gd_error(" into (%d, %d) - (%d, %d)\n", xlo, ylo, xhi, yhi)); for (y = ylo; (y < yhi); y++) { @@ -617,7 +617,7 @@ if (!gdGetInt (&ch, in)) { ch = 0; - /*printf("EOF while reading file\n"); */ + /*php_gd_error("EOF while reading file\n"); */ /*goto fail2; */ } } @@ -627,7 +627,7 @@ if (ch == EOF) { ch = 0; - /*printf("EOF while reading file\n"); */ + /*php_gd_error("EOF while reading file\n"); */ /*goto fail2; */ } } @@ -718,7 +718,7 @@ int bytesPerPixel = im->trueColor ? 4 : 1; int compMax = 0; - /*printf("Trying to write GD2 file\n"); */ + /*php_gd_error("Trying to write GD2 file\n"); */ /* */ /* Force fmt to a valid value since we don't return anything. */ @@ -777,7 +777,7 @@ /* */ idxPos = gdTell (out); idxSize = ncx * ncy * sizeof (t_chunk_info); - GD2_DBG (printf ("Index size is %d\n", idxSize)); + GD2_DBG(php_gd_error("Index size is %d\n", idxSize)); gdSeek (out, idxPos + idxSize); chunkIdx = gdCalloc (idxSize * sizeof (t_chunk_info), 1); @@ -785,8 +785,8 @@ _gdPutColors (im, out); - GD2_DBG (printf ("Size: %dx%d\n", im->sx, im->sy)); - GD2_DBG (printf ("Chunks: %dx%d\n", ncx, ncy)); + GD2_DBG(php_gd_error("Size: %dx%d\n", im->sx, im->sy)); + GD2_DBG(php_gd_error("Chunks: %dx%d\n", ncx, ncy)); for (cy = 0; (cy < ncy); cy++) { @@ -800,12 +800,12 @@ yhi = im->sy; }; - GD2_DBG (printf ("Processing Chunk (%dx%d), y from %d to %d\n", cx, cy, ylo, yhi)); + GD2_DBG(php_gd_error("Processing Chunk (%dx%d), y from %d to %d\n", cx, cy, +ylo, yhi)); chunkLen = 0; for (y = ylo; (y < yhi); y++) { - /*GD2_DBG(printf("y=%d: ",y)); */ + GD2_DBG(php_gd_error("y=%d: ",y)); xlo = cx * cs; xhi = xlo + cs; @@ -819,7 +819,7 @@ for (x = xlo; x < xhi; x++) { int p = im->pixels[y][x]; - /*GD2_DBG(printf("%d...",x)); */ + GD2_DBG(php_gd_error("%d...",x)); if (im->trueColor) { chunkData[chunkLen++] = gdTrueColorGetAlpha (p); @@ -837,7 +837,7 @@ { for (x = xlo; x < xhi; x++) { - /*GD2_DBG(printf("%d, ",x)); */ + GD2_DBG(php_gd_error("%d, ",x)); if (im->trueColor) { @@ -849,7 +849,7 @@ } }; }; - /*GD2_DBG(printf("y=%d done.\n",y)); */ + GD2_DBG(php_gd_error("y=%d done.\n",y)); }; if (fmt == GD2_FMT_COMPRESSED) { @@ -859,18 +859,18 @@ (unsigned char *) &chunkData[0], chunkLen) != Z_OK) { - printf ("Error from compressing\n"); + php_gd_error ("Error from compressing\n"); } else { chunkIdx[chunkNum].offset = gdTell (out); chunkIdx[chunkNum++].size = compLen; - GD2_DBG (printf ("Chunk %d size %d offset %d\n", chunkNum, chunkIdx[chunkNum - 1].size, chunkIdx[chunkNum - 1].offset)); + GD2_DBG(php_gd_error("Chunk %d size %d offset %d\n", chunkNum, +chunkIdx[chunkNum - 1].size, chunkIdx[chunkNum - 1].offset)); if (gdPutBuf (compData, compLen, out) <= 0) { /* Any alternate suggestions for handling this? */ - printf ("Error %d on write\n", errno); + php_gd_error_ex (E_WARNING, "Error %d on write\n", errno); }; }; }; @@ -879,13 +879,13 @@ if (fmt == GD2_FMT_COMPRESSED) { /* Save the position, write the index, restore position (paranoia). */ - GD2_DBG (printf ("Seeking %d to write index\n", idxPos)); + GD2_DBG(php_gd_error("Seeking %d to write index\n", idxPos)); posSave = gdTell (out); gdSeek (out, idxPos); - GD2_DBG (printf ("Writing index\n")); + GD2_DBG(php_gd_error("Writing index\n")); for (x = 0; x < chunkNum; x++) { - GD2_DBG (printf ("Chunk %d size %d offset %d\n", x, chunkIdx[x].size, chunkIdx[x].offset)); + GD2_DBG(php_gd_error("Chunk %d size %d offset %d\n", x, chunkIdx[x].size, +chunkIdx[x].offset)); gdPutInt (chunkIdx[x].offset, out); gdPutInt (chunkIdx[x].size, out); }; @@ -894,13 +894,13 @@ gdSeek (out, posSave); }; - GD2_DBG (printf ("Freeing memory\n")); + GD2_DBG(php_gd_error("Freeing memory\n")); gdFree (chunkData); gdFree (compData); gdFree (chunkIdx); - GD2_DBG (printf ("Done\n")); + GD2_DBG(php_gd_error("Done\n")); - /*printf("Memory block size is %d\n",gdTell(out)); */ + /*php_gd_error("Memory block size is %d\n",gdTell(out)); */ } Index: php4/ext/gd/libgd/gd_gif_in.c diff -u php4/ext/gd/libgd/gd_gif_in.c:1.2 php4/ext/gd/libgd/gd_gif_in.c:1.3 --- php4/ext/gd/libgd/gd_gif_in.c:1.2 Tue Oct 29 18:08:01 2002 +++ php4/ext/gd/libgd/gd_gif_in.c Sun Dec 1 06:43:54 2002 @@ -4,6 +4,8 @@ #include <stdlib.h> #include "gd.h" +#include "php.h" + /* Used only when debugging GIF compression code */ /* #define DEBUGGING_ENVARS */ @@ -290,19 +292,24 @@ static int GetDataBlock(gdIOCtx *fd, unsigned char *buf) { - int rv; - int i; - - rv = GetDataBlock_(fd,buf); - if (VERBOSE) - { printf("[GetDataBlock returning %d",rv); - if (rv > 0) - { printf(":"); - for (i=0;i<rv;i++) printf(" %02x",buf[i]); - } - printf("]\n"); - } - return(rv); + int rv; + int i; + char *tmp = NULL; + + rv = GetDataBlock_(fd,buf); + if (VERBOSE) { + if (rv > 0) { + tmp = emalloc((3*sizeof(char)*rv) + 1); + for (i=0;i<rv;i++) { + sprintf(&tmp[3*sizeof(char)*i], " %02x", buf[i]); + } + } else { + tmp = estrdup(""); + } + php_gd_error_ex(E_NOTICE, "[GetDataBlock returning %d: %s]", rv, tmp); + efree(tmp); + } + return(rv); } static int @@ -352,7 +359,7 @@ int rv; rv = GetCode_(fd,code_size,flag); - if (VERBOSE) printf("[GetCode(,%d,%d) returning %d]\n",code_size,flag,rv); + if (VERBOSE) php_gd_error_ex(E_NOTICE, "[GetCode(,%d,%d) returning +%d]\n",code_size,flag,rv); return(rv); } @@ -484,7 +491,7 @@ int rv; rv = LWZReadByte_(fd,flag,input_code_size); - if (VERBOSE) printf("[LWZReadByte(,%d,%d) returning %d]\n",flag,input_code_size,rv); + if (VERBOSE) php_gd_error_ex(E_NOTICE, "[LWZReadByte(,%d,%d) returning +%d]\n",flag,input_code_size,rv); return(rv); } Index: php4/ext/gd/libgd/gd_jpeg.c diff -u php4/ext/gd/libgd/gd_jpeg.c:1.8 php4/ext/gd/libgd/gd_jpeg.c:1.9 --- php4/ext/gd/libgd/gd_jpeg.c:1.8 Thu Nov 28 20:44:19 2002 +++ php4/ext/gd/libgd/gd_jpeg.c Sun Dec 1 06:43:54 2002 @@ -49,9 +49,8 @@ { jmpbuf_wrapper *jmpbufw; - fprintf (stderr, "gd-jpeg: JPEG library reports unrecoverable error: "); + php_gd_error("gd-jpeg: JPEG library reports unrecoverable error: "); (*cinfo->err->output_message) (cinfo); - fflush (stderr); jmpbufw = (jmpbuf_wrapper *) cinfo->client_data; jpeg_destroy (cinfo); @@ -59,16 +58,15 @@ if (jmpbufw != 0) { longjmp (jmpbufw->jmpbuf, 1); - fprintf (stderr, "gd-jpeg: EXTREMELY fatal error: longjmp" + php_gd_error_ex(E_ERROR, "gd-jpeg: EXTREMELY fatal error: longjmp" " returned control; terminating\n"); } else { - fprintf (stderr, "gd-jpeg: EXTREMELY fatal error: jmpbuf" + php_gd_error_ex(E_ERROR, "gd-jpeg: EXTREMELY fatal error: jmpbuf" " unrecoverable; terminating\n"); } - fflush (stderr); exit (99); } @@ -170,7 +168,7 @@ * sizeof (JSAMPLE)); if (row == 0) { - fprintf (stderr, "gd-jpeg: error: unable to allocate JPEG row " + php_gd_error("gd-jpeg: error: unable to allocate JPEG row " "structure: gdCalloc returns NULL\n"); jpeg_destroy_compress (&cinfo); return; @@ -192,7 +190,7 @@ if (im->trueColor) { #if BITS_IN_JSAMPLE == 12 - fprintf (stderr, "gd-jpeg: error: jpeg library was compiled for 12-bit\n" + php_gd_error("gd-jpeg: error: jpeg library was compiled for 12-bit\n" "precision. This is mostly useless, because JPEGs on the web are\n" "8-bit and such versions of the jpeg library won't read or write\n" "them. GD doesn't support these unusual images. Edit your\n" @@ -212,7 +210,7 @@ nlines = jpeg_write_scanlines (&cinfo, rowptr, 1); if (nlines != 1) - fprintf (stderr, "gd_jpeg: warning: jpeg_write_scanlines" + php_gd_error_ex(E_WARNING, "gd_jpeg: warning: jpeg_write_scanlines" " returns %u -- expected 1\n", nlines); } } @@ -244,7 +242,7 @@ nlines = jpeg_write_scanlines (&cinfo, rowptr, 1); if (nlines != 1) - fprintf (stderr, "gd_jpeg: warning: jpeg_write_scanlines" + php_gd_error_ex(E_WARNING, "gd_jpeg: warning: jpeg_write_scanlines" " returns %u -- expected 1\n", nlines); } } @@ -314,17 +312,17 @@ retval = jpeg_read_header (&cinfo, TRUE); if (retval != JPEG_HEADER_OK) - fprintf (stderr, "gd-jpeg: warning: jpeg_read_header returns" + php_gd_error_ex(E_WARNING, "gd-jpeg: warning: jpeg_read_header returns" " %d, expected %d\n", retval, JPEG_HEADER_OK); if (cinfo.image_height > INT_MAX) - fprintf (stderr, "gd-jpeg: warning: JPEG image height (%u) is" + php_gd_error_ex(E_WARNING, "gd-jpeg: warning: JPEG image height (%u) is" " greater than INT_MAX (%d) (and thus greater than" " gd can handle)", cinfo.image_height, INT_MAX); if (cinfo.image_width > INT_MAX) - fprintf (stderr, "gd-jpeg: warning: JPEG image width (%u) is" + php_gd_error_ex(E_WARNING, "gd-jpeg: warning: JPEG image width (%u) is" " greater than INT_MAX (%d) (and thus greater than" " gd can handle)\n", cinfo.image_width, INT_MAX); @@ -332,7 +330,7 @@ (int) cinfo.image_height); if (im == 0) { - fprintf (stderr, "gd-jpeg error: cannot allocate gdImage" + php_gd_error("gd-jpeg error: cannot allocate gdImage" " struct\n"); goto error; } @@ -344,7 +342,7 @@ cinfo.out_color_space = JCS_RGB; if (jpeg_start_decompress (&cinfo) != TRUE) - fprintf (stderr, "gd-jpeg: warning: jpeg_start_decompress" + php_gd_error("gd-jpeg: warning: jpeg_start_decompress" " reports suspended data source\n"); #ifdef JPEG_DEBUG @@ -409,14 +407,14 @@ #endif if (cinfo.output_components != 3) { - fprintf (stderr, "gd-jpeg: error: JPEG color quantization" + php_gd_error_ex(E_WARNING, "gd-jpeg: error: JPEG color quantization" " request resulted in output_components == %d" " (expected 3)\n", cinfo.output_components); goto error; } #if BITS_IN_JSAMPLE == 12 - fprintf (stderr, "gd-jpeg: error: jpeg library was compiled for 12-bit\n" + php_gd_error("gd-jpeg: error: jpeg library was compiled for 12-bit\n" "precision. This is mostly useless, because JPEGs on the web are\n" "8-bit and such versions of the jpeg library won't read or write\n" "them. GD doesn't support these unusual images. Edit your\n" @@ -428,7 +426,7 @@ row = gdCalloc (cinfo.output_width * 3, sizeof (JSAMPLE)); if (row == 0) { - fprintf (stderr, "gd-jpeg: error: unable to allocate row for" + php_gd_error("gd-jpeg: error: unable to allocate row for" " JPEG scanline: gdCalloc returns NULL\n"); goto error; } @@ -439,7 +437,7 @@ nrows = jpeg_read_scanlines (&cinfo, rowptr, 1); if (nrows != 1) { - fprintf (stderr, "gd-jpeg: error: jpeg_read_scanlines" + php_gd_error_ex(E_WARNING, "gd-jpeg: error: jpeg_read_scanlines" " returns %u, expected 1\n", nrows); goto error; } @@ -450,7 +448,7 @@ } if (jpeg_finish_decompress (&cinfo) != TRUE) - fprintf (stderr, "gd-jpeg: warning: jpeg_finish_decompress" + php_gd_error("gd-jpeg: warning: jpeg_finish_decompress" " reports suspended data source\n"); Index: php4/ext/gd/libgd/gd_png.c diff -u php4/ext/gd/libgd/gd_png.c:1.7 php4/ext/gd/libgd/gd_png.c:1.8 --- php4/ext/gd/libgd/gd_png.c:1.7 Thu Nov 28 17:48:19 2002 +++ php4/ext/gd/libgd/gd_png.c Sun Dec 1 06:43:54 2002 @@ -59,15 +59,12 @@ * regardless of whether _BSD_SOURCE or anything else has (or has not) * been defined. */ - fprintf (stderr, "gd-png: fatal libpng error: %s\n", msg); - fflush (stderr); + php_gd_error_ex(E_ERROR, "gd-png: fatal libpng error: %s\n", msg); jmpbuf_ptr = png_get_error_ptr (png_ptr); if (jmpbuf_ptr == NULL) { /* we are completely hosed now */ - fprintf (stderr, - "gd-png: EXTREMELY fatal error: jmpbuf unrecoverable; terminating.\n"); - fflush (stderr); + php_gd_error_ex(E_ERROR, "gd-png: EXTREMELY fatal error: jmpbuf unrecoverable; +terminating.\n"); exit (99); } @@ -148,14 +145,14 @@ #endif if (png_ptr == NULL) { - fprintf (stderr, "gd-png error: cannot allocate libpng main struct\n"); + php_gd_error("gd-png error: cannot allocate libpng main struct\n"); return NULL; } info_ptr = png_create_info_struct (png_ptr); if (info_ptr == NULL) { - fprintf (stderr, "gd-png error: cannot allocate libpng info struct\n"); + php_gd_error("gd-png error: cannot allocate libpng info struct\n"); png_destroy_read_struct (&png_ptr, NULL, NULL); return NULL; } @@ -169,7 +166,7 @@ #ifndef PNG_SETJMP_NOT_SUPPORTED if (setjmp (gdPngJmpbufStruct.jmpbuf)) { - fprintf (stderr, "gd-png error: setjmp returns error condition\n"); + php_gd_error("gd-png error: setjmp returns error condition\n"); png_destroy_read_struct (&png_ptr, &info_ptr, NULL); return NULL; } @@ -193,7 +190,7 @@ } if (im == NULL) { - fprintf (stderr, "gd-png error: cannot allocate gdImage struct\n"); + php_gd_error("gd-png error: cannot allocate gdImage struct\n"); png_destroy_read_struct (&png_ptr, &info_ptr, NULL); gdFree (image_data); gdFree (row_pointers); @@ -209,7 +206,7 @@ case PNG_COLOR_TYPE_PALETTE: png_get_PLTE (png_ptr, info_ptr, &palette, &num_palette); #ifdef DEBUG - fprintf (stderr, "gd-png color_type is palette, colors: %d\n", + php_gd_error("gd-png color_type is palette, colors: %d\n", num_palette); #endif /* DEBUG */ if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) @@ -238,7 +235,7 @@ /* create a fake palette and check for single-shade transparency */ if ((palette = (png_colorp) gdMalloc (256 * sizeof (png_color))) == NULL) { - fprintf (stderr, "gd-png error: cannot allocate gray palette\n"); + php_gd_error("gd-png error: cannot allocate gray palette\n"); png_destroy_read_struct (&png_ptr, &info_ptr, NULL); return NULL; } @@ -306,13 +303,13 @@ rowbytes = png_get_rowbytes (png_ptr, info_ptr); if ((image_data = (png_bytep) gdMalloc (rowbytes * height)) == NULL) { - fprintf (stderr, "gd-png error: cannot allocate image data\n"); + php_gd_error("gd-png error: cannot allocate image data\n"); png_destroy_read_struct (&png_ptr, &info_ptr, NULL); return NULL; } if ((row_pointers = (png_bytepp) gdMalloc (height * sizeof (png_bytep))) == NULL) { - fprintf (stderr, "gd-png error: cannot allocate row pointers\n"); + php_gd_error("gd-png error: cannot allocate row pointers\n"); png_destroy_read_struct (&png_ptr, &info_ptr, NULL); gdFree (image_data); return NULL; @@ -401,7 +398,7 @@ { if (!open[i]) { - fprintf (stderr, "gd-png warning: image data references out-of-range" + php_gd_error("gd-png warning: image data references out-of-range" " color index (%d)\n", i); } } @@ -466,14 +463,14 @@ #endif if (png_ptr == NULL) { - fprintf (stderr, "gd-png error: cannot allocate libpng main struct\n"); + php_gd_error("gd-png error: cannot allocate libpng main struct\n"); return; } info_ptr = png_create_info_struct (png_ptr); if (info_ptr == NULL) { - fprintf (stderr, "gd-png error: cannot allocate libpng info struct\n"); + php_gd_error("gd-png error: cannot allocate libpng info struct\n"); png_destroy_write_struct (&png_ptr, (png_infopp) NULL); return; } @@ -481,7 +478,7 @@ #ifndef PNG_SETJMP_NOT_SUPPORTED if (setjmp (gdPngJmpbufStruct.jmpbuf)) { - fprintf (stderr, "gd-png error: setjmp returns error condition\n"); + php_gd_error("gd-png error: setjmp returns error condition\n"); png_destroy_write_struct (&png_ptr, &info_ptr); return; } @@ -672,14 +669,14 @@ row_pointers = gdMalloc (sizeof (png_bytep) * height); if (row_pointers == NULL) { - fprintf (stderr, "gd-png error: unable to allocate row_pointers\n"); + php_gd_error("gd-png error: unable to allocate row_pointers\n"); } for (j = 0; j < height; ++j) { int bo = 0; if ((row_pointers[j] = (png_bytep) gdMalloc (width * channels)) == NULL) { - fprintf (stderr, "gd-png error: unable to allocate rows\n"); + php_gd_error("gd-png error: unable to allocate rows\n"); for (i = 0; i < j; ++i) gdFree (row_pointers[i]); return; @@ -719,13 +716,13 @@ row_pointers = gdMalloc (sizeof (png_bytep) * height); if (row_pointers == NULL) { - fprintf (stderr, "gd-png error: unable to allocate row_pointers\n"); + php_gd_error("gd-png error: unable to allocate row_pointers\n"); } for (j = 0; j < height; ++j) { if ((row_pointers[j] = (png_bytep) gdMalloc (width)) == NULL) { - fprintf (stderr, "gd-png error: unable to allocate rows\n"); + php_gd_error("gd-png error: unable to allocate rows\n"); for (i = 0; i < j; ++i) gdFree (row_pointers[i]); return; Index: php4/ext/gd/libgd/gd_ss.c diff -u php4/ext/gd/libgd/gd_ss.c:1.2 php4/ext/gd/libgd/gd_ss.c:1.3 --- php4/ext/gd/libgd/gd_ss.c:1.2 Tue Oct 29 18:08:01 2002 +++ php4/ext/gd/libgd/gd_ss.c Sun Dec 1 06:43:54 2002 @@ -41,12 +41,12 @@ void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink) { - fprintf(stderr,"PNG support is not available\n"); + php_gd_error("PNG support is not available\n"); } gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource) { - fprintf(stderr,"PNG support is not available\n"); + php_gd_error("PNG support is not available\n"); return NULL; } #endif /* HAVE_LIBPNG */ Index: php4/ext/gd/libgd/gd_wbmp.c diff -u php4/ext/gd/libgd/gd_wbmp.c:1.4 php4/ext/gd/libgd/gd_wbmp.c:1.5 --- php4/ext/gd/libgd/gd_wbmp.c:1.4 Sun Nov 24 20:51:53 2002 +++ php4/ext/gd/libgd/gd_wbmp.c Sun Dec 1 06:43:54 2002 @@ -105,7 +105,7 @@ /* create the WBMP */ if ((wbmp = createwbmp (gdImageSX (image), gdImageSY (image), WBMP_WHITE)) == NULL) - fprintf (stderr, "Could not create WBMP\n"); + php_gd_error("Could not create WBMP\n"); /* fill up the WBMP structure */ pos = 0; @@ -123,7 +123,7 @@ /* write the WBMP to a gd file descriptor */ if (writewbmp (wbmp, &gd_putout, out)) - fprintf (stderr, "Could not save WBMP\n"); + php_gd_error("Could not save WBMP\n"); /* des submitted this bugfix: gdFree the memory. */ freewbmp (wbmp); } Index: php4/ext/gd/libgd/gdkanji.c diff -u php4/ext/gd/libgd/gdkanji.c:1.2 php4/ext/gd/libgd/gdkanji.c:1.3 --- php4/ext/gd/libgd/gdkanji.c:1.2 Tue Oct 29 18:08:01 2002 +++ php4/ext/gd/libgd/gdkanji.c Sun Dec 1 06:43:54 2002 @@ -72,13 +72,15 @@ static void error (const char *format,...) { - va_list args; - - va_start (args, format); - fprintf (stderr, "%s: ", LIBNAME); - vfprintf (stderr, format, args); - fprintf (stderr, "\n"); - va_end (args); + va_list args; + char *tmp; + TSRMLS_FETCH(); + + va_start(args, format); + vspprintf(&tmp, 0, format, args); + va_end(args); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: %s", LIBNAME, tmp); + efree(tmp); } /* DetectKanjiCode() derived from DetectCodeType() by Ken Lunde. */ Index: php4/ext/gd/libgd/gdxpm.c diff -u php4/ext/gd/libgd/gdxpm.c:1.3 php4/ext/gd/libgd/gdxpm.c:1.4 --- php4/ext/gd/libgd/gdxpm.c:1.3 Sun Nov 24 20:51:53 2002 +++ php4/ext/gd/libgd/gdxpm.c Sun Dec 1 06:43:54 2002 @@ -115,7 +115,7 @@ colors[i] = gdImageColorResolve (im, red, green, blue); if (colors[i] == -1) - fprintf (stderr, "ARRRGH\n"); + php_gd_error("ARRRGH\n"); } apixel = (char *) gdMalloc (image.cpp + 1);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php