2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % V V EEEEE RRRR SSSSS IIIII OOO N N %
7 % V V E R R SS I O O NN N %
8 % V V EEE RRRR SSS I O O N N N %
9 % V V E R R SS I O O N NN %
10 % V EEEEE R R SSSSS IIIII OOO N N %
13 % MagickCore Version and Copyright Methods %
20 % Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 #include "MagickCore/studio.h"
40 #include "MagickCore/configure.h"
41 #include "MagickCore/exception.h"
42 #include "MagickCore/exception-private.h"
43 #include "MagickCore/hashmap.h"
44 #include "MagickCore/locale_.h"
45 #include "MagickCore/option.h"
46 #include "MagickCore/string_.h"
47 #include "MagickCore/utility.h"
48 #include "MagickCore/utility-private.h"
49 #include "MagickCore/version.h"
54 #define MagickURLFilename "index.html"
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 % G e t M a g i c k C o p y r i g h t %
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % GetMagickCopyright() returns the ImageMagick API copyright as a string.
69 % The format of the GetMagickCopyright method is:
71 % const char *GetMagickCopyright(void)
74 MagickExport const char *GetMagickCopyright(void)
76 return(MagickCopyright);
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 % G e t M a g i c k D e l e g a t e s %
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 % GetMagickDelegates() returns the ImageMagick delegate libraries.
92 % The format of the GetMagickDelegates method is:
94 % const char *GetMagickDelegates(void)
96 % No parameters are required.
99 MagickExport const char *GetMagickDelegates(void)
101 return(MagickDelegates);
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 % G e t M a g i c k F e a t u r e s %
113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115 % GetMagickFeatures() returns the ImageMagick features.
117 % The format of the GetMagickFeatures method is:
119 % const char *GetMagickFeatures(void)
121 % No parameters are required.
124 MagickExport const char *GetMagickFeatures(void)
126 return(MagickFeatures);
130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 % G e t M a g i c k H o m e U R L %
138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140 % GetMagickHomeURL() returns the ImageMagick home URL.
142 % The format of the GetMagickHomeURL method is:
144 % char *GetMagickHomeURL(void)
147 MagickExport char *GetMagickHomeURL(void)
161 exception=AcquireExceptionInfo();
162 paths=GetConfigurePaths(MagickURLFilename,exception);
163 exception=DestroyExceptionInfo(exception);
164 if (paths == (LinkedListInfo *) NULL)
165 return(ConstantString(MagickHomeURL));
166 element=(const char *) GetNextValueInLinkedList(paths);
167 while (element != (const char *) NULL)
169 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",element,
170 DirectorySeparator,MagickURLFilename);
171 if (IsPathAccessible(path) != MagickFalse)
172 return(ConstantString(path));
173 element=(const char *) GetNextValueInLinkedList(paths);
175 return(ConstantString(MagickHomeURL));
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 % G e t M a g i c k P a c k a g e N a m e %
187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189 % GetMagickPackageName() returns the ImageMagick package name.
191 % The format of the GetMagickName method is:
193 % const char *GetMagickName(void)
195 % No parameters are required.
198 MagickExport const char *GetMagickPackageName(void)
200 return(MagickPackageName);
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 % G e t M a g i c k Q u a n t u m D e p t h %
212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 % GetMagickQuantumDepth() returns the ImageMagick quantum depth.
216 % The format of the GetMagickQuantumDepth method is:
218 % const char *GetMagickQuantumDepth(size_t *depth)
220 % A description of each parameter follows:
222 % o depth: the quantum depth is returned as a number.
225 MagickExport const char *GetMagickQuantumDepth(size_t *depth)
227 if (depth != (size_t *) NULL)
228 *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
229 return(MagickQuantumDepth);
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 % G e t M a g i c k Q u a n t u m R a n g e %
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % GetMagickQuantumRange() returns the ImageMagick quantum range.
245 % The format of the GetMagickQuantumRange method is:
247 % const char *GetMagickQuantumRange(size_t *range)
249 % A description of each parameter follows:
251 % o range: the quantum range is returned as a number.
254 MagickExport const char *GetMagickQuantumRange(size_t *range)
256 if (range != (size_t *) NULL)
257 *range=(size_t) QuantumRange;
258 return(MagickQuantumRange);
262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 % G e t M a g i c k R e l e a s e D a t e %
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272 % GetMagickReleaseDate() returns the ImageMagick release date.
274 % The format of the GetMagickReleaseDate method is:
276 % const char *GetMagickReleaseDate(void)
278 % No parameters are required.
281 MagickExport const char *GetMagickReleaseDate(void)
283 return(MagickReleaseDate);
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291 % G e t M a g i c k S i g n a t u r e %
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 % GetMagickSignature() returns a signature that uniquely encodes the
298 % MagickCore libary version, quantum depth, HDRI status, OS word size, and
301 % The format of the GetMagickSignature method is:
303 % unsigned int GetMagickSignature(const StringInfo *nonce)
305 % A description of each parameter follows:
307 % o nonce: arbitrary data.
311 static unsigned int CRC32(const unsigned char *message,const size_t length)
316 static MagickBooleanType
317 crc_initial = MagickFalse;
326 Generate a 32-bit cyclic redundancy check for the message.
328 if (crc_initial == MagickFalse)
333 for (i=0; i < 256; i++)
338 alpha=(unsigned int) i;
339 for (j=0; j < 8; j++)
340 alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1);
343 crc_initial=MagickTrue;
346 for (i=0; i < (ssize_t) length; i++)
347 crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8);
348 return(crc ^ 0xFFFFFFFF);
351 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
353 register unsigned char
362 version=AcquireStringInfo(MaxTextExtent);
363 p=GetStringInfoDatum(version);
364 signature=MAGICKCORE_QUANTUM_DEPTH;
365 (void) memcpy(p,&signature,sizeof(signature));
366 p+=sizeof(signature);
367 signature=MAGICKCORE_HDRI_ENABLE;
368 (void) memcpy(p,&signature,sizeof(signature));
369 p+=sizeof(signature);
370 signature=MagickLibInterface;
371 (void) memcpy(p,&signature,sizeof(signature));
372 p+=sizeof(signature);
373 signature=1; /* endianess */
374 (void) memcpy(p,&signature,sizeof(signature));
375 p+=sizeof(signature);
376 SetStringInfoLength(version,p-GetStringInfoDatum(version));
377 if (nonce != (const StringInfo *) NULL)
378 ConcatenateStringInfo(version,nonce);
379 signature=CRC32(GetStringInfoDatum(version),GetStringInfoLength(version));
380 version=DestroyStringInfo(version);
385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389 % G e t M a g i c k V e r s i o n %
393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395 % GetMagickVersion() returns the ImageMagick API version as a string and
398 % The format of the GetMagickVersion method is:
400 % const char *GetMagickVersion(size_t *version)
402 % A description of each parameter follows:
404 % o version: the ImageMagick version is returned as a number.
407 MagickExport const char *GetMagickVersion(size_t *version)
409 if (version != (size_t *) NULL)
410 *version=MagickLibVersion;
411 return(MagickVersion);
415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 % L i s t M a g i c k V e r s i o n %
423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
425 % ListMagickVersion() identifies the ImageMagick version by printing its
426 % attributes to the file. Attributes include the copyright, features, and
429 % The format of the ListMagickVersion method is:
431 % void ListMagickVersion(FILE *file)
433 % A description of each parameter follows:
435 % o file: the file, typically stdout.
438 MagickExport void ListMagickVersion(FILE *file)
440 (void) FormatLocaleFile(file,"Version: %s\n",
441 GetMagickVersion((size_t *) NULL));
442 (void) FormatLocaleFile(file,"Copyright: %s\n",GetMagickCopyright());
443 (void) FormatLocaleFile(file,"Features: %s\n",GetMagickFeatures());
444 (void) FormatLocaleFile(file,"Delegates: %s\n\n",GetMagickDelegates());