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-2010 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 "magick/studio.h"
44 #include "magick/blob.h"
45 #include "magick/coder.h"
46 #include "magick/client.h"
47 #include "magick/configure.h"
48 #include "magick/exception.h"
49 #include "magick/exception-private.h"
50 #include "magick/log.h"
51 #include "magick/hashmap.h"
52 #include "magick/magic.h"
53 #include "magick/magick.h"
54 #include "magick/memory_.h"
55 #include "magick/module.h"
56 #include "magick/policy.h"
57 #include "magick/semaphore.h"
58 #include "magick/splay-tree.h"
59 #include "magick/static.h"
60 #include "magick/string_.h"
61 #include "magick/token.h"
62 #include "magick/utility.h"
63 #if defined(MAGICKCORE_MODULES_SUPPORT)
64 #if defined(MAGICKCORE_LTDL_DELEGATE)
66 typedef lt_dlhandle ModuleHandle;
68 typedef void *ModuleHandle;
74 #if defined(MAGICKCORE_LTDL_DELEGATE)
75 # define ModuleGlobExpression "*.la"
78 # define ModuleGlobExpression "IM_MOD_DB_*.dll"
80 # define ModuleGlobExpression "IM_MOD_RL_*.dll"
88 *module_semaphore = (SemaphoreInfo *) NULL;
91 *module_list = (SplayTreeInfo *) NULL;
93 static volatile MagickBooleanType
94 instantiate_module = MagickFalse;
99 static const ModuleInfo
100 *RegisterModule(const ModuleInfo *,ExceptionInfo *);
102 static MagickBooleanType
103 GetMagickModulePath(const char *,MagickModuleType,char *,ExceptionInfo *),
104 UnregisterModule(const ModuleInfo *,ExceptionInfo *);
107 TagToCoderModuleName(const char *,char *),
108 TagToFilterModuleName(const char *,char *),
109 TagToModuleName(const char *,const char *,char *);
112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 % A c q u i r e M o d u l e I n f o %
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 % AcquireModuleInfo() allocates the ModuleInfo structure.
124 % The format of the AcquireModuleInfo method is:
126 % ModuleInfo *AcquireModuleInfo(const char *path,const char *tag)
128 % A description of each parameter follows:
130 % o path: the path associated with the tag.
132 % o tag: a character string that represents the image format we are
136 MagickExport ModuleInfo *AcquireModuleInfo(const char *path,const char *tag)
141 module_info=(ModuleInfo *) AcquireMagickMemory(sizeof(*module_info));
142 if (module_info == (ModuleInfo *) NULL)
143 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
144 (void) ResetMagickMemory(module_info,0,sizeof(*module_info));
145 if (path != (const char *) NULL)
146 module_info->path=ConstantString(path);
147 if (tag != (const char *) NULL)
148 module_info->tag=ConstantString(tag);
149 module_info->timestamp=time(0);
150 module_info->signature=MagickSignature;
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 % D e s t r o y M o d u l e L i s t %
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 % DestroyModuleList() unregisters any previously loaded modules and exits
166 % the module loaded environment.
168 % The format of the DestroyModuleList module is:
170 % void DestroyModuleList(void)
173 MagickExport void DestroyModuleList(void)
176 Destroy magick modules.
178 LockSemaphoreInfo(module_semaphore);
179 #if defined(MAGICKCORE_MODULES_SUPPORT)
180 if (module_list != (SplayTreeInfo *) NULL)
181 module_list=DestroySplayTree(module_list);
182 if (instantiate_module != MagickFalse)
184 #if !defined(MAGICKCORE_JP2_DELEGATE)
185 (void) lt_dlexit(); /* Jasper has an errant atexit() handler */
187 instantiate_module=MagickFalse;
190 UnlockSemaphoreInfo(module_semaphore);
194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 % G e t M o d u l e I n f o %
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 % GetModuleInfo() returns a pointer to a ModuleInfo structure that matches the
205 % specified tag. If tag is NULL, the head of the module list is returned. If
206 % no modules are loaded, or the requested module is not found, NULL is
209 % The format of the GetModuleInfo module is:
211 % ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
213 % A description of each parameter follows:
215 % o tag: a character string that represents the image format we are
218 % o exception: return any errors or warnings in this structure.
221 MagickExport ModuleInfo *GetModuleInfo(const char *tag,ExceptionInfo *exception)
223 if ((module_list == (SplayTreeInfo *) NULL) ||
224 (instantiate_module == MagickFalse))
225 if (InitializeModuleList(exception) == MagickFalse)
226 return((ModuleInfo *) NULL);
227 if ((module_list == (SplayTreeInfo *) NULL) ||
228 (GetNumberOfNodesInSplayTree(module_list) == 0))
229 return((ModuleInfo *) NULL);
230 if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0))
235 #if defined(MAGICKCORE_MODULES_SUPPORT)
236 if (LocaleCompare(tag,"*") == 0)
237 (void) OpenModules(exception);
239 LockSemaphoreInfo(module_semaphore);
240 ResetSplayTreeIterator(module_list);
241 p=(ModuleInfo *) GetNextValueInSplayTree(module_list);
242 UnlockSemaphoreInfo(module_semaphore);
245 return((ModuleInfo *) GetValueFromSplayTree(module_list,tag));
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 % G e t M o d u l e I n f o L i s t %
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % GetModuleInfoList() returns any modules that match the specified pattern.
261 % The format of the GetModuleInfoList function is:
263 % const ModuleInfo **GetModuleInfoList(const char *pattern,
264 % size_t *number_modules,ExceptionInfo *exception)
266 % A description of each parameter follows:
268 % o pattern: Specifies a pointer to a text string containing a pattern.
270 % o number_modules: This integer returns the number of modules in the list.
272 % o exception: return any errors or warnings in this structure.
276 #if defined(__cplusplus) || defined(c_plusplus)
280 static int ModuleInfoCompare(const void *x,const void *y)
286 p=(const ModuleInfo **) x,
287 q=(const ModuleInfo **) y;
288 if (LocaleCompare((*p)->path,(*q)->path) == 0)
289 return(LocaleCompare((*p)->tag,(*q)->tag));
290 return(LocaleCompare((*p)->path,(*q)->path));
293 #if defined(__cplusplus) || defined(c_plusplus)
297 MagickExport const ModuleInfo **GetModuleInfoList(const char *pattern,
298 size_t *number_modules,ExceptionInfo *exception)
303 register const ModuleInfo
310 Allocate module list.
312 assert(pattern != (char *) NULL);
313 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
314 assert(number_modules != (size_t *) NULL);
316 p=GetModuleInfo("*",exception);
317 if (p == (const ModuleInfo *) NULL)
318 return((const ModuleInfo **) NULL);
319 modules=(const ModuleInfo **) AcquireQuantumMemory((size_t)
320 GetNumberOfNodesInSplayTree(module_list)+1UL,sizeof(*modules));
321 if (modules == (const ModuleInfo **) NULL)
322 return((const ModuleInfo **) NULL);
324 Generate module list.
326 LockSemaphoreInfo(module_semaphore);
327 ResetSplayTreeIterator(module_list);
328 p=(const ModuleInfo *) GetNextValueInSplayTree(module_list);
329 for (i=0; p != (const ModuleInfo *) NULL; )
331 if ((p->stealth == MagickFalse) &&
332 (GlobExpression(p->tag,pattern,MagickFalse) != MagickFalse))
334 p=(const ModuleInfo *) GetNextValueInSplayTree(module_list);
336 UnlockSemaphoreInfo(module_semaphore);
337 qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleInfoCompare);
338 modules[i]=(ModuleInfo *) NULL;
339 *number_modules=(size_t) i;
344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
348 % G e t M o d u l e L i s t %
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
354 % GetModuleList() returns any image format modules that match the specified
357 % The format of the GetModuleList function is:
359 % char **GetModuleList(const char *pattern,const MagickModuleType type,
360 % size_t *number_modules,ExceptionInfo *exception)
362 % A description of each parameter follows:
364 % o pattern: Specifies a pointer to a text string containing a pattern.
366 % o type: choose from MagickImageCoderModule or MagickImageFilterModule.
368 % o number_modules: This integer returns the number of modules in the
371 % o exception: return any errors or warnings in this structure.
375 #if defined(__cplusplus) || defined(c_plusplus)
379 static int ModuleCompare(const void *x,const void *y)
387 return(LocaleCompare(*p,*q));
390 #if defined(__cplusplus) || defined(c_plusplus)
394 static inline int MagickReadDirectory(DIR *directory,struct dirent *entry,
395 struct dirent **result)
397 #if defined(MAGICKCORE_HAVE_READDIR_R)
398 return(readdir_r(directory,entry,result));
402 *result=readdir(directory);
407 MagickExport char **GetModuleList(const char *pattern,
408 const MagickModuleType type,size_t *number_modules,ExceptionInfo *exception)
412 filename[MaxTextExtent],
413 module_path[MaxTextExtent],
433 Locate all modules in the image coder or filter path.
437 case MagickImageCoderModule:
440 TagToCoderModuleName("magick",filename);
441 status=GetMagickModulePath(filename,MagickImageCoderModule,module_path,
445 case MagickImageFilterModule:
447 TagToFilterModuleName("analyze",filename);
448 status=GetMagickModulePath(filename,MagickImageFilterModule,module_path,
453 if (status == MagickFalse)
454 return((char **) NULL);
455 GetPathComponent(module_path,HeadPath,path);
457 modules=(char **) AcquireQuantumMemory((size_t) max_entries+1UL,
459 if (modules == (char **) NULL)
460 return((char **) NULL);
461 *modules=(char *) NULL;
462 directory=opendir(path);
463 if (directory == (DIR *) NULL)
465 modules=(char **) RelinquishMagickMemory(modules);
466 return((char **) NULL);
468 buffer=(struct dirent *) AcquireMagickMemory(sizeof(*buffer)+
470 if (buffer == (struct dirent *) NULL)
471 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
473 while ((MagickReadDirectory(directory,buffer,&entry) == 0) &&
474 (entry != (struct dirent *) NULL))
476 status=GlobExpression(entry->d_name,ModuleGlobExpression,MagickFalse);
477 if (status == MagickFalse)
479 if (GlobExpression(entry->d_name,pattern,MagickFalse) == MagickFalse)
481 if (i >= (ssize_t) max_entries)
483 modules=(char **) NULL;
484 if (~max_entries > max_entries)
485 modules=(char **) ResizeQuantumMemory(modules,(size_t)
486 (max_entries << 1),sizeof(*modules));
488 if (modules == (char **) NULL)
492 Add new module name to list.
494 modules[i]=AcquireString((char *) NULL);
495 GetPathComponent(entry->d_name,BasePath,modules[i]);
496 if (LocaleNCompare("IM_MOD_",modules[i],7) == 0)
498 (void) CopyMagickString(modules[i],modules[i]+10,MaxTextExtent);
499 modules[i][strlen(modules[i])-1]='\0';
503 buffer=(struct dirent *) RelinquishMagickMemory(buffer);
504 (void) closedir(directory);
505 if (modules == (char **) NULL)
507 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureError,
508 "MemoryAllocationFailed","`%s'",pattern);
509 return((char **) NULL);
511 qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleCompare);
512 modules[i]=(char *) NULL;
513 *number_modules=(size_t) i;
518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522 % G e t M a g i c k M o d u l e P a t h %
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
528 % GetMagickModulePath() finds a module with the specified module type and
531 % The format of the GetMagickModulePath module is:
533 % MagickBooleanType GetMagickModulePath(const char *filename,
534 % MagickModuleType module_type,char *path,ExceptionInfo *exception)
536 % A description of each parameter follows:
538 % o filename: the module file name.
540 % o module_type: the module type: MagickImageCoderModule or
541 % MagickImageFilterModule.
543 % o path: the path associated with the filename.
545 % o exception: return any errors or warnings in this structure.
548 static MagickBooleanType GetMagickModulePath(const char *filename,
549 MagickModuleType module_type,char *path,ExceptionInfo *exception)
554 assert(filename != (const char *) NULL);
555 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
556 assert(path != (char *) NULL);
557 assert(exception != (ExceptionInfo *) NULL);
558 (void) CopyMagickString(path,filename,MaxTextExtent);
559 module_path=(char *) NULL;
562 case MagickImageCoderModule:
565 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
566 "Searching for coder module file \"%s\" ...",filename);
567 module_path=GetEnvironmentValue("MAGICK_CODER_MODULE_PATH");
568 #if defined(MAGICKCORE_CODER_PATH)
569 if (module_path == (char *) NULL)
570 module_path=AcquireString(MAGICKCORE_CODER_PATH);
574 case MagickImageFilterModule:
576 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
577 "Searching for filter module file \"%s\" ...",filename);
578 module_path=GetEnvironmentValue("MAGICK_CODER_FILTER_PATH");
579 #if defined(MAGICKCORE_FILTER_PATH)
580 if (module_path == (char *) NULL)
581 module_path=AcquireString(MAGICKCORE_FILTER_PATH);
586 if (module_path != (char *) NULL)
592 for (p=module_path-1; p != (char *) NULL; )
594 (void) CopyMagickString(path,p+1,MaxTextExtent);
595 q=strchr(path,DirectoryListSeparator);
596 if (q != (char *) NULL)
598 q=path+strlen(path)-1;
599 if ((q >= path) && (*q != *DirectorySeparator))
600 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
601 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
602 if (IsPathAccessible(path) != MagickFalse)
604 module_path=DestroyString(module_path);
607 p=strchr(p+1,DirectoryListSeparator);
609 module_path=DestroyString(module_path);
611 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
613 #if defined(MAGICKCORE_CODER_PATH)
619 Search hard coded paths.
623 case MagickImageCoderModule:
626 directory=MAGICKCORE_CODER_PATH;
629 case MagickImageFilterModule:
631 directory=MAGICKCORE_FILTER_PATH;
635 (void) FormatMagickString(path,MaxTextExtent,"%s%s",directory,filename);
636 if (IsPathAccessible(path) == MagickFalse)
638 ThrowFileException(exception,ConfigureWarning,
639 "UnableToOpenModuleFile",path);
645 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
654 Locate path via registry key.
658 case MagickImageCoderModule:
661 registery_key="CoderModulesPath";
664 case MagickImageFilterModule:
666 registery_key="FilterModulesPath";
670 key_value=NTRegistryKeyLookup(registery_key);
671 if (key_value == (unsigned char *) NULL)
673 ThrowMagickException(exception,GetMagickModule(),ConfigureError,
674 "RegistryKeyLookupFailed","`%s'",registery_key);
677 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",(char *) key_value,
678 DirectorySeparator,filename);
679 key_value=(unsigned char *) RelinquishMagickMemory(key_value);
680 if (IsPathAccessible(path) == MagickFalse)
682 ThrowFileException(exception,ConfigureWarning,
683 "UnableToOpenModuleFile",path);
690 #if !defined(MAGICKCORE_CODER_PATH) && !defined(MAGICKCORE_WINDOWS_SUPPORT)
691 # error MAGICKCORE_CODER_PATH or MAGICKCORE_WINDOWS_SUPPORT must be defined when MAGICKCORE_INSTALLED_SUPPORT is defined
698 home=GetEnvironmentValue("MAGICK_HOME");
699 if (home != (char *) NULL)
704 #if !defined(MAGICKCORE_POSIX_SUPPORT)
705 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",home,
706 DirectorySeparator,filename);
713 case MagickImageCoderModule:
716 directory=MAGICKCORE_CODER_RELATIVE_PATH;
719 case MagickImageFilterModule:
721 directory=MAGICKCORE_FILTER_RELATIVE_PATH;
725 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",home,
728 home=DestroyString(home);
729 if (IsPathAccessible(path) != MagickFalse)
733 if (*GetClientPath() != '\0')
736 Search based on executable directory.
738 #if !defined(MAGICKCORE_POSIX_SUPPORT)
739 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
740 DirectorySeparator,filename);
743 prefix[MaxTextExtent];
750 case MagickImageCoderModule:
756 case MagickImageFilterModule:
762 (void) CopyMagickString(prefix,GetClientPath(),MaxTextExtent);
763 ChopPathComponents(prefix,1);
764 (void) FormatMagickString(path,MaxTextExtent,
765 "%s/lib/%s/modules-Q%d/%s/%s",prefix,MAGICKCORE_LIBRARY_RELATIVE_PATH,
766 MAGICKCORE_QUANTUM_DEPTH,directory,filename);
768 if (IsPathAccessible(path) != MagickFalse)
771 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
776 if ((NTGetModulePath("CORE_RL_magick_.dll",path) != MagickFalse) ||
777 (NTGetModulePath("CORE_DB_magick_.dll",path) != MagickFalse) ||
778 (NTGetModulePath("Magick.dll",path) != MagickFalse))
780 (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
781 (void) ConcatenateMagickString(path,filename,MaxTextExtent);
782 if (IsPathAccessible(path) != MagickFalse)
791 home=GetEnvironmentValue("HOME");
792 if (home == (char *) NULL)
793 home=GetEnvironmentValue("USERPROFILE");
794 if (home != (char *) NULL)
797 Search $HOME/.magick.
799 (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s%s",home,
800 DirectorySeparator,DirectorySeparator,filename);
801 home=DestroyString(home);
802 if (IsPathAccessible(path) != MagickFalse)
807 Search current directory.
809 if (IsPathAccessible(path) != MagickFalse)
811 if (exception->severity < ConfigureError)
812 ThrowFileException(exception,ConfigureWarning,"UnableToOpenModuleFile",
820 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
824 % I n i t i a l i z e M o d u l e L i s t %
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 % InitializeModuleList() initializes the module loader.
832 % The format of the InitializeModuleList() method is:
834 % InitializeModuleList(Exceptioninfo *exception)
836 % A description of each parameter follows.
838 % o exception: return any errors or warnings in this structure.
842 static void *DestroyModuleNode(void *module_info)
850 exception=AcquireExceptionInfo();
851 p=(ModuleInfo *) module_info;
852 if (UnregisterModule(p,exception) == MagickFalse)
853 CatchException(exception);
854 if (p->tag != (char *) NULL)
855 p->tag=DestroyString(p->tag);
856 if (p->path != (char *) NULL)
857 p->path=DestroyString(p->path);
858 exception=DestroyExceptionInfo(exception);
859 return(RelinquishMagickMemory(p));
862 MagickExport MagickBooleanType InitializeModuleList(
863 ExceptionInfo *magick_unused(exception))
865 if ((module_list == (SplayTreeInfo *) NULL) &&
866 (instantiate_module == MagickFalse))
868 if (module_semaphore == (SemaphoreInfo *) NULL)
869 AcquireSemaphoreInfo(&module_semaphore);
870 LockSemaphoreInfo(module_semaphore);
871 if ((module_list == (SplayTreeInfo *) NULL) &&
872 (instantiate_module == MagickFalse))
880 module_list=NewSplayTree(CompareSplayTreeString,
881 (void *(*)(void *)) NULL,DestroyModuleNode);
882 if (module_list == (SplayTreeInfo *) NULL)
883 ThrowFatalException(ResourceLimitFatalError,
884 "MemoryAllocationFailed");
885 module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
886 module_info->stealth=MagickTrue;
887 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
888 if (status == MagickFalse)
889 ThrowFatalException(ResourceLimitFatalError,
890 "MemoryAllocationFailed");
891 if (lt_dlinit() != 0)
892 ThrowFatalException(ModuleFatalError,
893 "UnableToInitializeModuleLoader");
894 instantiate_module=MagickTrue;
896 UnlockSemaphoreInfo(module_semaphore);
898 return(module_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
902 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
906 % I n v o k e D y n a m i c I m a g e F i l t e r %
910 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
912 % InvokeDynamicImageFilter() invokes a dynamic image filter.
914 % The format of the InvokeDynamicImageFilter module is:
916 % MagickBooleanType InvokeDynamicImageFilter(const char *tag,Image **image,
917 % const int argc,const char **argv,ExceptionInfo *exception)
919 % A description of each parameter follows:
921 % o tag: a character string that represents the name of the particular
924 % o image: the image.
926 % o argc: a pointer to an integer describing the number of elements in the
929 % o argv: a pointer to a text array containing the command line arguments.
931 % o exception: return any errors or warnings in this structure.
934 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
935 Image **images,const int argc,const char **argv,ExceptionInfo *exception)
956 assert(images != (Image **) NULL);
957 assert((*images)->signature == MagickSignature);
958 if ((*images)->debug != MagickFalse)
959 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
960 (*images)->filename);
961 #if !defined(MAGICKCORE_BUILD_MODULES)
966 status=InvokeStaticImageFilter(tag,images,argc,argv,exception);
967 if (status != MagickFalse)
971 rights=ReadPolicyRights;
972 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
975 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
976 "NotAuthorized","`%s'",tag);
979 TagToFilterModuleName(tag,name);
980 status=GetMagickModulePath(name,MagickImageFilterModule,path,exception);
981 if (status == MagickFalse)
983 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
984 "UnableToLoadModule","`%s': %s",name,path);
990 handle=(ModuleHandle) lt_dlopen(path);
991 if (handle == (ModuleHandle) NULL)
993 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
994 "UnableToLoadModule","`%s': %s",name,lt_dlerror());
1000 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1001 (void) FormatMagickString(name,MaxTextExtent,"%sImage",tag);
1003 (void) FormatMagickString(name,MaxTextExtent,"%s%sImage",
1004 MAGICKCORE_NAMESPACE_PREFIX,tag);
1009 ClearMagickException(exception);
1010 image_filter=(ImageFilterHandler *) lt_dlsym(handle,name);
1011 if (image_filter == (ImageFilterHandler *) NULL)
1012 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1013 "UnableToLoadModule","`%s': %s",name,lt_dlerror());
1019 if ((*images)->debug != MagickFalse)
1020 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1021 "Invoking \"%s\" dynamic image filter",tag);
1022 signature=image_filter(images,argc,argv,exception);
1023 if ((*images)->debug != MagickFalse)
1024 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),"\"%s\" completes",
1026 if (signature != MagickImageFilterSignature)
1027 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1028 "ImageFilterSignatureMismatch","`%s': %8lx != %8lx",tag,
1029 (unsigned long) signature,(unsigned long) MagickImageFilterSignature);
1034 if (lt_dlclose(handle) != 0)
1035 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1036 "UnableToCloseModule","`%s': %s",name,lt_dlerror());
1037 return(exception->severity < ErrorException ? MagickTrue : MagickFalse);
1041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1045 % L i s t M o d u l e I n f o %
1049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1051 % ListModuleInfo() lists the module info to a file.
1053 % The format of the ListModuleInfo module is:
1055 % MagickBooleanType ListModuleInfo(FILE *file,ExceptionInfo *exception)
1057 % A description of each parameter follows.
1059 % o file: An pointer to a FILE.
1061 % o exception: return any errors or warnings in this structure.
1064 MagickExport MagickBooleanType ListModuleInfo(FILE *file,
1065 ExceptionInfo *exception)
1068 filename[MaxTextExtent],
1069 module_path[MaxTextExtent],
1071 path[MaxTextExtent];
1079 if (file == (const FILE *) NULL)
1084 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1085 if (modules == (char **) NULL)
1086 return(MagickFalse);
1087 TagToCoderModuleName("magick",filename);
1088 (void) GetMagickModulePath(filename,MagickImageCoderModule,module_path,
1090 GetPathComponent(module_path,HeadPath,path);
1091 (void) fprintf(file,"\nPath: %s\n\n",path);
1092 (void) fprintf(file,"Image Coder\n");
1093 (void) fprintf(file,"-------------------------------------------------"
1094 "------------------------------\n");
1095 for (i=0; i < (ssize_t) number_modules; i++)
1097 (void) fprintf(file,"%s",modules[i]);
1098 (void) fprintf(file,"\n");
1100 (void) fflush(file);
1102 Relinquish resources.
1104 for (i=0; i < (ssize_t) number_modules; i++)
1105 modules[i]=DestroyString(modules[i]);
1106 modules=(char **) RelinquishMagickMemory(modules);
1110 modules=GetModuleList("*",MagickImageFilterModule,&number_modules,exception);
1111 if (modules == (char **) NULL)
1112 return(MagickFalse);
1113 TagToFilterModuleName("analyze",filename);
1114 (void) GetMagickModulePath(filename,MagickImageFilterModule,module_path,
1116 GetPathComponent(module_path,HeadPath,path);
1117 (void) fprintf(file,"\nPath: %s\n\n",path);
1118 (void) fprintf(file,"Image Filter\n");
1119 (void) fprintf(file,"-------------------------------------------------"
1120 "------------------------------\n");
1121 for (i=0; i < (ssize_t) number_modules; i++)
1123 (void) fprintf(file,"%s",modules[i]);
1124 (void) fprintf(file,"\n");
1126 (void) fflush(file);
1128 Relinquish resources.
1130 for (i=0; i < (ssize_t) number_modules; i++)
1131 modules[i]=DestroyString(modules[i]);
1132 modules=(char **) RelinquishMagickMemory(modules);
1137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1141 + M o d u l e C o m p o n e n t G e n e s i s %
1145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1147 % ModuleComponentGenesis() instantiates the module component.
1149 % The format of the ModuleComponentGenesis method is:
1151 % MagickBooleanType ModuleComponentGenesis(void)
1154 MagickExport MagickBooleanType ModuleComponentGenesis(void)
1162 AcquireSemaphoreInfo(&module_semaphore);
1163 exception=AcquireExceptionInfo();
1164 status=InitializeModuleList(exception);
1165 exception=DestroyExceptionInfo(exception);
1170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1174 + M o d u l e C o m p o n e n t T e r m i n u s %
1178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1180 % ModuleComponentTerminus() destroys the module component.
1182 % The format of the ModuleComponentTerminus method is:
1184 % ModuleComponentTerminus(void)
1187 MagickExport void ModuleComponentTerminus(void)
1189 if (module_semaphore == (SemaphoreInfo *) NULL)
1190 AcquireSemaphoreInfo(&module_semaphore);
1191 DestroyModuleList();
1192 DestroySemaphoreInfo(&module_semaphore);
1196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1200 % O p e n M o d u l e %
1204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1206 % OpenModule() loads a module, and invokes its registration module. It
1207 % returns MagickTrue on success, and MagickFalse if there is an error.
1209 % The format of the OpenModule module is:
1211 % MagickBooleanType OpenModule(const char *module,ExceptionInfo *exception)
1213 % A description of each parameter follows:
1215 % o module: a character string that indicates the module to load.
1217 % o exception: return any errors or warnings in this structure.
1220 MagickExport MagickBooleanType OpenModule(const char *module,
1221 ExceptionInfo *exception)
1224 filename[MaxTextExtent],
1225 module_name[MaxTextExtent],
1226 name[MaxTextExtent],
1227 path[MaxTextExtent];
1238 register const CoderInfo
1245 Assign module name from alias.
1247 assert(module != (const char *) NULL);
1248 module_info=(ModuleInfo *) GetModuleInfo(module,exception);
1249 if (module_info != (ModuleInfo *) NULL)
1251 (void) CopyMagickString(module_name,module,MaxTextExtent);
1252 p=GetCoderInfo(module,exception);
1253 if (p != (CoderInfo *) NULL)
1254 (void) CopyMagickString(module_name,p->name,MaxTextExtent);
1255 if (GetValueFromSplayTree(module_list,module_name) != (void *) NULL)
1256 return(MagickTrue); /* module already opened, return */
1260 handle=(ModuleHandle) NULL;
1261 TagToCoderModuleName(module_name,filename);
1262 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1263 "Searching for module \"%s\" using filename \"%s\"",module_name,filename);
1265 status=GetMagickModulePath(filename,MagickImageCoderModule,path,exception);
1266 if (status == MagickFalse)
1267 return(MagickFalse);
1271 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1272 "Opening module at path \"%s\"",path);
1273 handle=(ModuleHandle) lt_dlopen(path);
1274 if (handle == (ModuleHandle) NULL)
1276 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1277 "UnableToLoadModule","`%s': %s",path,lt_dlerror());
1278 return(MagickFalse);
1283 module_info=AcquireModuleInfo(path,module_name);
1284 module_info->handle=handle;
1285 if (RegisterModule(module_info,exception) == (ModuleInfo *) NULL)
1286 return(MagickFalse);
1288 Define RegisterFORMATImage method.
1290 TagToModuleName(module_name,"Register%sImage",name);
1291 module_info->register_module=(size_t (*)(void)) lt_dlsym(handle,name);
1292 if (module_info->register_module == (size_t (*)(void)) NULL)
1294 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1295 "UnableToRegisterImageFormat","`%s': %s",module_name,lt_dlerror());
1296 return(MagickFalse);
1298 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1299 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1300 (void *) module_info->register_module);
1302 Define UnregisterFORMATImage method.
1304 TagToModuleName(module_name,"Unregister%sImage",name);
1305 module_info->unregister_module=(void (*)(void)) lt_dlsym(handle,name);
1306 if (module_info->unregister_module == (void (*)(void)) NULL)
1308 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1309 "UnableToRegisterImageFormat","`%s': %s",module_name,lt_dlerror());
1310 return(MagickFalse);
1312 (void) LogMagickEvent(ModuleEvent,GetMagickModule(),
1313 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1314 (void *) module_info->unregister_module);
1315 signature=module_info->register_module();
1316 if (signature != MagickImageCoderSignature)
1318 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1319 "ImageCoderSignatureMismatch","`%s': %8lx != %8lx",module_name,
1320 (unsigned long) signature,(unsigned long) MagickImageCoderSignature);
1321 return(MagickFalse);
1327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1331 % O p e n M o d u l e s %
1335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1337 % OpenModules() loads all available modules.
1339 % The format of the OpenModules module is:
1341 % MagickBooleanType OpenModules(ExceptionInfo *exception)
1343 % A description of each parameter follows:
1345 % o exception: return any errors or warnings in this structure.
1348 MagickExport MagickBooleanType OpenModules(ExceptionInfo *exception)
1362 (void) GetMagickInfo((char *) NULL,exception);
1364 modules=GetModuleList("*",MagickImageCoderModule,&number_modules,exception);
1365 if (modules == (char **) NULL)
1366 return(MagickFalse);
1367 for (i=0; i < (ssize_t) number_modules; i++)
1368 (void) OpenModule(modules[i],exception);
1370 Relinquish resources.
1372 for (i=0; i < (ssize_t) number_modules; i++)
1373 modules[i]=DestroyString(modules[i]);
1374 modules=(char **) RelinquishMagickMemory(modules);
1379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1383 % R e g i s t e r M o d u l e %
1387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1389 % RegisterModule() adds an entry to the module list. It returns a pointer to
1390 % the registered entry on success.
1392 % The format of the RegisterModule module is:
1394 % ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1395 % ExceptionInfo *exception)
1397 % A description of each parameter follows:
1399 % o info: a pointer to the registered entry is returned.
1401 % o module_info: a pointer to the ModuleInfo structure to register.
1403 % o exception: return any errors or warnings in this structure.
1406 static const ModuleInfo *RegisterModule(const ModuleInfo *module_info,
1407 ExceptionInfo *exception)
1412 assert(module_info != (ModuleInfo *) NULL);
1413 assert(module_info->signature == MagickSignature);
1414 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1415 if (module_list == (SplayTreeInfo *) NULL)
1416 return((const ModuleInfo *) NULL);
1417 status=AddValueToSplayTree(module_list,module_info->tag,module_info);
1418 if (status == MagickFalse)
1419 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
1420 "MemoryAllocationFailed","`%s'",module_info->tag);
1421 return(module_info);
1425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1429 % T a g T o C o d e r M o d u l e N a m e %
1433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1435 % TagToCoderModuleName() munges a module tag and obtains the filename of the
1436 % corresponding module.
1438 % The format of the TagToCoderModuleName module is:
1440 % char *TagToCoderModuleName(const char *tag,char *name)
1442 % A description of each parameter follows:
1444 % o tag: a character string representing the module tag.
1446 % o name: return the module name here.
1449 static void TagToCoderModuleName(const char *tag,char *name)
1451 assert(tag != (char *) NULL);
1452 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1453 assert(name != (char *) NULL);
1454 #if defined(MAGICKCORE_LTDL_DELEGATE)
1455 (void) FormatMagickString(name,MaxTextExtent,"%s.la",tag);
1456 (void) LocaleLower(name);
1458 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1459 if (LocaleNCompare("IM_MOD_",tag,7) == 0)
1460 (void) CopyMagickString(name,tag,MaxTextExtent);
1464 (void) FormatMagickString(name,MaxTextExtent,"IM_MOD_DB_%s_.dll",tag);
1466 (void) FormatMagickString(name,MaxTextExtent,"IM_MOD_RL_%s_.dll",tag);
1474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1478 % T a g T o F i l t e r M o d u l e N a m e %
1482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1484 % TagToFilterModuleName() munges a module tag and returns the filename of the
1485 % corresponding filter module.
1487 % The format of the TagToFilterModuleName module is:
1489 % void TagToFilterModuleName(const char *tag,char name)
1491 % A description of each parameter follows:
1493 % o tag: a character string representing the module tag.
1495 % o name: return the filter name here.
1498 static void TagToFilterModuleName(const char *tag,char *name)
1500 assert(tag != (char *) NULL);
1501 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1502 assert(name != (char *) NULL);
1503 #if !defined(MAGICKCORE_LTDL_DELEGATE)
1504 (void) FormatMagickString(name,MaxTextExtent,"%s.dll",tag);
1506 (void) FormatMagickString(name,MaxTextExtent,"%s.la",tag);
1511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1515 % T a g T o M o d u l e N a m e %
1519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1521 % TagToModuleName() munges the module tag name and returns an upper-case tag
1522 % name as the input string, and a user-provided format.
1524 % The format of the TagToModuleName module is:
1526 % TagToModuleName(const char *tag,const char *format,char *module)
1528 % A description of each parameter follows:
1530 % o tag: the module tag.
1532 % o format: a sprintf-compatible format string containing %s where the
1533 % upper-case tag name is to be inserted.
1535 % o module: pointer to a destination buffer for the formatted result.
1538 static void TagToModuleName(const char *tag,const char *format,char *module)
1541 name[MaxTextExtent];
1543 assert(tag != (const char *) NULL);
1544 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tag);
1545 assert(format != (const char *) NULL);
1546 assert(module != (char *) NULL);
1547 (void) CopyMagickString(name,tag,MaxTextExtent);
1549 #if !defined(MAGICKCORE_NAMESPACE_PREFIX)
1550 (void) FormatMagickString(module,MaxTextExtent,format,name);
1554 prefix_format[MaxTextExtent];
1556 (void) FormatMagickString(prefix_format,MaxTextExtent,"%s%s",
1557 MAGICKCORE_NAMESPACE_PREFIX,format);
1558 (void) FormatMagickString(module,MaxTextExtent,prefix_format,name);
1564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1568 % U n r e g i s t e r M o d u l e %
1572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1574 % UnregisterModule() unloads a module, and invokes its de-registration module.
1575 % Returns MagickTrue on success, and MagickFalse if there is an error.
1577 % The format of the UnregisterModule module is:
1579 % MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1580 % ExceptionInfo *exception)
1582 % A description of each parameter follows:
1584 % o module_info: the module info.
1586 % o exception: return any errors or warnings in this structure.
1589 static MagickBooleanType UnregisterModule(const ModuleInfo *module_info,
1590 ExceptionInfo *exception)
1593 Locate and execute UnregisterFORMATImage module.
1595 assert(module_info != (const ModuleInfo *) NULL);
1596 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",module_info->tag);
1597 assert(exception != (ExceptionInfo *) NULL);
1598 if (module_info->unregister_module == NULL)
1600 module_info->unregister_module();
1601 if (lt_dlclose((ModuleHandle) module_info->handle) != 0)
1603 (void) ThrowMagickException(exception,GetMagickModule(),ModuleWarning,
1604 "UnableToCloseModule","`%s': %s",module_info->tag,lt_dlerror());
1605 return(MagickFalse);
1610 MagickExport MagickBooleanType ListModuleInfo(FILE *magick_unused(file),
1611 ExceptionInfo *magick_unused(exception))
1616 MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag,
1617 Image **image,const int argc,const char **argv,ExceptionInfo *exception)
1622 assert(image != (Image **) NULL);
1623 assert((*image)->signature == MagickSignature);
1624 if ((*image)->debug != MagickFalse)
1625 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1626 rights=ReadPolicyRights;
1627 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
1630 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1631 "NotAuthorized","`%s'",tag);
1632 return(MagickFalse);
1634 #if defined(MAGICKCORE_BUILD_MODULES)
1642 analyzeImage(Image **,const int,const char **,ExceptionInfo *);
1647 image_filter=(ImageFilterHandler *) NULL;
1648 if (LocaleCompare("analyze",tag) == 0)
1649 image_filter=(ImageFilterHandler *) analyzeImage;
1650 if (image_filter == (ImageFilterHandler *) NULL)
1651 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1652 "UnableToLoadModule","`%s'",tag);
1658 if ((*image)->debug != MagickFalse)
1659 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
1660 "Invoking \"%s\" static image filter",tag);
1661 signature=image_filter(image,argc,argv,exception);
1662 if ((*image)->debug != MagickFalse)
1663 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes",
1665 if (signature != MagickImageFilterSignature)
1667 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
1668 "ImageFilterSignatureMismatch","`%s': %8lx != %8lx",tag,
1669 (unsigned long) signature,(unsigned long)
1670 MagickImageFilterSignature);
1671 return(MagickFalse);