diff --git a/mapio.c b/mapio.c index 799aaec01b..a55653fdd3 100644 --- a/mapio.c +++ b/mapio.c @@ -553,11 +553,7 @@ typedef struct { gdIOCtx gd_io_ctx; #endif msIOContext *ms_io_ctx; -} msIO_gdIOCtx; - -#ifndef USE_GD -#define gdIOCtx void -#endif +} msIO_IOCtx; #ifdef USE_GD @@ -600,6 +596,7 @@ static int msIO_gd_putBuf( gdIOCtx *cbData, const void *data, int byteCount ) /* longer needed. */ /************************************************************************/ +#ifdef USE_GD gdIOCtx *msIO_getGDIOCtx( FILE *fp ) { @@ -609,15 +606,14 @@ gdIOCtx *msIO_getGDIOCtx( FILE *fp ) if( context == NULL ) return NULL; - merged_context = (msIO_gdIOCtx *) calloc(1,sizeof(msIO_gdIOCtx)); -#ifdef USE_GD + merged_context = (msIO_IOCtx *) calloc(1,sizeof(msIO_IOCtx)); merged_context->gd_io_ctx.putC = msIO_gd_putC; merged_context->gd_io_ctx.putBuf = msIO_gd_putBuf; -#endif merged_context->ms_io_ctx = context; return (gdIOCtx *) merged_context; } +#endif /* ==================================================================== */ /* ==================================================================== */ diff --git a/mapscript/php/image.c b/mapscript/php/image.c index 2c270a25cd..a9b8df7891 100644 --- a/mapscript/php/image.c +++ b/mapscript/php/image.c @@ -328,7 +328,7 @@ PHP_METHOD(imageObj, saveImage) php_write(iptr, size TSRMLS_CC); status = MS_SUCCESS; /* status = size; why should we return the size ?? */ - gdFree(iptr); + msFree(iptr); } RETURN_LONG(status); diff --git a/mapscript/python/pyextend.i b/mapscript/python/pyextend.i index f0aa4fec1b..2262ae7607 100644 --- a/mapscript/python/pyextend.i +++ b/mapscript/python/pyextend.i @@ -168,6 +168,7 @@ def fromstring(data, mappath=None): imageObj(PyObject *arg1=Py_None, PyObject *arg2=Py_None, PyObject *input_format=Py_None, PyObject *input_resolution=Py_None, PyObject *input_defresolution=Py_None) { +#ifdef FORCE_BROKEN_GD_CODE imageObj *image=NULL; outputFormatObj *format=NULL; int width; @@ -318,6 +319,10 @@ def fromstring(data, mappath=None): "imageObj()"); return NULL; } +#else + msSetError(MS_IMGERR, "imageObj() is severely broken and should not be used","imageObj()"); + return NULL; +#endif } /* ====================================================================== diff --git a/mapscript/python/pygdioctx/pygdioctx.c b/mapscript/python/pygdioctx/pygdioctx.c index 6b6e9ed70a..1206aa2b5e 100644 --- a/mapscript/python/pygdioctx/pygdioctx.c +++ b/mapscript/python/pygdioctx/pygdioctx.c @@ -47,6 +47,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ***************************************************************************/ +#ifdef USE_GD + #include "pygdioctx.h" int PyFileIfaceObj_IOCtx_GetC(gdIOCtx *ctx) @@ -161,3 +163,5 @@ imageObj *createImageObjFromPyFile(PyObject *file, const char *driver) } } +#endif + diff --git a/mapscript/python/pygdioctx/pygdioctx.h b/mapscript/python/pygdioctx/pygdioctx.h index 13da345454..1825ad3c38 100644 --- a/mapscript/python/pygdioctx/pygdioctx.h +++ b/mapscript/python/pygdioctx/pygdioctx.h @@ -47,6 +47,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ***************************************************************************/ +#ifdef USE_GD + #include #include #include @@ -74,3 +76,5 @@ struct PyFileIfaceObj_gdIOCtx * alloc_PyFileIfaceObj_IOCtx(PyObject *fileIfaceOb void free_PyFileIfaceObj_IOCtx(struct PyFileIfaceObj_gdIOCtx *pctx); imageObj *createImageObjFromPyFile(PyObject *file, const char *driver); +#endif + diff --git a/mapscript/swiginc/image.i b/mapscript/swiginc/image.i index ab8cdc359d..8dece883de 100644 --- a/mapscript/swiginc/image.i +++ b/mapscript/swiginc/image.i @@ -143,6 +143,7 @@ Tcl_Obj *saveToString() { +#ifdef FORCE_BROKEN_GD_CODE unsigned char *imgbytes; int size; Tcl_Obj *imgstring; @@ -210,6 +211,11 @@ gdFree(imgbytes); return imgstring; +#else /* force_gd_broken_code */ + msSetError(MS_MISCERR, "saveToString() is long deprecated and severley broken", "saveToString()", self->format->driver ); + return(MS_FAILURE); +#endif + } #endif diff --git a/mapserver.h b/mapserver.h index eb4d8dad7c..f601ec97ec 100644 --- a/mapserver.h +++ b/mapserver.h @@ -2266,6 +2266,8 @@ MS_DLL_EXPORT imageObj *msImageLoadGD( const char *filename ); MS_DLL_EXPORT imageObj *msImageLoadGDCtx( gdIOCtx *ctx, const char *driver ); MS_DLL_EXPORT int msGDSetup(); MS_DLL_EXPORT void msGDCleanup(int signal); +#else +//#define gdIOCtx void* #endif MS_DLL_EXPORT void msImageStartLayerIM(mapObj *map, layerObj *layer, imageObj *image); MS_DLL_EXPORT int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format);