exception.c revision f135cd6da2ad8e3998222124b0a36ecaef8386c8
13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        EEEEE  X   X   CCCC  EEEEE  PPPP  TTTTT  IIIII   OOO   N   N         %
73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        E       X X   C      E      P   P   T      I    O   O  NN  N         %
83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        EEE      X    C      EEE    PPPP    T      I    O   O  N N N         %
93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        E       X X   C      E      P       T      I    O   O  N  NN         %
103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        EEEEE   X  X   CCCC  EEEEE  P       T    IIIII   OOO   N   N         %
113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                        MagickCore Exception Methods                         %
143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                             Software Design                                 %
16de984cdc3631106b1cbbb8d3972b76a0fc27e8e8cristy%                                  Cristy                                     %
173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                July 1993                                    %
183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
20fe676ee3a9cf43404bdc9ba8b27f597b5e4e28f7cristy%  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization      %
213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  dedicated to making software imaging solutions freely available.           %
223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  You may not use this file except in compliance with the License.  You may  %
243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  obtain a copy of the License at                                            %
253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    http://www.imagemagick.org/script/license.php                            %
273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  Unless required by applicable law or agreed to in writing, software        %
293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  distributed under the License is distributed on an "AS IS" BASIS,          %
303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  See the License for the specific language governing permissions and        %
323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  limitations under the License.                                             %
333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Include declarations.
423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
434c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/studio.h"
444c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/client.h"
454c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception.h"
464c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception-private.h"
474c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/hashmap.h"
484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/locale_.h"
494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/log.h"
504c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magick.h"
514c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/memory_.h"
524c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/string_.h"
534c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/utility.h"
54d1dd6e4fefa0810b9893e6ac9418f79c97c1b39acristy#include "MagickCore/utility-private.h"
553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Forward declarations.
583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus)
603ed852eea50f9d4cd633efb8c2b054b8e33c253cristyextern "C" {
613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
633ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void
643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DefaultErrorHandler(const ExceptionType,const char *,const char *),
653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DefaultFatalErrorHandler(const ExceptionType,const char *,const char *),
663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DefaultWarningHandler(const ExceptionType,const char *,const char *);
673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus)
693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Global declarations.
743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
753ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic ErrorHandler
763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  error_handler = DefaultErrorHandler;
773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
783ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic FatalErrorHandler
793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  fatal_error_handler = DefaultFatalErrorHandler;
803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
813ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic WarningHandler
823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  warning_handler = DefaultWarningHandler;
833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   A c q u i r e E x c e p t i o n I n f o                                   %
903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  AcquireExceptionInfo() allocates the ExceptionInfo structure.
963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the AcquireExceptionInfo method is:
983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      ExceptionInfo *AcquireExceptionInfo(void)
1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport ExceptionInfo *AcquireExceptionInfo(void)
1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ExceptionInfo
1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *exception;
1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10773bd4a51b419e914565bdf204bf1540dc4c8ee26cristy  exception=(ExceptionInfo *) AcquireMagickMemory(sizeof(*exception));
1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (exception == (ExceptionInfo *) NULL)
1093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  GetExceptionInfo(exception);
1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->relinquish=MagickTrue;
1123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(exception);
1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   C l e a r M a g i c k E x c e p t i o n                                   %
1213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ClearMagickException() clears any exception that may not have been caught
1273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  yet.
1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ClearMagickException method is:
1303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      ClearMagickException(ExceptionInfo *exception)
1323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
1363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1393ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void *DestroyExceptionElement(void *exception)
1403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  register ExceptionInfo
1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *p;
1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p=(ExceptionInfo *) exception;
1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (p->reason != (char *) NULL)
1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    p->reason=DestroyString(p->reason);
1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (p->description != (char *) NULL)
1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    p->description=DestroyString(p->description);
1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p=(ExceptionInfo *) RelinquishMagickMemory(p);
1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return((void *) NULL);
1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void ClearMagickException(ExceptionInfo *exception)
1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception->signature == MagickSignature);
1573efeece86a747d7cd4bc18ddb09791a2f5aee0addirk  if (exception->exceptions == (void *) NULL)
1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return;
159f84a193d5f435588cd78d521fff3f1f852e227f8cristy  LockSemaphoreInfo(exception->semaphore);
1603efeece86a747d7cd4bc18ddb09791a2f5aee0addirk  ClearLinkedList((LinkedListInfo *) exception->exceptions,
161f135cd6da2ad8e3998222124b0a36ecaef8386c8cristy    DestroyExceptionElement);
1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->severity=UndefinedException;
1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->reason=(char *) NULL;
1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->description=(char *) NULL;
165f84a193d5f435588cd78d521fff3f1f852e227f8cristy  UnlockSemaphoreInfo(exception->semaphore);
1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  errno=0;
1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   C a t c h E x c e p t i o n                                               %
1753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  CatchException() returns if no exceptions is found otherwise it reports
1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  the exception as a warning, error, or fatal depending on the severity.
1823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the CatchException method is:
1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      CatchException(ExceptionInfo *exception)
1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
1883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1923ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void CatchException(ExceptionInfo *exception)
1933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  register const ExceptionInfo
1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *p;
1963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception->signature == MagickSignature);
1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (exception->exceptions  == (void *) NULL)
2003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return;
201f84a193d5f435588cd78d521fff3f1f852e227f8cristy  LockSemaphoreInfo(exception->semaphore);
2023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ResetLinkedListIterator((LinkedListInfo *) exception->exceptions);
2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
2043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    exception->exceptions);
2053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  while (p != (const ExceptionInfo *) NULL)
2063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if ((p->severity >= WarningException) && (p->severity < ErrorException))
2083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      MagickWarning(p->severity,p->reason,p->description);
2093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if ((p->severity >= ErrorException) && (p->severity < FatalErrorException))
2103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      MagickError(p->severity,p->reason,p->description);
21132cca407db0c7f1812b1809773513370b5813309cristy    if (p->severity >= FatalErrorException)
2123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      MagickFatalError(p->severity,p->reason,p->description);
2133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
2143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      exception->exceptions);
2153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
216f84a193d5f435588cd78d521fff3f1f852e227f8cristy  UnlockSemaphoreInfo(exception->semaphore);
2173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ClearMagickException(exception);
2183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
2193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
2213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
222c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%                                                                             %
223c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%                                                                             %
224c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%                                                                             %
225c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%   C l o n e E x c e p t i o n I n f o                                       %
226c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%                                                                             %
227c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%                                                                             %
228c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%                                                                             %
229c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%
231c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%  CloneExceptionInfo() clones the ExceptionInfo structure.
232c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%
233c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%  The format of the CloneExceptionInfo method is:
234c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%
235c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%      ExceptionInfo *CloneException(ExceptionInfo *exception)
236c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%
237c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%  A description of each parameter follows:
238c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%
239c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%    o exception: the exception info.
240c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%
241c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy*/
242c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristyMagickExport ExceptionInfo *CloneExceptionInfo(ExceptionInfo *exception)
243c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy{
244c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy  ExceptionInfo
245c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy    *clone_exception;
246c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy
247c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy  clone_exception=(ExceptionInfo *) AcquireMagickMemory(sizeof(*exception));
248c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy  if (clone_exception == (ExceptionInfo *) NULL)
249c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
250c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy  GetExceptionInfo(clone_exception);
251c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy  InheritException(clone_exception,exception);
2524592b2c7a40c37efd17aaa688be0d18fe953bd8fcristy  clone_exception->relinquish=MagickTrue;
253a0dfced3583f9d765af3ee2b45158baec0f6a2a4cristy  return(clone_exception);
254c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy}
255c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy
256c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy/*
257c82a27bb8e3138ff9bbf0f696663bdf3e704cedecristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+   D e f a u l t E r r o r H a n d l e r                                     %
2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  DefaultErrorHandler() displays an error reason.
2683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the DefaultErrorHandler method is:
2703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      void MagickError(const ExceptionType severity,const char *reason,
2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *description)
2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o severity: Specifies the numeric error category.
2773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reason: Specifies the reason to display before terminating the
2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      program.
2803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: Specifies any description to the reason.
2823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
2843ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void DefaultErrorHandler(const ExceptionType magick_unused(severity),
2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *reason,const char *description)
2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (reason == (char *) NULL)
2883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return;
289b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stderr,"%s: %s",GetClientName(),reason);
2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (description != (char *) NULL)
291b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stderr," (%s)",description);
292b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stderr,".\n");
2933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) fflush(stderr);
2943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
2953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
2973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+   D e f a u l t F a t a l E r r o r H a n d l e r                           %
3023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  DefaultFatalErrorHandler() displays an error reason and then terminates the
3083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program.
3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the DefaultFatalErrorHandler method is:
3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      void MagickFatalError(const ExceptionType severity,const char *reason,
3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *description)
3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
3163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o severity: Specifies the numeric error category.
3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
319b200b6c973701dcc4e43539e1da620fc25aa2c29cristy%    o reason: Specifies the reason to display before terminating the program.
3203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: Specifies any description to the reason.
3223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
324b200b6c973701dcc4e43539e1da620fc25aa2c29cristystatic void DefaultFatalErrorHandler(const ExceptionType severity,
3253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *reason,const char *description)
3263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
3273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (reason == (char *) NULL)
3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return;
329b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stderr,"%s: %s",GetClientName(),reason);
3303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (description != (char *) NULL)
331b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stderr," (%s)",description);
332b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stderr,".\n");
3333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) fflush(stderr);
3343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickCoreTerminus();
335b4d552cbf0187d092fc9f83fdca1ef6ce90206fbcristy  exit((int) (severity-FatalErrorException)+1);
3363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
3373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+   D e f a u l t W a r n i n g H a n d l e r                                 %
3443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  DefaultWarningHandler() displays a warning reason.
3503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the DefaultWarningHandler method is:
3523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3533b743bb1b7243007b41c2d143bd529c884069efccristy%      void DefaultWarningHandler(const ExceptionType severity,
3543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reason,const char *description)
3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3583b743bb1b7243007b41c2d143bd529c884069efccristy%    o severity: Specifies the numeric warning category.
3593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reason: Specifies the reason to display before terminating the
3613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      program.
3623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: Specifies any description to the reason.
3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
3663ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void DefaultWarningHandler(const ExceptionType magick_unused(severity),
3673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *reason,const char *description)
3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (reason == (char *) NULL)
3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return;
371b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stderr,"%s: %s",GetClientName(),reason);
3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (description != (char *) NULL)
373b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stderr," (%s)",description);
374b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stderr,".\n");
3753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) fflush(stderr);
3763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
3773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
3793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   D e s t r o y E x c e p t i o n I n f o                                   %
3843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  DestroyExceptionInfo() deallocates memory associated with an exception.
3903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the DestroyExceptionInfo method is:
3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception)
3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
3963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
3983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception)
4013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
4023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    relinquish;
4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception->signature == MagickSignature);
40778883b2620bba1a3572967ae6e04bcd5f42339d6cristy  if (exception->semaphore == (SemaphoreInfo *) NULL)
40804b11db5504ecdf205114ae7e9e68774a1ff0b9bcristy    ActivateSemaphoreInfo(&exception->semaphore);
409f84a193d5f435588cd78d521fff3f1f852e227f8cristy  LockSemaphoreInfo(exception->semaphore);
4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->severity=UndefinedException;
4113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (exception->relinquish != MagickFalse)
412cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk    {
413cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk      exception->signature=(~MagickSignature);
414cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk      if (exception->exceptions != (void *) NULL)
415cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk        exception->exceptions=(void *) DestroyLinkedList((LinkedListInfo *)
416cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk          exception->exceptions,DestroyExceptionElement);
417cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk    }
418cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk  else if (exception->exceptions != (void *) NULL)
419cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk    ClearLinkedList((LinkedListInfo *) exception->exceptions,
420cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk      DestroyExceptionElement);
421cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk  relinquish=exception->relinquish;
422f84a193d5f435588cd78d521fff3f1f852e227f8cristy  UnlockSemaphoreInfo(exception->semaphore);
4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (relinquish != MagickFalse)
424cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk    {
425cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk      RelinquishSemaphoreInfo(&exception->semaphore);
426cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk      exception=(ExceptionInfo *) RelinquishMagickMemory(exception);
427cee811c0c5eb1f4f2f83453439e380c83e12ed1bdirk    }
4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(exception);
4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   G e t E x c e p t i o n I n f o                                           %
4373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  GetExceptionInfo() initializes an exception to default values.
4433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the GetExceptionInfo method is:
4453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      GetExceptionInfo(ExceptionInfo *exception)
4473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
4493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
4513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
4533ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void GetExceptionInfo(ExceptionInfo *exception)
4543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
4553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
4563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) ResetMagickMemory(exception,0,sizeof(*exception));
4573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->severity=UndefinedException;
4583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->exceptions=(void *) NewLinkedList(0);
4593d162a93f537cb7cbb6d9fa3b8e73e8f992a527acristy  exception->semaphore=AcquireSemaphoreInfo();
4603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception->signature=MagickSignature;
4613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
4623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
4643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   G e t E x c e p t i o n M e s s a g e                                     %
4693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  GetExceptionMessage() returns the error message defined by the specified
4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  error code.
4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the GetExceptionMessage method is:
4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      char *GetExceptionMessage(const int error)
4803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o error: the error code.
4843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
4863ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *GetExceptionMessage(const int error)
4873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    exception[MaxTextExtent];
4903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
491b56416944f1a142ac6fc387f125cbd3bf00ccd65cristy  *exception='\0';
4923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_STRERROR_R)
4937d4a1d61307140a43a65a85587eb9ee09a00d1bfcristy#if !defined(MAGICKCORE_STRERROR_R_CHAR_P)
4943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) strerror_r(error,exception,sizeof(exception));
4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else
496866a02f04bdc706d86be55b1182f9ac4c48ce03bcristy  (void) CopyMagickString(exception,strerror_r(error,exception,
497866a02f04bdc706d86be55b1182f9ac4c48ce03bcristy    sizeof(exception)),sizeof(exception));
498866a02f04bdc706d86be55b1182f9ac4c48ce03bcristy#endif
499866a02f04bdc706d86be55b1182f9ac4c48ce03bcristy#else
5003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) CopyMagickString(exception,strerror(error),sizeof(exception));
5013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
5023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(ConstantString(exception));
5033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
5043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
5053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
5063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
5083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
5093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
5103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   G e t L o c a l e E x c e p t i o n M e s s a g e                         %
5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
5143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  GetLocaleExceptionMessage() converts a enumerated exception severity and tag
5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  to a message in the current locale.
5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the GetLocaleExceptionMessage method is:
5203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      const char *GetLocaleExceptionMessage(const ExceptionType severity,
5223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *tag)
5233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
5253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o severity: the severity of the exception.
5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o tag: the message tag.
5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
5303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
5313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
5323ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic const char *ExceptionSeverityToTag(const ExceptionType severity)
5333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
5343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  switch (severity)
5353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
5363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ResourceLimitWarning: return("Resource/Limit/Warning/");
5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case TypeWarning: return("Type/Warning/");
5383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case OptionWarning: return("Option/Warning/");
5393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case DelegateWarning: return("Delegate/Warning/");
5403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case MissingDelegateWarning: return("Missing/Delegate/Warning/");
5413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CorruptImageWarning: return("Corrupt/Image/Warning/");
5423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case FileOpenWarning: return("File/Open/Warning/");
5433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case BlobWarning: return("Blob/Warning/");
5443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case StreamWarning: return("Stream/Warning/");
5453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CacheWarning: return("Cache/Warning/");
5463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CoderWarning: return("Coder/Warning/");
547992729daaa55bb5c0c49f54cc525f992e09ccae3cristy    case FilterWarning: return("Filter/Warning/");
5483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ModuleWarning: return("Module/Warning/");
5493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case DrawWarning: return("Draw/Warning/");
5503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ImageWarning: return("Image/Warning/");
5513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case WandWarning: return("Wand/Warning/");
5523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case XServerWarning: return("XServer/Warning/");
5533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case MonitorWarning: return("Monitor/Warning/");
5543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case RegistryWarning: return("Registry/Warning/");
5553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ConfigureWarning: return("Configure/Warning/");
5563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case PolicyWarning: return("Policy/Warning/");
5573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ResourceLimitError: return("Resource/Limit/Error/");
5583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case TypeError: return("Type/Error/");
5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case OptionError: return("Option/Error/");
5603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case DelegateError: return("Delegate/Error/");
5613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case MissingDelegateError: return("Missing/Delegate/Error/");
5623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CorruptImageError: return("Corrupt/Image/Error/");
5633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case FileOpenError: return("File/Open/Error/");
5643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case BlobError: return("Blob/Error/");
5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case StreamError: return("Stream/Error/");
5663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CacheError: return("Cache/Error/");
5673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CoderError: return("Coder/Error/");
568992729daaa55bb5c0c49f54cc525f992e09ccae3cristy    case FilterError: return("Filter/Error/");
5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ModuleError: return("Module/Error/");
5703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case DrawError: return("Draw/Error/");
5713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ImageError: return("Image/Error/");
5723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case WandError: return("Wand/Error/");
5733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case XServerError: return("XServer/Error/");
5743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case MonitorError: return("Monitor/Error/");
5753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case RegistryError: return("Registry/Error/");
5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ConfigureError: return("Configure/Error/");
5773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case PolicyError: return("Policy/Error/");
5783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ResourceLimitFatalError: return("Resource/Limit/FatalError/");
5793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case TypeFatalError: return("Type/FatalError/");
5803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case OptionFatalError: return("Option/FatalError/");
5813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case DelegateFatalError: return("Delegate/FatalError/");
5823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case MissingDelegateFatalError: return("Missing/Delegate/FatalError/");
5833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CorruptImageFatalError: return("Corrupt/Image/FatalError/");
5843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case FileOpenFatalError: return("File/Open/FatalError/");
5853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case BlobFatalError: return("Blob/FatalError/");
5863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case StreamFatalError: return("Stream/FatalError/");
5873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CacheFatalError: return("Cache/FatalError/");
5883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case CoderFatalError: return("Coder/FatalError/");
589992729daaa55bb5c0c49f54cc525f992e09ccae3cristy    case FilterFatalError: return("Filter/FatalError/");
5903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ModuleFatalError: return("Module/FatalError/");
5913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case DrawFatalError: return("Draw/FatalError/");
5923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ImageFatalError: return("Image/FatalError/");
5933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case WandFatalError: return("Wand/FatalError/");
5943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case XServerFatalError: return("XServer/FatalError/");
5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case MonitorFatalError: return("Monitor/FatalError/");
5963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case RegistryFatalError: return("Registry/FatalError/");
5973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case ConfigureFatalError: return("Configure/FatalError/");
5983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    case PolicyFatalError: return("Policy/FatalError/");
5993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    default: break;
6003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
6013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return("");
6023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
6033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6043ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport const char *GetLocaleExceptionMessage(const ExceptionType severity,
6053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *tag)
6063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
6073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
6083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    message[MaxTextExtent];
6093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char
6113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *locale_message;
6123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(tag != (const char *) NULL);
614b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleString(message,MaxTextExtent,"Exception/%s%s",
6153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ExceptionSeverityToTag(severity),tag);
6163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  locale_message=GetLocaleMessage(message);
6173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (locale_message == (const char *) NULL)
6183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return(tag);
6193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (locale_message == message)
6203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return(tag);
6213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(locale_message);
6223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
6233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
6253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   I n h e r i t E x c e p t i o n                                           %
6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  InheritException() inherits an exception from a related exception.
6363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the InheritException method is:
6383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      InheritException(ExceptionInfo *exception,const ExceptionInfo *relative)
6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o relative: the related exception info.
6463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
6483ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void InheritException(ExceptionInfo *exception,
6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const ExceptionInfo *relative)
6503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
6513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  register const ExceptionInfo
6523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *p;
6533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
6553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception->signature == MagickSignature);
6563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(relative != (ExceptionInfo *) NULL);
6573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(relative->signature == MagickSignature);
6583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (relative->exceptions == (void *) NULL)
6593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    return;
66093670403847955b4bb6a820d62d1ac2c689fe84dcristy  LockSemaphoreInfo(relative->semaphore);
6613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ResetLinkedListIterator((LinkedListInfo *) relative->exceptions);
6623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
6633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    relative->exceptions);
6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  while (p != (const ExceptionInfo *) NULL)
6653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
6663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (void) ThrowException(exception,p->severity,p->reason,p->description);
6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
6683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      relative->exceptions);
6693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
67093670403847955b4bb6a820d62d1ac2c689fe84dcristy  UnlockSemaphoreInfo(relative->semaphore);
6713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
6723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   M a g i c k E r r o r                                                     %
6793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  MagickError() calls the exception handler methods with an error reason.
6853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the MagickError method is:
6873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      void MagickError(const ExceptionType error,const char *reason,
6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *description)
6903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
6923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: Specifies the numeric error category.
6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reason: Specifies the reason to display before terminating the
6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      program.
6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
6983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: Specifies any description to the reason.
6993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
7013ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void MagickError(const ExceptionType error,const char *reason,
7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *description)
7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (error_handler != (ErrorHandler) NULL)
7053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (*error_handler)(error,reason,description);
7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
7093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   M a g i c k F a t al E r r o r                                            %
7143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  MagickFatalError() calls the fatal exception handler methods with an error
7203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  reason.
7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the MagickError method is:
7233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      void MagickFatalError(const ExceptionType error,const char *reason,
7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *description)
7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
7283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: Specifies the numeric error category.
7303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reason: Specifies the reason to display before terminating the
7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      program.
7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: Specifies any description to the reason.
7353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void MagickFatalError(const ExceptionType error,const char *reason,
7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *description)
7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (fatal_error_handler != (ErrorHandler) NULL)
7413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (*fatal_error_handler)(error,reason,description);
7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
7453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   M a g i c k W a r n i n g                                                 %
7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  MagickWarning() calls the warning handler methods with a warning reason.
7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the MagickWarning method is:
7583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      void MagickWarning(const ExceptionType warning,const char *reason,
7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *description)
7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
7633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o warning: the warning severity.
7653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reason: Define the reason for the warning.
7673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: Describe the warning.
7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
7713ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void MagickWarning(const ExceptionType warning,const char *reason,
7723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char *description)
7733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
7743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (warning_handler != (WarningHandler) NULL)
7753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (*warning_handler)(warning,reason,description);
7763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
7773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   S e t E r r o r H a n d l e r                                             %
7843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  SetErrorHandler() sets the exception handler to the specified method
7903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  and returns the previous exception handler.
7913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the SetErrorHandler method is:
7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      ErrorHandler SetErrorHandler(ErrorHandler handler)
7953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
7973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o handler: the method to handle errors.
7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
8013ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport ErrorHandler SetErrorHandler(ErrorHandler handler)
8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ErrorHandler
8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    previous_handler;
8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
8063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  previous_handler=error_handler;
8073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  error_handler=handler;
8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(previous_handler);
8093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
8103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
8113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   S e t F a t a l E r r o r H a n d l e r                                   %
8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  SetFatalErrorHandler() sets the fatal exception handler to the specified
8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  method and returns the previous fatal exception handler.
8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the SetErrorHandler method is:
8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      ErrorHandler SetErrorHandler(ErrorHandler handler)
8283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
8303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o handler: the method to handle errors.
8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
8343ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport FatalErrorHandler SetFatalErrorHandler(FatalErrorHandler handler)
8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
8363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  FatalErrorHandler
8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    previous_handler;
8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  previous_handler=fatal_error_handler;
8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  fatal_error_handler=handler;
8413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(previous_handler);
8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
8433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
8443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
8453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   S e t W a r n i n g H a n d l e r                                         %
8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  SetWarningHandler() sets the warning handler to the specified method
8563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  and returns the previous warning handler.
8573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the SetWarningHandler method is:
8593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      ErrorHandler SetWarningHandler(ErrorHandler handler)
8613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
8633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o handler: the method to handle warnings.
8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
8673ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport WarningHandler SetWarningHandler(WarningHandler handler)
8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  WarningHandler
8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    previous_handler;
8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  previous_handler=warning_handler;
8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  warning_handler=handler;
8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(previous_handler);
8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
8763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
8773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   T h r o w E x c e p t i o n                                               %
8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
8863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ThrowException() throws an exception with the specified severity code,
8893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  reason, and optional description.
8903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ThrowException method is:
8923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      MagickBooleanType ThrowException(ExceptionInfo *exception,
8943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const ExceptionType severity,const char *reason,
8953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *description)
8963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
8983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
8993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
9003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o severity: the severity of the exception.
9023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reason: the reason for the exception.
9043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o description: the exception description.
9063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
9083ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType ThrowException(ExceptionInfo *exception,
9093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const ExceptionType severity,const char *reason,const char *description)
9103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
9113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  register ExceptionInfo
9123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *p;
9133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
9153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception->signature == MagickSignature);
91693670403847955b4bb6a820d62d1ac2c689fe84dcristy  LockSemaphoreInfo(exception->semaphore);
9173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p=(ExceptionInfo *) GetLastValueInLinkedList((LinkedListInfo *)
9183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    exception->exceptions);
9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if ((p != (ExceptionInfo *) NULL) && (p->severity == severity) &&
9203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (LocaleCompare(exception->reason,reason) == 0) &&
9213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (LocaleCompare(exception->description,description) == 0))
92293670403847955b4bb6a820d62d1ac2c689fe84dcristy    {
92393670403847955b4bb6a820d62d1ac2c689fe84dcristy      UnlockSemaphoreInfo(exception->semaphore);
92493670403847955b4bb6a820d62d1ac2c689fe84dcristy      return(MagickTrue);
92593670403847955b4bb6a820d62d1ac2c689fe84dcristy    }
92673bd4a51b419e914565bdf204bf1540dc4c8ee26cristy  p=(ExceptionInfo *) AcquireMagickMemory(sizeof(*p));
9273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (p == (ExceptionInfo *) NULL)
92893670403847955b4bb6a820d62d1ac2c689fe84dcristy    {
92993670403847955b4bb6a820d62d1ac2c689fe84dcristy      UnlockSemaphoreInfo(exception->semaphore);
93093670403847955b4bb6a820d62d1ac2c689fe84dcristy      ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
93193670403847955b4bb6a820d62d1ac2c689fe84dcristy    }
9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) ResetMagickMemory(p,0,sizeof(*p));
9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p->severity=severity;
9343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (reason != (const char *) NULL)
9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    p->reason=ConstantString(reason);
9363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (description != (const char *) NULL)
9373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    p->description=ConstantString(description);
9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  p->signature=MagickSignature;
9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) AppendValueToLinkedList((LinkedListInfo *) exception->exceptions,p);
940992f537a471552415614fd4eddf5e30ec90cc2b6cristy  if (p->severity >= exception->severity)
941992f537a471552415614fd4eddf5e30ec90cc2b6cristy    {
942992f537a471552415614fd4eddf5e30ec90cc2b6cristy      exception->severity=p->severity;
943992f537a471552415614fd4eddf5e30ec90cc2b6cristy      exception->reason=p->reason;
944992f537a471552415614fd4eddf5e30ec90cc2b6cristy      exception->description=p->description;
945992f537a471552415614fd4eddf5e30ec90cc2b6cristy    }
94693670403847955b4bb6a820d62d1ac2c689fe84dcristy  UnlockSemaphoreInfo(exception->semaphore);
9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickTrue);
9483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
9493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
9513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   T h r o w M a g i c k E x c e p t i o n                                   %
9563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9615216f82250f6a3a9fe652a6534a46e0a69f5c6f7anthony%  ThrowMagickException logs an exception as determined by the log
9625216f82250f6a3a9fe652a6534a46e0a69f5c6f7anthony%  configuration file.  If an error occurs, MagickFalse is returned
9635216f82250f6a3a9fe652a6534a46e0a69f5c6f7anthony%  otherwise MagickTrue.
9643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ThrowMagickException method is:
9663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      MagickBooleanType ThrowFileException(ExceptionInfo *exception,
968bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        const char *module,const char *function,const size_t line,
9693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const ExceptionType severity,const char *tag,const char *format,...)
9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
9723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: the exception info.
9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o filename: the source module filename.
9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o function: the function name.
9783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o line: the line number of the source module.
9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o severity: Specifies the numeric error category.
9823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o tag: the locale tag.
9843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o format: the output format.
9863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
98993670403847955b4bb6a820d62d1ac2c689fe84dcristyMagickExport MagickBooleanType ThrowMagickExceptionList(
99093670403847955b4bb6a820d62d1ac2c689fe84dcristy  ExceptionInfo *exception,const char *module,const char *function,
99193670403847955b4bb6a820d62d1ac2c689fe84dcristy  const size_t line,const ExceptionType severity,const char *tag,
99293670403847955b4bb6a820d62d1ac2c689fe84dcristy  const char *format,va_list operands)
9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
9953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    message[MaxTextExtent],
9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    path[MaxTextExtent],
9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    reason[MaxTextExtent];
9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char
100032cca407db0c7f1812b1809773513370b5813309cristy    *locale,
100132cca407db0c7f1812b1809773513370b5813309cristy    *type;
10023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    n;
10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  size_t
10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    length;
10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
10133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception->signature == MagickSignature);
10143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  locale=GetLocaleExceptionMessage(severity,tag);
10153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) CopyMagickString(reason,locale,MaxTextExtent);
10163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) ConcatenateMagickString(reason," ",MaxTextExtent);
10173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  length=strlen(reason);
10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_VSNPRINTF)
10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  n=vsnprintf(reason+length,MaxTextExtent-length,format,operands);
10203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else
10213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  n=vsprintf(reason+length,format,operands);
10223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
10233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (n < 0)
10243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    reason[MaxTextExtent-1]='\0';
10253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  status=LogMagickEvent(ExceptionEvent,module,function,line,"%s",reason);
10263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  GetPathComponent(module,TailPath,path);
102732cca407db0c7f1812b1809773513370b5813309cristy  type="undefined";
102832cca407db0c7f1812b1809773513370b5813309cristy  if ((severity >= WarningException) && (severity < ErrorException))
102932cca407db0c7f1812b1809773513370b5813309cristy    type="warning";
103032cca407db0c7f1812b1809773513370b5813309cristy  if ((severity >= ErrorException) && (severity < FatalErrorException))
103132cca407db0c7f1812b1809773513370b5813309cristy    type="error";
103232cca407db0c7f1812b1809773513370b5813309cristy  if (severity >= FatalErrorException)
103332cca407db0c7f1812b1809773513370b5813309cristy    type="fatal";
1034b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleString(message,MaxTextExtent,"%s @ %s/%s/%s/%.20g",reason,
1035e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy    type,path,function,(double) line);
10363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) ThrowException(exception,severity,message,(char *) NULL);
10373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(status);
10383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
10393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10403ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception,
1041bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  const char *module,const char *function,const size_t line,
10423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const ExceptionType severity,const char *tag,const char *format,...)
10433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
10443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
10453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
10463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  va_list
10483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    operands;
10493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  va_start(operands,format);
10513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  status=ThrowMagickExceptionList(exception,module,function,line,severity,tag,
10523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    format,operands);
10533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  va_end(operands);
10543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(status);
10553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1056