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-2014 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"
50 #include "MagickCore/version-private.h"
55 #define MagickURLFilename "index.html"
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 % G e t M a g i c k C o p y r i g h t %
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 % GetMagickCopyright() returns the ImageMagick API copyright as a string.
70 % The format of the GetMagickCopyright method is:
72 % const char *GetMagickCopyright(void)
75 MagickExport const char *GetMagickCopyright(void)
77 return(MagickCopyright);
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % G e t M a g i c k D e l e g a t e s %
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 % GetMagickDelegates() returns the ImageMagick delegate libraries.
93 % The format of the GetMagickDelegates method is:
95 % const char *GetMagickDelegates(void)
97 % No parameters are required.
100 MagickExport const char *GetMagickDelegates(void)
103 #if defined(MAGICKCORE_AUTOTRACE_DELEGATE)
106 #if defined(MAGICKCORE_BZLIB_DELEGATE)
109 #if defined(MAGICKCORE_CAIRO_DELEGATE)
112 #if defined(MAGICKCORE_DJVU_DELEGATE)
115 #if defined(MAGICKCORE_DPS_DELEGATE)
118 #if defined(MAGICKCORE_EMF_DELEGATE)
121 #if defined(MAGICKCORE_FFTW_DELEGATE)
124 #if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
127 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
130 #if defined(MAGICKCORE_FPX_DELEGATE)
133 #if defined(MAGICKCORE_GS_DELEGATE)
136 #if defined(MAGICKCORE_GVC_DELEGATE)
139 #if defined(MAGICKCORE_JBIG_DELEGATE)
142 #if defined(MAGICKCORE_JPEG_DELEGATE) && defined(MAGICKCORE_PNG_DELEGATE)
145 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE)
148 #if defined(MAGICKCORE_JPEG_DELEGATE)
151 #if defined(MAGICKCORE_LCMS_DELEGATE)
154 #if defined(MAGICKCORE_LQR_DELEGATE)
157 #if defined(MAGICKCORE_LTDL_DELEGATE)
160 #if defined(MAGICKCORE_LZMA_DELEGATE)
163 #if defined(MAGICKCORE_OPENEXR_DELEGATE)
166 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
169 #if defined(MAGICKCORE_PNG_DELEGATE)
172 #if defined(MAGICKCORE_DPS_DELEGATE) || defined(MAGICKCORE_GS_DELEGATE) || defined(WIN32)
175 #if defined(MAGICKCORE_RSVG_DELEGATE)
178 #if defined(MAGICKCORE_TIFF_DELEGATE)
181 #if defined(MAGICKCORE_WEBP_DELEGATE)
184 #if defined(MAGICKCORE_WMF_DELEGATE) || defined (MAGICKCORE_WMFLITE_DELEGATE)
187 #if defined(MAGICKCORE_X11_DELEGATE)
190 #if defined(MAGICKCORE_XML_DELEGATE)
193 #if defined(MAGICKCORE_ZLIB_DELEGATE)
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 % G e t M a g i c k F e a t u r e s %
208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 % GetMagickFeatures() returns the ImageMagick features.
212 % The format of the GetMagickFeatures method is:
214 % const char *GetMagickFeatures(void)
216 % No parameters are required.
219 MagickExport const char *GetMagickFeatures(void)
222 #if defined(MAGICKCORE_BUILD_MODULES) || defined(_DLL)
225 #if defined(MAGICKCORE_HDRI_SUPPORT)
228 #if defined(MAGICKCORE_OPENCL_SUPPORT)
231 #if defined(MAGICKCORE_OPENMP_SUPPORT)
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 % G e t M a g i c k H o m e U R L %
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 % GetMagickHomeURL() returns the ImageMagick home URL.
250 % The format of the GetMagickHomeURL method is:
252 % char *GetMagickHomeURL(void)
255 MagickExport char *GetMagickHomeURL(void)
269 exception=AcquireExceptionInfo();
270 paths=GetConfigurePaths(MagickURLFilename,exception);
271 exception=DestroyExceptionInfo(exception);
272 if (paths == (LinkedListInfo *) NULL)
273 return(ConstantString(MagickHomeURL));
274 element=(const char *) GetNextValueInLinkedList(paths);
275 while (element != (const char *) NULL)
277 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",element,
278 DirectorySeparator,MagickURLFilename);
279 if (IsPathAccessible(path) != MagickFalse)
280 return(ConstantString(path));
281 element=(const char *) GetNextValueInLinkedList(paths);
283 return(ConstantString(MagickHomeURL));
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291 % G e t M a g i c k P a c k a g e N a m e %
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 % GetMagickPackageName() returns the ImageMagick package name.
299 % The format of the GetMagickName method is:
301 % const char *GetMagickName(void)
303 % No parameters are required.
306 MagickExport const char *GetMagickPackageName(void)
308 return(MagickPackageName);
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 % G e t M a g i c k Q u a n t u m D e p t h %
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 % GetMagickQuantumDepth() returns the ImageMagick quantum depth.
324 % The format of the GetMagickQuantumDepth method is:
326 % const char *GetMagickQuantumDepth(size_t *depth)
328 % A description of each parameter follows:
330 % o depth: the quantum depth is returned as a number.
333 MagickExport const char *GetMagickQuantumDepth(size_t *depth)
335 if (depth != (size_t *) NULL)
336 *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
337 return(MagickQuantumDepth);
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
345 % G e t M a g i c k Q u a n t u m R a n g e %
349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351 % GetMagickQuantumRange() returns the ImageMagick quantum range.
353 % The format of the GetMagickQuantumRange method is:
355 % const char *GetMagickQuantumRange(size_t *range)
357 % A description of each parameter follows:
359 % o range: the quantum range is returned as a number.
362 MagickExport const char *GetMagickQuantumRange(size_t *range)
364 if (range != (size_t *) NULL)
365 *range=(size_t) QuantumRange;
366 return(MagickQuantumRange);
370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374 % G e t M a g i c k R e l e a s e D a t e %
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380 % GetMagickReleaseDate() returns the ImageMagick release date.
382 % The format of the GetMagickReleaseDate method is:
384 % const char *GetMagickReleaseDate(void)
386 % No parameters are required.
389 MagickExport const char *GetMagickReleaseDate(void)
391 return(MagickReleaseDate);
395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399 % G e t M a g i c k S i g n a t u r e %
403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405 % GetMagickSignature() returns a signature that uniquely encodes the
406 % MagickCore libary version, quantum depth, HDRI status, OS word size, and
409 % The format of the GetMagickSignature method is:
411 % unsigned int GetMagickSignature(const StringInfo *nonce)
413 % A description of each parameter follows:
415 % o nonce: arbitrary data.
419 static unsigned int CRC32(const unsigned char *message,const size_t length)
424 static MagickBooleanType
425 crc_initial = MagickFalse;
434 Generate a 32-bit cyclic redundancy check for the message.
436 if (crc_initial == MagickFalse)
438 register unsigned int
444 for (i=0; i < 256; i++)
450 for (j=0; j < 8; j++)
451 alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1);
454 crc_initial=MagickTrue;
457 for (i=0; i < (ssize_t) length; i++)
458 crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8);
459 return(crc ^ 0xFFFFFFFF);
462 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
464 register unsigned char
473 version=AcquireStringInfo(MaxTextExtent);
474 p=GetStringInfoDatum(version);
475 signature=MAGICKCORE_QUANTUM_DEPTH;
476 (void) memcpy(p,&signature,sizeof(signature));
477 p+=sizeof(signature);
478 signature=MAGICKCORE_HDRI_ENABLE;
479 (void) memcpy(p,&signature,sizeof(signature));
480 p+=sizeof(signature);
481 signature=MagickLibInterface;
482 (void) memcpy(p,&signature,sizeof(signature));
483 p+=sizeof(signature);
484 signature=1; /* endianess */
485 (void) memcpy(p,&signature,sizeof(signature));
486 p+=sizeof(signature);
487 SetStringInfoLength(version,p-GetStringInfoDatum(version));
488 if (nonce != (const StringInfo *) NULL)
489 ConcatenateStringInfo(version,nonce);
490 signature=CRC32(GetStringInfoDatum(version),GetStringInfoLength(version));
491 version=DestroyStringInfo(version);
496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500 % G e t M a g i c k V e r s i o n %
504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
506 % GetMagickVersion() returns the ImageMagick API version as a string and
509 % The format of the GetMagickVersion method is:
511 % const char *GetMagickVersion(size_t *version)
513 % A description of each parameter follows:
515 % o version: the ImageMagick version is returned as a number.
518 MagickExport const char *GetMagickVersion(size_t *version)
520 if (version != (size_t *) NULL)
521 *version=MagickLibVersion;
522 return(MagickVersion);
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 % L i s t M a g i c k V e r s i o n %
534 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536 % ListMagickVersion() identifies the ImageMagick version by printing its
537 % attributes to the file. Attributes include the copyright, features, and
540 % The format of the ListMagickVersion method is:
542 % void ListMagickVersion(FILE *file)
544 % A description of each parameter follows:
546 % o file: the file, typically stdout.
549 MagickExport void ListMagickVersion(FILE *file)
551 (void) FormatLocaleFile(file,"Version: %s\n",
552 GetMagickVersion((size_t *) NULL));
553 (void) FormatLocaleFile(file,"Copyright: %s\n",GetMagickCopyright());
554 (void) FormatLocaleFile(file,"Features: %s\n",GetMagickFeatures());
555 (void) FormatLocaleFile(file,"Delegates: %s\n\n",GetMagickDelegates());