]> granicus.if.org Git - imagemagick/blobdiff - coders/url.c
(no commit message)
[imagemagick] / coders / url.c
index 30919e43dccdf2e7ea5775601472f40248fdccd4..19dbd73bdceeb5fbda4889cbe4036eb72139dc64 100644 (file)
@@ -18,7 +18,7 @@
 %                                March 2000                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
 /*
   Include declarations.
 */
-#include "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/constitute.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/resource_.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/utility.h"
 #if defined(MAGICKCORE_XML_DELEGATE)
-#  if defined(__WINDOWS__)
-#    if defined(__MINGW32__)
+#  if defined(MAGICKCORE_WINDOWS_SUPPORT)
+#    if defined(__MINGW32__) || defined(__MINGW64__)
 #      define _MSC_VER
 #    else
 #      include <win32config.h>
@@ -116,6 +117,7 @@ static void GetFTPData(void *userdata,const char *data,int size)
   if (size <= 0)
     return;
   length=fwrite(data,size,1,file);
+  (void) length;
 }
 #endif
 
@@ -210,6 +212,7 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
           while ((bytes=xmlNanoHTTPRead(context,buffer,MaxBufferExtent)) > 0)
             count=(ssize_t) fwrite(buffer,bytes,1,file);
+          (void) count;
           xmlNanoHTTPClose(context);
           xmlFree(type);
           xmlNanoHTTPCleanup();
@@ -217,14 +220,35 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
     }
 #endif
   (void) fclose(file);
-  *read_info->magick='\0';
+  {
+    ExceptionInfo
+      *sans;
+
+    ImageInfo
+      *clone_info;
+
+    /*
+      Guess image format from URL.
+    */
+    clone_info=CloneImageInfo(image_info);
+    sans=AcquireExceptionInfo();
+    (void) SetImageInfo(clone_info,0,sans);
+    (void) CopyMagickString(read_info->magick,clone_info->magick,MaxTextExtent);
+    clone_info=DestroyImageInfo(clone_info);
+    sans=DestroyExceptionInfo(sans);
+  }
   image=ReadImage(read_info,exception);
   if (unique_file != -1)
     (void) RelinquishUniqueFileResource(read_info->filename);
   read_info=DestroyImageInfo(read_info);
-  if (image == (Image *) NULL)
-    (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
-      "NoDataReturned","`%s'",filename);
+  if (image != (Image *) NULL)
+    GetPathComponent(image_info->filename,TailPath,image->filename);
+  else
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
+        "NoDataReturned","`%s'",filename);
+      return((Image *) NULL);
+    }
   return(GetFirstImageInList(image));
 }
 \f
@@ -248,10 +272,10 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
 %
 %  The format of the RegisterURLImage method is:
 %
-%      unsigned long RegisterURLImage(void)
+%      size_t RegisterURLImage(void)
 %
 */
-ModuleExport unsigned long RegisterURLImage(void)
+ModuleExport size_t RegisterURLImage(void)
 {
   MagickInfo
     *entry;