]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/constitute.c
(no commit message)
[imagemagick] / MagickCore / constitute.c
index 12cababd542f0b53f61459c131ab8ad4dec24281..cea98cae61d61e9498291b49ae2c9262daabd223 100644 (file)
 %                  MagickCore Methods to Consitute an Image                   %
 %                                                                             %
 %                             Software Design                                 %
-%                               John Cristy                                   %
+%                                  Cristy                                     %
 %                               October 1998                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 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 "MagickCore/utility.h"
 #include "MagickCore/utility-private.h"
 \f
-static SemaphoreInfo
-  *constitute_semaphore = (SemaphoreInfo *) NULL;
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                                                             %
-%                                                                             %
-%                                                                             %
-+   C o n s t i t u t e C o m p o n e n t G e n e s i s                       %
-%                                                                             %
-%                                                                             %
-%                                                                             %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-%  ConstituteComponentGenesis() instantiates the constitute component.
-%
-%  The format of the ConstituteComponentGenesis method is:
-%
-%      MagickBooleanType ConstituteComponentGenesis(void)
-%
-*/
-MagickPrivate MagickBooleanType ConstituteComponentGenesis(void)
-{
-  AcquireSemaphoreInfo(&constitute_semaphore);
-  return(MagickTrue);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                                                             %
-%                                                                             %
-%                                                                             %
-+   C o n s t i t u t e C o m p o n e n t T e r m i n u s                     %
-%                                                                             %
-%                                                                             %
-%                                                                             %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-%  ConstituteComponentTerminus() destroys the constitute component.
-%
-%  The format of the ConstituteComponentTerminus method is:
-%
-%      ConstituteComponentTerminus(void)
-%
-*/
-MagickPrivate void ConstituteComponentTerminus(void)
-{
-  if (constitute_semaphore == (SemaphoreInfo *) NULL)
-    AcquireSemaphoreInfo(&constitute_semaphore);
-  DestroySemaphoreInfo(&constitute_semaphore);
-}
-\f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -527,8 +475,6 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
       image=DestroyImage(image);
     }
   image=NewImageList();
-  if (constitute_semaphore == (SemaphoreInfo *) NULL)
-    AcquireSemaphoreInfo(&constitute_semaphore);
   if ((magick_info == (const MagickInfo *) NULL) ||
       (GetImageDecoder(magick_info) == (DecodeImageHandler *) NULL))
     {
@@ -545,10 +491,10 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
     {
       thread_support=GetMagickThreadSupport(magick_info);
       if ((thread_support & DecoderThreadSupport) == 0)
-        LockSemaphoreInfo(constitute_semaphore);
+        LockSemaphoreInfo(magick_info->semaphore);
       image=GetImageDecoder(magick_info)(read_info,exception);
       if ((thread_support & DecoderThreadSupport) == 0)
-        UnlockSemaphoreInfo(constitute_semaphore);
+        UnlockSemaphoreInfo(magick_info->semaphore);
     }
   else
     {
@@ -557,7 +503,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         {
           (void) ThrowMagickException(exception,GetMagickModule(),
             MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
-            read_info->filename);
+            read_info->magick);
           if (read_info->temporary != MagickFalse)
             (void) RelinquishUniqueFileResource(read_info->filename);
           read_info=DestroyImageInfo(read_info);
@@ -576,11 +522,11 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         MaxTextExtent);
       *read_info->filename='\0';
       if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
-        LockSemaphoreInfo(constitute_semaphore);
+        LockSemaphoreInfo(delegate_info->semaphore);
       (void) InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
         exception);
       if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
-        UnlockSemaphoreInfo(constitute_semaphore);
+        UnlockSemaphoreInfo(delegate_info->semaphore);
       image=DestroyImageList(image);
       read_info->temporary=MagickTrue;
       (void) SetImageInfo(read_info,0,exception);
@@ -591,7 +537,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
           if (IsPathAccessible(read_info->filename) != MagickFalse)
             (void) ThrowMagickException(exception,GetMagickModule(),
               MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
-              read_info->filename);
+              read_info->magick);
           else
             ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
               read_info->filename);
