blob: 8590731eea3bcbaf37e909d3ace62ce40410a63a [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);
cristy86e5ac92014-03-16 19:27:39 +0000338 status=MagickTrue;
dirkb18d8642016-07-17 19:32:43 +0200339#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
cristy86e5ac92014-03-16 19:27:39 +0000340 {
dirkb18d8642016-07-17 19:32:43 +0200341 const StringInfo
342 *option;
343
344 LinkedListInfo
345 *options;
346
347 options=GetConfigureOptions(filename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000348 option=(const StringInfo *) GetNextValueInLinkedList(options);
dirkb18d8642016-07-17 19:32:43 +0200349 while (option != (const StringInfo *) NULL)
350 {
351 status&=LoadCoderCache(cache,(const char *) GetStringInfoDatum(option),
352 GetStringInfoPath(option),0,exception);
353 option=(const StringInfo *) GetNextValueInLinkedList(options);
354 }
355 options=DestroyConfigureOptions(options);
cristy86e5ac92014-03-16 19:27:39 +0000356 }
dirkb18d8642016-07-17 19:32:43 +0200357#endif
cristy86e5ac92014-03-16 19:27:39 +0000358 /*
359 Load built-in coder map.
360 */
361 for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
362 {
363 CoderInfo
364 *coder_info;
365
366 register const CoderMapInfo
367 *p;
368
369 p=CoderMap+i;
370 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
371 if (coder_info == (CoderInfo *) NULL)
372 {
373 (void) ThrowMagickException(exception,GetMagickModule(),
374 ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
375 continue;
376 }
377 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
378 coder_info->path=(char *) "[built-in]";
379 coder_info->magick=(char *) p->magick;
380 coder_info->name=(char *) p->name;
381 coder_info->exempt=MagickTrue;
cristye1c94d92015-06-28 12:16:33 +0000382 coder_info->signature=MagickCoreSignature;
dirkb18d8642016-07-17 19:32:43 +0200383 status&=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
cristy86e5ac92014-03-16 19:27:39 +0000384 coder_info);
385 if (status == MagickFalse)
386 (void) ThrowMagickException(exception,GetMagickModule(),
387 ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
388 }
dirkb18d8642016-07-17 19:32:43 +0200389 return(cache);
cristy86e5ac92014-03-16 19:27:39 +0000390}
cristy3ed852e2009-09-05 21:47:34 +0000391
392/*
393%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394% %
395% %
396% %
cristyf34a1452009-10-24 22:29:27 +0000397+ 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 +0000398% %
399% %
400% %
401%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402%
cristyf34a1452009-10-24 22:29:27 +0000403% CoderComponentGenesis() instantiates the coder component.
cristy3ed852e2009-09-05 21:47:34 +0000404%
cristyf34a1452009-10-24 22:29:27 +0000405% The format of the CoderComponentGenesis method is:
cristy3ed852e2009-09-05 21:47:34 +0000406%
cristyf34a1452009-10-24 22:29:27 +0000407% MagickBooleanType CoderComponentGenesis(void)
cristy3ed852e2009-09-05 21:47:34 +0000408%
409*/
cristy5ff4eaf2011-09-03 01:38:02 +0000410MagickPrivate MagickBooleanType CoderComponentGenesis(void)
cristyf34a1452009-10-24 22:29:27 +0000411{
cristy7c977062014-04-04 14:05:53 +0000412 if (coder_semaphore == (SemaphoreInfo *) NULL)
413 coder_semaphore=AcquireSemaphoreInfo();
cristyf34a1452009-10-24 22:29:27 +0000414 return(MagickTrue);
415}
416
417/*
418%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419% %
420% %
421% %
422+ C o d e r C o m p o n e n t T e r m i n u s %
423% %
424% %
425% %
426%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427%
428% CoderComponentTerminus() destroys the coder component.
429%
430% The format of the CoderComponentTerminus method is:
431%
432% CoderComponentTerminus(void)
433%
434*/
cristy5ff4eaf2011-09-03 01:38:02 +0000435MagickPrivate void CoderComponentTerminus(void)
cristy3ed852e2009-09-05 21:47:34 +0000436{
cristy18b17442009-10-25 18:36:48 +0000437 if (coder_semaphore == (SemaphoreInfo *) NULL)
cristy04b11db2014-02-16 15:10:39 +0000438 ActivateSemaphoreInfo(&coder_semaphore);
cristyf84a1932010-01-03 18:00:18 +0000439 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000440 if (coder_cache != (SplayTreeInfo *) NULL)
441 coder_cache=DestroySplayTree(coder_cache);
cristyf84a1932010-01-03 18:00:18 +0000442 UnlockSemaphoreInfo(coder_semaphore);
cristy3d162a92014-02-16 14:05:06 +0000443 RelinquishSemaphoreInfo(&coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000444}
445
446/*
447%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448% %
449% %
450% %
451+ G e t C o d e r I n f o %
452% %
453% %
454% %
455%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
456%
457% GetCoderInfo searches the coder list for the specified name and if found
458% returns attributes for that coder.
459%
460% The format of the GetCoderInfo method is:
461%
462% const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception)
463%
464% A description of each parameter follows:
465%
466% o name: the coder name.
467%
468% o exception: return any errors or warnings in this structure.
469%
470*/
471MagickExport const CoderInfo *GetCoderInfo(const char *name,
472 ExceptionInfo *exception)
473{
474 assert(exception != (ExceptionInfo *) NULL);
cristy904e5912014-03-15 19:53:14 +0000475 if (IsCoderTreeInstantiated(exception) == MagickFalse)
476 return((const CoderInfo *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000477 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
Cristy1d8b1f12017-09-16 10:13:23 -0400478 return((const CoderInfo *) GetRootValueFromSplayTree(coder_cache));
479 return((const CoderInfo *) GetValueFromSplayTree(coder_cache,name));
cristy3ed852e2009-09-05 21:47:34 +0000480}
481
482/*
483%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484% %
485% %
486% %
487% G e t C o d e r I n f o L i s t %
488% %
489% %
490% %
491%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
492%
493% GetCoderInfoList() returns any coder_map that match the specified pattern.
494% The format of the GetCoderInfoList function is:
495%
496% const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000497% size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000498%
499% A description of each parameter follows:
500%
501% o pattern: Specifies a pointer to a text string containing a pattern.
502%
503% o number_coders: This integer returns the number of coders in the list.
504%
505% o exception: return any errors or warnings in this structure.
506%
507*/
508
509static int CoderInfoCompare(const void *x,const void *y)
510{
511 const CoderInfo
512 **p,
513 **q;
514
515 p=(const CoderInfo **) x,
516 q=(const CoderInfo **) y;
517 if (LocaleCompare((*p)->path,(*q)->path) == 0)
518 return(LocaleCompare((*p)->name,(*q)->name));
519 return(LocaleCompare((*p)->path,(*q)->path));
520}
521
522MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000523 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000524{
525 const CoderInfo
526 **coder_map;
527
528 register const CoderInfo
529 *p;
530
cristybb503372010-05-27 20:51:26 +0000531 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000532 i;
533
534 /*
535 Allocate coder list.
536 */
537 assert(pattern != (char *) NULL);
538 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000539 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000540 *number_coders=0;
541 p=GetCoderInfo("*",exception);
542 if (p == (const CoderInfo *) NULL)
543 return((const CoderInfo **) NULL);
544 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000545 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000546 if (coder_map == (const CoderInfo **) NULL)
547 return((const CoderInfo **) NULL);
548 /*
549 Generate coder list.
550 */
cristyf84a1932010-01-03 18:00:18 +0000551 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000552 ResetSplayTreeIterator(coder_cache);
553 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000554 for (i=0; p != (const CoderInfo *) NULL; )
555 {
556 if ((p->stealth == MagickFalse) &&
557 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
558 coder_map[i++]=p;
cristy86e5ac92014-03-16 19:27:39 +0000559 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000560 }
cristyf84a1932010-01-03 18:00:18 +0000561 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000562 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
563 coder_map[i]=(CoderInfo *) NULL;
cristybb503372010-05-27 20:51:26 +0000564 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000565 return(coder_map);
566}
567
568/*
569%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570% %
571% %
572% %
573% G e t C o d e r L i s t %
574% %
575% %
576% %
577%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578%
579% GetCoderList() returns any coder_map that match the specified pattern.
580%
581% The format of the GetCoderList function is:
582%
cristybb503372010-05-27 20:51:26 +0000583% char **GetCoderList(const char *pattern,size_t *number_coders,
cristy3ed852e2009-09-05 21:47:34 +0000584% ExceptionInfo *exception)
585%
586% A description of each parameter follows:
587%
588% o pattern: Specifies a pointer to a text string containing a pattern.
589%
590% o number_coders: This integer returns the number of coders in the list.
591%
592% o exception: return any errors or warnings in this structure.
593%
594*/
595
596static int CoderCompare(const void *x,const void *y)
597{
598 register const char
599 **p,
600 **q;
601
602 p=(const char **) x;
603 q=(const char **) y;
604 return(LocaleCompare(*p,*q));
605}
606
607MagickExport char **GetCoderList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000608 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000609{
610 char
611 **coder_map;
612
613 register const CoderInfo
614 *p;
615
cristybb503372010-05-27 20:51:26 +0000616 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000617 i;
618
619 /*
620 Allocate coder list.
621 */
622 assert(pattern != (char *) NULL);
623 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000624 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000625 *number_coders=0;
626 p=GetCoderInfo("*",exception);
627 if (p == (const CoderInfo *) NULL)
628 return((char **) NULL);
629 coder_map=(char **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000630 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000631 if (coder_map == (char **) NULL)
632 return((char **) NULL);
633 /*
634 Generate coder list.
635 */
cristyf84a1932010-01-03 18:00:18 +0000636 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000637 ResetSplayTreeIterator(coder_cache);
638 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000639 for (i=0; p != (const CoderInfo *) NULL; )
640 {
641 if ((p->stealth == MagickFalse) &&
642 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
643 coder_map[i++]=ConstantString(p->name);
cristy86e5ac92014-03-16 19:27:39 +0000644 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000645 }
cristyf84a1932010-01-03 18:00:18 +0000646 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000647 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
648 coder_map[i]=(char *) NULL;
cristybb503372010-05-27 20:51:26 +0000649 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000650 return(coder_map);
651}
652
653/*
654%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655% %
656% %
657% %
cristy904e5912014-03-15 19:53:14 +0000658+ 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 +0000659% %
660% %
661% %
662%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663%
cristycd2cd182014-03-18 12:10:55 +0000664% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If
665% not, it instantiates the tree and returns it.
cristy3ed852e2009-09-05 21:47:34 +0000666%
cristy904e5912014-03-15 19:53:14 +0000667% The format of the IsCoderInstantiated method is:
cristy3ed852e2009-09-05 21:47:34 +0000668%
cristy904e5912014-03-15 19:53:14 +0000669% MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000670%
671% A description of each parameter follows.
672%
673% o exception: return any errors or warnings in this structure.
674%
675*/
cristy904e5912014-03-15 19:53:14 +0000676static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000677{
cristy86e5ac92014-03-16 19:27:39 +0000678 if (coder_cache == (SplayTreeInfo *) NULL)
679 {
680 if (coder_semaphore == (SemaphoreInfo *) NULL)
681 ActivateSemaphoreInfo(&coder_semaphore);
682 LockSemaphoreInfo(coder_semaphore);
683 if (coder_cache == (SplayTreeInfo *) NULL)
cristycd2cd182014-03-18 12:10:55 +0000684 coder_cache=AcquireCoderCache(MagickCoderFilename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000685 UnlockSemaphoreInfo(coder_semaphore);
686 }
687 return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000688}
689
690/*
691%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
692% %
693% %
694% %
695% L i s t C o d e r I n f o %
696% %
697% %
698% %
699%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
700%
701% ListCoderInfo() lists the coder info to a file.
702%
703% The format of the ListCoderInfo coder is:
704%
705% MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
706%
707% A description of each parameter follows.
708%
709% o file: An pointer to a FILE.
710%
711% o exception: return any errors or warnings in this structure.
712%
713*/
714MagickExport MagickBooleanType ListCoderInfo(FILE *file,
715 ExceptionInfo *exception)
716{
717 const char
718 *path;
719
720 const CoderInfo
721 **coder_info;
722
cristybb503372010-05-27 20:51:26 +0000723 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000724 i;
725
cristybb503372010-05-27 20:51:26 +0000726 size_t
cristy3ed852e2009-09-05 21:47:34 +0000727 number_coders;
728
cristy9d314ff2011-03-09 01:30:28 +0000729 ssize_t
730 j;
731
cristy3ed852e2009-09-05 21:47:34 +0000732 if (file == (const FILE *) NULL)
733 file=stdout;
734 coder_info=GetCoderInfoList("*",&number_coders,exception);
735 if (coder_info == (const CoderInfo **) NULL)
736 return(MagickFalse);
737 path=(const char *) NULL;
cristybb503372010-05-27 20:51:26 +0000738 for (i=0; i < (ssize_t) number_coders; i++)
cristy3ed852e2009-09-05 21:47:34 +0000739 {
740 if (coder_info[i]->stealth != MagickFalse)
741 continue;
742 if ((path == (const char *) NULL) ||
743 (LocaleCompare(path,coder_info[i]->path) != 0))
744 {
745 if (coder_info[i]->path != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000746 (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path);
747 (void) FormatLocaleFile(file,"Magick Coder\n");
cristy1e604812011-05-19 18:07:50 +0000748 (void) FormatLocaleFile(file,
749 "-------------------------------------------------"
cristy3ed852e2009-09-05 21:47:34 +0000750 "------------------------------\n");
751 }
752 path=coder_info[i]->path;
cristyb51dff52011-05-19 16:55:47 +0000753 (void) FormatLocaleFile(file,"%s",coder_info[i]->magick);
cristybb503372010-05-27 20:51:26 +0000754 for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
cristyb51dff52011-05-19 16:55:47 +0000755 (void) FormatLocaleFile(file," ");
cristy3ed852e2009-09-05 21:47:34 +0000756 if (coder_info[i]->name != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000757 (void) FormatLocaleFile(file,"%s",coder_info[i]->name);
758 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000759 }
760 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
761 (void) fflush(file);
762 return(MagickTrue);
763}
764
765/*
766%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
767% %
768% %
769% %
dirkfc0f1242016-03-26 00:36:39 +0100770+ L o a d C o d e r C a c h e %
cristy3ed852e2009-09-05 21:47:34 +0000771% %
772% %
773% %
774%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
775%
cristy86e5ac92014-03-16 19:27:39 +0000776% LoadCoderCache() loads the coder configurations which provides a
cristy3ed852e2009-09-05 21:47:34 +0000777% mapping between coder attributes and a coder name.
778%
cristy86e5ac92014-03-16 19:27:39 +0000779% The format of the LoadCoderCache coder is:
cristy3ed852e2009-09-05 21:47:34 +0000780%
dirkb18d8642016-07-17 19:32:43 +0200781% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
782% const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000783%
784% A description of each parameter follows:
785%
786% o xml: The coder list in XML format.
787%
788% o filename: The coder list filename.
789%
790% o depth: depth of <include /> statements.
791%
792% o exception: return any errors or warnings in this structure.
793%
794*/
dirkb18d8642016-07-17 19:32:43 +0200795static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
796 const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000797{
798 char
cristy151b66d2015-04-15 10:50:31 +0000799 keyword[MagickPathExtent],
cristy3ed852e2009-09-05 21:47:34 +0000800 *token;
801
802 const char
803 *q;
804
805 CoderInfo
806 *coder_info;
807
cristy759ba912014-06-26 11:59:43 +0000808 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000809 status;
810
dirkfc0f1242016-03-26 00:36:39 +0100811 size_t
812 extent;
813
cristy3ed852e2009-09-05 21:47:34 +0000814 /*
815 Load the coder map file.
816 */
817 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
818 "Loading coder configuration file \"%s\" ...",filename);
819 if (xml == (const char *) NULL)
820 return(MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000821 status=MagickTrue;
822 coder_info=(CoderInfo *) NULL;
823 token=AcquireString(xml);
dirkfc0f1242016-03-26 00:36:39 +0100824 extent=strlen(token)+MagickPathExtent;
cristy3ed852e2009-09-05 21:47:34 +0000825 for (q=(char *) xml; *q != '\0'; )
826 {
827 /*
828 Interpret XML.
829 */
Cristy8bedb4e2016-03-25 19:54:25 -0400830 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000831 if (*token == '\0')
832 break;
cristy151b66d2015-04-15 10:50:31 +0000833 (void) CopyMagickString(keyword,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000834 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
835 {
836 /*
837 Doctype element.
838 */
839 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400840 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000841 continue;
842 }
843 if (LocaleNCompare(keyword,"<!--",4) == 0)
844 {
845 /*
846 Comment element.
847 */
848 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400849 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000850 continue;
851 }
852 if (LocaleCompare(keyword,"<include") == 0)
853 {
854 /*
855 Include element.
856 */
857 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
858 {
cristy151b66d2015-04-15 10:50:31 +0000859 (void) CopyMagickString(keyword,token,MagickPathExtent);
Cristy8bedb4e2016-03-25 19:54:25 -0400860 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000861 if (*token != '=')
862 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400863 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000864 if (LocaleCompare(keyword,"file") == 0)
865 {
866 if (depth > 200)
867 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000868 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
cristy3ed852e2009-09-05 21:47:34 +0000869 else
870 {
871 char
cristy151b66d2015-04-15 10:50:31 +0000872 path[MagickPathExtent],
dirkb81f0ab2015-10-20 23:01:53 +0200873 *file_xml;
cristy3ed852e2009-09-05 21:47:34 +0000874
875 GetPathComponent(filename,HeadPath,path);
876 if (*path != '\0')
877 (void) ConcatenateMagickString(path,DirectorySeparator,
cristy151b66d2015-04-15 10:50:31 +0000878 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000879 if (*token == *DirectorySeparator)
cristy151b66d2015-04-15 10:50:31 +0000880 (void) CopyMagickString(path,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000881 else
cristy151b66d2015-04-15 10:50:31 +0000882 (void) ConcatenateMagickString(path,token,MagickPathExtent);
dirkb81f0ab2015-10-20 23:01:53 +0200883 file_xml=FileToXML(path,~0UL);
884 if (file_xml != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000885 {
dirkb18d8642016-07-17 19:32:43 +0200886 status&=LoadCoderCache(cache,file_xml,path,depth+1,
cristy86e5ac92014-03-16 19:27:39 +0000887 exception);
dirkb81f0ab2015-10-20 23:01:53 +0200888 file_xml=DestroyString(file_xml);
cristy3ed852e2009-09-05 21:47:34 +0000889 }
890 }
891 }
892 }
893 continue;
894 }
895 if (LocaleCompare(keyword,"<coder") == 0)
896 {
897 /*
898 Coder element.
899 */
Dirk Lemstra06344a02017-10-15 10:10:01 +0200900 coder_info=(CoderInfo *) AcquireCriticalMemory(sizeof(*coder_info));
cristy3ed852e2009-09-05 21:47:34 +0000901 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
902 coder_info->path=ConstantString(filename);
cristye3e77a12009-10-16 00:47:21 +0000903 coder_info->exempt=MagickFalse;
cristye1c94d92015-06-28 12:16:33 +0000904 coder_info->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000905 continue;
906 }
907 if (coder_info == (CoderInfo *) NULL)
908 continue;
Cristyfed111e2017-01-09 07:22:16 -0500909 if ((LocaleCompare(keyword,"/>") == 0) ||
910 (LocaleCompare(keyword,"</policy>") == 0))
cristy3ed852e2009-09-05 21:47:34 +0000911 {
dirkb18d8642016-07-17 19:32:43 +0200912 status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
913 coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000914 if (status == MagickFalse)
915 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000916 ResourceLimitError,"MemoryAllocationFailed","`%s'",
cristy3ed852e2009-09-05 21:47:34 +0000917 coder_info->magick);
918 coder_info=(CoderInfo *) NULL;
cristyd45122f2014-01-14 23:46:16 +0000919 continue;
cristy3ed852e2009-09-05 21:47:34 +0000920 }
Cristy8bedb4e2016-03-25 19:54:25 -0400921 GetNextToken(q,(const char **) NULL,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000922 if (*token != '=')
923 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400924 GetNextToken(q,&q,extent,token);
925 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000926 switch (*keyword)
927 {
928 case 'M':
929 case 'm':
930 {
931 if (LocaleCompare((char *) keyword,"magick") == 0)
932 {
933 coder_info->magick=ConstantString(token);
934 break;
935 }
936 break;
937 }
938 case 'N':
939 case 'n':
940 {
941 if (LocaleCompare((char *) keyword,"name") == 0)
942 {
943 coder_info->name=ConstantString(token);
944 break;
945 }
946 break;
947 }
948 case 'S':
949 case 's':
950 {
951 if (LocaleCompare((char *) keyword,"stealth") == 0)
952 {
anthony6f201312012-03-30 04:08:15 +0000953 coder_info->stealth=IsStringTrue(token);
cristy3ed852e2009-09-05 21:47:34 +0000954 break;
955 }
956 break;
957 }
958 default:
959 break;
960 }
961 }
962 token=(char *) RelinquishMagickMemory(token);
cristy759ba912014-06-26 11:59:43 +0000963 return(status != 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000964}