From 6e323674c9d45d10365849e4cee6db17b9d0935b Mon Sep 17 00:00:00 2001 From: cristy <urban-warrior@git.imagemagick.org> Date: Tue, 5 Feb 2013 18:44:04 +0000 Subject: [PATCH] --- MagickCore/version.c | 30 +++++++++++++++++++++++++++++- coders/mpc.c | 26 ++++++++++++++------------ config/english.xml | 4 ++-- config/francais.xml | 4 ++-- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/MagickCore/version.c b/MagickCore/version.c index dc32a6c41..712805838 100644 --- a/MagickCore/version.c +++ b/MagickCore/version.c @@ -350,7 +350,35 @@ static unsigned int CRC32(const unsigned char *message,const size_t length) MagickExport unsigned int GetMagickSignature(const StringInfo *nonce) { - return(0); + register unsigned char + *p; + + StringInfo + *version; + + unsigned int + signature; + + version=AcquireStringInfo(MaxTextExtent); + p=GetStringInfoDatum(version); + signature=MagickLibVersion; + (void) memcpy(p,&signature,sizeof(signature)); + p+=sizeof(signature); + signature=MAGICKCORE_QUANTUM_DEPTH; + (void) memcpy(p,&signature,sizeof(signature)); + p+=sizeof(signature); + signature=MAGICKCORE_HDRI_ENABLE; + (void) memcpy(p,&signature,sizeof(signature)); + p+=sizeof(signature); + signature=1; /* endianess */ + (void) memcpy(p,&signature,sizeof(signature)); + p+=sizeof(signature); + SetStringInfoLength(version,p-GetStringInfoDatum(version)); + if (nonce != (const StringInfo *) NULL) + ConcatenateStringInfo(version,nonce); + signature=CRC32(GetStringInfoDatum(version),GetStringInfoLength(version)); + version=DestroyStringInfo(version); + return(signature); } /* diff --git a/coders/mpc.c b/coders/mpc.c index 88ffa2d8f..0f0c0d22d 100644 --- a/coders/mpc.c +++ b/coders/mpc.c @@ -177,8 +177,7 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) size_t depth, - length, - quantum_depth; + length; ssize_t count; @@ -186,6 +185,9 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) StringInfo *profile; + unsigned int + signature; + /* Open image file. */ @@ -222,7 +224,7 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) profiles=(LinkedListInfo *) NULL; length=MaxTextExtent; options=AcquireString((char *) NULL); - quantum_depth=MAGICKCORE_QUANTUM_DEPTH; + signature=GetMagickSignature((const StringInfo *) NULL); image->depth=8; image->compression=NoCompression; while ((isgraph(c) != MagickFalse) && (c != (int) ':')) @@ -605,11 +607,6 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) image->quality=StringToUnsignedLong(options); break; } - if (LocaleCompare(keyword,"quantum-depth") == 0) - { - quantum_depth=StringToUnsignedLong(options); - break; - } (void) SetImageProperty(image,keyword,options,exception); break; } @@ -661,6 +658,11 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) image->scene=StringToUnsignedLong(options); break; } + if (LocaleCompare(keyword,"signature") == 0) + { + signature=(unsigned int) StringToUnsignedLong(options); + break; + } (void) SetImageProperty(image,keyword,options,exception); break; } @@ -752,8 +754,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) (image->compression == UndefinedCompression) || (image->columns == 0) || (image->rows == 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); - if (quantum_depth != MAGICKCORE_QUANTUM_DEPTH) - ThrowReaderException(CacheError,"InconsistentPersistentCacheDepth"); + if (signature != GetMagickSignature((const StringInfo *) NULL)) + ThrowReaderException(CacheError,"IncompatibleAPI"); if (image->montage != (char *) NULL) { register char @@ -1091,8 +1093,8 @@ static MagickBooleanType WriteMPCImage(const ImageInfo *image_info,Image *image, (image->colors > (one << depth))) image->storage_class=DirectClass; (void) WriteBlobString(image,"id=MagickCache\n"); - (void) FormatLocaleString(buffer,MaxTextExtent,"quantum-depth=%d\n", - MAGICKCORE_QUANTUM_DEPTH); + (void) FormatLocaleString(buffer,MaxTextExtent,"signature=%u\n", + GetMagickSignature((const StringInfo *) NULL)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent, "class=%s colors=%.20g alpha-trait=%s\n",CommandOptionToMnemonic( diff --git a/config/english.xml b/config/english.xml index 52c1fd2ff..2a0532f81 100644 --- a/config/english.xml +++ b/config/english.xml @@ -38,8 +38,8 @@ <message name="CacheResourcesExhausted"> cache resources exhausted </message> - <message name="InconsistentPersistentCacheDepth"> - inconsistent persistent cache depth + <message name="IncompatibleAPI"> + incompatible API </message> <message name="NoPixelsDefinedInCache"> no pixels defined in cache diff --git a/config/francais.xml b/config/francais.xml index 465f9a65c..ffdb388fc 100644 --- a/config/francais.xml +++ b/config/francais.xml @@ -38,8 +38,8 @@ <message name="CacheResourcesExhausted"> Ressources du cache épuisées </message> - <message name="InconsistentPersistentCacheDepth"> - profondeur du cache persistant inconsistante + <message name="IncompatibleAPI"> + incompatible API </message> <message name="NoPixelsDefinedInCache"> pas de pixels définis dans le cache -- 2.40.0