*/
static MagickBooleanType
IsMimeCacheInstantiated(ExceptionInfo *),
- LoadMimeCache(const char *,const char *,const size_t,ExceptionInfo *);
+ LoadMimeCache(LinkedListInfo *,const char *,const char *,const size_t,
+ ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% AcquireMimeCache() caches one or more magic configurations which provides a
-% mapping between magic attributes and a magic name.
+% 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:
%
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;
+ *mime_cache;
MagickStatusType
status;
if (mime_cache == (LinkedListInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
+#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
{
- status&=LoadMimeCache((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ options=GetConfigureOptions(filename,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadMimeCache(mime_cache,(const char *)
+ GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(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
+ if (IsLinkedListEmpty(mime_cache) != MagickFalse)
+ status&=LoadMimeCache(mime_cache,MimeMap,"built-in",0,exception);
+ return(mime_cache);
}
\f
/*
if (endian == LSBEndian)
{
value=(ssize_t) (*q++);
- value|=(*q++) << 8;
- value|=(*q++) << 16;
- value|=(*q++) << 24;
+ value|=((ssize_t) *q++) << 8;
+ value|=((ssize_t) *q++) << 16;
+ value|=((ssize_t) *q++) << 24;
}
else
{
value=(ssize_t) (*q++) << 24;
- value|=(*q++) << 16;
- value|=(*q++) << 8;
- value|=(*q++);
+ value|=((ssize_t) *q++) << 16;
+ value|=((ssize_t) *q++) << 8;
+ value|=((ssize_t) *q++);
}
if (p->mask == 0)
{
}
p=(const MimeInfo *) GetNextValueInLinkedList(mime_cache);
}
- if (p != (const MimeInfo *) NULL)
+ if (mime_info != (const MimeInfo *) NULL)
(void) InsertValueInLinkedList(mime_cache,0,
RemoveElementByValueFromLinkedList(mime_cache,p));
UnlockSemaphoreInfo(mime_semaphore);
- return(p);
+ return(mime_info);
}
\f
/*
% %
% %
% %
-+ L o a d M i m e L i s t %
++ L o a d M i m e C a c h e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadMimeCache() loads the magic configurations which provides a mapping
-% between magic attributes and a magic name.
+% LoadMimeCache() loads the mime configurations which provides a mapping
+% between mime attributes and a mime name.
%
% The format of the LoadMimeCache method is:
%
-% MagickBooleanType LoadMimeCache(const char *xml,const char *filename,
-% const size_t depth,ExceptionInfo *exception)
+% MagickBooleanType LoadMimeCache(LinkedListInfo *mime_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 MagickBooleanType LoadMimeCache(const char *xml,const char *filename,
- const size_t depth,ExceptionInfo *exception)
+static MagickBooleanType LoadMimeCache(LinkedListInfo *mime_cache,
+ const char *xml,const char *filename,const size_t depth,
+ ExceptionInfo *exception)
{
const char
*attribute;
"Loading mime map \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (mime_cache == (LinkedListInfo *) NULL)
- {
- mime_cache=NewLinkedList(0);
- if (mime_cache == (LinkedListInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
mime_map=NewXMLTree(xml,exception);
if (mime_map == (XMLTreeInfo *) NULL)
return(MagickFalse);
xml=FileToXML(path,~0UL);
if (xml != (char *) NULL)
{
- status=LoadMimeCache(xml,path,depth+1,exception);
+ status&=LoadMimeCache(mime_cache,xml,path,depth+1,exception);
xml=DestroyString(xml);
}
}
if (attribute != (const char *) NULL)
mime_info->priority=(ssize_t) strtol(attribute,(char **) NULL,0);
attribute=GetXMLTreeAttribute(mime,"stealth");
- mime_info->stealth=IsStringTrue(attribute);
+ if (attribute != (const char *) NULL)
+ mime_info->stealth=IsStringTrue(attribute);
attribute=GetXMLTreeAttribute(mime,"type");
if (attribute != (const char *) NULL)
mime_info->type=ConstantString(attribute);
*/
MagickPrivate MagickBooleanType MimeComponentGenesis(void)
{
- mime_semaphore=AcquireSemaphoreInfo();
+ if (mime_semaphore == (SemaphoreInfo *) NULL)
+ mime_semaphore=AcquireSemaphoreInfo();
return(MagickTrue);
}
\f