68 #if defined(MAGICKCORE_MODULES_SUPPORT) 69 #if defined(MAGICKCORE_LTDL_DELEGATE) 71 typedef lt_dlhandle ModuleHandle;
73 typedef void *ModuleHandle;
79 #if defined(MAGICKCORE_LTDL_DELEGATE) 80 # define ModuleGlobExpression "*.la" 83 # define ModuleGlobExpression "IM_MOD_DB_*.dll" 85 # define ModuleGlobExpression "IM_MOD_RL_*.dll" 106 IsModuleTreeInstantiated(),
110 TagToCoderModuleName(
const char *,
char *),
111 TagToFilterModuleName(
const char *,
char *),
112 TagToModuleName(
const char *,
const char *,
char *);
145 (void) memset(module_info,0,
sizeof(*module_info));
146 if (
path != (
const char *) NULL)
148 if (tag != (
const char *) NULL)
180 #if defined(MAGICKCORE_MODULES_SUPPORT) 224 if ((tag == (
const char *) NULL) || (
LocaleCompare(tag,
"*") == 0))
226 #if defined(MAGICKCORE_MODULES_SUPPORT) 267 #if defined(__cplusplus) || defined(c_plusplus) 271 static int ModuleInfoCompare(
const void *x,
const void *y)
284 #if defined(__cplusplus) || defined(c_plusplus) 303 assert(
pattern != (
char *) NULL);
305 assert(number_modules != (
size_t *) NULL);
328 qsort((
void *) modules,(
size_t) i,
sizeof(*modules),ModuleInfoCompare);
330 *number_modules=(size_t) i;
366 #if defined(__cplusplus) || defined(c_plusplus) 370 static int ModuleCompare(
const void *x,
const void *y)
381 #if defined(__cplusplus) || defined(c_plusplus) 388 #define MaxModules 511 420 TagToCoderModuleName(
"magick",filename);
427 TagToFilterModuleName(
"analyze",filename);
434 return((
char **) NULL);
436 max_entries=MaxModules;
439 if (modules == (
char **) NULL)
440 return((
char **) NULL);
441 *modules=(
char *) NULL;
443 if (directory == (
DIR *) NULL)
446 return((
char **) NULL);
449 if (buffer == (
struct dirent *) NULL)
453 (entry != (
struct dirent *) NULL))
460 if (i >= (ssize_t) max_entries)
462 modules=(
char **) NULL;
463 if (~max_entries > max_entries)
465 (max_entries << 1),
sizeof(*modules));
467 if (modules == (
char **) NULL)
478 modules[i][strlen(modules[i])-1]=
'\0';
484 if (modules == (
char **) NULL)
487 "MemoryAllocationFailed",
"`%s'",pattern);
488 return((
char **) NULL);
490 qsort((
void *) modules,(
size_t) i,
sizeof(*modules),ModuleCompare);
491 modules[i]=(
char *) NULL;
492 *number_modules=(size_t) i;
533 assert(filename != (
const char *) NULL);
535 assert(path != (
char *) NULL);
537 if (strchr(filename,
'/') != (
char *) NULL)
540 module_path=(
char *) NULL;
547 "Searching for coder module file \"%s\" ...",filename);
549 #if defined(MAGICKCORE_CODER_PATH) 550 if (module_path == (
char *) NULL)
558 "Searching for filter module file \"%s\" ...",filename);
560 #if defined(MAGICKCORE_FILTER_PATH) 561 if (module_path == (
char *) NULL)
567 if (module_path != (
char *) NULL)
573 for (p=module_path-1; p != (
char *) NULL; )
577 if (q != (
char *) NULL)
579 q=path+strlen(path)-1;
584 #if defined(MAGICKCORE_HAVE_REALPATH) 589 if (realpath(path,resolved_path) != (
char *) NULL)
602 #if defined(MAGICKCORE_INSTALLED_SUPPORT) 604 #if defined(MAGICKCORE_CODER_PATH) 617 directory=MAGICKCORE_CODER_PATH;
622 directory=MAGICKCORE_FILTER_PATH;
631 "UnableToOpenModuleFile",path);
637 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 653 registery_key=
"CoderModulesPath";
658 registery_key=
"FilterModulesPath";
662 key_value=NTRegistryKeyLookup(registery_key);
663 if (key_value == (
unsigned char *) NULL)
666 "RegistryKeyLookupFailed",
"`%s'",registery_key);
675 "UnableToOpenModuleFile",path);
682 #if !defined(MAGICKCORE_CODER_PATH) && !defined(MAGICKCORE_WINDOWS_SUPPORT) 683 # error MAGICKCORE_CODER_PATH or MAGICKCORE_WINDOWS_SUPPORT must be defined when MAGICKCORE_INSTALLED_SUPPORT is defined 691 if (home != (
char *) NULL)
696 #if !defined(MAGICKCORE_POSIX_SUPPORT) 708 directory=MAGICKCORE_CODER_RELATIVE_PATH;
713 directory=MAGICKCORE_FILTER_RELATIVE_PATH;
730 #if !defined(MAGICKCORE_POSIX_SUPPORT) 757 MAGICKCORE_MODULES_RELATIVE_PATH,directory,filename);
762 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 767 if ((NTGetModulePath(
"CORE_RL_MagickCore_.dll",path) !=
MagickFalse) ||
768 (NTGetModulePath(
"CORE_DB_MagickCore_.dll",path) !=
MagickFalse))
783 if (home == (
char *) NULL)
784 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__) 786 if (home == (
char *) NULL)
788 if (home == (
char *) NULL)
791 if (home != (
char *) NULL)
803 if (home != (
char *) NULL)
848 static void *DestroyModuleNode(
void *module_info)
860 if (p->
tag != (
char *) NULL)
862 if (p->
path != (
char *) NULL)
887 (
void *(*)(
void *)) NULL,DestroyModuleNode);
888 module_info=AcquireModuleInfo((
const char *) NULL,
"[boot-strap]");
893 "MemoryAllocationFailed");
894 if (lt_dlinit() != 0)
896 "UnableToInitializeModuleLoader");
897 module_list=splay_tree;
959 assert(images != (
Image **) NULL);
963 (*images)->filename);
969 "NotAuthorized",
"`%s'",tag);
972 #if !defined(MAGICKCORE_BUILD_MODULES) 982 TagToFilterModuleName(tag,name);
987 "UnableToLoadModule",
"'%s': %s",name,path);
993 handle=(ModuleHandle) lt_dlopen(path);
994 if (handle == (ModuleHandle) NULL)
997 "UnableToLoadModule",
"'%s': %s",name,lt_dlerror());
1003 #if !defined(MAGICKCORE_NAMESPACE_PREFIX) 1007 MAGICKCORE_NAMESPACE_PREFIX_TAG,tag);
1016 "UnableToLoadModule",
"'%s': %s",name,lt_dlerror());
1024 "Invoking \"%s\" dynamic image filter",tag);
1025 signature=image_filter(images,argc,argv,exception);
1031 "ImageFilterSignatureMismatch",
"'%s': %8lx != %8lx",tag,
1037 if (lt_dlclose(handle) != 0)
1039 "UnableToCloseModule",
"'%s': %s",name,lt_dlerror());
1082 if (file == (
const FILE *) NULL)
1088 if (modules == (
char **) NULL)
1090 TagToCoderModuleName(
"magick",filename);
1097 "-------------------------------------------------" 1098 "------------------------------\n");
1099 for (i=0; i < (ssize_t) number_modules; i++)
1104 (void) fflush(file);
1108 for (i=0; i < (ssize_t) number_modules; i++)
1115 if (modules == (
char **) NULL)
1117 TagToFilterModuleName(
"analyze",filename);
1124 "-------------------------------------------------" 1125 "------------------------------\n");
1126 for (i=0; i < (ssize_t) number_modules; i++)
1131 (void) fflush(file);
1135 for (i=0; i < (ssize_t) number_modules; i++)
1166 status=IsModuleTreeInstantiated();
1250 assert(
module != (
const char *) NULL);
1259 "NotAuthorized",
"`%s'",
module);
1271 handle=(ModuleHandle) NULL;
1272 TagToCoderModuleName(module_name,name);
1274 "Searching for module \"%s\" using filename \"%s\"",module_name,name);
1283 "Opening module at path \"%s\"",path);
1284 handle=(ModuleHandle) lt_dlopen(path);
1285 if (handle == (ModuleHandle) NULL)
1288 "UnableToLoadModule",
"'%s': %s",path,lt_dlerror());
1294 module_info=AcquireModuleInfo(path,module_name);
1295 module_info->
handle=handle;
1296 if (RegisterModule(module_info,exception) == (
ModuleInfo *) NULL)
1301 TagToModuleName(module_name,
"Register%sImage",name);
1302 module_info->
register_module=(size_t (*)(void)) lt_dlsym(handle,name);
1306 "UnableToRegisterImageFormat",
"'%s': %s",module_name,lt_dlerror());
1310 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1315 TagToModuleName(module_name,
"Unregister%sImage",name);
1320 "UnableToRegisterImageFormat",
"'%s': %s",module_name,lt_dlerror());
1324 "Method \"%s\" in module \"%s\" at address %p",name,module_name,
1330 "ImageCoderSignatureMismatch",
"'%s': %8lx != %8lx",module_name,
1376 if ((modules == (
char **) NULL) || (*modules == (
char *) NULL))
1378 if (modules != (
char **) NULL)
1382 for (i=0; i < (ssize_t) number_modules; i++)
1387 for (i=0; i < (ssize_t) number_modules; i++)
1435 "MemoryAllocationFailed",
"`%s'",module_info->
tag);
1436 return(module_info);
1464 static void TagToCoderModuleName(
const char *tag,
char *name)
1466 assert(tag != (
char *) NULL);
1468 assert(name != (
char *) NULL);
1469 #if defined(MAGICKCORE_LTDL_DELEGATE) 1473 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 1513 static void TagToFilterModuleName(
const char *tag,
char *name)
1515 assert(tag != (
char *) NULL);
1517 assert(name != (
char *) NULL);
1518 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 1520 #elif !defined(MAGICKCORE_LTDL_DELEGATE) 1555 static void TagToModuleName(
const char *tag,
const char *format,
char *
module)
1560 assert(tag != (
const char *) NULL);
1562 assert(format != (
const char *) NULL);
1563 assert(
module != (
char *) NULL);
1566 #if !defined(MAGICKCORE_NAMESPACE_PREFIX) 1574 MAGICKCORE_NAMESPACE_PREFIX_TAG,format);
1612 assert(module_info != (
const ModuleInfo *) NULL);
1618 if (lt_dlclose((ModuleHandle) module_info->
handle) != 0)
1621 "UnableToCloseModule",
"'%s': %s",module_info->
tag,lt_dlerror());
1628 #if !defined(MAGICKCORE_BUILD_MODULES) 1645 assert(image != (
Image **) NULL);
1654 "NotAuthorized",
"`%s'",tag);
1657 #if defined(MAGICKCORE_BUILD_MODULES) 1672 "UnableToLoadModule",
"`%s'",tag);
1680 "Invoking \"%s\" static image filter",tag);
1681 signature=image_filter(image,argc,argv,exception);
1688 "ImageFilterSignatureMismatch",
"'%s': %8lx != %8lx",tag,
1689 (
unsigned long) signature,(
unsigned long)
MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain, const PolicyRights rights, const char *pattern)
MagickExport size_t ConcatenateMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
#define ThrowFatalException(severity, tag)
size_t(* register_module)(void)
#define MagickImageCoderSignature
MagickExport char ** GetModuleList(const char *, const MagickModuleType, size_t *, ExceptionInfo *)
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
void(* unregister_module)(void)
MagickExport void * ResizeQuantumMemory(void *memory, const size_t count, const size_t quantum)
size_t ImageFilterHandler(Image **, const int, const char **, ExceptionInfo *)
MagickExport const void * GetNextValueInSplayTree(SplayTreeInfo *splay_tree)
MagickExport const ModuleInfo ** GetModuleInfoList(const char *, size_t *, ExceptionInfo *)
#define MagickCoreSignature
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
MagickExport void DestroyModuleList(void)
MagickExport MagickBooleanType ListModuleInfo(FILE *magick_unused(file), ExceptionInfo *magick_unused(exception))
#define MagickImageFilterSignature
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
#define DirectorySeparator
MagickExport char * AcquireString(const char *source)
MagickPrivate MagickBooleanType ModuleComponentGenesis(void)
MagickExport void LocaleLower(char *string)
MagickExport MagickBooleanType GlobExpression(const char *magick_restrict expression, const char *magick_restrict pattern, const MagickBooleanType case_insensitive)
MagickExport void * AcquireCriticalMemory(const size_t size)
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
MagickExport MagickBooleanType InvokeDynamicImageFilter(const char *tag, Image **image, const int argc, const char **argv, ExceptionInfo *exception)
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
MagickExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
#define ThrowFileException(exception, severity, tag, context)
MagickExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
MagickPrivate void ModuleComponentTerminus(void)
MagickExport ModuleInfo * GetModuleInfo(const char *, ExceptionInfo *)
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
MagickExport MagickBooleanType IsPathAccessible(const char *path)
MagickExport const MagickInfo * GetMagickInfo(const char *name, ExceptionInfo *exception)
MagickExport char * GetEnvironmentValue(const char *name)
MagickExport void CatchException(ExceptionInfo *exception)
MagickExport const void * GetValueFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
MagickPrivate MagickBooleanType OpenModules(ExceptionInfo *)
MagickExport int LocaleCompare(const char *p, const char *q)
#define GetMagickModule()
MagickExport int CompareSplayTreeString(const void *target, const void *source)
MagickBooleanType stealth
MagickExport void ClearMagickException(ExceptionInfo *exception)
MagickExport const CoderInfo * GetCoderInfo(const char *name, ExceptionInfo *exception)
MagickExport char * DestroyString(char *string)
MagickExport void * AcquireMagickMemory(const size_t size)
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
static int MagickReadDirectory(DIR *directory, struct dirent *entry, struct dirent **result)
MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
MagickExport void * RelinquishMagickMemory(void *memory)
MagickExport size_t GetNumberOfNodesInSplayTree(const SplayTreeInfo *splay_tree)
size_t analyzeImage(Image **, const int, const char **, ExceptionInfo *)
MagickPrivate void ChopPathComponents(char *, const size_t)
MagickPrivate MagickBooleanType OpenModule(const char *, ExceptionInfo *)
MagickExport MagickBooleanType InvokeStaticImageFilter(const char *, Image **, const int, const char **, ExceptionInfo *)
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
MagickExport void LocaleUpper(char *string)
MagickExport char * ConstantString(const char *source)
#define DirectoryListSeparator
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
MagickExport const char * GetClientPath(void)