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-2017 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 % https://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/linked-list.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_FLIF_DELEGATE)
127 #if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
130 #if defined(MAGICKCORE_FPX_DELEGATE)
133 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
136 #if defined(MAGICKCORE_GS_DELEGATE)
139 #if defined(MAGICKCORE_GVC_DELEGATE)
142 #if defined(MAGICKCORE_JBIG_DELEGATE)
145 #if defined(MAGICKCORE_JPEG_DELEGATE) && defined(MAGICKCORE_PNG_DELEGATE)
148 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE)
151 #if defined(MAGICKCORE_JPEG_DELEGATE)
154 #if defined(MAGICKCORE_LCMS_DELEGATE)
157 #if defined(MAGICKCORE_LQR_DELEGATE)
160 #if defined(MAGICKCORE_LTDL_DELEGATE)
163 #if defined(MAGICKCORE_LZMA_DELEGATE)
166 #if defined(MAGICKCORE_OPENEXR_DELEGATE)
169 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
172 #if defined(MAGICKCORE_PNG_DELEGATE)
175 #if defined(MAGICKCORE_DPS_DELEGATE) || defined(MAGICKCORE_GS_DELEGATE) || defined(WIN32)
178 #if defined(MAGICKCORE_RSVG_DELEGATE)
181 #if defined(MAGICKCORE_TIFF_DELEGATE)
184 #if defined(MAGICKCORE_WEBP_DELEGATE)
187 #if defined(MAGICKCORE_WMF_DELEGATE) || defined (MAGICKCORE_WMFLITE_DELEGATE)
190 #if defined(MAGICKCORE_X11_DELEGATE)
193 #if defined(MAGICKCORE_XML_DELEGATE)
196 #if defined(MAGICKCORE_ZLIB_DELEGATE)
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207 % G e t M a g i c k F e a t u r e s %
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213 % GetMagickFeatures() returns the ImageMagick features.
215 % The format of the GetMagickFeatures method is:
217 % const char *GetMagickFeatures(void)
219 % No parameters are required.
222 MagickExport const char *GetMagickFeatures(void)
225 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG)
228 #if defined(MAGICKCORE_CIPHER_SUPPORT)
231 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_HAVE_SOCKET) && defined(MAGICKCORE_THREAD_SUPPORT)
234 #if defined(MAGICKCORE_HDRI_SUPPORT)
237 #if defined(MAGICKCORE_BUILD_MODULES) || defined(_DLL)
240 #if defined(MAGICKCORE_OPENCL_SUPPORT)
243 #if defined(MAGICKCORE_OPENMP_SUPPORT)
246 #if defined(ZERO_CONFIGURATION_SUPPORT)
247 "Zero-configuration "
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 % G e t M a g i c k H o m e U R L %
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
263 % GetMagickHomeURL() returns the ImageMagick home URL.
265 % The format of the GetMagickHomeURL method is:
267 % char *GetMagickHomeURL(void)
270 MagickExport char *GetMagickHomeURL(void)
273 path[MagickPathExtent];
284 exception=AcquireExceptionInfo();
285 paths=GetConfigurePaths(MagickURLFilename,exception);
286 exception=DestroyExceptionInfo(exception);
287 if (paths == (LinkedListInfo *) NULL)
288 return(ConstantString(MagickHomeURL));
289 element=(const char *) GetNextValueInLinkedList(paths);
290 while (element != (const char *) NULL)
292 (void) FormatLocaleString(path,MagickPathExtent,"%s%s%s",element,
293 DirectorySeparator,MagickURLFilename);
294 if (IsPathAccessible(path) != MagickFalse)
296 paths=DestroyLinkedList(paths,RelinquishMagickMemory);
297 return(ConstantString(path));
299 element=(const char *) GetNextValueInLinkedList(paths);
301 paths=DestroyLinkedList(paths,RelinquishMagickMemory);
302 return(ConstantString(MagickHomeURL));
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310 % G e t M a g i c k L i c e n s e %
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 % GetMagickLicense() returns the ImageMagick API license as a string.
318 % The format of the GetMagickLicense method is:
320 % const char *GetMagickLicense(void)
323 MagickExport const char *GetMagickLicense(void)
325 return(MagickAuthoritativeLicense);
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333 % G e t M a g i c k P a c k a g e N a m e %
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
339 % GetMagickPackageName() returns the ImageMagick package name.
341 % The format of the GetMagickName method is:
343 % const char *GetMagickName(void)
345 % No parameters are required.
348 MagickExport const char *GetMagickPackageName(void)
350 return(MagickPackageName);
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 % G e t M a g i c k Q u a n t u m D e p t h %
362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364 % GetMagickQuantumDepth() returns the ImageMagick quantum depth.
366 % The format of the GetMagickQuantumDepth method is:
368 % const char *GetMagickQuantumDepth(size_t *depth)
370 % A description of each parameter follows:
372 % o depth: the quantum depth is returned as a number.
375 MagickExport const char *GetMagickQuantumDepth(size_t *depth)
377 if (depth != (size_t *) NULL)
378 *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
379 return(MagickQuantumDepth);
383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387 % G e t M a g i c k Q u a n t u m R a n g e %
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393 % GetMagickQuantumRange() returns the ImageMagick quantum range.
395 % The format of the GetMagickQuantumRange method is:
397 % const char *GetMagickQuantumRange(size_t *range)
399 % A description of each parameter follows:
401 % o range: the quantum range is returned as a number.
404 MagickExport const char *GetMagickQuantumRange(size_t *range)
406 if (range != (size_t *) NULL)
407 *range=(size_t) QuantumRange;
408 return(MagickQuantumRange);
412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 % G e t M a g i c k R e l e a s e D a t e %
420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422 % GetMagickReleaseDate() returns the ImageMagick release date.
424 % The format of the GetMagickReleaseDate method is:
426 % const char *GetMagickReleaseDate(void)
428 % No parameters are required.
431 MagickExport const char *GetMagickReleaseDate(void)
433 return(MagickReleaseDate);
437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 % G e t M a g i c k S i g n a t u r e %
445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 % GetMagickSignature() returns a signature that uniquely encodes the
448 % MagickCore libary version, quantum depth, HDRI status, OS word size, and
451 % The format of the GetMagickSignature method is:
453 % unsigned int GetMagickSignature(const StringInfo *nonce)
455 % A description of each parameter follows:
457 % o nonce: arbitrary data.
461 static unsigned int CRC32(const unsigned char *message,const size_t length)
466 static MagickBooleanType
467 crc_initial = MagickFalse;
476 Generate a 32-bit cyclic redundancy check for the message.
478 if (crc_initial == MagickFalse)
480 register unsigned int
486 for (i=0; i < 256; i++)
492 for (j=0; j < 8; j++)
493 alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1);
496 crc_initial=MagickTrue;
499 for (i=0; i < (ssize_t) length; i++)
500 crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8);
501 return(crc ^ 0xFFFFFFFF);
504 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
506 register unsigned char
515 version=AcquireStringInfo(MagickPathExtent);
516 p=GetStringInfoDatum(version);
517 signature=MAGICKCORE_QUANTUM_DEPTH;
518 (void) memcpy(p,&signature,sizeof(signature));
519 p+=sizeof(signature);
520 signature=MAGICKCORE_HDRI_ENABLE;
521 (void) memcpy(p,&signature,sizeof(signature));
522 p+=sizeof(signature);
523 signature=MagickLibInterface;
524 (void) memcpy(p,&signature,sizeof(signature));
525 p+=sizeof(signature);
526 signature=1; /* endianess */
527 (void) memcpy(p,&signature,sizeof(signature));
528 p+=sizeof(signature);
529 SetStringInfoLength(version,p-GetStringInfoDatum(version));
530 if (nonce != (const StringInfo *) NULL)
531 ConcatenateStringInfo(version,nonce);
532 signature=CRC32(GetStringInfoDatum(version),GetStringInfoLength(version));
533 version=DestroyStringInfo(version);
538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 % G e t M a g i c k V e r s i o n %
546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548 % GetMagickVersion() returns the ImageMagick API version as a string and
551 % The format of the GetMagickVersion method is:
553 % const char *GetMagickVersion(size_t *version)
555 % A description of each parameter follows:
557 % o version: the ImageMagick version is returned as a number.
560 MagickExport const char *GetMagickVersion(size_t *version)
562 if (version != (size_t *) NULL)
563 *version=MagickLibVersion;
564 return(MagickVersion);
568 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 % L i s t M a g i c k V e r s i o n %
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 % ListMagickVersion() identifies the ImageMagick version by printing its
579 % attributes to the file. Attributes include the copyright, features, and
582 % The format of the ListMagickVersion method is:
584 % void ListMagickVersion(FILE *file)
586 % A description of each parameter follows:
588 % o file: the file, typically stdout.
591 MagickExport void ListMagickVersion(FILE *file)
593 (void) FormatLocaleFile(file,"Version: %s\n",
594 GetMagickVersion((size_t *) NULL));;
595 (void) FormatLocaleFile(file,"Copyright: %s\n",GetMagickCopyright());
596 (void) FormatLocaleFile(file,"License: %s\n",GetMagickLicense());
597 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_MSC_FULL_VER)
598 (void) FormatLocaleFile(file,"Visual C++: %d\n",_MSC_FULL_VER);
600 (void) FormatLocaleFile(file,"Features: %s\n",GetMagickFeatures());
601 (void) FormatLocaleFile(file,"Delegates (built-in): %s\n",
602 GetMagickDelegates());