blob: 4836fc8124400552e0d63b01eca9383d36024c9a [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% %
Cristy93b707b2017-12-06 07:05:51 -050020% Copyright 1999-2018 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" },
cristye3e77a12009-10-16 00:47:21 +0000211 { "PICON", "XPM" },
212 { "PJPEG", "JPEG" },
213 { "PM", "XPM" },
dirk2a2d3d62015-07-27 11:09:58 +0000214 { "PNG00", "PNG" },
cristye3e77a12009-10-16 00:47:21 +0000215 { "PNG24", "PNG" },
216 { "PNG32", "PNG" },
dirk2a2d3d62015-07-27 11:09:58 +0000217 { "PNG48", "PNG" },
218 { "PNG64", "PNG" },
cristye3e77a12009-10-16 00:47:21 +0000219 { "PNG8", "PNG" },
220 { "PPM", "PNM" },
cristyb4233012010-02-28 20:09:14 +0000221 { "PSB", "PSD" },
cristye3e77a12009-10-16 00:47:21 +0000222 { "PTIF", "TIFF" },
dirk2a2d3d62015-07-27 11:09:58 +0000223 { "R", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000224 { "RADIAL-GRADIENT", "GRADIENT" },
225 { "RAF", "DNG" },
226 { "RAS", "SUN" },
cristy1b1f0722014-06-10 10:14:59 +0000227 { "RAW", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000228 { "RGBA", "RGB" },
229 { "RGBO", "RGB" },
cristy15e22962014-02-21 22:56:26 +0000230 { "RMF", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000231 { "ROSE", "MAGICK" },
cristy98aceb82012-10-20 21:24:00 +0000232 { "RW2", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000233 { "SHTML", "HTML" },
dirka1e4ab82014-10-07 05:06:49 +0000234 { "SIX", "SIXEL" },
cristye6ee7492013-03-16 15:04:42 +0000235 { "SPARSE-COLOR", "TXT" },
cristye3e77a12009-10-16 00:47:21 +0000236 { "SR2", "DNG" },
237 { "SRF", "DNG" },
238 { "SVGZ", "SVG" },
239 { "TEXT", "TXT" },
240 { "TIFF64", "TIFF" },
241 { "TIF", "TIFF" },
242 { "TTC", "TTF" },
243 { "UBRL", "BRAILLE" },
Samuel Thibault531aa152015-11-01 23:36:24 +0100244 { "UBRL6", "BRAILLE" },
cristye3e77a12009-10-16 00:47:21 +0000245 { "VDA", "TGA" },
246 { "VST", "TGA" },
cristyed40d622011-01-17 15:51:00 +0000247 { "WIZARD", "MAGICK" },
dirk073ff372014-01-05 14:05:25 +0000248#if defined(MAGICKCORE_WINGDI32_DELEGATE)
249 { "WMF", "EMF" },
250#endif
cristye3e77a12009-10-16 00:47:21 +0000251 { "WMV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000252 { "WMZ", "WMF" },
253 { "X3f", "DNG" },
254 { "XMP", "META" },
255 { "XTRNARRAY", "XTRN" },
cristye3e77a12009-10-16 00:47:21 +0000256 { "XV", "VIFF" },
257 { "Y", "RAW" },
cristy54a531d2009-10-21 17:58:01 +0000258 { "YCbCrA", "YCbCr" }
cristye3e77a12009-10-16 00:47:21 +0000259 };
260
cristy3ed852e2009-09-05 21:47:34 +0000261static SemaphoreInfo
262 *coder_semaphore = (SemaphoreInfo *) NULL;
263
264static SplayTreeInfo
cristy86e5ac92014-03-16 19:27:39 +0000265 *coder_cache = (SplayTreeInfo *) NULL;
cristy3ed852e2009-09-05 21:47:34 +0000266
267/*
268 Forward declarations.
269*/
270static MagickBooleanType
cristy904e5912014-03-15 19:53:14 +0000271 IsCoderTreeInstantiated(ExceptionInfo *),
cristy86e5ac92014-03-16 19:27:39 +0000272 LoadCoderCache(SplayTreeInfo *,const char *,const char *,const size_t,
273 ExceptionInfo *);
274
275/*
276%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277% %
278% %
279% %
cristy6c6322e2014-09-09 22:39:21 +0000280+ A c q u i r e C o d e r C a c h e %
cristy86e5ac92014-03-16 19:27:39 +0000281% %
282% %
283% %
284%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285%
cristy6c6322e2014-09-09 22:39:21 +0000286% AcquireCoderCache() caches one or more coder configurations which provides a
287% mapping between coder attributes and a coder name.
cristy86e5ac92014-03-16 19:27:39 +0000288%
289% The format of the AcquireCoderCache coder is:
290%
291% SplayTreeInfo *AcquireCoderCache(const char *filename,
292% ExceptionInfo *exception)
293%
294% A description of each parameter follows:
295%
296% o filename: the font file name.
297%
298% o exception: return any errors or warnings in this structure.
299%
300*/
301
302static void *DestroyCoderNode(void *coder_info)
303{
304 register CoderInfo
305 *p;
306
307 p=(CoderInfo *) coder_info;
308 if (p->exempt == MagickFalse)
309 {
310 if (p->path != (char *) NULL)
311 p->path=DestroyString(p->path);
312 if (p->name != (char *) NULL)
313 p->name=DestroyString(p->name);
314 if (p->magick != (char *) NULL)
315 p->magick=DestroyString(p->magick);
316 }
317 return(RelinquishMagickMemory(p));
318}
319
320static SplayTreeInfo *AcquireCoderCache(const char *filename,
321 ExceptionInfo *exception)
322{
cristy86e5ac92014-03-16 19:27:39 +0000323 MagickStatusType
324 status;
325
326 register ssize_t
327 i;
328
329 SplayTreeInfo
dirkb18d8642016-07-17 19:32:43 +0200330 *cache;
cristy86e5ac92014-03-16 19:27:39 +0000331
332 /*
333 Load external coder map.
334 */
dirkb18d8642016-07-17 19:32:43 +0200335 cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
cristy86e5ac92014-03-16 19:27:39 +0000336 DestroyCoderNode);
cristy86e5ac92014-03-16 19:27:39 +0000337 status=MagickTrue;
dirkb18d8642016-07-17 19:32:43 +0200338#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
cristy86e5ac92014-03-16 19:27:39 +0000339 {
dirkb18d8642016-07-17 19:32:43 +0200340 const StringInfo
341 *option;
342
343 LinkedListInfo
344 *options;
345
346 options=GetConfigureOptions(filename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000347 option=(const StringInfo *) GetNextValueInLinkedList(options);
dirkb18d8642016-07-17 19:32:43 +0200348 while (option != (const StringInfo *) NULL)
349 {
350 status&=LoadCoderCache(cache,(const char *) GetStringInfoDatum(option),
351 GetStringInfoPath(option),0,exception);
352 option=(const StringInfo *) GetNextValueInLinkedList(options);
353 }
354 options=DestroyConfigureOptions(options);
cristy86e5ac92014-03-16 19:27:39 +0000355 }
dirkb18d8642016-07-17 19:32:43 +0200356#endif
cristy86e5ac92014-03-16 19:27:39 +0000357 /*
358 Load built-in coder map.
359 */
360 for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
361 {
362 CoderInfo
363 *coder_info;
364
365 register const CoderMapInfo
366 *p;
367
368 p=CoderMap+i;
369 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
370 if (coder_info == (CoderInfo *) NULL)
371 {
372 (void) ThrowMagickException(exception,GetMagickModule(),
373 ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
374 continue;
375 }
376 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
377 coder_info->path=(char *) "[built-in]";
378 coder_info->magick=(char *) p->magick;
379 coder_info->name=(char *) p->name;
380 coder_info->exempt=MagickTrue;
cristye1c94d92015-06-28 12:16:33 +0000381 coder_info->signature=MagickCoreSignature;
dirkb18d8642016-07-17 19:32:43 +0200382 status&=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
cristy86e5ac92014-03-16 19:27:39 +0000383 coder_info);
384 if (status == MagickFalse)
385 (void) ThrowMagickException(exception,GetMagickModule(),
386 ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
387 }
dirkb18d8642016-07-17 19:32:43 +0200388 return(cache);
cristy86e5ac92014-03-16 19:27:39 +0000389}
cristy3ed852e2009-09-05 21:47:34 +0000390
391/*
392%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393% %
394% %
395% %
cristyf34a1452009-10-24 22:29:27 +0000396+ 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 +0000397% %
398% %
399% %
400%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401%
cristyf34a1452009-10-24 22:29:27 +0000402% CoderComponentGenesis() instantiates the coder component.
cristy3ed852e2009-09-05 21:47:34 +0000403%
cristyf34a1452009-10-24 22:29:27 +0000404% The format of the CoderComponentGenesis method is:
cristy3ed852e2009-09-05 21:47:34 +0000405%
cristyf34a1452009-10-24 22:29:27 +0000406% MagickBooleanType CoderComponentGenesis(void)
cristy3ed852e2009-09-05 21:47:34 +0000407%
408*/
cristy5ff4eaf2011-09-03 01:38:02 +0000409MagickPrivate MagickBooleanType CoderComponentGenesis(void)
cristyf34a1452009-10-24 22:29:27 +0000410{
cristy7c977062014-04-04 14:05:53 +0000411 if (coder_semaphore == (SemaphoreInfo *) NULL)
412 coder_semaphore=AcquireSemaphoreInfo();
cristyf34a1452009-10-24 22:29:27 +0000413 return(MagickTrue);
414}
415
416/*
417%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418% %
419% %
420% %
421+ C o d e r C o m p o n e n t T e r m i n u s %
422% %
423% %
424% %
425%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426%
427% CoderComponentTerminus() destroys the coder component.
428%
429% The format of the CoderComponentTerminus method is:
430%
431% CoderComponentTerminus(void)
432%
433*/
cristy5ff4eaf2011-09-03 01:38:02 +0000434MagickPrivate void CoderComponentTerminus(void)
cristy3ed852e2009-09-05 21:47:34 +0000435{
cristy18b17442009-10-25 18:36:48 +0000436 if (coder_semaphore == (SemaphoreInfo *) NULL)
cristy04b11db2014-02-16 15:10:39 +0000437 ActivateSemaphoreInfo(&coder_semaphore);
cristyf84a1932010-01-03 18:00:18 +0000438 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000439 if (coder_cache != (SplayTreeInfo *) NULL)
440 coder_cache=DestroySplayTree(coder_cache);
cristyf84a1932010-01-03 18:00:18 +0000441 UnlockSemaphoreInfo(coder_semaphore);
cristy3d162a92014-02-16 14:05:06 +0000442 RelinquishSemaphoreInfo(&coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000443}
444
445/*
446%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447% %
448% %
449% %
450+ G e t C o d e r I n f o %
451% %
452% %
453% %
454%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
455%
456% GetCoderInfo searches the coder list for the specified name and if found
457% returns attributes for that coder.
458%
459% The format of the GetCoderInfo method is:
460%
461% const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception)
462%
463% A description of each parameter follows:
464%
465% o name: the coder name.
466%
467% o exception: return any errors or warnings in this structure.
468%
469*/
470MagickExport const CoderInfo *GetCoderInfo(const char *name,
471 ExceptionInfo *exception)
472{
473 assert(exception != (ExceptionInfo *) NULL);
cristy904e5912014-03-15 19:53:14 +0000474 if (IsCoderTreeInstantiated(exception) == MagickFalse)
475 return((const CoderInfo *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000476 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
Cristy1d8b1f12017-09-16 10:13:23 -0400477 return((const CoderInfo *) GetRootValueFromSplayTree(coder_cache));
478 return((const CoderInfo *) GetValueFromSplayTree(coder_cache,name));
cristy3ed852e2009-09-05 21:47:34 +0000479}
480
481/*
482%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483% %
484% %
485% %
486% G e t C o d e r I n f o L i s t %
487% %
488% %
489% %
490%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491%
492% GetCoderInfoList() returns any coder_map that match the specified pattern.
493% The format of the GetCoderInfoList function is:
494%
495% const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000496% size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000497%
498% A description of each parameter follows:
499%
500% o pattern: Specifies a pointer to a text string containing a pattern.
501%
502% o number_coders: This integer returns the number of coders in the list.
503%
504% o exception: return any errors or warnings in this structure.
505%
506*/
507
508static int CoderInfoCompare(const void *x,const void *y)
509{
510 const CoderInfo
511 **p,
512 **q;
513
514 p=(const CoderInfo **) x,
515 q=(const CoderInfo **) y;
516 if (LocaleCompare((*p)->path,(*q)->path) == 0)
517 return(LocaleCompare((*p)->name,(*q)->name));
518 return(LocaleCompare((*p)->path,(*q)->path));
519}
520
521MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000522 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000523{
524 const CoderInfo
525 **coder_map;
526
527 register const CoderInfo
528 *p;
529
cristybb503372010-05-27 20:51:26 +0000530 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000531 i;
532
533 /*
534 Allocate coder list.
535 */
536 assert(pattern != (char *) NULL);
537 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000538 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000539 *number_coders=0;
540 p=GetCoderInfo("*",exception);
541 if (p == (const CoderInfo *) NULL)
542 return((const CoderInfo **) NULL);
543 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000544 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000545 if (coder_map == (const CoderInfo **) NULL)
546 return((const CoderInfo **) NULL);
547 /*
548 Generate coder list.
549 */
cristyf84a1932010-01-03 18:00:18 +0000550 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000551 ResetSplayTreeIterator(coder_cache);
552 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000553 for (i=0; p != (const CoderInfo *) NULL; )
554 {
555 if ((p->stealth == MagickFalse) &&
556 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
557 coder_map[i++]=p;
cristy86e5ac92014-03-16 19:27:39 +0000558 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000559 }
cristyf84a1932010-01-03 18:00:18 +0000560 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000561 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
562 coder_map[i]=(CoderInfo *) NULL;
cristybb503372010-05-27 20:51:26 +0000563 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000564 return(coder_map);
565}
566
567/*
568%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569% %
570% %
571% %
572% G e t C o d e r L i s t %
573% %
574% %
575% %
576%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
577%
578% GetCoderList() returns any coder_map that match the specified pattern.
579%
580% The format of the GetCoderList function is:
581%
cristybb503372010-05-27 20:51:26 +0000582% char **GetCoderList(const char *pattern,size_t *number_coders,
cristy3ed852e2009-09-05 21:47:34 +0000583% ExceptionInfo *exception)
584%
585% A description of each parameter follows:
586%
587% o pattern: Specifies a pointer to a text string containing a pattern.
588%
589% o number_coders: This integer returns the number of coders in the list.
590%
591% o exception: return any errors or warnings in this structure.
592%
593*/
594
595static int CoderCompare(const void *x,const void *y)
596{
597 register const char
598 **p,
599 **q;
600
601 p=(const char **) x;
602 q=(const char **) y;
603 return(LocaleCompare(*p,*q));
604}
605
606MagickExport char **GetCoderList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000607 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000608{
609 char
610 **coder_map;
611
612 register const CoderInfo
613 *p;
614
cristybb503372010-05-27 20:51:26 +0000615 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000616 i;
617
618 /*
619 Allocate coder list.
620 */
621 assert(pattern != (char *) NULL);
622 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000623 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000624 *number_coders=0;
625 p=GetCoderInfo("*",exception);
626 if (p == (const CoderInfo *) NULL)
627 return((char **) NULL);
628 coder_map=(char **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000629 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000630 if (coder_map == (char **) NULL)
631 return((char **) NULL);
632 /*
633 Generate coder list.
634 */
cristyf84a1932010-01-03 18:00:18 +0000635 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000636 ResetSplayTreeIterator(coder_cache);
637 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000638 for (i=0; p != (const CoderInfo *) NULL; )
639 {
640 if ((p->stealth == MagickFalse) &&
641 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
642 coder_map[i++]=ConstantString(p->name);
cristy86e5ac92014-03-16 19:27:39 +0000643 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000644 }
cristyf84a1932010-01-03 18:00:18 +0000645 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000646 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
647 coder_map[i]=(char *) NULL;
cristybb503372010-05-27 20:51:26 +0000648 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000649 return(coder_map);
650}
651
652/*
653%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
654% %
655% %
656% %
cristy904e5912014-03-15 19:53:14 +0000657+ 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 +0000658% %
659% %
660% %
661%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
662%
cristycd2cd182014-03-18 12:10:55 +0000663% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If
664% not, it instantiates the tree and returns it.
cristy3ed852e2009-09-05 21:47:34 +0000665%
cristy904e5912014-03-15 19:53:14 +0000666% The format of the IsCoderInstantiated method is:
cristy3ed852e2009-09-05 21:47:34 +0000667%
cristy904e5912014-03-15 19:53:14 +0000668% MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000669%
670% A description of each parameter follows.
671%
672% o exception: return any errors or warnings in this structure.
673%
674*/
cristy904e5912014-03-15 19:53:14 +0000675static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000676{
cristy86e5ac92014-03-16 19:27:39 +0000677 if (coder_cache == (SplayTreeInfo *) NULL)
678 {
679 if (coder_semaphore == (SemaphoreInfo *) NULL)
680 ActivateSemaphoreInfo(&coder_semaphore);
681 LockSemaphoreInfo(coder_semaphore);
682 if (coder_cache == (SplayTreeInfo *) NULL)
cristycd2cd182014-03-18 12:10:55 +0000683 coder_cache=AcquireCoderCache(MagickCoderFilename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000684 UnlockSemaphoreInfo(coder_semaphore);
685 }
686 return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000687}
688
689/*
690%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
691% %
692% %
693% %
694% L i s t C o d e r I n f o %
695% %
696% %
697% %
698%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
699%
700% ListCoderInfo() lists the coder info to a file.
701%
702% The format of the ListCoderInfo coder is:
703%
704% MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
705%
706% A description of each parameter follows.
707%
708% o file: An pointer to a FILE.
709%
710% o exception: return any errors or warnings in this structure.
711%
712*/
713MagickExport MagickBooleanType ListCoderInfo(FILE *file,
714 ExceptionInfo *exception)
715{
716 const char
717 *path;
718
719 const CoderInfo
720 **coder_info;
721
cristybb503372010-05-27 20:51:26 +0000722 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000723 i;
724
cristybb503372010-05-27 20:51:26 +0000725 size_t
cristy3ed852e2009-09-05 21:47:34 +0000726 number_coders;
727
cristy9d314ff2011-03-09 01:30:28 +0000728 ssize_t
729 j;
730
cristy3ed852e2009-09-05 21:47:34 +0000731 if (file == (const FILE *) NULL)
732 file=stdout;
733 coder_info=GetCoderInfoList("*",&number_coders,exception);
734 if (coder_info == (const CoderInfo **) NULL)
735 return(MagickFalse);
736 path=(const char *) NULL;
cristybb503372010-05-27 20:51:26 +0000737 for (i=0; i < (ssize_t) number_coders; i++)
cristy3ed852e2009-09-05 21:47:34 +0000738 {
739 if (coder_info[i]->stealth != MagickFalse)
740 continue;
741 if ((path == (const char *) NULL) ||
742 (LocaleCompare(path,coder_info[i]->path) != 0))
743 {
744 if (coder_info[i]->path != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000745 (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path);
746 (void) FormatLocaleFile(file,"Magick Coder\n");
cristy1e604812011-05-19 18:07:50 +0000747 (void) FormatLocaleFile(file,
748 "-------------------------------------------------"
cristy3ed852e2009-09-05 21:47:34 +0000749 "------------------------------\n");
750 }
751 path=coder_info[i]->path;
cristyb51dff52011-05-19 16:55:47 +0000752 (void) FormatLocaleFile(file,"%s",coder_info[i]->magick);
cristybb503372010-05-27 20:51:26 +0000753 for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
cristyb51dff52011-05-19 16:55:47 +0000754 (void) FormatLocaleFile(file," ");
cristy3ed852e2009-09-05 21:47:34 +0000755 if (coder_info[i]->name != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000756 (void) FormatLocaleFile(file,"%s",coder_info[i]->name);
757 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000758 }
759 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
760 (void) fflush(file);
761 return(MagickTrue);
762}
763
764/*
765%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
766% %
767% %
768% %
dirkfc0f1242016-03-26 00:36:39 +0100769+ L o a d C o d e r C a c h e %
cristy3ed852e2009-09-05 21:47:34 +0000770% %
771% %
772% %
773%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774%
cristy86e5ac92014-03-16 19:27:39 +0000775% LoadCoderCache() loads the coder configurations which provides a
cristy3ed852e2009-09-05 21:47:34 +0000776% mapping between coder attributes and a coder name.
777%
cristy86e5ac92014-03-16 19:27:39 +0000778% The format of the LoadCoderCache coder is:
cristy3ed852e2009-09-05 21:47:34 +0000779%
dirkb18d8642016-07-17 19:32:43 +0200780% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
781% const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000782%
783% A description of each parameter follows:
784%
785% o xml: The coder list in XML format.
786%
787% o filename: The coder list filename.
788%
789% o depth: depth of <include /> statements.
790%
791% o exception: return any errors or warnings in this structure.
792%
793*/
dirkb18d8642016-07-17 19:32:43 +0200794static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
795 const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000796{
797 char
cristy151b66d2015-04-15 10:50:31 +0000798 keyword[MagickPathExtent],
cristy3ed852e2009-09-05 21:47:34 +0000799 *token;
800
801 const char
802 *q;
803
804 CoderInfo
805 *coder_info;
806
cristy759ba912014-06-26 11:59:43 +0000807 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000808 status;
809
dirkfc0f1242016-03-26 00:36:39 +0100810 size_t
811 extent;
812
cristy3ed852e2009-09-05 21:47:34 +0000813 /*
814 Load the coder map file.
815 */
816 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
817 "Loading coder configuration file \"%s\" ...",filename);
818 if (xml == (const char *) NULL)
819 return(MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000820 status=MagickTrue;
821 coder_info=(CoderInfo *) NULL;
822 token=AcquireString(xml);
dirkfc0f1242016-03-26 00:36:39 +0100823 extent=strlen(token)+MagickPathExtent;
cristy3ed852e2009-09-05 21:47:34 +0000824 for (q=(char *) xml; *q != '\0'; )
825 {
826 /*
827 Interpret XML.
828 */
Cristy8bedb4e2016-03-25 19:54:25 -0400829 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000830 if (*token == '\0')
831 break;
cristy151b66d2015-04-15 10:50:31 +0000832 (void) CopyMagickString(keyword,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000833 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
834 {
835 /*
836 Doctype element.
837 */
838 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400839 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000840 continue;
841 }
842 if (LocaleNCompare(keyword,"<!--",4) == 0)
843 {
844 /*
845 Comment element.
846 */
847 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400848 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000849 continue;
850 }
851 if (LocaleCompare(keyword,"<include") == 0)
852 {
853 /*
854 Include element.
855 */
856 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
857 {
cristy151b66d2015-04-15 10:50:31 +0000858 (void) CopyMagickString(keyword,token,MagickPathExtent);
Cristy8bedb4e2016-03-25 19:54:25 -0400859 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000860 if (*token != '=')
861 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400862 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000863 if (LocaleCompare(keyword,"file") == 0)
864 {
Cristy8a4029f2018-02-05 07:35:07 -0500865 if (depth > MagickMaxRecursionDepth)
cristy3ed852e2009-09-05 21:47:34 +0000866 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000867 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
cristy3ed852e2009-09-05 21:47:34 +0000868 else
869 {
870 char
cristy151b66d2015-04-15 10:50:31 +0000871 path[MagickPathExtent],
dirkb81f0ab2015-10-20 23:01:53 +0200872 *file_xml;
cristy3ed852e2009-09-05 21:47:34 +0000873
874 GetPathComponent(filename,HeadPath,path);
875 if (*path != '\0')
876 (void) ConcatenateMagickString(path,DirectorySeparator,
cristy151b66d2015-04-15 10:50:31 +0000877 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000878 if (*token == *DirectorySeparator)
cristy151b66d2015-04-15 10:50:31 +0000879 (void) CopyMagickString(path,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000880 else
cristy151b66d2015-04-15 10:50:31 +0000881 (void) ConcatenateMagickString(path,token,MagickPathExtent);
dirkb81f0ab2015-10-20 23:01:53 +0200882 file_xml=FileToXML(path,~0UL);
883 if (file_xml != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000884 {
dirkb18d8642016-07-17 19:32:43 +0200885 status&=LoadCoderCache(cache,file_xml,path,depth+1,
cristy86e5ac92014-03-16 19:27:39 +0000886 exception);
dirkb81f0ab2015-10-20 23:01:53 +0200887 file_xml=DestroyString(file_xml);
cristy3ed852e2009-09-05 21:47:34 +0000888 }
889 }
890 }
891 }
892 continue;
893 }
894 if (LocaleCompare(keyword,"<coder") == 0)
895 {
896 /*
897 Coder element.
898 */
Dirk Lemstra06344a02017-10-15 10:10:01 +0200899 coder_info=(CoderInfo *) AcquireCriticalMemory(sizeof(*coder_info));
cristy3ed852e2009-09-05 21:47:34 +0000900 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
901 coder_info->path=ConstantString(filename);
cristye3e77a12009-10-16 00:47:21 +0000902 coder_info->exempt=MagickFalse;
cristye1c94d92015-06-28 12:16:33 +0000903 coder_info->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000904 continue;
905 }
906 if (coder_info == (CoderInfo *) NULL)
907 continue;
Cristyfed111e2017-01-09 07:22:16 -0500908 if ((LocaleCompare(keyword,"/>") == 0) ||
909 (LocaleCompare(keyword,"</policy>") == 0))
cristy3ed852e2009-09-05 21:47:34 +0000910 {
dirkb18d8642016-07-17 19:32:43 +0200911 status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
912 coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000913 if (status == MagickFalse)
914 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000915 ResourceLimitError,"MemoryAllocationFailed","`%s'",
cristy3ed852e2009-09-05 21:47:34 +0000916 coder_info->magick);
917 coder_info=(CoderInfo *) NULL;
cristyd45122f2014-01-14 23:46:16 +0000918 continue;
cristy3ed852e2009-09-05 21:47:34 +0000919 }
Cristy8bedb4e2016-03-25 19:54:25 -0400920 GetNextToken(q,(const char **) NULL,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000921 if (*token != '=')
922 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400923 GetNextToken(q,&q,extent,token);
924 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000925 switch (*keyword)
926 {
927 case 'M':
928 case 'm':
929 {
930 if (LocaleCompare((char *) keyword,"magick") == 0)
931 {
932 coder_info->magick=ConstantString(token);
933 break;
934 }
935 break;
936 }
937 case 'N':
938 case 'n':
939 {
940 if (LocaleCompare((char *) keyword,"name") == 0)
941 {
942 coder_info->name=ConstantString(token);
943 break;
944 }
945 break;
946 }
947 case 'S':
948 case 's':
949 {
950 if (LocaleCompare((char *) keyword,"stealth") == 0)
951 {
anthony6f201312012-03-30 04:08:15 +0000952 coder_info->stealth=IsStringTrue(token);
cristy3ed852e2009-09-05 21:47:34 +0000953 break;
954 }
955 break;
956 }
957 default:
958 break;
959 }
960 }
961 token=(char *) RelinquishMagickMemory(token);
cristy759ba912014-06-26 11:59:43 +0000962 return(status != 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000963}