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-2019 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://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) || defined(MAGICKCORE_WINDOWS_SUPPORT) 141 "gslib " 142 #endif 143 #if defined(MAGICKCORE_GVC_DELEGATE) 144 "gvc " 145 #endif 146 #if defined(MAGICKCORE_HEIC_DELEGATE) 147 "heic " 148 #endif 149 #if defined(MAGICKCORE_JBIG_DELEGATE) 150 "jbig " 151 #endif 152 #if defined(MAGICKCORE_JPEG_DELEGATE) && defined(MAGICKCORE_PNG_DELEGATE) 153 "jng " 154 #endif 155 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) 156 "jp2 " 157 #endif 158 #if defined(MAGICKCORE_JPEG_DELEGATE) 159 "jpeg " 160 #endif 161 #if defined(MAGICKCORE_LCMS_DELEGATE) 162 "lcms " 163 #endif 164 #if defined(MAGICKCORE_LQR_DELEGATE) 165 "lqr " 166 #endif 167 #if defined(MAGICKCORE_LTDL_DELEGATE) 168 "ltdl " 169 #endif 170 #if defined(MAGICKCORE_LZMA_DELEGATE) 171 "lzma " 172 #endif 173 #if defined(MAGICKCORE_OPENEXR_DELEGATE) 174 "openexr " 175 #endif 176 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE) 177 "pangocairo " 178 #endif 179 #if defined(MAGICKCORE_PNG_DELEGATE) 180 "png " 181 #endif 182 #if defined(MAGICKCORE_DPS_DELEGATE) || defined(MAGICKCORE_GS_DELEGATE) || \ 183 defined(MAGICKCORE_WINDOWS_SUPPORT) 184 "ps " 185 #endif 186 #if defined(MAGICKCORE_RAW_R_DELEGATE) 187 "raw " 188 #endif 189 #if defined(MAGICKCORE_RSVG_DELEGATE) 190 "rsvg " 191 #endif 192 #if defined(MAGICKCORE_TIFF_DELEGATE) 193 "tiff " 194 #endif 195 #if defined(MAGICKCORE_WEBP_DELEGATE) 196 "webp " 197 #endif 198 #if defined(MAGICKCORE_WMF_DELEGATE) || defined (MAGICKCORE_WMFLITE_DELEGATE) 199 "wmf " 200 #endif 201 #if defined(MAGICKCORE_X11_DELEGATE) 202 "x " 203 #endif 204 #if defined(MAGICKCORE_XML_DELEGATE) 205 "xml " 206 #endif 207 #if defined(MAGICKCORE_ZLIB_DELEGATE) 208 "zlib" 209 #endif 210 ; 211 } 212 213 /* 215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 216 % % 217 % % 218 % % 219 % G e t M a g i c k F e a t u r e s % 220 % % 221 % % 222 % % 223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 224 % 225 % GetMagickFeatures() returns the ImageMagick features. 226 % 227 % The format of the GetMagickFeatures method is: 228 % 229 % const char *GetMagickFeatures(void) 230 % 231 % No parameters are required. 232 % 233 */ 234 MagickExport const char *GetMagickFeatures(void) 235 { 236 return "" 237 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG) 238 "Debug " 239 #endif 240 #if defined(MAGICKCORE_CIPHER_SUPPORT) 241 "Cipher " 242 #endif 243 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_HAVE_SOCKET) && defined(MAGICKCORE_THREAD_SUPPORT) 244 "DPC " 245 #endif 246 #if defined(MAGICKCORE_HDRI_SUPPORT) 247 "HDRI " 248 #endif 249 #if defined(MAGICKCORE_BUILD_MODULES) || defined(_DLL) 250 "Modules " 251 #endif 252 #if defined(MAGICKCORE_OPENCL_SUPPORT) 253 "OpenCL " 254 #endif 255 #if defined(MAGICKCORE_OPENMP_SUPPORT) 256 "OpenMP " 257 #endif 258 #if defined(ZERO_CONFIGURATION_SUPPORT) 259 "Zero-configuration " 260 #endif 261 ; 262 } 263 264 /* 266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 267 % % 268 % % 269 % % 270 % G e t M a g i c k H o m e U R L % 271 % % 272 % % 273 % % 274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 275 % 276 % GetMagickHomeURL() returns the ImageMagick home URL. 277 % 278 % The format of the GetMagickHomeURL method is: 279 % 280 % char *GetMagickHomeURL(void) 281 % 282 */ 283 MagickExport char *GetMagickHomeURL(void) 284 { 285 char 286 path[MagickPathExtent]; 287 288 const char 289 *element; 290 291 ExceptionInfo 292 *exception; 293 294 LinkedListInfo 295 *paths; 296 297 exception=AcquireExceptionInfo(); 298 paths=GetConfigurePaths(MagickURLFilename,exception); 299 exception=DestroyExceptionInfo(exception); 300 if (paths == (LinkedListInfo *) NULL) 301 return(ConstantString(MagickHomeURL)); 302 element=(const char *) GetNextValueInLinkedList(paths); 303 while (element != (const char *) NULL) 304 { 305 (void) FormatLocaleString(path,MagickPathExtent,"%s%s%s",element, 306 DirectorySeparator,MagickURLFilename); 307 if (IsPathAccessible(path) != MagickFalse) 308 { 309 paths=DestroyLinkedList(paths,RelinquishMagickMemory); 310 return(ConstantString(path)); 311 } 312 element=(const char *) GetNextValueInLinkedList(paths); 313 } 314 paths=DestroyLinkedList(paths,RelinquishMagickMemory); 315 return(ConstantString(MagickHomeURL)); 316 } 317 318 /* 320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 321 % % 322 % % 323 % % 324 % G e t M a g i c k L i c e n s e % 325 % % 326 % % 327 % % 328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 329 % 330 % GetMagickLicense() returns the ImageMagick API license as a string. 331 % 332 % The format of the GetMagickLicense method is: 333 % 334 % const char *GetMagickLicense(void) 335 % 336 */ 337 MagickExport const char *GetMagickLicense(void) 338 { 339 return(MagickAuthoritativeLicense); 340 } 341 342 /* 344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 345 % % 346 % % 347 % % 348 % G e t M a g i c k P a c k a g e N a m e % 349 % % 350 % % 351 % % 352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 353 % 354 % GetMagickPackageName() returns the ImageMagick package name. 355 % 356 % The format of the GetMagickName method is: 357 % 358 % const char *GetMagickName(void) 359 % 360 % No parameters are required. 361 % 362 */ 363 MagickExport const char *GetMagickPackageName(void) 364 { 365 return(MagickPackageName); 366 } 367 368 /* 370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 371 % % 372 % % 373 % % 374 % G e t M a g i c k Q u a n t u m D e p t h % 375 % % 376 % % 377 % % 378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 379 % 380 % GetMagickQuantumDepth() returns the ImageMagick quantum depth. 381 % 382 % The format of the GetMagickQuantumDepth method is: 383 % 384 % const char *GetMagickQuantumDepth(size_t *depth) 385 % 386 % A description of each parameter follows: 387 % 388 % o depth: the quantum depth is returned as a number. 389 % 390 */ 391 MagickExport const char *GetMagickQuantumDepth(size_t *depth) 392 { 393 if (depth != (size_t *) NULL) 394 *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH; 395 return(MagickQuantumDepth); 396 } 397 398 /* 400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 401 % % 402 % % 403 % % 404 % G e t M a g i c k Q u a n t u m R a n g e % 405 % % 406 % % 407 % % 408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 409 % 410 % GetMagickQuantumRange() returns the ImageMagick quantum range. 411 % 412 % The format of the GetMagickQuantumRange method is: 413 % 414 % const char *GetMagickQuantumRange(size_t *range) 415 % 416 % A description of each parameter follows: 417 % 418 % o range: the quantum range is returned as a number. 419 % 420 */ 421 MagickExport const char *GetMagickQuantumRange(size_t *range) 422 { 423 if (range != (size_t *) NULL) 424 *range=(size_t) QuantumRange; 425 return(MagickQuantumRange); 426 } 427 428 /* 430 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 431 % % 432 % % 433 % % 434 % G e t M a g i c k R e l e a s e D a t e % 435 % % 436 % % 437 % % 438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 439 % 440 % GetMagickReleaseDate() returns the ImageMagick release date. 441 % 442 % The format of the GetMagickReleaseDate method is: 443 % 444 % const char *GetMagickReleaseDate(void) 445 % 446 % No parameters are required. 447 % 448 */ 449 MagickExport const char *GetMagickReleaseDate(void) 450 { 451 return(MagickReleaseDate); 452 } 453 454 /* 456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 457 % % 458 % % 459 % % 460 % G e t M a g i c k S i g n a t u r e % 461 % % 462 % % 463 % % 464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 465 % 466 % GetMagickSignature() returns a signature that uniquely encodes the 467 % MagickCore libary version, quantum depth, HDRI status, OS word size, and 468 % endianness. 469 % 470 % The format of the GetMagickSignature method is: 471 % 472 % unsigned int GetMagickSignature(const StringInfo *nonce) 473 % 474 % A description of each parameter follows: 475 % 476 % o nonce: arbitrary data. 477 % 478 */ 479 480 static unsigned int CRC32(const unsigned char *message,const size_t length) 481 { 482 register ssize_t 483 i; 484 485 static MagickBooleanType 486 crc_initial = MagickFalse; 487 488 static unsigned int 489 crc_xor[256]; 490 491 unsigned int 492 crc; 493 494 /* 495 Generate a 32-bit cyclic redundancy check for the message. 496 */ 497 if (crc_initial == MagickFalse) 498 { 499 register unsigned int 500 j; 501 502 unsigned int 503 alpha; 504 505 for (j=0; j < 256; j++) 506 { 507 register ssize_t 508 k; 509 510 alpha=j; 511 for (k=0; k < 8; k++) 512 alpha=(alpha & 0x01) ? (0xEDB88320 ^ (alpha >> 1)) : (alpha >> 1); 513 crc_xor[j]=alpha; 514 } 515 crc_initial=MagickTrue; 516 } 517 crc=0xFFFFFFFF; 518 for (i=0; i < (ssize_t) length; i++) 519 crc=crc_xor[(crc ^ message[i]) & 0xff] ^ (crc >> 8); 520 return(crc ^ 0xFFFFFFFF); 521 } 522 523 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce) 524 { 525 register unsigned char 526 *p; 527 528 StringInfo 529 *version; 530 531 unsigned int 532 signature; 533 534 version=AcquireStringInfo(MagickPathExtent); 535 p=GetStringInfoDatum(version); 536 signature=MAGICKCORE_QUANTUM_DEPTH; 537 (void) memcpy(p,&signature,sizeof(signature)); 538 p+=sizeof(signature); 539 signature=MAGICKCORE_HDRI_ENABLE; 540 (void) memcpy(p,&signature,sizeof(signature)); 541 p+=sizeof(signature); 542 signature=MagickLibInterface; 543 (void) memcpy(p,&signature,sizeof(signature)); 544 p+=sizeof(signature); 545 signature=1; /* endianess */ 546 (void) memcpy(p,&signature,sizeof(signature)); 547 p+=sizeof(signature); 548 SetStringInfoLength(version,p-GetStringInfoDatum(version)); 549 if (nonce != (const StringInfo *) NULL) 550 ConcatenateStringInfo(version,nonce); 551 signature=CRC32(GetStringInfoDatum(version),GetStringInfoLength(version)); 552 version=DestroyStringInfo(version); 553 return(signature); 554 } 555 556 /* 558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 559 % % 560 % % 561 % % 562 % G e t M a g i c k V e r s i o n % 563 % % 564 % % 565 % % 566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 567 % 568 % GetMagickVersion() returns the ImageMagick API version as a string and 569 % as a number. 570 % 571 % The format of the GetMagickVersion method is: 572 % 573 % const char *GetMagickVersion(size_t *version) 574 % 575 % A description of each parameter follows: 576 % 577 % o version: the ImageMagick version is returned as a number. 578 % 579 */ 580 MagickExport const char *GetMagickVersion(size_t *version) 581 { 582 if (version != (size_t *) NULL) 583 *version=MagickLibVersion; 584 return(MagickVersion); 585 } 586 587 /* 589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 590 % % 591 % % 592 % % 593 % L i s t M a g i c k V e r s i o n % 594 % % 595 % % 596 % % 597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 598 % 599 % ListMagickVersion() identifies the ImageMagick version by printing its 600 % attributes to the file. Attributes include the copyright, features, and 601 % delegates. 602 % 603 % The format of the ListMagickVersion method is: 604 % 605 % void ListMagickVersion(FILE *file) 606 % 607 % A description of each parameter follows: 608 % 609 % o file: the file, typically stdout. 610 % 611 */ 612 MagickExport void ListMagickVersion(FILE *file) 613 { 614 (void) FormatLocaleFile(file,"Version: %s\n", 615 GetMagickVersion((size_t *) NULL));; 616 (void) FormatLocaleFile(file,"Copyright: %s\n",GetMagickCopyright()); 617 (void) FormatLocaleFile(file,"License: %s\n",GetMagickLicense()); 618 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_MSC_FULL_VER) 619 (void) FormatLocaleFile(file,"Visual C++: %d\n",_MSC_FULL_VER); 620 #endif 621 (void) FormatLocaleFile(file,"Features: %s\n",GetMagickFeatures()); 622 (void) FormatLocaleFile(file,"Delegates (built-in): %s\n", 623 GetMagickDelegates()); 624 if (IsEventLogging() != MagickFalse) 625 { 626 (void) FormatLocaleFile(file,"Wizard attributes: "); 627 (void) FormatLocaleFile(file,"QuantumRange=%g; ",(double) QuantumRange); 628 (void) FormatLocaleFile(file,"QuantumScale=%.*g; ",GetMagickPrecision(), 629 (double) QuantumScale); 630 (void) FormatLocaleFile(file,"MagickEpsilon=%.*g; ",GetMagickPrecision(), 631 (double) MagickEpsilon); 632 (void) FormatLocaleFile(file,"MaxMap=%g; ",(double) MaxMap); 633 (void) FormatLocaleFile(file,"MagickPathExtent=%g; ", 634 (double) MagickPathExtent); 635 (void) FormatLocaleFile(file,"sizeof(Quantum)=%g; ",(double) 636 sizeof(Quantum)); 637 (void) FormatLocaleFile(file,"sizeof(MagickSizeType)=%g; ",(double) 638 sizeof(MagickSizeType)); 639 (void) FormatLocaleFile(file,"sizeof(MagickOffsetType)=%g",(double) 640 sizeof(MagickOffsetType)); 641 } 642 } 643