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