43#include "MagickCore/studio.h"
44#include "MagickCore/coder.h"
45#include "MagickCore/exception-private.h"
46#include "MagickCore/image.h"
47#include "MagickCore/module.h"
48#include "MagickCore/policy.h"
49#include "MagickCore/static.h"
50#include "MagickCore/string_.h"
51#include "coders/coders.h"
56#define AddMagickCoder(coder) { #coder, MagickFalse, \
57 Register ## coder ## Image, Unregister ## coder ## Image },
62ModuleExport
size_t RegisterUndefinedImage(
void)
64 return(MagickImageCoderSignature);
67ModuleExport
void UnregisterUndefinedImage(
void)
83 (*register_module)(void);
86 (*unregister_module)(void);
88#if !defined(MAGICKCORE_BUILD_MODULES)
89 #include "coders/coders-list.h"
91 { (
const char *) NULL, MagickFalse, RegisterUndefinedImage, UnregisterUndefinedImage }
127#if defined(MAGICKCORE_MODULES_SUPPORT)
128MagickExport MagickBooleanType InvokeStaticImageFilter(
const char *tag,
134 assert(image != (
Image **) NULL);
135 assert((*image)->signature == MagickCoreSignature);
136 if (IsEventLogging() != MagickFalse)
137 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",(*image)->filename);
138 rights=ReadPolicyRights;
139 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
142 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
143 "NotAuthorized",
"`%s'",tag);
146#if defined(MAGICKCORE_MODULES_SUPPORT)
159 image_filter=(ImageFilterHandler *) NULL;
160 if (LocaleCompare(
"analyze",tag) == 0)
161 image_filter=(ImageFilterHandler *) analyzeImage;
162 if (image_filter == (ImageFilterHandler *) NULL)
163 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
164 "UnableToLoadModule",
"`%s'",tag);
170 if ((*image)->debug != MagickFalse)
171 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
172 "Invoking \"%s\" static image filter",tag);
173 signature=image_filter(image,argc,argv,exception);
174 if ((*image)->debug != MagickFalse)
175 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
176 "\"%s\" completes",tag);
177 if (signature != MagickImageFilterSignature)
179 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
180 "ImageFilterSignatureMismatch",
"'%s': %8lx != %8lx",tag,
181 (
unsigned long) signature,(
unsigned long)
182 MagickImageFilterSignature);
217MagickExport MagickBooleanType RegisterStaticModule(
const char *module,
221 module_name[MagickPathExtent];
238 assert(module != (
const char *) NULL);
239 (void) CopyMagickString(module_name,module,MagickPathExtent);
240 p=GetCoderInfo(module,exception);
242 (void) CopyMagickString(module_name,p->name,MagickPathExtent);
243 rights=(PolicyRights) (ReadPolicyRights | WritePolicyRights);
244 if (IsRightsAuthorized(ModulePolicyDomain,rights,module_name) == MagickFalse)
247 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
248 "NotAuthorized",
"`%s'",module);
251 extent=
sizeof(MagickModules)/
sizeof(MagickModules[0]);
252 for (i=0; i < (ssize_t) extent; i++)
253 if (LocaleCompare(MagickModules[i].module,module_name) == 0)
255 if (MagickModules[i].registered == MagickFalse)
257 (void) (MagickModules[i].register_module)();
258 MagickModules[i].registered=MagickTrue;
284MagickExport
void RegisterStaticModules(
void)
295 rights=(PolicyRights) (ReadPolicyRights | WritePolicyRights);
296 extent=
sizeof(MagickModules)/
sizeof(MagickModules[0]);
297 for (i=0; i < (ssize_t) extent; i++)
299 if (MagickModules[i].registered == MagickFalse)
301 if (IsRightsAuthorized(ModulePolicyDomain,rights,MagickModules[i].module) == MagickFalse)
303 (void) (MagickModules[i].register_module)();
304 MagickModules[i].registered=MagickTrue;
331MagickExport MagickBooleanType UnregisterStaticModule(
const char *module)
339 extent=
sizeof(MagickModules)/
sizeof(MagickModules[0]);
340 for (i=0; i < (ssize_t) extent; i++)
341 if (LocaleCompare(MagickModules[i].module,module) == 0)
343 if (MagickModules[i].registered != MagickFalse)
345 (MagickModules[i].unregister_module)();
346 MagickModules[i].registered=MagickFalse;
372MagickExport
void UnregisterStaticModules(
void)
380 extent=
sizeof(MagickModules)/
sizeof(MagickModules[0]);
381 for (i=0; i < (ssize_t) extent; i++)
383 if (MagickModules[i].registered != MagickFalse)
385 (MagickModules[i].unregister_module)();
386 MagickModules[i].registered=MagickFalse;