2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M OOO DDDD U U L EEEEE %
7 % MM MM O O D D U U L E %
8 % M M M O O D D U U L EEE %
9 % M M O O D D U U L E %
10 % M M OOO DDDD UUU LLLLL EEEEE %
13 % MagickCore Module Methods %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "MagickCore/studio.h"
44 #include "MagickCore/blob.h"
45 #include "MagickCore/coder.h"
46 #include "MagickCore/client.h"
47 #include "MagickCore/configure.h"
48 #include "MagickCore/exception.h"
49 #include "MagickCore/exception-private.h"
50 #include "MagickCore/log.h"
51 #include "MagickCore/hashmap.h"
52 #include "MagickCore/magic.h"
53 #include "MagickCore/magick.h"
54 #include "MagickCore/memory_.h"
55 #include "MagickCore/module.h"
56 #include "MagickCore/module-private.h"
57 #include "MagickCore/nt-base-private.h"
58 #include "MagickCore/policy.h"
59 #include "MagickCore/semaphore.h"
60 #include "MagickCore/splay-tree.h"
61 #include "MagickCore/static.h"
62 #include "MagickCore/string_.h"
63 #include "MagickCore/string-private.h"
64 #include "MagickCore/token.h"
65 #include "MagickCore/utility.h"
66 #include "MagickCore/utility-private.h"
67 #if defined(MAGICKCORE_MODULES_SUPPORT)
68 #if defined(MAGICKCORE_LTDL_DELEGATE)
70 typedef lt_dlhandle ModuleHandle;
72 typedef void *ModuleHandle;
78 #if defined(MAGICKCORE_LTDL_DELEGATE)
79 # define ModuleGlobExpression "*.la"
82 # define ModuleGlobExpression "IM_MOD_DB_*.dll"
84 # define ModuleGlobExpression "IM_MOD_RL_*.dll"
92 *module_semaphore = (SemaphoreInfo *) NULL;
95 *module_list = (SplayTreeInfo *) NULL;
97 static volatile MagickBooleanType
98 instantiate_module = MagickFalse;
101 Forward declarations.
103 static const ModuleInfo
104 *RegisterModule(const ModuleInfo *,ExceptionInfo *);
106 static MagickBooleanType
107 GetMagickModulePath(const char *,MagickModuleType,char *,ExceptionInfo *),
108 InitializeModuleList(ExceptionInfo *),
109 UnregisterModule(const ModuleInfo *,ExceptionInfo *);
112 TagToCoderModuleName(const char *,char *),
113 TagToFilterModuleName(const char *,char *),
114 TagToModuleName(const char *,const char *,char *);
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 % A c q u i r e M o d u l e I n f o %
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 % AcquireModuleInfo() allocates the ModuleInfo structure.
129 % The format of the AcquireModuleInfo method is:
131 % ModuleInfo *AcquireModuleInfo(const char *path,const char *tag)
133 % A description of each parameter follows:
135 % o path: the path associated with the tag.
137 % o tag: a character string that represents the image format we are
141 MagickExport ModuleInfo *AcquireModuleInfo(const char *path,const char *tag)
146 module_info=(ModuleInfo *) AcquireMagickMemory(sizeof(*module_info));
147 if (module_info == (ModuleInfo *) NULL)
148 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
149 (void) ResetMagickMemory(module_info,0,sizeof(*module_info));
150 if (path != (const char *) NULL)
151 module_info->path=ConstantString(path);
152 if (tag != (const char *) NULL)
153 module_info->tag=ConstantString(tag);
154 module_info->timestamp=time(0);
155 module_info->signature=MagickSignature;
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 % D e s t r o y M o d u l e L i s t %
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170 % DestroyModuleList() unregisters any previously loaded modules and exits
171 % the module loaded environment.
173 % The format of the DestroyModuleList module is:
175 % void DestroyModuleList(void)
178 MagickExport void DestroyModuleList(void)
181 Destroy magick modules.
183 LockSemaphoreInfo(module_semaphore);
184 #if defined(MAGICKCORE_MODULES_SUPPORT)
185 if (module_list != (SplayTreeInfo *) NULL)
186 module_list=DestroySplayTree(module_list);
187 if (instantiate_module != MagickFalse)
189 #if !defined(MAGICKCORE_JP2_DELEGATE)
190 (void) lt_dlexit(); /* Jasper has an errant atexit() handler */
192 instantiate_module=MagickFalse;
195 UnlockSemaphoreInfo(module_semaphore);
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 % G e t M o d u l e I n f o %
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 % GetModuleInfo() returns a pointer to a ModuleInfo structure that matches the
210 % specified tag. If tag is NULL, the head of the module list is returned. If
211 % no modules are loaded, or the requested module is not found, NULL is
214 % The format of the GetModuleInfo module is:
216 % ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
218 % A description of each parameter follows:
220 % o tag: a character string that represents the image format we are
223 % o exception: return any errors or warnings in this structure.
226 MagickExport ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
228 if ((module_list == (SplayTreeInfo *) NULL) ||
229 (instantiate_module == MagickFalse))
230 if (InitializeModuleList(exception) == MagickFalse)
231 return((ModuleInfo *) NULL);
232 if ((module_list == (SplayTreeInfo *) NULL) ||
233 (GetNumberOfNodesInSplayTree(module_list) == 0))
234 return((ModuleInfo *) NULL);
235 if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0))
240 #if defined(MAGICKCORE_MODULES_SUPPORT)
241 if (LocaleCompare(tag,"*") == 0)
242 (void) OpenModules(exception);
244 LockSemaphoreInfo(module_semaphore);
245 ResetSplayTreeIterator(module_list);
246 p=(ModuleInfo *) GetNextValueInSplayTree(module_list);
247 UnlockSemaphoreInfo(module_semaphore);
250 return((ModuleInfo *) GetValueFromSplayTree(module_list,tag));
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 % G e t M o d u l e I n f o L i s t %
262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264 % GetModuleInfoList() returns any modules that match the specified pattern.
266 % The format of the GetModuleInfoList function is:
268 % const ModuleInfo **GetModuleInfoList(const char *pattern,
269 % size_t *number_modules,ExceptionInfo *exception)
271 % A description of each parameter follows:
273 % o pattern: Specifies a pointer to a text string containing a pattern.
275 % o number_modules: This integer returns the number of modules in the list.
277 % o exception: return any errors or warnings in this structure.
281 #if defined(__cplusplus) || defined(c_plusplus)
285 static int ModuleInfoCompare(const void *x,const void *y)
291 p=(const ModuleInfo **) x,
292 q=(const ModuleInfo **) y;
293 if (LocaleCompare((*p)->path,(*q)->path) == 0)
294 return(LocaleCompare((*p)->tag,(*q)->tag));
295 return(LocaleCompare((*p)->path,(*q)->path));
298 #if defined(__cplusplus) || defined(c_plusplus)
302 MagickExport const ModuleInfo **GetModuleInfoList(const char *pattern,
303 size_t *number_modules,ExceptionInfo *exception)
308 register const ModuleInfo
315 Allocate module list.
317 assert(pattern != (char *) NULL);
318 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
319 assert(number_modules != (size_t *) NULL);
321 p=GetModuleInfo("*",exception);
322 if (p == (const ModuleInfo *) NULL)
323 return((const ModuleInfo **) NULL);
324 modules=(const ModuleInfo **) AcquireQuantumMemory((size_t)
325 GetNumberOfNodesInSplayTree(module_list)+1UL,sizeof(*modules));
326 if (modules == (const ModuleInfo **) NULL)
327 return((const ModuleInfo **) NULL);
329 Generate module list.
331 LockSemaphoreInfo(module_semaphore);
332 ResetSplayTreeIterator(module_list);
333 p=(const ModuleInfo *) GetNextValueInSplayTree(module_list);
334 for (i=0; p != (const ModuleInfo *) NULL; )
336 if ((p->stealth == MagickFalse) &&
337 (GlobExpression(p->tag,pattern,MagickFalse) != MagickFalse))
339 p=(const ModuleInfo *) GetNextValueInSplayTree(module_list);
341 UnlockSemaphoreInfo(module_semaphore);
342 qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleInfoCompare);
343 modules[i]=(ModuleInfo *) NULL;
344 *number_modules=(size_t) i;
349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353 % G e t M o d u l e L i s t %
357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
359 % GetModuleList() returns any image format modules that match the specified
362 % The format of the GetModuleList function is:
364 % char **GetModuleList(const char *pattern,const MagickModuleType type,
365 % size_t *number_modules,ExceptionInfo *exception)
367 % A description of each parameter follows:
369 % o pattern: Specifies a pointer to a text string containing a pattern.
371 % o type: choose from MagickImageCoderModule or MagickImageFilterModule.
373 % o number_modules: This integer returns the number of modules in the
376 % o exception: return any errors or warnings in this structure.
380 #if defined(__cplusplus) || defined(c_plusplus)
384 static int ModuleCompare(const void *x,const void *y)
392 return(LocaleCompare(*p,*q));
395 #if defined(__cplusplus) || defined(c_plusplus)
399 static inline int MagickReadDirectory(DIR *directory,struct dirent *entry,
400 struct dirent **result)
402 #if defined(MAGICKCORE_HAVE_READDIR_R)
403 return(readdir_r(directory,entry,result));
407 *result=readdir(directory);
412 MagickExport char **GetModuleList(const char *pattern,
413 const MagickModuleType type,size_t *number_modules,ExceptionInfo *exception)
417 filename[MaxTextExtent],
418 module_path[MaxTextExtent],
438 Locate all modules in the image coder or filter path.
442 case MagickImageCoderModule:
445 TagToCoderModuleName("magick",filename);
446 status=GetMagickModulePath(filename,MagickImageCoderModule,module_path,
450 case MagickImageFilterModule:
452 TagToFilterModuleName("analyze",filename);
453 status=GetMagickModulePath(filename,MagickImageFilterModule,module_path,
458 if (status == MagickFalse)
459 return((char **) NULL);
460 GetPathComponent(module_path,HeadPath,path);
462 modules=(char **) AcquireQuantumMemory((size_t) max_entries+1UL,
464 if (modules == (char **) NULL)
465 return((char **) NULL);
466 *modules=(char *) NULL;
467 directory=opendir(path);
468 if (directory == (DIR *) NULL)
470 modules=(char **) RelinquishMagickMemory(modules);
471 return((char **) NULL);
473 buffer=(struct dirent *) AcquireMagickMemory(sizeof(*buffer)+FILENAME_MAX+1);
474 if (buffer == (struct dirent *) NULL)
475 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
477 while ((MagickReadDirectory(directory,buffer,&entry) == 0) &&
478 (entry != (struct dirent *) NULL))
480 status=GlobExpression(entry->d_name,ModuleGlobExpression,MagickFalse);
481 if (status == MagickFalse)
483 if (GlobExpression(entry->d_name,pattern,MagickFalse) == MagickFalse)
485 if (i >= (ssize_t) max_entries)
487 modules=(char **) NULL;
488 if (~max_entries > max_entries)
489 modules=(char **) ResizeQuantumMemory(modules,(size_t)
490 (max_entries << 1),sizeof(*modules));
492 if (modules == (char **) NULL)
496 Add new module name to list.
498 modules[i]=AcquireString((char *) NULL);
499 GetPathComponent(entry->d_name,BasePath,modules[i]);
500 if (LocaleNCompare("IM_MOD_",modules[i],7) == 0)
502 (void) CopyMagickString(modules[i],modules[i]+10,MaxTextExtent);
503 modules[i][strlen(modules[i])-1]='\0';
507 buffer=(struct dirent *) RelinquishMagickMemory(buffer);
508 (void) closedir(directory);
509 if (modules == (char **) NULL)
511 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureError,
512 "MemoryAllocationFailed","`%s'",pattern);
513 return((char **) NULL);
515 qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleCompare);
516 modules[i]=(char *) NULL;
517 *number_modules=(size_t) i;
522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
526 % G e t M a g i c k M o d u l e P a t h %
530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
532 % GetMagickModulePath() finds a module with the specified module type and
535 % The format of the GetMagickModulePath module is:
537 % MagickBooleanType GetMagickModulePath(const char *filename,
538 % MagickModuleType module_type,char *path,ExceptionInfo *exception)
540 % A description of each parameter follows:
542 % o filename: the module file name.
544 % o module_type: the module type: MagickImageCoderModule or
545 % MagickImageFilterModule.
547 % o path: the path associated with the filename.
549 % o exception: return any errors or warnings in this structure.
552 static MagickBooleanType GetMagickModulePath(const char *filename,
553 MagickModuleType module_type,char *path,ExceptionInfo *exception)
558 assert(filename != (const char *) NULL);
559 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
560 assert(path != (char *) NULL);
561 assert(exception != (ExceptionInfo *) NULL);
562 (void) CopyMagickString(path,filename,MaxTextExtent);
563 module_path=(char *) NULL;
566 case MagickImageCoderModule:
569 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
570 "Searching for coder module file \"%s\" ...",filename);
571 module_path=GetEnvironmentValue("MAGICK_CODER_MODULE_PATH");
572 #if defined(MAGICKCORE_CODER_PATH)
573 if (module_path == (char *) NULL)
574 module_path=AcquireString(MAGICKCORE_CODER_PATH);
578 case MagickImageFilterModule:
580 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
581 "Searching for filter module file \"%s\" ...",filename);
582 module_path=GetEnvironmentValue("MAGICK_CODER_FILTER_PATH");
583 #if defined(MAGICKCORE_FILTER_PATH)
584 if (module_path == (char *) NULL)
585 module_path=AcquireString(MAGICKCORE_FILTER_PATH);
590 if (module_path != (char *) NULL)
596 for (p=module_path-1; p != (char *) NULL; )
598 (void) CopyMagickString(path,p+1,MaxTextExtent);
599 q=strchr(path,DirectoryListSeparator);
600 if (q != (char *) NULL)
602 q=path+strlen(path)-1;
603 if ((q >= path) && (*q != *DirectorySeparator))
604 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
605 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
606 if (IsPathAccessible(path) != MagickFalse)
608 module_path=DestroyString(module_path);
611 p=strchr(p+1,DirectoryListSeparator);
613 module_path=DestroyString(module_path);
615 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
617 #if defined(MAGICKCORE_CODER_PATH)
623 Search hard coded paths.
627 case MagickImageCoderModule:
630 directory=MAGICKCORE_CODER_PATH;
633 case MagickImageFilterModule:
635 directory=MAGICKCORE_FILTER_PATH;
639 (void) FormatLocaleString(path,MaxTextExtent,"%s%s",directory,filename);
640 if (IsPathAccessible(path) == MagickFalse)
642 ThrowFileException(exception,ConfigureWarning,
643 "UnableToOpenModuleFile",path);
649 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
658 Locate path via registry key.
662 case MagickImageCoderModule:
665 registery_key="CoderModulesPath";
668 case MagickImageFilterModule:
670 registery_key="FilterModulesPath";
674 key_value=NTRegistryKeyLookup(registery_key);
675 if (key_value == (unsigned char *) NULL)
677 ThrowMagickException(exception,GetMagickModule(),ConfigureError,
678 "RegistryKeyLookupFailed","`%s'",registery_key);
681 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",(char *) key_value,
682 DirectorySeparator,filename);
683 key_value=(unsigned char *) RelinquishMagickMemory(key_value);
684 if (IsPathAccessible(path) == MagickFalse)
686 ThrowFileException(exception,ConfigureWarning,
687 "UnableToOpenModuleFile",path);
694 #if !defined(MAGICKCORE_CODER_PATH) && !defined(MAGICKCORE_WINDOWS_SUPPORT)
695 # error MAGICKCORE_CODER_PATH or MAGICKCORE_WINDOWS_SUPPORT must be defined when MAGICKCORE_INSTALLED_SUPPORT is defined
702 home=GetEnvironmentValue("MAGICK_HOME");
703 if (home != (char *) NULL)
708 #if !defined(MAGICKCORE_POSIX_SUPPORT)
709 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",home,
710 DirectorySeparator,filename);
717 case MagickImageCoderModule:
720 directory=MAGICKCORE_CODER_RELATIVE_PATH;
723 case MagickImageFilterModule:
725 directory=MAGICKCORE_FILTER_RELATIVE_PATH;
729 (void) FormatLocaleString(path,MaxTextExtent,"%s/lib/%s/%s",home,
732 home=DestroyString(home);
733 if (IsPathAccessible(path) != MagickFalse)
737 if (*GetClientPath() != '\0')
740 Search based on executable directory.
742 #if !defined(MAGICKCORE_POSIX_SUPPORT)
743 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
744 DirectorySeparator,filename);
747 prefix[MaxTextExtent];
754 case MagickImageCoderModule:
760 case MagickImageFilterModule:
766 (void) CopyMagickString(prefix,GetClientPath(),MaxTextExtent);
767 ChopPathComponents(prefix,1);
768 (void) FormatLocaleString(path,MaxTextExtent,"%s/lib/%s/%s/%s",prefix,
769 MAGICKCORE_MODULES_RELATIVE_PATH,directory,filename);
771 if (IsPathAccessible(path) != MagickFalse)
774 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
779 if ((NTGetModulePath("CORE_RL_magick_.dll",path) != MagickFalse) ||
780 (NTGetModulePath("CORE_DB_magick_.dll",path) != MagickFalse) ||
781 (NTGetModulePath("Magick.dll",path) != MagickFalse))
783 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
784 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
785 if (IsPathAccessible(path) != MagickFalse)
794 home=GetEnvironmentValue("HOME");
795 if (home == (char *) NULL)
796 home=GetEnvironmentValue("USERPROFILE");
797 if (home != (char *) NULL)
800 Search $HOME/.config/ImageMagick.
802 (void) FormatLocaleString(path,MaxTextExtent,
803 "%s%s.config%sImageMagick%s%s",home,DirectorySeparator,
804 DirectorySeparator,DirectorySeparator,filename);
805 home=DestroyString(home);
806 if (IsPathAccessible(path) != MagickFalse)
811 Search current directory.
813 if (IsPathAccessible(path) != MagickFalse)
815 if (exception->severity < ConfigureError)
816 ThrowFileException(exception,ConfigureWarning,"UnableToOpenModuleFile",
823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
827 % I n i t i a l i z e M o d u l e L i s t %
831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833 % InitializeModuleList() initializes the module loader.
835 % The format of the InitializeModuleList() method is:
837 % InitializeModuleList(Exceptioninfo *exception)
839 % A description of each parameter follows.
841 % o exception: return any errors or warnings in this structure.
845 static void *DestroyModuleNode(void *module_info)
853 exception=AcquireExceptionInfo();
854 p=(ModuleInfo *) module_info;
855 if (UnregisterModule(p,exception) == MagickFalse)
856 CatchException(exception);
857 if (p->tag != (char *) NULL)
858 p->tag=DestroyString(p->tag);
859 if (p->path != (char *) NULL)
860 p->path=DestroyString(p->path);
861 exception=DestroyExceptionInfo(exception);
862 return(RelinquishMagickMemory(p));
865 static MagickBooleanType InitializeModuleList(
866 ExceptionInfo *magick_unused(exception))
868 if ((module_list == (SplayTreeInfo *) NULL) &&
869 (instantiate_module == MagickFalse))
871 if (module_semaphore == (SemaphoreInfo *) NULL)
872 AcquireSemaphoreInfo(&module_semaphore);
873 LockSemaphoreInfo(module_semaphore);
874 if ((module_list == (SplayTreeInfo *) NULL) &&
875 (instantiate_module == MagickFalse))
883 module_list=NewSplayTree(CompareSplayTreeString,
884 (void *(*)(void *)) NULL,DestroyModuleNode);
885 if (module_list == (SplayTreeInfo *) NULL)
886 ThrowFatalException(ResourceLimitFatalError,
887 "MemoryAllocationFailed");
888 module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
889 module_info->stealth=MagickTrue;
890 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
891 if (status == MagickFalse)
892 ThrowFatalException(ResourceLimitFatalError,
893 "MemoryAllocationFailed");
894 if (lt_dlinit() != 0)
895 ThrowFatalException(ModuleFatalError,
896 "UnableToInitializeModuleLoader");
897 instantiate_module=MagickTrue;
899 UnlockSemaphoreInfo(module_semaphore);
901 return(module_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
909 % I n v o k e D y n a m i c I m a g e F i l t e r %
913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
915 % InvokeDynamicImageFilter() invokes a dynamic image filter.
917 % The format of the InvokeDynamicImageFilter module is:
919 % MagickBooleanType InvokeDynamicImageFilter(const char *tag,Image **image,
920 % const int argc,const char **argv,ExceptionInfo *exception)
922 % A description of each parameter follows:
924 % o tag: a character string that represents the name of the particular
927 % o image: the image.
929 % o argc: a pointer to an integer describing the number of elements in the
932 % o argv: a pointer to a text array containing the command line arguments.
934 % o exception: return any errors or warnings in this structure.
937 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
938 Image **images,const int argc,const char **argv,ExceptionInfo *exception)
959 assert(images != (Image **) NULL);
960 assert((*images)->signature == MagickSignature);
961 if ((*images)->debug != MagickFalse)
962 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
963 (*images)->filename);
964 #if !defined(MAGICKCORE_BUILD_MODULES)
969 status=InvokeStaticImageFilter(tag,images,argc,argv,exception);
970 if (status != MagickFalse)
974 rights=ReadPolicyRights;
975 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
978 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
979 "NotAuthorized","`%s'",tag);
982 TagToFilterModuleName(tag,name);
983 status=GetMagickModulePath(name,MagickImageFilterModule,path,exception);
984 if (status == MagickFalse)
986 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
987 "UnableToLoadModule","'%s': %s",name,path);
993 handle=(ModuleHandle) lt_dlopen(path);
994 if (handle == (ModuleHandle) NULL)
996 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
997 "UnableToLoadModule","'%s': %s",name,lt_dlerror());
1003 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1004 (void) FormatLocaleString(name,MaxTextExtent,"%sImage",tag);
1006 (void) FormatLocaleString(name,MaxTextExtent,"%s%sImage",
1007 MAGICKCORE_NAMESPACE_PREFIX,tag);
1012 ClearMagickException(exception);
1013 image_filter=(ImageFilterHandler *) lt_dlsym(handle,name);
1014 if (image_filter == (ImageFilterHandler *) NULL)
1015 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1016 "UnableToLoadModule","'%s': %s",name,lt_dlerror());
1022 if ((*images)->debug != MagickFalse)
1023 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1024 "Invoking \"%s\" dynamic image filter",tag);
1025 signature=image_filter(images,argc,argv,exception);
1026 if ((*images)->debug != MagickFalse)
1027 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),"\"%s\" completes",
1029 if (signature != MagickImageFilterSignature)
1030 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1031 "ImageFilterSignatureMismatch","'%s': %8lx != %8lx",tag,
1032 (unsigned long) signature,(unsigned long) MagickImageFilterSignature);
1037 if (lt_dlclose(handle) != 0)
1038 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1039 "UnableToCloseModule","'%s': %s",name,lt_dlerror());
1040 return(exception->severity < ErrorException ? MagickTrue : MagickFalse);
1044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1048 % L i s t M o d u l e I n f o %
1052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1054 % ListModuleInfo() lists the module info to a file.
1056 % The format of the ListModuleInfo module is:
1058 % MagickBooleanType ListModuleInfo(FILE *file,ExceptionInfo *exception)
1060 % A description of each parameter follows.
1062 % o file: An pointer to a FILE.
1064 % o exception: return any errors or warnings in this structure.
1067 MagickExport MagickBooleanType ListModuleInfo(FILE *file,
1068 ExceptionInfo *exception)
1071 filename[MaxTextExtent],
1072 module_path[MaxTextExtent],
1074 path[MaxTextExtent];
1082 if (file == (const FILE *) NULL)
1087 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1088 if (modules == (char **) NULL)
1089 return(MagickFalse);
1090 TagToCoderModuleName("magick",filename);
1091 (void) GetMagickModulePath(filename,MagickImageCoderModule,module_path,
1093 GetPathComponent(module_path,HeadPath,path);
1094 (void) FormatLocaleFile(file,"\nPath: %s\n\n",path);
1095 (void) FormatLocaleFile(file,"Image Coder\n");
1096 (void) FormatLocaleFile(file,
1097 "-------------------------------------------------"
1098 "------------------------------\n");
1099 for (i=0; i < (ssize_t) number_modules; i++)
1101 (void) FormatLocaleFile(file,"%s",modules[i]);
1102 (void) FormatLocaleFile(file,"\n");
1104 (void) fflush(file);
1106 Relinquish resources.
1108 for (i=0; i < (ssize_t) number_modules; i++)
1109 modules[i]=DestroyString(modules[i]);
1110 modules=(char **) RelinquishMagickMemory(modules);
1114 modules=GetModuleList("*",MagickImageFilterModule,&number_modules,exception);
1115 if (modules == (char **) NULL)
1116 return(MagickFalse);
1117 TagToFilterModuleName("analyze",filename);
1118 (void) GetMagickModulePath(filename,MagickImageFilterModule,module_path,
1120 GetPathComponent(module_path,HeadPath,path);
1121 (void) FormatLocaleFile(file,"\nPath: %s\n\n",path);
1122 (void) FormatLocaleFile(file,"Image Filter\n");
1123 (void) FormatLocaleFile(file,
1124 "-------------------------------------------------"
1125 "------------------------------\n");
1126 for (i=0; i < (ssize_t) number_modules; i++)
1128 (void) FormatLocaleFile(file,"%s",modules[i]);
1129 (void) FormatLocaleFile(file,"\n");
1131 (void) fflush(file);
1133 Relinquish resources.
1135 for (i=0; i < (ssize_t) number_modules; i++)
1136 modules[i]=DestroyString(modules[i]);
1137 modules=(char **) RelinquishMagickMemory(modules);
1142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1146 + M o d u l e C o m p o n e n t G e n e s i s %
1150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1152 % ModuleComponentGenesis() instantiates the module component.
1154 % The format of the ModuleComponentGenesis method is:
1156 % MagickBooleanType ModuleComponentGenesis(void)
1159 MagickPrivate MagickBooleanType ModuleComponentGenesis(void)
1167 AcquireSemaphoreInfo(&module_semaphore);
1168 exception=AcquireExceptionInfo();
1169 status=InitializeModuleList(exception);
1170 exception=DestroyExceptionInfo(exception);
1175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1179 + M o d u l e C o m p o n e n t T e r m i n u s %
1183 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1185 % ModuleComponentTerminus() destroys the module component.
1187 % The format of the ModuleComponentTerminus method is:
1189 % ModuleComponentTerminus(void)
1192 MagickPrivate void ModuleComponentTerminus(void)
1194 if (module_semaphore == (SemaphoreInfo *) NULL)
1195 AcquireSemaphoreInfo(&module_semaphore);
1196 DestroyModuleList();
1197 DestroySemaphoreInfo(&module_semaphore);
1201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1205 % O p e n M o d u l e %
1209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1211 % OpenModule() loads a module, and invokes its registration module. It
1212 % returns MagickTrue on success, and MagickFalse if there is an error.
1214 % The format of the OpenModule module is:
1216 % MagickBooleanType OpenModule(const char *module,ExceptionInfo *exception)
1218 % A description of each parameter follows:
1220 % o module: a character string that indicates the module to load.
1222 % o exception: return any errors or warnings in this structure.
1225 MagickPrivate MagickBooleanType OpenModule(const char *module,
1226 ExceptionInfo *exception)
1229 filename[MaxTextExtent],
1230 module_name[MaxTextExtent],
1231 name[MaxTextExtent],
1232 path[MaxTextExtent];
1243 register const CoderInfo
1250 Assign module name from alias.
1252 assert(module != (const char *) NULL);
1253 module_info=(ModuleInfo *) GetModuleInfo(module,exception);
1254 if (module_info != (ModuleInfo *) NULL)
1256 (void) CopyMagickString(module_name,module,MaxTextExtent);
1257 p=GetCoderInfo(module,exception);
1258 if (p != (CoderInfo *) NULL)
1259 (void) CopyMagickString(module_name,p->name,MaxTextExtent);
1260 if (GetValueFromSplayTree(module_list,module_name) != (void *) NULL)
1261 return(MagickTrue); /* module already opened, return */
1265 handle=(ModuleHandle) NULL;
1266 TagToCoderModuleName(module_name,filename);
1267 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1268 "Searching for module \"%s\" using filename \"%s\"",module_name,filename);
1270 status=GetMagickModulePath(filename,MagickImageCoderModule,path,exception);
1271 if (status == MagickFalse)
1272 return(MagickFalse);
1276 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1277 "Opening module at path \"%s\"",path);
1278 handle=(ModuleHandle) lt_dlopen(path);
1279 if (handle == (ModuleHandle) NULL)
1281 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1282 "UnableToLoadModule","'%s': %s",path,lt_dlerror());
1283 return(MagickFalse);
1288 module_info=AcquireModuleInfo(path,module_name);
1289 module_info->handle=handle;
1290 if (RegisterModule(module_info,exception) == (ModuleInfo *) NULL)
1291 return(MagickFalse);
1293 Define RegisterFORMATImage method.
1295 TagToModuleName(module_name,"Register%sImage",name);
1296 module_info->register_module=(size_t (*)(void)) lt_dlsym(handle,name);
1297 if (module_info->register_module == (size_t (*)(void)) NULL)
1299 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1300 "UnableToRegisterImageFormat","'%s': %s",module_name,lt_dlerror());
1301 return(MagickFalse);
1303 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1304 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1305 (void *) module_info->register_module);
1307 Define UnregisterFORMATImage method.
1309 TagToModuleName(module_name,"Unregister%sImage",name);
1310 module_info->unregister_module=(void (*)(void)) lt_dlsym(handle,name);
1311 if (module_info->unregister_module == (void (*)(void)) NULL)
1313 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1314 "UnableToRegisterImageFormat","'%s': %s",module_name,lt_dlerror());
1315 return(MagickFalse);
1317 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1318 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1319 (void *) module_info->unregister_module);
1320 signature=module_info->register_module();
1321 if (signature != MagickImageCoderSignature)
1323 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1324 "ImageCoderSignatureMismatch","'%s': %8lx != %8lx",module_name,
1325 (unsigned long) signature,(unsigned long) MagickImageCoderSignature);
1326 return(MagickFalse);
1332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1336 % O p e n M o d u l e s %
1340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1342 % OpenModules() loads all available modules.
1344 % The format of the OpenModules module is:
1346 % MagickBooleanType OpenModules(ExceptionInfo *exception)
1348 % A description of each parameter follows:
1350 % o exception: return any errors or warnings in this structure.
1353 MagickPrivate MagickBooleanType OpenModules(ExceptionInfo *exception)
1367 (void) GetMagickInfo((char *) NULL,exception);
1369 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1370 if (modules == (char **) NULL)
1371 return(MagickFalse);
1372 for (i=0; i < (ssize_t) number_modules; i++)
1373 (void) OpenModule(modules[i],exception);
1375 Relinquish resources.
1377 for (i=0; i < (ssize_t) number_modules; i++)
1378 modules[i]=DestroyString(modules[i]);
1379 modules=(char **) RelinquishMagickMemory(modules);
1384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1388 % R e g i s t e r M o d u l e %
1392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1394 % RegisterModule() adds an entry to the module list. It returns a pointer to
1395 % the registered entry on success.
1397 % The format of the RegisterModule module is:
1399 % ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1400 % ExceptionInfo *exception)
1402 % A description of each parameter follows:
1404 % o info: a pointer to the registered entry is returned.
1406 % o module_info: a pointer to the ModuleInfo structure to register.
1408 % o exception: return any errors or warnings in this structure.
1411 static const ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1412 ExceptionInfo *exception)
1417 assert(module_info != (ModuleInfo *) NULL);
1418 assert(module_info->signature == MagickSignature);
1419 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1420 if (module_list == (SplayTreeInfo *) NULL)
1421 return((const ModuleInfo *) NULL);
1422 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
1423 if (status == MagickFalse)
1424 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
1425 "MemoryAllocationFailed","`%s'",module_info->tag);
1426 return(module_info);
1430 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1434 % T a g T o C o d e r M o d u l e N a m e %
1438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1440 % TagToCoderModuleName() munges a module tag and obtains the filename of the
1441 % corresponding module.
1443 % The format of the TagToCoderModuleName module is:
1445 % char *TagToCoderModuleName(const char *tag,char *name)
1447 % A description of each parameter follows:
1449 % o tag: a character string representing the module tag.
1451 % o name: return the module name here.
1454 static void TagToCoderModuleName(const char *tag,char *name)
1456 assert(tag != (char *) NULL);
1457 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1458 assert(name != (char *) NULL);
1459 #if defined(MAGICKCORE_LTDL_DELEGATE)
1460 (void) FormatLocaleString(name,MaxTextExtent,"%s.la",tag);
1461 (void) LocaleLower(name);
1463 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1464 if (LocaleNCompare("IM_MOD_",tag,7) == 0)
1465 (void) CopyMagickString(name,tag,MaxTextExtent);
1469 (void) FormatLocaleString(name,MaxTextExtent,"IM_MOD_DB_%s_.dll",tag);
1471 (void) FormatLocaleString(name,MaxTextExtent,"IM_MOD_RL_%s_.dll",tag);
1479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1483 % T a g T o F i l t e r M o d u l e N a m e %
1487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1489 % TagToFilterModuleName() munges a module tag and returns the filename of the
1490 % corresponding filter module.
1492 % The format of the TagToFilterModuleName module is:
1494 % void TagToFilterModuleName(const char *tag,char name)
1496 % A description of each parameter follows:
1498 % o tag: a character string representing the module tag.
1500 % o name: return the filter name here.
1503 static void TagToFilterModuleName(const char *tag,char *name)
1505 assert(tag != (char *) NULL);
1506 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1507 assert(name != (char *) NULL);
1508 #if !defined(MAGICKCORE_LTDL_DELEGATE)
1509 (void) FormatLocaleString(name,MaxTextExtent,"%s.dll",tag);
1511 (void) FormatLocaleString(name,MaxTextExtent,"%s.la",tag);
1516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1520 % T a g T o M o d u l e N a m e %
1524 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1526 % TagToModuleName() munges the module tag name and returns an upper-case tag
1527 % name as the input string, and a user-provided format.
1529 % The format of the TagToModuleName module is:
1531 % TagToModuleName(const char *tag,const char *format,char *module)
1533 % A description of each parameter follows:
1535 % o tag: the module tag.
1537 % o format: a sprintf-compatible format string containing %s where the
1538 % upper-case tag name is to be inserted.
1540 % o module: pointer to a destination buffer for the formatted result.
1543 static void TagToModuleName(const char *tag,const char *format,char *module)
1546 name[MaxTextExtent];
1548 assert(tag != (const char *) NULL);
1549 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1550 assert(format != (const char *) NULL);
1551 assert(module != (char *) NULL);
1552 (void) CopyMagickString(name,tag,MaxTextExtent);
1554 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1555 (void) FormatLocaleString(module,MaxTextExtent,format,name);
1559 prefix_format[MaxTextExtent];
1561 (void) FormatLocaleString(prefix_format,MaxTextExtent,"%s%s",
1562 MAGICKCORE_NAMESPACE_PREFIX,format);
1563 (void) FormatLocaleString(module,MaxTextExtent,prefix_format,name);
1569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1573 % U n r e g i s t e r M o d u l e %
1577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1579 % UnregisterModule() unloads a module, and invokes its de-registration module.
1580 % Returns MagickTrue on success, and MagickFalse if there is an error.
1582 % The format of the UnregisterModule module is:
1584 % MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1585 % ExceptionInfo *exception)
1587 % A description of each parameter follows:
1589 % o module_info: the module info.
1591 % o exception: return any errors or warnings in this structure.
1594 static MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1595 ExceptionInfo *exception)
1598 Locate and execute UnregisterFORMATImage module.
1600 assert(module_info != (const ModuleInfo *) NULL);
1601 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1602 assert(exception != (ExceptionInfo *) NULL);
1603 if (module_info->unregister_module == NULL)
1605 module_info->unregister_module();
1606 if (lt_dlclose((ModuleHandle) module_info->handle) != 0)
1608 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1609 "UnableToCloseModule","'%s': %s",module_info->tag,lt_dlerror());
1610 return(MagickFalse);
1615 MagickExport MagickBooleanType ListModuleInfo(FILE *magick_unused(file),
1616 ExceptionInfo *magick_unused(exception))
1621 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
1622 Image **image,const int argc,const char **argv,ExceptionInfo *exception)
1627 assert(image != (Image **) NULL);
1628 assert((*image)->signature == MagickSignature);
1629 if ((*image)->debug != MagickFalse)
1630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1631 rights=ReadPolicyRights;
1632 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
1635 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1636 "NotAuthorized","`%s'",tag);
1637 return(MagickFalse);
1639 #if defined(MAGICKCORE_BUILD_MODULES)
1647 analyzeImage(Image **,const int,const char **,ExceptionInfo *);
1652 image_filter=(ImageFilterHandler *) NULL;
1653 if (LocaleCompare("analyze",tag) == 0)
1654 image_filter=(ImageFilterHandler *) analyzeImage;
1655 if (image_filter == (ImageFilterHandler *) NULL)
1656 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1657 "UnableToLoadModule","`%s'",tag);
1663 if ((*image)->debug != MagickFalse)
1664 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1665 "Invoking \"%s\" static image filter",tag);
1666 signature=image_filter(image,argc,argv,exception);
1667 if ((*image)->debug != MagickFalse)
1668 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes",
1670 if (signature != MagickImageFilterSignature)
1672 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1673 "ImageFilterSignatureMismatch","'%s': %8lx != %8lx",tag,
1674 (unsigned long) signature,(unsigned long)
1675 MagickImageFilterSignature);
1676 return(MagickFalse);