]> granicus.if.org Git - imagemagick/blob - MagickCore/version.c
(no commit message)
[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-2014 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 #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_FONTCONFIG_DELEGATE)
125   "fontconfig "
126 #endif
127 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
128   "freetype "
129 #endif
130 #if defined(MAGICKCORE_FPX_DELEGATE)
131   "fpx "
132 #endif
133 #if defined(MAGICKCORE_GS_DELEGATE)
134   "gslib "
135 #endif
136 #if defined(MAGICKCORE_GVC_DELEGATE)
137   "gvc "
138 #endif
139 #if defined(MAGICKCORE_JBIG_DELEGATE)
140   "jbig "
141 #endif
142 #if defined(MAGICKCORE_JPEG_DELEGATE) && defined(MAGICKCORE_PNG_DELEGATE)
143   "jng "
144 #endif
145 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE)
146   "jp2 "
147 #endif
148 #if defined(MAGICKCORE_JPEG_DELEGATE)
149   "jpeg "
150 #endif
151 #if defined(MAGICKCORE_LCMS_DELEGATE)
152   "lcms "
153 #endif
154 #if defined(MAGICKCORE_LQR_DELEGATE)
155   "lqr "
156 #endif
157 #if defined(MAGICKCORE_LTDL_DELEGATE)
158   "ltdl "
159 #endif
160 #if defined(MAGICKCORE_LZMA_DELEGATE)
161   "lzma "
162 #endif
163 #if defined(MAGICKCORE_OPENEXR_DELEGATE)
164   "openexr "
165 #endif
166 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
167   "pangocairo "
168 #endif
169 #if defined(MAGICKCORE_PNG_DELEGATE)
170   "png "
171 #endif
172 #if defined(MAGICKCORE_DPS_DELEGATE) || defined(MAGICKCORE_GS_DELEGATE) || defined(WIN32)
173   "ps "
174 #endif
175 #if defined(MAGICKCORE_RSVG_DELEGATE)
176   "rsvg "
177 #endif
178 #if defined(MAGICKCORE_TIFF_DELEGATE)
179   "tiff "
180 #endif
181 #if defined(MAGICKCORE_WEBP_DELEGATE)
182   "webp "
183 #endif
184 #if defined(MAGICKCORE_WMF_DELEGATE) || defined (MAGICKCORE_WMFLITE_DELEGATE)
185   "wmf "
186 #endif
187 #if defined(MAGICKCORE_X11_DELEGATE)
188   "x "
189 #endif
190 #if defined(MAGICKCORE_XML_DELEGATE)
191   "xml "
192 #endif
193 #if defined(MAGICKCORE_ZLIB_DELEGATE)
194   "zlib"
195 #endif
196   ;
197 }
198 \f
199 /*
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 %                                                                             %
202 %                                                                             %
203 %                                                                             %
204 %   G e t M a g i c k F e a t u r e s                                         %
205 %                                                                             %
206 %                                                                             %
207 %                                                                             %
208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 %
210 %  GetMagickFeatures() returns the ImageMagick features.
211 %
212 %  The format of the GetMagickFeatures method is:
213 %
214 %      const char *GetMagickFeatures(void)
215 %
216 %  No parameters are required.
217 %
218 */
219 MagickExport const char *GetMagickFeatures(void)
220 {
221   return "DPC"
222 #if defined(MAGICKCORE_BUILD_MODULES) || defined(_DLL)
223   " Modules"
224 #endif
225 #if defined(MAGICKCORE_HDRI_SUPPORT)
226   " HDRI"
227 #endif
228 #if defined(MAGICKCORE_OPENCL_SUPPORT)
229   " OpenCL"
230 #endif
231 #if defined(MAGICKCORE_OPENMP_SUPPORT)
232   " OpenMP"
233 #endif
234   ;
235 }
236 \f
237 /*
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 %                                                                             %
240 %                                                                             %
241 %                                                                             %
242 %   G e t M a g i c k H o m e U R L                                           %
243 %                                                                             %
244 %                                                                             %
245 %                                                                             %
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247 %
248 %  GetMagickHomeURL() returns the ImageMagick home URL.
249 %
250 %  The format of the GetMagickHomeURL method is:
251 %
252 %      char *GetMagickHomeURL(void)
253 %
254 */
255 MagickExport char *GetMagickHomeURL(void)
256 {
257   char
258     path[MaxTextExtent];
259
260   const char
261     *element;
262
263   ExceptionInfo
264     *exception;
265
266   LinkedListInfo
267     *paths;
268
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)
276   {
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);
282   }
283   return(ConstantString(MagickHomeURL));
284 }
285 \f
286 /*
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 %                                                                             %
289 %                                                                             %
290 %                                                                             %
291 %   G e t M a g i c k P a c k a g e N a m e                                   %
292 %                                                                             %
293 %                                                                             %
294 %                                                                             %
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296 %
297 %  GetMagickPackageName() returns the ImageMagick package name.
298 %
299 %  The format of the GetMagickName method is:
300 %
301 %      const char *GetMagickName(void)
302 %
303 %  No parameters are required.
304 %
305 */
306 MagickExport const char *GetMagickPackageName(void)
307 {
308   return(MagickPackageName);
309 }
310 \f
311 /*
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313 %                                                                             %
314 %                                                                             %
315 %                                                                             %
316 %   G e t M a g i c k Q u a n t u m D e p t h                                 %
317 %                                                                             %
318 %                                                                             %
319 %                                                                             %
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321 %
322 %  GetMagickQuantumDepth() returns the ImageMagick quantum depth.
323 %
324 %  The format of the GetMagickQuantumDepth method is:
325 %
326 %      const char *GetMagickQuantumDepth(size_t *depth)
327 %
328 %  A description of each parameter follows:
329 %
330 %    o depth: the quantum depth is returned as a number.
331 %
332 */
333 MagickExport const char *GetMagickQuantumDepth(size_t *depth)
334 {
335   if (depth != (size_t *) NULL)
336     *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
337   return(MagickQuantumDepth);
338 }
339 \f
340 /*
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 %                                                                             %
343 %                                                                             %
344 %                                                                             %
345 %   G e t M a g i c k Q u a n t u m R a n g e                                 %
346 %                                                                             %
347 %                                                                             %
348 %                                                                             %
349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350 %
351 %  GetMagickQuantumRange() returns the ImageMagick quantum range.
352 %
353 %  The format of the GetMagickQuantumRange method is:
354 %
355 %      const char *GetMagickQuantumRange(size_t *range)
356 %
357 %  A description of each parameter follows:
358 %
359 %    o range: the quantum range is returned as a number.
360 %
361 */
362 MagickExport const char *GetMagickQuantumRange(size_t *range)
363 {
364   if (range != (size_t *) NULL)
365     *range=(size_t) QuantumRange;
366   return(MagickQuantumRange);
367 }
368 \f
369 /*
370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
371 %                                                                             %
372 %                                                                             %
373 %                                                                             %
374 %   G e t M a g i c k R e l e a s e D a t e                                   %
375 %                                                                             %
376 %                                                                             %
377 %                                                                             %
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 %
380 %  GetMagickReleaseDate() returns the ImageMagick release date.
381 %
382 %  The format of the GetMagickReleaseDate method is:
383 %
384 %      const char *GetMagickReleaseDate(void)
385 %
386 %  No parameters are required.
387 %
388 */
389 MagickExport const char *GetMagickReleaseDate(void)
390 {
391   return(MagickReleaseDate);
392 }
393 \f
394 /*
395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396 %                                                                             %
397 %                                                                             %
398 %                                                                             %
399 %   G e t M a g i c k S i g n a t u r e                                       %
400 %                                                                             %
401 %                                                                             %
402 %                                                                             %
403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404 %
405 %  GetMagickSignature() returns a signature that uniquely encodes the
406 %  MagickCore libary version, quantum depth, HDRI status, OS word size, and
407 %  endianness.
408 %
409 %  The format of the GetMagickSignature method is:
410 %
411 %      unsigned int GetMagickSignature(const StringInfo *nonce)
412 %
413 %  A description of each parameter follows:
414 %
415 %    o nonce: arbitrary data.
416 %
417 */
418
419 static unsigned int CRC32(const unsigned char *message,const size_t length)
420 {
421   register ssize_t
422     i;
423
424   static MagickBooleanType
425     crc_initial = MagickFalse;
426
427   static unsigned int
428     crc_xor[256];
429
430   unsigned int
431     crc;
432
433   /*
434     Generate a 32-bit cyclic redundancy check for the message.
435   */
436   if (crc_initial == MagickFalse)
437     {
438       register unsigned int
439         i;
440
441       unsigned int
442         alpha;
443
444       for (i=0; i < 256; i++)
445       {
446         register ssize_t
447           j;
448
449         alpha=i;
450         for (j=0; j < 8; j++)
451           alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1);
452         crc_xor[i]=alpha;
453       }
454       crc_initial=MagickTrue;
455     }
456   crc=0xFFFFFFFF;
457   for (i=0; i < (ssize_t) length; i++)
458     crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8);
459   return(crc ^ 0xFFFFFFFF);
460 }
461
462 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
463 {
464   register unsigned char
465     *p;
466
467   StringInfo
468     *version;
469
470   unsigned int
471     signature;
472
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);
492   return(signature);
493 }
494 \f
495 /*
496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
497 %                                                                             %
498 %                                                                             %
499 %                                                                             %
500 %   G e t M a g i c k V e r s i o n                                           %
501 %                                                                             %
502 %                                                                             %
503 %                                                                             %
504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 %
506 %  GetMagickVersion() returns the ImageMagick API version as a string and
507 %  as a number.
508 %
509 %  The format of the GetMagickVersion method is:
510 %
511 %      const char *GetMagickVersion(size_t *version)
512 %
513 %  A description of each parameter follows:
514 %
515 %    o version: the ImageMagick version is returned as a number.
516 %
517 */
518 MagickExport const char *GetMagickVersion(size_t *version)
519 {
520   if (version != (size_t *) NULL)
521     *version=MagickLibVersion;
522   return(MagickVersion);
523 }
524 \f
525 /*
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 %                                                                             %
528 %                                                                             %
529 %                                                                             %
530 %   L i s t M a g i c k V e r s i o n                                         %
531 %                                                                             %
532 %                                                                             %
533 %                                                                             %
534 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
535 %
536 %  ListMagickVersion() identifies the ImageMagick version by printing its
537 %  attributes to the file.  Attributes include the copyright, features, and
538 %  delegates.
539 %
540 %  The format of the ListMagickVersion method is:
541 %
542 %      void ListMagickVersion(FILE *file)
543 %
544 %  A description of each parameter follows:
545 %
546 %    o file: the file, typically stdout.
547 %
548 */
549 MagickExport void ListMagickVersion(FILE *file)
550 {
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());
556 }