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"
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)
102 #if defined(MAGICKCORE_AUTOTRACE_DELEGATE)
105 #if defined(MAGICKCORE_BZLIB_DELEGATE)
108 #if defined(MAGICKCORE_CAIRO_DELEGATE)
111 #if defined(MAGICKCORE_DJVU_DELEGATE)
114 #if defined(MAGICKCORE_DPS_DELEGATE)
117 #if defined(MAGICKCORE_EMF_DELEGATE)
120 #if defined(MAGICKCORE_FFTW_DELEGATE)
123 #if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
126 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
129 #if defined(MAGICKCORE_FPX_DELEGATE)
132 #if defined(MAGICKCORE_GS_DELEGATE)
135 #if defined(MAGICKCORE_GVC_DELEGATE)
138 #if defined(MAGICKCORE_JBIG_DELEGATE)
141 #if defined(MAGICKCORE_JPEG_DELEGATE) && defined(MAGICKCORE_PNG_DELEGATE)
144 #if defined(MAGICKCORE_JP2_DELEGATE)
147 #if defined(MAGICKCORE_JPEG_DELEGATE)
150 #if defined(MAGICKCORE_LCMS_DELEGATE)
153 #if defined(MAGICKCORE_LQR_DELEGATE)
156 #if defined(MAGICKCORE_LTDL_DELEGATE)
159 #if defined(MAGICKCORE_LZMA_DELEGATE)
162 #if defined(MAGICKCORE_OPENEXR_DELEGATE)
165 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
168 #if defined(MAGICKCORE_PNG_DELEGATE)
171 #if defined(MAGICKCORE_DPS_DELEGATE) || defined(MAGICKCORE_GS_DELEGATE) || defined(WIN32)
174 #if defined(MAGICKCORE_RSVG_DELEGATE)
177 #if defined(MAGICKCORE_TIFF_DELEGATE)
180 #if defined(MAGICKCORE_WEBP_DELEGATE)
183 #if defined(MAGICKCORE_WMF_DELEGATE) || defined (MAGICKCORE_WMFLITE_DELEGATE)
186 #if defined(MAGICKCORE_X11_DELEGATE)
189 #if defined(MAGICKCORE_XML_DELEGATE)
192 #if defined(MAGICKCORE_ZLIB_DELEGATE)
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 % G e t M a g i c k F e a t u r e s %
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 % GetMagickFeatures() returns the ImageMagick features.
211 % The format of the GetMagickFeatures method is:
213 % const char *GetMagickFeatures(void)
215 % No parameters are required.
218 MagickExport const char *GetMagickFeatures(void)
221 #if defined(MAGICKCORE_BUILD_MODULES) || defined(_DLL)
224 #if defined(MAGICKCORE_HDRI_SUPPORT)
227 #if defined(MAGICKCORE_OPENCL_SUPPORT)
230 #if defined(MAGICKCORE_OPENMP_SUPPORT)
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 % G e t M a g i c k H o m e U R L %
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247 % GetMagickHomeURL() returns the ImageMagick home URL.
249 % The format of the GetMagickHomeURL method is:
251 % char *GetMagickHomeURL(void)
254 MagickExport char *GetMagickHomeURL(void)
268 exception=AcquireExceptionInfo();
269 paths=GetConfigurePaths(MagickURLFilename,exception);
270 exception=DestroyExceptionInfo(exception);
271 if (paths == (LinkedListInfo *) NULL)
272 return(ConstantString(MagickHomeURL));
273 element=(const char *) GetNextValueInLinkedList(paths);
274 while (element != (const char *) NULL)
276 (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",element,
277 DirectorySeparator,MagickURLFilename);
278 if (IsPathAccessible(path) != MagickFalse)
279 return(ConstantString(path));
280 element=(const char *) GetNextValueInLinkedList(paths);
282 return(ConstantString(MagickHomeURL));
286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 % G e t M a g i c k P a c k a g e N a m e %
294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296 % GetMagickPackageName() returns the ImageMagick package name.
298 % The format of the GetMagickName method is:
300 % const char *GetMagickName(void)
302 % No parameters are required.
305 MagickExport const char *GetMagickPackageName(void)
307 return(MagickPackageName);
311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315 % G e t M a g i c k Q u a n t u m D e p t h %
319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321 % GetMagickQuantumDepth() returns the ImageMagick quantum depth.
323 % The format of the GetMagickQuantumDepth method is:
325 % const char *GetMagickQuantumDepth(size_t *depth)
327 % A description of each parameter follows:
329 % o depth: the quantum depth is returned as a number.
332 MagickExport const char *GetMagickQuantumDepth(size_t *depth)
334 if (depth != (size_t *) NULL)
335 *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
336 return(MagickQuantumDepth);
340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
344 % G e t M a g i c k Q u a n t u m R a n g e %
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350 % GetMagickQuantumRange() returns the ImageMagick quantum range.
352 % The format of the GetMagickQuantumRange method is:
354 % const char *GetMagickQuantumRange(size_t *range)
356 % A description of each parameter follows:
358 % o range: the quantum range is returned as a number.
361 MagickExport const char *GetMagickQuantumRange(size_t *range)
363 if (range != (size_t *) NULL)
364 *range=(size_t) QuantumRange;
365 return(MagickQuantumRange);
369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373 % G e t M a g i c k R e l e a s e D a t e %
377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 % GetMagickReleaseDate() returns the ImageMagick release date.
381 % The format of the GetMagickReleaseDate method is:
383 % const char *GetMagickReleaseDate(void)
385 % No parameters are required.
388 MagickExport const char *GetMagickReleaseDate(void)
390 return(MagickReleaseDate);
394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398 % G e t M a g i c k S i g n a t u r e %
402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404 % GetMagickSignature() returns a signature that uniquely encodes the
405 % MagickCore libary version, quantum depth, HDRI status, OS word size, and
408 % The format of the GetMagickSignature method is:
410 % unsigned int GetMagickSignature(const StringInfo *nonce)
412 % A description of each parameter follows:
414 % o nonce: arbitrary data.
418 static unsigned int CRC32(const unsigned char *message,const size_t length)
423 static MagickBooleanType
424 crc_initial = MagickFalse;
433 Generate a 32-bit cyclic redundancy check for the message.
435 if (crc_initial == MagickFalse)
437 register unsigned int
443 for (i=0; i < 256; i++)
449 for (j=0; j < 8; j++)
450 alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1);
453 crc_initial=MagickTrue;
456 for (i=0; i < (ssize_t) length; i++)
457 crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8);
458 return(crc ^ 0xFFFFFFFF);
461 #if defined(__cplusplus) || defined(c_plusplus)
465 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
467 register unsigned char
476 version=AcquireStringInfo(MaxTextExtent);
477 p=GetStringInfoDatum(version);
478 signature=MAGICKCORE_QUANTUM_DEPTH;
479 (void) memcpy(p,&signature,sizeof(signature));
480 p+=sizeof(signature);
481 signature=MAGICKCORE_HDRI_ENABLE;
482 (void) memcpy(p,&signature,sizeof(signature));
483 p+=sizeof(signature);
484 signature=MagickLibInterface;
485 (void) memcpy(p,&signature,sizeof(signature));
486 p+=sizeof(signature);
487 signature=1; /* endianess */
488 (void) memcpy(p,&signature,sizeof(signature));
489 p+=sizeof(signature);
490 SetStringInfoLength(version,p-GetStringInfoDatum(version));
491 if (nonce != (const StringInfo *) NULL)
492 ConcatenateStringInfo(version,nonce);
493 signature=CRC32(GetStringInfoDatum(version),GetStringInfoLength(version));
494 version=DestroyStringInfo(version);
498 #if defined(__cplusplus) || defined(c_plusplus)
503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 % G e t M a g i c k V e r s i o n %
511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513 % GetMagickVersion() returns the ImageMagick API version as a string and
516 % The format of the GetMagickVersion method is:
518 % const char *GetMagickVersion(size_t *version)
520 % A description of each parameter follows:
522 % o version: the ImageMagick version is returned as a number.
525 MagickExport const char *GetMagickVersion(size_t *version)
527 if (version != (size_t *) NULL)
528 *version=MagickLibVersion;
529 return(MagickVersion);
533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
537 % L i s t M a g i c k V e r s i o n %
541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
543 % ListMagickVersion() identifies the ImageMagick version by printing its
544 % attributes to the file. Attributes include the copyright, features, and
547 % The format of the ListMagickVersion method is:
549 % void ListMagickVersion(FILE *file)
551 % A description of each parameter follows:
553 % o file: the file, typically stdout.
556 MagickExport void ListMagickVersion(FILE *file)
558 (void) FormatLocaleFile(file,"Version: %s\n",
559 GetMagickVersion((size_t *) NULL));
560 (void) FormatLocaleFile(file,"Copyright: %s\n",GetMagickCopyright());
561 (void) FormatLocaleFile(file,"Features: %s\n",GetMagickFeatures());
562 (void) FormatLocaleFile(file,"Delegates: %s\n\n",GetMagickDelegates());