MagickCore  6.9.11-60
Convert, Edit, Or Compose Bitmap Images
constitute-private.h
Go to the documentation of this file.
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  magick private image constitute methods.
17 */
18 #ifndef MAGICKCORE_CONSTITUTE_PRIVATE_H
19 #define MAGICKCORE_CONSTITUTE_PRIVATE_H
20 
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24 
25 #include "magick/constitute.h"
26 #include "magick/exception.h"
27 #include "magick/log.h"
28 #include "magick/utility.h"
29 
30 static inline MagickBooleanType IsAllowedCoder(const char *coder)
31 {
32  static const char
33  *allowed_coders[] = {
34  "MPR",
35  "MPRI",
36  NULL
37  };
38 
39  const char **p = allowed_coders;
40  while (*p != NULL)
41  {
42  if (LocaleCompare(coder,*p) == 0)
43  return(MagickTrue);
44  p++;
45  }
46  return(MagickFalse);
47 }
48 
49 static inline Image *StrictReadImage(const ImageInfo *image_info,
50  ExceptionInfo *exception)
51 {
52  char
53  magic[MagickPathExtent];
54 
55  (void) GetPathComponent(image_info->filename,MagickPath,magic);
56  if (*magic != '\0')
57  {
58  LocaleUpper(magic);
59  if (IsAllowedCoder(magic) == MagickFalse)
60  {
62  "ExplicitCoderNotAllowed","`%s'",image_info->filename);
63  return((Image *) NULL);
64  }
65  else
66  return(ReadImage(image_info,exception));
67  }
68  if (IsPathAccessible(image_info->filename) == MagickFalse)
69  {
71  "UnableToOpenFile","`%s'",image_info->filename);
72  return((Image *) NULL);
73  }
74  return(ReadImage(image_info,exception));
75 }
76 
77 #if defined(__cplusplus) || defined(c_plusplus)
78 }
79 #endif
80 
81 #endif
static Image * StrictReadImage(const ImageInfo *image_info, ExceptionInfo *exception)
Definition: constitute-private.h:49
static MagickBooleanType IsAllowedCoder(const char *coder)
Definition: constitute-private.h:30
MagickExport Image * ReadImage(const ImageInfo *image_info, ExceptionInfo *exception)
Definition: constitute.c:428
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1149
@ FileOpenError
Definition: exception.h:61
@ OptionError
Definition: exception.h:57
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1435
MagickExport void LocaleUpper(char *string)
Definition: locale.c:1630
#define GetMagickModule()
Definition: log.h:29
#define MagickPathExtent
Definition: magick-type.h:31
MagickBooleanType
Definition: magick-type.h:203
@ MagickFalse
Definition: magick-type.h:204
@ MagickTrue
Definition: magick-type.h:205
Definition: exception.h:103
Definition: image.h:362
char filename[MaxTextExtent]
Definition: image.h:473
Definition: image.h:153
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1236
MagickExport MagickBooleanType IsPathAccessible(const char *path)
Definition: utility.c:1490
@ MagickPath
Definition: utility.h:28