blob: 0eecfedf1bfb0bd94eb690fd481d0d20562c10a2 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% CCCC OOO DDDD EEEEE RRRR %
7% C O O D D E R R %
8% C O O D D EEE RRRR %
9% C O O D D E R R %
10% CCCC OOO DDDD EEEEE R R %
11% %
12% %
13% MagickCore Image Coder Methods %
14% %
15% Software Design %
cristyde984cd2013-12-01 14:49:27 +000016% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000017% May 2001 %
18% %
19% %
Cristyf6ff9ea2016-12-05 09:53:35 -050020% Copyright 1999-2017 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% %
Cristyf19d4142017-04-24 11:34:30 -040026% https://www.imagemagick.org/script/license.php %
cristy3ed852e2009-09-05 21:47:34 +000027% %
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 Include declarations.
41*/
cristy4c08aed2011-07-01 19:47:50 +000042#include "MagickCore/studio.h"
43#include "MagickCore/blob.h"
44#include "MagickCore/client.h"
45#include "MagickCore/coder.h"
cristy5ff4eaf2011-09-03 01:38:02 +000046#include "MagickCore/coder-private.h"
cristy4c08aed2011-07-01 19:47:50 +000047#include "MagickCore/configure.h"
48#include "MagickCore/draw.h"
49#include "MagickCore/exception.h"
50#include "MagickCore/exception-private.h"
dirkabed7e22016-01-31 17:10:21 +010051#include "MagickCore/linked-list.h"
cristy4c08aed2011-07-01 19:47:50 +000052#include "MagickCore/log.h"
53#include "MagickCore/memory_.h"
Dirk Lemstra06344a02017-10-15 10:10:01 +020054#include "MagickCore/memory-private.h"
cristy4c08aed2011-07-01 19:47:50 +000055#include "MagickCore/option.h"
56#include "MagickCore/semaphore.h"
57#include "MagickCore/string_.h"
58#include "MagickCore/splay-tree.h"
59#include "MagickCore/token.h"
60#include "MagickCore/utility.h"
cristyd1dd6e42011-09-04 01:46:08 +000061#include "MagickCore/utility-private.h"
cristy4c08aed2011-07-01 19:47:50 +000062#include "MagickCore/xml-tree.h"
cristy3291f512014-03-16 22:16:22 +000063#include "MagickCore/xml-tree-private.h"
cristy3ed852e2009-09-05 21:47:34 +000064
65/*
66 Define declarations.
67*/
68#define MagickCoderFilename "coder.xml"
69
70/*
cristy54a531d2009-10-21 17:58:01 +000071 Typedef declarations.
cristy3ed852e2009-09-05 21:47:34 +000072*/
cristye3e77a12009-10-16 00:47:21 +000073typedef struct _CoderMapInfo
74{
75 const char
76 *magick,
77 *name;
78} CoderMapInfo;
cristy54a531d2009-10-21 17:58:01 +000079
80/*
81 Static declarations.
82*/
cristye3e77a12009-10-16 00:47:21 +000083static const CoderMapInfo
84 CoderMap[] =
85 {
86 { "3FR", "DNG" },
Cristyb066eae2017-01-20 09:15:54 -050087 { "3GP", "MPEG" },
88 { "3G2", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +000089 { "8BIMTEXT", "META" },
90 { "8BIMWTEXT", "META" },
91 { "AFM", "TTF" },
92 { "A", "RAW" },
93 { "AI", "PDF" },
94 { "APP1JPEG", "META" },
95 { "APP1", "META" },
96 { "ARW", "DNG" },
cristy0fc02592010-05-24 14:12:38 +000097 { "AVI", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +000098 { "BIE", "JBIG" },
99 { "BMP2", "BMP" },
100 { "BMP3", "BMP" },
101 { "B", "RAW" },
102 { "BRF", "BRAILLE" },
cristy90dbac72010-08-22 15:08:40 +0000103 { "BGRA", "BGR" },
dirk2a2d3d62015-07-27 11:09:58 +0000104 { "BGRO", "BGR" },
cristye3e77a12009-10-16 00:47:21 +0000105 { "CMYKA", "CMYK" },
106 { "C", "RAW" },
107 { "CAL", "CALS" },
cristyc05417c2010-09-21 16:30:32 +0000108 { "CANVAS", "XC" },
dirk2a2d3d62015-07-27 11:09:58 +0000109 { "CMYKA", "CMYK" },
cristye3e77a12009-10-16 00:47:21 +0000110 { "CR2", "DNG" },
111 { "CRW", "DNG" },
112 { "CUR", "ICON" },
Cristy6ffac4f2015-08-23 10:55:57 -0400113 { "DATA", "INLINE" },
cristye3e77a12009-10-16 00:47:21 +0000114 { "DCR", "DNG" },
115 { "DCX", "PCX" },
116 { "DFONT", "TTF" },
dirk2a2d3d62015-07-27 11:09:58 +0000117 { "DXT1", "DDS" },
118 { "DXT5", "DDS" },
cristye3e77a12009-10-16 00:47:21 +0000119 { "EPDF", "PDF" },
120 { "EPI", "PS" },
121 { "EPS2", "PS2" },
122 { "EPS3", "PS3" },
123 { "EPSF", "PS" },
124 { "EPSI", "PS" },
125 { "EPS", "PS" },
126 { "EPT2", "EPT" },
127 { "EPT3", "EPT" },
128 { "ERF", "DNG" },
129 { "EXIF", "META" },
130 { "FILE", "URL" },
131 { "FRACTAL", "PLASMA" },
132 { "FTP", "URL" },
133 { "FTS", "FITS" },
134 { "G3", "FAX" },
dirk52456ef2016-06-17 15:29:46 +0200135 { "G4", "FAX" },
cristye3e77a12009-10-16 00:47:21 +0000136 { "GIF87", "GIF" },
137 { "G", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000138 { "GRANITE", "MAGICK" },
139 { "GROUP4", "TIFF" },
cristy7f47ac62013-02-10 14:16:17 +0000140 { "GV", "DOT" },
dirk2a2d3d62015-07-27 11:09:58 +0000141 { "HTM", "HTML" },
142 { "ICB", "TGA" },
143 { "ICO", "ICON" },
cristya5338bb2014-11-05 18:25:16 +0000144 { "IIQ", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000145 { "K25", "DNG" },
146 { "KDC", "DNG" },
147 { "H", "MAGICK" },
148 { "HTM", "HTML" },
149 { "HTTP", "URL" },
dirk853b77b2013-09-21 19:04:42 +0000150 { "HTTPS", "URL" },
cristye3e77a12009-10-16 00:47:21 +0000151 { "ICB", "TGA" },
152 { "ICC", "META" },
153 { "ICM", "META" },
154 { "ICO", "ICON" },
155 { "IMPLICIT", "***" },
156 { "IPTC", "META" },
157 { "IPTCTEXT", "META" },
158 { "IPTCWTEXT", "META" },
159 { "ISOBRL", "BRAILLE" },
Samuel Thibault531aa152015-11-01 23:36:24 +0100160 { "ISOBRL6", "BRAILLE" },
cristye3e77a12009-10-16 00:47:21 +0000161 { "JBG", "JBIG" },
162 { "JNG", "PNG" },
163 { "JPC", "JP2" },
cristy2267fa42014-09-12 10:27:47 +0000164 { "JPT", "JP2" },
165 { "JPM", "JP2" },
cristy02f1fda2009-12-10 15:23:56 +0000166 { "J2C", "JP2" },
cristy4faac682012-05-10 12:09:45 +0000167 { "J2K", "JP2" },
dirk2a2d3d62015-07-27 11:09:58 +0000168 { "JNG", "PNG" },
cristyb338b712014-11-27 14:06:34 +0000169 { "JPE", "JPEG" },
cristye3e77a12009-10-16 00:47:21 +0000170 { "JPG", "JPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000171 { "JPM", "JP2" },
cristya663a4f2015-01-23 12:11:57 +0000172 { "JPS", "JPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000173 { "JPT", "JP2" },
cristye3e77a12009-10-16 00:47:21 +0000174 { "JPX", "JP2" },
175 { "K", "RAW" },
dirk2a2d3d62015-07-27 11:09:58 +0000176 { "K25", "DNG" },
177 { "KDC", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000178 { "LOGO", "MAGICK" },
dirk2a2d3d62015-07-27 11:09:58 +0000179 { "M", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000180 { "M2V", "MPEG" },
181 { "M4V", "MPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000182 { "MEF", "DNG" },
cristya3d81422015-04-03 13:00:33 +0000183 { "MKV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000184 { "MNG", "PNG" },
cristy1dbd5a32010-11-28 22:23:27 +0000185 { "MOV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000186 { "MP4", "MPEG" },
187 { "MPG", "MPEG" },
188 { "MPRI", "MPR" },
cristy1be98ec2012-01-30 16:51:12 +0000189 { "MEF", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000190 { "MRW", "DNG" },
191 { "MSVG", "SVG" },
192 { "NEF", "DNG" },
193 { "NETSCAPE", "MAGICK" },
cristycb8f0ae2012-03-02 12:26:21 +0000194 { "NRW", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000195 { "O", "RAW" },
196 { "ORF", "DNG" },
197 { "OTF", "TTF" },
198 { "P7", "PNM" },
199 { "PAL", "UYVY" },
200 { "PAM", "PNM" },
201 { "PBM", "PNM" },
202 { "PCDS", "PCD" },
dirk2a2d3d62015-07-27 11:09:58 +0000203 { "PCT", "PICT" },
cristye3e77a12009-10-16 00:47:21 +0000204 { "PDFA", "PDF" },
205 { "PEF", "DNG" },
206 { "PEF", "DNG" },
207 { "PFA", "TTF" },
208 { "PFB", "TTF" },
209 { "PFM", "PNM" },
210 { "PGM", "PNM" },
211 { "PGX", "JP2" },
212 { "PICON", "XPM" },
213 { "PJPEG", "JPEG" },
214 { "PM", "XPM" },
dirk2a2d3d62015-07-27 11:09:58 +0000215 { "PNG00", "PNG" },
cristye3e77a12009-10-16 00:47:21 +0000216 { "PNG24", "PNG" },
217 { "PNG32", "PNG" },
dirk2a2d3d62015-07-27 11:09:58 +0000218 { "PNG48", "PNG" },
219 { "PNG64", "PNG" },
cristye3e77a12009-10-16 00:47:21 +0000220 { "PNG8", "PNG" },
221 { "PPM", "PNM" },
cristyb4233012010-02-28 20:09:14 +0000222 { "PSB", "PSD" },
cristye3e77a12009-10-16 00:47:21 +0000223 { "PTIF", "TIFF" },
dirk2a2d3d62015-07-27 11:09:58 +0000224 { "R", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000225 { "RADIAL-GRADIENT", "GRADIENT" },
226 { "RAF", "DNG" },
227 { "RAS", "SUN" },
cristy1b1f0722014-06-10 10:14:59 +0000228 { "RAW", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000229 { "RGBA", "RGB" },
230 { "RGBO", "RGB" },
cristy15e22962014-02-21 22:56:26 +0000231 { "RMF", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000232 { "ROSE", "MAGICK" },
cristy98aceb82012-10-20 21:24:00 +0000233 { "RW2", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000234 { "SHTML", "HTML" },
dirka1e4ab82014-10-07 05:06:49 +0000235 { "SIX", "SIXEL" },
cristye6ee7492013-03-16 15:04:42 +0000236 { "SPARSE-COLOR", "TXT" },
cristye3e77a12009-10-16 00:47:21 +0000237 { "SR2", "DNG" },
238 { "SRF", "DNG" },
239 { "SVGZ", "SVG" },
240 { "TEXT", "TXT" },
241 { "TIFF64", "TIFF" },
242 { "TIF", "TIFF" },
243 { "TTC", "TTF" },
244 { "UBRL", "BRAILLE" },
Samuel Thibault531aa152015-11-01 23:36:24 +0100245 { "UBRL6", "BRAILLE" },
cristye3e77a12009-10-16 00:47:21 +0000246 { "VDA", "TGA" },
247 { "VST", "TGA" },
cristyed40d622011-01-17 15:51:00 +0000248 { "WIZARD", "MAGICK" },
dirk073ff372014-01-05 14:05:25 +0000249#if defined(MAGICKCORE_WINGDI32_DELEGATE)
250 { "WMF", "EMF" },
251#endif
cristye3e77a12009-10-16 00:47:21 +0000252 { "WMV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000253 { "WMZ", "WMF" },
254 { "X3f", "DNG" },
255 { "XMP", "META" },
256 { "XTRNARRAY", "XTRN" },
cristye3e77a12009-10-16 00:47:21 +0000257 { "XV", "VIFF" },
258 { "Y", "RAW" },
cristy54a531d2009-10-21 17:58:01 +0000259 { "YCbCrA", "YCbCr" }
cristye3e77a12009-10-16 00:47:21 +0000260 };
261
cristy3ed852e2009-09-05 21:47:34 +0000262static SemaphoreInfo
263 *coder_semaphore = (SemaphoreInfo *) NULL;
264
265static SplayTreeInfo
cristy86e5ac92014-03-16 19:27:39 +0000266 *coder_cache = (SplayTreeInfo *) NULL;
cristy3ed852e2009-09-05 21:47:34 +0000267
268/*
269 Forward declarations.
270*/
271static MagickBooleanType
cristy904e5912014-03-15 19:53:14 +0000272 IsCoderTreeInstantiated(ExceptionInfo *),
cristy86e5ac92014-03-16 19:27:39 +0000273 LoadCoderCache(SplayTreeInfo *,const char *,const char *,const size_t,
274 ExceptionInfo *);
275
276/*
277%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278% %
279% %
280% %
cristy6c6322e2014-09-09 22:39:21 +0000281+ A c q u i r e C o d e r C a c h e %
cristy86e5ac92014-03-16 19:27:39 +0000282% %
283% %
284% %
285%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286%
cristy6c6322e2014-09-09 22:39:21 +0000287% AcquireCoderCache() caches one or more coder configurations which provides a
288% mapping between coder attributes and a coder name.
cristy86e5ac92014-03-16 19:27:39 +0000289%
290% The format of the AcquireCoderCache coder is:
291%
292% SplayTreeInfo *AcquireCoderCache(const char *filename,
293% ExceptionInfo *exception)
294%
295% A description of each parameter follows:
296%
297% o filename: the font file name.
298%
299% o exception: return any errors or warnings in this structure.
300%
301*/
302
303static void *DestroyCoderNode(void *coder_info)
304{
305 register CoderInfo
306 *p;
307
308 p=(CoderInfo *) coder_info;
309 if (p->exempt == MagickFalse)
310 {
311 if (p->path != (char *) NULL)
312 p->path=DestroyString(p->path);
313 if (p->name != (char *) NULL)
314 p->name=DestroyString(p->name);
315 if (p->magick != (char *) NULL)
316 p->magick=DestroyString(p->magick);
317 }
318 return(RelinquishMagickMemory(p));
319}
320
321static SplayTreeInfo *AcquireCoderCache(const char *filename,
322 ExceptionInfo *exception)
323{
cristy86e5ac92014-03-16 19:27:39 +0000324 MagickStatusType
325 status;
326
327 register ssize_t
328 i;
329
330 SplayTreeInfo
dirkb18d8642016-07-17 19:32:43 +0200331 *cache;
cristy86e5ac92014-03-16 19:27:39 +0000332
333 /*
334 Load external coder map.
335 */
dirkb18d8642016-07-17 19:32:43 +0200336 cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
cristy86e5ac92014-03-16 19:27:39 +0000337 DestroyCoderNode);
dirkb18d8642016-07-17 19:32:43 +0200338 if (cache == (SplayTreeInfo *) NULL)
cristy86e5ac92014-03-16 19:27:39 +0000339 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
340 status=MagickTrue;
dirkb18d8642016-07-17 19:32:43 +0200341#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
cristy86e5ac92014-03-16 19:27:39 +0000342 {
dirkb18d8642016-07-17 19:32:43 +0200343 const StringInfo
344 *option;
345
346 LinkedListInfo
347 *options;
348
349 options=GetConfigureOptions(filename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000350 option=(const StringInfo *) GetNextValueInLinkedList(options);
dirkb18d8642016-07-17 19:32:43 +0200351 while (option != (const StringInfo *) NULL)
352 {
353 status&=LoadCoderCache(cache,(const char *) GetStringInfoDatum(option),
354 GetStringInfoPath(option),0,exception);
355 option=(const StringInfo *) GetNextValueInLinkedList(options);
356 }
357 options=DestroyConfigureOptions(options);
cristy86e5ac92014-03-16 19:27:39 +0000358 }
dirkb18d8642016-07-17 19:32:43 +0200359#endif
cristy86e5ac92014-03-16 19:27:39 +0000360 /*
361 Load built-in coder map.
362 */
363 for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
364 {
365 CoderInfo
366 *coder_info;
367
368 register const CoderMapInfo
369 *p;
370
371 p=CoderMap+i;
372 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
373 if (coder_info == (CoderInfo *) NULL)
374 {
375 (void) ThrowMagickException(exception,GetMagickModule(),
376 ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
377 continue;
378 }
379 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
380 coder_info->path=(char *) "[built-in]";
381 coder_info->magick=(char *) p->magick;
382 coder_info->name=(char *) p->name;
383 coder_info->exempt=MagickTrue;
cristye1c94d92015-06-28 12:16:33 +0000384 coder_info->signature=MagickCoreSignature;
dirkb18d8642016-07-17 19:32:43 +0200385 status&=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
cristy86e5ac92014-03-16 19:27:39 +0000386 coder_info);
387 if (status == MagickFalse)
388 (void) ThrowMagickException(exception,GetMagickModule(),
389 ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
390 }
dirkb18d8642016-07-17 19:32:43 +0200391 return(cache);
cristy86e5ac92014-03-16 19:27:39 +0000392}
cristy3ed852e2009-09-05 21:47:34 +0000393
394/*
395%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396% %
397% %
398% %
cristyf34a1452009-10-24 22:29:27 +0000399+ C o d e r C o m p o n e n t G e n e s i s %
cristy3ed852e2009-09-05 21:47:34 +0000400% %
401% %
402% %
403%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404%
cristyf34a1452009-10-24 22:29:27 +0000405% CoderComponentGenesis() instantiates the coder component.
cristy3ed852e2009-09-05 21:47:34 +0000406%
cristyf34a1452009-10-24 22:29:27 +0000407% The format of the CoderComponentGenesis method is:
cristy3ed852e2009-09-05 21:47:34 +0000408%
cristyf34a1452009-10-24 22:29:27 +0000409% MagickBooleanType CoderComponentGenesis(void)
cristy3ed852e2009-09-05 21:47:34 +0000410%
411*/
cristy5ff4eaf2011-09-03 01:38:02 +0000412MagickPrivate MagickBooleanType CoderComponentGenesis(void)
cristyf34a1452009-10-24 22:29:27 +0000413{
cristy7c977062014-04-04 14:05:53 +0000414 if (coder_semaphore == (SemaphoreInfo *) NULL)
415 coder_semaphore=AcquireSemaphoreInfo();
cristyf34a1452009-10-24 22:29:27 +0000416 return(MagickTrue);
417}
418
419/*
420%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
421% %
422% %
423% %
424+ C o d e r C o m p o n e n t T e r m i n u s %
425% %
426% %
427% %
428%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429%
430% CoderComponentTerminus() destroys the coder component.
431%
432% The format of the CoderComponentTerminus method is:
433%
434% CoderComponentTerminus(void)
435%
436*/
cristy5ff4eaf2011-09-03 01:38:02 +0000437MagickPrivate void CoderComponentTerminus(void)
cristy3ed852e2009-09-05 21:47:34 +0000438{
cristy18b17442009-10-25 18:36:48 +0000439 if (coder_semaphore == (SemaphoreInfo *) NULL)
cristy04b11db2014-02-16 15:10:39 +0000440 ActivateSemaphoreInfo(&coder_semaphore);
cristyf84a1932010-01-03 18:00:18 +0000441 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000442 if (coder_cache != (SplayTreeInfo *) NULL)
443 coder_cache=DestroySplayTree(coder_cache);
cristyf84a1932010-01-03 18:00:18 +0000444 UnlockSemaphoreInfo(coder_semaphore);
cristy3d162a92014-02-16 14:05:06 +0000445 RelinquishSemaphoreInfo(&coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000446}
447
448/*
449%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450% %
451% %
452% %
453+ G e t C o d e r I n f o %
454% %
455% %
456% %
457%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
458%
459% GetCoderInfo searches the coder list for the specified name and if found
460% returns attributes for that coder.
461%
462% The format of the GetCoderInfo method is:
463%
464% const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception)
465%
466% A description of each parameter follows:
467%
468% o name: the coder name.
469%
470% o exception: return any errors or warnings in this structure.
471%
472*/
473MagickExport const CoderInfo *GetCoderInfo(const char *name,
474 ExceptionInfo *exception)
475{
476 assert(exception != (ExceptionInfo *) NULL);
cristy904e5912014-03-15 19:53:14 +0000477 if (IsCoderTreeInstantiated(exception) == MagickFalse)
478 return((const CoderInfo *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000479 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
Cristy1d8b1f12017-09-16 10:13:23 -0400480 return((const CoderInfo *) GetRootValueFromSplayTree(coder_cache));
481 return((const CoderInfo *) GetValueFromSplayTree(coder_cache,name));
cristy3ed852e2009-09-05 21:47:34 +0000482}
483
484/*
485%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486% %
487% %
488% %
489% G e t C o d e r I n f o L i s t %
490% %
491% %
492% %
493%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
494%
495% GetCoderInfoList() returns any coder_map that match the specified pattern.
496% The format of the GetCoderInfoList function is:
497%
498% const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000499% size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000500%
501% A description of each parameter follows:
502%
503% o pattern: Specifies a pointer to a text string containing a pattern.
504%
505% o number_coders: This integer returns the number of coders in the list.
506%
507% o exception: return any errors or warnings in this structure.
508%
509*/
510
511static int CoderInfoCompare(const void *x,const void *y)
512{
513 const CoderInfo
514 **p,
515 **q;
516
517 p=(const CoderInfo **) x,
518 q=(const CoderInfo **) y;
519 if (LocaleCompare((*p)->path,(*q)->path) == 0)
520 return(LocaleCompare((*p)->name,(*q)->name));
521 return(LocaleCompare((*p)->path,(*q)->path));
522}
523
524MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000525 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000526{
527 const CoderInfo
528 **coder_map;
529
530 register const CoderInfo
531 *p;
532
cristybb503372010-05-27 20:51:26 +0000533 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000534 i;
535
536 /*
537 Allocate coder list.
538 */
539 assert(pattern != (char *) NULL);
540 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000541 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000542 *number_coders=0;
543 p=GetCoderInfo("*",exception);
544 if (p == (const CoderInfo *) NULL)
545 return((const CoderInfo **) NULL);
546 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000547 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000548 if (coder_map == (const CoderInfo **) NULL)
549 return((const CoderInfo **) NULL);
550 /*
551 Generate coder list.
552 */
cristyf84a1932010-01-03 18:00:18 +0000553 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000554 ResetSplayTreeIterator(coder_cache);
555 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000556 for (i=0; p != (const CoderInfo *) NULL; )
557 {
558 if ((p->stealth == MagickFalse) &&
559 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
560 coder_map[i++]=p;
cristy86e5ac92014-03-16 19:27:39 +0000561 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000562 }
cristyf84a1932010-01-03 18:00:18 +0000563 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000564 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
565 coder_map[i]=(CoderInfo *) NULL;
cristybb503372010-05-27 20:51:26 +0000566 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000567 return(coder_map);
568}
569
570/*
571%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572% %
573% %
574% %
575% G e t C o d e r L i s t %
576% %
577% %
578% %
579%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580%
581% GetCoderList() returns any coder_map that match the specified pattern.
582%
583% The format of the GetCoderList function is:
584%
cristybb503372010-05-27 20:51:26 +0000585% char **GetCoderList(const char *pattern,size_t *number_coders,
cristy3ed852e2009-09-05 21:47:34 +0000586% ExceptionInfo *exception)
587%
588% A description of each parameter follows:
589%
590% o pattern: Specifies a pointer to a text string containing a pattern.
591%
592% o number_coders: This integer returns the number of coders in the list.
593%
594% o exception: return any errors or warnings in this structure.
595%
596*/
597
598static int CoderCompare(const void *x,const void *y)
599{
600 register const char
601 **p,
602 **q;
603
604 p=(const char **) x;
605 q=(const char **) y;
606 return(LocaleCompare(*p,*q));
607}
608
609MagickExport char **GetCoderList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000610 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000611{
612 char
613 **coder_map;
614
615 register const CoderInfo
616 *p;
617
cristybb503372010-05-27 20:51:26 +0000618 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000619 i;
620
621 /*
622 Allocate coder list.
623 */
624 assert(pattern != (char *) NULL);
625 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000626 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000627 *number_coders=0;
628 p=GetCoderInfo("*",exception);
629 if (p == (const CoderInfo *) NULL)
630 return((char **) NULL);
631 coder_map=(char **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000632 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000633 if (coder_map == (char **) NULL)
634 return((char **) NULL);
635 /*
636 Generate coder list.
637 */
cristyf84a1932010-01-03 18:00:18 +0000638 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000639 ResetSplayTreeIterator(coder_cache);
640 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000641 for (i=0; p != (const CoderInfo *) NULL; )
642 {
643 if ((p->stealth == MagickFalse) &&
644 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
645 coder_map[i++]=ConstantString(p->name);
cristy86e5ac92014-03-16 19:27:39 +0000646 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000647 }
cristyf84a1932010-01-03 18:00:18 +0000648 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000649 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
650 coder_map[i]=(char *) NULL;
cristybb503372010-05-27 20:51:26 +0000651 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000652 return(coder_map);
653}
654
655/*
656%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657% %
658% %
659% %
cristy904e5912014-03-15 19:53:14 +0000660+ I s C o d e r T r e e I n s t a n t i a t e d %
cristy3ed852e2009-09-05 21:47:34 +0000661% %
662% %
663% %
664%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
665%
cristycd2cd182014-03-18 12:10:55 +0000666% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If
667% not, it instantiates the tree and returns it.
cristy3ed852e2009-09-05 21:47:34 +0000668%
cristy904e5912014-03-15 19:53:14 +0000669% The format of the IsCoderInstantiated method is:
cristy3ed852e2009-09-05 21:47:34 +0000670%
cristy904e5912014-03-15 19:53:14 +0000671% MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000672%
673% A description of each parameter follows.
674%
675% o exception: return any errors or warnings in this structure.
676%
677*/
cristy904e5912014-03-15 19:53:14 +0000678static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000679{
cristy86e5ac92014-03-16 19:27:39 +0000680 if (coder_cache == (SplayTreeInfo *) NULL)
681 {
682 if (coder_semaphore == (SemaphoreInfo *) NULL)
683 ActivateSemaphoreInfo(&coder_semaphore);
684 LockSemaphoreInfo(coder_semaphore);
685 if (coder_cache == (SplayTreeInfo *) NULL)
cristycd2cd182014-03-18 12:10:55 +0000686 coder_cache=AcquireCoderCache(MagickCoderFilename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000687 UnlockSemaphoreInfo(coder_semaphore);
688 }
689 return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000690}
691
692/*
693%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
694% %
695% %
696% %
697% L i s t C o d e r I n f o %
698% %
699% %
700% %
701%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
702%
703% ListCoderInfo() lists the coder info to a file.
704%
705% The format of the ListCoderInfo coder is:
706%
707% MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
708%
709% A description of each parameter follows.
710%
711% o file: An pointer to a FILE.
712%
713% o exception: return any errors or warnings in this structure.
714%
715*/
716MagickExport MagickBooleanType ListCoderInfo(FILE *file,
717 ExceptionInfo *exception)
718{
719 const char
720 *path;
721
722 const CoderInfo
723 **coder_info;
724
cristybb503372010-05-27 20:51:26 +0000725 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000726 i;
727
cristybb503372010-05-27 20:51:26 +0000728 size_t
cristy3ed852e2009-09-05 21:47:34 +0000729 number_coders;
730
cristy9d314ff2011-03-09 01:30:28 +0000731 ssize_t
732 j;
733
cristy3ed852e2009-09-05 21:47:34 +0000734 if (file == (const FILE *) NULL)
735 file=stdout;
736 coder_info=GetCoderInfoList("*",&number_coders,exception);
737 if (coder_info == (const CoderInfo **) NULL)
738 return(MagickFalse);
739 path=(const char *) NULL;
cristybb503372010-05-27 20:51:26 +0000740 for (i=0; i < (ssize_t) number_coders; i++)
cristy3ed852e2009-09-05 21:47:34 +0000741 {
742 if (coder_info[i]->stealth != MagickFalse)
743 continue;
744 if ((path == (const char *) NULL) ||
745 (LocaleCompare(path,coder_info[i]->path) != 0))
746 {
747 if (coder_info[i]->path != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000748 (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path);
749 (void) FormatLocaleFile(file,"Magick Coder\n");
cristy1e604812011-05-19 18:07:50 +0000750 (void) FormatLocaleFile(file,
751 "-------------------------------------------------"
cristy3ed852e2009-09-05 21:47:34 +0000752 "------------------------------\n");
753 }
754 path=coder_info[i]->path;
cristyb51dff52011-05-19 16:55:47 +0000755 (void) FormatLocaleFile(file,"%s",coder_info[i]->magick);
cristybb503372010-05-27 20:51:26 +0000756 for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
cristyb51dff52011-05-19 16:55:47 +0000757 (void) FormatLocaleFile(file," ");
cristy3ed852e2009-09-05 21:47:34 +0000758 if (coder_info[i]->name != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000759 (void) FormatLocaleFile(file,"%s",coder_info[i]->name);
760 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000761 }
762 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
763 (void) fflush(file);
764 return(MagickTrue);
765}
766
767/*
768%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
769% %
770% %
771% %
dirkfc0f1242016-03-26 00:36:39 +0100772+ L o a d C o d e r C a c h e %
cristy3ed852e2009-09-05 21:47:34 +0000773% %
774% %
775% %
776%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
777%
cristy86e5ac92014-03-16 19:27:39 +0000778% LoadCoderCache() loads the coder configurations which provides a
cristy3ed852e2009-09-05 21:47:34 +0000779% mapping between coder attributes and a coder name.
780%
cristy86e5ac92014-03-16 19:27:39 +0000781% The format of the LoadCoderCache coder is:
cristy3ed852e2009-09-05 21:47:34 +0000782%
dirkb18d8642016-07-17 19:32:43 +0200783% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
784% const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000785%
786% A description of each parameter follows:
787%
788% o xml: The coder list in XML format.
789%
790% o filename: The coder list filename.
791%
792% o depth: depth of <include /> statements.
793%
794% o exception: return any errors or warnings in this structure.
795%
796*/
dirkb18d8642016-07-17 19:32:43 +0200797static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
798 const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000799{
800 char
cristy151b66d2015-04-15 10:50:31 +0000801 keyword[MagickPathExtent],
cristy3ed852e2009-09-05 21:47:34 +0000802 *token;
803
804 const char
805 *q;
806
807 CoderInfo
808 *coder_info;
809
cristy759ba912014-06-26 11:59:43 +0000810 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000811 status;
812
dirkfc0f1242016-03-26 00:36:39 +0100813 size_t
814 extent;
815
cristy3ed852e2009-09-05 21:47:34 +0000816 /*
817 Load the coder map file.
818 */
819 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
820 "Loading coder configuration file \"%s\" ...",filename);
821 if (xml == (const char *) NULL)
822 return(MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000823 status=MagickTrue;
824 coder_info=(CoderInfo *) NULL;
825 token=AcquireString(xml);
dirkfc0f1242016-03-26 00:36:39 +0100826 extent=strlen(token)+MagickPathExtent;
cristy3ed852e2009-09-05 21:47:34 +0000827 for (q=(char *) xml; *q != '\0'; )
828 {
829 /*
830 Interpret XML.
831 */
Cristy8bedb4e2016-03-25 19:54:25 -0400832 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000833 if (*token == '\0')
834 break;
cristy151b66d2015-04-15 10:50:31 +0000835 (void) CopyMagickString(keyword,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000836 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
837 {
838 /*
839 Doctype element.
840 */
841 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400842 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000843 continue;
844 }
845 if (LocaleNCompare(keyword,"<!--",4) == 0)
846 {
847 /*
848 Comment element.
849 */
850 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400851 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000852 continue;
853 }
854 if (LocaleCompare(keyword,"<include") == 0)
855 {
856 /*
857 Include element.
858 */
859 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
860 {
cristy151b66d2015-04-15 10:50:31 +0000861 (void) CopyMagickString(keyword,token,MagickPathExtent);
Cristy8bedb4e2016-03-25 19:54:25 -0400862 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000863 if (*token != '=')
864 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400865 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000866 if (LocaleCompare(keyword,"file") == 0)
867 {
868 if (depth > 200)
869 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000870 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
cristy3ed852e2009-09-05 21:47:34 +0000871 else
872 {
873 char
cristy151b66d2015-04-15 10:50:31 +0000874 path[MagickPathExtent],
dirkb81f0ab2015-10-20 23:01:53 +0200875 *file_xml;
cristy3ed852e2009-09-05 21:47:34 +0000876
877 GetPathComponent(filename,HeadPath,path);
878 if (*path != '\0')
879 (void) ConcatenateMagickString(path,DirectorySeparator,
cristy151b66d2015-04-15 10:50:31 +0000880 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000881 if (*token == *DirectorySeparator)
cristy151b66d2015-04-15 10:50:31 +0000882 (void) CopyMagickString(path,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000883 else
cristy151b66d2015-04-15 10:50:31 +0000884 (void) ConcatenateMagickString(path,token,MagickPathExtent);
dirkb81f0ab2015-10-20 23:01:53 +0200885 file_xml=FileToXML(path,~0UL);
886 if (file_xml != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000887 {
dirkb18d8642016-07-17 19:32:43 +0200888 status&=LoadCoderCache(cache,file_xml,path,depth+1,
cristy86e5ac92014-03-16 19:27:39 +0000889 exception);
dirkb81f0ab2015-10-20 23:01:53 +0200890 file_xml=DestroyString(file_xml);
cristy3ed852e2009-09-05 21:47:34 +0000891 }
892 }
893 }
894 }
895 continue;
896 }
897 if (LocaleCompare(keyword,"<coder") == 0)
898 {
899 /*
900 Coder element.
901 */
Dirk Lemstra06344a02017-10-15 10:10:01 +0200902 coder_info=(CoderInfo *) AcquireCriticalMemory(sizeof(*coder_info));
cristy3ed852e2009-09-05 21:47:34 +0000903 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
904 coder_info->path=ConstantString(filename);
cristye3e77a12009-10-16 00:47:21 +0000905 coder_info->exempt=MagickFalse;
cristye1c94d92015-06-28 12:16:33 +0000906 coder_info->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000907 continue;
908 }
909 if (coder_info == (CoderInfo *) NULL)
910 continue;
Cristyfed111e2017-01-09 07:22:16 -0500911 if ((LocaleCompare(keyword,"/>") == 0) ||
912 (LocaleCompare(keyword,"</policy>") == 0))
cristy3ed852e2009-09-05 21:47:34 +0000913 {
dirkb18d8642016-07-17 19:32:43 +0200914 status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
915 coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000916 if (status == MagickFalse)
917 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000918 ResourceLimitError,"MemoryAllocationFailed","`%s'",
cristy3ed852e2009-09-05 21:47:34 +0000919 coder_info->magick);
920 coder_info=(CoderInfo *) NULL;
cristyd45122f2014-01-14 23:46:16 +0000921 continue;
cristy3ed852e2009-09-05 21:47:34 +0000922 }
Cristy8bedb4e2016-03-25 19:54:25 -0400923 GetNextToken(q,(const char **) NULL,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000924 if (*token != '=')
925 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400926 GetNextToken(q,&q,extent,token);
927 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000928 switch (*keyword)
929 {
930 case 'M':
931 case 'm':
932 {
933 if (LocaleCompare((char *) keyword,"magick") == 0)
934 {
935 coder_info->magick=ConstantString(token);
936 break;
937 }
938 break;
939 }
940 case 'N':
941 case 'n':
942 {
943 if (LocaleCompare((char *) keyword,"name") == 0)
944 {
945 coder_info->name=ConstantString(token);
946 break;
947 }
948 break;
949 }
950 case 'S':
951 case 's':
952 {
953 if (LocaleCompare((char *) keyword,"stealth") == 0)
954 {
anthony6f201312012-03-30 04:08:15 +0000955 coder_info->stealth=IsStringTrue(token);
cristy3ed852e2009-09-05 21:47:34 +0000956 break;
957 }
958 break;
959 }
960 default:
961 break;
962 }
963 }
964 token=(char *) RelinquishMagickMemory(token);
cristy759ba912014-06-26 11:59:43 +0000965 return(status != 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000966}