MagickCore  7.1.2-29
Convert, Edit, Or Compose Bitmap Images
exception-private.h
1 /*
2  Copyright @ 1999 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. You may
6  obtain a copy of the License at
7 
8  https://imagemagick.org/license/
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 private methods.
17 */
18 #ifndef MAGICKCORE_EXCEPTION_PRIVATE_H
19 #define MAGICKCORE_EXCEPTION_PRIVATE_H
20 
21 #include "MagickCore/log.h"
22 #include "MagickCore/magick.h"
23 #include "MagickCore/string_.h"
24 
25 #if defined(__cplusplus) || defined(c_plusplus)
26 extern "C" {
27 #endif
28 
29 #define ThrowBinaryException(severity,tag,context) \
30 { \
31  (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \
32  "`%s'",context); \
33  return(MagickFalse); \
34 }
35 #define ThrowFatalException(severity,tag) \
36 { \
37  char \
38  *fatal_message; \
39  \
40  ExceptionInfo \
41  *fatal_exception; \
42  \
43  fatal_exception=AcquireExceptionInfo(); \
44  fatal_message=GetExceptionMessage(errno); \
45  (void) ThrowMagickException(fatal_exception,GetMagickModule(),severity,tag, \
46  "`%s'",fatal_message); \
47  fatal_message=DestroyString(fatal_message); \
48  CatchException(fatal_exception); \
49  (void) DestroyExceptionInfo(fatal_exception); \
50  MagickCoreTerminus(); \
51  _exit((int) (severity-FatalErrorException)+1); \
52 }
53 #define ThrowFileException(exception,severity,tag,context) \
54 { \
55  char \
56  *file_message; \
57  \
58  file_message=GetExceptionMessage(errno); \
59  (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \
60  "'%s': %s",context,file_message); \
61  file_message=DestroyString(file_message); \
62 }
63 #define ThrowImageException(severity,tag) \
64 { \
65  (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \
66  "`%s'",image->filename); \
67  return((Image *) NULL); \
68 }
69 #define ThrowPolicyException(tag,status) \
70 { \
71  errno=EPERM; \
72  (void) ThrowMagickException(exception,GetMagickModule(),PolicyError, \
73  "NotAuthorized","`%s'",tag); \
74  return(status); \
75 }
76 #define ThrowReaderException(severity,tag) \
77 { \
78  (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \
79  "`%s'",image_info->filename); \
80  if ((image) != (Image *) NULL) \
81  { \
82  (void) CloseBlob(image); \
83  image=DestroyImageList(image); \
84  } \
85  return((Image *) NULL); \
86 }
87 #define ThrowWriterException(severity,tag) \
88 { \
89  (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \
90  "`%s'",image->filename); \
91  if (image_info->adjoin != MagickFalse) \
92  while (image->previous != (Image *) NULL) \
93  image=image->previous; \
94  (void) CloseBlob(image); \
95  return(MagickFalse); \
96 }
97 
98 extern MagickPrivate void
99  ExceptionComponentTerminus(void),
100  InitializeExceptionInfo(ExceptionInfo *);
101 
102 extern MagickPrivate MagickBooleanType
103  ExceptionComponentGenesis(void);
104 
105 #if defined(__cplusplus) || defined(c_plusplus)
106 }
107 #endif
108 
109 #endif