]> granicus.if.org Git - imagemagick/blob - MagickCore/version.c
...
[imagemagick] / MagickCore / version.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
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               %
11 %                                                                             %
12 %                                                                             %
13 %                   MagickCore Version and Copyright Methods                  %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                   Cristy                                    %
17 %                               September 2002                                %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    https://www.imagemagick.org/script/license.php                           %
27 %                                                                             %
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.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 */
38 \f
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"
51 \f
52 /*
53   Define declarations.
54 */
55 #define MagickURLFilename  "index.html"
56 \f
57 /*
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %                                                                             %
60 %                                                                             %
61 %                                                                             %
62 %   G e t M a g i c k C o p y r i g h t                                       %
63 %                                                                             %
64 %                                                                             %
65 %                                                                             %
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %
68 %  GetMagickCopyright() returns the ImageMagick API copyright as a string.
69 %
70 %  The format of the GetMagickCopyright method is:
71 %
72 %      const char *GetMagickCopyright(void)
73 %
74 */
75 MagickExport const char *GetMagickCopyright(void)
76 {
77   return(MagickCopyright);
78 }
79 \f
80 /*
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 %                                                                             %
83 %                                                                             %
84 %                                                                             %
85 %   G e t M a g i c k D e l e g a t e s                                       %
86 %                                                                             %
87 %                                                                             %
88 %                                                                             %
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %
91 %  GetMagickDelegates() returns the ImageMagick delegate libraries.
92 %
93 %  The format of the GetMagickDelegates method is:
94 %
95 %      const char *GetMagickDelegates(void)
96 %
97 %  No parameters are required.
98 %
99 */
100 MagickExport const char *GetMagickDelegates(void)
101 {
102   return ""
103 #if defined(MAGICKCORE_AUTOTRACE_DELEGATE)
104   "autotrace "
105 #endif
106 #if defined(MAGICKCORE_BZLIB_DELEGATE)
107   "bzlib "
108 #endif
109 #if defined(MAGICKCORE_CAIRO_DELEGATE)
110   "cairo "
111 #endif
112 #if defined(MAGICKCORE_DJVU_DELEGATE)
113   "djvu "
114 #endif
115 #if defined(MAGICKCORE_DPS_DELEGATE)
116   "dps "
117 #endif
118 #if defined(MAGICKCORE_EMF_DELEGATE)
119   "emf "
120 #endif
121 #if defined(MAGICKCORE_FFTW_DELEGATE)
122   "fftw "
123 #endif
124 #if defined(MAGICKCORE_FLIF_DELEGATE)
125   "flif "
126 #endif
127 #if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
128   "fontconfig "
129 #endif
130 #if defined(MAGICKCORE_FPX_DELEGATE)
131   "fpx "
132 #endif
133 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
134   "freetype "
135 #endif
136 #if defined(MAGICKCORE_GS_DELEGATE)
137   "gslib "
138 #endif
139 #if defined(MAGICKCORE_GVC_DELEGATE)
140   "gvc "
141 #endif
142 #if defined(MAGICKCORE_JBIG_DELEGATE)
143   "jbig "
144 #endif
145 #if defined(MAGICKCORE_JPEG_DELEGATE) && defined(MAGICKCORE_PNG_DELEGATE)
146   "jng "
147 #endif
148 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE)
149   "jp2 "
150 #endif
151 #if defined(MAGICKCORE_JPEG_DELEGATE)
152   "jpeg "
153 #endif
154 #if defined(MAGICKCORE_LCMS_DELEGATE)
155   "lcms "
156 #endif
157 #if defined(MAGICKCORE_LQR_DELEGATE)
158   "lqr "
159 #endif
160 #if defined(MAGICKCORE_LTDL_DELEGATE)
161   "ltdl "
162 #endif
163 #if defined(MAGICKCORE_LZMA_DELEGATE)
164   "lzma "
165 #endif
166 #if defined(MAGICKCORE_OPENEXR_DELEGATE)
167   "openexr "
168 #endif
169 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
170   "pangocairo "
171 #endif
172 #if defined(MAGICKCORE_PNG_DELEGATE)
173   "png "
174 #endif
175 #if defined(MAGICKCORE_DPS_DELEGATE) || defined(MAGICKCORE_GS_DELEGATE) || defined(WIN32)
176   "ps "
177 #endif
178 #if defined(MAGICKCORE_RSVG_DELEGATE)
179   "rsvg "
180 #endif
181 #if defined(MAGICKCORE_TIFF_DELEGATE)
182   "tiff "
183 #endif
184 #if defined(MAGICKCORE_WEBP_DELEGATE)
185   "webp "
186 #endif
187 #if defined(MAGICKCORE_WMF_DELEGATE) || defined (MAGICKCORE_WMFLITE_DELEGATE)
188   "wmf "
189 #endif
190 #if defined(MAGICKCORE_X11_DELEGATE)
191   "x "
192 #endif
193 #if defined(MAGICKCORE_XML_DELEGATE)
194   "xml "
195 #endif
196 #if defined(MAGICKCORE_ZLIB_DELEGATE)
197   "zlib"
198 #endif
199   ;
200 }
201 \f
202 /*
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 %                                                                             %
205 %                                                                             %
206 %                                                                             %
207 %   G e t M a g i c k F e a t u r e s                                         %
208 %                                                                             %
209 %                                                                             %
210 %                                                                             %
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 %
213 %  GetMagickFeatures() returns the ImageMagick features.
214 %
215 %  The format of the GetMagickFeatures method is:
216 %
217 %      const char *GetMagickFeatures(void)
218 %
219 %  No parameters are required.
220 %
221 */
222 MagickExport const char *GetMagickFeatures(void)
223 {
224   return ""
225 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG)
226   "Debug "
227 #endif
228 #if defined(MAGICKCORE_CIPHER_SUPPORT)
229   "Cipher "
230 #endif
231 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_HAVE_SOCKET) && defined(MAGICKCORE_THREAD_SUPPORT)
232   "DPC "
233 #endif
234 #if defined(MAGICKCORE_HDRI_SUPPORT)
235   "HDRI "
236 #endif
237 #if defined(MAGICKCORE_BUILD_MODULES) || defined(_DLL)
238   "Modules "
239 #endif
240 #if defined(MAGICKCORE_OPENCL_SUPPORT)
241   "OpenCL "
242 #endif
243 #if defined(MAGICKCORE_OPENMP_SUPPORT)
244   "OpenMP "
245 #endif
246 #if defined(ZERO_CONFIGURATION_SUPPORT)
247   "Zero-configuration "
248 #endif
249   ;
250 }
251 \f
252 /*
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 %                                                                             %
255 %                                                                             %
256 %                                                                             %
257 %   G e t M a g i c k H o m e U R L                                           %
258 %                                                                             %
259 %                                                                             %
260 %                                                                             %
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262 %
263 %  GetMagickHomeURL() returns the ImageMagick home URL.
264 %
265 %  The format of the GetMagickHomeURL method is:
266 %
267 %      char *GetMagickHomeURL(void)
268 %
269 */
270 MagickExport char *GetMagickHomeURL(void)
271 {
272   char
273     path[MagickPathExtent];
274
275   const char
276     *element;
277
278   ExceptionInfo
279     *exception;
280
281   LinkedListInfo
282     *paths;
283
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)
291   {
292     (void) FormatLocaleString(path,MagickPathExtent,"%s%s%s",element,
293       DirectorySeparator,MagickURLFilename);
294     if (IsPathAccessible(path) != MagickFalse)
295       {
296         paths=DestroyLinkedList(paths,RelinquishMagickMemory);
297         return(ConstantString(path));
298       }
299     element=(const char *) GetNextValueInLinkedList(paths);
300   }
301   paths=DestroyLinkedList(paths,RelinquishMagickMemory);
302   return(ConstantString(MagickHomeURL));
303 }
304 \f
305 /*
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307 %                                                                             %
308 %                                                                             %
309 %                                                                             %
310 %   G e t M a g i c k L i c e n s e                                           %
311 %                                                                             %
312 %                                                                             %
313 %                                                                             %
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315 %
316 %  GetMagickLicense() returns the ImageMagick API license as a string.
317 %
318 %  The format of the GetMagickLicense method is:
319 %
320 %      const char *GetMagickLicense(void)
321 %
322 */
323 MagickExport const char *GetMagickLicense(void)
324 {
325   return(MagickAuthoritativeLicense);
326 }
327 \f
328 /*
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 %                                                                             %
331 %                                                                             %
332 %                                                                             %
333 %   G e t M a g i c k P a c k a g e N a m e                                   %
334 %                                                                             %
335 %                                                                             %
336 %                                                                             %
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
338 %
339 %  GetMagickPackageName() returns the ImageMagick package name.
340 %
341 %  The format of the GetMagickName method is:
342 %
343 %      const char *GetMagickName(void)
344 %
345 %  No parameters are required.
346 %
347 */
348 MagickExport const char *GetMagickPackageName(void)
349 {
350   return(MagickPackageName);
351 }
352 \f
353 /*
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355 %                                                                             %
356 %                                                                             %
357 %                                                                             %
358 %   G e t M a g i c k Q u a n t u m D e p t h                                 %
359 %                                                                             %
360 %                                                                             %
361 %                                                                             %
362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363 %
364 %  GetMagickQuantumDepth() returns the ImageMagick quantum depth.
365 %
366 %  The format of the GetMagickQuantumDepth method is:
367 %
368 %      const char *GetMagickQuantumDepth(size_t *depth)
369 %
370 %  A description of each parameter follows:
371 %
372 %    o depth: the quantum depth is returned as a number.
373 %
374 */
375 MagickExport const char *GetMagickQuantumDepth(size_t *depth)
376 {
377   if (depth != (size_t *) NULL)
378     *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
379   return(MagickQuantumDepth);
380 }
381 \f
382 /*
383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
384 %                                                                             %
385 %                                                                             %
386 %                                                                             %
387 %   G e t M a g i c k Q u a n t u m R a n g e                                 %
388 %                                                                             %
389 %                                                                             %
390 %                                                                             %
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392 %
393 %  GetMagickQuantumRange() returns the ImageMagick quantum range.
394 %
395 %  The format of the GetMagickQuantumRange method is:
396 %
397 %      const char *GetMagickQuantumRange(size_t *range)
398 %
399 %  A description of each parameter follows:
400 %
401 %    o range: the quantum range is returned as a number.
402 %
403 */
404 MagickExport const char *GetMagickQuantumRange(size_t *range)
405 {
406   if (range != (size_t *) NULL)
407     *range=(size_t) QuantumRange;
408   return(MagickQuantumRange);
409 }
410 \f
411 /*
412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
413 %                                                                             %
414 %                                                                             %
415 %                                                                             %
416 %   G e t M a g i c k R e l e a s e D a t e                                   %
417 %                                                                             %
418 %                                                                             %
419 %                                                                             %
420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
421 %
422 %  GetMagickReleaseDate() returns the ImageMagick release date.
423 %
424 %  The format of the GetMagickReleaseDate method is:
425 %
426 %      const char *GetMagickReleaseDate(void)
427 %
428 %  No parameters are required.
429 %
430 */
431 MagickExport const char *GetMagickReleaseDate(void)
432 {
433   return(MagickReleaseDate);
434 }
435 \f
436 /*
437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
438 %                                                                             %
439 %                                                                             %
440 %                                                                             %
441 %   G e t M a g i c k S i g n a t u r e                                       %
442 %                                                                             %
443 %                                                                             %
444 %                                                                             %
445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446 %
447 %  GetMagickSignature() returns a signature that uniquely encodes the
448 %  MagickCore libary version, quantum depth, HDRI status, OS word size, and
449 %  endianness.
450 %
451 %  The format of the GetMagickSignature method is:
452 %
453 %      unsigned int GetMagickSignature(const StringInfo *nonce)
454 %
455 %  A description of each parameter follows:
456 %
457 %    o nonce: arbitrary data.
458 %
459 */
460
461 static unsigned int CRC32(const unsigned char *message,const size_t length)
462 {
463   register ssize_t
464     i;
465
466   static MagickBooleanType
467     crc_initial = MagickFalse;
468
469   static unsigned int
470     crc_xor[256];
471
472   unsigned int
473     crc;
474
475   /*
476     Generate a 32-bit cyclic redundancy check for the message.
477   */
478   if (crc_initial == MagickFalse)
479     {
480       register unsigned int
481         i;
482
483       unsigned int
484         alpha;
485
486       for (i=0; i < 256; i++)
487       {
488         register ssize_t
489           j;
490
491         alpha=i;
492         for (j=0; j < 8; j++)
493           alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1);
494         crc_xor[i]=alpha;
495       }
496       crc_initial=MagickTrue;
497     }
498   crc=0xFFFFFFFF;
499   for (i=0; i < (ssize_t) length; i++)
500     crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8);
501   return(crc ^ 0xFFFFFFFF);
502 }
503
504 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
505 {
506   register unsigned char
507     *p;
508
509   StringInfo
510     *version;
511
512   unsigned int
513     signature;
514
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);
534   return(signature);
535 }
536 \f
537 /*
538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
539 %                                                                             %
540 %                                                                             %
541 %                                                                             %
542 %   G e t M a g i c k V e r s i o n                                           %
543 %                                                                             %
544 %                                                                             %
545 %                                                                             %
546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
547 %
548 %  GetMagickVersion() returns the ImageMagick API version as a string and
549 %  as a number.
550 %
551 %  The format of the GetMagickVersion method is:
552 %
553 %      const char *GetMagickVersion(size_t *version)
554 %
555 %  A description of each parameter follows:
556 %
557 %    o version: the ImageMagick version is returned as a number.
558 %
559 */
560 MagickExport const char *GetMagickVersion(size_t *version)
561 {
562   if (version != (size_t *) NULL)
563     *version=MagickLibVersion;
564   return(MagickVersion);
565 }
566 \f
567 /*
568 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 %                                                                             %
570 %                                                                             %
571 %                                                                             %
572 %   L i s t M a g i c k V e r s i o n                                         %
573 %                                                                             %
574 %                                                                             %
575 %                                                                             %
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
577 %
578 %  ListMagickVersion() identifies the ImageMagick version by printing its
579 %  attributes to the file.  Attributes include the copyright, features, and
580 %  delegates.
581 %
582 %  The format of the ListMagickVersion method is:
583 %
584 %      void ListMagickVersion(FILE *file)
585 %
586 %  A description of each parameter follows:
587 %
588 %    o file: the file, typically stdout.
589 %
590 */
591 MagickExport void ListMagickVersion(FILE *file)
592 {
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);
599 #endif
600   (void) FormatLocaleFile(file,"Features: %s\n",GetMagickFeatures());
601   (void) FormatLocaleFile(file,"Delegates (built-in): %s\n",
602     GetMagickDelegates());
603 }