blob: 0c647d5e7ea0891da3729040f0c8ee7be6fdef6b [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"
54#include "MagickCore/option.h"
55#include "MagickCore/semaphore.h"
56#include "MagickCore/string_.h"
57#include "MagickCore/splay-tree.h"
58#include "MagickCore/token.h"
59#include "MagickCore/utility.h"
cristyd1dd6e42011-09-04 01:46:08 +000060#include "MagickCore/utility-private.h"
cristy4c08aed2011-07-01 19:47:50 +000061#include "MagickCore/xml-tree.h"
cristy3291f512014-03-16 22:16:22 +000062#include "MagickCore/xml-tree-private.h"
cristy3ed852e2009-09-05 21:47:34 +000063
64/*
65 Define declarations.
66*/
67#define MagickCoderFilename "coder.xml"
68
69/*
cristy54a531d2009-10-21 17:58:01 +000070 Typedef declarations.
cristy3ed852e2009-09-05 21:47:34 +000071*/
cristye3e77a12009-10-16 00:47:21 +000072typedef struct _CoderMapInfo
73{
74 const char
75 *magick,
76 *name;
77} CoderMapInfo;
cristy54a531d2009-10-21 17:58:01 +000078
79/*
80 Static declarations.
81*/
cristye3e77a12009-10-16 00:47:21 +000082static const CoderMapInfo
83 CoderMap[] =
84 {
85 { "3FR", "DNG" },
Cristyb066eae2017-01-20 09:15:54 -050086 { "3GP", "MPEG" },
87 { "3G2", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +000088 { "8BIMTEXT", "META" },
89 { "8BIMWTEXT", "META" },
90 { "AFM", "TTF" },
91 { "A", "RAW" },
92 { "AI", "PDF" },
93 { "APP1JPEG", "META" },
94 { "APP1", "META" },
95 { "ARW", "DNG" },
cristy0fc02592010-05-24 14:12:38 +000096 { "AVI", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +000097 { "BIE", "JBIG" },
98 { "BMP2", "BMP" },
99 { "BMP3", "BMP" },
100 { "B", "RAW" },
101 { "BRF", "BRAILLE" },
cristy90dbac72010-08-22 15:08:40 +0000102 { "BGRA", "BGR" },
dirk2a2d3d62015-07-27 11:09:58 +0000103 { "BGRO", "BGR" },
cristye3e77a12009-10-16 00:47:21 +0000104 { "CMYKA", "CMYK" },
105 { "C", "RAW" },
106 { "CAL", "CALS" },
cristyc05417c2010-09-21 16:30:32 +0000107 { "CANVAS", "XC" },
dirk2a2d3d62015-07-27 11:09:58 +0000108 { "CMYKA", "CMYK" },
cristye3e77a12009-10-16 00:47:21 +0000109 { "CR2", "DNG" },
110 { "CRW", "DNG" },
111 { "CUR", "ICON" },
Cristy6ffac4f2015-08-23 10:55:57 -0400112 { "DATA", "INLINE" },
cristye3e77a12009-10-16 00:47:21 +0000113 { "DCR", "DNG" },
114 { "DCX", "PCX" },
115 { "DFONT", "TTF" },
dirk2a2d3d62015-07-27 11:09:58 +0000116 { "DXT1", "DDS" },
117 { "DXT5", "DDS" },
cristye3e77a12009-10-16 00:47:21 +0000118 { "EPDF", "PDF" },
119 { "EPI", "PS" },
120 { "EPS2", "PS2" },
121 { "EPS3", "PS3" },
122 { "EPSF", "PS" },
123 { "EPSI", "PS" },
124 { "EPS", "PS" },
125 { "EPT2", "EPT" },
126 { "EPT3", "EPT" },
127 { "ERF", "DNG" },
128 { "EXIF", "META" },
129 { "FILE", "URL" },
130 { "FRACTAL", "PLASMA" },
131 { "FTP", "URL" },
132 { "FTS", "FITS" },
133 { "G3", "FAX" },
dirk52456ef2016-06-17 15:29:46 +0200134 { "G4", "FAX" },
cristye3e77a12009-10-16 00:47:21 +0000135 { "GIF87", "GIF" },
136 { "G", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000137 { "GRANITE", "MAGICK" },
138 { "GROUP4", "TIFF" },
cristy7f47ac62013-02-10 14:16:17 +0000139 { "GV", "DOT" },
dirk2a2d3d62015-07-27 11:09:58 +0000140 { "HTM", "HTML" },
141 { "ICB", "TGA" },
142 { "ICO", "ICON" },
cristya5338bb2014-11-05 18:25:16 +0000143 { "IIQ", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000144 { "K25", "DNG" },
145 { "KDC", "DNG" },
146 { "H", "MAGICK" },
147 { "HTM", "HTML" },
148 { "HTTP", "URL" },
dirk853b77b2013-09-21 19:04:42 +0000149 { "HTTPS", "URL" },
cristye3e77a12009-10-16 00:47:21 +0000150 { "ICB", "TGA" },
151 { "ICC", "META" },
152 { "ICM", "META" },
153 { "ICO", "ICON" },
154 { "IMPLICIT", "***" },
155 { "IPTC", "META" },
156 { "IPTCTEXT", "META" },
157 { "IPTCWTEXT", "META" },
158 { "ISOBRL", "BRAILLE" },
Samuel Thibault531aa152015-11-01 23:36:24 +0100159 { "ISOBRL6", "BRAILLE" },
cristye3e77a12009-10-16 00:47:21 +0000160 { "JBG", "JBIG" },
161 { "JNG", "PNG" },
162 { "JPC", "JP2" },
cristy2267fa42014-09-12 10:27:47 +0000163 { "JPT", "JP2" },
164 { "JPM", "JP2" },
cristy02f1fda2009-12-10 15:23:56 +0000165 { "J2C", "JP2" },
cristy4faac682012-05-10 12:09:45 +0000166 { "J2K", "JP2" },
dirk2a2d3d62015-07-27 11:09:58 +0000167 { "JNG", "PNG" },
cristyb338b712014-11-27 14:06:34 +0000168 { "JPE", "JPEG" },
cristye3e77a12009-10-16 00:47:21 +0000169 { "JPG", "JPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000170 { "JPM", "JP2" },
cristya663a4f2015-01-23 12:11:57 +0000171 { "JPS", "JPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000172 { "JPT", "JP2" },
cristye3e77a12009-10-16 00:47:21 +0000173 { "JPX", "JP2" },
174 { "K", "RAW" },
dirk2a2d3d62015-07-27 11:09:58 +0000175 { "K25", "DNG" },
176 { "KDC", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000177 { "LOGO", "MAGICK" },
dirk2a2d3d62015-07-27 11:09:58 +0000178 { "M", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000179 { "M2V", "MPEG" },
180 { "M4V", "MPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000181 { "MEF", "DNG" },
cristya3d81422015-04-03 13:00:33 +0000182 { "MKV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000183 { "MNG", "PNG" },
cristy1dbd5a32010-11-28 22:23:27 +0000184 { "MOV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000185 { "MP4", "MPEG" },
186 { "MPG", "MPEG" },
187 { "MPRI", "MPR" },
cristy1be98ec2012-01-30 16:51:12 +0000188 { "MEF", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000189 { "MRW", "DNG" },
190 { "MSVG", "SVG" },
191 { "NEF", "DNG" },
192 { "NETSCAPE", "MAGICK" },
cristycb8f0ae2012-03-02 12:26:21 +0000193 { "NRW", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000194 { "O", "RAW" },
195 { "ORF", "DNG" },
196 { "OTF", "TTF" },
197 { "P7", "PNM" },
198 { "PAL", "UYVY" },
199 { "PAM", "PNM" },
200 { "PBM", "PNM" },
201 { "PCDS", "PCD" },
dirk2a2d3d62015-07-27 11:09:58 +0000202 { "PCT", "PICT" },
cristye3e77a12009-10-16 00:47:21 +0000203 { "PDFA", "PDF" },
204 { "PEF", "DNG" },
205 { "PEF", "DNG" },
206 { "PFA", "TTF" },
207 { "PFB", "TTF" },
208 { "PFM", "PNM" },
209 { "PGM", "PNM" },
210 { "PGX", "JP2" },
211 { "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);
dirkb18d8642016-07-17 19:32:43 +0200337 if (cache == (SplayTreeInfo *) NULL)
cristy86e5ac92014-03-16 19:27:39 +0000338 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
339 status=MagickTrue;
dirkb18d8642016-07-17 19:32:43 +0200340#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
cristy86e5ac92014-03-16 19:27:39 +0000341 {
dirkb18d8642016-07-17 19:32:43 +0200342 const StringInfo
343 *option;
344
345 LinkedListInfo
346 *options;
347
348 options=GetConfigureOptions(filename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000349 option=(const StringInfo *) GetNextValueInLinkedList(options);
dirkb18d8642016-07-17 19:32:43 +0200350 while (option != (const StringInfo *) NULL)
351 {
352 status&=LoadCoderCache(cache,(const char *) GetStringInfoDatum(option),
353 GetStringInfoPath(option),0,exception);
354 option=(const StringInfo *) GetNextValueInLinkedList(options);
355 }
356 options=DestroyConfigureOptions(options);
cristy86e5ac92014-03-16 19:27:39 +0000357 }
dirkb18d8642016-07-17 19:32:43 +0200358#endif
cristy86e5ac92014-03-16 19:27:39 +0000359 /*
360 Load built-in coder map.
361 */
362 for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
363 {
364 CoderInfo
365 *coder_info;
366
367 register const CoderMapInfo
368 *p;
369
370 p=CoderMap+i;
371 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
372 if (coder_info == (CoderInfo *) NULL)
373 {
374 (void) ThrowMagickException(exception,GetMagickModule(),
375 ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
376 continue;
377 }
378 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
379 coder_info->path=(char *) "[built-in]";
380 coder_info->magick=(char *) p->magick;
381 coder_info->name=(char *) p->name;
382 coder_info->exempt=MagickTrue;
cristye1c94d92015-06-28 12:16:33 +0000383 coder_info->signature=MagickCoreSignature;
dirkb18d8642016-07-17 19:32:43 +0200384 status&=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
cristy86e5ac92014-03-16 19:27:39 +0000385 coder_info);
386 if (status == MagickFalse)
387 (void) ThrowMagickException(exception,GetMagickModule(),
388 ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
389 }
dirkb18d8642016-07-17 19:32:43 +0200390 return(cache);
cristy86e5ac92014-03-16 19:27:39 +0000391}
cristy3ed852e2009-09-05 21:47:34 +0000392
393/*
394%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395% %
396% %
397% %
cristyf34a1452009-10-24 22:29:27 +0000398+ 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 +0000399% %
400% %
401% %
402%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403%
cristyf34a1452009-10-24 22:29:27 +0000404% CoderComponentGenesis() instantiates the coder component.
cristy3ed852e2009-09-05 21:47:34 +0000405%
cristyf34a1452009-10-24 22:29:27 +0000406% The format of the CoderComponentGenesis method is:
cristy3ed852e2009-09-05 21:47:34 +0000407%
cristyf34a1452009-10-24 22:29:27 +0000408% MagickBooleanType CoderComponentGenesis(void)
cristy3ed852e2009-09-05 21:47:34 +0000409%
410*/
cristy5ff4eaf2011-09-03 01:38:02 +0000411MagickPrivate MagickBooleanType CoderComponentGenesis(void)
cristyf34a1452009-10-24 22:29:27 +0000412{
cristy7c977062014-04-04 14:05:53 +0000413 if (coder_semaphore == (SemaphoreInfo *) NULL)
414 coder_semaphore=AcquireSemaphoreInfo();
cristyf34a1452009-10-24 22:29:27 +0000415 return(MagickTrue);
416}
417
418/*
419%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420% %
421% %
422% %
423+ C o d e r C o m p o n e n t T e r m i n u s %
424% %
425% %
426% %
427%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
428%
429% CoderComponentTerminus() destroys the coder component.
430%
431% The format of the CoderComponentTerminus method is:
432%
433% CoderComponentTerminus(void)
434%
435*/
cristy5ff4eaf2011-09-03 01:38:02 +0000436MagickPrivate void CoderComponentTerminus(void)
cristy3ed852e2009-09-05 21:47:34 +0000437{
cristy18b17442009-10-25 18:36:48 +0000438 if (coder_semaphore == (SemaphoreInfo *) NULL)
cristy04b11db2014-02-16 15:10:39 +0000439 ActivateSemaphoreInfo(&coder_semaphore);
cristyf84a1932010-01-03 18:00:18 +0000440 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000441 if (coder_cache != (SplayTreeInfo *) NULL)
442 coder_cache=DestroySplayTree(coder_cache);
cristyf84a1932010-01-03 18:00:18 +0000443 UnlockSemaphoreInfo(coder_semaphore);
cristy3d162a92014-02-16 14:05:06 +0000444 RelinquishSemaphoreInfo(&coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000445}
446
447/*
448%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
449% %
450% %
451% %
452+ G e t C o d e r I n f o %
453% %
454% %
455% %
456%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
457%
458% GetCoderInfo searches the coder list for the specified name and if found
459% returns attributes for that coder.
460%
461% The format of the GetCoderInfo method is:
462%
463% const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception)
464%
465% A description of each parameter follows:
466%
467% o name: the coder name.
468%
469% o exception: return any errors or warnings in this structure.
470%
471*/
472MagickExport const CoderInfo *GetCoderInfo(const char *name,
473 ExceptionInfo *exception)
474{
475 assert(exception != (ExceptionInfo *) NULL);
cristy904e5912014-03-15 19:53:14 +0000476 if (IsCoderTreeInstantiated(exception) == MagickFalse)
477 return((const CoderInfo *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000478 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
Cristy1d8b1f12017-09-16 10:13:23 -0400479 return((const CoderInfo *) GetRootValueFromSplayTree(coder_cache));
480 return((const CoderInfo *) GetValueFromSplayTree(coder_cache,name));
cristy3ed852e2009-09-05 21:47:34 +0000481}
482
483/*
484%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
485% %
486% %
487% %
488% G e t C o d e r I n f o L i s t %
489% %
490% %
491% %
492%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493%
494% GetCoderInfoList() returns any coder_map that match the specified pattern.
495% The format of the GetCoderInfoList function is:
496%
497% const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000498% size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000499%
500% A description of each parameter follows:
501%
502% o pattern: Specifies a pointer to a text string containing a pattern.
503%
504% o number_coders: This integer returns the number of coders in the list.
505%
506% o exception: return any errors or warnings in this structure.
507%
508*/
509
510static int CoderInfoCompare(const void *x,const void *y)
511{
512 const CoderInfo
513 **p,
514 **q;
515
516 p=(const CoderInfo **) x,
517 q=(const CoderInfo **) y;
518 if (LocaleCompare((*p)->path,(*q)->path) == 0)
519 return(LocaleCompare((*p)->name,(*q)->name));
520 return(LocaleCompare((*p)->path,(*q)->path));
521}
522
523MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000524 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000525{
526 const CoderInfo
527 **coder_map;
528
529 register const CoderInfo
530 *p;
531
cristybb503372010-05-27 20:51:26 +0000532 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000533 i;
534
535 /*
536 Allocate coder list.
537 */
538 assert(pattern != (char *) NULL);
539 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000540 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000541 *number_coders=0;
542 p=GetCoderInfo("*",exception);
543 if (p == (const CoderInfo *) NULL)
544 return((const CoderInfo **) NULL);
545 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000546 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000547 if (coder_map == (const CoderInfo **) NULL)
548 return((const CoderInfo **) NULL);
549 /*
550 Generate coder list.
551 */
cristyf84a1932010-01-03 18:00:18 +0000552 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000553 ResetSplayTreeIterator(coder_cache);
554 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000555 for (i=0; p != (const CoderInfo *) NULL; )
556 {
557 if ((p->stealth == MagickFalse) &&
558 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
559 coder_map[i++]=p;
cristy86e5ac92014-03-16 19:27:39 +0000560 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000561 }
cristyf84a1932010-01-03 18:00:18 +0000562 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000563 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
564 coder_map[i]=(CoderInfo *) NULL;
cristybb503372010-05-27 20:51:26 +0000565 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000566 return(coder_map);
567}
568
569/*
570%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571% %
572% %
573% %
574% G e t C o d e r L i s t %
575% %
576% %
577% %
578%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
579%
580% GetCoderList() returns any coder_map that match the specified pattern.
581%
582% The format of the GetCoderList function is:
583%
cristybb503372010-05-27 20:51:26 +0000584% char **GetCoderList(const char *pattern,size_t *number_coders,
cristy3ed852e2009-09-05 21:47:34 +0000585% ExceptionInfo *exception)
586%
587% A description of each parameter follows:
588%
589% o pattern: Specifies a pointer to a text string containing a pattern.
590%
591% o number_coders: This integer returns the number of coders in the list.
592%
593% o exception: return any errors or warnings in this structure.
594%
595*/
596
597static int CoderCompare(const void *x,const void *y)
598{
599 register const char
600 **p,
601 **q;
602
603 p=(const char **) x;
604 q=(const char **) y;
605 return(LocaleCompare(*p,*q));
606}
607
608MagickExport char **GetCoderList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000609 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000610{
611 char
612 **coder_map;
613
614 register const CoderInfo
615 *p;
616
cristybb503372010-05-27 20:51:26 +0000617 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000618 i;
619
620 /*
621 Allocate coder list.
622 */
623 assert(pattern != (char *) NULL);
624 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000625 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000626 *number_coders=0;
627 p=GetCoderInfo("*",exception);
628 if (p == (const CoderInfo *) NULL)
629 return((char **) NULL);
630 coder_map=(char **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000631 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000632 if (coder_map == (char **) NULL)
633 return((char **) NULL);
634 /*
635 Generate coder list.
636 */
cristyf84a1932010-01-03 18:00:18 +0000637 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000638 ResetSplayTreeIterator(coder_cache);
639 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000640 for (i=0; p != (const CoderInfo *) NULL; )
641 {
642 if ((p->stealth == MagickFalse) &&
643 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
644 coder_map[i++]=ConstantString(p->name);
cristy86e5ac92014-03-16 19:27:39 +0000645 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000646 }
cristyf84a1932010-01-03 18:00:18 +0000647 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000648 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
649 coder_map[i]=(char *) NULL;
cristybb503372010-05-27 20:51:26 +0000650 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000651 return(coder_map);
652}
653
654/*
655%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656% %
657% %
658% %
cristy904e5912014-03-15 19:53:14 +0000659+ 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 +0000660% %
661% %
662% %
663%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
664%
cristycd2cd182014-03-18 12:10:55 +0000665% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If
666% not, it instantiates the tree and returns it.
cristy3ed852e2009-09-05 21:47:34 +0000667%
cristy904e5912014-03-15 19:53:14 +0000668% The format of the IsCoderInstantiated method is:
cristy3ed852e2009-09-05 21:47:34 +0000669%
cristy904e5912014-03-15 19:53:14 +0000670% MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000671%
672% A description of each parameter follows.
673%
674% o exception: return any errors or warnings in this structure.
675%
676*/
cristy904e5912014-03-15 19:53:14 +0000677static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000678{
cristy86e5ac92014-03-16 19:27:39 +0000679 if (coder_cache == (SplayTreeInfo *) NULL)
680 {
681 if (coder_semaphore == (SemaphoreInfo *) NULL)
682 ActivateSemaphoreInfo(&coder_semaphore);
683 LockSemaphoreInfo(coder_semaphore);
684 if (coder_cache == (SplayTreeInfo *) NULL)
cristycd2cd182014-03-18 12:10:55 +0000685 coder_cache=AcquireCoderCache(MagickCoderFilename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000686 UnlockSemaphoreInfo(coder_semaphore);
687 }
688 return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000689}
690
691/*
692%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693% %
694% %
695% %
696% L i s t C o d e r I n f o %
697% %
698% %
699% %
700%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701%
702% ListCoderInfo() lists the coder info to a file.
703%
704% The format of the ListCoderInfo coder is:
705%
706% MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
707%
708% A description of each parameter follows.
709%
710% o file: An pointer to a FILE.
711%
712% o exception: return any errors or warnings in this structure.
713%
714*/
715MagickExport MagickBooleanType ListCoderInfo(FILE *file,
716 ExceptionInfo *exception)
717{
718 const char
719 *path;
720
721 const CoderInfo
722 **coder_info;
723
cristybb503372010-05-27 20:51:26 +0000724 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000725 i;
726
cristybb503372010-05-27 20:51:26 +0000727 size_t
cristy3ed852e2009-09-05 21:47:34 +0000728 number_coders;
729
cristy9d314ff2011-03-09 01:30:28 +0000730 ssize_t
731 j;
732
cristy3ed852e2009-09-05 21:47:34 +0000733 if (file == (const FILE *) NULL)
734 file=stdout;
735 coder_info=GetCoderInfoList("*",&number_coders,exception);
736 if (coder_info == (const CoderInfo **) NULL)
737 return(MagickFalse);
738 path=(const char *) NULL;
cristybb503372010-05-27 20:51:26 +0000739 for (i=0; i < (ssize_t) number_coders; i++)
cristy3ed852e2009-09-05 21:47:34 +0000740 {
741 if (coder_info[i]->stealth != MagickFalse)
742 continue;
743 if ((path == (const char *) NULL) ||
744 (LocaleCompare(path,coder_info[i]->path) != 0))
745 {
746 if (coder_info[i]->path != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000747 (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path);
748 (void) FormatLocaleFile(file,"Magick Coder\n");
cristy1e604812011-05-19 18:07:50 +0000749 (void) FormatLocaleFile(file,
750 "-------------------------------------------------"
cristy3ed852e2009-09-05 21:47:34 +0000751 "------------------------------\n");
752 }
753 path=coder_info[i]->path;
cristyb51dff52011-05-19 16:55:47 +0000754 (void) FormatLocaleFile(file,"%s",coder_info[i]->magick);
cristybb503372010-05-27 20:51:26 +0000755 for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
cristyb51dff52011-05-19 16:55:47 +0000756 (void) FormatLocaleFile(file," ");
cristy3ed852e2009-09-05 21:47:34 +0000757 if (coder_info[i]->name != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000758 (void) FormatLocaleFile(file,"%s",coder_info[i]->name);
759 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000760 }
761 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
762 (void) fflush(file);
763 return(MagickTrue);
764}
765
766/*
767%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
768% %
769% %
770% %
dirkfc0f1242016-03-26 00:36:39 +0100771+ L o a d C o d e r C a c h e %
cristy3ed852e2009-09-05 21:47:34 +0000772% %
773% %
774% %
775%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
776%
cristy86e5ac92014-03-16 19:27:39 +0000777% LoadCoderCache() loads the coder configurations which provides a
cristy3ed852e2009-09-05 21:47:34 +0000778% mapping between coder attributes and a coder name.
779%
cristy86e5ac92014-03-16 19:27:39 +0000780% The format of the LoadCoderCache coder is:
cristy3ed852e2009-09-05 21:47:34 +0000781%
dirkb18d8642016-07-17 19:32:43 +0200782% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
783% const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000784%
785% A description of each parameter follows:
786%
787% o xml: The coder list in XML format.
788%
789% o filename: The coder list filename.
790%
791% o depth: depth of <include /> statements.
792%
793% o exception: return any errors or warnings in this structure.
794%
795*/
dirkb18d8642016-07-17 19:32:43 +0200796static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
797 const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000798{
799 char
cristy151b66d2015-04-15 10:50:31 +0000800 keyword[MagickPathExtent],
cristy3ed852e2009-09-05 21:47:34 +0000801 *token;
802
803 const char
804 *q;
805
806 CoderInfo
807 *coder_info;
808
cristy759ba912014-06-26 11:59:43 +0000809 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000810 status;
811
dirkfc0f1242016-03-26 00:36:39 +0100812 size_t
813 extent;
814
cristy3ed852e2009-09-05 21:47:34 +0000815 /*
816 Load the coder map file.
817 */
818 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
819 "Loading coder configuration file \"%s\" ...",filename);
820 if (xml == (const char *) NULL)
821 return(MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000822 status=MagickTrue;
823 coder_info=(CoderInfo *) NULL;
824 token=AcquireString(xml);
dirkfc0f1242016-03-26 00:36:39 +0100825 extent=strlen(token)+MagickPathExtent;
cristy3ed852e2009-09-05 21:47:34 +0000826 for (q=(char *) xml; *q != '\0'; )
827 {
828 /*
829 Interpret XML.
830 */
Cristy8bedb4e2016-03-25 19:54:25 -0400831 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000832 if (*token == '\0')
833 break;
cristy151b66d2015-04-15 10:50:31 +0000834 (void) CopyMagickString(keyword,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000835 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
836 {
837 /*
838 Doctype element.
839 */
840 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400841 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000842 continue;
843 }
844 if (LocaleNCompare(keyword,"<!--",4) == 0)
845 {
846 /*
847 Comment element.
848 */
849 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400850 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000851 continue;
852 }
853 if (LocaleCompare(keyword,"<include") == 0)
854 {
855 /*
856 Include element.
857 */
858 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
859 {
cristy151b66d2015-04-15 10:50:31 +0000860 (void) CopyMagickString(keyword,token,MagickPathExtent);
Cristy8bedb4e2016-03-25 19:54:25 -0400861 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000862 if (*token != '=')
863 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400864 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000865 if (LocaleCompare(keyword,"file") == 0)
866 {
867 if (depth > 200)
868 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000869 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
cristy3ed852e2009-09-05 21:47:34 +0000870 else
871 {
872 char
cristy151b66d2015-04-15 10:50:31 +0000873 path[MagickPathExtent],
dirkb81f0ab2015-10-20 23:01:53 +0200874 *file_xml;
cristy3ed852e2009-09-05 21:47:34 +0000875
876 GetPathComponent(filename,HeadPath,path);
877 if (*path != '\0')
878 (void) ConcatenateMagickString(path,DirectorySeparator,
cristy151b66d2015-04-15 10:50:31 +0000879 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000880 if (*token == *DirectorySeparator)
cristy151b66d2015-04-15 10:50:31 +0000881 (void) CopyMagickString(path,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000882 else
cristy151b66d2015-04-15 10:50:31 +0000883 (void) ConcatenateMagickString(path,token,MagickPathExtent);
dirkb81f0ab2015-10-20 23:01:53 +0200884 file_xml=FileToXML(path,~0UL);
885 if (file_xml != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000886 {
dirkb18d8642016-07-17 19:32:43 +0200887 status&=LoadCoderCache(cache,file_xml,path,depth+1,
cristy86e5ac92014-03-16 19:27:39 +0000888 exception);
dirkb81f0ab2015-10-20 23:01:53 +0200889 file_xml=DestroyString(file_xml);
cristy3ed852e2009-09-05 21:47:34 +0000890 }
891 }
892 }
893 }
894 continue;
895 }
896 if (LocaleCompare(keyword,"<coder") == 0)
897 {
898 /*
899 Coder element.
900 */
cristy73bd4a52010-10-05 11:24:23 +0000901 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
cristy3ed852e2009-09-05 21:47:34 +0000902 if (coder_info == (CoderInfo *) NULL)
903 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
904 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
905 coder_info->path=ConstantString(filename);
cristye3e77a12009-10-16 00:47:21 +0000906 coder_info->exempt=MagickFalse;
cristye1c94d92015-06-28 12:16:33 +0000907 coder_info->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000908 continue;
909 }
910 if (coder_info == (CoderInfo *) NULL)
911 continue;
Cristyfed111e2017-01-09 07:22:16 -0500912 if ((LocaleCompare(keyword,"/>") == 0) ||
913 (LocaleCompare(keyword,"</policy>") == 0))
cristy3ed852e2009-09-05 21:47:34 +0000914 {
dirkb18d8642016-07-17 19:32:43 +0200915 status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
916 coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000917 if (status == MagickFalse)
918 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000919 ResourceLimitError,"MemoryAllocationFailed","`%s'",
cristy3ed852e2009-09-05 21:47:34 +0000920 coder_info->magick);
921 coder_info=(CoderInfo *) NULL;
cristyd45122f2014-01-14 23:46:16 +0000922 continue;
cristy3ed852e2009-09-05 21:47:34 +0000923 }
Cristy8bedb4e2016-03-25 19:54:25 -0400924 GetNextToken(q,(const char **) NULL,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000925 if (*token != '=')
926 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400927 GetNextToken(q,&q,extent,token);
928 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000929 switch (*keyword)
930 {
931 case 'M':
932 case 'm':
933 {
934 if (LocaleCompare((char *) keyword,"magick") == 0)
935 {
936 coder_info->magick=ConstantString(token);
937 break;
938 }
939 break;
940 }
941 case 'N':
942 case 'n':
943 {
944 if (LocaleCompare((char *) keyword,"name") == 0)
945 {
946 coder_info->name=ConstantString(token);
947 break;
948 }
949 break;
950 }
951 case 'S':
952 case 's':
953 {
954 if (LocaleCompare((char *) keyword,"stealth") == 0)
955 {
anthony6f201312012-03-30 04:08:15 +0000956 coder_info->stealth=IsStringTrue(token);
cristy3ed852e2009-09-05 21:47:34 +0000957 break;
958 }
959 break;
960 }
961 default:
962 break;
963 }
964 }
965 token=(char *) RelinquishMagickMemory(token);
cristy759ba912014-06-26 11:59:43 +0000966 return(status != 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000967}