% July 2000 %
% %
% %
-% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
*description,
*pattern;
- long
+ ssize_t
priority;
MagickOffsetType
DataType
data_type;
- long
+ ssize_t
mask,
value;
MagickBooleanType
stealth;
- unsigned long
+ size_t
signature;
};
\f
% %
% %
% %
-+ D e s t r o y M i m e L i s t %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DestroyMimeList() deallocates memory associated with the mime list.
-%
-% The format of the DestroyMimeList method is:
-%
-% DestroyMimeList(void)
-%
-*/
-
-static void *DestroyMimeElement(void *mime_info)
-{
- register MimeInfo
- *p;
-
- p=(MimeInfo *) mime_info;
- if (p->magic != (unsigned char *) NULL)
- p->magic=(unsigned char *) RelinquishMagickMemory(p->magic);
- if (p->pattern != (char *) NULL)
- p->pattern=DestroyString(p->pattern);
- if (p->description != (char *) NULL)
- p->description=DestroyString(p->description);
- if (p->type != (char *) NULL)
- p->type=DestroyString(p->type);
- if (p->path != (char *) NULL)
- p->path=DestroyString(p->path);
- p=(MimeInfo *) RelinquishMagickMemory(p);
- return((void *) NULL);
-}
-
-MagickExport void DestroyMimeList(void)
-{
- AcquireSemaphoreInfo(&mime_semaphore);
- if (mime_list != (LinkedListInfo *) NULL)
- mime_list=DestroyLinkedList(mime_list,DestroyMimeElement);
- instantiate_mime=MagickFalse;
- RelinquishSemaphoreInfo(mime_semaphore);
- DestroySemaphoreInfo(&mime_semaphore);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ G e t M i m e I n f o %
% %
% %
EndianType
endian;
- long
- value;
-
register const MimeInfo
*p;
register const unsigned char
*q;
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
lsb_first;
+ ssize_t
+ value;
+
assert(exception != (ExceptionInfo *) NULL);
if ((mime_list == (LinkedListInfo *) NULL) ||
(instantiate_mime == MagickFalse))
*/
mime_info=(const MimeInfo *) NULL;
lsb_first=1;
- AcquireSemaphoreInfo(&mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
ResetLinkedListIterator(mime_list);
p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
while (p != (const MimeInfo *) NULL)
case StringData:
default:
{
- for (i=0; i <= (long) p->extent; i++)
+ for (i=0; i <= (ssize_t) p->extent; i++)
{
if ((size_t) (p->offset+i+p->length) > length)
break;
if (p != (const MimeInfo *) NULL)
(void) InsertValueInLinkedList(mime_list,0,
RemoveElementByValueFromLinkedList(mime_list,p));
- RelinquishSemaphoreInfo(mime_semaphore);
+ UnlockSemaphoreInfo(mime_semaphore);
return(mime_info);
}
\f
% The magic of the GetMimeInfoList function is:
%
% const MimeInfo **GetMimeInfoList(const char *pattern,
-% unsigned long *number_aliases,ExceptionInfo *exception)
+% size_t *number_aliases,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
#endif
MagickExport const MimeInfo **GetMimeInfoList(const char *pattern,
- unsigned long *number_aliases,ExceptionInfo *exception)
+ size_t *number_aliases,ExceptionInfo *exception)
{
const MimeInfo
**aliases;
register const MimeInfo
*p;
- register long
+ register ssize_t
i;
/*
*/
assert(pattern != (char *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
- assert(number_aliases != (unsigned long *) NULL);
+ assert(number_aliases != (size_t *) NULL);
*number_aliases=0;
p=GetMimeInfo((char *) NULL,(unsigned char *) "*",0,exception);
if (p == (const MimeInfo *) NULL)
/*
Generate mime list.
*/
- AcquireSemaphoreInfo(&mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
ResetLinkedListIterator(mime_list);
p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
for (i=0; p != (const MimeInfo *) NULL; )
aliases[i++]=p;
p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
}
- RelinquishSemaphoreInfo(mime_semaphore);
+ UnlockSemaphoreInfo(mime_semaphore);
qsort((void *) aliases,(size_t) i,sizeof(*aliases),MimeInfoCompare);
aliases[i]=(MimeInfo *) NULL;
- *number_aliases=(unsigned long) i;
+ *number_aliases=(size_t) i;
return(aliases);
}
\f
%
% The format of the GetMimeList function is:
%
-% char **GetMimeList(const char *pattern,unsigned long *number_aliases,
+% char **GetMimeList(const char *pattern,size_t *number_aliases,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
#endif
MagickExport char **GetMimeList(const char *pattern,
- unsigned long *number_aliases,ExceptionInfo *exception)
+ size_t *number_aliases,ExceptionInfo *exception)
{
char
**aliases;
register const MimeInfo
*p;
- register long
+ register ssize_t
i;
/*
*/
assert(pattern != (char *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
- assert(number_aliases != (unsigned long *) NULL);
+ assert(number_aliases != (size_t *) NULL);
*number_aliases=0;
p=GetMimeInfo((char *) NULL,(unsigned char *) "*",0,exception);
if (p == (const MimeInfo *) NULL)
GetNumberOfElementsInLinkedList(mime_list)+1UL,sizeof(*aliases));
if (aliases == (char **) NULL)
return((char **) NULL);
- AcquireSemaphoreInfo(&mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
ResetLinkedListIterator(mime_list);
p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
for (i=0; p != (const MimeInfo *) NULL; )
aliases[i++]=ConstantString(p->type);
p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
}
- RelinquishSemaphoreInfo(mime_semaphore);
+ UnlockSemaphoreInfo(mime_semaphore);
qsort((void *) aliases,(size_t) i,sizeof(*aliases),MimeCompare);
aliases[i]=(char *) NULL;
- *number_aliases=(unsigned long) i;
+ *number_aliases=(size_t) i;
return(aliases);
}
\f
if ((mime_list == (LinkedListInfo *) NULL) &&
(instantiate_mime == MagickFalse))
{
- AcquireSemaphoreInfo(&mime_semaphore);
+ if (mime_semaphore == (SemaphoreInfo *) NULL)
+ AcquireSemaphoreInfo(&mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
if ((mime_list == (LinkedListInfo *) NULL) &&
(instantiate_mime == MagickFalse))
{
(void) LoadMimeLists(MimeFilename,exception);
instantiate_mime=MagickTrue;
}
- RelinquishSemaphoreInfo(mime_semaphore);
+ UnlockSemaphoreInfo(mime_semaphore);
}
return(mime_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
const MimeInfo
**mime_info;
- long
+ ssize_t
j;
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
number_aliases;
if (file == (const FILE *) NULL)
return(MagickFalse);
j=0;
path=(const char *) NULL;
- for (i=0; i < (long) number_aliases; i++)
+ for (i=0; i < (ssize_t) number_aliases; i++)
{
if (mime_info[i]->stealth != MagickFalse)
continue;
(void) fprintf(file,"%s",mime_info[i]->type);
if (strlen(mime_info[i]->type) <= 25)
{
- for (j=(long) strlen(mime_info[i]->type); j <= 27; j++)
+ for (j=(ssize_t) strlen(mime_info[i]->type); j <= 27; j++)
(void) fprintf(file," ");
}
else
% The format of the LoadMimeList method is:
%
% MagickBooleanType LoadMimeList(const char *xml,const char *filename,
-% const unsigned long depth,ExceptionInfo *exception)
+% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
*/
static MagickBooleanType LoadMimeList(const char *xml,const char *filename,
- const unsigned long depth,ExceptionInfo *exception)
+ const size_t depth,ExceptionInfo *exception)
{
const char
*attribute;
/*
Process mime element.
*/
- mime_info=(MimeInfo *) AcquireMagickMemory(sizeof(*mime_info));
+ mime_info=(MimeInfo *) AcquireAlignedMemory(1,sizeof(*mime_info));
if (mime_info == (MimeInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(mime_info,0,sizeof(*mime_info));
}
token=DestroyString(token);
if (mime_info->data_type != StringData)
- mime_info->value=strtol((char *) mime_info->magic,(char **) NULL,0);
+ mime_info->value=(size_t) strtoul((char *) mime_info->magic,
+ (char **) NULL,0);
}
attribute=GetXMLTreeAttribute(mime,"mask");
if (attribute != (const char *) NULL)
- mime_info->mask=strtol(attribute,(char **) NULL,0);
+ mime_info->mask=(size_t) strtoul(attribute,(char **) NULL,0);
attribute=GetXMLTreeAttribute(mime,"offset");
if (attribute != (const char *) NULL)
{
mime_info->pattern=ConstantString(attribute);
attribute=GetXMLTreeAttribute(mime,"priority");
if (attribute != (const char *) NULL)
- mime_info->priority=strtol(attribute,(char **) NULL,0);
+ mime_info->priority=(ssize_t) strtol(attribute,(char **) NULL,0);
attribute=GetXMLTreeAttribute(mime,"stealth");
if (attribute != (const char *) NULL)
mime_info->stealth=IsMagickTrue(attribute);
LocaleLower(media+8);
return(ConstantString(media));
}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
++ M i m e C o m p o n e n t G e n e s i s %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% MimeComponentGenesis() instantiates the mime component.
+%
+% The format of the MimeComponentGenesis method is:
+%
+% MagickBooleanType MimeComponentGenesis(void)
+%
+*/
+MagickExport MagickBooleanType MimeComponentGenesis(void)
+{
+ AcquireSemaphoreInfo(&mime_semaphore);
+ return(MagickTrue);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
++ M i m e C o m p o n e n t T e r m i n u s %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% MimeComponentTerminus() destroys the mime component.
+%
+% The format of the MimeComponentTerminus method is:
+%
+% MimeComponentTerminus(void)
+%
+*/
+
+static void *DestroyMimeElement(void *mime_info)
+{
+ register MimeInfo
+ *p;
+
+ p=(MimeInfo *) mime_info;
+ if (p->magic != (unsigned char *) NULL)
+ p->magic=(unsigned char *) RelinquishMagickMemory(p->magic);
+ if (p->pattern != (char *) NULL)
+ p->pattern=DestroyString(p->pattern);
+ if (p->description != (char *) NULL)
+ p->description=DestroyString(p->description);
+ if (p->type != (char *) NULL)
+ p->type=DestroyString(p->type);
+ if (p->path != (char *) NULL)
+ p->path=DestroyString(p->path);
+ p=(MimeInfo *) RelinquishMagickMemory(p);
+ return((void *) NULL);
+}
+
+MagickExport void MimeComponentTerminus(void)
+{
+ if (mime_semaphore == (SemaphoreInfo *) NULL)
+ AcquireSemaphoreInfo(&mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
+ if (mime_list != (LinkedListInfo *) NULL)
+ mime_list=DestroyLinkedList(mime_list,DestroyMimeElement);
+ instantiate_mime=MagickFalse;
+ UnlockSemaphoreInfo(mime_semaphore);
+ DestroySemaphoreInfo(&mime_semaphore);
+}