blob: 0b55c88cef5e2277c4e9f7d562cb3cea45d7e046 [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" },
86 { "8BIM", "META" },
87 { "8BIMTEXT", "META" },
88 { "8BIMWTEXT", "META" },
89 { "AFM", "TTF" },
90 { "A", "RAW" },
91 { "AI", "PDF" },
92 { "APP1JPEG", "META" },
93 { "APP1", "META" },
94 { "ARW", "DNG" },
cristy0fc02592010-05-24 14:12:38 +000095 { "AVI", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +000096 { "BIE", "JBIG" },
97 { "BMP2", "BMP" },
98 { "BMP3", "BMP" },
99 { "B", "RAW" },
100 { "BRF", "BRAILLE" },
cristy90dbac72010-08-22 15:08:40 +0000101 { "BGRA", "BGR" },
dirk2a2d3d62015-07-27 11:09:58 +0000102 { "BGRO", "BGR" },
cristye3e77a12009-10-16 00:47:21 +0000103 { "CMYKA", "CMYK" },
104 { "C", "RAW" },
105 { "CAL", "CALS" },
cristyc05417c2010-09-21 16:30:32 +0000106 { "CANVAS", "XC" },
dirk2a2d3d62015-07-27 11:09:58 +0000107 { "CMYKA", "CMYK" },
cristye3e77a12009-10-16 00:47:21 +0000108 { "CR2", "DNG" },
109 { "CRW", "DNG" },
110 { "CUR", "ICON" },
Cristy6ffac4f2015-08-23 10:55:57 -0400111 { "DATA", "INLINE" },
cristye3e77a12009-10-16 00:47:21 +0000112 { "DCR", "DNG" },
113 { "DCX", "PCX" },
114 { "DFONT", "TTF" },
dirk2a2d3d62015-07-27 11:09:58 +0000115 { "DXT1", "DDS" },
116 { "DXT5", "DDS" },
cristye3e77a12009-10-16 00:47:21 +0000117 { "EPDF", "PDF" },
118 { "EPI", "PS" },
119 { "EPS2", "PS2" },
120 { "EPS3", "PS3" },
121 { "EPSF", "PS" },
122 { "EPSI", "PS" },
123 { "EPS", "PS" },
124 { "EPT2", "EPT" },
125 { "EPT3", "EPT" },
126 { "ERF", "DNG" },
127 { "EXIF", "META" },
128 { "FILE", "URL" },
129 { "FRACTAL", "PLASMA" },
130 { "FTP", "URL" },
131 { "FTS", "FITS" },
132 { "G3", "FAX" },
dirk52456ef2016-06-17 15:29:46 +0200133 { "G4", "FAX" },
cristye3e77a12009-10-16 00:47:21 +0000134 { "GIF87", "GIF" },
135 { "G", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000136 { "GRANITE", "MAGICK" },
137 { "GROUP4", "TIFF" },
cristy7f47ac62013-02-10 14:16:17 +0000138 { "GV", "DOT" },
dirk2a2d3d62015-07-27 11:09:58 +0000139 { "HTM", "HTML" },
140 { "ICB", "TGA" },
141 { "ICO", "ICON" },
cristya5338bb2014-11-05 18:25:16 +0000142 { "IIQ", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000143 { "K25", "DNG" },
144 { "KDC", "DNG" },
145 { "H", "MAGICK" },
146 { "HTM", "HTML" },
147 { "HTTP", "URL" },
dirk853b77b2013-09-21 19:04:42 +0000148 { "HTTPS", "URL" },
cristye3e77a12009-10-16 00:47:21 +0000149 { "ICB", "TGA" },
150 { "ICC", "META" },
151 { "ICM", "META" },
152 { "ICO", "ICON" },
153 { "IMPLICIT", "***" },
154 { "IPTC", "META" },
155 { "IPTCTEXT", "META" },
156 { "IPTCWTEXT", "META" },
157 { "ISOBRL", "BRAILLE" },
Samuel Thibault531aa152015-11-01 23:36:24 +0100158 { "ISOBRL6", "BRAILLE" },
cristye3e77a12009-10-16 00:47:21 +0000159 { "JBG", "JBIG" },
160 { "JNG", "PNG" },
161 { "JPC", "JP2" },
cristy2267fa42014-09-12 10:27:47 +0000162 { "JPT", "JP2" },
163 { "JPM", "JP2" },
cristy02f1fda2009-12-10 15:23:56 +0000164 { "J2C", "JP2" },
cristy4faac682012-05-10 12:09:45 +0000165 { "J2K", "JP2" },
dirk2a2d3d62015-07-27 11:09:58 +0000166 { "JNG", "PNG" },
cristyb338b712014-11-27 14:06:34 +0000167 { "JPE", "JPEG" },
cristye3e77a12009-10-16 00:47:21 +0000168 { "JPG", "JPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000169 { "JPM", "JP2" },
cristya663a4f2015-01-23 12:11:57 +0000170 { "JPS", "JPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000171 { "JPT", "JP2" },
cristye3e77a12009-10-16 00:47:21 +0000172 { "JPX", "JP2" },
173 { "K", "RAW" },
dirk2a2d3d62015-07-27 11:09:58 +0000174 { "K25", "DNG" },
175 { "KDC", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000176 { "LOGO", "MAGICK" },
dirk2a2d3d62015-07-27 11:09:58 +0000177 { "M", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000178 { "M2V", "MPEG" },
179 { "M4V", "MPEG" },
dirk2a2d3d62015-07-27 11:09:58 +0000180 { "MEF", "DNG" },
cristya3d81422015-04-03 13:00:33 +0000181 { "MKV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000182 { "MNG", "PNG" },
cristy1dbd5a32010-11-28 22:23:27 +0000183 { "MOV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000184 { "MP4", "MPEG" },
185 { "MPG", "MPEG" },
186 { "MPRI", "MPR" },
cristy1be98ec2012-01-30 16:51:12 +0000187 { "MEF", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000188 { "MRW", "DNG" },
189 { "MSVG", "SVG" },
190 { "NEF", "DNG" },
191 { "NETSCAPE", "MAGICK" },
cristycb8f0ae2012-03-02 12:26:21 +0000192 { "NRW", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000193 { "O", "RAW" },
194 { "ORF", "DNG" },
195 { "OTF", "TTF" },
196 { "P7", "PNM" },
197 { "PAL", "UYVY" },
198 { "PAM", "PNM" },
199 { "PBM", "PNM" },
200 { "PCDS", "PCD" },
dirk2a2d3d62015-07-27 11:09:58 +0000201 { "PCT", "PICT" },
cristye3e77a12009-10-16 00:47:21 +0000202 { "PDFA", "PDF" },
203 { "PEF", "DNG" },
204 { "PEF", "DNG" },
205 { "PFA", "TTF" },
206 { "PFB", "TTF" },
207 { "PFM", "PNM" },
208 { "PGM", "PNM" },
209 { "PGX", "JP2" },
210 { "PICON", "XPM" },
211 { "PJPEG", "JPEG" },
212 { "PM", "XPM" },
dirk2a2d3d62015-07-27 11:09:58 +0000213 { "PNG00", "PNG" },
cristye3e77a12009-10-16 00:47:21 +0000214 { "PNG24", "PNG" },
215 { "PNG32", "PNG" },
dirk2a2d3d62015-07-27 11:09:58 +0000216 { "PNG48", "PNG" },
217 { "PNG64", "PNG" },
cristye3e77a12009-10-16 00:47:21 +0000218 { "PNG8", "PNG" },
219 { "PPM", "PNM" },
cristyb4233012010-02-28 20:09:14 +0000220 { "PSB", "PSD" },
cristye3e77a12009-10-16 00:47:21 +0000221 { "PTIF", "TIFF" },
dirk2a2d3d62015-07-27 11:09:58 +0000222 { "R", "RAW" },
cristye3e77a12009-10-16 00:47:21 +0000223 { "RADIAL-GRADIENT", "GRADIENT" },
224 { "RAF", "DNG" },
225 { "RAS", "SUN" },
cristy1b1f0722014-06-10 10:14:59 +0000226 { "RAW", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000227 { "RGBA", "RGB" },
228 { "RGBO", "RGB" },
cristy15e22962014-02-21 22:56:26 +0000229 { "RMF", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000230 { "ROSE", "MAGICK" },
cristy98aceb82012-10-20 21:24:00 +0000231 { "RW2", "DNG" },
cristye3e77a12009-10-16 00:47:21 +0000232 { "SHTML", "HTML" },
dirka1e4ab82014-10-07 05:06:49 +0000233 { "SIX", "SIXEL" },
cristye6ee7492013-03-16 15:04:42 +0000234 { "SPARSE-COLOR", "TXT" },
cristye3e77a12009-10-16 00:47:21 +0000235 { "SR2", "DNG" },
236 { "SRF", "DNG" },
237 { "SVGZ", "SVG" },
238 { "TEXT", "TXT" },
239 { "TIFF64", "TIFF" },
240 { "TIF", "TIFF" },
241 { "TTC", "TTF" },
242 { "UBRL", "BRAILLE" },
Samuel Thibault531aa152015-11-01 23:36:24 +0100243 { "UBRL6", "BRAILLE" },
cristye3e77a12009-10-16 00:47:21 +0000244 { "VDA", "TGA" },
245 { "VST", "TGA" },
cristyed40d622011-01-17 15:51:00 +0000246 { "WIZARD", "MAGICK" },
dirk073ff372014-01-05 14:05:25 +0000247#if defined(MAGICKCORE_WINGDI32_DELEGATE)
248 { "WMF", "EMF" },
249#endif
cristye3e77a12009-10-16 00:47:21 +0000250 { "WMV", "MPEG" },
cristye3e77a12009-10-16 00:47:21 +0000251 { "WMZ", "WMF" },
252 { "X3f", "DNG" },
253 { "XMP", "META" },
254 { "XTRNARRAY", "XTRN" },
cristye3e77a12009-10-16 00:47:21 +0000255 { "XV", "VIFF" },
256 { "Y", "RAW" },
cristy54a531d2009-10-21 17:58:01 +0000257 { "YCbCrA", "YCbCr" }
cristye3e77a12009-10-16 00:47:21 +0000258 };
259
cristy3ed852e2009-09-05 21:47:34 +0000260static SemaphoreInfo
261 *coder_semaphore = (SemaphoreInfo *) NULL;
262
263static SplayTreeInfo
cristy86e5ac92014-03-16 19:27:39 +0000264 *coder_cache = (SplayTreeInfo *) NULL;
cristy3ed852e2009-09-05 21:47:34 +0000265
266/*
267 Forward declarations.
268*/
269static MagickBooleanType
cristy904e5912014-03-15 19:53:14 +0000270 IsCoderTreeInstantiated(ExceptionInfo *),
cristy86e5ac92014-03-16 19:27:39 +0000271 LoadCoderCache(SplayTreeInfo *,const char *,const char *,const size_t,
272 ExceptionInfo *);
273
274/*
275%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276% %
277% %
278% %
cristy6c6322e2014-09-09 22:39:21 +0000279+ A c q u i r e C o d e r C a c h e %
cristy86e5ac92014-03-16 19:27:39 +0000280% %
281% %
282% %
283%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284%
cristy6c6322e2014-09-09 22:39:21 +0000285% AcquireCoderCache() caches one or more coder configurations which provides a
286% mapping between coder attributes and a coder name.
cristy86e5ac92014-03-16 19:27:39 +0000287%
288% The format of the AcquireCoderCache coder is:
289%
290% SplayTreeInfo *AcquireCoderCache(const char *filename,
291% ExceptionInfo *exception)
292%
293% A description of each parameter follows:
294%
295% o filename: the font file name.
296%
297% o exception: return any errors or warnings in this structure.
298%
299*/
300
301static void *DestroyCoderNode(void *coder_info)
302{
303 register CoderInfo
304 *p;
305
306 p=(CoderInfo *) coder_info;
307 if (p->exempt == MagickFalse)
308 {
309 if (p->path != (char *) NULL)
310 p->path=DestroyString(p->path);
311 if (p->name != (char *) NULL)
312 p->name=DestroyString(p->name);
313 if (p->magick != (char *) NULL)
314 p->magick=DestroyString(p->magick);
315 }
316 return(RelinquishMagickMemory(p));
317}
318
319static SplayTreeInfo *AcquireCoderCache(const char *filename,
320 ExceptionInfo *exception)
321{
cristy86e5ac92014-03-16 19:27:39 +0000322 MagickStatusType
323 status;
324
325 register ssize_t
326 i;
327
328 SplayTreeInfo
dirkb18d8642016-07-17 19:32:43 +0200329 *cache;
cristy86e5ac92014-03-16 19:27:39 +0000330
331 /*
332 Load external coder map.
333 */
dirkb18d8642016-07-17 19:32:43 +0200334 cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
cristy86e5ac92014-03-16 19:27:39 +0000335 DestroyCoderNode);
dirkb18d8642016-07-17 19:32:43 +0200336 if (cache == (SplayTreeInfo *) NULL)
cristy86e5ac92014-03-16 19:27:39 +0000337 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
338 status=MagickTrue;
dirkb18d8642016-07-17 19:32:43 +0200339#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
cristy86e5ac92014-03-16 19:27:39 +0000340 {
dirkb18d8642016-07-17 19:32:43 +0200341 const StringInfo
342 *option;
343
344 LinkedListInfo
345 *options;
346
347 options=GetConfigureOptions(filename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000348 option=(const StringInfo *) GetNextValueInLinkedList(options);
dirkb18d8642016-07-17 19:32:43 +0200349 while (option != (const StringInfo *) NULL)
350 {
351 status&=LoadCoderCache(cache,(const char *) GetStringInfoDatum(option),
352 GetStringInfoPath(option),0,exception);
353 option=(const StringInfo *) GetNextValueInLinkedList(options);
354 }
355 options=DestroyConfigureOptions(options);
cristy86e5ac92014-03-16 19:27:39 +0000356 }
dirkb18d8642016-07-17 19:32:43 +0200357#endif
cristy86e5ac92014-03-16 19:27:39 +0000358 /*
359 Load built-in coder map.
360 */
361 for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
362 {
363 CoderInfo
364 *coder_info;
365
366 register const CoderMapInfo
367 *p;
368
369 p=CoderMap+i;
370 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
371 if (coder_info == (CoderInfo *) NULL)
372 {
373 (void) ThrowMagickException(exception,GetMagickModule(),
374 ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
375 continue;
376 }
377 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
378 coder_info->path=(char *) "[built-in]";
379 coder_info->magick=(char *) p->magick;
380 coder_info->name=(char *) p->name;
381 coder_info->exempt=MagickTrue;
cristye1c94d92015-06-28 12:16:33 +0000382 coder_info->signature=MagickCoreSignature;
dirkb18d8642016-07-17 19:32:43 +0200383 status&=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
cristy86e5ac92014-03-16 19:27:39 +0000384 coder_info);
385 if (status == MagickFalse)
386 (void) ThrowMagickException(exception,GetMagickModule(),
387 ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
388 }
dirkb18d8642016-07-17 19:32:43 +0200389 return(cache);
cristy86e5ac92014-03-16 19:27:39 +0000390}
cristy3ed852e2009-09-05 21:47:34 +0000391
392/*
393%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394% %
395% %
396% %
cristyf34a1452009-10-24 22:29:27 +0000397+ C o d e r C o m p o n e n t G e n e s i s %
cristy3ed852e2009-09-05 21:47:34 +0000398% %
399% %
400% %
401%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402%
cristyf34a1452009-10-24 22:29:27 +0000403% CoderComponentGenesis() instantiates the coder component.
cristy3ed852e2009-09-05 21:47:34 +0000404%
cristyf34a1452009-10-24 22:29:27 +0000405% The format of the CoderComponentGenesis method is:
cristy3ed852e2009-09-05 21:47:34 +0000406%
cristyf34a1452009-10-24 22:29:27 +0000407% MagickBooleanType CoderComponentGenesis(void)
cristy3ed852e2009-09-05 21:47:34 +0000408%
409*/
cristy5ff4eaf2011-09-03 01:38:02 +0000410MagickPrivate MagickBooleanType CoderComponentGenesis(void)
cristyf34a1452009-10-24 22:29:27 +0000411{
cristy7c977062014-04-04 14:05:53 +0000412 if (coder_semaphore == (SemaphoreInfo *) NULL)
413 coder_semaphore=AcquireSemaphoreInfo();
cristyf34a1452009-10-24 22:29:27 +0000414 return(MagickTrue);
415}
416
417/*
418%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419% %
420% %
421% %
422+ C o d e r C o m p o n e n t T e r m i n u s %
423% %
424% %
425% %
426%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427%
428% CoderComponentTerminus() destroys the coder component.
429%
430% The format of the CoderComponentTerminus method is:
431%
432% CoderComponentTerminus(void)
433%
434*/
cristy5ff4eaf2011-09-03 01:38:02 +0000435MagickPrivate void CoderComponentTerminus(void)
cristy3ed852e2009-09-05 21:47:34 +0000436{
cristy18b17442009-10-25 18:36:48 +0000437 if (coder_semaphore == (SemaphoreInfo *) NULL)
cristy04b11db2014-02-16 15:10:39 +0000438 ActivateSemaphoreInfo(&coder_semaphore);
cristyf84a1932010-01-03 18:00:18 +0000439 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000440 if (coder_cache != (SplayTreeInfo *) NULL)
441 coder_cache=DestroySplayTree(coder_cache);
cristyf84a1932010-01-03 18:00:18 +0000442 UnlockSemaphoreInfo(coder_semaphore);
cristy3d162a92014-02-16 14:05:06 +0000443 RelinquishSemaphoreInfo(&coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000444}
445
446/*
447%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448% %
449% %
450% %
451+ G e t C o d e r I n f o %
452% %
453% %
454% %
455%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
456%
457% GetCoderInfo searches the coder list for the specified name and if found
458% returns attributes for that coder.
459%
460% The format of the GetCoderInfo method is:
461%
462% const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception)
463%
464% A description of each parameter follows:
465%
466% o name: the coder name.
467%
468% o exception: return any errors or warnings in this structure.
469%
470*/
471MagickExport const CoderInfo *GetCoderInfo(const char *name,
472 ExceptionInfo *exception)
473{
cristy49d4d222014-03-16 00:37:58 +0000474 const CoderInfo
475 *coder_info;
476
cristy3ed852e2009-09-05 21:47:34 +0000477 assert(exception != (ExceptionInfo *) NULL);
cristy904e5912014-03-15 19:53:14 +0000478 if (IsCoderTreeInstantiated(exception) == MagickFalse)
479 return((const CoderInfo *) NULL);
cristy49d4d222014-03-16 00:37:58 +0000480 LockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000481 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
482 {
cristy86e5ac92014-03-16 19:27:39 +0000483 ResetSplayTreeIterator(coder_cache);
484 coder_info=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy49d4d222014-03-16 00:37:58 +0000485 UnlockSemaphoreInfo(coder_semaphore);
486 return(coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000487 }
cristy86e5ac92014-03-16 19:27:39 +0000488 coder_info=(const CoderInfo *) GetValueFromSplayTree(coder_cache,name);
cristy49d4d222014-03-16 00:37:58 +0000489 UnlockSemaphoreInfo(coder_semaphore);
490 return(coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000491}
492
493/*
494%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
495% %
496% %
497% %
498% G e t C o d e r I n f o L i s t %
499% %
500% %
501% %
502%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503%
504% GetCoderInfoList() returns any coder_map that match the specified pattern.
505% The format of the GetCoderInfoList function is:
506%
507% const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000508% size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000509%
510% A description of each parameter follows:
511%
512% o pattern: Specifies a pointer to a text string containing a pattern.
513%
514% o number_coders: This integer returns the number of coders in the list.
515%
516% o exception: return any errors or warnings in this structure.
517%
518*/
519
520static int CoderInfoCompare(const void *x,const void *y)
521{
522 const CoderInfo
523 **p,
524 **q;
525
526 p=(const CoderInfo **) x,
527 q=(const CoderInfo **) y;
528 if (LocaleCompare((*p)->path,(*q)->path) == 0)
529 return(LocaleCompare((*p)->name,(*q)->name));
530 return(LocaleCompare((*p)->path,(*q)->path));
531}
532
533MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000534 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000535{
536 const CoderInfo
537 **coder_map;
538
539 register const CoderInfo
540 *p;
541
cristybb503372010-05-27 20:51:26 +0000542 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000543 i;
544
545 /*
546 Allocate coder list.
547 */
548 assert(pattern != (char *) NULL);
549 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000550 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000551 *number_coders=0;
552 p=GetCoderInfo("*",exception);
553 if (p == (const CoderInfo *) NULL)
554 return((const CoderInfo **) NULL);
555 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000556 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000557 if (coder_map == (const CoderInfo **) NULL)
558 return((const CoderInfo **) NULL);
559 /*
560 Generate coder list.
561 */
cristyf84a1932010-01-03 18:00:18 +0000562 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000563 ResetSplayTreeIterator(coder_cache);
564 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000565 for (i=0; p != (const CoderInfo *) NULL; )
566 {
567 if ((p->stealth == MagickFalse) &&
568 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
569 coder_map[i++]=p;
cristy86e5ac92014-03-16 19:27:39 +0000570 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000571 }
cristyf84a1932010-01-03 18:00:18 +0000572 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000573 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
574 coder_map[i]=(CoderInfo *) NULL;
cristybb503372010-05-27 20:51:26 +0000575 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000576 return(coder_map);
577}
578
579/*
580%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581% %
582% %
583% %
584% G e t C o d e r L i s t %
585% %
586% %
587% %
588%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589%
590% GetCoderList() returns any coder_map that match the specified pattern.
591%
592% The format of the GetCoderList function is:
593%
cristybb503372010-05-27 20:51:26 +0000594% char **GetCoderList(const char *pattern,size_t *number_coders,
cristy3ed852e2009-09-05 21:47:34 +0000595% ExceptionInfo *exception)
596%
597% A description of each parameter follows:
598%
599% o pattern: Specifies a pointer to a text string containing a pattern.
600%
601% o number_coders: This integer returns the number of coders in the list.
602%
603% o exception: return any errors or warnings in this structure.
604%
605*/
606
607static int CoderCompare(const void *x,const void *y)
608{
609 register const char
610 **p,
611 **q;
612
613 p=(const char **) x;
614 q=(const char **) y;
615 return(LocaleCompare(*p,*q));
616}
617
618MagickExport char **GetCoderList(const char *pattern,
cristybb503372010-05-27 20:51:26 +0000619 size_t *number_coders,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000620{
621 char
622 **coder_map;
623
624 register const CoderInfo
625 *p;
626
cristybb503372010-05-27 20:51:26 +0000627 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000628 i;
629
630 /*
631 Allocate coder list.
632 */
633 assert(pattern != (char *) NULL);
634 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
cristybb503372010-05-27 20:51:26 +0000635 assert(number_coders != (size_t *) NULL);
cristy3ed852e2009-09-05 21:47:34 +0000636 *number_coders=0;
637 p=GetCoderInfo("*",exception);
638 if (p == (const CoderInfo *) NULL)
639 return((char **) NULL);
640 coder_map=(char **) AcquireQuantumMemory((size_t)
cristy86e5ac92014-03-16 19:27:39 +0000641 GetNumberOfNodesInSplayTree(coder_cache)+1UL,sizeof(*coder_map));
cristy3ed852e2009-09-05 21:47:34 +0000642 if (coder_map == (char **) NULL)
643 return((char **) NULL);
644 /*
645 Generate coder list.
646 */
cristyf84a1932010-01-03 18:00:18 +0000647 LockSemaphoreInfo(coder_semaphore);
cristy86e5ac92014-03-16 19:27:39 +0000648 ResetSplayTreeIterator(coder_cache);
649 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000650 for (i=0; p != (const CoderInfo *) NULL; )
651 {
652 if ((p->stealth == MagickFalse) &&
653 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
654 coder_map[i++]=ConstantString(p->name);
cristy86e5ac92014-03-16 19:27:39 +0000655 p=(const CoderInfo *) GetNextValueInSplayTree(coder_cache);
cristy3ed852e2009-09-05 21:47:34 +0000656 }
cristyf84a1932010-01-03 18:00:18 +0000657 UnlockSemaphoreInfo(coder_semaphore);
cristy3ed852e2009-09-05 21:47:34 +0000658 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
659 coder_map[i]=(char *) NULL;
cristybb503372010-05-27 20:51:26 +0000660 *number_coders=(size_t) i;
cristy3ed852e2009-09-05 21:47:34 +0000661 return(coder_map);
662}
663
664/*
665%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
666% %
667% %
668% %
cristy904e5912014-03-15 19:53:14 +0000669+ 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 +0000670% %
671% %
672% %
673%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674%
cristycd2cd182014-03-18 12:10:55 +0000675% IsCoderTreeInstantiated() determines if the coder tree is instantiated. If
676% not, it instantiates the tree and returns it.
cristy3ed852e2009-09-05 21:47:34 +0000677%
cristy904e5912014-03-15 19:53:14 +0000678% The format of the IsCoderInstantiated method is:
cristy3ed852e2009-09-05 21:47:34 +0000679%
cristy904e5912014-03-15 19:53:14 +0000680% MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000681%
682% A description of each parameter follows.
683%
684% o exception: return any errors or warnings in this structure.
685%
686*/
cristy904e5912014-03-15 19:53:14 +0000687static MagickBooleanType IsCoderTreeInstantiated(ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000688{
cristy86e5ac92014-03-16 19:27:39 +0000689 if (coder_cache == (SplayTreeInfo *) NULL)
690 {
691 if (coder_semaphore == (SemaphoreInfo *) NULL)
692 ActivateSemaphoreInfo(&coder_semaphore);
693 LockSemaphoreInfo(coder_semaphore);
694 if (coder_cache == (SplayTreeInfo *) NULL)
cristycd2cd182014-03-18 12:10:55 +0000695 coder_cache=AcquireCoderCache(MagickCoderFilename,exception);
cristy86e5ac92014-03-16 19:27:39 +0000696 UnlockSemaphoreInfo(coder_semaphore);
697 }
698 return(coder_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000699}
700
701/*
702%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
703% %
704% %
705% %
706% L i s t C o d e r I n f o %
707% %
708% %
709% %
710%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
711%
712% ListCoderInfo() lists the coder info to a file.
713%
714% The format of the ListCoderInfo coder is:
715%
716% MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
717%
718% A description of each parameter follows.
719%
720% o file: An pointer to a FILE.
721%
722% o exception: return any errors or warnings in this structure.
723%
724*/
725MagickExport MagickBooleanType ListCoderInfo(FILE *file,
726 ExceptionInfo *exception)
727{
728 const char
729 *path;
730
731 const CoderInfo
732 **coder_info;
733
cristybb503372010-05-27 20:51:26 +0000734 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000735 i;
736
cristybb503372010-05-27 20:51:26 +0000737 size_t
cristy3ed852e2009-09-05 21:47:34 +0000738 number_coders;
739
cristy9d314ff2011-03-09 01:30:28 +0000740 ssize_t
741 j;
742
cristy3ed852e2009-09-05 21:47:34 +0000743 if (file == (const FILE *) NULL)
744 file=stdout;
745 coder_info=GetCoderInfoList("*",&number_coders,exception);
746 if (coder_info == (const CoderInfo **) NULL)
747 return(MagickFalse);
748 path=(const char *) NULL;
cristybb503372010-05-27 20:51:26 +0000749 for (i=0; i < (ssize_t) number_coders; i++)
cristy3ed852e2009-09-05 21:47:34 +0000750 {
751 if (coder_info[i]->stealth != MagickFalse)
752 continue;
753 if ((path == (const char *) NULL) ||
754 (LocaleCompare(path,coder_info[i]->path) != 0))
755 {
756 if (coder_info[i]->path != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000757 (void) FormatLocaleFile(file,"\nPath: %s\n\n",coder_info[i]->path);
758 (void) FormatLocaleFile(file,"Magick Coder\n");
cristy1e604812011-05-19 18:07:50 +0000759 (void) FormatLocaleFile(file,
760 "-------------------------------------------------"
cristy3ed852e2009-09-05 21:47:34 +0000761 "------------------------------\n");
762 }
763 path=coder_info[i]->path;
cristyb51dff52011-05-19 16:55:47 +0000764 (void) FormatLocaleFile(file,"%s",coder_info[i]->magick);
cristybb503372010-05-27 20:51:26 +0000765 for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
cristyb51dff52011-05-19 16:55:47 +0000766 (void) FormatLocaleFile(file," ");
cristy3ed852e2009-09-05 21:47:34 +0000767 if (coder_info[i]->name != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000768 (void) FormatLocaleFile(file,"%s",coder_info[i]->name);
769 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000770 }
771 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
772 (void) fflush(file);
773 return(MagickTrue);
774}
775
776/*
777%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778% %
779% %
780% %
dirkfc0f1242016-03-26 00:36:39 +0100781+ L o a d C o d e r C a c h e %
cristy3ed852e2009-09-05 21:47:34 +0000782% %
783% %
784% %
785%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
786%
cristy86e5ac92014-03-16 19:27:39 +0000787% LoadCoderCache() loads the coder configurations which provides a
cristy3ed852e2009-09-05 21:47:34 +0000788% mapping between coder attributes and a coder name.
789%
cristy86e5ac92014-03-16 19:27:39 +0000790% The format of the LoadCoderCache coder is:
cristy3ed852e2009-09-05 21:47:34 +0000791%
dirkb18d8642016-07-17 19:32:43 +0200792% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
793% const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000794%
795% A description of each parameter follows:
796%
797% o xml: The coder list in XML format.
798%
799% o filename: The coder list filename.
800%
801% o depth: depth of <include /> statements.
802%
803% o exception: return any errors or warnings in this structure.
804%
805*/
dirkb18d8642016-07-17 19:32:43 +0200806static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
807 const char *filename,const size_t depth,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000808{
809 char
cristy151b66d2015-04-15 10:50:31 +0000810 keyword[MagickPathExtent],
cristy3ed852e2009-09-05 21:47:34 +0000811 *token;
812
813 const char
814 *q;
815
816 CoderInfo
817 *coder_info;
818
cristy759ba912014-06-26 11:59:43 +0000819 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000820 status;
821
dirkfc0f1242016-03-26 00:36:39 +0100822 size_t
823 extent;
824
cristy3ed852e2009-09-05 21:47:34 +0000825 /*
826 Load the coder map file.
827 */
828 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
829 "Loading coder configuration file \"%s\" ...",filename);
830 if (xml == (const char *) NULL)
831 return(MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000832 status=MagickTrue;
833 coder_info=(CoderInfo *) NULL;
834 token=AcquireString(xml);
dirkfc0f1242016-03-26 00:36:39 +0100835 extent=strlen(token)+MagickPathExtent;
cristy3ed852e2009-09-05 21:47:34 +0000836 for (q=(char *) xml; *q != '\0'; )
837 {
838 /*
839 Interpret XML.
840 */
Cristy8bedb4e2016-03-25 19:54:25 -0400841 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000842 if (*token == '\0')
843 break;
cristy151b66d2015-04-15 10:50:31 +0000844 (void) CopyMagickString(keyword,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000845 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
846 {
847 /*
848 Doctype element.
849 */
850 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400851 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000852 continue;
853 }
854 if (LocaleNCompare(keyword,"<!--",4) == 0)
855 {
856 /*
857 Comment element.
858 */
859 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
Cristy8bedb4e2016-03-25 19:54:25 -0400860 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000861 continue;
862 }
863 if (LocaleCompare(keyword,"<include") == 0)
864 {
865 /*
866 Include element.
867 */
868 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
869 {
cristy151b66d2015-04-15 10:50:31 +0000870 (void) CopyMagickString(keyword,token,MagickPathExtent);
Cristy8bedb4e2016-03-25 19:54:25 -0400871 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000872 if (*token != '=')
873 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400874 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000875 if (LocaleCompare(keyword,"file") == 0)
876 {
877 if (depth > 200)
878 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000879 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
cristy3ed852e2009-09-05 21:47:34 +0000880 else
881 {
882 char
cristy151b66d2015-04-15 10:50:31 +0000883 path[MagickPathExtent],
dirkb81f0ab2015-10-20 23:01:53 +0200884 *file_xml;
cristy3ed852e2009-09-05 21:47:34 +0000885
886 GetPathComponent(filename,HeadPath,path);
887 if (*path != '\0')
888 (void) ConcatenateMagickString(path,DirectorySeparator,
cristy151b66d2015-04-15 10:50:31 +0000889 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000890 if (*token == *DirectorySeparator)
cristy151b66d2015-04-15 10:50:31 +0000891 (void) CopyMagickString(path,token,MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000892 else
cristy151b66d2015-04-15 10:50:31 +0000893 (void) ConcatenateMagickString(path,token,MagickPathExtent);
dirkb81f0ab2015-10-20 23:01:53 +0200894 file_xml=FileToXML(path,~0UL);
895 if (file_xml != (char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000896 {
dirkb18d8642016-07-17 19:32:43 +0200897 status&=LoadCoderCache(cache,file_xml,path,depth+1,
cristy86e5ac92014-03-16 19:27:39 +0000898 exception);
dirkb81f0ab2015-10-20 23:01:53 +0200899 file_xml=DestroyString(file_xml);
cristy3ed852e2009-09-05 21:47:34 +0000900 }
901 }
902 }
903 }
904 continue;
905 }
906 if (LocaleCompare(keyword,"<coder") == 0)
907 {
908 /*
909 Coder element.
910 */
cristy73bd4a52010-10-05 11:24:23 +0000911 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
cristy3ed852e2009-09-05 21:47:34 +0000912 if (coder_info == (CoderInfo *) NULL)
913 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
914 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
915 coder_info->path=ConstantString(filename);
cristye3e77a12009-10-16 00:47:21 +0000916 coder_info->exempt=MagickFalse;
cristye1c94d92015-06-28 12:16:33 +0000917 coder_info->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000918 continue;
919 }
920 if (coder_info == (CoderInfo *) NULL)
921 continue;
922 if (LocaleCompare(keyword,"/>") == 0)
923 {
dirkb18d8642016-07-17 19:32:43 +0200924 status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
925 coder_info);
cristy3ed852e2009-09-05 21:47:34 +0000926 if (status == MagickFalse)
927 (void) ThrowMagickException(exception,GetMagickModule(),
cristyefe601c2013-01-05 17:51:12 +0000928 ResourceLimitError,"MemoryAllocationFailed","`%s'",
cristy3ed852e2009-09-05 21:47:34 +0000929 coder_info->magick);
930 coder_info=(CoderInfo *) NULL;
cristyd45122f2014-01-14 23:46:16 +0000931 continue;
cristy3ed852e2009-09-05 21:47:34 +0000932 }
Cristy8bedb4e2016-03-25 19:54:25 -0400933 GetNextToken(q,(const char **) NULL,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000934 if (*token != '=')
935 continue;
Cristy8bedb4e2016-03-25 19:54:25 -0400936 GetNextToken(q,&q,extent,token);
937 GetNextToken(q,&q,extent,token);
cristy3ed852e2009-09-05 21:47:34 +0000938 switch (*keyword)
939 {
940 case 'M':
941 case 'm':
942 {
943 if (LocaleCompare((char *) keyword,"magick") == 0)
944 {
945 coder_info->magick=ConstantString(token);
946 break;
947 }
948 break;
949 }
950 case 'N':
951 case 'n':
952 {
953 if (LocaleCompare((char *) keyword,"name") == 0)
954 {
955 coder_info->name=ConstantString(token);
956 break;
957 }
958 break;
959 }
960 case 'S':
961 case 's':
962 {
963 if (LocaleCompare((char *) keyword,"stealth") == 0)
964 {
anthony6f201312012-03-30 04:08:15 +0000965 coder_info->stealth=IsStringTrue(token);
cristy3ed852e2009-09-05 21:47:34 +0000966 break;
967 }
968 break;
969 }
970 default:
971 break;
972 }
973 }
974 token=(char *) RelinquishMagickMemory(token);
cristy759ba912014-06-26 11:59:43 +0000975 return(status != 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000976}