blob: 2cfcaa29b8ded8b77537d417db92afcb03ee1c68 [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% %
26% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37*/
38
39/*
40 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{
cristy49d4d222014-03-16 00:37:58 +0000475 const CoderInfo
476 *coder_info;
477
cristy3ed852e2009-09-05 21:47:34 +0000478 assert(exception != (ExceptionInfo *) NULL);
cristy904e5912014-03-15 19:53:14 +0000479 if (IsCoderTreeInstantiated(exception) == MagickFalse)
480 return((const CoderInfo *) NULL);
cristy49d4d222014-03-16 00:37:58 +0000481 LockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000482 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
483 {
cristy86e5ac92014-03-16 19:27:39 +0000484 ResetSplayTreeIterator(coder_cache);
485 coder_info=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy49d4d222014-03-16 00:37:58 +0000486 UnlockSemaphoreInfo(coder_semaphore);
487 return(coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000488 }
cristy86e5ac92014-03-16 19:27:39 +0000489 coder_info=(const CoderInfo *) GetValueFromSplayTree(coder_cache,name);
cristy49d4d222014-03-16 00:37:58 +0000490 UnlockSemaphoreInfo(coder_semaphore);
491 return(coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000492}
493
494/*
495%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
496% %
497% %
498% %
499% G e t C o d e r I n f o L i s t %
500% %
501% %
502% %
503%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504%
505% GetCoderInfoList() returns any coder_map that match the specified pattern.
506% The format of the GetCoderInfoList function is:
507%
508% const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000509% size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000510%
511% A description of each parameter follows:
512%
513% o pattern: Specifies a pointer to a text string containing a pattern.
514%
515% o number_coders: This integer returns the number of coders in the list.
516%
517% o exception: return any errors or warnings in this structure.
518%
519*/
520
521static int CoderInfoCompare(const void *x,const void *y)
522{
523 const CoderInfo
524 **p,
525 **q;
526
527 p=(const CoderInfo **) x,
528 q=(const CoderInfo **) y;
529 if (LocaleCompare((*p)->path,(*q)->path) == 0)
530 return(LocaleCompare((*p)->name,(*q)->name));
531 return(LocaleCompare((*p)->path,(*q)->path));
532}
533
534MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000535 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000536{
537 const CoderInfo
538 **coder_map;
539
540 register const CoderInfo
541 *p;
542
cristybb503372010-05-27 20:51:26 +0000543 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000544 i;
545
546 /*
547 Allocate coder list.
548 */
549 assert(pattern != (char *) NULL);
550 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000551 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000552 *number_coders=0;
553 p=GetCoderInfo("*",exception);
554 if (p == (const CoderInfo *) NULL)
555 return((const CoderInfo **) NULL);
556 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000557 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000558 if (coder_map == (const CoderInfo **) NULL)
559 return((const CoderInfo **) NULL);
560 /*
561 Generate coder list.
562 */
cristyf84a1932010-01-03 18:00:18 +0000563 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000564 ResetSplayTreeIterator(coder_cache);
565 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000566 for (i=0; p != (const CoderInfo *) NULL; )
567 {
568 if ((p->stealth == MagickFalse) &&
569 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
570 coder_map[i++]=p;
cristy86e5ac92014-03-16 19:27:39 +0000571 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000572 }
cristyf84a1932010-01-03 18:00:18 +0000573 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000574 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
575 coder_map[i]=(CoderInfo *) NULL;
cristybb503372010-05-27 20:51:26 +0000576 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000577 return(coder_map);
578}
579
580/*
581%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582% %
583% %
584% %
585% G e t C o d e r L i s t %
586% %
587% %
588% %
589%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590%
591% GetCoderList() returns any coder_map that match the specified pattern.
592%
593% The format of the GetCoderList function is:
594%
cristybb503372010-05-27 20:51:26 +0000595% char **GetCoderList(const char *pattern,size_t *number_coders,
cristy3ed852e2009-09-05 21:47:34 +0000596% ExceptionInfo *exception)
597%
598% A description of each parameter follows:
599%
600% o pattern: Specifies a pointer to a text string containing a pattern.
601%
602% o number_coders: This integer returns the number of coders in the list.
603%
604% o exception: return any errors or warnings in this structure.
605%
606*/
607
608static int CoderCompare(const void *x,const void *y)
609{
610 register const char
611 **p,
612 **q;
613
614 p=(const char **) x;
615 q=(const char **) y;
616 return(LocaleCompare(*p,*q));
617}
618
619MagickExport char **GetCoderList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000620 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000621{
622 char
623 **coder_map;
624
625 register const CoderInfo
626 *p;
627
cristybb503372010-05-27 20:51:26 +0000628 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000629 i;
630
631 /*
632 Allocate coder list.
633 */
634 assert(pattern != (char *) NULL);
635 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000636 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000637 *number_coders=0;
638 p=GetCoderInfo("*",exception);
639 if (p == (const CoderInfo *) NULL)
640 return((char **) NULL);
641 coder_map=(char **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000642 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000643 if (coder_map == (char **) NULL)
644 return((char **) NULL);
645 /*
646 Generate coder list.
647 */
cristyf84a1932010-01-03 18:00:18 +0000648 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000649 ResetSplayTreeIterator(coder_cache);
650 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000651 for (i=0; p != (const CoderInfo *) NULL; )
652 {
653 if ((p->stealth == MagickFalse) &&
654 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
655 coder_map[i++]=ConstantString(p->name);
cristy86e5ac92014-03-16 19:27:39 +0000656 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000657 }
cristyf84a1932010-01-03 18:00:18 +0000658 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000659 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
660 coder_map[i]=(char *) NULL;
cristybb503372010-05-27 20:51:26 +0000661 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000662 return(coder_map);
663}
664
665/*
666%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
667% %
668% %
669% %
cristy904e5912014-03-15 19:53:14 +0000670+ 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 +0000671% %
672% %
673% %
674%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
675%
cristycd2cd182014-03-18 12:10:55 +0000676% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If
677% not, it instantiates the tree and returns it.
cristy3ed852e2009-09-05 21:47:34 +0000678%
cristy904e5912014-03-15 19:53:14 +0000679% The format of the IsCoderInstantiated method is:
cristy3ed852e2009-09-05 21:47:34 +0000680%
cristy904e5912014-03-15 19:53:14 +0000681% MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000682%
683% A description of each parameter follows.
684%
685% o exception: return any errors or warnings in this structure.
686%
687*/
cristy904e5912014-03-15 19:53:14 +0000688static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000689{
cristy86e5ac92014-03-16 19:27:39 +0000690 if (coder_cache == (SplayTreeInfo *) NULL)
691 {
692 if (coder_semaphore == (SemaphoreInfo *) NULL)
693 ActivateSemaphoreInfo(&coder_semaphore);
694 LockSemaphoreInfo(coder_semaphore);
695 if (coder_cache == (SplayTreeInfo *) NULL)
cristycd2cd182014-03-18 12:10:55 +0000696 coder_cache=AcquireCoderCache(MagickCoderFilename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000697 UnlockSemaphoreInfo(coder_semaphore);
698 }
699 return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000700}
701
702/*
703%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704% %
705% %
706% %
707% L i s t C o d e r I n f o %
708% %
709% %
710% %
711%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
712%
713% ListCoderInfo() lists the coder info to a file.
714%
715% The format of the ListCoderInfo coder is:
716%
717% MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
718%
719% A description of each parameter follows.
720%
721% o file: An pointer to a FILE.
722%
723% o exception: return any errors or warnings in this structure.
724%
725*/
726MagickExport MagickBooleanType ListCoderInfo(FILE *file,
727 ExceptionInfo *exception)
728{
729 const char
730 *path;
731
732 const CoderInfo
733 **coder_info;
734
cristybb503372010-05-27 20:51:26 +0000735 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000736 i;
737
cristybb503372010-05-27 20:51:26 +0000738 size_t
cristy3ed852e2009-09-05 21:47:34 +0000739 number_coders;
740
cristy9d314ff2011-03-09 01:30:28 +0000741 ssize_t
742 j;
743
cristy3ed852e2009-09-05 21:47:34 +0000744 if (file == (const FILE *) NULL)
745 file=stdout;
746 coder_info=GetCoderInfoList("*",&number_coders,exception);
747 if (coder_info == (const CoderInfo **) NULL)
748 return(MagickFalse);
749 path=(const char *) NULL;
cristybb503372010-05-27 20:51:26 +0000750 for (i=0; i < (ssize_t) number_coders; i++)
cristy3ed852e2009-09-05 21:47:34 +0000751 {
752 if (coder_info[i]->stealth != MagickFalse)
753 continue;
754 if ((path == (const char *) NULL) ||
755 (LocaleCompare(path,coder_info[i]->path) != 0))
756 {
757 if (coder_info[i]->path != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000758 (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path);
759 (void) FormatLocaleFile(file,"Magick Coder\n");
cristy1e604812011-05-19 18:07:50 +0000760 (void) FormatLocaleFile(file,
761 "-------------------------------------------------"
cristy3ed852e2009-09-05 21:47:34 +0000762 "------------------------------\n");
763 }
764 path=coder_info[i]->path;
cristyb51dff52011-05-19 16:55:47 +0000765 (void) FormatLocaleFile(file,"%s",coder_info[i]->magick);
cristybb503372010-05-27 20:51:26 +0000766 for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
cristyb51dff52011-05-19 16:55:47 +0000767 (void) FormatLocaleFile(file," ");
cristy3ed852e2009-09-05 21:47:34 +0000768 if (coder_info[i]->name != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000769 (void) FormatLocaleFile(file,"%s",coder_info[i]->name);
770 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000771 }
772 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
773 (void) fflush(file);
774 return(MagickTrue);
775}
776
777/*
778%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
779% %
780% %
781% %
dirkfc0f1242016-03-26 00:36:39 +0100782+ L o a d C o d e r C a c h e %
cristy3ed852e2009-09-05 21:47:34 +0000783% %
784% %
785% %
786%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
787%
cristy86e5ac92014-03-16 19:27:39 +0000788% LoadCoderCache() loads the coder configurations which provides a
cristy3ed852e2009-09-05 21:47:34 +0000789% mapping between coder attributes and a coder name.
790%
cristy86e5ac92014-03-16 19:27:39 +0000791% The format of the LoadCoderCache coder is:
cristy3ed852e2009-09-05 21:47:34 +0000792%
dirkb18d8642016-07-17 19:32:43 +0200793% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
794% const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000795%
796% A description of each parameter follows:
797%
798% o xml: The coder list in XML format.
799%
800% o filename: The coder list filename.
801%
802% o depth: depth of <include /> statements.
803%
804% o exception: return any errors or warnings in this structure.
805%
806*/
dirkb18d8642016-07-17 19:32:43 +0200807static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
808 const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000809{
810 char
cristy151b66d2015-04-15 10:50:31 +0000811 keyword[MagickPathExtent],
cristy3ed852e2009-09-05 21:47:34 +0000812 *token;
813
814 const char
815 *q;
816
817 CoderInfo
818 *coder_info;
819
cristy759ba912014-06-26 11:59:43 +0000820 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000821 status;
822
dirkfc0f1242016-03-26 00:36:39 +0100823 size_t
824 extent;
825
cristy3ed852e2009-09-05 21:47:34 +0000826 /*
827 Load the coder map file.
828 */
829 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
830 "Loading coder configuration file \"%s\" ...",filename);
831 if (xml == (const char *) NULL)
832 return(MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000833 status=MagickTrue;
834 coder_info=(CoderInfo *) NULL;
835 token=AcquireString(xml);
dirkfc0f1242016-03-26 00:36:39 +0100836 extent=strlen(token)+MagickPathExtent;
cristy3ed852e2009-09-05 21:47:34 +0000837 for (q=(char *) xml; *q != '\0'; )
838 {
839 /*
840 Interpret XML.
841 */
Cristy8bedb4e2016-03-25 19:54:25 -0400842 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000843 if (*token == '\0')
844 break;
cristy151b66d2015-04-15 10:50:31 +0000845 (void) CopyMagickString(keyword,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000846 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
847 {
848 /*
849 Doctype element.
850 */
851 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400852 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000853 continue;
854 }
855 if (LocaleNCompare(keyword,"<!--",4) == 0)
856 {
857 /*
858 Comment element.
859 */
860 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400861 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000862 continue;
863 }
864 if (LocaleCompare(keyword,"<include") == 0)
865 {
866 /*
867 Include element.
868 */
869 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
870 {
cristy151b66d2015-04-15 10:50:31 +0000871 (void) CopyMagickString(keyword,token,MagickPathExtent);
Cristy8bedb4e2016-03-25 19:54:25 -0400872 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000873 if (*token != '=')
874 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400875 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000876 if (LocaleCompare(keyword,"file") == 0)
877 {
878 if (depth > 200)
879 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000880 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
cristy3ed852e2009-09-05 21:47:34 +0000881 else
882 {
883 char
cristy151b66d2015-04-15 10:50:31 +0000884 path[MagickPathExtent],
dirkb81f0ab2015-10-20 23:01:53 +0200885 *file_xml;
cristy3ed852e2009-09-05 21:47:34 +0000886
887 GetPathComponent(filename,HeadPath,path);
888 if (*path != '\0')
889 (void) ConcatenateMagickString(path,DirectorySeparator,
cristy151b66d2015-04-15 10:50:31 +0000890 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000891 if (*token == *DirectorySeparator)
cristy151b66d2015-04-15 10:50:31 +0000892 (void) CopyMagickString(path,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000893 else
cristy151b66d2015-04-15 10:50:31 +0000894 (void) ConcatenateMagickString(path,token,MagickPathExtent);
dirkb81f0ab2015-10-20 23:01:53 +0200895 file_xml=FileToXML(path,~0UL);
896 if (file_xml != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000897 {
dirkb18d8642016-07-17 19:32:43 +0200898 status&=LoadCoderCache(cache,file_xml,path,depth+1,
cristy86e5ac92014-03-16 19:27:39 +0000899 exception);
dirkb81f0ab2015-10-20 23:01:53 +0200900 file_xml=DestroyString(file_xml);
cristy3ed852e2009-09-05 21:47:34 +0000901 }
902 }
903 }
904 }
905 continue;
906 }
907 if (LocaleCompare(keyword,"<coder") == 0)
908 {
909 /*
910 Coder element.
911 */
cristy73bd4a52010-10-05 11:24:23 +0000912 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
cristy3ed852e2009-09-05 21:47:34 +0000913 if (coder_info == (CoderInfo *) NULL)
914 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
915 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
916 coder_info->path=ConstantString(filename);
cristye3e77a12009-10-16 00:47:21 +0000917 coder_info->exempt=MagickFalse;
cristye1c94d92015-06-28 12:16:33 +0000918 coder_info->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000919 continue;
920 }
921 if (coder_info == (CoderInfo *) NULL)
922 continue;
Cristyfed111e2017-01-09 07:22:16 -0500923 if ((LocaleCompare(keyword,"/>") == 0) ||
924 (LocaleCompare(keyword,"</policy>") == 0))
cristy3ed852e2009-09-05 21:47:34 +0000925 {
dirkb18d8642016-07-17 19:32:43 +0200926 status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
927 coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000928 if (status == MagickFalse)
929 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000930 ResourceLimitError,"MemoryAllocationFailed","`%s'",
cristy3ed852e2009-09-05 21:47:34 +0000931 coder_info->magick);
932 coder_info=(CoderInfo *) NULL;
cristyd45122f2014-01-14 23:46:16 +0000933 continue;
cristy3ed852e2009-09-05 21:47:34 +0000934 }
Cristy8bedb4e2016-03-25 19:54:25 -0400935 GetNextToken(q,(const char **) NULL,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000936 if (*token != '=')
937 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400938 GetNextToken(q,&q,extent,token);
939 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000940 switch (*keyword)
941 {
942 case 'M':
943 case 'm':
944 {
945 if (LocaleCompare((char *) keyword,"magick") == 0)
946 {
947 coder_info->magick=ConstantString(token);
948 break;
949 }
950 break;
951 }
952 case 'N':
953 case 'n':
954 {
955 if (LocaleCompare((char *) keyword,"name") == 0)
956 {
957 coder_info->name=ConstantString(token);
958 break;
959 }
960 break;
961 }
962 case 'S':
963 case 's':
964 {
965 if (LocaleCompare((char *) keyword,"stealth") == 0)
966 {
anthony6f201312012-03-30 04:08:15 +0000967 coder_info->stealth=IsStringTrue(token);
cristy3ed852e2009-09-05 21:47:34 +0000968 break;
969 }
970 break;
971 }
972 default:
973 break;
974 }
975 }
976 token=(char *) RelinquishMagickMemory(token);
cristy759ba912014-06-26 11:59:43 +0000977 return(status != 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000978}