cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization |
| 3 | dedicated to making software imaging solutions freely available. |
| 4 | |
| 5 | You may not use this file except in compliance with the License. |
| 6 | obtain a copy of the License at |
| 7 | |
| 8 | http://www.imagemagick.org/script/license.php |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | MagickCore exception methods. |
| 17 | */ |
| 18 | #ifndef _MAGICKCORE_EXCEPTION_H |
| 19 | #define _MAGICKCORE_EXCEPTION_H |
| 20 | |
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | #include <stdarg.h> |
| 26 | #include "magick/semaphore.h" |
| 27 | |
| 28 | typedef enum |
| 29 | { |
| 30 | UndefinedException, |
| 31 | WarningException = 300, |
| 32 | ResourceLimitWarning = 300, |
| 33 | TypeWarning = 305, |
| 34 | OptionWarning = 310, |
| 35 | DelegateWarning = 315, |
| 36 | MissingDelegateWarning = 320, |
| 37 | CorruptImageWarning = 325, |
| 38 | FileOpenWarning = 330, |
| 39 | BlobWarning = 335, |
| 40 | StreamWarning = 340, |
| 41 | CacheWarning = 345, |
| 42 | CoderWarning = 350, |
| 43 | ModuleWarning = 355, |
| 44 | DrawWarning = 360, |
| 45 | ImageWarning = 365, |
| 46 | WandWarning = 370, |
| 47 | RandomWarning = 375, |
| 48 | XServerWarning = 380, |
| 49 | MonitorWarning = 385, |
| 50 | RegistryWarning = 390, |
| 51 | ConfigureWarning = 395, |
| 52 | PolicyWarning = 399, |
| 53 | ErrorException = 400, |
| 54 | ResourceLimitError = 400, |
| 55 | TypeError = 405, |
| 56 | OptionError = 410, |
| 57 | DelegateError = 415, |
| 58 | MissingDelegateError = 420, |
| 59 | CorruptImageError = 425, |
| 60 | FileOpenError = 430, |
| 61 | BlobError = 435, |
| 62 | StreamError = 440, |
| 63 | CacheError = 445, |
| 64 | CoderError = 450, |
| 65 | ModuleError = 455, |
| 66 | DrawError = 460, |
| 67 | ImageError = 465, |
| 68 | WandError = 470, |
| 69 | RandomError = 475, |
| 70 | XServerError = 480, |
| 71 | MonitorError = 485, |
| 72 | RegistryError = 490, |
| 73 | ConfigureError = 495, |
| 74 | PolicyError = 499, |
| 75 | FatalErrorException = 700, |
| 76 | ResourceLimitFatalError = 700, |
| 77 | TypeFatalError = 705, |
| 78 | OptionFatalError = 710, |
| 79 | DelegateFatalError = 715, |
| 80 | MissingDelegateFatalError = 720, |
| 81 | CorruptImageFatalError = 725, |
| 82 | FileOpenFatalError = 730, |
| 83 | BlobFatalError = 735, |
| 84 | StreamFatalError = 740, |
| 85 | CacheFatalError = 745, |
| 86 | CoderFatalError = 750, |
| 87 | ModuleFatalError = 755, |
| 88 | DrawFatalError = 760, |
| 89 | ImageFatalError = 765, |
| 90 | WandFatalError = 770, |
| 91 | RandomFatalError = 775, |
| 92 | XServerFatalError = 780, |
| 93 | MonitorFatalError = 785, |
| 94 | RegistryFatalError = 790, |
| 95 | ConfigureFatalError = 795, |
| 96 | PolicyFatalError = 799 |
| 97 | } ExceptionType; |
| 98 | |
| 99 | struct _ExceptionInfo |
| 100 | { |
| 101 | ExceptionType |
| 102 | severity; |
| 103 | |
| 104 | int |
| 105 | error_number; |
| 106 | |
| 107 | char |
| 108 | *reason, |
| 109 | *description; |
| 110 | |
| 111 | void |
| 112 | *exceptions; |
| 113 | |
| 114 | MagickBooleanType |
| 115 | relinquish; |
| 116 | |
| 117 | SemaphoreInfo |
| 118 | *semaphore; |
| 119 | |
| 120 | unsigned long |
| 121 | signature; |
| 122 | }; |
| 123 | |
| 124 | typedef void |
| 125 | (*ErrorHandler)(const ExceptionType,const char *,const char *); |
| 126 | |
| 127 | typedef void |
| 128 | (*FatalErrorHandler)(const ExceptionType,const char *,const char *); |
| 129 | |
| 130 | typedef void |
| 131 | (*WarningHandler)(const ExceptionType,const char *,const char *); |
| 132 | |
| 133 | extern MagickExport char |
| 134 | *GetExceptionMessage(const int); |
| 135 | |
| 136 | extern MagickExport const char |
| 137 | *GetLocaleExceptionMessage(const ExceptionType,const char *); |
| 138 | |
| 139 | extern MagickExport ErrorHandler |
| 140 | SetErrorHandler(ErrorHandler); |
| 141 | |
| 142 | extern MagickExport ExceptionInfo |
| 143 | *AcquireExceptionInfo(void), |
| 144 | *DestroyExceptionInfo(ExceptionInfo *); |
| 145 | |
| 146 | extern MagickExport FatalErrorHandler |
| 147 | SetFatalErrorHandler(FatalErrorHandler); |
| 148 | |
| 149 | extern MagickExport MagickBooleanType |
| 150 | ThrowException(ExceptionInfo *,const ExceptionType,const char *, |
| 151 | const char *), |
| 152 | ThrowMagickException(ExceptionInfo *,const char *,const char *, |
| 153 | const unsigned long,const ExceptionType,const char *,const char *,...) |
| 154 | magick_attribute((format (printf,7,8))), |
| 155 | ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *, |
| 156 | const unsigned long,const ExceptionType,const char *,const char *,va_list) |
| 157 | magick_attribute((format (printf,7,0))); |
| 158 | |
| 159 | extern MagickExport void |
| 160 | CatchException(ExceptionInfo *), |
| 161 | ClearMagickException(ExceptionInfo *), |
| 162 | GetExceptionInfo(ExceptionInfo *), |
| 163 | InheritException(ExceptionInfo *,const ExceptionInfo *), |
| 164 | MagickError(const ExceptionType,const char *,const char *), |
| 165 | MagickFatalError(const ExceptionType,const char *,const char *), |
| 166 | MagickWarning(const ExceptionType,const char *,const char *); |
| 167 | |
| 168 | extern MagickExport WarningHandler |
| 169 | SetWarningHandler(WarningHandler); |
| 170 | |
| 171 | #if defined(__cplusplus) || defined(c_plusplus) |
| 172 | } |
| 173 | #endif |
| 174 | |
| 175 | #endif |