home *** CD-ROM | disk | FTP | other *** search
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % EEEEE RRRR RRRR OOO RRRR %
- % E R R R R O O R R %
- % EEE RRRR RRRR O O RRRR %
- % E R R R R O O R R %
- % EEEEE R R R R OOO R R %
- % %
- % %
- % ImageMagick Error Routines %
- % %
- % %
- % %
- % Software Design %
- % John Cristy %
- % July 1993 %
- % %
- % %
- % Copyright 1994 E. I. du Pont de Nemours & Company %
- % %
- % Permission to use, copy, modify, distribute, and sell this software and %
- % its documentation for any purpose is hereby granted without fee, %
- % provided that the above Copyright notice appear in all copies and that %
- % both that Copyright notice and this permission notice appear in %
- % supporting documentation, and that the name of E. I. du Pont de Nemours %
- % & Company not be used in advertising or publicity pertaining to %
- % distribution of the software without specific, written prior %
- % permission. E. I. du Pont de Nemours & Company makes no representations %
- % about the suitability of this software for any purpose. It is provided %
- % "as is" without express or implied warranty. %
- % %
- % E. I. du Pont de Nemours & Company disclaims all warranties with regard %
- % to this software, including all implied warranties of merchantability %
- % and fitness, in no event shall E. I. du Pont de Nemours & Company be %
- % liable for any special, indirect or consequential damages or any %
- % damages whatsoever resulting from loss of use, data or profits, whether %
- % in an action of contract, negligence or other tortuous action, arising %
- % out of or in connection with the use or performance of this software. %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %
- %
- */
-
- /*
- Include declarations.
- */
- #include "magick.h"
-
- /*
- Forward declaraations.
- */
- static void
- DefaultErrorHandler _Declare((char *,char *)),
- DefaultWarningHandler _Declare((char *,char *));
-
- /*
- Global declarations.
- */
- char
- *client_name;
-
- static ErrorHandler
- error_handler = DefaultErrorHandler,
- warning_handler = DefaultWarningHandler;
-
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % D e f a u l t E r r o r H a n d l e r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function DefaultErrorHandler displays an error message and then terminates
- % the program.
- %
- % The format of the DefaultErrorHandler routine is:
- %
- % DefaultErrorHandler(message,qualifier)
- %
- % A description of each parameter follows:
- %
- % o message: Specifies the message to display before terminating the
- % program.
- %
- % o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- static void DefaultErrorHandler(message,qualifier)
- char
- *message,
- *qualifier;
- {
- (void) fprintf(stderr,"%s: %s",client_name,message);
- if (qualifier != (char *) NULL)
- (void) fprintf(stderr," (%s)",qualifier);
- (void) fprintf(stderr,".\n");
- exit(1);
- }
-
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % D e f a u l t W a r n i n g H a n d l e r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function DefaultWarningHandler displays an warning message.
- %
- % The format of the DefaultWarningHandler routine is:
- %
- % DefaultWarningHandler(message,qualifier)
- %
- % A description of each parameter follows:
- %
- % o message: Specifies the message to display before terminating the
- % program.
- %
- % o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- static void DefaultWarningHandler(message,qualifier)
- char
- *message,
- *qualifier;
- {
- (void) fprintf(stderr,"%s: %s",client_name,message);
- if (qualifier != (char *) NULL)
- (void) fprintf(stderr," (%s)",qualifier);
- (void) fprintf(stderr,".\n");
- }
-
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % E r r o r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Error calls the error handler routines with an error message.
- %
- % The format of the Error routine is:
- %
- % Error(message,qualifier)
- %
- % A description of each parameter follows:
- %
- % o message: Specifies the message to display before terminating the
- % program.
- %
- % o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- void Error(message,qualifier)
- char
- *message,
- *qualifier;
- {
- if (error_handler != (ErrorHandler) NULL)
- (*error_handler)(message,qualifier);
- }
-
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % S e t E r r o r H a n d l e r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function SetErrorHandler sets the error handler to the specified routine.
- %
- % The format of the SetErrorHandler routine is:
- %
- % SetErrorHandler(handler)
- %
- % A description of each parameter follows:
- %
- % o handler: Specifies a pointer to a routine to handle errors.
- %
- %
- */
- void SetErrorHandler(handler)
- ErrorHandler
- handler;
- {
- error_handler=handler;
- }
-
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % S e t W a r n i n g H a n d l e r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function SetWarningHandler sets the warning handler to the specified routine.
- %
- % The format of the SetWarningHandler routine is:
- %
- % SetWarningHandler(handler)
- %
- % A description of each parameter follows:
- %
- % o handler: Specifies a pointer to a routine to handle warnings.
- %
- %
- */
- void SetWarningHandler(handler)
- ErrorHandler
- handler;
- {
- warning_handler=handler;
- }
-
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % W a r n i n g %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Warning calls the warning handler routines with an warning message.
- %
- % The format of the Warning routine is:
- %
- % Warning(message,qualifier)
- %
- % A description of each parameter follows:
- %
- % o message: Specifies the message to display before terminating the
- % program.
- %
- % o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- void Warning(message,qualifier)
- char
- *message,
- *qualifier;
- {
- if (warning_handler != (ErrorHandler) NULL)
- (*warning_handler)(message,qualifier);
- }
-