% July 2000 %
% %
% %
-% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2011 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
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;
- (void) LockSemaphoreInfo(mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
ResetLinkedListIterator(mime_list);
p=(const MimeInfo *) GetNextValueInLinkedList(mime_list);
while (p != (const MimeInfo *) NULL)
if ((size_t) (p->offset+4) > length)
break;
q=magic+p->offset;
- value=(*q++);
+ value=(ssize_t) (*q++);
if (p->mask == 0)
{
if (p->value == value)
endian=(*(char *) &lsb_first) == 1 ? LSBEndian : MSBEndian;
if (endian == LSBEndian)
{
- value=(*q++);
+ value=(ssize_t) (*q++);
value|=(*q++) << 8;
}
else
{
- value=(*q++) << 8;
+ value=(ssize_t) (*q++) << 8;
value|=(*q++);
}
if (p->mask == 0)
endian=(*(char *) &lsb_first) == 1 ? LSBEndian : MSBEndian;
if (endian == LSBEndian)
{
- value=(*q++);
+ value=(ssize_t) (*q++);
value|=(*q++) << 8;
value|=(*q++) << 16;
value|=(*q++) << 24;
}
else
{
- value=(*q++) << 24;
+ value=(ssize_t) (*q++) << 24;
value|=(*q++) << 16;
value|=(*q++) << 8;
value|=(*q++);
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));
- (void) UnlockSemaphoreInfo(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.
*/
- (void) LockSemaphoreInfo(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);
}
- (void) UnlockSemaphoreInfo(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);
- (void) LockSemaphoreInfo(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);
}
- (void) UnlockSemaphoreInfo(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_semaphore == (SemaphoreInfo *) NULL)
AcquireSemaphoreInfo(&mime_semaphore);
- (void) LockSemaphoreInfo(mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
if ((mime_list == (LinkedListInfo *) NULL) &&
(instantiate_mime == MagickFalse))
{
(void) LoadMimeLists(MimeFilename,exception);
instantiate_mime=MagickTrue;
}
- (void) UnlockSemaphoreInfo(mime_semaphore);
+ UnlockSemaphoreInfo(mime_semaphore);
}
return(mime_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
const MimeInfo
**mime_info;
- long
- j;
-
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
number_aliases;
+ ssize_t
+ j;
+
if (file == (const FILE *) NULL)
file=stdout;
mime_info=GetMimeInfoList("*",&number_aliases,exception);
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;
(strcasecmp(path,mime_info[i]->path) != 0))
{
if (mime_info[i]->path != (char *) NULL)
- (void) fprintf(file,"\nPath: %s\n\n",mime_info[i]->path);
- (void) fprintf(file,"Type Description\n");
- (void) fprintf(file,"-------------------------------------------------"
+ (void) FormatLocaleFile(file,"\nPath: %s\n\n",mime_info[i]->path);
+ (void) FormatLocaleFile(file,"Type Description\n");
+ (void) FormatLocaleFile(file,
+ "-------------------------------------------------"
"------------------------------\n");
}
path=mime_info[i]->path;
- (void) fprintf(file,"%s",mime_info[i]->type);
+ (void) FormatLocaleFile(file,"%s",mime_info[i]->type);
if (strlen(mime_info[i]->type) <= 25)
{
- for (j=(long) strlen(mime_info[i]->type); j <= 27; j++)
- (void) fprintf(file," ");
+ for (j=(ssize_t) strlen(mime_info[i]->type); j <= 27; j++)
+ (void) FormatLocaleFile(file," ");
}
else
{
- (void) fprintf(file,"\n");
+ (void) FormatLocaleFile(file,"\n");
for (j=0; j <= 27; j++)
- (void) fprintf(file," ");
+ (void) FormatLocaleFile(file," ");
}
if (mime_info[i]->description != (char *) NULL)
- (void) fprintf(file,"%s",mime_info[i]->description);
- (void) fprintf(file,"\n");
+ (void) FormatLocaleFile(file,"%s",mime_info[i]->description);
+ (void) FormatLocaleFile(file,"\n");
}
(void) fflush(file);
mime_info=(const MimeInfo **) RelinquishMagickMemory((void *) mime_info);
% 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;
mime_info->signature=MagickSignature;
attribute=GetXMLTreeAttribute(mime,"data-type");
if (attribute != (const char *) NULL)
- mime_info->data_type=(DataType) ParseMagickOption(MagickDataTypeOptions,
+ mime_info->data_type=(DataType) ParseCommandOption(MagickDataTypeOptions,
MagickTrue,attribute);
attribute=GetXMLTreeAttribute(mime,"description");
if (attribute != (const char *) NULL)
mime_info->description=ConstantString(attribute);
attribute=GetXMLTreeAttribute(mime,"endian");
if (attribute != (const char *) NULL)
- mime_info->endian=(EndianType) ParseMagickOption(MagickEndianOptions,
+ mime_info->endian=(EndianType) ParseCommandOption(MagickEndianOptions,
MagickTrue,attribute);
attribute=GetXMLTreeAttribute(mime,"magic");
if (attribute != (const char *) NULL)
}
token=DestroyString(token);
if (mime_info->data_type != StringData)
- mime_info->value=strtol((char *) mime_info->magic,(char **) NULL,0);
+ mime_info->value=(ssize_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=(ssize_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);
ExceptionInfo
*exception;
- (void) FormatMagickString(filename,MaxTextExtent,"file.%s",magick);
+ (void) FormatLocaleString(filename,MaxTextExtent,"file.%s",magick);
LocaleLower(filename);
exception=AcquireExceptionInfo();
mime_info=GetMimeInfo(filename,(unsigned char *) " ",1,exception);
exception=DestroyExceptionInfo(exception);
if (mime_info != (const MimeInfo *) NULL)
return(ConstantString(GetMimeType(mime_info)));
- (void) FormatMagickString(media,MaxTextExtent,"image/x-%s",magick);
+ (void) FormatLocaleString(media,MaxTextExtent,"image/x-%s",magick);
LocaleLower(media+8);
return(ConstantString(media));
}
*/
MagickExport MagickBooleanType MimeComponentGenesis(void)
{
- assert(mime_semaphore == (SemaphoreInfo *) NULL);
- mime_semaphore=AllocateSemaphoreInfo();
+ AcquireSemaphoreInfo(&mime_semaphore);
return(MagickTrue);
}
\f
{
if (mime_semaphore == (SemaphoreInfo *) NULL)
AcquireSemaphoreInfo(&mime_semaphore);
- (void) LockSemaphoreInfo(mime_semaphore);
+ LockSemaphoreInfo(mime_semaphore);
if (mime_list != (LinkedListInfo *) NULL)
mime_list=DestroyLinkedList(mime_list,DestroyMimeElement);
instantiate_mime=MagickFalse;
- (void) UnlockSemaphoreInfo(mime_semaphore);
+ UnlockSemaphoreInfo(mime_semaphore);
DestroySemaphoreInfo(&mime_semaphore);
}