home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ImageMagick / magick / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  10.9 KB  |  276 lines

  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %                                                                             %
  4. %                                                                             %
  5. %                                                                             %
  6. %                      EEEEE  RRRR   RRRR   OOO   RRRR                        %
  7. %                      E      R   R  R   R O   O  R   R                       %
  8. %                      EEE    RRRR   RRRR  O   O  RRRR                        %
  9. %                      E      R R    R R   O   O  R R                         %
  10. %                      EEEEE  R  R   R  R   OOO   R  R                        %
  11. %                                                                             %
  12. %                                                                             %
  13. %                         ImageMagick Error Routines                          %
  14. %                                                                             %
  15. %                                                                             %
  16. %                                                                             %
  17. %                              Software Design                                %
  18. %                                John Cristy                                  %
  19. %                                 July 1993                                   %
  20. %                                                                             %
  21. %                                                                             %
  22. %  Copyright 1994 E. I. du Pont de Nemours & Company                          %
  23. %                                                                             %
  24. %  Permission to use, copy, modify, distribute, and sell this software and    %
  25. %  its documentation for any purpose is hereby granted without fee,           %
  26. %  provided that the above Copyright notice appear in all copies and that     %
  27. %  both that Copyright notice and this permission notice appear in            %
  28. %  supporting documentation, and that the name of E. I. du Pont de Nemours    %
  29. %  & Company not be used in advertising or publicity pertaining to            %
  30. %  distribution of the software without specific, written prior               %
  31. %  permission.  E. I. du Pont de Nemours & Company makes no representations   %
  32. %  about the suitability of this software for any purpose.  It is provided    %
  33. %  "as is" without express or implied warranty.                               %
  34. %                                                                             %
  35. %  E. I. du Pont de Nemours & Company disclaims all warranties with regard    %
  36. %  to this software, including all implied warranties of merchantability      %
  37. %  and fitness, in no event shall E. I. du Pont de Nemours & Company be       %
  38. %  liable for any special, indirect or consequential damages or any           %
  39. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  40. %  in an action of contract, negligence or other tortuous action, arising     %
  41. %  out of or in connection with the use or performance of this software.      %
  42. %                                                                             %
  43. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  44. %
  45. %
  46. %
  47. */
  48.  
  49. /*
  50.   Include declarations.
  51. */
  52. #include "magick.h"
  53.  
  54. /*
  55.   Forward declaraations.
  56. */
  57. static void
  58.   DefaultErrorHandler _Declare((char *,char *)),
  59.   DefaultWarningHandler _Declare((char *,char *));
  60.  
  61. /*
  62.   Global declarations.
  63. */
  64. char
  65.   *client_name;
  66.  
  67. static ErrorHandler
  68.   error_handler = DefaultErrorHandler,
  69.   warning_handler = DefaultWarningHandler;
  70.  
  71. /*
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  73. %                                                                             %
  74. %                                                                             %
  75. %                                                                             %
  76. %   D e f a u l t E r r o r H a n d l e r                                     %
  77. %                                                                             %
  78. %                                                                             %
  79. %                                                                             %
  80. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  81. %
  82. %  Function DefaultErrorHandler displays an error message and then terminates
  83. %  the program.
  84. %
  85. %  The format of the DefaultErrorHandler routine is:
  86. %
  87. %      DefaultErrorHandler(message,qualifier)
  88. %
  89. %  A description of each parameter follows:
  90. %
  91. %    o message: Specifies the message to display before terminating the
  92. %      program.
  93. %
  94. %    o qualifier: Specifies any qualifier to the message.
  95. %
  96. %
  97. */
  98. static void DefaultErrorHandler(message,qualifier)
  99. char
  100.   *message,
  101.   *qualifier;
  102. {
  103.   (void) fprintf(stderr,"%s: %s",client_name,message);
  104.   if (qualifier != (char *) NULL)
  105.     (void) fprintf(stderr," (%s)",qualifier);
  106.   (void) fprintf(stderr,".\n");
  107.   exit(1);
  108. }
  109.  
  110. /*
  111. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  112. %                                                                             %
  113. %                                                                             %
  114. %                                                                             %
  115. %   D e f a u l t W a r n i n g H a n d l e r                                 %
  116. %                                                                             %
  117. %                                                                             %
  118. %                                                                             %
  119. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  120. %
  121. %  Function DefaultWarningHandler displays an warning message.
  122. %
  123. %  The format of the DefaultWarningHandler routine is:
  124. %
  125. %      DefaultWarningHandler(message,qualifier)
  126. %
  127. %  A description of each parameter follows:
  128. %
  129. %    o message: Specifies the message to display before terminating the
  130. %      program.
  131. %
  132. %    o qualifier: Specifies any qualifier to the message.
  133. %
  134. %
  135. */
  136. static void DefaultWarningHandler(message,qualifier)
  137. char
  138.   *message,
  139.   *qualifier;
  140. {
  141.   (void) fprintf(stderr,"%s: %s",client_name,message);
  142.   if (qualifier != (char *) NULL)
  143.     (void) fprintf(stderr," (%s)",qualifier);
  144.   (void) fprintf(stderr,".\n");
  145. }
  146.  
  147. /*
  148. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  149. %                                                                             %
  150. %                                                                             %
  151. %                                                                             %
  152. %   E r r o r                                                                 %
  153. %                                                                             %
  154. %                                                                             %
  155. %                                                                             %
  156. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  157. %
  158. %  Function Error calls the error handler routines with an error message.
  159. %
  160. %  The format of the Error routine is:
  161. %
  162. %      Error(message,qualifier)
  163. %
  164. %  A description of each parameter follows:
  165. %
  166. %    o message: Specifies the message to display before terminating the
  167. %      program.
  168. %
  169. %    o qualifier: Specifies any qualifier to the message.
  170. %
  171. %
  172. */
  173. void Error(message,qualifier)
  174. char
  175.   *message,
  176.   *qualifier;
  177. {
  178.   if (error_handler != (ErrorHandler) NULL)
  179.     (*error_handler)(message,qualifier);
  180. }
  181.  
  182. /*
  183. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  184. %                                                                             %
  185. %                                                                             %
  186. %                                                                             %
  187. %   S e t E r r o r H a n d l e r                                             %
  188. %                                                                             %
  189. %                                                                             %
  190. %                                                                             %
  191. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  192. %
  193. %  Function SetErrorHandler sets the error handler to the specified routine.
  194. %
  195. %  The format of the SetErrorHandler routine is:
  196. %
  197. %      SetErrorHandler(handler)
  198. %
  199. %  A description of each parameter follows:
  200. %
  201. %    o handler: Specifies a pointer to a routine to handle errors.
  202. %
  203. %
  204. */
  205. void SetErrorHandler(handler)
  206. ErrorHandler
  207.   handler;
  208. {
  209.   error_handler=handler;
  210. }
  211.  
  212. /*
  213. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  214. %                                                                             %
  215. %                                                                             %
  216. %                                                                             %
  217. %   S e t W a r n i n g H a n d l e r                                         %
  218. %                                                                             %
  219. %                                                                             %
  220. %                                                                             %
  221. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  222. %
  223. %  Function SetWarningHandler sets the warning handler to the specified routine.
  224. %
  225. %  The format of the SetWarningHandler routine is:
  226. %
  227. %      SetWarningHandler(handler)
  228. %
  229. %  A description of each parameter follows:
  230. %
  231. %    o handler: Specifies a pointer to a routine to handle warnings.
  232. %
  233. %
  234. */
  235. void SetWarningHandler(handler)
  236. ErrorHandler
  237.   handler;
  238. {
  239.   warning_handler=handler;
  240. }
  241.  
  242. /*
  243. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  244. %                                                                             %
  245. %                                                                             %
  246. %                                                                             %
  247. %   W a r n i n g                                                             %
  248. %                                                                             %
  249. %                                                                             %
  250. %                                                                             %
  251. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  252. %
  253. %  Function Warning calls the warning handler routines with an warning message.
  254. %
  255. %  The format of the Warning routine is:
  256. %
  257. %      Warning(message,qualifier)
  258. %
  259. %  A description of each parameter follows:
  260. %
  261. %    o message: Specifies the message to display before terminating the
  262. %      program.
  263. %
  264. %    o qualifier: Specifies any qualifier to the message.
  265. %
  266. %
  267. */
  268. void Warning(message,qualifier)
  269. char
  270.   *message,
  271.   *qualifier;
  272. {
  273.   if (warning_handler != (ErrorHandler) NULL)
  274.     (*warning_handler)(message,qualifier);
  275. }
  276.