--- ..\imagemagick.c Sun Dec 2 22:27:45 2001 +++ imagemagick.c Sun Feb 3 21:13:25 2002 @@ -6,21 +6,24 @@ #include "config.h" #endif -#ifdef HAVE_IMAGEMAGICK +#ifdef HAVE_IMAGEMAGICK #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "ext/standard/php_smart_str.h" #include "php_imagemagick.h" + +#define XS_VERSION 1 + + +#if PHP_API_VERSION > 20010119 +#define IMAGEMAGICK_NEWER_API 1 +#endif #include #include -#if PHP_API_VERSION < 20010119 -#error Incompatable API version, please upgrade php to version >= 4.0.6 -#endif - #define im_warning() MagickWarning(exception.severity, exception.reason, exception.description) #define IM_MAX_BUF_SIZE 8192 @@ -51,9 +54,9 @@ /* {{{ imagemagick_module_entry */ zend_module_entry imagemagick_module_entry = { -#ifdef STANDART_MODULE_HEADER - STANDARD_MODULE_HEADER, -#endif +#ifdef IMAGEMAGICK_NEWER_API + STANDARD_MODULE_HEADER, +#endif "imagemagick", imagemagick_functions, PHP_MINIT(imagemagick), @@ -61,9 +64,9 @@ NULL, NULL, PHP_MINFO(imagemagick), -#ifdef NO_VERSION_YET - NO_VERSION_YET, -#endif +#ifdef IMAGEMAGICK_NEWER_API + "0.6", +#endif STANDARD_MODULE_PROPERTIES }; /* }}} */ @@ -127,13 +130,14 @@ /* {{{ PHP_MINIT_FUNCTION */ -PHP_MINIT_FUNCTION(imagemagick) { +PHP_MINIT_FUNCTION(imagemagick) { /* If you have INI entries, uncomment these lines ZEND_INIT_MODULE_GLOBALS(imagemagick, php_imagemagick_init_globals, NULL); REGISTER_INI_ENTRIES(); */ - le_imagemagick = register_list_destructors(im_destroy_image, NULL); - InitializeMagick(im_client_name); + le_imagemagick = register_list_destructors(im_destroy_image, NULL); + + InitializeMagick(im_client_name); SetErrorHandler(im_error_handler); SetWarningHandler(im_warning_handler); @@ -150,7 +154,7 @@ MagickInfo *magick_info; register MagickInfo *p; - magick_info = GetMagickInfo(NULL, &exception); + magick_info = (MagickInfo*)GetMagickInfo(NULL, &exception); if (magick_info == (MagickInfo *) NULL) { im_warning(); @@ -192,7 +196,8 @@ zval **filename; Image *image; ImageInfo *image_info; - int argc = ZEND_NUM_ARGS(); + int argc = ZEND_NUM_ARGS(); + char realPath[MAXPATHLEN]; if(argc != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) ZEND_WRONG_PARAM_COUNT(); @@ -204,8 +209,10 @@ RETURN_FALSE; } - image_info = CloneImageInfo((ImageInfo *) NULL); - strcpy(image_info->filename, Z_STRVAL_PP(filename)); + image_info = CloneImageInfo((ImageInfo *) NULL); + + VCWD_REALPATH(Z_STRVAL_PP(filename), realPath); + strcpy(image_info->filename, realPath); errno = 0; image = ReadImage(image_info, &exception); @@ -253,7 +260,8 @@ Image *image; ImageInfo *image_info; int argc = ZEND_NUM_ARGS(); - unsigned int result; + unsigned int result; + char realPath[MAXPATHLEN]; switch (argc) { case 2 : @@ -279,8 +287,9 @@ php_error(E_WARNING, "Too long filename"); RETURN_FALSE; } - - strcpy(image->filename, Z_STRVAL_PP(filename)); + + VCWD_REALPATH(Z_STRVAL_PP(filename), realPath); + strcpy(image->filename, realPath); image_info = CloneImageInfo((ImageInfo *) NULL);