blob: f5e57fe8eb4b62baa40e77d68c16f6256b7e1ff3 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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% John Cristy %
17% March 2000 %
18% %
19% %
cristy16af1cb2009-12-11 21:38:29 +000020% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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 "magick/studio.h"
44#include "magick/exception-private.h"
45#include "magick/image.h"
46#include "magick/module.h"
47#include "magick/policy.h"
48#include "magick/static.h"
49#include "magick/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)
85MagickExport 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 == MagickSignature);
93 if ((*image)->debug != MagickFalse)
94 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
95 rights=ReadPolicyRights;
96 if (IsRightsAuthorized(FilterPolicyDomain,rights,tag) == MagickFalse)
97 {
cristya9197f62010-01-12 02:23:34 +000098 errno=EPERM;
cristy3ed852e2009-09-05 21:47:34 +000099 (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 unsigned long
cristya0b81c32010-01-22 02:54:33 +0000111 analyzeImage(Image **,const int,char **,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +0000112
113 ImageFilterHandler
114 *image_filter;
115
116 image_filter=(ImageFilterHandler *) NULL;
117 if (LocaleCompare("analyze",tag) == 0)
cristyc4c8d132010-01-07 01:58:38 +0000118 image_filter=(ImageFilterHandler *) analyzeImage;
cristy3ed852e2009-09-05 21:47:34 +0000119 if (image_filter != (ImageFilterHandler *) NULL)
120 {
121 unsigned long
122 signature;
123
124 if ((*image)->debug != MagickFalse)
125 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
126 "Invoking \"%s\" static image filter",tag);
127 signature=image_filter(image,argc,argv,exception);
128 if ((*image)->debug != MagickFalse)
129 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"\"%s\" completes",
130 tag);
131 if (signature != MagickImageFilterSignature)
132 {
133 (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
134 "ImageFilterSignatureMismatch","`%s': %8lx != %8lx",tag,signature,
135 MagickImageFilterSignature);
136 return(MagickFalse);
137 }
138 }
139 }
140#endif
141 return(MagickTrue);
142}
143#endif
144
145/*
146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147% %
148% %
149% %
150% R e g i s t e r S t a t i c M o d u l e s %
151% %
152% %
153% %
154%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155%
156% (void) RegisterStaticModules() statically registers all the available module
157% handlers.
158%
159% The format of the RegisterStaticModules method is:
160%
161% (void) RegisterStaticModules(void)
162%
163*/
164MagickExport void RegisterStaticModules(void)
165{
166#if !defined(MAGICKCORE_BUILD_MODULES)
167 (void) RegisterARTImage();
cristy3ed852e2009-09-05 21:47:34 +0000168 (void) RegisterAVSImage();
169 (void) RegisterBMPImage();
170 (void) RegisterCAPTIONImage();
171 (void) RegisterCINImage();
172 (void) RegisterCIPImage();
173 (void) RegisterCLIPImage();
174#if defined(MAGICKCORE_WINGDI32_DELEGATE)
175 (void) RegisterCLIPBOARDImage();
176#endif
177 (void) RegisterCMYKImage();
178 (void) RegisterCUTImage();
179 (void) RegisterDCMImage();
180 (void) RegisterDDSImage();
181 (void) RegisterDIBImage();
182#if defined(MAGICKCORE_DJVU_DELEGATE)
183 (void) RegisterDJVUImage();
184#endif
185 (void) RegisterDNGImage();
cristyb32b90a2009-09-07 21:45:48 +0000186#if defined(MAGICKCORE_DPS_DELEGATE)
cristy3ed852e2009-09-05 21:47:34 +0000187 (void) RegisterDPSImage();
cristyb32b90a2009-09-07 21:45:48 +0000188#endif
cristy3ed852e2009-09-05 21:47:34 +0000189 (void) RegisterDPXImage();
190#if defined(MAGICKCORE_WINGDI32_DELEGATE)
191 (void) RegisterEMFImage();
192#endif
193#if defined(MAGICKCORE_TIFF_DELEGATE)
194 (void) RegisterEPTImage();
195#endif
196#if defined(MAGICKCORE_OPENEXR_DELEGATE)
197 (void) RegisterEXRImage();
198#endif
199 (void) RegisterFAXImage();
200 (void) RegisterFITSImage();
201#if defined(MAGICKCORE_FPX_DELEGATE)
202 (void) RegisterFPXImage();
203#endif
204 (void) RegisterGIFImage();
205 (void) RegisterGRAYImage();
206 (void) RegisterGRADIENTImage();
207 (void) RegisterHISTOGRAMImage();
208 (void) RegisterHRZImage();
209 (void) RegisterHTMLImage();
210 (void) RegisterICONImage();
211 (void) RegisterINFOImage();
212 (void) RegisterINLINEImage();
213 (void) RegisterIPLImage();
214#if defined(MAGICKCORE_JBIG_DELEGATE)
215 (void) RegisterJBIGImage();
216#endif
217#if defined(MAGICKCORE_JPEG_DELEGATE)
218 (void) RegisterJPEGImage();
219#endif
220#if defined(MAGICKCORE_JP2_DELEGATE)
221 (void) RegisterJP2Image();
222#endif
223 (void) RegisterLABELImage();
224 (void) RegisterMAGICKImage();
225 (void) RegisterMAPImage();
226 (void) RegisterMATImage();
227 (void) RegisterMATTEImage();
228 (void) RegisterMETAImage();
229 (void) RegisterMIFFImage();
230 (void) RegisterMONOImage();
231 (void) RegisterMPCImage();
232 (void) RegisterMPEGImage();
233 (void) RegisterMPRImage();
234 (void) RegisterMSLImage();
235 (void) RegisterMTVImage();
236 (void) RegisterMVGImage();
237 (void) RegisterNULLImage();
238 (void) RegisterOTBImage();
239 (void) RegisterPALMImage();
240 (void) RegisterPATTERNImage();
241 (void) RegisterPCDImage();
242 (void) RegisterPCLImage();
243 (void) RegisterPCXImage();
244 (void) RegisterPDBImage();
245 (void) RegisterPDFImage();
cristyc2e5d6d2010-01-24 17:45:00 +0000246 (void) RegisterPESImage();
cristy3ed852e2009-09-05 21:47:34 +0000247 (void) RegisterPICTImage();
248 (void) RegisterPIXImage();
249 (void) RegisterPLASMAImage();
250#if defined(MAGICKCORE_PNG_DELEGATE)
251 (void) RegisterPNGImage();
252#endif
253 (void) RegisterPNMImage();
254 (void) RegisterPREVIEWImage();
255 (void) RegisterPSImage();
256 (void) RegisterPS2Image();
257 (void) RegisterPS3Image();
258 (void) RegisterPSDImage();
259 (void) RegisterPWPImage();
260 (void) RegisterRAWImage();
261 (void) RegisterRGBImage();
262 (void) RegisterRLAImage();
263 (void) RegisterRLEImage();
264 (void) RegisterSCRImage();
265 (void) RegisterSCTImage();
266 (void) RegisterSFWImage();
267 (void) RegisterSGIImage();
268 (void) RegisterSTEGANOImage();
269 (void) RegisterSUNImage();
270 (void) RegisterSVGImage();
271 (void) RegisterTGAImage();
272 (void) RegisterTHUMBNAILImage();
273#if defined(MAGICKCORE_TIFF_DELEGATE)
274 (void) RegisterTIFFImage();
275#endif
276 (void) RegisterTILEImage();
277 (void) RegisterTIMImage();
278 (void) RegisterTTFImage();
279 (void) RegisterTXTImage();
280 (void) RegisterUILImage();
281 (void) RegisterURLImage();
282 (void) RegisterUYVYImage();
283 (void) RegisterVICARImage();
284 (void) RegisterVIDImage();
285 (void) RegisterVIFFImage();
286 (void) RegisterWBMPImage();
287#if defined(MAGICKCORE_WMF_DELEGATE) || defined(MAGICKCORE_WMFLITE_DELEGATE)
288 (void) RegisterWMFImage();
289#endif
290 (void) RegisterWPGImage();
291#if defined(MAGICKCORE_X11_DELEGATE)
292 (void) RegisterXImage();
293#endif
294 (void) RegisterXBMImage();
295 (void) RegisterXCImage();
296 (void) RegisterXCFImage();
297 (void) RegisterXPMImage();
298 (void) RegisterXPSImage();
299#if defined(_VISUALC_)
300 (void) RegisterXTRNImage();
301#endif
302#if defined(MAGICKCORE_X11_DELEGATE)
303 (void) RegisterXWDImage();
304#endif
305 (void) RegisterYCBCRImage();
306 (void) RegisterYUVImage();
307#endif
308}
309
310/*
311%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312% %
313% %
314% %
315% U n r e g i s t e r S t a t i c M o d u l e s %
316% %
317% %
318% %
319%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320%
321% UnregisterStaticModules() statically unregisters all the available module
322% handlers.
323%
324% The format of the UnregisterStaticModules method is:
325%
326% UnregisterStaticModules(void)
327%
328*/
329MagickExport void UnregisterStaticModules(void)
330{
331#if !defined(MAGICKCORE_BUILD_MODULES)
332 UnregisterARTImage();
cristy3ed852e2009-09-05 21:47:34 +0000333 UnregisterAVSImage();
334 UnregisterBMPImage();
335 UnregisterBRAILLEImage();
336 UnregisterCAPTIONImage();
337 UnregisterCINImage();
338 UnregisterCIPImage();
339 UnregisterCLIPImage();
340#if defined(MAGICKCORE_WINGDI32_DELEGATE)
341 UnregisterCLIPBOARDImage();
342#endif
343 UnregisterCMYKImage();
344 UnregisterCUTImage();
345 UnregisterDCMImage();
346 UnregisterDDSImage();
347 UnregisterDIBImage();
348#if defined(MAGICKCORE_DJVU_DELEGATE)
349 UnregisterDJVUImage();
350#endif
351 UnregisterDNGImage();
cristyb32b90a2009-09-07 21:45:48 +0000352#if defined(MAGICKCORE_DPS_DELEGATE)
cristy3ed852e2009-09-05 21:47:34 +0000353 UnregisterDPSImage();
cristyb32b90a2009-09-07 21:45:48 +0000354#endif
cristy3ed852e2009-09-05 21:47:34 +0000355 UnregisterDPXImage();
356#if defined(MAGICKCORE_WINGDI32_DELEGATE)
357 UnregisterEMFImage();
358#endif
359#if defined(MAGICKCORE_TIFF_DELEGATE)
360 UnregisterEPTImage();
361#endif
362#if defined(MAGICKCORE_OPENEXR_DELEGATE)
363 UnregisterEXRImage();
364#endif
365 UnregisterFAXImage();
366 UnregisterFITSImage();
367#if defined(MAGICKCORE_FPX_DELEGATE)
368 UnregisterFPXImage();
369#endif
370 UnregisterGIFImage();
371 UnregisterGRAYImage();
372 UnregisterGRADIENTImage();
373 UnregisterHISTOGRAMImage();
374 UnregisterHRZImage();
375 UnregisterHTMLImage();
376 UnregisterICONImage();
377 UnregisterINFOImage();
378 UnregisterINLINEImage();
379 UnregisterIPLImage();
380#if defined(MAGICKCORE_JBIG_DELEGATE)
381 UnregisterJBIGImage();
382#endif
383#if defined(MAGICKCORE_JPEG_DELEGATE)
384 UnregisterJPEGImage();
385#endif
386#if defined(MAGICKCORE_JP2_DELEGATE)
387 UnregisterJP2Image();
388#endif
389 UnregisterLABELImage();
390 UnregisterMAGICKImage();
391 UnregisterMAPImage();
392 UnregisterMATImage();
393 UnregisterMATTEImage();
394 UnregisterMETAImage();
395 UnregisterMIFFImage();
396 UnregisterMONOImage();
397 UnregisterMPCImage();
398 UnregisterMPEGImage();
399 UnregisterMPRImage();
400 UnregisterMSLImage();
401 UnregisterMTVImage();
402 UnregisterMVGImage();
403 UnregisterNULLImage();
404 UnregisterOTBImage();
405 UnregisterPALMImage();
406 UnregisterPATTERNImage();
407 UnregisterPCDImage();
408 UnregisterPCLImage();
409 UnregisterPCXImage();
410 UnregisterPDBImage();
411 UnregisterPDFImage();
cristyc2e5d6d2010-01-24 17:45:00 +0000412 UnregisterPESImage();
cristy3ed852e2009-09-05 21:47:34 +0000413 UnregisterPICTImage();
414 UnregisterPIXImage();
415 UnregisterPLASMAImage();
416#if defined(MAGICKCORE_PNG_DELEGATE)
417 UnregisterPNGImage();
418#endif
419 UnregisterPNMImage();
420 UnregisterPREVIEWImage();
421 UnregisterPSImage();
422 UnregisterPS2Image();
423 UnregisterPS3Image();
424 UnregisterPSDImage();
425 UnregisterPWPImage();
426 UnregisterRAWImage();
427 UnregisterRGBImage();
428 UnregisterRLAImage();
429 UnregisterRLEImage();
430 UnregisterSCRImage();
431 UnregisterSCTImage();
432 UnregisterSFWImage();
433 UnregisterSGIImage();
434 UnregisterSTEGANOImage();
435 UnregisterSUNImage();
436 UnregisterSVGImage();
437 UnregisterTGAImage();
438 UnregisterTHUMBNAILImage();
439#if defined(MAGICKCORE_TIFF_DELEGATE)
440 UnregisterTIFFImage();
441#endif
442 UnregisterTILEImage();
443 UnregisterTIMImage();
444 UnregisterTTFImage();
445 UnregisterTXTImage();
446 UnregisterUILImage();
447 UnregisterURLImage();
448 UnregisterUYVYImage();
449 UnregisterVICARImage();
450 UnregisterVIDImage();
451 UnregisterVIFFImage();
452 UnregisterWBMPImage();
453#if defined(MAGICKCORE_WMF_DELEGATE) || defined(MAGICKCORE_WMFLITE_DELEGATE)
454 UnregisterWMFImage();
455#endif
456 UnregisterWPGImage();
457#if defined(MAGICKCORE_X11_DELEGATE)
458 UnregisterXImage();
459#endif
460 UnregisterXBMImage();
461 UnregisterXCImage();
462 UnregisterXCFImage();
463 UnregisterXPMImage();
464 UnregisterXPSImage();
465#if defined(_VISUALC_)
466 UnregisterXTRNImage();
467#endif
468#if defined(MAGICKCORE_X11_DELEGATE)
469 UnregisterXWDImage();
470#endif
471 UnregisterYCBCRImage();
472 UnregisterYUVImage();
473#endif
474}