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