@@ -600,10 +546,10 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         }
       thread_support=GetMagickThreadSupport(magick_info);
       if ((thread_support & DecoderThreadSupport) == 0)
-        LockSemaphoreInfo(constitute_semaphore);
+        LockSemaphoreInfo(magick_info->semaphore);
       image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
       if ((thread_support & DecoderThreadSupport) == 0)
-        UnlockSemaphoreInfo(constitute_semaphore);
+        UnlockSemaphoreInfo(magick_info->semaphore);
     }
   if (read_info->temporary != MagickFalse)
     {
@@ -640,13 +586,8 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         }
     }
   if (GetBlobError(image) != MagickFalse)
-    {
-      ThrowFileException(exception,FileOpenError,
-        "AnErrorHasOccurredReadingFromFile",read_info->filename);
-      image=DestroyImageList(image);
-      read_info=DestroyImageInfo(read_info);
-      return((Image *) NULL);
-    }
+    ThrowFileException(exception,FileOpenError,
+      "AnErrorHasOccurredReadingFromFile",read_info->filename);
   for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
   {
     char
@@ -1146,8 +1087,6 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
           (void) CloseBlob(image);
         }
     }
-  if (constitute_semaphore == (SemaphoreInfo *) NULL)
-    AcquireSemaphoreInfo(&constitute_semaphore);
   if ((magick_info != (const MagickInfo *) NULL) &&
       (GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
     {
@@ -1156,10 +1095,10 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
       */
       thread_support=GetMagickThreadSupport(magick_info);
       if ((thread_support & EncoderThreadSupport) == 0)
-        LockSemaphoreInfo(constitute_semaphore);
+        LockSemaphoreInfo(magick_info->semaphore);
       status=GetImageEncoder(magick_info)(write_info,image,exception);
       if ((thread_support & EncoderThreadSupport) == 0)
-        UnlockSemaphoreInfo(constitute_semaphore);
+        UnlockSemaphoreInfo(magick_info->semaphore);
     }
   else
     {
@@ -1171,11 +1110,11 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
           */
           *write_info->filename='\0';
           if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
-            LockSemaphoreInfo(constitute_semaphore);
+            LockSemaphoreInfo(delegate_info->semaphore);
           status=InvokeDelegate(write_info,image,(char *) NULL,
             write_info->magick,exception);
           if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
-            UnlockSemaphoreInfo(constitute_semaphore);
+            UnlockSemaphoreInfo(delegate_info->semaphore);
           (void) CopyMagickString(image->filename,filename,MaxTextExtent);
         }
       else
@@ -1211,11 +1150,11 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
                   (GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
                 (void) ThrowMagickException(exception,GetMagickModule(),
                   MissingDelegateError,"NoEncodeDelegateForThisImageFormat",
-                  "`%s'",image->filename);
+                  "`%s'",write_info->magick);
               else
                 (void) ThrowMagickException(exception,GetMagickModule(),
                   MissingDelegateWarning,"NoEncodeDelegateForThisImageFormat",
-                  "`%s'",image->filename);
+                  "`%s'",write_info->magick);
             }
           if ((magick_info != (const MagickInfo *) NULL) &&
               (GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
@@ -1225,17 +1164,17 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
               */
               thread_support=GetMagickThreadSupport(magick_info);
               if ((thread_support & EncoderThreadSupport) == 0)
-                LockSemaphoreInfo(constitute_semaphore);
+                LockSemaphoreInfo(magick_info->semaphore);
               status=GetImageEncoder(magick_info)(write_info,image,exception);
               if ((thread_support & EncoderThreadSupport) == 0)
-                UnlockSemaphoreInfo(constitute_semaphore);
+                UnlockSemaphoreInfo(magick_info->semaphore);
             }
         }
     }
   if (GetBlobError(image) != MagickFalse)
     ThrowFileException(exception,FileOpenError,
       "AnErrorHasOccurredWritingToFile",image->filename);
-  if (temporary == MagickTrue)
+  if (temporary != MagickFalse)
     {
       /*
         Copy temporary image file to permanent.