2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % CCCC OOO DDDD EEEEE RRRR %
10 % CCCC OOO DDDD EEEEE R R %
13 % MagickCore Image Coder Methods %
20 % Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/client.h"
45 #include "magick/coder.h"
46 #include "magick/configure.h"
47 #include "magick/draw.h"
48 #include "magick/exception.h"
49 #include "magick/exception-private.h"
50 #include "magick/hashmap.h"
51 #include "magick/log.h"
52 #include "magick/memory_.h"
53 #include "magick/option.h"
54 #include "magick/semaphore.h"
55 #include "magick/string_.h"
56 #include "magick/splay-tree.h"
57 #include "magick/token.h"
58 #include "magick/utility.h"
59 #include "magick/xml-tree.h"
64 #define MagickCoderFilename "coder.xml"
70 *CoderMap = (const char *)
71 "<?xml version=\"1.0\"?>"
73 " <coder magick=\"8BIM\" name=\"META\" />"
74 " <coder magick=\"8BIMTEXT\" name=\"META\" />"
75 " <coder magick=\"8BIMWTEXT\" name=\"META\" />"
76 " <coder magick=\"A\" name=\"RAW\" />"
77 " <coder magick=\"AI\" name=\"PDF\" />"
78 " <coder magick=\"AFM\" name=\"TTF\" />"
79 " <coder magick=\"APP1JPEG\" name=\"META\" />"
80 " <coder magick=\"APP1\" name=\"META\" />"
81 " <coder magick=\"ARW\" name=\"DNG\" />"
82 " <coder magick=\"BIE\" name=\"JBIG\" />"
83 " <coder magick=\"BMP2\" name=\"BMP\" />"
84 " <coder magick=\"BMP3\" name=\"BMP\" />"
85 " <coder magick=\"B\" name=\"GRAY\" />"
86 " <coder magick=\"BRF\" name=\"BRAILLE\" />"
87 " <coder magick=\"CMYKA\" name=\"CMYK\" />"
88 " <coder magick=\"C\" name=\"GRAY\" />"
89 " <coder magick=\"CR2\" name=\"DNG\" />"
90 " <coder magick=\"CRW\" name=\"DNG\" />"
91 " <coder magick=\"CUR\" name=\"ICON\" />"
92 " <coder magick=\"DCR\" name=\"DNG\" />"
93 " <coder magick=\"DCX\" name=\"PCX\" />"
94 " <coder magick=\"DFONT\" name=\"TTF\" />"
95 " <coder magick=\"EMF\" name=\"EMF\" />"
96 " <coder magick=\"EPDF\" name=\"PDF\" />"
97 " <coder magick=\"EPI\" name=\"PS\" />"
98 " <coder magick=\"EPS2\" name=\"PS2\" />"
99 " <coder magick=\"EPS3\" name=\"PS3\" />"
100 " <coder magick=\"EPSF\" name=\"PS\" />"
101 " <coder magick=\"EPSI\" name=\"PS\" />"
102 " <coder magick=\"EPS\" name=\"PS\" />"
103 " <coder magick=\"EPT2\" name=\"EPT\" />"
104 " <coder magick=\"EPT3\" name=\"EPT\" />"
105 " <coder magick=\"EXIF\" name=\"META\" />"
106 " <coder magick=\"FILE\" name=\"URL\" />"
107 " <coder magick=\"FRACTAL\" name=\"PLASMA\" />"
108 " <coder magick=\"FTP\" name=\"URL\" />"
109 " <coder magick=\"FTS\" name=\"FITS\" />"
110 " <coder magick=\"G3\" name=\"FAX\" />"
111 " <coder magick=\"GIF87\" name=\"GIF\" />"
112 " <coder magick=\"G\" name=\"GRAY\" />"
113 " <coder magick=\"GRANITE\" name=\"MAGICK\" />"
114 " <coder magick=\"H\" name=\"MAGICK\" />"
115 " <coder magick=\"HTM\" name=\"HTML\" />"
116 " <coder magick=\"HTTP\" name=\"URL\" />"
117 " <coder magick=\"ICB\" name=\"TGA\" />"
118 " <coder magick=\"ICC\" name=\"META\" />"
119 " <coder magick=\"ICM\" name=\"META\" />"
120 " <coder magick=\"ICO\" name=\"ICON\" />"
121 " <coder magick=\"IMPLICIT\" name=\"***\" />"
122 " <coder magick=\"IPTC\" name=\"META\" />"
123 " <coder magick=\"IPTCTEXT\" name=\"META\" />"
124 " <coder magick=\"IPTCWTEXT\" name=\"META\" />"
125 " <coder magick=\"ISOBRL\" name=\"BRAILLE\" />"
126 " <coder magick=\"JBG\" name=\"JBIG\" />"
127 " <coder magick=\"JNG\" name=\"PNG\" />"
128 " <coder magick=\"JPC\" name=\"JP2\" />"
129 " <coder magick=\"JPG\" name=\"JPEG\" />"
130 " <coder magick=\"JPX\" name=\"JP2\" />"
131 " <coder magick=\"K\" name=\"GRAY\" />"
132 " <coder magick=\"LOGO\" name=\"MAGICK\" />"
133 " <coder magick=\"M2V\" name=\"MPEG\" />"
134 " <coder magick=\"M4V\" name=\"MPEG\" />"
135 " <coder magick=\"M\" name=\"GRAY\" />"
136 " <coder magick=\"MNG\" name=\"PNG\" />"
137 " <coder magick=\"MOV\" name=\"MPEG\" />"
138 " <coder magick=\"MPG\" name=\"MPEG\" />"
139 " <coder magick=\"MP4\" name=\"MPEG\" />"
140 " <coder magick=\"MPRI\" name=\"MPR\" />"
141 " <coder magick=\"MRW\" name=\"DNG\" />"
142 " <coder magick=\"MSVG\" name=\"SVG\" />"
143 " <coder magick=\"NEF\" name=\"DNG\" />"
144 " <coder magick=\"NETSCAPE\" name=\"MAGICK\" />"
145 " <coder magick=\"O\" name=\"GRAY\" />"
146 " <coder magick=\"ORF\" name=\"DNG\" />"
147 " <coder magick=\"OTF\" name=\"TTF\" />"
148 " <coder magick=\"P7\" name=\"PNM\" />"
149 " <coder magick=\"PAL\" name=\"UYVY\" />"
150 " <coder magick=\"PAM\" name=\"PNM\" />"
151 " <coder magick=\"PBM\" name=\"PNM\" />"
152 " <coder magick=\"PCDS\" name=\"PCD\" />"
153 " <coder magick=\"PCT\" name=\"PICT\" />"
154 " <coder magick=\"PDFA\" name=\"PDF\" />"
155 " <coder magick=\"PEF\" name=\"DNG\" />"
156 " <coder magick=\"PFA\" name=\"TTF\" />"
157 " <coder magick=\"PFB\" name=\"TTF\" />"
158 " <coder magick=\"PFM\" name=\"PNM\" />"
159 " <coder magick=\"PGM\" name=\"PNM\" />"
160 " <coder magick=\"PGX\" name=\"JP2\" />"
161 " <coder magick=\"PICON\" name=\"XPM\" />"
162 " <coder magick=\"PJPEG\" name=\"JPEG\" />"
163 " <coder magick=\"PM\" name=\"XPM\" />"
164 " <coder magick=\"PNG24\" name=\"PNG\" />"
165 " <coder magick=\"PNG32\" name=\"PNG\" />"
166 " <coder magick=\"PNG8\" name=\"PNG\" />"
167 " <coder magick=\"PPM\" name=\"PNM\" />"
168 " <coder magick=\"PTIF\" name=\"TIFF\" />"
169 " <coder magick=\"RADIAL-GRADIENT\" name=\"GRADIENT\" />"
170 " <coder magick=\"RAF\" name=\"DNG\" />"
171 " <coder magick=\"RAS\" name=\"SUN\" />"
172 " <coder magick=\"RGBA\" name=\"RGB\" />"
173 " <coder magick=\"RGBO\" name=\"RGB\" />"
174 " <coder magick=\"R\" name=\"GRAY\" />"
175 " <coder magick=\"ROSE\" name=\"MAGICK\" />"
176 " <coder magick=\"SHTML\" name=\"HTML\" />"
177 " <coder magick=\"SVGZ\" name=\"SVG\" />"
178 " <coder magick=\"TEXT\" name=\"TXT\" />"
179 " <coder magick=\"TIFF64\" name=\"TIFF\" />"
180 " <coder magick=\"TIF\" name=\"TIFF\" />"
181 " <coder magick=\"TTC\" name=\"TTF\" />"
182 " <coder magick=\"UBRL\" name=\"BRAILLE\" />"
183 " <coder magick=\"VDA\" name=\"TGA\" />"
184 " <coder magick=\"VST\" name=\"TGA\" />"
185 " <coder magick=\"WMFWIN32\" name=\"EMF\" />"
186 " <coder magick=\"WMV\" name=\"MPEG\" />"
187 " <coder magick=\"X3F\" name=\"DNG\" />"
188 " <coder magick=\"XTRNARRAY\" name=\"XTRN\" />"
189 " <coder magick=\"XTRNBLOB\" name=\"XTRN\" />"
190 " <coder magick=\"XTRNBSTR\" name=\"XTRN\" />"
191 " <coder magick=\"XTRNFILE\" name=\"XTRN\" />"
192 " <coder magick=\"XTRNIMAGE\" name=\"XTRN\" />"
193 " <coder magick=\"XTRNSTREAM\" name=\"XTRN\" />"
194 " <coder magick=\"XV\" name=\"VIFF\" />"
195 " <coder magick=\"Y\" name=\"GRAY\" />"
196 " <coder magick=\"YCbCrA\" name=\"YCbCr\" />"
203 *coder_semaphore = (SemaphoreInfo *) NULL;
206 *coder_list = (SplayTreeInfo *) NULL;
208 static volatile MagickBooleanType
209 instantiate_coder = MagickFalse;
212 Forward declarations.
214 static MagickBooleanType
215 InitializeCoderList(ExceptionInfo *),
216 LoadCoderLists(const char *,ExceptionInfo *);
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 + D e s t r o y C o d e r L i s t %
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 % DestroyCoderList() deallocates memory associated with the font list.
231 % The format of the DestroyCoderList method is:
233 % DestroyCoderList(void)
236 MagickExport void DestroyCoderList(void)
238 AcquireSemaphoreInfo(&coder_semaphore);
239 if (coder_list != (SplayTreeInfo *) NULL)
240 coder_list=DestroySplayTree(coder_list);
241 instantiate_coder=MagickFalse;
242 RelinquishSemaphoreInfo(coder_semaphore);
243 DestroySemaphoreInfo(&coder_semaphore);
247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251 + G e t C o d e r I n f o %
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 % GetCoderInfo searches the coder list for the specified name and if found
258 % returns attributes for that coder.
260 % The format of the GetCoderInfo method is:
262 % const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception)
264 % A description of each parameter follows:
266 % o name: the coder name.
268 % o exception: return any errors or warnings in this structure.
271 MagickExport const CoderInfo *GetCoderInfo(const char *name,
272 ExceptionInfo *exception)
274 assert(exception != (ExceptionInfo *) NULL);
275 if ((coder_list == (SplayTreeInfo *) NULL) ||
276 (instantiate_coder == MagickFalse))
277 if (InitializeCoderList(exception) == MagickFalse)
278 return((const CoderInfo *) NULL);
279 if ((coder_list == (SplayTreeInfo *) NULL) ||
280 (GetNumberOfNodesInSplayTree(coder_list) == 0))
281 return((const CoderInfo *) NULL);
282 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
284 ResetSplayTreeIterator(coder_list);
285 return((const CoderInfo *) GetNextValueInSplayTree(coder_list));
287 return((const CoderInfo *) GetValueFromSplayTree(coder_list,name));
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295 % G e t C o d e r I n f o L i s t %
299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 % GetCoderInfoList() returns any coder_map that match the specified pattern.
302 % The format of the GetCoderInfoList function is:
304 % const CoderInfo **GetCoderInfoList(const char *pattern,
305 % unsigned long *number_coders,ExceptionInfo *exception)
307 % A description of each parameter follows:
309 % o pattern: Specifies a pointer to a text string containing a pattern.
311 % o number_coders: This integer returns the number of coders in the list.
313 % o exception: return any errors or warnings in this structure.
317 static int CoderInfoCompare(const void *x,const void *y)
323 p=(const CoderInfo **) x,
324 q=(const CoderInfo **) y;
325 if (LocaleCompare((*p)->path,(*q)->path) == 0)
326 return(LocaleCompare((*p)->name,(*q)->name));
327 return(LocaleCompare((*p)->path,(*q)->path));
330 MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
331 unsigned long *number_coders,ExceptionInfo *exception)
336 register const CoderInfo
345 assert(pattern != (char *) NULL);
346 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
347 assert(number_coders != (unsigned long *) NULL);
349 p=GetCoderInfo("*",exception);
350 if (p == (const CoderInfo *) NULL)
351 return((const CoderInfo **) NULL);
352 coder_map=(const CoderInfo **) AcquireQuantumMemory((size_t)
353 GetNumberOfNodesInSplayTree(coder_list)+1UL,sizeof(*coder_map));
354 if (coder_map == (const CoderInfo **) NULL)
355 return((const CoderInfo **) NULL);
359 AcquireSemaphoreInfo(&coder_semaphore);
360 ResetSplayTreeIterator(coder_list);
361 p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
362 for (i=0; p != (const CoderInfo *) NULL; )
364 if ((p->stealth == MagickFalse) &&
365 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
367 p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
369 RelinquishSemaphoreInfo(coder_semaphore);
370 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
371 coder_map[i]=(CoderInfo *) NULL;
372 *number_coders=(unsigned long) i;
377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381 % G e t C o d e r L i s t %
385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387 % GetCoderList() returns any coder_map that match the specified pattern.
389 % The format of the GetCoderList function is:
391 % char **GetCoderList(const char *pattern,unsigned long *number_coders,
392 % ExceptionInfo *exception)
394 % A description of each parameter follows:
396 % o pattern: Specifies a pointer to a text string containing a pattern.
398 % o number_coders: This integer returns the number of coders in the list.
400 % o exception: return any errors or warnings in this structure.
404 static int CoderCompare(const void *x,const void *y)
412 return(LocaleCompare(*p,*q));
415 MagickExport char **GetCoderList(const char *pattern,
416 unsigned long *number_coders,ExceptionInfo *exception)
421 register const CoderInfo
430 assert(pattern != (char *) NULL);
431 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
432 assert(number_coders != (unsigned long *) NULL);
434 p=GetCoderInfo("*",exception);
435 if (p == (const CoderInfo *) NULL)
436 return((char **) NULL);
437 coder_map=(char **) AcquireQuantumMemory((size_t)
438 GetNumberOfNodesInSplayTree(coder_list)+1UL,sizeof(*coder_map));
439 if (coder_map == (char **) NULL)
440 return((char **) NULL);
444 AcquireSemaphoreInfo(&coder_semaphore);
445 ResetSplayTreeIterator(coder_list);
446 p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
447 for (i=0; p != (const CoderInfo *) NULL; )
449 if ((p->stealth == MagickFalse) &&
450 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
451 coder_map[i++]=ConstantString(p->name);
452 p=(const CoderInfo *) GetNextValueInSplayTree(coder_list);
454 RelinquishSemaphoreInfo(coder_semaphore);
455 qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
456 coder_map[i]=(char *) NULL;
457 *number_coders=(unsigned long) i;
462 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
466 + I n i t i a l i z e C o d e r L i s t %
470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
472 % InitializeCoderList() initializes the coder list.
474 % The format of the InitializeCoderList method is:
476 % MagickBooleanType InitializeCoderList(ExceptionInfo *exception)
478 % A description of each parameter follows.
480 % o exception: return any errors or warnings in this structure.
483 static MagickBooleanType InitializeCoderList(ExceptionInfo *exception)
485 if ((coder_list == (SplayTreeInfo *) NULL) &&
486 (instantiate_coder == MagickFalse))
488 AcquireSemaphoreInfo(&coder_semaphore);
489 if ((coder_list == (SplayTreeInfo *) NULL) &&
490 (instantiate_coder == MagickFalse))
492 (void) LoadCoderLists(MagickCoderFilename,exception);
493 instantiate_coder=MagickTrue;
495 RelinquishSemaphoreInfo(coder_semaphore);
497 return(coder_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 % L i s t C o d e r I n f o %
509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 % ListCoderInfo() lists the coder info to a file.
513 % The format of the ListCoderInfo coder is:
515 % MagickBooleanType ListCoderInfo(FILE *file,ExceptionInfo *exception)
517 % A description of each parameter follows.
519 % o file: An pointer to a FILE.
521 % o exception: return any errors or warnings in this structure.
524 MagickExport MagickBooleanType ListCoderInfo(FILE *file,
525 ExceptionInfo *exception)
542 if (file == (const FILE *) NULL)
544 coder_info=GetCoderInfoList("*",&number_coders,exception);
545 if (coder_info == (const CoderInfo **) NULL)
547 path=(const char *) NULL;
548 for (i=0; i < (long) number_coders; i++)
550 if (coder_info[i]->stealth != MagickFalse)
552 if ((path == (const char *) NULL) ||
553 (LocaleCompare(path,coder_info[i]->path) != 0))
555 if (coder_info[i]->path != (char *) NULL)
556 (void) fprintf(file,"\nPath: %s\n\n",coder_info[i]->path);
557 (void) fprintf(file,"Magick Coder\n");
558 (void) fprintf(file,"-------------------------------------------------"
559 "------------------------------\n");
561 path=coder_info[i]->path;
562 (void) fprintf(file,"%s",coder_info[i]->magick);
563 for (j=(long) strlen(coder_info[i]->magick); j <= 11; j++)
564 (void) fprintf(file," ");
565 if (coder_info[i]->name != (char *) NULL)
566 (void) fprintf(file,"%s",coder_info[i]->name);
567 (void) fprintf(file,"\n");
569 coder_info=(const CoderInfo **) RelinquishMagickMemory((void *) coder_info);
575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
579 + L o a d C o d e r L i s t %
583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % LoadCoderList() loads the coder configuration file which provides a
586 % mapping between coder attributes and a coder name.
588 % The format of the LoadCoderList coder is:
590 % MagickBooleanType LoadCoderList(const char *xml,const char *filename,
591 % const unsigned long depth,ExceptionInfo *exception)
593 % A description of each parameter follows:
595 % o xml: The coder list in XML format.
597 % o filename: The coder list filename.
599 % o depth: depth of <include /> statements.
601 % o exception: return any errors or warnings in this structure.
605 static void *DestroyCoderNode(void *coder_info)
610 p=(CoderInfo *) coder_info;
611 if (p->path != (char *) NULL)
612 p->path=DestroyString(p->path);
613 if (p->name != (char *) NULL)
614 p->name=DestroyString(p->name);
615 if (p->magick != (char *) NULL)
616 p->magick=DestroyString(p->magick);
617 return(RelinquishMagickMemory(p));
620 static MagickBooleanType LoadCoderList(const char *xml,const char *filename,
621 const unsigned long depth,ExceptionInfo *exception)
624 keyword[MaxTextExtent],
637 Load the coder map file.
639 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
640 "Loading coder configuration file \"%s\" ...",filename);
641 if (xml == (const char *) NULL)
643 if (coder_list == (SplayTreeInfo *) NULL)
645 coder_list=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
647 if (coder_list == (SplayTreeInfo *) NULL)
649 ThrowFileException(exception,ResourceLimitError,
650 "MemoryAllocationFailed",filename);
655 coder_info=(CoderInfo *) NULL;
656 token=AcquireString(xml);
657 for (q=(char *) xml; *q != '\0'; )
662 GetMagickToken(q,&q,token);
665 (void) CopyMagickString(keyword,token,MaxTextExtent);
666 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
671 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
672 GetMagickToken(q,&q,token);
675 if (LocaleNCompare(keyword,"<!--",4) == 0)
680 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
681 GetMagickToken(q,&q,token);
684 if (LocaleCompare(keyword,"<include") == 0)
689 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
691 (void) CopyMagickString(keyword,token,MaxTextExtent);
692 GetMagickToken(q,&q,token);
695 GetMagickToken(q,&q,token);
696 if (LocaleCompare(keyword,"file") == 0)
699 (void) ThrowMagickException(exception,GetMagickModule(),
700 ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
707 GetPathComponent(filename,HeadPath,path);
709 (void) ConcatenateMagickString(path,DirectorySeparator,
711 if (*token == *DirectorySeparator)
712 (void) CopyMagickString(path,token,MaxTextExtent);
714 (void) ConcatenateMagickString(path,token,MaxTextExtent);
715 xml=FileToString(path,~0,exception);
716 if (xml != (char *) NULL)
718 status=LoadCoderList(xml,path,depth+1,exception);
719 xml=(char *) RelinquishMagickMemory(xml);
726 if (LocaleCompare(keyword,"<coder") == 0)
731 coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
732 if (coder_info == (CoderInfo *) NULL)
733 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
734 (void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
735 coder_info->path=ConstantString(filename);
736 coder_info->signature=MagickSignature;
739 if (coder_info == (CoderInfo *) NULL)
741 if (LocaleCompare(keyword,"/>") == 0)
743 status=AddValueToSplayTree(coder_list,ConstantString(
744 coder_info->magick),coder_info);
745 if (status == MagickFalse)
746 (void) ThrowMagickException(exception,GetMagickModule(),
747 ResourceLimitError,"MemoryAllocationFailed","`%s'",
749 coder_info=(CoderInfo *) NULL;
751 GetMagickToken(q,(const char **) NULL,token);
754 GetMagickToken(q,&q,token);
755 GetMagickToken(q,&q,token);
761 if (LocaleCompare((char *) keyword,"magick") == 0)
763 coder_info->magick=ConstantString(token);
771 if (LocaleCompare((char *) keyword,"name") == 0)
773 coder_info->name=ConstantString(token);
781 if (LocaleCompare((char *) keyword,"stealth") == 0)
783 coder_info->stealth=IsMagickTrue(token);
792 token=(char *) RelinquishMagickMemory(token);
797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
801 % L o a d C o d e r L i s t s %
805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807 % LoadCoderLists() loads one or more coder configuration file which
808 % provides a mapping between coder attributes and a coder name.
810 % The format of the LoadCoderLists coder is:
812 % MagickBooleanType LoadCoderLists(const char *filename,
813 % ExceptionInfo *exception)
815 % A description of each parameter follows:
817 % o filename: the font file name.
819 % o exception: return any errors or warnings in this structure.
822 static MagickBooleanType LoadCoderLists(const char *filename,
823 ExceptionInfo *exception)
825 #if defined(MAGICKCORE_EMBEDDABLE_SUPPORT)
826 return(LoadCoderList(CoderMap,"built-in",0,exception));
838 options=GetConfigureOptions(filename,exception);
839 option=(const StringInfo *) GetNextValueInLinkedList(options);
840 while (option != (const StringInfo *) NULL)
842 status|=LoadCoderList((const char *) GetStringInfoDatum(option),
843 GetStringInfoPath(option),0,exception);
844 option=(const StringInfo *) GetNextValueInLinkedList(options);
846 options=DestroyConfigureOptions(options);
847 if ((coder_list == (SplayTreeInfo *) NULL) ||
848 (GetNumberOfNodesInSplayTree(coder_list) == 0))
849 status|=LoadCoderList(CoderMap,"built-in",0,exception);
850 return(status != 0 ? MagickTrue : MagickFalse);