From 853b77b21ea750b0223c659b86a3372b1729efc2 Mon Sep 17 00:00:00 2001 From: dirk Date: Sat, 21 Sep 2013 19:04:42 +0000 Subject: [PATCH] Added support for opening https files under windows. --- MagickCore/coder.c | 1 + coders/url.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/MagickCore/coder.c b/MagickCore/coder.c index f0d39a35b..9076f0aa7 100644 --- a/MagickCore/coder.c +++ b/MagickCore/coder.c @@ -134,6 +134,7 @@ static const CoderMapInfo { "H", "MAGICK" }, { "HTM", "HTML" }, { "HTTP", "URL" }, + { "HTTPS", "URL" }, { "ICB", "TGA" }, { "ICC", "META" }, { "ICM", "META" }, diff --git a/coders/url.c b/coders/url.c index abab35165..8873b5cb5 100644 --- a/coders/url.c +++ b/coders/url.c @@ -70,7 +70,11 @@ # include # include #endif - +#if defined(MAGICKCORE_WINDOWS_SUPPORT) && \ + !(defined(__MINGW32__) || defined(__MINGW64__)) +# include +#endif + /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % @@ -169,6 +173,18 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception) (void) CopyMagickString(read_info->filename,image_info->filename+2, MaxTextExtent); } +#if defined(MAGICKCORE_WINDOWS_SUPPORT) && \ + !(defined(__MINGW32__) || defined(__MINGW64__)) + (void) fclose(file); + if (URLDownloadToFile(NULL,filename,read_info->filename,NULL,NULL) != S_OK) + { + ThrowFileException(exception,FileOpenError,"UnableToOpenFile", + filename); + (void) RelinquishUniqueFileResource(read_info->filename); + read_info=DestroyImageInfo(read_info); + return((Image *) NULL); + } +#else #if defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_FTP_ENABLED) if (LocaleCompare(read_info->magick,"ftp") == 0) { @@ -217,6 +233,7 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception) } #endif (void) fclose(file); +#endif { ExceptionInfo *sans; @@ -278,15 +295,28 @@ ModuleExport size_t RegisterURLImage(void) *entry; entry=SetMagickInfo("HTTP"); -#if defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_HTTP_ENABLED) +#if (defined(MAGICKCORE_WINDOWS_SUPPORT) && \ + !(defined(__MINGW32__) || defined(__MINGW64__))) || \ + (defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_HTTP_ENABLED)) entry->decoder=(DecodeImageHandler *) ReadURLImage; #endif entry->description=ConstantString("Uniform Resource Locator (http://)"); entry->module=ConstantString("URL"); entry->stealth=MagickTrue; (void) RegisterMagickInfo(entry); + entry=SetMagickInfo("HTTPS"); +#if defined(MAGICKCORE_WINDOWS_SUPPORT) && \ + !(defined(__MINGW32__) || defined(__MINGW64__)) + entry->decoder=(DecodeImageHandler *) ReadURLImage; +#endif + entry->description=ConstantString("Uniform Resource Locator (https://)"); + entry->module=ConstantString("URL"); + entry->stealth=MagickTrue; + (void) RegisterMagickInfo(entry); entry=SetMagickInfo("FTP"); -#if defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_FTP_ENABLED) +#if (defined(MAGICKCORE_WINDOWS_SUPPORT) && \ + !(defined(__MINGW32__) || defined(__MINGW64__))) || \ + (defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_FTP_ENABLED)) entry->decoder=(DecodeImageHandler *) ReadURLImage; #endif entry->description=ConstantString("Uniform Resource Locator (ftp://)"); -- 2.40.0