1 /* 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 % % 4 % % 5 % % 6 % SSSSS TTTTT AAA TTTTT IIIII CCCC % 7 % SS T A A T I C % 8 % SSS T AAAAA T I C % 9 % SS T A A T I C % 10 % SSSSS T A A T IIIII CCCC % 11 % % 12 % % 13 % MagickCore Static Methods % 14 % % 15 % Software Design % 16 % Cristy % 17 % March 2000 % 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 40 /* 42 Include declarations. 43 */ 44 #include "MagickCore/studio.h" 45 #include "MagickCore/exception-private.h" 46 #include "MagickCore/image.h" 47 #include "MagickCore/module.h" 48 #include "MagickCore/policy.h" 49 #include "MagickCore/static.h" 50 #include "MagickCore/string_.h" 51 52 /* 54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 55 % % 56 % % 57 % % 58 % I n v o k e S t a t i c I m a g e F i l t e r % 59 % % 60 % % 61 % % 62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 63 % 64 % InvokeStaticImageFilter() invokes a static image filter. 65 % 66 % The format of the InvokeStaticImageFilter method is: 67 % 68 % MagickBooleanType InvokeStaticImageFilter(const char *tag,Image **image, 69 % const int argc,const char **argv) 70 % 71 % A description of each parameter follows: 72 % 73 % o tag: the module tag. 74 % 75 % o image: the image. 76 % 77 % o argc: the number of elements in the argument vector. 78 % 79 % o argv: A text array containing the command line arguments. 80 % 81 % o argv: A text array containing the command line arguments. 82 % 83 % o exception: return any errors or warnings in this structure. 84 % 85 */ 86 #if defined(MAGICKCORE_MODULES_SUPPORT) 87 MagickExport MagickBooleanType InvokeStaticImageFilter(const char *tag, 88 Image **image,const int argc,const char **argv,ExceptionInfo *exception) 89 { 90 PolicyRights 91 rights; 92 93 assert(image != (Image **) NULL); 94 assert((*image)->signature == MagickCoreSignature); 95 if ((*image)->debug != MagickFalse) 96 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); 97 rights=ReadPolicyRights; 98 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse) 99 { 100 errno=EPERM; 101 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError, 102 "NotAuthorized","`%s'",tag); 103 return(MagickFalse); 104 } 105 #if defined(MAGICKCORE_BUILD_MODULES) 106 (void) tag; 107 (void) argc; 108 (void) argv; 109 (void) exception; 110 #else 111 { 112 extern size_t 113 analyzeImage(Image **,const int,char **,ExceptionInfo *); 114 115 ImageFilterHandler 116 *image_filter; 117 118 image_filter=(ImageFilterHandler *) NULL; 119 if (LocaleCompare("analyze",tag) == 0) 120 image_filter=(ImageFilterHandler *) analyzeImage; 121 if (image_filter == (ImageFilterHandler *) NULL) 122 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError, 123 "UnableToLoadModule","`%s'",tag); 124 else 125 { 126 size_t 127 signature; 128 129 if ((*image)->debug != MagickFalse) 130 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 131 "Invoking \"%s\" static image filter",tag); 132 signature=image_filter(image,argc,argv,exception); 133 if ((*image)->debug != MagickFalse) 134 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes", 135 tag); 136 if (signature != MagickImageFilterSignature) 137 { 138 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError, 139 "ImageFilterSignatureMismatch","'%s': %8lx != %8lx",tag, 140 (unsigned long) signature,(unsigned long) 141 MagickImageFilterSignature); 142 return(MagickFalse); 143 } 144 } 145 } 146 #endif 147 return(MagickTrue); 148 } 149 #endif 150 151 /* 153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 154 % % 155 % % 156 % % 157 % R e g i s t e r S t a t i c M o d u l e s % 158 % % 159 % % 160 % % 161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 162 % 163 % (void) RegisterStaticModules() statically registers all the available module 164 % handlers. 165 % 166 % The format of the RegisterStaticModules method is: 167 % 168 % (void) RegisterStaticModules(void) 169 % 170 */ 171 MagickExport void RegisterStaticModules(void) 172 { 173 #if !defined(MAGICKCORE_BUILD_MODULES) 174 (void) RegisterAAIImage(); 175 (void) RegisterARTImage(); 176 (void) RegisterAVSImage(); 177 (void) RegisterBGRImage(); 178 (void) RegisterBMPImage(); 179 (void) RegisterBRAILLEImage(); 180 (void) RegisterCALSImage(); 181 (void) RegisterCAPTIONImage(); 182 (void) RegisterCINImage(); 183 (void) RegisterCIPImage(); 184 (void) RegisterCLIPImage(); 185 #if defined(MAGICKCORE_WINGDI32_DELEGATE) 186 (void) RegisterCLIPBOARDImage(); 187 #endif 188 (void) RegisterCMYKImage(); 189 (void) RegisterCUTImage(); 190 (void) RegisterDCMImage(); 191 (void) RegisterDDSImage(); 192 (void) RegisterDEBUGImage(); 193 (void) RegisterDIBImage(); 194 #if defined(MAGICKCORE_DJVU_DELEGATE) 195 (void) RegisterDJVUImage(); 196 #endif 197 (void) RegisterDNGImage(); 198 #if defined(MAGICKCORE_DPS_DELEGATE) 199 (void) RegisterDPSImage(); 200 #endif 201 (void) RegisterDPXImage(); 202 #if defined(MAGICKCORE_WINGDI32_DELEGATE) 203 (void) RegisterEMFImage(); 204 #endif 205 #if defined(MAGICKCORE_TIFF_DELEGATE) 206 (void) RegisterEPTImage(); 207 #endif 208 #if defined(MAGICKCORE_OPENEXR_DELEGATE) 209 (void) RegisterEXRImage(); 210 #endif 211 (void) RegisterFAXImage(); 212 (void) RegisterFDImage(); 213 (void) RegisterFITSImage(); 214 #if defined(MAGICKCORE_FLIF_DELEGATE) 215 (void) RegisterFLIFImage(); 216 #endif 217 #if defined(MAGICKCORE_FPX_DELEGATE) 218 (void) RegisterFPXImage(); 219 #endif 220 (void) RegisterGIFImage(); 221 (void) RegisterGRAYImage(); 222 (void) RegisterGRADIENTImage(); 223 (void) RegisterHALDImage(); 224 (void) RegisterHDRImage(); 225 (void) RegisterHISTOGRAMImage(); 226 (void) RegisterHRZImage(); 227 (void) RegisterHTMLImage(); 228 (void) RegisterICONImage(); 229 (void) RegisterINFOImage(); 230 (void) RegisterINLINEImage(); 231 (void) RegisterIPLImage(); 232 #if defined(MAGICKCORE_JBIG_DELEGATE) 233 (void) RegisterJBIGImage(); 234 #endif 235 (void) RegisterJNXImage(); 236 #if defined(MAGICKCORE_JPEG_DELEGATE) 237 (void) RegisterJPEGImage(); 238 #endif 239 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) 240 (void) RegisterJP2Image(); 241 #endif 242 (void) RegisterJSONImage(); 243 (void) RegisterLABELImage(); 244 (void) RegisterMACImage(); 245 (void) RegisterMAGICKImage(); 246 (void) RegisterMAPImage(); 247 (void) RegisterMATImage(); 248 (void) RegisterMATTEImage(); 249 (void) RegisterMASKImage(); 250 (void) RegisterMETAImage(); 251 (void) RegisterMIFFImage(); 252 (void) RegisterMONOImage(); 253 (void) RegisterMPCImage(); 254 (void) RegisterMPEGImage(); 255 (void) RegisterMPRImage(); 256 (void) RegisterMSLImage(); 257 (void) RegisterMTVImage(); 258 (void) RegisterMVGImage(); 259 (void) RegisterNULLImage(); 260 (void) RegisterOTBImage(); 261 (void) RegisterPALMImage(); 262 (void) RegisterPANGOImage(); 263 (void) RegisterPATTERNImage(); 264 (void) RegisterPCDImage(); 265 (void) RegisterPCLImage(); 266 (void) RegisterPCXImage(); 267 (void) RegisterPDBImage(); 268 (void) RegisterPDFImage(); 269 (void) RegisterPESImage(); 270 (void) RegisterPICTImage(); 271 (void) RegisterPIXImage(); 272 (void) RegisterPLASMAImage(); 273 #if defined(MAGICKCORE_PNG_DELEGATE) 274 (void) RegisterPNGImage(); 275 #endif 276 (void) RegisterPNMImage(); 277 (void) RegisterPSImage(); 278 (void) RegisterPS2Image(); 279 (void) RegisterPS3Image(); 280 (void) RegisterPSDImage(); 281 (void) RegisterPWPImage(); 282 (void) RegisterRAWImage(); 283 (void) RegisterRGBImage(); 284 (void) RegisterRGFImage(); 285 (void) RegisterRLAImage(); 286 (void) RegisterRLEImage(); 287 (void) RegisterSCRImage(); 288 (void) RegisterSCREENSHOTImage(); 289 (void) RegisterSCTImage(); 290 (void) RegisterSFWImage(); 291 (void) RegisterSGIImage(); 292 (void) RegisterSIXELImage(); 293 (void) RegisterSTEGANOImage(); 294 (void) RegisterSUNImage(); 295 (void) RegisterSVGImage(); 296 (void) RegisterTGAImage(); 297 (void) RegisterTHUMBNAILImage(); 298 #if defined(MAGICKCORE_TIFF_DELEGATE) 299 (void) RegisterTIFFImage(); 300 #endif 301 (void) RegisterTILEImage(); 302 (void) RegisterTIMImage(); 303 (void) RegisterTTFImage(); 304 (void) RegisterTXTImage(); 305 (void) RegisterUILImage(); 306 (void) RegisterURLImage(); 307 (void) RegisterUYVYImage(); 308 (void) RegisterVICARImage(); 309 (void) RegisterVIDImage(); 310 (void) RegisterVIFFImage(); 311 (void) RegisterVIPSImage(); 312 (void) RegisterWBMPImage(); 313 #if defined(MAGICKCORE_WEBP_DELEGATE) 314 (void) RegisterWEBPImage(); 315 #endif 316 #if defined(MAGICKCORE_WMF_DELEGATE) || defined(MAGICKCORE_WMFLITE_DELEGATE) 317 (void) RegisterWMFImage(); 318 #endif 319 (void) RegisterWPGImage(); 320 #if defined(MAGICKCORE_X11_DELEGATE) 321 (void) RegisterXImage(); 322 #endif 323 (void) RegisterXBMImage(); 324 (void) RegisterXCImage(); 325 (void) RegisterXCFImage(); 326 (void) RegisterXPMImage(); 327 (void) RegisterXPSImage(); 328 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 329 (void) RegisterXTRNImage(); 330 #endif 331 #if defined(MAGICKCORE_X11_DELEGATE) 332 (void) RegisterXWDImage(); 333 #endif 334 (void) RegisterYCBCRImage(); 335 (void) RegisterYUVImage(); 336 #endif 337 } 338 339 /* 341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 342 % % 343 % % 344 % % 345 % U n r e g i s t e r S t a t i c M o d u l e s % 346 % % 347 % % 348 % % 349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 350 % 351 % UnregisterStaticModules() statically unregisters all the available module 352 % handlers. 353 % 354 % The format of the UnregisterStaticModules method is: 355 % 356 % UnregisterStaticModules(void) 357 % 358 */ 359 MagickExport void UnregisterStaticModules(void) 360 { 361 #if !defined(MAGICKCORE_BUILD_MODULES) 362 UnregisterAAIImage(); 363 UnregisterARTImage(); 364 UnregisterAVSImage(); 365 UnregisterBGRImage(); 366 UnregisterBMPImage(); 367 UnregisterBRAILLEImage(); 368 UnregisterCALSImage(); 369 UnregisterCAPTIONImage(); 370 UnregisterCINImage(); 371 UnregisterCIPImage(); 372 UnregisterCLIPImage(); 373 #if defined(MAGICKCORE_WINGDI32_DELEGATE) 374 UnregisterCLIPBOARDImage(); 375 #endif 376 UnregisterCMYKImage(); 377 UnregisterCUTImage(); 378 UnregisterDCMImage(); 379 UnregisterDDSImage(); 380 UnregisterDEBUGImage(); 381 UnregisterDIBImage(); 382 #if defined(MAGICKCORE_DJVU_DELEGATE) 383 UnregisterDJVUImage(); 384 #endif 385 UnregisterDNGImage(); 386 #if defined(MAGICKCORE_DPS_DELEGATE) 387 UnregisterDPSImage(); 388 #endif 389 UnregisterDPXImage(); 390 #if defined(MAGICKCORE_WINGDI32_DELEGATE) 391 UnregisterEMFImage(); 392 #endif 393 #if defined(MAGICKCORE_TIFF_DELEGATE) 394 UnregisterEPTImage(); 395 #endif 396 #if defined(MAGICKCORE_OPENEXR_DELEGATE) 397 UnregisterEXRImage(); 398 #endif 399 UnregisterFAXImage(); 400 UnregisterFDImage(); 401 UnregisterFITSImage(); 402 #if defined(MAGICKCORE_FLIF_DELEGATE) 403 UnregisterFLIFImage(); 404 #endif 405 #if defined(MAGICKCORE_FPX_DELEGATE) 406 UnregisterFPXImage(); 407 #endif 408 UnregisterGIFImage(); 409 UnregisterGRAYImage(); 410 UnregisterGRADIENTImage(); 411 UnregisterHALDImage(); 412 UnregisterHDRImage(); 413 UnregisterHISTOGRAMImage(); 414 UnregisterHRZImage(); 415 UnregisterHTMLImage(); 416 UnregisterICONImage(); 417 UnregisterINFOImage(); 418 UnregisterINLINEImage(); 419 UnregisterIPLImage(); 420 #if defined(MAGICKCORE_JBIG_DELEGATE) 421 UnregisterJBIGImage(); 422 #endif 423 UnregisterJNXImage(); 424 #if defined(MAGICKCORE_JPEG_DELEGATE) 425 UnregisterJPEGImage(); 426 #endif 427 #if defined(MAGICKCORE_LIBOPENJP2_DELEGATE) 428 UnregisterJP2Image(); 429 #endif 430 UnregisterJSONImage(); 431 UnregisterLABELImage(); 432 UnregisterMACImage(); 433 UnregisterMAGICKImage(); 434 UnregisterMAPImage(); 435 UnregisterMASKImage(); 436 UnregisterMATImage(); 437 UnregisterMATTEImage(); 438 UnregisterMETAImage(); 439 UnregisterMIFFImage(); 440 UnregisterMONOImage(); 441 UnregisterMPCImage(); 442 UnregisterMPEGImage(); 443 UnregisterMPRImage(); 444 UnregisterMSLImage(); 445 UnregisterMTVImage(); 446 UnregisterMVGImage(); 447 UnregisterNULLImage(); 448 UnregisterOTBImage(); 449 UnregisterPALMImage(); 450 UnregisterPANGOImage(); 451 UnregisterPATTERNImage(); 452 UnregisterPCDImage(); 453 UnregisterPCLImage(); 454 UnregisterPCXImage(); 455 UnregisterPDBImage(); 456 UnregisterPDFImage(); 457 UnregisterPESImage(); 458 UnregisterPICTImage(); 459 UnregisterPIXImage(); 460 UnregisterPLASMAImage(); 461 #if defined(MAGICKCORE_PNG_DELEGATE) 462 UnregisterPNGImage(); 463 #endif 464 UnregisterPNMImage(); 465 UnregisterPSImage(); 466 UnregisterPS2Image(); 467 UnregisterPS3Image(); 468 UnregisterPSDImage(); 469 UnregisterPWPImage(); 470 UnregisterRAWImage(); 471 UnregisterRGBImage(); 472 UnregisterRGFImage(); 473 UnregisterRLAImage(); 474 UnregisterRLEImage(); 475 UnregisterSCRImage(); 476 UnregisterSCREENSHOTImage(); 477 UnregisterSCTImage(); 478 UnregisterSFWImage(); 479 UnregisterSGIImage(); 480 UnregisterSIXELImage(); 481 UnregisterSTEGANOImage(); 482 UnregisterSUNImage(); 483 UnregisterSVGImage(); 484 UnregisterTGAImage(); 485 UnregisterTHUMBNAILImage(); 486 #if defined(MAGICKCORE_TIFF_DELEGATE) 487 UnregisterTIFFImage(); 488 #endif 489 UnregisterTILEImage(); 490 UnregisterTIMImage(); 491 UnregisterTTFImage(); 492 UnregisterTXTImage(); 493 UnregisterUILImage(); 494 UnregisterURLImage(); 495 UnregisterUYVYImage(); 496 UnregisterVICARImage(); 497 UnregisterVIDImage(); 498 UnregisterVIFFImage(); 499 UnregisterVIPSImage(); 500 UnregisterWBMPImage(); 501 #if defined(MAGICKCORE_WEBP_DELEGATE) 502 UnregisterWEBPImage(); 503 #endif 504 #if defined(MAGICKCORE_WMF_DELEGATE) || defined(MAGICKCORE_WMFLITE_DELEGATE) 505 UnregisterWMFImage(); 506 #endif 507 UnregisterWPGImage(); 508 #if defined(MAGICKCORE_X11_DELEGATE) 509 UnregisterXImage(); 510 #endif 511 UnregisterXBMImage(); 512 UnregisterXCImage(); 513 UnregisterXCFImage(); 514 UnregisterXPMImage(); 515 UnregisterXPSImage(); 516 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 517 UnregisterXTRNImage(); 518 #endif 519 #if defined(MAGICKCORE_X11_DELEGATE) 520 UnregisterXWDImage(); 521 #endif 522 UnregisterYCBCRImage(); 523 UnregisterYUVImage(); 524 #endif 525 } 526