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