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-2012 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)+
475 if (buffer == (struct dirent *) NULL)
476 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
478 while ((MagickReadDirectory(directory,buffer,&entry) == 0) &&
479 (entry != (struct dirent *) NULL))
481 status=GlobExpression(entry->d_name,ModuleGlobExpression,MagickFalse);
482 if (status == MagickFalse)
484 if (GlobExpression(entry->d_name,pattern,MagickFalse) == MagickFalse)
486 if (i >= (ssize_t) max_entries)
488 modules=(char **) NULL;
489 if (~max_entries > max_entries)
490 modules=(char **) ResizeQuantumMemory(modules,(size_t)
491 (max_entries << 1),sizeof(*modules));
493 if (modules == (char **) NULL)
497 Add new module name to list.
499 modules[i]=AcquireString((char *) NULL);
500 GetPathComponent(entry->d_name,BasePath,modules[i]);
501 if (LocaleNCompare("IM_MOD_",modules[i],7) == 0)
503 (void) CopyMagickString(modules[i],modules[i]+10,MaxTextExtent);
504 modules[i][strlen(modules[i])-1]='\0';
508 buffer=(struct dirent *) RelinquishMagickMemory(buffer);
509 (void) closedir(directory);
510 if (modules == (char **) NULL)
512 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureError,
513 "MemoryAllocationFailed","'%s'",pattern);
514 return((char **) NULL);
516 qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleCompare);
517 modules[i]=(char *) NULL;
518 *number_modules=(size_t) i;
523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 % G e t M a g i c k M o d u l e P a t h %
531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533 % GetMagickModulePath() finds a module with the specified module type and
536 % The format of the GetMagickModulePath module is:
538 % MagickBooleanType GetMagickModulePath(const char *filename,
539 % MagickModuleType module_type,char *path,ExceptionInfo *exception)
541 % A description of each parameter follows:
543 % o filename: the module file name.
545 % o module_type: the module type: MagickImageCoderModule or
546 % MagickImageFilterModule.
548 % o path: the path associated with the filename.
550 % o exception: return any errors or warnings in this structure.
553 static MagickBooleanType GetMagickModulePath(const char *filename,
554 MagickModuleType module_type,char *path,ExceptionInfo *exception)
559 assert(filename != (const char *) NULL);
560 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
561 assert(path != (char *) NULL);
562 assert(exception != (ExceptionInfo *) NULL);
563 (void) CopyMagickString(path,filename,MaxTextExtent);
564 module_path=(char *) NULL;
567 case MagickImageCoderModule:
570 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
571 "Searching for coder module file \"%s\" ...",filename);
572 module_path=GetEnvironmentValue("MAGICK_CODER_MODULE_PATH");
573 #if defined(MAGICKCORE_CODER_PATH)
574 if (module_path == (char *) NULL)
575 module_path=AcquireString(MAGICKCORE_CODER_PATH);
579 case MagickImageFilterModule:
581 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
582 "Searching for filter module file \"%s\" ...",filename);
583 module_path=GetEnvironmentValue("MAGICK_CODER_FILTER_PATH");
584 #if defined(MAGICKCORE_FILTER_PATH)
585 if (module_path == (char *) NULL)
586 module_path=AcquireString(MAGICKCORE_FILTER_PATH);
591 if (module_path != (char *) NULL)
597 for (p=module_path-1; p != (char *) NULL; )
599 (void) CopyMagickString(path,p+1,MaxTextExtent);
600 q=strchr(path,DirectoryListSeparator);
601 if (q != (char *) NULL)
603 q=path+strlen(path)-1;
604 if ((q >= path) && (*q != *DirectorySeparator))
605 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
606 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
607 if (IsPathAccessible(path) != MagickFalse)
609 module_path=DestroyString(module_path);
612 p=strchr(p+1,DirectoryListSeparator);
614 module_path=DestroyString(module_path);
616 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
618 #if defined(MAGICKCORE_CODER_PATH)
624 Search hard coded paths.
628 case MagickImageCoderModule:
631 directory=MAGICKCORE_CODER_PATH;
634 case MagickImageFilterModule:
636 directory=MAGICKCORE_FILTER_PATH;
640 (void) FormatLocaleString(path,MaxTextExtent,"%s%s",directory,filename);
641 if (IsPathAccessible(path) == MagickFalse)
643 ThrowFileException(exception,ConfigureWarning,
644 "UnableToOpenModuleFile",path);
650 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
659 Locate path via registry key.
663 case MagickImageCoderModule:
666 registery_key="CoderModulesPath";
669 case MagickImageFilterModule:
671 registery_key="FilterModulesPath";
675 key_value=NTRegistryKeyLookup(registery_key);
676 if (key_value == (unsigned char *) NULL)
678 ThrowMagickException(exception,GetMagickModule(),ConfigureError,
679 "RegistryKeyLookupFailed","'%s'",registery_key);
682 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",(char *) key_value,
683 DirectorySeparator,filename);
684 key_value=(unsigned char *) RelinquishMagickMemory(key_value);
685 if (IsPathAccessible(path) == MagickFalse)
687 ThrowFileException(exception,ConfigureWarning,
688 "UnableToOpenModuleFile",path);
695 #if !defined(MAGICKCORE_CODER_PATH) && !defined(MAGICKCORE_WINDOWS_SUPPORT)
696 # error MAGICKCORE_CODER_PATH or MAGICKCORE_WINDOWS_SUPPORT must be defined when MAGICKCORE_INSTALLED_SUPPORT is defined
703 home=GetEnvironmentValue("MAGICK_HOME");
704 if (home != (char *) NULL)
709 #if !defined(MAGICKCORE_POSIX_SUPPORT)
710 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",home,
711 DirectorySeparator,filename);
718 case MagickImageCoderModule:
721 directory=MAGICKCORE_CODER_RELATIVE_PATH;
724 case MagickImageFilterModule:
726 directory=MAGICKCORE_FILTER_RELATIVE_PATH;
730 (void) FormatLocaleString(path,MaxTextExtent,"%s/lib/%s/%s",home,
733 home=DestroyString(home);
734 if (IsPathAccessible(path) != MagickFalse)
738 if (*GetClientPath() != '\0')
741 Search based on executable directory.
743 #if !defined(MAGICKCORE_POSIX_SUPPORT)
744 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
745 DirectorySeparator,filename);
748 prefix[MaxTextExtent];
755 case MagickImageCoderModule:
761 case MagickImageFilterModule:
767 (void) CopyMagickString(prefix,GetClientPath(),MaxTextExtent);
768 ChopPathComponents(prefix,1);
769 (void) FormatLocaleString(path,MaxTextExtent,
770 "%s/lib/%s/modules-Q%d/%s/%s",prefix,MAGICKCORE_LIBRARY_RELATIVE_PATH,
771 MAGICKCORE_QUANTUM_DEPTH,directory,filename);
773 if (IsPathAccessible(path) != MagickFalse)
776 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
781 if ((NTGetModulePath("CORE_RL_magick_.dll",path) != MagickFalse) ||
782 (NTGetModulePath("CORE_DB_magick_.dll",path) != MagickFalse) ||
783 (NTGetModulePath("Magick.dll",path) != MagickFalse))
785 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
786 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
787 if (IsPathAccessible(path) != MagickFalse)
796 home=GetEnvironmentValue("HOME");
797 if (home == (char *) NULL)
798 home=GetEnvironmentValue("USERPROFILE");
799 if (home != (char *) NULL)
802 Search $HOME/.magick.
804 (void) FormatLocaleString(path,MaxTextExtent,"%s%s.magick%s%s",home,
805 DirectorySeparator,DirectorySeparator,filename);
806 home=DestroyString(home);
807 if (IsPathAccessible(path) != MagickFalse)
812 Search current directory.
814 if (IsPathAccessible(path) != MagickFalse)
816 if (exception->severity < ConfigureError)
817 ThrowFileException(exception,ConfigureWarning,"UnableToOpenModuleFile",
825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 % I n i t i a l i z e M o d u l e L i s t %
833 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
835 % InitializeModuleList() initializes the module loader.
837 % The format of the InitializeModuleList() method is:
839 % InitializeModuleList(Exceptioninfo *exception)
841 % A description of each parameter follows.
843 % o exception: return any errors or warnings in this structure.
847 static void *DestroyModuleNode(void *module_info)
855 exception=AcquireExceptionInfo();
856 p=(ModuleInfo *) module_info;
857 if (UnregisterModule(p,exception) == MagickFalse)
858 CatchException(exception);
859 if (p->tag != (char *) NULL)
860 p->tag=DestroyString(p->tag);
861 if (p->path != (char *) NULL)
862 p->path=DestroyString(p->path);
863 exception=DestroyExceptionInfo(exception);
864 return(RelinquishMagickMemory(p));
867 static MagickBooleanType InitializeModuleList(
868 ExceptionInfo *magick_unused(exception))
870 if ((module_list == (SplayTreeInfo *) NULL) &&
871 (instantiate_module == MagickFalse))
873 if (module_semaphore == (SemaphoreInfo *) NULL)
874 AcquireSemaphoreInfo(&module_semaphore);
875 LockSemaphoreInfo(module_semaphore);
876 if ((module_list == (SplayTreeInfo *) NULL) &&
877 (instantiate_module == MagickFalse))
885 module_list=NewSplayTree(CompareSplayTreeString,
886 (void *(*)(void *)) NULL,DestroyModuleNode);
887 if (module_list == (SplayTreeInfo *) NULL)
888 ThrowFatalException(ResourceLimitFatalError,
889 "MemoryAllocationFailed");
890 module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
891 module_info->stealth=MagickTrue;
892 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
893 if (status == MagickFalse)
894 ThrowFatalException(ResourceLimitFatalError,
895 "MemoryAllocationFailed");
896 if (lt_dlinit() != 0)
897 ThrowFatalException(ModuleFatalError,
898 "UnableToInitializeModuleLoader");
899 instantiate_module=MagickTrue;
901 UnlockSemaphoreInfo(module_semaphore);
903 return(module_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
911 % I n v o k e D y n a m i c I m a g e F i l t e r %
915 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
917 % InvokeDynamicImageFilter() invokes a dynamic image filter.
919 % The format of the InvokeDynamicImageFilter module is:
921 % MagickBooleanType InvokeDynamicImageFilter(const char *tag,Image **image,
922 % const int argc,const char **argv,ExceptionInfo *exception)
924 % A description of each parameter follows:
926 % o tag: a character string that represents the name of the particular
929 % o image: the image.
931 % o argc: a pointer to an integer describing the number of elements in the
934 % o argv: a pointer to a text array containing the command line arguments.
936 % o exception: return any errors or warnings in this structure.
939 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
940 Image **images,const int argc,const char **argv,ExceptionInfo *exception)
961 assert(images != (Image **) NULL);
962 assert((*images)->signature == MagickSignature);
963 if ((*images)->debug != MagickFalse)
964 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
965 (*images)->filename);
966 #if !defined(MAGICKCORE_BUILD_MODULES)
971 status=InvokeStaticImageFilter(tag,images,argc,argv,exception);
972 if (status != MagickFalse)
976 rights=ReadPolicyRights;
977 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
980 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
981 "NotAuthorized","'%s'",tag);
984 TagToFilterModuleName(tag,name);
985 status=GetMagickModulePath(name,MagickImageFilterModule,path,exception);
986 if (status == MagickFalse)
988 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
989 "UnableToLoadModule","'%s': %s",name,path);
995 handle=(ModuleHandle) lt_dlopen(path);
996 if (handle == (ModuleHandle) NULL)
998 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
999 "UnableToLoadModule","'%s': %s",name,lt_dlerror());
1000 return(MagickFalse);
1005 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1006 (void) FormatLocaleString(name,MaxTextExtent,"%sImage",tag);
1008 (void) FormatLocaleString(name,MaxTextExtent,"%s%sImage",
1009 MAGICKCORE_NAMESPACE_PREFIX,tag);
1014 ClearMagickException(exception);
1015 image_filter=(ImageFilterHandler *) lt_dlsym(handle,name);
1016 if (image_filter == (ImageFilterHandler *) NULL)
1017 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1018 "UnableToLoadModule","'%s': %s",name,lt_dlerror());
1024 if ((*images)->debug != MagickFalse)
1025 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1026 "Invoking \"%s\" dynamic image filter",tag);
1027 signature=image_filter(images,argc,argv,exception);
1028 if ((*images)->debug != MagickFalse)
1029 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),"\"%s\" completes",
1031 if (signature != MagickImageFilterSignature)
1032 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1033 "ImageFilterSignatureMismatch","'%s': %8lx != %8lx",tag,
1034 (unsigned long) signature,(unsigned long) MagickImageFilterSignature);
1039 if (lt_dlclose(handle) != 0)
1040 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1041 "UnableToCloseModule","'%s': %s",name,lt_dlerror());
1042 return(exception->severity < ErrorException ? MagickTrue : MagickFalse);
1046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1050 % L i s t M o d u l e I n f o %
1054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1056 % ListModuleInfo() lists the module info to a file.
1058 % The format of the ListModuleInfo module is:
1060 % MagickBooleanType ListModuleInfo(FILE *file,ExceptionInfo *exception)
1062 % A description of each parameter follows.
1064 % o file: An pointer to a FILE.
1066 % o exception: return any errors or warnings in this structure.
1069 MagickExport MagickBooleanType ListModuleInfo(FILE *file,
1070 ExceptionInfo *exception)
1073 filename[MaxTextExtent],
1074 module_path[MaxTextExtent],
1076 path[MaxTextExtent];
1084 if (file == (const FILE *) NULL)
1089 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1090 if (modules == (char **) NULL)
1091 return(MagickFalse);
1092 TagToCoderModuleName("magick",filename);
1093 (void) GetMagickModulePath(filename,MagickImageCoderModule,module_path,
1095 GetPathComponent(module_path,HeadPath,path);
1096 (void) FormatLocaleFile(file,"\nPath: %s\n\n",path);
1097 (void) FormatLocaleFile(file,"Image Coder\n");
1098 (void) FormatLocaleFile(file,
1099 "-------------------------------------------------"
1100 "------------------------------\n");
1101 for (i=0; i < (ssize_t) number_modules; i++)
1103 (void) FormatLocaleFile(file,"%s",modules[i]);
1104 (void) FormatLocaleFile(file,"\n");
1106 (void) fflush(file);
1108 Relinquish resources.
1110 for (i=0; i < (ssize_t) number_modules; i++)
1111 modules[i]=DestroyString(modules[i]);
1112 modules=(char **) RelinquishMagickMemory(modules);
1116 modules=GetModuleList("*",MagickImageFilterModule,&number_modules,exception);
1117 if (modules == (char **) NULL)
1118 return(MagickFalse);
1119 TagToFilterModuleName("analyze",filename);
1120 (void) GetMagickModulePath(filename,MagickImageFilterModule,module_path,
1122 GetPathComponent(module_path,HeadPath,path);
1123 (void) FormatLocaleFile(file,"\nPath: %s\n\n",path);
1124 (void) FormatLocaleFile(file,"Image Filter\n");
1125 (void) FormatLocaleFile(file,
1126 "-------------------------------------------------"
1127 "------------------------------\n");
1128 for (i=0; i < (ssize_t) number_modules; i++)
1130 (void) FormatLocaleFile(file,"%s",modules[i]);
1131 (void) FormatLocaleFile(file,"\n");
1133 (void) fflush(file);
1135 Relinquish resources.
1137 for (i=0; i < (ssize_t) number_modules; i++)
1138 modules[i]=DestroyString(modules[i]);
1139 modules=(char **) RelinquishMagickMemory(modules);
1144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1148 + M o d u l e C o m p o n e n t G e n e s i s %
1152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1154 % ModuleComponentGenesis() instantiates the module component.
1156 % The format of the ModuleComponentGenesis method is:
1158 % MagickBooleanType ModuleComponentGenesis(void)
1161 MagickPrivate MagickBooleanType ModuleComponentGenesis(void)
1169 AcquireSemaphoreInfo(&module_semaphore);
1170 exception=AcquireExceptionInfo();
1171 status=InitializeModuleList(exception);
1172 exception=DestroyExceptionInfo(exception);
1177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1181 + M o d u l e C o m p o n e n t T e r m i n u s %
1185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1187 % ModuleComponentTerminus() destroys the module component.
1189 % The format of the ModuleComponentTerminus method is:
1191 % ModuleComponentTerminus(void)
1194 MagickPrivate void ModuleComponentTerminus(void)
1196 if (module_semaphore == (SemaphoreInfo *) NULL)
1197 AcquireSemaphoreInfo(&module_semaphore);
1198 DestroyModuleList();
1199 DestroySemaphoreInfo(&module_semaphore);
1203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1207 % O p e n M o d u l e %
1211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1213 % OpenModule() loads a module, and invokes its registration module. It
1214 % returns MagickTrue on success, and MagickFalse if there is an error.
1216 % The format of the OpenModule module is:
1218 % MagickBooleanType OpenModule(const char *module,ExceptionInfo *exception)
1220 % A description of each parameter follows:
1222 % o module: a character string that indicates the module to load.
1224 % o exception: return any errors or warnings in this structure.
1227 MagickPrivate MagickBooleanType OpenModule(const char *module,
1228 ExceptionInfo *exception)
1231 filename[MaxTextExtent],
1232 module_name[MaxTextExtent],
1233 name[MaxTextExtent],
1234 path[MaxTextExtent];
1245 register const CoderInfo
1252 Assign module name from alias.
1254 assert(module != (const char *) NULL);
1255 module_info=(ModuleInfo *) GetModuleInfo(module,exception);
1256 if (module_info != (ModuleInfo *) NULL)
1258 (void) CopyMagickString(module_name,module,MaxTextExtent);
1259 p=GetCoderInfo(module,exception);
1260 if (p != (CoderInfo *) NULL)
1261 (void) CopyMagickString(module_name,p->name,MaxTextExtent);
1262 if (GetValueFromSplayTree(module_list,module_name) != (void *) NULL)
1263 return(MagickTrue); /* module already opened, return */
1267 handle=(ModuleHandle) NULL;
1268 TagToCoderModuleName(module_name,filename);
1269 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1270 "Searching for module \"%s\" using filename \"%s\"",module_name,filename);
1272 status=GetMagickModulePath(filename,MagickImageCoderModule,path,exception);
1273 if (status == MagickFalse)
1274 return(MagickFalse);
1278 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1279 "Opening module at path \"%s\"",path);
1280 handle=(ModuleHandle) lt_dlopen(path);
1281 if (handle == (ModuleHandle) NULL)
1283 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1284 "UnableToLoadModule","'%s': %s",path,lt_dlerror());
1285 return(MagickFalse);
1290 module_info=AcquireModuleInfo(path,module_name);
1291 module_info->handle=handle;
1292 if (RegisterModule(module_info,exception) == (ModuleInfo *) NULL)
1293 return(MagickFalse);
1295 Define RegisterFORMATImage method.
1297 TagToModuleName(module_name,"Register%sImage",name);
1298 module_info->register_module=(size_t (*)(void)) lt_dlsym(handle,name);
1299 if (module_info->register_module == (size_t (*)(void)) NULL)
1301 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1302 "UnableToRegisterImageFormat","'%s': %s",module_name,lt_dlerror());
1303 return(MagickFalse);
1305 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1306 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1307 (void *) module_info->register_module);
1309 Define UnregisterFORMATImage method.
1311 TagToModuleName(module_name,"Unregister%sImage",name);
1312 module_info->unregister_module=(void (*)(void)) lt_dlsym(handle,name);
1313 if (module_info->unregister_module == (void (*)(void)) NULL)
1315 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1316 "UnableToRegisterImageFormat","'%s': %s",module_name,lt_dlerror());
1317 return(MagickFalse);
1319 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1320 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1321 (void *) module_info->unregister_module);
1322 signature=module_info->register_module();
1323 if (signature != MagickImageCoderSignature)
1325 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1326 "ImageCoderSignatureMismatch","'%s': %8lx != %8lx",module_name,
1327 (unsigned long) signature,(unsigned long) MagickImageCoderSignature);
1328 return(MagickFalse);
1334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1338 % O p e n M o d u l e s %
1342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1344 % OpenModules() loads all available modules.
1346 % The format of the OpenModules module is:
1348 % MagickBooleanType OpenModules(ExceptionInfo *exception)
1350 % A description of each parameter follows:
1352 % o exception: return any errors or warnings in this structure.
1355 MagickPrivate MagickBooleanType OpenModules(ExceptionInfo *exception)
1369 (void) GetMagickInfo((char *) NULL,exception);
1371 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1372 if (modules == (char **) NULL)
1373 return(MagickFalse);
1374 for (i=0; i < (ssize_t) number_modules; i++)
1375 (void) OpenModule(modules[i],exception);
1377 Relinquish resources.
1379 for (i=0; i < (ssize_t) number_modules; i++)
1380 modules[i]=DestroyString(modules[i]);
1381 modules=(char **) RelinquishMagickMemory(modules);
1386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1390 % R e g i s t e r M o d u l e %
1394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1396 % RegisterModule() adds an entry to the module list. It returns a pointer to
1397 % the registered entry on success.
1399 % The format of the RegisterModule module is:
1401 % ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1402 % ExceptionInfo *exception)
1404 % A description of each parameter follows:
1406 % o info: a pointer to the registered entry is returned.
1408 % o module_info: a pointer to the ModuleInfo structure to register.
1410 % o exception: return any errors or warnings in this structure.
1413 static const ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1414 ExceptionInfo *exception)
1419 assert(module_info != (ModuleInfo *) NULL);
1420 assert(module_info->signature == MagickSignature);
1421 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1422 if (module_list == (SplayTreeInfo *) NULL)
1423 return((const ModuleInfo *) NULL);
1424 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
1425 if (status == MagickFalse)
1426 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
1427 "MemoryAllocationFailed","'%s'",module_info->tag);
1428 return(module_info);
1432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1436 % T a g T o C o d e r M o d u l e N a m e %
1440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1442 % TagToCoderModuleName() munges a module tag and obtains the filename of the
1443 % corresponding module.
1445 % The format of the TagToCoderModuleName module is:
1447 % char *TagToCoderModuleName(const char *tag,char *name)
1449 % A description of each parameter follows:
1451 % o tag: a character string representing the module tag.
1453 % o name: return the module name here.
1456 static void TagToCoderModuleName(const char *tag,char *name)
1458 assert(tag != (char *) NULL);
1459 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1460 assert(name != (char *) NULL);
1461 #if defined(MAGICKCORE_LTDL_DELEGATE)
1462 (void) FormatLocaleString(name,MaxTextExtent,"%s.la",tag);
1463 (void) LocaleLower(name);
1465 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1466 if (LocaleNCompare("IM_MOD_",tag,7) == 0)
1467 (void) CopyMagickString(name,tag,MaxTextExtent);
1471 (void) FormatLocaleString(name,MaxTextExtent,"IM_MOD_DB_%s_.dll",tag);
1473 (void) FormatLocaleString(name,MaxTextExtent,"IM_MOD_RL_%s_.dll",tag);
1481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1485 % T a g T o F i l t e r M o d u l e N a m e %
1489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1491 % TagToFilterModuleName() munges a module tag and returns the filename of the
1492 % corresponding filter module.
1494 % The format of the TagToFilterModuleName module is:
1496 % void TagToFilterModuleName(const char *tag,char name)
1498 % A description of each parameter follows:
1500 % o tag: a character string representing the module tag.
1502 % o name: return the filter name here.
1505 static void TagToFilterModuleName(const char *tag,char *name)
1507 assert(tag != (char *) NULL);
1508 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1509 assert(name != (char *) NULL);
1510 #if !defined(MAGICKCORE_LTDL_DELEGATE)
1511 (void) FormatLocaleString(name,MaxTextExtent,"%s.dll",tag);
1513 (void) FormatLocaleString(name,MaxTextExtent,"%s.la",tag);
1518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1522 % T a g T o M o d u l e N a m e %
1526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1528 % TagToModuleName() munges the module tag name and returns an upper-case tag
1529 % name as the input string, and a user-provided format.
1531 % The format of the TagToModuleName module is:
1533 % TagToModuleName(const char *tag,const char *format,char *module)
1535 % A description of each parameter follows:
1537 % o tag: the module tag.
1539 % o format: a sprintf-compatible format string containing %s where the
1540 % upper-case tag name is to be inserted.
1542 % o module: pointer to a destination buffer for the formatted result.
1545 static void TagToModuleName(const char *tag,const char *format,char *module)
1548 name[MaxTextExtent];
1550 assert(tag != (const char *) NULL);
1551 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1552 assert(format != (const char *) NULL);
1553 assert(module != (char *) NULL);
1554 (void) CopyMagickString(name,tag,MaxTextExtent);
1556 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1557 (void) FormatLocaleString(module,MaxTextExtent,format,name);
1561 prefix_format[MaxTextExtent];
1563 (void) FormatLocaleString(prefix_format,MaxTextExtent,"%s%s",
1564 MAGICKCORE_NAMESPACE_PREFIX,format);
1565 (void) FormatLocaleString(module,MaxTextExtent,prefix_format,name);
1571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1575 % U n r e g i s t e r M o d u l e %
1579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1581 % UnregisterModule() unloads a module, and invokes its de-registration module.
1582 % Returns MagickTrue on success, and MagickFalse if there is an error.
1584 % The format of the UnregisterModule module is:
1586 % MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1587 % ExceptionInfo *exception)
1589 % A description of each parameter follows:
1591 % o module_info: the module info.
1593 % o exception: return any errors or warnings in this structure.
1596 static MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1597 ExceptionInfo *exception)
1600 Locate and execute UnregisterFORMATImage module.
1602 assert(module_info != (const ModuleInfo *) NULL);
1603 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1604 assert(exception != (ExceptionInfo *) NULL);
1605 if (module_info->unregister_module == NULL)
1607 module_info->unregister_module();
1608 if (lt_dlclose((ModuleHandle) module_info->handle) != 0)
1610 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1611 "UnableToCloseModule","'%s': %s",module_info->tag,lt_dlerror());
1612 return(MagickFalse);
1617 MagickExport MagickBooleanType ListModuleInfo(FILE *magick_unused(file),
1618 ExceptionInfo *magick_unused(exception))
1623 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
1624 Image **image,const int argc,const char **argv,ExceptionInfo *exception)
1629 assert(image != (Image **) NULL);
1630 assert((*image)->signature == MagickSignature);
1631 if ((*image)->debug != MagickFalse)
1632 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1633 rights=ReadPolicyRights;
1634 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
1637 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1638 "NotAuthorized","'%s'",tag);
1639 return(MagickFalse);
1641 #if defined(MAGICKCORE_BUILD_MODULES)
1649 analyzeImage(Image **,const int,const char **,ExceptionInfo *);
1654 image_filter=(ImageFilterHandler *) NULL;
1655 if (LocaleCompare("analyze",tag) == 0)
1656 image_filter=(ImageFilterHandler *) analyzeImage;
1657 if (image_filter == (ImageFilterHandler *) NULL)
1658 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1659 "UnableToLoadModule","'%s'",tag);
1665 if ((*image)->debug != MagickFalse)
1666 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1667 "Invoking \"%s\" static image filter",tag);
1668 signature=image_filter(image,argc,argv,exception);
1669 if ((*image)->debug != MagickFalse)
1670 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes",
1672 if (signature != MagickImageFilterSignature)
1674 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1675 "ImageFilterSignatureMismatch","'%s': %8lx != %8lx",tag,
1676 (unsigned long) signature,(unsigned long)
1677 MagickImageFilterSignature);
1678 return(MagickFalse);