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-2011 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/policy.h"
58 #include "MagickCore/semaphore.h"
59 #include "MagickCore/splay-tree.h"
60 #include "MagickCore/static.h"
61 #include "MagickCore/string_.h"
62 #include "MagickCore/string-private.h"
63 #include "MagickCore/token.h"
64 #include "MagickCore/utility.h"
65 #include "MagickCore/utility-private.h"
66 #if defined(MAGICKCORE_MODULES_SUPPORT)
67 #if defined(MAGICKCORE_LTDL_DELEGATE)
69 typedef lt_dlhandle ModuleHandle;
71 typedef void *ModuleHandle;
77 #if defined(MAGICKCORE_LTDL_DELEGATE)
78 # define ModuleGlobExpression "*.la"
81 # define ModuleGlobExpression "IM_MOD_DB_*.dll"
83 # define ModuleGlobExpression "IM_MOD_RL_*.dll"
91 *module_semaphore = (SemaphoreInfo *) NULL;
94 *module_list = (SplayTreeInfo *) NULL;
96 static volatile MagickBooleanType
97 instantiate_module = MagickFalse;
100 Forward declarations.
102 static const ModuleInfo
103 *RegisterModule(const ModuleInfo *,ExceptionInfo *);
105 static MagickBooleanType
106 GetMagickModulePath(const char *,MagickModuleType,char *,ExceptionInfo *),
107 InitializeModuleList(ExceptionInfo *),
108 UnregisterModule(const ModuleInfo *,ExceptionInfo *);
111 TagToCoderModuleName(const char *,char *),
112 TagToFilterModuleName(const char *,char *),
113 TagToModuleName(const char *,const char *,char *);
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 % A c q u i r e M o d u l e I n f o %
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126 % AcquireModuleInfo() allocates the ModuleInfo structure.
128 % The format of the AcquireModuleInfo method is:
130 % ModuleInfo *AcquireModuleInfo(const char *path,const char *tag)
132 % A description of each parameter follows:
134 % o path: the path associated with the tag.
136 % o tag: a character string that represents the image format we are
140 MagickExport ModuleInfo *AcquireModuleInfo(const char *path,const char *tag)
145 module_info=(ModuleInfo *) AcquireMagickMemory(sizeof(*module_info));
146 if (module_info == (ModuleInfo *) NULL)
147 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
148 (void) ResetMagickMemory(module_info,0,sizeof(*module_info));
149 if (path != (const char *) NULL)
150 module_info->path=ConstantString(path);
151 if (tag != (const char *) NULL)
152 module_info->tag=ConstantString(tag);
153 module_info->timestamp=time(0);
154 module_info->signature=MagickSignature;
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 % D e s t r o y M o d u l e L i s t %
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169 % DestroyModuleList() unregisters any previously loaded modules and exits
170 % the module loaded environment.
172 % The format of the DestroyModuleList module is:
174 % void DestroyModuleList(void)
177 MagickExport void DestroyModuleList(void)
180 Destroy magick modules.
182 LockSemaphoreInfo(module_semaphore);
183 #if defined(MAGICKCORE_MODULES_SUPPORT)
184 if (module_list != (SplayTreeInfo *) NULL)
185 module_list=DestroySplayTree(module_list);
186 if (instantiate_module != MagickFalse)
188 #if !defined(MAGICKCORE_JP2_DELEGATE)
189 (void) lt_dlexit(); /* Jasper has an errant atexit() handler */
191 instantiate_module=MagickFalse;
194 UnlockSemaphoreInfo(module_semaphore);
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 % G e t M o d u l e I n f o %
206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 % GetModuleInfo() returns a pointer to a ModuleInfo structure that matches the
209 % specified tag. If tag is NULL, the head of the module list is returned. If
210 % no modules are loaded, or the requested module is not found, NULL is
213 % The format of the GetModuleInfo module is:
215 % ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
217 % A description of each parameter follows:
219 % o tag: a character string that represents the image format we are
222 % o exception: return any errors or warnings in this structure.
225 MagickExport ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
227 if ((module_list == (SplayTreeInfo *) NULL) ||
228 (instantiate_module == MagickFalse))
229 if (InitializeModuleList(exception) == MagickFalse)
230 return((ModuleInfo *) NULL);
231 if ((module_list == (SplayTreeInfo *) NULL) ||
232 (GetNumberOfNodesInSplayTree(module_list) == 0))
233 return((ModuleInfo *) NULL);
234 if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0))
239 #if defined(MAGICKCORE_MODULES_SUPPORT)
240 if (LocaleCompare(tag,"*") == 0)
241 (void) OpenModules(exception);
243 LockSemaphoreInfo(module_semaphore);
244 ResetSplayTreeIterator(module_list);
245 p=(ModuleInfo *) GetNextValueInSplayTree(module_list);
246 UnlockSemaphoreInfo(module_semaphore);
249 return((ModuleInfo *) GetValueFromSplayTree(module_list,tag));
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 % G e t M o d u l e I n f o L i s t %
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
263 % GetModuleInfoList() returns any modules that match the specified pattern.
265 % The format of the GetModuleInfoList function is:
267 % const ModuleInfo **GetModuleInfoList(const char *pattern,
268 % size_t *number_modules,ExceptionInfo *exception)
270 % A description of each parameter follows:
272 % o pattern: Specifies a pointer to a text string containing a pattern.
274 % o number_modules: This integer returns the number of modules in the list.
276 % o exception: return any errors or warnings in this structure.
280 #if defined(__cplusplus) || defined(c_plusplus)
284 static int ModuleInfoCompare(const void *x,const void *y)
290 p=(const ModuleInfo **) x,
291 q=(const ModuleInfo **) y;
292 if (LocaleCompare((*p)->path,(*q)->path) == 0)
293 return(LocaleCompare((*p)->tag,(*q)->tag));
294 return(LocaleCompare((*p)->path,(*q)->path));
297 #if defined(__cplusplus) || defined(c_plusplus)
301 MagickExport const ModuleInfo **GetModuleInfoList(const char *pattern,
302 size_t *number_modules,ExceptionInfo *exception)
307 register const ModuleInfo
314 Allocate module list.
316 assert(pattern != (char *) NULL);
317 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
318 assert(number_modules != (size_t *) NULL);
320 p=GetModuleInfo("*",exception);
321 if (p == (const ModuleInfo *) NULL)
322 return((const ModuleInfo **) NULL);
323 modules=(const ModuleInfo **) AcquireQuantumMemory((size_t)
324 GetNumberOfNodesInSplayTree(module_list)+1UL,sizeof(*modules));
325 if (modules == (const ModuleInfo **) NULL)
326 return((const ModuleInfo **) NULL);
328 Generate module list.
330 LockSemaphoreInfo(module_semaphore);
331 ResetSplayTreeIterator(module_list);
332 p=(const ModuleInfo *) GetNextValueInSplayTree(module_list);
333 for (i=0; p != (const ModuleInfo *) NULL; )
335 if ((p->stealth == MagickFalse) &&
336 (GlobExpression(p->tag,pattern,MagickFalse) != MagickFalse))
338 p=(const ModuleInfo *) GetNextValueInSplayTree(module_list);
340 UnlockSemaphoreInfo(module_semaphore);
341 qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleInfoCompare);
342 modules[i]=(ModuleInfo *) NULL;
343 *number_modules=(size_t) i;
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
352 % G e t M o d u l e L i s t %
356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 % GetModuleList() returns any image format modules that match the specified
361 % The format of the GetModuleList function is:
363 % char **GetModuleList(const char *pattern,const MagickModuleType type,
364 % size_t *number_modules,ExceptionInfo *exception)
366 % A description of each parameter follows:
368 % o pattern: Specifies a pointer to a text string containing a pattern.
370 % o type: choose from MagickImageCoderModule or MagickImageFilterModule.
372 % o number_modules: This integer returns the number of modules in the
375 % o exception: return any errors or warnings in this structure.
379 #if defined(__cplusplus) || defined(c_plusplus)
383 static int ModuleCompare(const void *x,const void *y)
391 return(LocaleCompare(*p,*q));
394 #if defined(__cplusplus) || defined(c_plusplus)
398 static inline int MagickReadDirectory(DIR *directory,struct dirent *entry,
399 struct dirent **result)
401 #if defined(MAGICKCORE_HAVE_READDIR_R)
402 return(readdir_r(directory,entry,result));
406 *result=readdir(directory);
411 MagickExport char **GetModuleList(const char *pattern,
412 const MagickModuleType type,size_t *number_modules,ExceptionInfo *exception)
416 filename[MaxTextExtent],
417 module_path[MaxTextExtent],
437 Locate all modules in the image coder or filter path.
441 case MagickImageCoderModule:
444 TagToCoderModuleName("magick",filename);
445 status=GetMagickModulePath(filename,MagickImageCoderModule,module_path,
449 case MagickImageFilterModule:
451 TagToFilterModuleName("analyze",filename);
452 status=GetMagickModulePath(filename,MagickImageFilterModule,module_path,
457 if (status == MagickFalse)
458 return((char **) NULL);
459 GetPathComponent(module_path,HeadPath,path);
461 modules=(char **) AcquireQuantumMemory((size_t) max_entries+1UL,
463 if (modules == (char **) NULL)
464 return((char **) NULL);
465 *modules=(char *) NULL;
466 directory=opendir(path);
467 if (directory == (DIR *) NULL)
469 modules=(char **) RelinquishMagickMemory(modules);
470 return((char **) NULL);
472 buffer=(struct dirent *) AcquireMagickMemory(sizeof(*buffer)+
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,
769 "%s/lib/%s/modules-Q%d/%s/%s",prefix,MAGICKCORE_LIBRARY_RELATIVE_PATH,
770 MAGICKCORE_QUANTUM_DEPTH,directory,filename);
772 if (IsPathAccessible(path) != MagickFalse)
775 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
780 if ((NTGetModulePath("CORE_RL_magick_.dll",path) != MagickFalse) ||
781 (NTGetModulePath("CORE_DB_magick_.dll",path) != MagickFalse) ||
782 (NTGetModulePath("Magick.dll",path) != MagickFalse))
784 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
785 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
786 if (IsPathAccessible(path) != MagickFalse)
795 home=GetEnvironmentValue("HOME");
796 if (home == (char *) NULL)
797 home=GetEnvironmentValue("USERPROFILE");
798 if (home != (char *) NULL)
801 Search $HOME/.magick.
803 (void) FormatLocaleString(path,MaxTextExtent,"%s%s.magick%s%s",home,
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",
824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 % I n i t i a l i z e M o d u l e L i s t %
832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
834 % InitializeModuleList() initializes the module loader.
836 % The format of the InitializeModuleList() method is:
838 % InitializeModuleList(Exceptioninfo *exception)
840 % A description of each parameter follows.
842 % o exception: return any errors or warnings in this structure.
846 static void *DestroyModuleNode(void *module_info)
854 exception=AcquireExceptionInfo();
855 p=(ModuleInfo *) module_info;
856 if (UnregisterModule(p,exception) == MagickFalse)
857 CatchException(exception);
858 if (p->tag != (char *) NULL)
859 p->tag=DestroyString(p->tag);
860 if (p->path != (char *) NULL)
861 p->path=DestroyString(p->path);
862 exception=DestroyExceptionInfo(exception);
863 return(RelinquishMagickMemory(p));
866 static MagickBooleanType InitializeModuleList(
867 ExceptionInfo *magick_unused(exception))
869 if ((module_list == (SplayTreeInfo *) NULL) &&
870 (instantiate_module == MagickFalse))
872 if (module_semaphore == (SemaphoreInfo *) NULL)
873 AcquireSemaphoreInfo(&module_semaphore);
874 LockSemaphoreInfo(module_semaphore);
875 if ((module_list == (SplayTreeInfo *) NULL) &&
876 (instantiate_module == MagickFalse))
884 module_list=NewSplayTree(CompareSplayTreeString,
885 (void *(*)(void *)) NULL,DestroyModuleNode);
886 if (module_list == (SplayTreeInfo *) NULL)
887 ThrowFatalException(ResourceLimitFatalError,
888 "MemoryAllocationFailed");
889 module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
890 module_info->stealth=MagickTrue;
891 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
892 if (status == MagickFalse)
893 ThrowFatalException(ResourceLimitFatalError,
894 "MemoryAllocationFailed");
895 if (lt_dlinit() != 0)
896 ThrowFatalException(ModuleFatalError,
897 "UnableToInitializeModuleLoader");
898 instantiate_module=MagickTrue;
900 UnlockSemaphoreInfo(module_semaphore);
902 return(module_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
906 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
910 % I n v o k e D y n a m i c I m a g e F i l t e r %
914 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
916 % InvokeDynamicImageFilter() invokes a dynamic image filter.
918 % The format of the InvokeDynamicImageFilter module is:
920 % MagickBooleanType InvokeDynamicImageFilter(const char *tag,Image **image,
921 % const int argc,const char **argv,ExceptionInfo *exception)
923 % A description of each parameter follows:
925 % o tag: a character string that represents the name of the particular
928 % o image: the image.
930 % o argc: a pointer to an integer describing the number of elements in the
933 % o argv: a pointer to a text array containing the command line arguments.
935 % o exception: return any errors or warnings in this structure.
938 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
939 Image **images,const int argc,const char **argv,ExceptionInfo *exception)
960 assert(images != (Image **) NULL);
961 assert((*images)->signature == MagickSignature);
962 if ((*images)->debug != MagickFalse)
963 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
964 (*images)->filename);
965 #if !defined(MAGICKCORE_BUILD_MODULES)
970 status=InvokeStaticImageFilter(tag,images,argc,argv,exception);
971 if (status != MagickFalse)
975 rights=ReadPolicyRights;
976 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
979 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
980 "NotAuthorized","`%s'",tag);
983 TagToFilterModuleName(tag,name);
984 status=GetMagickModulePath(name,MagickImageFilterModule,path,exception);
985 if (status == MagickFalse)
987 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
988 "UnableToLoadModule","`%s': %s",name,path);
994 handle=(ModuleHandle) lt_dlopen(path);
995 if (handle == (ModuleHandle) NULL)
997 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
998 "UnableToLoadModule","`%s': %s",name,lt_dlerror());
1004 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1005 (void) FormatLocaleString(name,MaxTextExtent,"%sImage",tag);
1007 (void) FormatLocaleString(name,MaxTextExtent,"%s%sImage",
1008 MAGICKCORE_NAMESPACE_PREFIX,tag);
1013 ClearMagickException(exception);
1014 image_filter=(ImageFilterHandler *) lt_dlsym(handle,name);
1015 if (image_filter == (ImageFilterHandler *) NULL)
1016 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1017 "UnableToLoadModule","`%s': %s",name,lt_dlerror());
1023 if ((*images)->debug != MagickFalse)
1024 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1025 "Invoking \"%s\" dynamic image filter",tag);
1026 signature=image_filter(images,argc,argv,exception);
1027 if ((*images)->debug != MagickFalse)
1028 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),"\"%s\" completes",
1030 if (signature != MagickImageFilterSignature)
1031 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1032 "ImageFilterSignatureMismatch","`%s': %8lx != %8lx",tag,
1033 (unsigned long) signature,(unsigned long) MagickImageFilterSignature);
1038 if (lt_dlclose(handle) != 0)
1039 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1040 "UnableToCloseModule","`%s': %s",name,lt_dlerror());
1041 return(exception->severity < ErrorException ? MagickTrue : MagickFalse);
1045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1049 % L i s t M o d u l e I n f o %
1053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1055 % ListModuleInfo() lists the module info to a file.
1057 % The format of the ListModuleInfo module is:
1059 % MagickBooleanType ListModuleInfo(FILE *file,ExceptionInfo *exception)
1061 % A description of each parameter follows.
1063 % o file: An pointer to a FILE.
1065 % o exception: return any errors or warnings in this structure.
1068 MagickExport MagickBooleanType ListModuleInfo(FILE *file,
1069 ExceptionInfo *exception)
1072 filename[MaxTextExtent],
1073 module_path[MaxTextExtent],
1075 path[MaxTextExtent];
1083 if (file == (const FILE *) NULL)
1088 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1089 if (modules == (char **) NULL)
1090 return(MagickFalse);
1091 TagToCoderModuleName("magick",filename);
1092 (void) GetMagickModulePath(filename,MagickImageCoderModule,module_path,
1094 GetPathComponent(module_path,HeadPath,path);
1095 (void) FormatLocaleFile(file,"\nPath: %s\n\n",path);
1096 (void) FormatLocaleFile(file,"Image Coder\n");
1097 (void) FormatLocaleFile(file,
1098 "-------------------------------------------------"
1099 "------------------------------\n");
1100 for (i=0; i < (ssize_t) number_modules; i++)
1102 (void) FormatLocaleFile(file,"%s",modules[i]);
1103 (void) FormatLocaleFile(file,"\n");
1105 (void) fflush(file);
1107 Relinquish resources.
1109 for (i=0; i < (ssize_t) number_modules; i++)
1110 modules[i]=DestroyString(modules[i]);
1111 modules=(char **) RelinquishMagickMemory(modules);
1115 modules=GetModuleList("*",MagickImageFilterModule,&number_modules,exception);
1116 if (modules == (char **) NULL)
1117 return(MagickFalse);
1118 TagToFilterModuleName("analyze",filename);
1119 (void) GetMagickModulePath(filename,MagickImageFilterModule,module_path,
1121 GetPathComponent(module_path,HeadPath,path);
1122 (void) FormatLocaleFile(file,"\nPath: %s\n\n",path);
1123 (void) FormatLocaleFile(file,"Image Filter\n");
1124 (void) FormatLocaleFile(file,
1125 "-------------------------------------------------"
1126 "------------------------------\n");
1127 for (i=0; i < (ssize_t) number_modules; i++)
1129 (void) FormatLocaleFile(file,"%s",modules[i]);
1130 (void) FormatLocaleFile(file,"\n");
1132 (void) fflush(file);
1134 Relinquish resources.
1136 for (i=0; i < (ssize_t) number_modules; i++)
1137 modules[i]=DestroyString(modules[i]);
1138 modules=(char **) RelinquishMagickMemory(modules);
1143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1147 + M o d u l e C o m p o n e n t G e n e s i s %
1151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1153 % ModuleComponentGenesis() instantiates the module component.
1155 % The format of the ModuleComponentGenesis method is:
1157 % MagickBooleanType ModuleComponentGenesis(void)
1160 MagickPrivate MagickBooleanType ModuleComponentGenesis(void)
1168 AcquireSemaphoreInfo(&module_semaphore);
1169 exception=AcquireExceptionInfo();
1170 status=InitializeModuleList(exception);
1171 exception=DestroyExceptionInfo(exception);
1176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1180 + M o d u l e C o m p o n e n t T e r m i n u s %
1184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1186 % ModuleComponentTerminus() destroys the module component.
1188 % The format of the ModuleComponentTerminus method is:
1190 % ModuleComponentTerminus(void)
1193 MagickPrivate void ModuleComponentTerminus(void)
1195 if (module_semaphore == (SemaphoreInfo *) NULL)
1196 AcquireSemaphoreInfo(&module_semaphore);
1197 DestroyModuleList();
1198 DestroySemaphoreInfo(&module_semaphore);
1202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1206 % O p e n M o d u l e %
1210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1212 % OpenModule() loads a module, and invokes its registration module. It
1213 % returns MagickTrue on success, and MagickFalse if there is an error.
1215 % The format of the OpenModule module is:
1217 % MagickBooleanType OpenModule(const char *module,ExceptionInfo *exception)
1219 % A description of each parameter follows:
1221 % o module: a character string that indicates the module to load.
1223 % o exception: return any errors or warnings in this structure.
1226 MagickPrivate MagickBooleanType OpenModule(const char *module,
1227 ExceptionInfo *exception)
1230 filename[MaxTextExtent],
1231 module_name[MaxTextExtent],
1232 name[MaxTextExtent],
1233 path[MaxTextExtent];
1244 register const CoderInfo
1251 Assign module name from alias.
1253 assert(module != (const char *) NULL);
1254 module_info=(ModuleInfo *) GetModuleInfo(module,exception);
1255 if (module_info != (ModuleInfo *) NULL)
1257 (void) CopyMagickString(module_name,module,MaxTextExtent);
1258 p=GetCoderInfo(module,exception);
1259 if (p != (CoderInfo *) NULL)
1260 (void) CopyMagickString(module_name,p->name,MaxTextExtent);
1261 if (GetValueFromSplayTree(module_list,module_name) != (void *) NULL)
1262 return(MagickTrue); /* module already opened, return */
1266 handle=(ModuleHandle) NULL;
1267 TagToCoderModuleName(module_name,filename);
1268 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1269 "Searching for module \"%s\" using filename \"%s\"",module_name,filename);
1271 status=GetMagickModulePath(filename,MagickImageCoderModule,path,exception);
1272 if (status == MagickFalse)
1273 return(MagickFalse);
1277 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1278 "Opening module at path \"%s\"",path);
1279 handle=(ModuleHandle) lt_dlopen(path);
1280 if (handle == (ModuleHandle) NULL)
1282 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1283 "UnableToLoadModule","`%s': %s",path,lt_dlerror());
1284 return(MagickFalse);
1289 module_info=AcquireModuleInfo(path,module_name);
1290 module_info->handle=handle;
1291 if (RegisterModule(module_info,exception) == (ModuleInfo *) NULL)
1292 return(MagickFalse);
1294 Define RegisterFORMATImage method.
1296 TagToModuleName(module_name,"Register%sImage",name);
1297 module_info->register_module=(size_t (*)(void)) lt_dlsym(handle,name);
1298 if (module_info->register_module == (size_t (*)(void)) NULL)
1300 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1301 "UnableToRegisterImageFormat","`%s': %s",module_name,lt_dlerror());
1302 return(MagickFalse);
1304 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1305 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1306 (void *) module_info->register_module);
1308 Define UnregisterFORMATImage method.
1310 TagToModuleName(module_name,"Unregister%sImage",name);
1311 module_info->unregister_module=(void (*)(void)) lt_dlsym(handle,name);
1312 if (module_info->unregister_module == (void (*)(void)) NULL)
1314 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1315 "UnableToRegisterImageFormat","`%s': %s",module_name,lt_dlerror());
1316 return(MagickFalse);
1318 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1319 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1320 (void *) module_info->unregister_module);
1321 signature=module_info->register_module();
1322 if (signature != MagickImageCoderSignature)
1324 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1325 "ImageCoderSignatureMismatch","`%s': %8lx != %8lx",module_name,
1326 (unsigned long) signature,(unsigned long) MagickImageCoderSignature);
1327 return(MagickFalse);
1333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1337 % O p e n M o d u l e s %
1341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1343 % OpenModules() loads all available modules.
1345 % The format of the OpenModules module is:
1347 % MagickBooleanType OpenModules(ExceptionInfo *exception)
1349 % A description of each parameter follows:
1351 % o exception: return any errors or warnings in this structure.
1354 MagickPrivate MagickBooleanType OpenModules(ExceptionInfo *exception)
1368 (void) GetMagickInfo((char *) NULL,exception);
1370 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1371 if (modules == (char **) NULL)
1372 return(MagickFalse);
1373 for (i=0; i < (ssize_t) number_modules; i++)
1374 (void) OpenModule(modules[i],exception);
1376 Relinquish resources.
1378 for (i=0; i < (ssize_t) number_modules; i++)
1379 modules[i]=DestroyString(modules[i]);
1380 modules=(char **) RelinquishMagickMemory(modules);
1385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1389 % R e g i s t e r M o d u l e %
1393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1395 % RegisterModule() adds an entry to the module list. It returns a pointer to
1396 % the registered entry on success.
1398 % The format of the RegisterModule module is:
1400 % ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1401 % ExceptionInfo *exception)
1403 % A description of each parameter follows:
1405 % o info: a pointer to the registered entry is returned.
1407 % o module_info: a pointer to the ModuleInfo structure to register.
1409 % o exception: return any errors or warnings in this structure.
1412 static const ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1413 ExceptionInfo *exception)
1418 assert(module_info != (ModuleInfo *) NULL);
1419 assert(module_info->signature == MagickSignature);
1420 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1421 if (module_list == (SplayTreeInfo *) NULL)
1422 return((const ModuleInfo *) NULL);
1423 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
1424 if (status == MagickFalse)
1425 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
1426 "MemoryAllocationFailed","`%s'",module_info->tag);
1427 return(module_info);
1431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1435 % T a g T o C o d e r M o d u l e N a m e %
1439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1441 % TagToCoderModuleName() munges a module tag and obtains the filename of the
1442 % corresponding module.
1444 % The format of the TagToCoderModuleName module is:
1446 % char *TagToCoderModuleName(const char *tag,char *name)
1448 % A description of each parameter follows:
1450 % o tag: a character string representing the module tag.
1452 % o name: return the module name here.
1455 static void TagToCoderModuleName(const char *tag,char *name)
1457 assert(tag != (char *) NULL);
1458 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1459 assert(name != (char *) NULL);
1460 #if defined(MAGICKCORE_LTDL_DELEGATE)
1461 (void) FormatLocaleString(name,MaxTextExtent,"%s.la",tag);
1462 (void) LocaleLower(name);
1464 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1465 if (LocaleNCompare("IM_MOD_",tag,7) == 0)
1466 (void) CopyMagickString(name,tag,MaxTextExtent);
1470 (void) FormatLocaleString(name,MaxTextExtent,"IM_MOD_DB_%s_.dll",tag);
1472 (void) FormatLocaleString(name,MaxTextExtent,"IM_MOD_RL_%s_.dll",tag);
1480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1484 % T a g T o F i l t e r M o d u l e N a m e %
1488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1490 % TagToFilterModuleName() munges a module tag and returns the filename of the
1491 % corresponding filter module.
1493 % The format of the TagToFilterModuleName module is:
1495 % void TagToFilterModuleName(const char *tag,char name)
1497 % A description of each parameter follows:
1499 % o tag: a character string representing the module tag.
1501 % o name: return the filter name here.
1504 static void TagToFilterModuleName(const char *tag,char *name)
1506 assert(tag != (char *) NULL);
1507 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1508 assert(name != (char *) NULL);
1509 #if !defined(MAGICKCORE_LTDL_DELEGATE)
1510 (void) FormatLocaleString(name,MaxTextExtent,"%s.dll",tag);
1512 (void) FormatLocaleString(name,MaxTextExtent,"%s.la",tag);
1517 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1521 % T a g T o M o d u l e N a m e %
1525 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1527 % TagToModuleName() munges the module tag name and returns an upper-case tag
1528 % name as the input string, and a user-provided format.
1530 % The format of the TagToModuleName module is:
1532 % TagToModuleName(const char *tag,const char *format,char *module)
1534 % A description of each parameter follows:
1536 % o tag: the module tag.
1538 % o format: a sprintf-compatible format string containing %s where the
1539 % upper-case tag name is to be inserted.
1541 % o module: pointer to a destination buffer for the formatted result.
1544 static void TagToModuleName(const char *tag,const char *format,char *module)
1547 name[MaxTextExtent];
1549 assert(tag != (const char *) NULL);
1550 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1551 assert(format != (const char *) NULL);
1552 assert(module != (char *) NULL);
1553 (void) CopyMagickString(name,tag,MaxTextExtent);
1555 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1556 (void) FormatLocaleString(module,MaxTextExtent,format,name);
1560 prefix_format[MaxTextExtent];
1562 (void) FormatLocaleString(prefix_format,MaxTextExtent,"%s%s",
1563 MAGICKCORE_NAMESPACE_PREFIX,format);
1564 (void) FormatLocaleString(module,MaxTextExtent,prefix_format,name);
1570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1574 % U n r e g i s t e r M o d u l e %
1578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1580 % UnregisterModule() unloads a module, and invokes its de-registration module.
1581 % Returns MagickTrue on success, and MagickFalse if there is an error.
1583 % The format of the UnregisterModule module is:
1585 % MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1586 % ExceptionInfo *exception)
1588 % A description of each parameter follows:
1590 % o module_info: the module info.
1592 % o exception: return any errors or warnings in this structure.
1595 static MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1596 ExceptionInfo *exception)
1599 Locate and execute UnregisterFORMATImage module.
1601 assert(module_info != (const ModuleInfo *) NULL);
1602 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1603 assert(exception != (ExceptionInfo *) NULL);
1604 if (module_info->unregister_module == NULL)
1606 module_info->unregister_module();
1607 if (lt_dlclose((ModuleHandle) module_info->handle) != 0)
1609 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1610 "UnableToCloseModule","`%s': %s",module_info->tag,lt_dlerror());
1611 return(MagickFalse);
1616 MagickExport MagickBooleanType ListModuleInfo(FILE *magick_unused(file),
1617 ExceptionInfo *magick_unused(exception))
1622 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
1623 Image **image,const int argc,const char **argv,ExceptionInfo *exception)
1628 assert(image != (Image **) NULL);
1629 assert((*image)->signature == MagickSignature);
1630 if ((*image)->debug != MagickFalse)
1631 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1632 rights=ReadPolicyRights;
1633 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
1636 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1637 "NotAuthorized","`%s'",tag);
1638 return(MagickFalse);
1640 #if defined(MAGICKCORE_BUILD_MODULES)
1648 analyzeImage(Image **,const int,const char **,ExceptionInfo *);
1653 image_filter=(ImageFilterHandler *) NULL;
1654 if (LocaleCompare("analyze",tag) == 0)
1655 image_filter=(ImageFilterHandler *) analyzeImage;
1656 if (image_filter == (ImageFilterHandler *) NULL)
1657 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1658 "UnableToLoadModule","`%s'",tag);
1664 if ((*image)->debug != MagickFalse)
1665 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1666 "Invoking \"%s\" static image filter",tag);
1667 signature=image_filter(image,argc,argv,exception);
1668 if ((*image)->debug != MagickFalse)
1669 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes",
1671 if (signature != MagickImageFilterSignature)
1673 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1674 "ImageFilterSignatureMismatch","`%s': %8lx != %8lx",tag,
1675 (unsigned long) signature,(unsigned long)
1676 MagickImageFilterSignature);
1677 return(MagickFalse);