43#include "MagickCore/studio.h"
44#include "MagickCore/annotate-private.h"
45#include "MagickCore/blob.h"
46#include "MagickCore/blob-private.h"
47#include "MagickCore/cache.h"
48#include "MagickCore/cache-private.h"
49#include "MagickCore/coder-private.h"
50#include "MagickCore/client.h"
51#include "MagickCore/color-private.h"
52#include "MagickCore/configure-private.h"
53#include "MagickCore/constitute-private.h"
54#include "MagickCore/delegate-private.h"
55#include "MagickCore/draw.h"
56#include "MagickCore/exception.h"
57#include "MagickCore/exception-private.h"
58#include "MagickCore/locale-private.h"
59#include "MagickCore/log-private.h"
60#include "MagickCore/magic-private.h"
61#include "MagickCore/magick.h"
62#include "MagickCore/magick-private.h"
63#include "MagickCore/memory_.h"
64#include "MagickCore/mime-private.h"
65#include "MagickCore/monitor-private.h"
66#include "MagickCore/module.h"
67#include "MagickCore/module-private.h"
68#include "MagickCore/mutex.h"
69#include "MagickCore/nt-base-private.h"
70#include "MagickCore/nt-feature.h"
71#include "MagickCore/opencl-private.h"
72#include "MagickCore/option-private.h"
73#include "MagickCore/random-private.h"
74#include "MagickCore/registry.h"
75#include "MagickCore/registry-private.h"
76#include "MagickCore/resource_.h"
77#include "MagickCore/resource-private.h"
78#include "MagickCore/policy.h"
79#include "MagickCore/policy-private.h"
80#include "MagickCore/mutex.h"
81#include "MagickCore/semaphore.h"
82#include "MagickCore/semaphore-private.h"
83#include "MagickCore/signature-private.h"
84#include "MagickCore/splay-tree.h"
85#include "MagickCore/static.h"
86#include "MagickCore/string_.h"
87#include "MagickCore/string-private.h"
88#include "MagickCore/thread_.h"
89#include "MagickCore/thread-private.h"
90#include "MagickCore/timer-private.h"
91#include "MagickCore/type-private.h"
92#include "MagickCore/token.h"
93#include "MagickCore/utility.h"
94#include "MagickCore/utility-private.h"
95#include "MagickCore/xwindow-private.h"
101# define SIG_DFL ((SignalHandler *) 0)
104# define SIG_ERR ((SignalHandler *) -1)
113typedef void SignalHandler(
int);
122 *signal_handlers[SIGMAX] = { (SignalHandler *) NULL };
127static volatile MagickBooleanType
128 magickcore_instantiated = MagickFalse,
129 magickcore_signal_in_progress = MagickFalse,
130 magick_list_initialized = MagickFalse;
133 magick_precision = 0;
138static MagickBooleanType
172MagickExport
MagickInfo *AcquireMagickInfo(
const char *magick_module,
173 const char *name,
const char *description)
178 assert(magick_module != (
const char *) NULL);
179 assert(name != (
const char *) NULL);
180 assert(description != (
const char *) NULL);
181 if (IsEventLogging() != MagickFalse)
182 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",name);
183 magick_info=(
MagickInfo *) AcquireCriticalMemory(
sizeof(*magick_info));
184 (void) memset(magick_info,0,
sizeof(*magick_info));
185 magick_info->magick_module=ConstantString(magick_module);
186 magick_info->name=ConstantString(name);
187 magick_info->description=ConstantString(description);
188 magick_info->flags=CoderAdjoinFlag | CoderBlobSupportFlag |
189 CoderDecoderThreadSupportFlag | CoderEncoderThreadSupportFlag |
190 CoderUseExtensionFlag;
191 magick_info->signature=MagickCoreSignature;
217MagickExport DecodeImageHandler *GetImageDecoder(
const MagickInfo *magick_info)
220 return((DecodeImageHandler *) NULL);
221 assert(magick_info->signature == MagickCoreSignature);
222 return(magick_info->decoder);
247MagickExport EncodeImageHandler *GetImageEncoder(
const MagickInfo *magick_info)
250 return((EncodeImageHandler *) NULL);
251 assert(magick_info->signature == MagickCoreSignature);
252 return(magick_info->encoder);
284MagickExport MagickBooleanType GetImageMagick(
const unsigned char *magick,
285 const size_t length,
char *format)
296 assert(magick != (
const unsigned char *) NULL);
297 if (IsEventLogging() != MagickFalse)
298 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
299 exception=AcquireExceptionInfo();
300 p=GetMagickInfo(
"*",exception);
301 exception=DestroyExceptionInfo(exception);
305 LockSemaphoreInfo(magick_semaphore);
306 ResetSplayTreeIterator(magick_list);
307 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
310 if ((p->magick != (IsImageFormatHandler *) NULL) &&
311 (p->magick(magick,length) != 0))
314 (void) CopyMagickString(format,p->name,MagickPathExtent);
317 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
319 UnlockSemaphoreInfo(magick_semaphore);
345MagickExport MagickBooleanType GetMagickAdjoin(
const MagickInfo *magick_info)
348 assert(magick_info->signature == MagickCoreSignature);
349 return(((magick_info->flags & CoderAdjoinFlag) == 0) ? MagickFalse :
375MagickExport MagickBooleanType GetMagickBlobSupport(
379 assert(magick_info->signature == MagickCoreSignature);
380 return(((magick_info->flags & CoderBlobSupportFlag) == 0) ? MagickFalse :
408MagickExport MagickBooleanType GetMagickDecoderSeekableStream(
412 assert(magick_info->signature == MagickCoreSignature);
413 if ((magick_info->flags & CoderDecoderSeekableStreamFlag) == 0)
442MagickExport MagickBooleanType GetMagickDecoderThreadSupport(
446 assert(magick_info->signature == MagickCoreSignature);
447 return(((magick_info->flags & CoderDecoderThreadSupportFlag) == 0) ?
448 MagickFalse : MagickTrue);
473MagickExport
const char *GetMagickDescription(
const MagickInfo *magick_info)
476 assert(magick_info->signature == MagickCoreSignature);
477 return(magick_info->description);
504MagickExport MagickBooleanType GetMagickEncoderSeekableStream(
508 assert(magick_info->signature == MagickCoreSignature);
509 if ((magick_info->flags & CoderEncoderSeekableStreamFlag) == 0)
538MagickExport MagickBooleanType GetMagickEncoderThreadSupport(
542 assert(magick_info->signature == MagickCoreSignature);
543 return(((magick_info->flags & CoderDecoderThreadSupportFlag) == 0) ?
544 MagickFalse : MagickTrue);
570MagickExport MagickBooleanType GetMagickEndianSupport(
574 assert(magick_info->signature == MagickCoreSignature);
575 return(((magick_info->flags & CoderEndianSupportFlag) == 0) ? MagickFalse :
605MagickExport
const MagickInfo *GetMagickInfo(
const char *name,
615 if (IsMagickTreeInstantiated(exception) == MagickFalse)
618 if ((name != (
const char *) NULL) && (*name !=
'\0'))
620 LockSemaphoreInfo(magick_semaphore);
621 if (LocaleCompare(name,
"*") == 0)
622#if defined(MAGICKCORE_BUILD_MODULES)
623 (void) OpenModules(exception);
625 RegisterStaticModules();
629 magick_info=(
const MagickInfo *) GetValueFromSplayTree(magick_list,
632#if defined(MAGICKCORE_BUILD_MODULES)
633 (void) OpenModule(name,exception);
635 (void) RegisterStaticModule(name,exception);
638 UnlockSemaphoreInfo(magick_semaphore);
640 if ((name == (
const char *) NULL) || (LocaleCompare(name,
"*") == 0))
641 return((
const MagickInfo *) GetRootValueFromSplayTree(magick_list));
643 magick_info=(
const MagickInfo *) GetValueFromSplayTree(magick_list,name);
676#if defined(__cplusplus) || defined(c_plusplus)
680static int MagickInfoCompare(
const void *x,
const void *y)
688 return(LocaleCompare((*p)->name,(*q)->name));
691#if defined(__cplusplus) || defined(c_plusplus)
695MagickExport
const MagickInfo **GetMagickInfoList(
const char *pattern,
710 assert(pattern != (
char *) NULL);
711 assert(number_formats != (
size_t *) NULL);
712 if (IsEventLogging() != MagickFalse)
713 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
715 p=GetMagickInfo(
"*",exception);
718 formats=(
const MagickInfo **) AcquireQuantumMemory((
size_t)
719 GetNumberOfNodesInSplayTree(magick_list)+1UL,
sizeof(*formats));
725 LockSemaphoreInfo(magick_semaphore);
726 ResetSplayTreeIterator(magick_list);
727 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
730 if ((GetMagickStealth(p) == MagickFalse) &&
731 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
733 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
735 UnlockSemaphoreInfo(magick_semaphore);
736 qsort((
void *) formats,(
size_t) i,
sizeof(*formats),MagickInfoCompare);
738 *number_formats=(size_t) i;
770#if defined(__cplusplus) || defined(c_plusplus)
774static int MagickCompare(
const void *x,
const void *y)
782 return(LocaleCompare(*p,*q));
785#if defined(__cplusplus) || defined(c_plusplus)
789MagickExport
char **GetMagickList(
const char *pattern,
804 assert(pattern != (
char *) NULL);
805 assert(number_formats != (
size_t *) NULL);
806 if (IsEventLogging() != MagickFalse)
807 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
809 p=GetMagickInfo(
"*",exception);
811 return((
char **) NULL);
812 formats=(
char **) AcquireQuantumMemory((
size_t)
813 GetNumberOfNodesInSplayTree(magick_list)+1UL,
sizeof(*formats));
814 if (formats == (
char **) NULL)
815 return((
char **) NULL);
816 LockSemaphoreInfo(magick_semaphore);
817 ResetSplayTreeIterator(magick_list);
818 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
821 if ((GetMagickStealth(p) == MagickFalse) &&
822 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
823 formats[i++]=ConstantString(p->name);
824 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
826 UnlockSemaphoreInfo(magick_semaphore);
827 qsort((
void *) formats,(
size_t) i,
sizeof(*formats),MagickCompare);
828 formats[i]=(
char *) NULL;
829 *number_formats=(size_t) i;
855MagickExport
const char *GetMagickMimeType(
const MagickInfo *magick_info)
858 assert(magick_info->signature == MagickCoreSignature);
859 return(magick_info->mime_type);
884MagickExport
const char *GetMagickModuleName(
const MagickInfo *magick_info)
887 assert(magick_info->signature == MagickCoreSignature);
888 return(magick_info->magick_module);
913MagickExport
const char *GetMagickName(
const MagickInfo *magick_info)
916 assert(magick_info->signature == MagickCoreSignature);
917 return(magick_info->name);
939MagickExport
int GetMagickPrecision(
void)
941 if (IsEventLogging() != MagickFalse)
942 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
943 return(SetMagickPrecision(0));
968MagickExport MagickBooleanType GetMagickRawSupport(
972 assert(magick_info->signature == MagickCoreSignature);
973 return(((magick_info->flags & CoderRawSupportFlag) == 0) ? MagickFalse :
999MagickExport MagickBooleanType GetMagickStealth(
const MagickInfo *magick_info)
1002 assert(magick_info->signature == MagickCoreSignature);
1003 return(((magick_info->flags & CoderStealthFlag) == 0) ? MagickFalse :
1031MagickExport MagickBooleanType GetMagickUseExtension(
1035 assert(magick_info->signature == MagickCoreSignature);
1036 return(((magick_info->flags & CoderUseExtensionFlag) == 0) ? MagickFalse :
1064static void *DestroyMagickNode(
void *magick_info)
1070 if (p->magick_module != (
char *) NULL)
1071 p->magick_module=DestroyString(p->magick_module);
1072 if (p->note != (
char *) NULL)
1073 p->note=DestroyString(p->note);
1074 if (p->mime_type != (
char *) NULL)
1075 p->mime_type=DestroyString(p->mime_type);
1076 if (p->version != (
char *) NULL)
1077 p->version=DestroyString(p->version);
1078 if (p->description != (
char *) NULL)
1079 p->description=DestroyString(p->description);
1080 if (p->name != (
char *) NULL)
1081 p->name=DestroyString(p->name);
1083 RelinquishSemaphoreInfo(&p->semaphore);
1084 return(RelinquishMagickMemory(p));
1087static MagickBooleanType IsMagickTreeInstantiated(
ExceptionInfo *exception)
1090 if (magick_list_initialized == MagickFalse)
1093 ActivateSemaphoreInfo(&magick_semaphore);
1094 LockSemaphoreInfo(magick_semaphore);
1095 if (magick_list_initialized == MagickFalse)
1097 magick_list=NewSplayTree(CompareSplayTreeString,(
void *(*)(
void *))
1098 NULL,DestroyMagickNode);
1099#if defined(MAGICKCORE_MODULES_SUPPORT)
1100 (void) GetModuleInfo((
char *) NULL,exception);
1102 magick_list_initialized=MagickTrue;
1104 UnlockSemaphoreInfo(magick_semaphore);
1106 return(magick_list != (
SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
1132MagickPrivate MagickBooleanType IsMagickConflict(
const char *magick)
1134 assert(magick != (
char *) NULL);
1136 return(VMSIsMagickConflict(magick));
1137#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
1138 return(NTIsMagickConflict(magick));
1140 return(MagickFalse);
1168MagickExport MagickBooleanType ListMagickInfo(FILE *file,
1183 if (file == (FILE *) NULL)
1185 magick_info=GetMagickInfoList(
"*",&number_formats,exception);
1186 if (magick_info == (
const MagickInfo **) NULL)
1187 return(MagickFalse);
1188 ClearMagickException(exception);
1189#if !defined(MAGICKCORE_MODULES_SUPPORT)
1190 (void) FormatLocaleFile(file,
" Format Mode Description\n");
1192 (void) FormatLocaleFile(file,
" Format Module Mode Description\n");
1194 (void) FormatLocaleFile(file,
1195 "--------------------------------------------------------"
1196 "-----------------------\n");
1197 for (i=0; i < (ssize_t) number_formats; i++)
1199 if (GetMagickStealth(magick_info[i]) != MagickFalse)
1201 (void) FormatLocaleFile(file,
"%9s%c ",
1202 magick_info[i]->name != (
char *) NULL ? magick_info[i]->name :
"",
1203 GetMagickBlobSupport(magick_info[i]) != MagickFalse ?
'*' :
' ');
1204#if defined(MAGICKCORE_MODULES_SUPPORT)
1207 magick_module[MagickPathExtent];
1209 *magick_module=
'\0';
1210 if (magick_info[i]->magick_module != (
char *) NULL)
1211 (void) CopyMagickString(magick_module,magick_info[i]->magick_module,
1213 (void) ConcatenateMagickString(magick_module,
" ",
1215 magick_module[9]=
'\0';
1216 (void) FormatLocaleFile(file,
"%9s ",magick_module);
1219 (void) FormatLocaleFile(file,
"%c%c%c ",magick_info[i]->decoder ?
'r' :
'-',
1220 magick_info[i]->encoder ?
'w' :
'-',magick_info[i]->encoder != NULL &&
1221 GetMagickAdjoin(magick_info[i]) != MagickFalse ?
'+' :
'-');
1222 if (magick_info[i]->description != (
char *) NULL)
1223 (void) FormatLocaleFile(file,
" %s",magick_info[i]->description);
1224 if (magick_info[i]->version != (
char *) NULL)
1225 (void) FormatLocaleFile(file,
" (%s)",magick_info[i]->version);
1226 (void) FormatLocaleFile(file,
"\n");
1227 if (magick_info[i]->note != (
char *) NULL)
1232 text=StringToList(magick_info[i]->note);
1233 if (text != (
char **) NULL)
1235 for (j=0; text[j] != (
char *) NULL; j++)
1237 (void) FormatLocaleFile(file,
" %s\n",text[j]);
1238 text[j]=DestroyString(text[j]);
1240 text=(
char **) RelinquishMagickMemory(text);
1244 (void) FormatLocaleFile(file,
"\n* native blob support\n");
1245 (void) FormatLocaleFile(file,
"r read support\n");
1246 (void) FormatLocaleFile(file,
"w write support\n");
1247 (void) FormatLocaleFile(file,
"+ support for multiple images\n");
1248 (void) fflush(file);
1249 magick_info=(
const MagickInfo **) RelinquishMagickMemory((
void *)
1275MagickExport MagickBooleanType IsMagickCoreInstantiated(
void)
1277 return(magickcore_instantiated);
1298MagickPrivate MagickBooleanType MagickComponentGenesis(
void)
1301 magick_semaphore=AcquireSemaphoreInfo();
1323MagickPrivate
void MagickComponentTerminus(
void)
1326 ActivateSemaphoreInfo(&magick_semaphore);
1327 LockSemaphoreInfo(magick_semaphore);
1330 magick_list=DestroySplayTree(magick_list);
1331 magick_list_initialized=MagickFalse;
1333 UnlockSemaphoreInfo(magick_semaphore);
1334 RelinquishSemaphoreInfo(&magick_semaphore);
1364static SignalHandler *SetMagickSignalHandler(
int signal_number,
1365 SignalHandler *handler)
1367#if defined(MAGICKCORE_HAVE_SIGACTION) && defined(MAGICKCORE_HAVE_SIGEMPTYSET)
1379 sigaddset(&mask,signal_number);
1380 sigprocmask(SIG_BLOCK,&mask,NULL);
1381 action.sa_mask=mask;
1382 action.sa_handler=handler;
1384#if defined(SA_INTERRUPT)
1385 action.sa_flags|=SA_INTERRUPT;
1387#if defined(SA_ONSTACK)
1388 action.sa_flags|=SA_ONSTACK;
1390 previous_action.sa_handler=SIG_DFL;
1391 status=sigaction(signal_number,&action,&previous_action);
1394 sigprocmask(SIG_UNBLOCK,&mask,NULL);
1395 return(previous_action.sa_handler);
1397 return(signal(signal_number,handler));
1401static void MagickSignalHandler(
int signal_number)
1403 if (magickcore_signal_in_progress != MagickFalse)
1404 (void) SetMagickSignalHandler(signal_number,signal_handlers[signal_number]);
1405 magickcore_signal_in_progress=MagickTrue;
1406 AsynchronousResourceComponentTerminus();
1408 if (signal_number == SIGQUIT)
1412 if (signal_number == SIGABRT)
1416 if (signal_number == SIGBUS)
1420 if (signal_number == SIGFPE)
1424 if (signal_number == SIGSEGV)
1427#if !defined(MAGICKCORE_HAVE__EXIT)
1428 exit(signal_number);
1431 if (signal_number == SIGHUP)
1432 _exit(signal_number);
1435 if (signal_number == SIGINT)
1436 _exit(signal_number);
1438#if defined(MAGICKCORE_HAVE_RAISE)
1439 if (signal_handlers[signal_number] != MagickSignalHandler)
1440 raise(signal_number);
1442 _exit(signal_number);
1446static SignalHandler *RegisterMagickSignalHandler(
int signal_number)
1451 handler=SetMagickSignalHandler(signal_number,MagickSignalHandler);
1452 if (handler == SIG_ERR)
1454 if (handler != SIG_DFL)
1455 handler=SetMagickSignalHandler(signal_number,handler);
1457 (
void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1458 "Register handler for signal: %d",signal_number);
1462static void SetClientNameAndPath(
const char *path)
1465 execution_path[MagickPathExtent],
1466 filename[MagickPathExtent];
1468#if defined(MAGICKCORE_WINDOWS_SUPPORT)
1469 if ((path != (
const char *) NULL) && (IsPathAccessible(path) != MagickFalse))
1471 if ((path != (
const char *) NULL) && (*path == *DirectorySeparator) &&
1472 (IsPathAccessible(path) != MagickFalse))
1474 (void) CopyMagickString(execution_path,path,MagickPathExtent);
1476 (
void) GetExecutionPath(execution_path,MagickPathExtent);
1477 GetPathComponent(execution_path,TailPath,filename);
1478 (void) SetClientName(filename);
1479 GetPathComponent(execution_path,HeadPath,execution_path);
1480 (void) SetClientPath(execution_path);
1483MagickExport
void MagickCoreGenesis(
const char *path,
1484 const MagickBooleanType establish_signal_handlers)
1492#if defined(__has_feature)
1493#if __has_feature(address_sanitizer)
1494 (void) putenv(
"MAGICK_THREAD_LIMIT=1");
1497 InitializeMagickMutex();
1499 if (magickcore_instantiated != MagickFalse)
1501 UnlockMagickMutex();
1504 (void) SemaphoreComponentGenesis();
1505 (void) ExceptionComponentGenesis();
1506 SetClientNameAndPath(path);
1507 (void) LogComponentGenesis();
1508 (void) LocaleComponentGenesis();
1509 (void) RandomComponentGenesis();
1510 events=GetEnvironmentValue(
"MAGICK_DEBUG");
1511 if (events != (
char *) NULL)
1513 (void) SetLogEventMask(events);
1514 events=DestroyString(events);
1516#if defined(MAGICKCORE_WINDOWS_SUPPORT)
1519 if (establish_signal_handlers != MagickFalse)
1525 if (signal_handlers[SIGABRT] == (SignalHandler *) NULL)
1526 signal_handlers[SIGABRT]=RegisterMagickSignalHandler(SIGABRT);
1529 if (signal_handlers[SIGBUS] == (SignalHandler *) NULL)
1530 signal_handlers[SIGBUS]=RegisterMagickSignalHandler(SIGBUS);
1533 if (signal_handlers[SIGSEGV] == (SignalHandler *) NULL)
1534 signal_handlers[SIGSEGV]=RegisterMagickSignalHandler(SIGSEGV);
1537 if (signal_handlers[SIGFPE] == (SignalHandler *) NULL)
1538 signal_handlers[SIGFPE]=RegisterMagickSignalHandler(SIGFPE);
1541 if (signal_handlers[SIGHUP] == (SignalHandler *) NULL)
1542 signal_handlers[SIGHUP]=RegisterMagickSignalHandler(SIGHUP);
1545 if (signal_handlers[SIGINT] == (SignalHandler *) NULL)
1546 signal_handlers[SIGINT]=RegisterMagickSignalHandler(SIGINT);
1549 if (signal_handlers[SIGQUIT] == (SignalHandler *) NULL)
1550 signal_handlers[SIGQUIT]=RegisterMagickSignalHandler(SIGQUIT);
1553 if (signal_handlers[SIGTERM] == (SignalHandler *) NULL)
1554 signal_handlers[SIGTERM]=RegisterMagickSignalHandler(SIGTERM);
1557 if (signal_handlers[SIGXCPU] == (SignalHandler *) NULL)
1558 signal_handlers[SIGXCPU]=RegisterMagickSignalHandler(SIGXCPU);
1561 if (signal_handlers[SIGXFSZ] == (SignalHandler *) NULL)
1562 signal_handlers[SIGXFSZ]=RegisterMagickSignalHandler(SIGXFSZ);
1568 (void) ConfigureComponentGenesis();
1569 (void) PolicyComponentGenesis();
1570#if MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
1571 (void) ZeroConfigurationPolicy;
1573 (void) CacheComponentGenesis();
1574 (void) ResourceComponentGenesis();
1575 (void) CoderComponentGenesis();
1576 (void) MagickComponentGenesis();
1577#if defined(MAGICKCORE_MODULES_SUPPORT)
1578 (void) ModuleComponentGenesis();
1580 (void) DelegateComponentGenesis();
1581 (void) MagicComponentGenesis();
1582 (void) ColorComponentGenesis();
1583 (void) TypeComponentGenesis();
1584 (void) MimeComponentGenesis();
1585 (void) AnnotateComponentGenesis();
1586#if defined(MAGICKCORE_X11_DELEGATE)
1587 (void) XComponentGenesis();
1589 (void) RegistryComponentGenesis();
1590 (void) MonitorComponentGenesis();
1591 magickcore_instantiated=MagickTrue;
1592 UnlockMagickMutex();
1635MagickExport
void MagickCoreTerminus(
void)
1637 InitializeMagickMutex();
1639 if (magickcore_instantiated == MagickFalse)
1641 UnlockMagickMutex();
1644 MonitorComponentTerminus();
1645 RegistryComponentTerminus();
1646 AnnotateComponentTerminus();
1647 MimeComponentTerminus();
1648 TypeComponentTerminus();
1649#if defined(MAGICKCORE_OPENCL_SUPPORT)
1652 ColorComponentTerminus();
1653#if defined(MAGICKCORE_WINDOWS_SUPPORT)
1654 NTWindowsTerminus();
1656 MagicComponentTerminus();
1657 DelegateComponentTerminus();
1658 MagickComponentTerminus();
1659#if !defined(MAGICKCORE_BUILD_MODULES)
1660 UnregisterStaticModules();
1662#if defined(MAGICKCORE_MODULES_SUPPORT)
1663 ModuleComponentTerminus();
1665#if defined(MAGICKCORE_X11_DELEGATE)
1666 XComponentTerminus();
1668 CoderComponentTerminus();
1669 ResourceComponentTerminus();
1670 CacheComponentTerminus();
1671 PolicyComponentTerminus();
1672 ConfigureComponentTerminus();
1673 RandomComponentTerminus();
1674 LocaleComponentTerminus();
1675 LogComponentTerminus();
1676 ExceptionComponentTerminus();
1677 magickcore_instantiated=MagickFalse;
1678 UnlockMagickMutex();
1679 SemaphoreComponentTerminus();
1708MagickExport MagickBooleanType RegisterMagickInfo(
MagickInfo *magick_info)
1717 assert(magick_info->signature == MagickCoreSignature);
1718 if (IsEventLogging() != MagickFalse)
1719 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",magick_info->name);
1721 return(MagickFalse);
1722 if ((GetMagickDecoderThreadSupport(magick_info) == MagickFalse) ||
1723 (GetMagickEncoderThreadSupport(magick_info) == MagickFalse))
1724 magick_info->semaphore=AcquireSemaphoreInfo();
1725 status=AddValueToSplayTree(magick_list,magick_info->name,magick_info);
1747MagickPrivate
void ResetMagickPrecision(
void)
1781MagickExport
int SetMagickPrecision(
const int precision)
1783#define MagickPrecision (MAGICKCORE_QUANTUM_DEPTH/8+4)
1785 if (IsEventLogging() != MagickFalse)
1786 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1788 magick_precision=precision;
1789 if ((precision < 0) || (magick_precision == 0))
1795 *exception = AcquireExceptionInfo();
1797 magick_precision=MagickPrecision;
1798 limit=(
char *) GetImageRegistry(StringRegistryType,
"precision",exception);
1799 exception=DestroyExceptionInfo(exception);
1800 if (limit == (
char *) NULL)
1801 limit=GetEnvironmentValue(
"MAGICK_PRECISION");
1802 if (limit == (
char *) NULL)
1803 limit=GetPolicyValue(
"system:precision");
1804 if (limit != (
char *) NULL)
1806 magick_precision=StringToInteger(limit);
1807 limit=DestroyString(limit);
1810 return(magick_precision);
1837MagickExport MagickBooleanType UnregisterMagickInfo(
const char *name)
1845 assert(name != (
const char *) NULL);
1847 return(MagickFalse);
1848 if (GetNumberOfNodesInSplayTree(magick_list) == 0)
1849 return(MagickFalse);
1850 LockSemaphoreInfo(magick_semaphore);
1851 ResetSplayTreeIterator(magick_list);
1852 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
1855 if (LocaleCompare(p->name,name) == 0)
1857 p=(
const MagickInfo *) GetNextValueInSplayTree(magick_list);
1859 status=DeleteNodeByValueFromSplayTree(magick_list,p);
1860 UnlockSemaphoreInfo(magick_semaphore);