*coder_semaphore = (SemaphoreInfo *) NULL;
static SplayTreeInfo
- *coder_list = (SplayTreeInfo *) NULL;
+ *coder_cache = (SplayTreeInfo *) NULL;
\f
/*
Forward declarations.
*/
static MagickBooleanType
IsCoderTreeInstantiated(ExceptionInfo *),
- LoadCoderLists(const char *,ExceptionInfo *);
+ LoadCoderCache(SplayTreeInfo *,const char *,const char *,const size_t,
+ ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e C o d e r S p l a y T r e e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireCoderCache() caches one or more coder configurations which
+% provides a mapping between coder attributes and a coder name.
+%
+% The format of the AcquireCoderCache coder is:
+%
+% SplayTreeInfo *AcquireCoderCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+
+static void *DestroyCoderNode(void *coder_info)
+{
+ register CoderInfo
+ *p;
+
+ p=(CoderInfo *) coder_info;
+ if (p->exempt == MagickFalse)
+ {
+ if (p->path != (char *) NULL)
+ p->path=DestroyString(p->path);
+ if (p->name != (char *) NULL)
+ p->name=DestroyString(p->name);
+ if (p->magick != (char *) NULL)
+ p->magick=DestroyString(p->magick);
+ }
+ return(RelinquishMagickMemory(p));
+}
+
+static SplayTreeInfo *AcquireCoderCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ MagickStatusType
+ status;
+
+ register ssize_t
+ i;
+
+ SplayTreeInfo
+ *coder_cache;
+
+ /*
+ Load external coder map.
+ */
+ coder_cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
+ DestroyCoderNode);
+ if (coder_cache == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadCoderCache(coder_cache,(const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ /*
+ Load built-in coder map.
+ */
+ for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
+ {
+ CoderInfo
+ *coder_info;
+
+ register const CoderMapInfo
+ *p;
+
+ p=CoderMap+i;
+ coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
+ if (coder_info == (CoderInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
+ continue;
+ }
+ (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
+ coder_info->path=(char *) "[built-in]";
+ coder_info->magick=(char *) p->magick;
+ coder_info->name=(char *) p->name;
+ coder_info->exempt=MagickTrue;
+ coder_info->signature=MagickSignature;
+ status&=AddValueToSplayTree(coder_cache,ConstantString(coder_info->magick),
+ coder_info);
+ if (status == MagickFalse)
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
+ }
+ return(coder_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (coder_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&coder_semaphore);
LockSemaphoreInfo(coder_semaphore);
- if (coder_list != (SplayTreeInfo *) NULL)
- coder_list=DestroySplayTree(coder_list);
+ if (coder_cache != (SplayTreeInfo *) NULL)
+ coder_cache=DestroySplayTree(coder_cache);
UnlockSemaphoreInfo(coder_semaphore);
RelinquishSemaphoreInfo(&coder_semaphore);
}
LockSemaphoreInfo(coder_semaphore);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
- ResetSplayTreeIterator(coder_list);
- coder_info=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
+ ResetSplayTreeIterator(coder_cache);
+ coder_info=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
UnlockSemaphoreInfo(coder_semaphore);
return(coder_info);
}
- coder_info=(const CoderInfo *) GetValueFromSplayTree(coder_list,name);
+ coder_info=(const CoderInfo *) GetValueFromSplayTree(coder_cache,name);
UnlockSemaphoreInfo(coder_semaphore);
return(coder_info);
}
if (p == (const CoderInfo *) NULL)
return((const CoderInfo **) NULL);
coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(coder_list)+1UL,sizeof(*coder_map));
+ GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
if (coder_map == (const CoderInfo **) NULL)
return((const CoderInfo **) NULL);
/*
Generate coder list.
*/
LockSemaphoreInfo(coder_semaphore);
- ResetSplayTreeIterator(coder_list);
- p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
+ ResetSplayTreeIterator(coder_cache);
+ p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
for (i=0; p != (const CoderInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
coder_map[i++]=p;
- p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
+ p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
}
UnlockSemaphoreInfo(coder_semaphore);
qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
if (p == (const CoderInfo *) NULL)
return((char **) NULL);
coder_map=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(coder_list)+1UL,sizeof(*coder_map));
+ GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
if (coder_map == (char **) NULL)
return((char **) NULL);
/*
Generate coder list.
*/
LockSemaphoreInfo(coder_semaphore);
- ResetSplayTreeIterator(coder_list);
- p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
+ ResetSplayTreeIterator(coder_cache);
+ p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
for (i=0; p != (const CoderInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
coder_map[i++]=ConstantString(p->name);
- p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
+ p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
}
UnlockSemaphoreInfo(coder_semaphore);
qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
*/
static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
{
- if (coder_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&coder_semaphore);
- LockSemaphoreInfo(coder_semaphore);
- if (coder_list == (SplayTreeInfo *) NULL)
- (void) LoadCoderLists(MagickCoderFilename,exception);
- UnlockSemaphoreInfo(coder_semaphore);
- return(coder_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
+ if (coder_cache == (SplayTreeInfo *) NULL)
+ {
+ if (coder_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&coder_semaphore);
+ LockSemaphoreInfo(coder_semaphore);
+ if (coder_cache == (SplayTreeInfo *) NULL)
+ (void) AcquireCoderCache(MagickCoderFilename,exception);
+ UnlockSemaphoreInfo(coder_semaphore);
+ }
+ return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadCoderList() loads the coder configuration file which provides a
+% LoadCoderCache() loads the coder configurations which provides a
% mapping between coder attributes and a coder name.
%
-% The format of the LoadCoderList coder is:
+% The format of the LoadCoderCache coder is:
%
-% MagickBooleanType LoadCoderList(const char *xml,const char *filename,
-% const size_t depth,ExceptionInfo *exception)
+% MagickBooleanType LoadCoderCache(SplayTreeInfo *coder_cache,
+% const char *xml,const char *filename,const size_t depth,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o exception: return any errors or warnings in this structure.
%
*/
-
-static void *DestroyCoderNode(void *coder_info)
-{
- register CoderInfo
- *p;
-
- p=(CoderInfo *) coder_info;
- if (p->exempt == MagickFalse)
- {
- if (p->path != (char *) NULL)
- p->path=DestroyString(p->path);
- if (p->name != (char *) NULL)
- p->name=DestroyString(p->name);
- if (p->magick != (char *) NULL)
- p->magick=DestroyString(p->magick);
- }
- return(RelinquishMagickMemory(p));
-}
-
-static MagickBooleanType LoadCoderList(const char *xml,const char *filename,
- const size_t depth,ExceptionInfo *exception)
+static MagickBooleanType LoadCoderCache(SplayTreeInfo *coder_cache,
+ const char *xml,const char *filename,const size_t depth,
+ ExceptionInfo *exception)
{
char
keyword[MaxTextExtent],
"Loading coder configuration file \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (coder_list == (SplayTreeInfo *) NULL)
- {
- coder_list=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
- DestroyCoderNode);
- if (coder_list == (SplayTreeInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
status=MagickTrue;
coder_info=(CoderInfo *) NULL;
token=AcquireString(xml);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadCoderList(xml,path,depth+1,exception);
+ status&=LoadCoderCache(coder_cache,xml,path,depth+1,
+ exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AddValueToSplayTree(coder_list,ConstantString(
+ status=AddValueToSplayTree(coder_cache,ConstantString(
coder_info->magick),coder_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
token=(char *) RelinquishMagickMemory(token);
return(status);
}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% L o a d C o d e r L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadCoderLists() loads one or more coder configuration file which
-% provides a mapping between coder attributes and a coder name.
-%
-% The format of the LoadCoderLists coder is:
-%
-% MagickBooleanType LoadCoderLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadCoderLists(const char *filename,
- ExceptionInfo *exception)
-{
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- register ssize_t
- i;
-
- /*
- Load external coder map.
- */
- if (coder_list == (SplayTreeInfo *) NULL)
- {
- coder_list=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
- DestroyCoderNode);
- if (coder_list == (SplayTreeInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
- status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadCoderList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- /*
- Load built-in coder map.
- */
- for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
- {
- CoderInfo
- *coder_info;
-
- register const CoderMapInfo
- *p;
-
- p=CoderMap+i;
- coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
- if (coder_info == (CoderInfo *) NULL)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
- continue;
- }
- (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
- coder_info->path=(char *) "[built-in]";
- coder_info->magick=(char *) p->magick;
- coder_info->name=(char *) p->name;
- coder_info->exempt=MagickTrue;
- coder_info->signature=MagickSignature;
- status&=AddValueToSplayTree(coder_list,ConstantString(coder_info->magick),
- coder_info);
- if (status == MagickFalse)
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
- }
- return(status != 0 ? MagickTrue : MagickFalse);
-}
Static declarations.
*/
static LinkedListInfo
- *color_list = (LinkedListInfo *) NULL;
+ *color_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*color_semaphore = (SemaphoreInfo *) NULL;
Forward declarations.
*/
static MagickBooleanType
- IsColorListInstantiated(ExceptionInfo *),
- LoadColorLists(const char *,ExceptionInfo *);
+ IsColorCacheInstantiated(ExceptionInfo *),
+ LoadColorCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e C o l o r C a c h e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireColorCache() caches one or more color configurations which provides a
+% mapping between color attributes and a color name.
+%
+% The format of the AcquireColorCache method is:
+%
+% LinkedListInfo *AcquireColorCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static LinkedListInfo *AcquireColorCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *color_cache,
+ *options;
+
+ MagickStatusType
+ status;
+
+ register ssize_t
+ i;
+
+ /*
+ Load external color map.
+ */
+ color_cache=NewLinkedList(0);
+ if (color_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadColorCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ /*
+ Load built-in color map.
+ */
+ for (i=0; i < (ssize_t) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
+ {
+ ColorInfo
+ *color_info;
+
+ register const ColorMapInfo
+ *p;
+
+ p=ColorMap+i;
+ color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
+ if (color_info == (ColorInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
+ continue;
+ }
+ (void) ResetMagickMemory(color_info,0,sizeof(*color_info));
+ color_info->path=(char *) "[built-in]";
+ color_info->name=(char *) p->name;
+ GetPixelInfo((Image *) NULL,&color_info->color);
+ color_info->color.red=(double) ScaleCharToQuantum(p->red);
+ color_info->color.green=(double) ScaleCharToQuantum(p->green);
+ color_info->color.blue=(double) ScaleCharToQuantum(p->blue);
+ color_info->color.alpha=(double) (QuantumRange*p->alpha);
+ color_info->compliance=(ComplianceType) p->compliance;
+ color_info->exempt=MagickTrue;
+ color_info->signature=MagickSignature;
+ status&=AppendValueToLinkedList(color_cache,color_info);
+ if (IfMagickFalse(status))
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
+ }
+ return(color_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (color_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&color_semaphore);
LockSemaphoreInfo(color_semaphore);
- if (color_list != (LinkedListInfo *) NULL)
- color_list=DestroyLinkedList(color_list,DestroyColorElement);
+ if (color_cache != (LinkedListInfo *) NULL)
+ color_cache=DestroyLinkedList(color_cache,DestroyColorElement);
UnlockSemaphoreInfo(color_semaphore);
RelinquishSemaphoreInfo(&color_semaphore);
}
*q;
assert(exception != (ExceptionInfo *) NULL);
- if (color_list == (LinkedListInfo *) NULL)
- if (IfMagickFalse(IsColorListInstantiated(exception)))
+ if (color_cache == (LinkedListInfo *) NULL)
+ if (IfMagickFalse(IsColorCacheInstantiated(exception)))
return((const ColorInfo *) NULL);
/*
Strip names of whitespace.
Search for color tag.
*/
LockSemaphoreInfo(color_semaphore);
- ResetLinkedListIterator(color_list);
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ ResetLinkedListIterator(color_cache);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
UnlockSemaphoreInfo(color_semaphore);
if (((p->compliance & compliance) != 0) &&
(LocaleCompare(colorname,p->name) == 0))
break;
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
}
if (p == (ColorInfo *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
"UnrecognizedColor","`%s'",name);
else
- (void) InsertValueInLinkedList(color_list,0,
- RemoveElementByValueFromLinkedList(color_list,p));
+ (void) InsertValueInLinkedList(color_cache,0,
+ RemoveElementByValueFromLinkedList(color_cache,p));
UnlockSemaphoreInfo(color_semaphore);
return(p);
}
if (p == (const ColorInfo *) NULL)
return((const ColorInfo **) NULL);
colors=(const ColorInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(color_list)+1UL,sizeof(*colors));
+ GetNumberOfElementsInLinkedList(color_cache)+1UL,sizeof(*colors));
if (colors == (const ColorInfo **) NULL)
return((const ColorInfo **) NULL);
/*
Generate color list.
*/
LockSemaphoreInfo(color_semaphore);
- ResetLinkedListIterator(color_list);
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ ResetLinkedListIterator(color_cache);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
for (i=0; p != (const ColorInfo *) NULL; )
{
if (IsMagickFalse(p->stealth) &&
IsMagickTrue(GlobExpression(p->name,pattern,MagickFalse)))
colors[i++]=p;
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
}
UnlockSemaphoreInfo(color_semaphore);
qsort((void *) colors,(size_t) i,sizeof(*colors),ColorInfoCompare);
if (p == (const ColorInfo *) NULL)
return((char **) NULL);
colors=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(color_list)+1UL,sizeof(*colors));
+ GetNumberOfElementsInLinkedList(color_cache)+1UL,sizeof(*colors));
if (colors == (char **) NULL)
return((char **) NULL);
/*
Generate color list.
*/
LockSemaphoreInfo(color_semaphore);
- ResetLinkedListIterator(color_list);
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ ResetLinkedListIterator(color_cache);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
for (i=0; p != (const ColorInfo *) NULL; )
{
if (IsMagickFalse(p->stealth) &&
IsMagickTrue(GlobExpression(p->name,pattern,MagickFalse)))
colors[i++]=ConstantString(p->name);
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
}
UnlockSemaphoreInfo(color_semaphore);
qsort((void *) colors,(size_t) i,sizeof(*colors),ColorCompare);
% %
% %
% %
-+ I s C o l o r L i s t I n s t a n t i a t e d %
++ I s C o l o r C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsColorListInstantiated() determines if the color list is instantiated. If
+% IsColorCacheInstantiated() determines if the color list is instantiated. If
% not, it instantiates the list and returns it.
%
% The format of the IsColorInstantiated method is:
%
-% MagickBooleanType IsColorListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsColorCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsColorListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsColorCacheInstantiated(ExceptionInfo *exception)
{
- if (color_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&color_semaphore);
- LockSemaphoreInfo(color_semaphore);
- if (color_list == (LinkedListInfo *) NULL)
- (void) LoadColorLists(ColorFilename,exception);
- UnlockSemaphoreInfo(color_semaphore);
- return(color_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
+ if (color_cache == (LinkedListInfo *) NULL)
+ {
+ if (color_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&color_semaphore);
+ LockSemaphoreInfo(color_semaphore);
+ if (color_cache == (LinkedListInfo *) NULL)
+ color_cache=AcquireColorCache(ColorFilename,exception);
+ UnlockSemaphoreInfo(color_semaphore);
+ }
+ return(color_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadColorList() loads the color configuration file which provides a mapping
+% LoadColorCache() loads the color configurations which provides a mapping
% between color attributes and a color name.
%
-% The format of the LoadColorList method is:
+% The format of the LoadColorCache method is:
%
-% MagickBooleanType LoadColorList(const char *xml,const char *filename,
+% MagickBooleanType LoadColorCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadColorList(const char *xml,const char *filename,
+static MagickBooleanType LoadColorCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
"Loading color file \"%s\" ...",filename);
if (xml == (char *) NULL)
return(MagickFalse);
- if (color_list == (LinkedListInfo *) NULL)
+ if (color_cache == (LinkedListInfo *) NULL)
{
- color_list=NewLinkedList(0);
- if (color_list == (LinkedListInfo *) NULL)
+ color_cache=NewLinkedList(0);
+ if (color_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadColorList(xml,path,depth+1,exception);
+ status=LoadColorCache(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AppendValueToLinkedList(color_list,color_info);
+ status=AppendValueToLinkedList(color_cache,color_info);
if (IfMagickFalse(status))
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
% %
% %
% %
-% L o a d C o l o r L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadColorList() loads one or more color configuration file which provides a
-% mapping between color attributes and a color name.
-%
-% The format of the LoadColorLists method is:
-%
-% MagickBooleanType LoadColorLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadColorLists(const char *filename,
- ExceptionInfo *exception)
-{
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- register ssize_t
- i;
-
- /*
- Load external color map.
- */
- if (color_list == (LinkedListInfo *) NULL)
- {
- color_list=NewLinkedList(0);
- if (color_list == (LinkedListInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
- status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadColorList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- /*
- Load built-in color map.
- */
- for (i=0; i < (ssize_t) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
- {
- ColorInfo
- *color_info;
-
- register const ColorMapInfo
- *p;
-
- p=ColorMap+i;
- color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
- if (color_info == (ColorInfo *) NULL)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
- continue;
- }
- (void) ResetMagickMemory(color_info,0,sizeof(*color_info));
- color_info->path=(char *) "[built-in]";
- color_info->name=(char *) p->name;
- GetPixelInfo((Image *) NULL,&color_info->color);
- color_info->color.red=(double) ScaleCharToQuantum(p->red);
- color_info->color.green=(double) ScaleCharToQuantum(p->green);
- color_info->color.blue=(double) ScaleCharToQuantum(p->blue);
- color_info->color.alpha=(double) (QuantumRange*p->alpha);
- color_info->compliance=(ComplianceType) p->compliance;
- color_info->exempt=MagickTrue;
- color_info->signature=MagickSignature;
- status&=AppendValueToLinkedList(color_list,color_info);
- if (IfMagickFalse(status))
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
- }
- return(status != 0 ? MagickTrue : MagickFalse);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ Q u e r y C o l o r C o m p l i a n c e %
% %
% %
return(MagickFalse);
alpha=color->alpha_trait == BlendPixelTrait ? color->alpha : OpaqueAlpha;
(void) GetColorInfo("*",exception);
- ResetLinkedListIterator(color_list);
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ ResetLinkedListIterator(color_cache);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
while (p != (const ColorInfo *) NULL)
{
if (((p->compliance & compliance) != 0) &&
(void) CopyMagickString(name,p->name,MaxTextExtent);
break;
}
- p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
+ p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
}
return(MagickTrue);
}
};
static LinkedListInfo
- *configure_list = (LinkedListInfo *) NULL;
+ *configure_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*configure_semaphore = (SemaphoreInfo *) NULL;
Forward declarations.
*/
static MagickBooleanType
- IsConfigureListInstantiated(ExceptionInfo *),
- LoadConfigureLists(const char *,ExceptionInfo *);
+ IsConfigureCacheInstantiated(ExceptionInfo *),
+ LoadConfigureCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e C o n f i g u r e C a c h e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireConfigureCache() caches one or more configure configuration files which
+% provides a mapping between configure attributes and a configure name.
+%
+% The format of the AcquireConfigureCache method is:
+%
+% LinkedListInfo *AcquireConfigureCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static LinkedListInfo *AcquireConfigureCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *configure_cache,
+ *options;
+
+ MagickStatusType
+ status;
+
+ register ssize_t
+ i;
+
+ /*
+ Load external configure map.
+ */
+ configure_cache=NewLinkedList(0);
+ if (configure_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadConfigureCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ /*
+ Load built-in configure map.
+ */
+ for (i=0; i < (ssize_t) (sizeof(ConfigureMap)/sizeof(*ConfigureMap)); i++)
+ {
+ ConfigureInfo
+ *configure_info;
+
+ register const ConfigureMapInfo
+ *p;
+
+ p=ConfigureMap+i;
+ configure_info=(ConfigureInfo *) AcquireMagickMemory(
+ sizeof(*configure_info));
+ if (configure_info == (ConfigureInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
+ continue;
+ }
+ (void) ResetMagickMemory(configure_info,0,sizeof(*configure_info));
+ configure_info->path=(char *) "[built-in]";
+ configure_info->name=(char *) p->name;
+ configure_info->value=(char *) p->value;
+ configure_info->exempt=MagickTrue;
+ configure_info->signature=MagickSignature;
+ status&=AppendValueToLinkedList(configure_cache,configure_info);
+ if (status == MagickFalse)
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ configure_info->name);
+ }
+ return(configure_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (configure_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&configure_semaphore);
LockSemaphoreInfo(configure_semaphore);
- if (configure_list != (LinkedListInfo *) NULL)
- configure_list=DestroyLinkedList(configure_list,DestroyConfigureElement);
- configure_list=(LinkedListInfo *) NULL;
+ if (configure_cache != (LinkedListInfo *) NULL)
+ configure_cache=DestroyLinkedList(configure_cache,DestroyConfigureElement);
+ configure_cache=(LinkedListInfo *) NULL;
UnlockSemaphoreInfo(configure_semaphore);
RelinquishSemaphoreInfo(&configure_semaphore);
}
*p;
assert(exception != (ExceptionInfo *) NULL);
- if (IsConfigureListInstantiated(exception) == MagickFalse)
+ if (IsConfigureCacheInstantiated(exception) == MagickFalse)
return((const ConfigureInfo *) NULL);
/*
Search for configure tag.
*/
LockSemaphoreInfo(configure_semaphore);
- ResetLinkedListIterator(configure_list);
- p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
+ ResetLinkedListIterator(configure_cache);
+ p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_cache);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
UnlockSemaphoreInfo(configure_semaphore);
{
if (LocaleCompare(name,p->name) == 0)
break;
- p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
+ p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_cache);
}
if (p != (ConfigureInfo *) NULL)
- (void) InsertValueInLinkedList(configure_list,0,
- RemoveElementByValueFromLinkedList(configure_list,p));
+ (void) InsertValueInLinkedList(configure_cache,0,
+ RemoveElementByValueFromLinkedList(configure_cache,p));
UnlockSemaphoreInfo(configure_semaphore);
return(p);
}
if (p == (const ConfigureInfo *) NULL)
return((const ConfigureInfo **) NULL);
options=(const ConfigureInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options));
+ GetNumberOfElementsInLinkedList(configure_cache)+1UL,sizeof(*options));
if (options == (const ConfigureInfo **) NULL)
return((const ConfigureInfo **) NULL);
/*
Generate configure list.
*/
LockSemaphoreInfo(configure_semaphore);
- ResetLinkedListIterator(configure_list);
- p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
+ ResetLinkedListIterator(configure_cache);
+ p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_cache);
for (i=0; p != (const ConfigureInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
options[i++]=p;
- p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
+ p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_cache);
}
UnlockSemaphoreInfo(configure_semaphore);
qsort((void *) options,(size_t) i,sizeof(*options),ConfigureInfoCompare);
if (p == (const ConfigureInfo *) NULL)
return((char **) NULL);
options=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options));
+ GetNumberOfElementsInLinkedList(configure_cache)+1UL,sizeof(*options));
if (options == (char **) NULL)
return((char **) NULL);
LockSemaphoreInfo(configure_semaphore);
- ResetLinkedListIterator(configure_list);
- p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
+ ResetLinkedListIterator(configure_cache);
+ p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_cache);
for (i=0; p != (const ConfigureInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
options[i++]=ConstantString(p->name);
- p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
+ p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_cache);
}
UnlockSemaphoreInfo(configure_semaphore);
qsort((void *) options,(size_t) i,sizeof(*options),ConfigureCompare);
% %
% %
% %
-+ I s C o n f i g u r e L i s t I n s t a n t i a t e d %
++ I s C o n f i g u r e C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsConfigureListInstantiated() determines if the configure list is
+% IsConfigureCacheInstantiated() determines if the configure list is
% instantiated. If not, it instantiates the list and returns it.
%
% The format of the IsConfigureInstantiated method is:
%
-% MagickBooleanType IsConfigureListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsConfigureCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsConfigureListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsConfigureCacheInstantiated(ExceptionInfo *exception)
{
- if (configure_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&configure_semaphore);
- LockSemaphoreInfo(configure_semaphore);
- if (configure_list == (LinkedListInfo *) NULL)
- (void) LoadConfigureLists(ConfigureFilename,exception);
- UnlockSemaphoreInfo(configure_semaphore);
- return(configure_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
+ if (configure_cache == (LinkedListInfo *) NULL)
+ {
+ if (configure_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&configure_semaphore);
+ LockSemaphoreInfo(configure_semaphore);
+ if (configure_cache == (LinkedListInfo *) NULL)
+ configure_cache=AcquireConfigureCache(ConfigureFilename,exception);
+ UnlockSemaphoreInfo(configure_semaphore);
+ }
+ return(configure_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadConfigureList() loads the configure configuration file which provides a
+% LoadConfigureCache() loads the configure configurations which provides a
% mapping between configure attributes and a configure name.
%
-% The format of the LoadConfigureList method is:
+% The format of the LoadConfigureCache method is:
%
-% MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
+% MagickBooleanType LoadConfigureCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
+static MagickBooleanType LoadConfigureCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
*/
(void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
"Loading configure file \"%s\" ...",filename);
- if (configure_list == (LinkedListInfo *) NULL)
+ if (configure_cache == (LinkedListInfo *) NULL)
{
- configure_list=NewLinkedList(0);
- if (configure_list == (LinkedListInfo *) NULL)
+ configure_cache=NewLinkedList(0);
+ if (configure_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadConfigureList(xml,path,depth+1,exception);
+ status=LoadConfigureCache(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AppendValueToLinkedList(configure_list,configure_info);
+ status=AppendValueToLinkedList(configure_cache,configure_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
token=(char *) RelinquishMagickMemory(token);
return(status);
}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% L o a d C o n f i g u r e L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadConfigureList() loads one or more configure configuration files which
-% provides a mapping between configure attributes and a configure name.
-%
-% The format of the LoadConfigureLists method is:
-%
-% MagickBooleanType LoadConfigureLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadConfigureLists(const char *filename,
- ExceptionInfo *exception)
-{
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- register ssize_t
- i;
-
- /*
- Load external configure map.
- */
- if (configure_list == (LinkedListInfo *) NULL)
- {
- configure_list=NewLinkedList(0);
- if (configure_list == (LinkedListInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
- status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadConfigureList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- /*
- Load built-in configure map.
- */
- for (i=0; i < (ssize_t) (sizeof(ConfigureMap)/sizeof(*ConfigureMap)); i++)
- {
- ConfigureInfo
- *configure_info;
-
- register const ConfigureMapInfo
- *p;
-
- p=ConfigureMap+i;
- configure_info=(ConfigureInfo *) AcquireMagickMemory(
- sizeof(*configure_info));
- if (configure_info == (ConfigureInfo *) NULL)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
- continue;
- }
- (void) ResetMagickMemory(configure_info,0,sizeof(*configure_info));
- configure_info->path=(char *) "[built-in]";
- configure_info->name=(char *) p->name;
- configure_info->value=(char *) p->value;
- configure_info->exempt=MagickTrue;
- configure_info->signature=MagickSignature;
- status&=AppendValueToLinkedList(configure_list,configure_info);
- if (status == MagickFalse)
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
- configure_info->name);
- }
- return(status != 0 ? MagickTrue : MagickFalse);
-}
Global declaractions.
*/
static LinkedListInfo
- *delegate_list = (LinkedListInfo *) NULL;
+ *delegate_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*delegate_semaphore = (SemaphoreInfo *) NULL;
Forward declaractions.
*/
static MagickBooleanType
- IsDelegateListInstantiated(ExceptionInfo *),
- LoadDelegateLists(const char *,ExceptionInfo *);
+ IsDelegateCacheInstantiated(ExceptionInfo *),
+ LoadDelegateCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e D e l e g a t e C a c h e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireDelegateCache() caches one or more delegate configurations which
+% provides a mapping between delegate attributes and a delegate name.
+%
+% The format of the AcquireDelegateCache method is:
+%
+% LinkedListInfo *AcquireDelegateCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static LinkedListInfo *AcquireDelegateCache(const char *filename,
+ ExceptionInfo *exception)
+{
+#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
+ return(LoadDelegateCache(DelegateMap,"built-in",0,exception));
+#else
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *delegate_cache,
+ *options;
+
+ MagickStatusType
+ status;
+
+ delegate_cache=NewLinkedList(0);
+ if (delegate_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadDelegateCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ if ((delegate_cache == (LinkedListInfo *) NULL) ||
+ (IfMagickTrue(IsLinkedListEmpty(delegate_cache))))
+ status&=LoadDelegateCache(DelegateMap,"built-in",0,exception);
+ return(delegate_cache);
+#endif
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (delegate_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&delegate_semaphore);
LockSemaphoreInfo(delegate_semaphore);
- if (delegate_list != (LinkedListInfo *) NULL)
- delegate_list=DestroyLinkedList(delegate_list,DestroyDelegate);
+ if (delegate_cache != (LinkedListInfo *) NULL)
+ delegate_cache=DestroyLinkedList(delegate_cache,DestroyDelegate);
UnlockSemaphoreInfo(delegate_semaphore);
RelinquishSemaphoreInfo(&delegate_semaphore);
}
*p;
assert(exception != (ExceptionInfo *) NULL);
- if (delegate_list == (LinkedListInfo *) NULL)
- if( IfMagickFalse(IsDelegateListInstantiated(exception)) )
+ if (delegate_cache == (LinkedListInfo *) NULL)
+ if( IfMagickFalse(IsDelegateCacheInstantiated(exception)) )
return((const DelegateInfo *) NULL);
/*
Search for named delegate.
*/
LockSemaphoreInfo(delegate_semaphore);
- ResetLinkedListIterator(delegate_list);
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ ResetLinkedListIterator(delegate_cache);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
if ((LocaleCompare(decode,"*") == 0) && (LocaleCompare(encode,"*") == 0))
{
UnlockSemaphoreInfo(delegate_semaphore);
{
if (LocaleCompare(p->decode,decode) == 0)
break;
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
continue;
}
if (p->mode < 0)
{
if (LocaleCompare(p->encode,encode) == 0)
break;
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
continue;
}
if (LocaleCompare(decode,p->decode) == 0)
if (LocaleCompare(decode,p->decode) == 0)
if (LocaleCompare(encode,"*") == 0)
break;
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
}
if (p != (const DelegateInfo *) NULL)
- (void) InsertValueInLinkedList(delegate_list,0,
- RemoveElementByValueFromLinkedList(delegate_list,p));
+ (void) InsertValueInLinkedList(delegate_cache,0,
+ RemoveElementByValueFromLinkedList(delegate_cache,p));
UnlockSemaphoreInfo(delegate_semaphore);
return(p);
}
if (p == (const DelegateInfo *) NULL)
return((const DelegateInfo **) NULL);
delegates=(const DelegateInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(delegate_list)+1UL,sizeof(*delegates));
+ GetNumberOfElementsInLinkedList(delegate_cache)+1UL,sizeof(*delegates));
if (delegates == (const DelegateInfo **) NULL)
return((const DelegateInfo **) NULL);
/*
Generate delegate list.
*/
LockSemaphoreInfo(delegate_semaphore);
- ResetLinkedListIterator(delegate_list);
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ ResetLinkedListIterator(delegate_cache);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
for (i=0; p != (const DelegateInfo *) NULL; )
{
if( IfMagickFalse(p->stealth) &&
( IfMagickTrue(GlobExpression(p->decode,pattern,MagickFalse)) ||
IfMagickTrue(GlobExpression(p->encode,pattern,MagickFalse))) )
delegates[i++]=p;
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
}
UnlockSemaphoreInfo(delegate_semaphore);
qsort((void *) delegates,(size_t) i,sizeof(*delegates),DelegateInfoCompare);
if (p == (const DelegateInfo *) NULL)
return((char **) NULL);
delegates=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(delegate_list)+1UL,sizeof(*delegates));
+ GetNumberOfElementsInLinkedList(delegate_cache)+1UL,sizeof(*delegates));
if (delegates == (char **) NULL)
return((char **) NULL);
LockSemaphoreInfo(delegate_semaphore);
- ResetLinkedListIterator(delegate_list);
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ ResetLinkedListIterator(delegate_cache);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
for (i=0; p != (const DelegateInfo *) NULL; )
{
if( IfMagickFalse(p->stealth) &&
if( IfMagickFalse(p->stealth) &&
IfMagickTrue(GlobExpression(p->encode,pattern,MagickFalse)) )
delegates[i++]=ConstantString(p->encode);
- p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_list);
+ p=(const DelegateInfo *) GetNextValueInLinkedList(delegate_cache);
}
UnlockSemaphoreInfo(delegate_semaphore);
qsort((void *) delegates,(size_t) i,sizeof(*delegates),DelegateCompare);
% %
% %
% %
-+ I s D e l e g a t e L i s t I n s t a n t i a t e d %
++ I s D e l e g a t e C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsDelegateListInstantiated() determines if the delegate list is instantiated.
+% IsDelegateCacheInstantiated() determines if the delegate list is instantiated.
% If not, it instantiates the list and returns it.
%
% The format of the IsDelegateInstantiated method is:
%
-% MagickBooleanType IsDelegateListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsDelegateCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsDelegateListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsDelegateCacheInstantiated(ExceptionInfo *exception)
{
- if (delegate_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&delegate_semaphore);
- LockSemaphoreInfo(delegate_semaphore);
- if (delegate_list == (LinkedListInfo *) NULL)
- (void) LoadDelegateLists(DelegateFilename,exception);
- UnlockSemaphoreInfo(delegate_semaphore);
- return(IsMagickNotNULL(delegate_list));
+ if (delegate_cache == (LinkedListInfo *) NULL)
+ {
+ if (delegate_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&delegate_semaphore);
+ LockSemaphoreInfo(delegate_semaphore);
+ if (delegate_cache == (LinkedListInfo *) NULL)
+ delegate_cache=AcquireDelegateCache(DelegateFilename,exception);
+ UnlockSemaphoreInfo(delegate_semaphore);
+ }
+ return(IsMagickNotNULL(delegate_cache));
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadDelegateList() loads the delegate configuration file which provides a
+% LoadDelegateCache() loads the delegate configurations which provides a
% mapping between delegate attributes and a delegate name.
%
-% The format of the LoadDelegateList method is:
+% The format of the LoadDelegateCache method is:
%
-% MagickBooleanType LoadDelegateList(const char *xml,const char *filename,
+% MagickBooleanType LoadDelegateCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadDelegateList(const char *xml,const char *filename,
+static MagickBooleanType LoadDelegateCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
"Loading delegate configuration file \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (delegate_list == (LinkedListInfo *) NULL)
+ if (delegate_cache == (LinkedListInfo *) NULL)
{
- delegate_list=NewLinkedList(0);
- if (delegate_list == (LinkedListInfo *) NULL)
+ delegate_cache=NewLinkedList(0);
+ if (delegate_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadDelegateList(xml,path,depth+1,exception);
+ status=LoadDelegateCache(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AppendValueToLinkedList(delegate_list,delegate_info);
+ status=AppendValueToLinkedList(delegate_cache,delegate_info);
if( IfMagickFalse(status) )
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
token=(char *) RelinquishMagickMemory(token);
return(status);
}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% L o a d D e l e g a t e L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadDelegateList() loads one or more delegate configuration file which
-% provides a mapping between delegate attributes and a delegate name.
-%
-% The format of the LoadDelegateLists method is:
-%
-% MagickBooleanType LoadDelegateLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadDelegateLists(const char *filename,
- ExceptionInfo *exception)
-{
-#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- return(LoadDelegateList(DelegateMap,"built-in",0,exception));
-#else
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- status=MagickFalse;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadDelegateList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- if ((delegate_list == (LinkedListInfo *) NULL) ||
- (IfMagickTrue(IsLinkedListEmpty(delegate_list))))
- status&=LoadDelegateList(DelegateMap,"built-in",0,exception);
- return(IsMagickTrue(status!=0));
-#endif
-}
*locale_semaphore = (SemaphoreInfo *) NULL;
static SplayTreeInfo
- *locale_list = (SplayTreeInfo *) NULL;
+ *locale_cache = (SplayTreeInfo *) NULL;
#if defined(MAGICKCORE_HAVE_STRTOD_L)
static volatile locale_t
*/
static MagickBooleanType
IsLocaleTreeInstantiated(ExceptionInfo *),
- LoadLocaleLists(const char *,const char *,ExceptionInfo *);
+ LoadLocaleCache(const char *,const char *,const char *,const size_t,
+ ExceptionInfo *);
\f
#if defined(MAGICKCORE_HAVE_STRTOD_L)
/*
}
#endif
\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e L o c a l e S p l a y T r e e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireLocaleSplayTree() caches one or more locale configurations which
+% provides a mapping between locale attributes and a locale tag.
+%
+% The format of the AcquireLocaleSplayTree method is:
+%
+% SplayTreeInfo *AcquireLocaleSplayTree(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file tag.
+%
+% o locale: the actual locale.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+
+static void *DestroyLocaleNode(void *locale_info)
+{
+ register LocaleInfo
+ *p;
+
+ p=(LocaleInfo *) locale_info;
+ if (p->path != (char *) NULL)
+ p->path=DestroyString(p->path);
+ if (p->tag != (char *) NULL)
+ p->tag=DestroyString(p->tag);
+ if (p->message != (char *) NULL)
+ p->message=DestroyString(p->message);
+ return(RelinquishMagickMemory(p));
+}
+
+static SplayTreeInfo *AcquireLocaleSplayTree(const char *filename,
+ const char *locale,ExceptionInfo *exception)
+{
+#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
+ return(LoadLocaleCache(LocaleMap,"built-in",locale,0,exception));
+#else
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ MagickStatusType
+ status;
+
+ SplayTreeInfo
+ *locale_cache;
+
+ locale_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
+ DestroyLocaleNode);
+ if (locale_cache == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetLocaleOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadLocaleCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),locale,0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyLocaleOptions(options);
+ if ((locale_cache == (SplayTreeInfo *) NULL) ||
+ (GetNumberOfNodesInSplayTree(locale_cache) == 0))
+ {
+ options=GetLocaleOptions("english.xml",exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadLocaleCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),locale,0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyLocaleOptions(options);
+ }
+ if ((locale_cache == (SplayTreeInfo *) NULL) ||
+ (GetNumberOfNodesInSplayTree(locale_cache) == 0))
+ status&=LoadLocaleCache(LocaleMap,"built-in",locale,0,exception);
+ return(locale_cache);
+#endif
+}
+\f
#if defined(MAGICKCORE_HAVE_STRTOD_L)
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LockSemaphoreInfo(locale_semaphore);
if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0))
{
- ResetSplayTreeIterator(locale_list);
- locale_info=(const LocaleInfo *) GetNextValueInSplayTree(locale_list);
+ ResetSplayTreeIterator(locale_cache);
+ locale_info=(const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
UnlockSemaphoreInfo(locale_semaphore);
return(locale_info);
}
- locale_info=(const LocaleInfo *) GetValueFromSplayTree(locale_list,tag);
+ locale_info=(const LocaleInfo *) GetValueFromSplayTree(locale_cache,tag);
UnlockSemaphoreInfo(locale_semaphore);
return(locale_info);
}
if (p == (const LocaleInfo *) NULL)
return((const LocaleInfo **) NULL);
messages=(const LocaleInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(locale_list)+1UL,sizeof(*messages));
+ GetNumberOfNodesInSplayTree(locale_cache)+1UL,sizeof(*messages));
if (messages == (const LocaleInfo **) NULL)
return((const LocaleInfo **) NULL);
/*
Generate locale list.
*/
LockSemaphoreInfo(locale_semaphore);
- ResetSplayTreeIterator(locale_list);
- p=(const LocaleInfo *) GetNextValueInSplayTree(locale_list);
+ ResetSplayTreeIterator(locale_cache);
+ p=(const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
for (i=0; p != (const LocaleInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->tag,pattern,MagickTrue) != MagickFalse))
messages[i++]=p;
- p=(const LocaleInfo *) GetNextValueInSplayTree(locale_list);
+ p=(const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
}
UnlockSemaphoreInfo(locale_semaphore);
qsort((void *) messages,(size_t) i,sizeof(*messages),LocaleInfoCompare);
if (p == (const LocaleInfo *) NULL)
return((char **) NULL);
messages=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(locale_list)+1UL,sizeof(*messages));
+ GetNumberOfNodesInSplayTree(locale_cache)+1UL,sizeof(*messages));
if (messages == (char **) NULL)
return((char **) NULL);
LockSemaphoreInfo(locale_semaphore);
- p=(const LocaleInfo *) GetNextValueInSplayTree(locale_list);
+ p=(const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
for (i=0; p != (const LocaleInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->tag,pattern,MagickTrue) != MagickFalse))
messages[i++]=ConstantString(p->tag);
- p=(const LocaleInfo *) GetNextValueInSplayTree(locale_list);
+ p=(const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
}
UnlockSemaphoreInfo(locale_semaphore);
qsort((void *) messages,(size_t) i,sizeof(*messages),LocaleTagCompare);
if (locale_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&locale_semaphore);
LockSemaphoreInfo(locale_semaphore);
- if (locale_list == (SplayTreeInfo *) NULL)
+ if (locale_cache == (SplayTreeInfo *) NULL)
{
char
*locale;
locale=GetEnvironmentValue("LANG");
if (locale == (char *) NULL)
locale=ConstantString("C");
- (void) LoadLocaleLists(LocaleFilename,locale,exception);
+ locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception);
locale=DestroyString(locale);
}
UnlockSemaphoreInfo(locale_semaphore);
- return(locale_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
+ return(locale_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadLocaleList() loads the locale configuration file which provides a mapping
+% LoadLocaleCache() loads the locale configurations which provides a mapping
% between locale attributes and a locale name.
%
-% The format of the LoadLocaleList method is:
+% The format of the LoadLocaleCache method is:
%
-% MagickBooleanType LoadLocaleList(const char *xml,const char *filename,
+% MagickBooleanType LoadLocaleCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
*path='\0';
}
-static void *DestroyLocaleNode(void *locale_info)
-{
- register LocaleInfo
- *p;
-
- p=(LocaleInfo *) locale_info;
- if (p->path != (char *) NULL)
- p->path=DestroyString(p->path);
- if (p->tag != (char *) NULL)
- p->tag=DestroyString(p->tag);
- if (p->message != (char *) NULL)
- p->message=DestroyString(p->message);
- return(RelinquishMagickMemory(p));
-}
-
static void LocaleFatalErrorHandler(
const ExceptionType magick_unused(severity),
const char *reason,const char *description)
return(y);
}
-static MagickBooleanType LoadLocaleList(const char *xml,const char *filename,
+static MagickBooleanType LoadLocaleCache(const char *xml,const char *filename,
const char *locale,const size_t depth,ExceptionInfo *exception)
{
char
"Loading locale configure file \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (locale_list == (SplayTreeInfo *) NULL)
+ if (locale_cache == (SplayTreeInfo *) NULL)
{
- locale_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
+ locale_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
DestroyLocaleNode);
- if (locale_list == (SplayTreeInfo *) NULL)
+ if (locale_cache == (SplayTreeInfo *) NULL)
return(MagickFalse);
}
status=MagickTrue;
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadLocaleList(xml,path,locale,depth+1,exception);
+ status=LoadLocaleCache(xml,path,locale,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
locale_info->tag=ConstantString(tag);
locale_info->message=ConstantString(message);
locale_info->signature=MagickSignature;
- status=AddValueToSplayTree(locale_list,locale_info->tag,locale_info);
+ status=AddValueToSplayTree(locale_cache,locale_info->tag,locale_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
% %
% %
% %
-% L o a d L o c a l e L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadLocaleList() loads one or more locale configuration file which
-% provides a mapping between locale attributes and a locale tag.
-%
-% The format of the LoadLocaleLists method is:
-%
-% MagickBooleanType LoadLocaleLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file tag.
-%
-% o locale: the actual locale.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadLocaleLists(const char *filename,
- const char *locale,ExceptionInfo *exception)
-{
-#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- return(LoadLocaleList(LocaleMap,"built-in",locale,0,exception));
-#else
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- status=MagickFalse;
- options=GetLocaleOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadLocaleList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),locale,0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyLocaleOptions(options);
- if ((locale_list == (SplayTreeInfo *) NULL) ||
- (GetNumberOfNodesInSplayTree(locale_list) == 0))
- {
- options=GetLocaleOptions("english.xml",exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadLocaleList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),locale,0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyLocaleOptions(options);
- }
- if ((locale_list == (SplayTreeInfo *) NULL) ||
- (GetNumberOfNodesInSplayTree(locale_list) == 0))
- status&=LoadLocaleList(LocaleMap,"built-in",locale,0,exception);
- return(status != 0 ? MagickTrue : MagickFalse);
-#endif
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ L o c a l e C o m p o n e n t G e n e s i s %
% %
% %
if (locale_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&locale_semaphore);
LockSemaphoreInfo(locale_semaphore);
- if (locale_list != (SplayTreeInfo *) NULL)
- locale_list=DestroySplayTree(locale_list);
+ if (locale_cache != (SplayTreeInfo *) NULL)
+ locale_cache=DestroySplayTree(locale_cache);
#if defined(MAGICKCORE_HAVE_STRTOD_L)
DestroyCLocale();
#endif
log_name[MaxTextExtent] = "Magick";
static LinkedListInfo
- *log_list = (LinkedListInfo *) NULL;
+ *log_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*event_semaphore = (SemaphoreInfo *) NULL,
*GetLogInfo(const char *,ExceptionInfo *);
static MagickBooleanType
- IsLogListInstantiated(ExceptionInfo *),
- LoadLogLists(const char *,ExceptionInfo *);
+ IsLogCacheInstantiated(ExceptionInfo *),
+ LoadLogCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e L o g C a c h e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireLogCache() caches one or more log configurations which provides a
+% mapping between log attributes and log name.
+%
+% The format of the AcquireLogCache method is:
+%
+% LinkedListInfo *AcquireLogCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the log configuration filename.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static LinkedListInfo *AcquireLogCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *log_cache,
+ *options;
+
+ MagickStatusType
+ status;
+
+ register ssize_t
+ i;
+
+ /*
+ Load external log map.
+ */
+ log_cache=NewLinkedList(0);
+ if (log_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadLogCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ /*
+ Load built-in log map.
+ */
+ for (i=0; i < (ssize_t) (sizeof(LogMap)/sizeof(*LogMap)); i++)
+ {
+ LogInfo
+ *log_info;
+
+ register const LogMapInfo
+ *p;
+
+ p=LogMap+i;
+ log_info=(LogInfo *) AcquireMagickMemory(sizeof(*log_info));
+ if (log_info == (LogInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",p->filename);
+ continue;
+ }
+ (void) ResetMagickMemory(log_info,0,sizeof(*log_info));
+ log_info->path=ConstantString("[built-in]");
+ GetTimerInfo((TimerInfo *) &log_info->timer);
+ log_info->event_mask=p->event_mask;
+ log_info->handler_mask=p->handler_mask;
+ log_info->filename=ConstantString(p->filename);
+ log_info->format=ConstantString(p->format);
+ log_info->signature=MagickSignature;
+ status&=AppendValueToLinkedList(log_cache,log_info);
+ if (status == MagickFalse)
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",log_info->name);
+ }
+ return(log_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*p;
assert(exception != (ExceptionInfo *) NULL);
- if (IsLogListInstantiated(exception) == MagickFalse)
+ if (IsLogCacheInstantiated(exception) == MagickFalse)
return((LogInfo *) NULL);
/*
Search for log tag.
*/
LockSemaphoreInfo(log_semaphore);
- ResetLinkedListIterator(log_list);
- p=(LogInfo *) GetNextValueInLinkedList(log_list);
+ ResetLinkedListIterator(log_cache);
+ p=(LogInfo *) GetNextValueInLinkedList(log_cache);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
UnlockSemaphoreInfo(log_semaphore);
{
if (LocaleCompare(name,p->name) == 0)
break;
- p=(LogInfo *) GetNextValueInLinkedList(log_list);
+ p=(LogInfo *) GetNextValueInLinkedList(log_cache);
}
if (p != (LogInfo *) NULL)
- (void) InsertValueInLinkedList(log_list,0,
- RemoveElementByValueFromLinkedList(log_list,p));
+ (void) InsertValueInLinkedList(log_cache,0,
+ RemoveElementByValueFromLinkedList(log_cache,p));
UnlockSemaphoreInfo(log_semaphore);
return(p);
}
if (p == (const LogInfo *) NULL)
return((const LogInfo **) NULL);
preferences=(const LogInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(log_list)+1UL,sizeof(*preferences));
+ GetNumberOfElementsInLinkedList(log_cache)+1UL,sizeof(*preferences));
if (preferences == (const LogInfo **) NULL)
return((const LogInfo **) NULL);
/*
Generate log list.
*/
LockSemaphoreInfo(log_semaphore);
- ResetLinkedListIterator(log_list);
- p=(const LogInfo *) GetNextValueInLinkedList(log_list);
+ ResetLinkedListIterator(log_cache);
+ p=(const LogInfo *) GetNextValueInLinkedList(log_cache);
for (i=0; p != (const LogInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
preferences[i++]=p;
- p=(const LogInfo *) GetNextValueInLinkedList(log_list);
+ p=(const LogInfo *) GetNextValueInLinkedList(log_cache);
}
UnlockSemaphoreInfo(log_semaphore);
qsort((void *) preferences,(size_t) i,sizeof(*preferences),LogInfoCompare);
if (p == (const LogInfo *) NULL)
return((char **) NULL);
preferences=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(log_list)+1UL,sizeof(*preferences));
+ GetNumberOfElementsInLinkedList(log_cache)+1UL,sizeof(*preferences));
if (preferences == (char **) NULL)
return((char **) NULL);
/*
Generate log list.
*/
LockSemaphoreInfo(log_semaphore);
- ResetLinkedListIterator(log_list);
- p=(const LogInfo *) GetNextValueInLinkedList(log_list);
+ ResetLinkedListIterator(log_cache);
+ p=(const LogInfo *) GetNextValueInLinkedList(log_cache);
for (i=0; p != (const LogInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
preferences[i++]=ConstantString(p->name);
- p=(const LogInfo *) GetNextValueInLinkedList(log_list);
+ p=(const LogInfo *) GetNextValueInLinkedList(log_cache);
}
UnlockSemaphoreInfo(log_semaphore);
qsort((void *) preferences,(size_t) i,sizeof(*preferences),LogCompare);
% %
% %
% %
-+ I s L o g L i s t I n s t a n t i a t e d %
++ I s L o g C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsLogListInstantiated() determines if the log list is instantiated. If not,
+% IsLogCacheInstantiated() determines if the log list is instantiated. If not,
% it instantiates the list and returns it.
%
% The format of the IsLogInstantiated method is:
%
-% MagickBooleanType IsLogListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsLogCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsLogListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsLogCacheInstantiated(ExceptionInfo *exception)
{
- if (log_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&log_semaphore);
- LockSemaphoreInfo(log_semaphore);
- if (log_list == (LinkedListInfo *) NULL)
- (void) LoadLogLists(LogFilename,exception);
- UnlockSemaphoreInfo(log_semaphore);
- return(log_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
+ if (log_cache == (LinkedListInfo *) NULL)
+ {
+ if (log_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&log_semaphore);
+ LockSemaphoreInfo(log_semaphore);
+ if (log_cache == (LinkedListInfo *) NULL)
+ log_cache=AcquireLogCache(LogFilename,exception);
+ UnlockSemaphoreInfo(log_semaphore);
+ }
+ return(log_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
ExceptionInfo
*exception;
- if ((log_list == (LinkedListInfo *) NULL) ||
- (IsLinkedListEmpty(log_list) != MagickFalse))
+ if ((log_cache == (LinkedListInfo *) NULL) ||
+ (IsLinkedListEmpty(log_cache) != MagickFalse))
return(MagickFalse);
exception=AcquireExceptionInfo();
log_info=GetLogInfo("*",exception);
if (log_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&log_semaphore);
LockSemaphoreInfo(log_semaphore);
- if (log_list != (LinkedListInfo *) NULL)
- log_list=DestroyLinkedList(log_list,DestroyLogElement);
+ if (log_cache != (LinkedListInfo *) NULL)
+ log_cache=DestroyLinkedList(log_cache,DestroyLogElement);
UnlockSemaphoreInfo(log_semaphore);
RelinquishSemaphoreInfo(&log_semaphore);
}
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadLogList() loads the log configuration file which provides a
+% LoadLogCache() loads the log configurations which provides a
% mapping between log attributes and log name.
%
-% The format of the LoadLogList method is:
+% The format of the LoadLogCache method is:
%
-% MagickBooleanType LoadLogList(const char *xml,const char *filename,
+% MagickBooleanType LoadLogCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadLogList(const char *xml,const char *filename,
+static MagickBooleanType LoadLogCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
*/
if (xml == (const char *) NULL)
return(MagickFalse);
- if (log_list == (LinkedListInfo *) NULL)
+ if (log_cache == (LinkedListInfo *) NULL)
{
- log_list=NewLinkedList(0);
- if (log_list == (LinkedListInfo *) NULL)
+ log_cache=NewLinkedList(0);
+ if (log_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status&=LoadLogList(xml,path,depth+1,exception);
+ status&=LoadLogCache(xml,path,depth+1,exception);
xml=DestroyString(xml);
}
}
continue;
if (LocaleCompare(keyword,"</logmap>") == 0)
{
- status=AppendValueToLinkedList(log_list,log_info);
+ status=AppendValueToLinkedList(log_cache,log_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
}
}
token=DestroyString(token);
- if (log_list == (LinkedListInfo *) NULL)
+ if (log_cache == (LinkedListInfo *) NULL)
return(MagickFalse);
return(status != 0 ? MagickTrue : MagickFalse);
}
% %
% %
% %
-% L o a d L o g L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadLogLists() loads one or more log configuration file which provides a
-% mapping between log attributes and log name.
-%
-% The format of the LoadLogLists method is:
-%
-% MagickBooleanType LoadLogLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the log configuration filename.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadLogLists(const char *filename,
- ExceptionInfo *exception)
-{
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- register ssize_t
- i;
-
- /*
- Load external log map.
- */
- if (log_list == (LinkedListInfo *) NULL)
- {
- log_list=NewLinkedList(0);
- if (log_list == (LinkedListInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
- status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadLogList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- /*
- Load built-in log map.
- */
- for (i=0; i < (ssize_t) (sizeof(LogMap)/sizeof(*LogMap)); i++)
- {
- LogInfo
- *log_info;
-
- register const LogMapInfo
- *p;
-
- p=LogMap+i;
- log_info=(LogInfo *) AcquireMagickMemory(sizeof(*log_info));
- if (log_info == (LogInfo *) NULL)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",p->filename);
- continue;
- }
- (void) ResetMagickMemory(log_info,0,sizeof(*log_info));
- log_info->path=ConstantString("[built-in]");
- GetTimerInfo((TimerInfo *) &log_info->timer);
- log_info->event_mask=p->event_mask;
- log_info->handler_mask=p->handler_mask;
- log_info->filename=ConstantString(p->filename);
- log_info->format=ConstantString(p->format);
- log_info->signature=MagickSignature;
- status&=AppendValueToLinkedList(log_list,log_info);
- if (status == MagickFalse)
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",log_info->name);
- }
- return(status != 0 ? MagickTrue : MagickFalse);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ P a r s e L o g H a n d l e r s %
% %
% %
exception=DestroyExceptionInfo(exception);
option=ParseCommandOption(MagickLogEventOptions,MagickTrue,events);
LockSemaphoreInfo(log_semaphore);
- log_info=(LogInfo *) GetValueFromLinkedList(log_list,0);
+ log_info=(LogInfo *) GetValueFromLinkedList(log_cache,0);
log_info->event_mask=(LogEventType) option;
if (option == -1)
log_info->event_mask=UndefinedEvents;
log_info=(LogInfo *) GetLogInfo("*",exception);
exception=DestroyExceptionInfo(exception);
LockSemaphoreInfo(log_semaphore);
- log_info=(LogInfo *) GetValueFromLinkedList(log_list,0);
+ log_info=(LogInfo *) GetValueFromLinkedList(log_cache,0);
log_info->handler_mask=(LogHandlerType) (log_info->handler_mask |
MethodHandler);
log_info->method=method;
};
static LinkedListInfo
- *magic_list = (LinkedListInfo *) NULL;
+ *magic_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*magic_semaphore = (SemaphoreInfo *) NULL;
Forward declarations.
*/
static MagickBooleanType
- IsMagicListInstantiated(ExceptionInfo *),
- LoadMagicLists(const char *,ExceptionInfo *);
+ IsMagicCacheInstantiated(ExceptionInfo *),
+ LoadMagicCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e M a g i c L i s t s %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireMagicCache() caches one or more magic configurations which provides a
+% mapping between magic attributes and a magic name.
+%
+% The format of the AcquireMagicCache method is:
+%
+% LinkedListInfo *AcquireMagicCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static LinkedListInfo *AcquireMagicCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ char
+ path[MaxTextExtent];
+
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *magic_cache,
+ *options;
+
+ MagickStatusType
+ status;
+
+ register ssize_t
+ i;
+
+ /*
+ Load external magic map.
+ */
+ magic_cache=NewLinkedList(0);
+ if (magic_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ *path='\0';
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
+ status&=LoadMagicCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ /*
+ Load built-in magic map.
+ */
+ for (i=0; i < (ssize_t) (sizeof(MagicMap)/sizeof(*MagicMap)); i++)
+ {
+ MagicInfo
+ *magic_info;
+
+ register const MagicMapInfo
+ *p;
+
+ p=MagicMap+i;
+ magic_info=(MagicInfo *) AcquireMagickMemory(sizeof(*magic_info));
+ if (magic_info == (MagicInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
+ continue;
+ }
+ (void) ResetMagickMemory(magic_info,0,sizeof(*magic_info));
+ magic_info->path=(char *) "[built-in]";
+ magic_info->name=(char *) p->name;
+ magic_info->offset=p->offset;
+ magic_info->target=(char *) p->magic;
+ magic_info->magic=(unsigned char *) p->magic;
+ magic_info->length=p->length;
+ magic_info->exempt=MagickTrue;
+ magic_info->signature=MagickSignature;
+ status&=AppendValueToLinkedList(magic_cache,magic_info);
+ if (status == MagickFalse)
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",magic_info->name);
+ }
+ return(magic_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*p;
assert(exception != (ExceptionInfo *) NULL);
- if (IsMagicListInstantiated(exception) == MagickFalse)
- return((const MagicInfo *) NULL);
- if (length == 0)
+ if (IsMagicCacheInstantiated(exception) == MagickFalse)
return((const MagicInfo *) NULL);
/*
Search for magic tag.
*/
LockSemaphoreInfo(magic_semaphore);
- ResetLinkedListIterator(magic_list);
- p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
+ ResetLinkedListIterator(magic_cache);
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
if (magic == (const unsigned char *) NULL)
{
UnlockSemaphoreInfo(magic_semaphore);
if (((size_t) (p->offset+p->length) <= length) &&
(memcmp(magic+p->offset,p->magic,p->length) == 0))
break;
- p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
}
if (p != (const MagicInfo *) NULL)
- (void) InsertValueInLinkedList(magic_list,0,
- RemoveElementByValueFromLinkedList(magic_list,p));
+ (void) InsertValueInLinkedList(magic_cache,0,
+ RemoveElementByValueFromLinkedList(magic_cache,p));
UnlockSemaphoreInfo(magic_semaphore);
return(p);
}
if (p == (const MagicInfo *) NULL)
return((const MagicInfo **) NULL);
aliases=(const MagicInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(magic_list)+1UL,sizeof(*aliases));
+ GetNumberOfElementsInLinkedList(magic_cache)+1UL,sizeof(*aliases));
if (aliases == (const MagicInfo **) NULL)
return((const MagicInfo **) NULL);
/*
Generate magic list.
*/
LockSemaphoreInfo(magic_semaphore);
- ResetLinkedListIterator(magic_list);
- p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
+ ResetLinkedListIterator(magic_cache);
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
for (i=0; p != (const MagicInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
aliases[i++]=p;
- p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
}
UnlockSemaphoreInfo(magic_semaphore);
qsort((void *) aliases,(size_t) i,sizeof(*aliases),MagicInfoCompare);
if (p == (const MagicInfo *) NULL)
return((char **) NULL);
aliases=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(magic_list)+1UL,sizeof(*aliases));
+ GetNumberOfElementsInLinkedList(magic_cache)+1UL,sizeof(*aliases));
if (aliases == (char **) NULL)
return((char **) NULL);
LockSemaphoreInfo(magic_semaphore);
- ResetLinkedListIterator(magic_list);
- p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
+ ResetLinkedListIterator(magic_cache);
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
for (i=0; p != (const MagicInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
aliases[i++]=ConstantString(p->name);
- p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
+ p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
}
UnlockSemaphoreInfo(magic_semaphore);
qsort((void *) aliases,(size_t) i,sizeof(*aliases),MagicCompare);
% %
% %
% %
-+ I s M a g i c L i s t I n s t a n t i a t e d %
++ I s M a g i c C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsMagicListInstantiated() determines if the magic list is instantiated.
+% IsMagicCacheInstantiated() determines if the magic list is instantiated.
% If not, it instantiates the list and returns it.
%
% The format of the IsMagicInstantiated method is:
%
-% MagickBooleanType IsMagicListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsMagicCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsMagicListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsMagicCacheInstantiated(ExceptionInfo *exception)
{
- if (magic_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&magic_semaphore);
- LockSemaphoreInfo(magic_semaphore);
- if (magic_list == (LinkedListInfo *) NULL)
- (void) LoadMagicLists(MagicFilename,exception);
- UnlockSemaphoreInfo(magic_semaphore);
- return(magic_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
+ if (magic_cache == (LinkedListInfo *) NULL)
+ {
+ if (magic_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&magic_semaphore);
+ LockSemaphoreInfo(magic_semaphore);
+ if (magic_cache == (LinkedListInfo *) NULL)
+ magic_cache=AcquireMagicCache(MagicFilename,exception);
+ UnlockSemaphoreInfo(magic_semaphore);
+ }
+ return(magic_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadMagicList() loads the magic configuration file which provides a mapping
+% LoadMagicCache() loads the magic configurations which provides a mapping
% between magic attributes and a magic name.
%
-% The format of the LoadMagicList method is:
+% The format of the LoadMagicCache method is:
%
-% MagickBooleanType LoadMagicList(const char *xml,const char *filename,
+% MagickBooleanType LoadMagicCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadMagicList(const char *xml,const char *filename,
+static MagickBooleanType LoadMagicCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
"Loading magic configure file \"%s\" ...",filename);
if (xml == (char *) NULL)
return(MagickFalse);
- if (magic_list == (LinkedListInfo *) NULL)
+ if (magic_cache == (LinkedListInfo *) NULL)
{
- magic_list=NewLinkedList(0);
- if (magic_list == (LinkedListInfo *) NULL)
+ magic_cache=NewLinkedList(0);
+ if (magic_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadMagicList(xml,path,depth+1,exception);
+ status=LoadMagicCache(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AppendValueToLinkedList(magic_list,magic_info);
+ status=AppendValueToLinkedList(magic_cache,magic_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
% %
% %
% %
-% L o a d M a g i c L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadMagicLists() loads one or more magic configuration file which provides a
-% mapping between magic attributes and a magic name.
-%
-% The format of the LoadMagicLists method is:
-%
-% MagickBooleanType LoadMagicLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadMagicLists(const char *filename,
- ExceptionInfo *exception)
-{
- char
- path[MaxTextExtent];
-
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- register ssize_t
- i;
-
- /*
- Load external magic map.
- */
- if (magic_list == (LinkedListInfo *) NULL)
- {
- magic_list=NewLinkedList(0);
- if (magic_list == (LinkedListInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
- status=MagickTrue;
- *path='\0';
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
- status&=LoadMagicList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- /*
- Load built-in magic map.
- */
- for (i=0; i < (ssize_t) (sizeof(MagicMap)/sizeof(*MagicMap)); i++)
- {
- MagicInfo
- *magic_info;
-
- register const MagicMapInfo
- *p;
-
- p=MagicMap+i;
- magic_info=(MagicInfo *) AcquireMagickMemory(sizeof(*magic_info));
- if (magic_info == (MagicInfo *) NULL)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
- continue;
- }
- (void) ResetMagickMemory(magic_info,0,sizeof(*magic_info));
- magic_info->path=(char *) "[built-in]";
- magic_info->name=(char *) p->name;
- magic_info->offset=p->offset;
- magic_info->target=(char *) p->magic;
- magic_info->magic=(unsigned char *) p->magic;
- magic_info->length=p->length;
- magic_info->exempt=MagickTrue;
- magic_info->signature=MagickSignature;
- status&=AppendValueToLinkedList(magic_list,magic_info);
- if (status == MagickFalse)
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",magic_info->name);
- }
- return(status != 0 ? MagickTrue : MagickFalse);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ M a g i c C o m p o n e n t G e n e s i s %
% %
% %
if (magic_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&magic_semaphore);
LockSemaphoreInfo(magic_semaphore);
- if (magic_list != (LinkedListInfo *) NULL)
- magic_list=DestroyLinkedList(magic_list,DestroyMagicElement);
+ if (magic_cache != (LinkedListInfo *) NULL)
+ magic_cache=DestroyLinkedList(magic_cache,DestroyMagicElement);
UnlockSemaphoreInfo(magic_semaphore);
RelinquishSemaphoreInfo(&magic_semaphore);
}
assert(exception != (ExceptionInfo *) NULL);
if (IsMagickTreeInstantiated(exception) == MagickFalse)
return((const MagickInfo *) NULL);
+#if defined(MAGICKCORE_MODULES_SUPPORT)
+ if ((name != (const char *) NULL) && (LocaleCompare(name,"*") == 0))
+ (void) OpenModules(exception);
+#endif
/*
Find name in list.
*/
p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
-#if defined(MAGICKCORE_MODULES_SUPPORT)
- if (LocaleCompare(name,"*") == 0)
- (void) OpenModules(exception);
-#endif
ResetSplayTreeIterator(magick_list);
p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
UnlockSemaphoreInfo(magick_semaphore);
static MagickBooleanType IsMagickTreeInstantiated(ExceptionInfo *exception)
{
(void) exception;
- if (magick_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&magick_semaphore);
- LockSemaphoreInfo(magick_semaphore);
if (magick_list == (SplayTreeInfo *) NULL)
{
- MagickBooleanType
- status;
+ if (magick_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&magick_semaphore);
+ LockSemaphoreInfo(magick_semaphore);
+ if (magick_list == (SplayTreeInfo *) NULL)
+ {
+ MagickBooleanType
+ status;
- MagickInfo
- *magick_info;
+ MagickInfo
+ *magick_info;
- magick_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
- DestroyMagickNode);
- if (magick_list == (SplayTreeInfo *) NULL)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- magick_info=SetMagickInfo("ephemeral");
- magick_info->stealth=MagickTrue;
- status=AddValueToSplayTree(magick_list,magick_info->name,magick_info);
- if (status == MagickFalse)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- magick_info=SetMagickInfo("clipmask");
- magick_info->stealth=MagickTrue;
- status=AddValueToSplayTree(magick_list,magick_info->name,magick_info);
- if (status == MagickFalse)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ magick_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *))
+ NULL, DestroyMagickNode);
+ if (magick_list == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
+ magick_info=SetMagickInfo("ephemeral");
+ magick_info->stealth=MagickTrue;
+ status=AddValueToSplayTree(magick_list,magick_info->name,magick_info);
+ if (status == MagickFalse)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
+ magick_info=SetMagickInfo("clipmask");
+ magick_info->stealth=MagickTrue;
+ status=AddValueToSplayTree(magick_list,magick_info->name,magick_info);
+ if (status == MagickFalse)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
#if defined(MAGICKCORE_MODULES_SUPPORT)
- (void) GetModuleInfo((char *) NULL,exception);
+ (void) GetModuleInfo((char *) NULL,exception);
#endif
#if !defined(MAGICKCORE_BUILD_MODULES)
- RegisterStaticModules();
+ RegisterStaticModules();
#endif
+ }
+ UnlockSemaphoreInfo(magick_semaphore);
}
- UnlockSemaphoreInfo(magick_semaphore);
return(magick_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
"</mimemap>";
static LinkedListInfo
- *mime_list = (LinkedListInfo *) NULL;
+ *mime_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*mime_semaphore = (SemaphoreInfo *) NULL;
Forward declarations.
*/
static MagickBooleanType
- IsMimeListInstantiated(ExceptionInfo *);
+ IsMimeCacheInstantiated(ExceptionInfo *),
+ LoadMimeCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e M i m e C a c h e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireMimeCache() caches one or more magic configurations which provides a
+% mapping between magic attributes and a magic name.
+%
+% The format of the AcquireMimeCache method is:
+%
+% LinkedListInfo *AcquireMimeCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport LinkedListInfo *AcquireMimeCache(const char *filename,
+ ExceptionInfo *exception)
+{
+#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
+ return(LoadMimeCache(MimeMap,"built-in",0,exception));
+#else
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *mime_cache,
+ *options;
+
+ MagickStatusType
+ status;
+
+ mime_cache=NewLinkedList(0);
+ if (mime_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadMimeCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ if ((mime_cache == (LinkedListInfo *) NULL) ||
+ (IsLinkedListEmpty(mime_cache) != MagickFalse))
+ status&=LoadMimeCache(MimeMap,"built-in",0,exception);
+ else
+ ClearMagickException(exception);
+ return(mime_cache);
+#endif
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
value;
assert(exception != (ExceptionInfo *) NULL);
- if (IsMimeListInstantiated(exception) == MagickFalse)
- return((const MimeInfo *) NULL);
- if ((magic == (const unsigned char *) NULL) || (length == 0))
- return((const MimeInfo *) GetValueFromLinkedList(mime_list,0));
- if (length == 0)
+ if (IsMimeCacheInstantiated(exception) == MagickFalse)
return((const MimeInfo *) NULL);
/*
Search for mime tag.
mime_info=(const MimeInfo *) NULL;
lsb_first=1;
LockSemaphoreInfo(mime_semaphore);
- ResetLinkedListIterator(mime_list);
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ ResetLinkedListIterator(mime_cache);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
+ if ((magic == (const unsigned char *) NULL) || (length == 0))
+ {
+ UnlockSemaphoreInfo(mime_semaphore);
+ return(p);
+ }
while (p != (const MimeInfo *) NULL)
{
assert(p->offset >= 0);
if (mime_info != (const MimeInfo *) NULL)
if (p->priority > mime_info->priority)
{
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
continue;
}
if ((p->pattern != (char *) NULL) && (filename != (char *) NULL))
{
if (GlobExpression(filename,p->pattern,MagickFalse) != MagickFalse)
mime_info=p;
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
continue;
}
switch (p->data_type)
break;
}
}
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
}
if (p != (const MimeInfo *) NULL)
- (void) InsertValueInLinkedList(mime_list,0,
- RemoveElementByValueFromLinkedList(mime_list,p));
+ (void) InsertValueInLinkedList(mime_cache,0,
+ RemoveElementByValueFromLinkedList(mime_cache,p));
UnlockSemaphoreInfo(mime_semaphore);
return(p);
}
if (p == (const MimeInfo *) NULL)
return((const MimeInfo **) NULL);
aliases=(const MimeInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(mime_list)+1UL,sizeof(*aliases));
+ GetNumberOfElementsInLinkedList(mime_cache)+1UL,sizeof(*aliases));
if (aliases == (const MimeInfo **) NULL)
return((const MimeInfo **) NULL);
/*
Generate mime list.
*/
LockSemaphoreInfo(mime_semaphore);
- ResetLinkedListIterator(mime_list);
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ ResetLinkedListIterator(mime_cache);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
for (i=0; p != (const MimeInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->type,pattern,MagickFalse) != MagickFalse))
aliases[i++]=p;
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
}
UnlockSemaphoreInfo(mime_semaphore);
qsort((void *) aliases,(size_t) i,sizeof(*aliases),MimeInfoCompare);
if (p == (const MimeInfo *) NULL)
return((char **) NULL);
aliases=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(mime_list)+1UL,sizeof(*aliases));
+ GetNumberOfElementsInLinkedList(mime_cache)+1UL,sizeof(*aliases));
if (aliases == (char **) NULL)
return((char **) NULL);
LockSemaphoreInfo(mime_semaphore);
- ResetLinkedListIterator(mime_list);
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ ResetLinkedListIterator(mime_cache);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
for (i=0; p != (const MimeInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->type,pattern,MagickFalse) != MagickFalse))
aliases[i++]=ConstantString(p->type);
- p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
+ p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
}
UnlockSemaphoreInfo(mime_semaphore);
qsort((void *) aliases,(size_t) i,sizeof(*aliases),MimeCompare);
% %
% %
% %
-+ I s M i m e L i s t I n s t a n t i a t e d %
++ I s M i m e C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsMimeListInstantiated() determines if the mime list is instantiated. If
+% IsMimeCacheInstantiated() determines if the mime list is instantiated. If
% not, it instantiates the list and returns it.
%
% The format of the IsMimeInstantiated method is:
%
-% MagickBooleanType IsMimeListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsMimeCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsMimeListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsMimeCacheInstantiated(ExceptionInfo *exception)
{
- if (mime_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&mime_semaphore);
- LockSemaphoreInfo(mime_semaphore);
- if (mime_list == (LinkedListInfo *) NULL)
- (void) LoadMimeLists(MimeFilename,exception);
- UnlockSemaphoreInfo(mime_semaphore);
- return(mime_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
+ if (mime_cache == (LinkedListInfo *) NULL)
+ {
+ if (mime_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
+ if (mime_cache == (LinkedListInfo *) NULL)
+ mime_cache=AcquireMimeCache(MimeFilename,exception);
+ UnlockSemaphoreInfo(mime_semaphore);
+ }
+ return(mime_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadMimeList() loads the magic configuration file which provides a mapping
+% LoadMimeCache() loads the magic configurations which provides a mapping
% between magic attributes and a magic name.
%
-% The format of the LoadMimeList method is:
+% The format of the LoadMimeCache method is:
%
-% MagickBooleanType LoadMimeList(const char *xml,const char *filename,
+% MagickBooleanType LoadMimeCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadMimeList(const char *xml,const char *filename,
+static MagickBooleanType LoadMimeCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
const char
"Loading mime map \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (mime_list == (LinkedListInfo *) NULL)
+ if (mime_cache == (LinkedListInfo *) NULL)
{
- mime_list=NewLinkedList(0);
- if (mime_list == (LinkedListInfo *) NULL)
+ mime_cache=NewLinkedList(0);
+ if (mime_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadMimeList(xml,path,depth+1,exception);
+ status=LoadMimeCache(xml,path,depth+1,exception);
xml=DestroyString(xml);
}
}
attribute=GetXMLTreeAttribute(mime,"type");
if (attribute != (const char *) NULL)
mime_info->type=ConstantString(attribute);
- status=AppendValueToLinkedList(mime_list,mime_info);
+ status=AppendValueToLinkedList(mime_cache,mime_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
% %
% %
% %
-% L o a d M i m e L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadMimeList() loads one or more magic configuration file which provides a
-% mapping between magic attributes and a magic name.
-%
-% The format of the LoadMimeLists method is:
-%
-% MagickBooleanType LoadMimeLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-MagickExport MagickBooleanType LoadMimeLists(const char *filename,
- ExceptionInfo *exception)
-{
-#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- return(LoadMimeList(MimeMap,"built-in",0,exception));
-#else
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- status=MagickFalse;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadMimeList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- if ((mime_list == (LinkedListInfo *) NULL) ||
- (IsLinkedListEmpty(mime_list) != MagickFalse))
- status&=LoadMimeList(MimeMap,"built-in",0,exception);
- else
- ClearMagickException(exception);
- return(status != 0 ? MagickTrue : MagickFalse);
-#endif
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ M a g i c k T o M i m e %
% %
% %
if (mime_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&mime_semaphore);
LockSemaphoreInfo(mime_semaphore);
- if (mime_list != (LinkedListInfo *) NULL)
- mime_list=DestroyLinkedList(mime_list,DestroyMimeElement);
+ if (mime_cache != (LinkedListInfo *) NULL)
+ mime_cache=DestroyLinkedList(mime_cache,DestroyMimeElement);
UnlockSemaphoreInfo(mime_semaphore);
RelinquishSemaphoreInfo(&mime_semaphore);
}
static MagickBooleanType IsModuleTreeInstantiated(
ExceptionInfo *magick_unused(exception))
{
- if (module_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&module_semaphore);
- LockSemaphoreInfo(module_semaphore);
if (module_list == (SplayTreeInfo *) NULL)
{
- MagickBooleanType
- status;
-
- ModuleInfo
- *module_info;
-
- module_list=NewSplayTree(CompareSplayTreeString,
- (void *(*)(void *)) NULL,DestroyModuleNode);
+ if (module_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&module_semaphore);
+ LockSemaphoreInfo(module_semaphore);
if (module_list == (SplayTreeInfo *) NULL)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
- module_info->stealth=MagickTrue;
- status=AddValueToSplayTree(module_list,module_info->tag,module_info);
- if (status == MagickFalse)
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- if (lt_dlinit() != 0)
- ThrowFatalException(ModuleFatalError,"UnableToInitializeModuleLoader");
+ {
+ MagickBooleanType
+ status;
+
+ ModuleInfo
+ *module_info;
+
+ module_list=NewSplayTree(CompareSplayTreeString,
+ (void *(*)(void *)) NULL,DestroyModuleNode);
+ if (module_list == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
+ module_info=AcquireModuleInfo((const char *) NULL,"[boot-strap]");
+ module_info->stealth=MagickTrue;
+ status=AddValueToSplayTree(module_list,module_info->tag,module_info);
+ if (status == MagickFalse)
+ ThrowFatalException(ResourceLimitFatalError,
+ "MemoryAllocationFailed");
+ if (lt_dlinit() != 0)
+ ThrowFatalException(ModuleFatalError,
+ "UnableToInitializeModuleLoader");
+ }
+ UnlockSemaphoreInfo(module_semaphore);
}
- UnlockSemaphoreInfo(module_semaphore);
return(module_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% NTLoadTypeLists() loads a Windows TrueType fonts.
+% NTAcquireTypeCache() loads a Windows TrueType fonts.
%
-% The format of the NTLoadTypeLists method is:
+% The format of the NTAcquireTypeCache method is:
%
-% MagickBooleanType NTLoadTypeLists(SplayTreeInfo *type_list)
+% MagickBooleanType NTAcquireTypeCache(SplayTreeInfo *type_cache)
%
% A description of each parameter follows:
%
-% o type_list: A linked list of fonts.
+% o type_cache: A linked list of fonts.
%
*/
-MagickExport MagickBooleanType NTLoadTypeLists(SplayTreeInfo *type_list,
+MagickExport MagickBooleanType NTAcquireTypeCache(SplayTreeInfo *type_cache,
ExceptionInfo *exception)
{
HKEY
type_info->family=ConstantString(buffer);
list_entries++;
- status=AddValueToSplayTree(type_list,ConstantString(type_info->name),
+ status=AddValueToSplayTree(type_cache,ConstantString(type_info->name),
type_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
};
static LinkedListInfo
- *policy_list = (LinkedListInfo *) NULL;
+ *policy_cache = (LinkedListInfo *) NULL;
static SemaphoreInfo
*policy_semaphore = (SemaphoreInfo *) NULL;
Forward declarations.
*/
static MagickBooleanType
- IsPolicyListInstantiated(ExceptionInfo *),
- LoadPolicyLists(const char *,ExceptionInfo *);
+ IsPolicyCacheInstantiated(ExceptionInfo *),
+ LoadPolicyCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e P o l i c y C a c h e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquirePolicyCache() caches one or more policy configurations which provides
+% a mapping between policy attributes and a policy name.
+%
+% The format of the AcquirePolicyCache method is:
+%
+% LinkedListInfo *AcquirePolicyCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static LinkedListInfo *AcquirePolicyCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options,
+ *policy_cache;
+
+ MagickStatusType
+ status;
+
+ register ssize_t
+ i;
+
+ /*
+ Load external policy map.
+ */
+ policy_cache=NewLinkedList(0);
+ if (policy_cache == (LinkedListInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadPolicyCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ /*
+ Load built-in policy map.
+ */
+ for (i=0; i < (ssize_t) (sizeof(PolicyMap)/sizeof(*PolicyMap)); i++)
+ {
+ PolicyInfo
+ *policy_info;
+
+ register const PolicyMapInfo
+ *p;
+
+ p=PolicyMap+i;
+ policy_info=(PolicyInfo *) AcquireMagickMemory(sizeof(*policy_info));
+ if (policy_info == (PolicyInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
+ continue;
+ }
+ (void) ResetMagickMemory(policy_info,0,sizeof(*policy_info));
+ policy_info->path=(char *) "[built-in]";
+ policy_info->domain=p->domain;
+ policy_info->rights=p->rights;
+ policy_info->name=(char *) p->name;
+ policy_info->pattern=(char *) p->pattern;
+ policy_info->value=(char *) p->value;
+ policy_info->exempt=MagickTrue;
+ policy_info->signature=MagickSignature;
+ status&=AppendValueToLinkedList(policy_cache,policy_info);
+ if (status == MagickFalse)
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",policy_info->name);
+ }
+ return(policy_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*q;
assert(exception != (ExceptionInfo *) NULL);
- if (IsPolicyListInstantiated(exception) == MagickFalse)
+ if (IsPolicyCacheInstantiated(exception) == MagickFalse)
return((PolicyInfo *) NULL);
/*
Strip names of whitespace.
Search for policy tag.
*/
LockSemaphoreInfo(policy_semaphore);
- ResetLinkedListIterator(policy_list);
- p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ ResetLinkedListIterator(policy_cache);
+ p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
UnlockSemaphoreInfo(policy_semaphore);
{
if (LocaleCompare(policyname,p->name) == 0)
break;
- p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
}
if (p != (PolicyInfo *) NULL)
- (void) InsertValueInLinkedList(policy_list,0,
- RemoveElementByValueFromLinkedList(policy_list,p));
+ (void) InsertValueInLinkedList(policy_cache,0,
+ RemoveElementByValueFromLinkedList(policy_cache,p));
UnlockSemaphoreInfo(policy_semaphore);
return(p);
}
if (p == (const PolicyInfo *) NULL)
return((const PolicyInfo **) NULL);
policies=(const PolicyInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(policy_list)+1UL,sizeof(*policies));
+ GetNumberOfElementsInLinkedList(policy_cache)+1UL,sizeof(*policies));
if (policies == (const PolicyInfo **) NULL)
return((const PolicyInfo **) NULL);
/*
Generate policy list.
*/
LockSemaphoreInfo(policy_semaphore);
- ResetLinkedListIterator(policy_list);
- p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ ResetLinkedListIterator(policy_cache);
+ p=(const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
for (i=0; p != (const PolicyInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
policies[i++]=p;
- p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ p=(const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
}
UnlockSemaphoreInfo(policy_semaphore);
policies[i]=(PolicyInfo *) NULL;
if (p == (const PolicyInfo *) NULL)
return((char **) NULL);
policies=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfElementsInLinkedList(policy_list)+1UL,sizeof(*policies));
+ GetNumberOfElementsInLinkedList(policy_cache)+1UL,sizeof(*policies));
if (policies == (char **) NULL)
return((char **) NULL);
/*
Generate policy list.
*/
LockSemaphoreInfo(policy_semaphore);
- ResetLinkedListIterator(policy_list);
- p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ ResetLinkedListIterator(policy_cache);
+ p=(const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
for (i=0; p != (const PolicyInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
policies[i++]=ConstantString(p->name);
- p=(const PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ p=(const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
}
UnlockSemaphoreInfo(policy_semaphore);
policies[i]=(char *) NULL;
% %
% %
% %
-+ I s P o l i c y L i s t I n s t a n t i a t e d %
++ I s P o l i c y C a c h e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% IsPolicyListInstantiated() determines if the policy list is instantiated.
+% IsPolicyCacheInstantiated() determines if the policy list is instantiated.
% If not, it instantiates the list and returns it.
%
% The format of the IsPolicyInstantiated method is:
%
-% MagickBooleanType IsPolicyListInstantiated(ExceptionInfo *exception)
+% MagickBooleanType IsPolicyCacheInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType IsPolicyListInstantiated(ExceptionInfo *exception)
+static MagickBooleanType IsPolicyCacheInstantiated(ExceptionInfo *exception)
{
- if (policy_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&policy_semaphore);
- LockSemaphoreInfo(policy_semaphore);
- if (policy_list == (LinkedListInfo *) NULL)
- (void) LoadPolicyLists(PolicyFilename,exception);
- UnlockSemaphoreInfo(policy_semaphore);
- return(policy_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
+ if (policy_cache == (LinkedListInfo *) NULL)
+ {
+ if (policy_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&policy_semaphore);
+ LockSemaphoreInfo(policy_semaphore);
+ if (policy_cache == (LinkedListInfo *) NULL)
+ policy_cache=AcquirePolicyCache(PolicyFilename,exception);
+ UnlockSemaphoreInfo(policy_semaphore);
+ }
+ return(policy_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
return(MagickTrue);
authorized=MagickTrue;
LockSemaphoreInfo(policy_semaphore);
- ResetLinkedListIterator(policy_list);
- p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ ResetLinkedListIterator(policy_cache);
+ p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
while ((p != (PolicyInfo *) NULL) && (authorized != MagickFalse))
{
if ((p->domain == domain) &&
((p->rights & ExecutePolicyRights) == 0))
authorized=MagickFalse;
}
- p=(PolicyInfo *) GetNextValueInLinkedList(policy_list);
+ p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
}
UnlockSemaphoreInfo(policy_semaphore);
return(authorized);
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadPolicyList() loads the policy configuration file which provides a mapping
+% LoadPolicyCache() loads the policy configurations which provides a mapping
% between policy attributes and a policy domain.
%
-% The format of the LoadPolicyList method is:
+% The format of the LoadPolicyCache method is:
%
-% MagickBooleanType LoadPolicyList(const char *xml,const char *filename,
+% MagickBooleanType LoadPolicyCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadPolicyList(const char *xml,const char *filename,
+static MagickBooleanType LoadPolicyCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
"Loading policy file \"%s\" ...",filename);
if (xml == (char *) NULL)
return(MagickFalse);
- if (policy_list == (LinkedListInfo *) NULL)
+ if (policy_cache == (LinkedListInfo *) NULL)
{
- policy_list=NewLinkedList(0);
- if (policy_list == (LinkedListInfo *) NULL)
+ policy_cache=NewLinkedList(0);
+ if (policy_cache == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
xml=FileToString(path,~0UL,exception);
if (xml != (char *) NULL)
{
- status=LoadPolicyList(xml,path,depth+1,exception);
+ status=LoadPolicyCache(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AppendValueToLinkedList(policy_list,policy_info);
+ status=AppendValueToLinkedList(policy_cache,policy_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
% %
% %
% %
-% L o a d P o l i c y L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadPolicyList() loads one or more policy configuration file which provides a
-% mapping between policy attributes and a policy name.
-%
-% The format of the LoadPolicyLists method is:
-%
-% MagickBooleanType LoadPolicyLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadPolicyLists(const char *filename,
- ExceptionInfo *exception)
-{
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- register ssize_t
- i;
-
- /*
- Load external policy map.
- */
- if (policy_list == (LinkedListInfo *) NULL)
- {
- policy_list=NewLinkedList(0);
- if (policy_list == (LinkedListInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
- status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- status&=LoadPolicyList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- /*
- Load built-in policy map.
- */
- for (i=0; i < (ssize_t) (sizeof(PolicyMap)/sizeof(*PolicyMap)); i++)
- {
- PolicyInfo
- *policy_info;
-
- register const PolicyMapInfo
- *p;
-
- p=PolicyMap+i;
- policy_info=(PolicyInfo *) AcquireMagickMemory(sizeof(*policy_info));
- if (policy_info == (PolicyInfo *) NULL)
- {
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
- continue;
- }
- (void) ResetMagickMemory(policy_info,0,sizeof(*policy_info));
- policy_info->path=(char *) "[built-in]";
- policy_info->domain=p->domain;
- policy_info->rights=p->rights;
- policy_info->name=(char *) p->name;
- policy_info->pattern=(char *) p->pattern;
- policy_info->value=(char *) p->value;
- policy_info->exempt=MagickTrue;
- policy_info->signature=MagickSignature;
- status&=AppendValueToLinkedList(policy_list,policy_info);
- if (status == MagickFalse)
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",policy_info->name);
- }
- return(status != 0 ? MagickTrue : MagickFalse);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ P o l i c y C o m p o n e n t G e n e s i s %
% %
% %
if (policy_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&policy_semaphore);
LockSemaphoreInfo(policy_semaphore);
- if (policy_list != (LinkedListInfo *) NULL)
- policy_list=DestroyLinkedList(policy_list,DestroyPolicyElement);
+ if (policy_cache != (LinkedListInfo *) NULL)
+ policy_cache=DestroyLinkedList(policy_cache,DestroyPolicyElement);
UnlockSemaphoreInfo(policy_semaphore);
RelinquishSemaphoreInfo(&policy_semaphore);
}
*type_semaphore = (SemaphoreInfo *) NULL;
static SplayTreeInfo
- *type_list = (SplayTreeInfo *) NULL;
+ *type_cache = (SplayTreeInfo *) NULL;
\f
/*
Forward declarations.
*/
static MagickBooleanType
IsTypeTreeInstantiated(ExceptionInfo *),
- LoadTypeLists(const char *,ExceptionInfo *);
+ LoadTypeCache(const char *,const char *,const size_t,ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e T y p e S p l a y T r e e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireTypeCache() caches one or more type configuration files which
+% provides a mapping between type attributes and a type name.
+%
+% The format of the AcquireTypeCache method is:
+%
+% SplayTreeInfo *AcquireTypeCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+
+static void *DestroyTypeNode(void *type_info)
+{
+ register TypeInfo
+ *p;
+
+ p=(TypeInfo *) type_info;
+ if (p->path != (char *) NULL)
+ p->path=DestroyString(p->path);
+ if (p->name != (char *) NULL)
+ p->name=DestroyString(p->name);
+ if (p->description != (char *) NULL)
+ p->description=DestroyString(p->description);
+ if (p->family != (char *) NULL)
+ p->family=DestroyString(p->family);
+ if (p->encoding != (char *) NULL)
+ p->encoding=DestroyString(p->encoding);
+ if (p->foundry != (char *) NULL)
+ p->foundry=DestroyString(p->foundry);
+ if (p->format != (char *) NULL)
+ p->format=DestroyString(p->format);
+ if (p->metrics != (char *) NULL)
+ p->metrics=DestroyString(p->metrics);
+ if (p->glyphs != (char *) NULL)
+ p->glyphs=DestroyString(p->glyphs);
+ return(RelinquishMagickMemory(p));
+}
+
+static SplayTreeInfo *AcquireTypeCache(const char *filename,
+ ExceptionInfo *exception)
+{
+#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
+ return(LoadTypeCache(TypeMap,"built-in",0,exception));
+#else
+ char
+ *font_path,
+ path[MaxTextExtent];
+
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ MagickStatusType
+ status;
+
+ SplayTreeInfo
+ *type_cache;
+
+ type_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
+ DestroyTypeNode);
+ if (type_cache == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+ *path='\0';
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
+ status&=LoadTypeCache((const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ font_path=GetEnvironmentValue("MAGICK_FONT_PATH");
+ if (font_path != (char *) NULL)
+ {
+ char
+ *option;
+
+ /*
+ Search MAGICK_FONT_PATH.
+ */
+ (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",font_path,
+ DirectorySeparator,filename);
+ option=FileToString(path,~0UL,exception);
+ if (option != (void *) NULL)
+ {
+ status&=LoadTypeCache(option,path,0,exception);
+ option=DestroyString(option);
+ }
+ font_path=DestroyString(font_path);
+ }
+ if ((type_cache == (SplayTreeInfo *) NULL) ||
+ (GetNumberOfNodesInSplayTree(type_cache) == 0))
+ status&=LoadTypeCache(TypeMap,"built-in",0,exception);
+ return(type_cache);
+#endif
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MagickExport const TypeInfo *GetTypeInfo(const char *name,
ExceptionInfo *exception)
{
+ const TypeInfo
+ *type_info;
+
assert(exception != (ExceptionInfo *) NULL);
if (IsTypeTreeInstantiated(exception) == MagickFalse)
return((const TypeInfo *) NULL);
LockSemaphoreInfo(type_semaphore);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
- ResetSplayTreeIterator(type_list);
- type_info=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ type_info=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
UnlockSemaphoreInfo(type_semaphore);
return(type_info);
}
- type_info=(const TypeInfo *) GetValueFromSplayTree(type_list,name);
+ type_info=(const TypeInfo *) GetValueFromSplayTree(type_cache,name);
UnlockSemaphoreInfo(type_semaphore);
return(type_info);
}
Check for an exact type match.
*/
(void) GetTypeInfo("*",exception);
- if (type_list == (SplayTreeInfo *) NULL)
+ if (type_cache == (SplayTreeInfo *) NULL)
return((TypeInfo *) NULL);
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
+ ResetSplayTreeIterator(type_cache);
type_info=(const TypeInfo *) NULL;
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
while (p != (const TypeInfo *) NULL)
{
if (p->family == (char *) NULL)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if (family == (const char *) NULL)
if ((LocaleCompare(p->family,"arial") != 0) &&
(LocaleCompare(p->family,"helvetica") != 0))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
}
else
if (LocaleCompare(p->family,family) != 0)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if ((style != UndefinedStyle) && (style != AnyStyle) && (p->style != style))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if ((stretch != UndefinedStretch) && (stretch != AnyStretch) &&
(p->stretch != stretch))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if ((weight != 0) && (p->weight != weight))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
type_info=p;
*/
max_score=0;
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
while (p != (const TypeInfo *) NULL)
{
if (p->family == (char *) NULL)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if (family == (const char *) NULL)
if ((LocaleCompare(p->family,"arial") != 0) &&
(LocaleCompare(p->family,"helvetica") != 0))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
}
else
if (LocaleCompare(p->family,family) != 0)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
score=0;
max_score=score;
type_info=p;
}
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
}
UnlockSemaphoreInfo(type_semaphore);
if (type_info != (const TypeInfo *) NULL)
if (p == (const TypeInfo *) NULL)
return((const TypeInfo **) NULL);
fonts=(const TypeInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(type_list)+1UL,sizeof(*fonts));
+ GetNumberOfNodesInSplayTree(type_cache)+1UL,sizeof(*fonts));
if (fonts == (const TypeInfo **) NULL)
return((const TypeInfo **) NULL);
/*
Generate type list.
*/
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
for (i=0; p != (const TypeInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
fonts[i++]=p;
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
}
UnlockSemaphoreInfo(type_semaphore);
qsort((void *) fonts,(size_t) i,sizeof(*fonts),TypeInfoCompare);
if (p == (const TypeInfo *) NULL)
return((char **) NULL);
fonts=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(type_list)+1UL,sizeof(*fonts));
+ GetNumberOfNodesInSplayTree(type_cache)+1UL,sizeof(*fonts));
if (fonts == (char **) NULL)
return((char **) NULL);
/*
Generate type list.
*/
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
for (i=0; p != (const TypeInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
fonts[i++]=ConstantString(p->name);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
}
UnlockSemaphoreInfo(type_semaphore);
qsort((void *) fonts,(size_t) i,sizeof(*fonts),TypeCompare);
*/
#if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
-MagickExport MagickBooleanType LoadFontConfigFonts(SplayTreeInfo *type_list,
+MagickExport MagickBooleanType LoadFontConfigFonts(SplayTreeInfo *type_cache,
ExceptionInfo *exception)
{
#if !defined(FC_FULLNAME)
if (weight >= FC_WEIGHT_BLACK)
type_info->weight=900;
type_info->glyphs=ConstantString((const char *) file);
- (void) AddValueToSplayTree(type_list,type_info->name,type_info);
+ (void) AddValueToSplayTree(type_cache,type_info->name,type_info);
}
FcFontSetDestroy(font_set);
FcConfigDestroy(font_config);
static MagickBooleanType IsTypeTreeInstantiated(ExceptionInfo *exception)
{
- if (type_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&type_semaphore);
- LockSemaphoreInfo(type_semaphore);
- if (type_list == (SplayTreeInfo *) NULL)
+ if (type_cache == (SplayTreeInfo *) NULL)
{
- (void) LoadTypeLists(MagickTypeFilename,exception);
+ if (type_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&type_semaphore);
+ LockSemaphoreInfo(type_semaphore);
+ if (type_cache == (SplayTreeInfo *) NULL)
+ {
+ type_cache=AcquireTypeCache(MagickTypeFilename,exception);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
- (void) NTLoadTypeLists(type_list,exception);
+ (void) NTAcquireTypeCache(type_cache,exception);
#endif
#if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
- (void) LoadFontConfigFonts(type_list,exception);
+ (void) LoadFontConfigFonts(type_cache,exception);
#endif
+ }
+ UnlockSemaphoreInfo(type_semaphore);
}
- UnlockSemaphoreInfo(type_semaphore);
- return(type_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
+ return(type_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadTypeList() loads the type configuration file which provides a mapping
+% LoadTypeCache() loads the type configurations which provides a mapping
% between type attributes and a type name.
%
-% The format of the LoadTypeList method is:
+% The format of the LoadTypeCache method is:
%
-% MagickBooleanType LoadTypeList(const char *xml,const char *filename,
+% MagickBooleanType LoadTypeCache(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*/
-static void *DestroyTypeNode(void *type_info)
-{
- register TypeInfo
- *p;
-
- p=(TypeInfo *) type_info;
- if (p->path != (char *) NULL)
- p->path=DestroyString(p->path);
- if (p->name != (char *) NULL)
- p->name=DestroyString(p->name);
- if (p->description != (char *) NULL)
- p->description=DestroyString(p->description);
- if (p->family != (char *) NULL)
- p->family=DestroyString(p->family);
- if (p->encoding != (char *) NULL)
- p->encoding=DestroyString(p->encoding);
- if (p->foundry != (char *) NULL)
- p->foundry=DestroyString(p->foundry);
- if (p->format != (char *) NULL)
- p->format=DestroyString(p->format);
- if (p->metrics != (char *) NULL)
- p->metrics=DestroyString(p->metrics);
- if (p->glyphs != (char *) NULL)
- p->glyphs=DestroyString(p->glyphs);
- return(RelinquishMagickMemory(p));
-}
-
static inline MagickBooleanType SetTypeNodePath(const char *filename,
-char *font_path,const char *token,char **target)
+ char *font_path,const char *token,char **target)
{
char
*path;
return(MagickTrue);
}
-static MagickBooleanType LoadTypeList(const char *xml,const char *filename,
+static MagickBooleanType LoadTypeCache(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
char
"Loading type configure file \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (type_list == (SplayTreeInfo *) NULL)
+ if (type_cache == (SplayTreeInfo *) NULL)
{
- type_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
+ type_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
DestroyTypeNode);
- if (type_list == (SplayTreeInfo *) NULL)
+ if (type_cache == (SplayTreeInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
sans_exception=DestroyExceptionInfo(sans_exception);
if (xml != (char *) NULL)
{
- status=LoadTypeList(xml,path,depth+1,exception);
+ status=LoadTypeCache(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AddValueToSplayTree(type_list,type_info->name,type_info);
+ status=AddValueToSplayTree(type_cache,type_info->name,type_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",type_info->name);
% %
% %
% %
-% L o a d T y p e L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadTypeList() loads one or more type configuration files which provides a
-% mapping between type attributes and a type name.
-%
-% The format of the LoadTypeLists method is:
-%
-% MagickBooleanType LoadTypeLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadTypeLists(const char *filename,
- ExceptionInfo *exception)
-{
-#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- return(LoadTypeList(TypeMap,"built-in",0,exception));
-#else
- char
- *font_path,
- path[MaxTextExtent];
-
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- status=MagickFalse;
- *path='\0';
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
- status&=LoadTypeList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- font_path=GetEnvironmentValue("MAGICK_FONT_PATH");
- if (font_path != (char *) NULL)
- {
- char
- *option;
-
- /*
- Search MAGICK_FONT_PATH.
- */
- (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",font_path,
- DirectorySeparator,filename);
- option=FileToString(path,~0UL,exception);
- if (option != (void *) NULL)
- {
- status&=LoadTypeList(option,path,0,exception);
- option=DestroyString(option);
- }
- font_path=DestroyString(font_path);
- }
- if ((type_list == (SplayTreeInfo *) NULL) ||
- (GetNumberOfNodesInSplayTree(type_list) == 0))
- status&=LoadTypeList(TypeMap,"built-in",0,exception);
- return(status != 0 ? MagickTrue : MagickFalse);
-#endif
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ T y p e C o m p o n e n t G e n e s i s %
% %
% %
if (type_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&type_semaphore);
LockSemaphoreInfo(type_semaphore);
- if (type_list != (SplayTreeInfo *) NULL)
- type_list=DestroySplayTree(type_list);
+ if (type_cache != (SplayTreeInfo *) NULL)
+ type_cache=DestroySplayTree(type_cache);
UnlockSemaphoreInfo(type_semaphore);
RelinquishSemaphoreInfo(&type_semaphore);
}