42 #include "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/client.h"
45 #include "magick/configure.h"
46 #include "magick/exception.h"
47 #include "magick/exception-private.h"
48 #include "magick/hashmap.h"
49 #include "magick/magic.h"
50 #include "magick/memory_.h"
51 #include "magick/semaphore.h"
52 #include "magick/string_.h"
53 #include "magick/string-private.h"
54 #include "magick/token.h"
55 #include "magick/utility.h"
56 #include "magick/xml-tree.h"
57 #include "magick/xml-tree-private.h"
62 #define MagicFilename "magic.xml"
63 #define MagicPattern(magic) (const unsigned char *) (magic), sizeof(magic)-1
73 const MagickOffsetType
89 {
"8BIMWTEXT", 0, MagicPattern(
"8\000B\000I\000M\000#") },
90 {
"8BIMTEXT", 0, MagicPattern(
"8BIM#") },
91 {
"8BIM", 0, MagicPattern(
"8BIM") },
92 {
"AVIF", 4, MagicPattern(
"ftypavif") },
93 {
"BMP", 0, MagicPattern(
"BA") },
94 {
"BMP", 0, MagicPattern(
"BM") },
95 {
"BMP", 0, MagicPattern(
"CI") },
96 {
"BMP", 0, MagicPattern(
"CP") },
97 {
"BMP", 0, MagicPattern(
"IC") },
98 {
"PICT", 0, MagicPattern(
"PICT") },
99 {
"BMP", 0, MagicPattern(
"PI") },
100 {
"CALS", 21, MagicPattern(
"version: MIL-STD-1840") },
101 {
"CALS", 0, MagicPattern(
"srcdocid:") },
102 {
"CALS", 9, MagicPattern(
"srcdocid:") },
103 {
"CALS", 8, MagicPattern(
"rorient:") },
104 {
"CGM", 0, MagicPattern(
"BEGMF") },
105 {
"CIN", 0, MagicPattern(
"\200\052\137\327") },
106 {
"CR2", 0, MagicPattern(
"II\x2a\x00\x10\x00\x00\x00CR\x02") },
107 {
"CR2", 0, MagicPattern(
"MM\x00\x2a\x00\x10\x00\x00RC\x02") },
108 {
"CRW", 0, MagicPattern(
"II\x1a\x00\x00\x00HEAPCCDR") },
109 {
"DCM", 128, MagicPattern(
"DICM") },
110 {
"DCX", 0, MagicPattern(
"\261\150\336\72") },
111 {
"DIB", 0, MagicPattern(
"\050\000") },
112 {
"DDS", 0, MagicPattern(
"DDS ") },
113 {
"DJVU", 0, MagicPattern(
"AT&TFORM") },
114 {
"DOT", 0, MagicPattern(
"digraph") },
115 {
"DPX", 0, MagicPattern(
"SDPX") },
116 {
"DPX", 0, MagicPattern(
"XPDS") },
117 {
"EMF", 40, MagicPattern(
"\040\105\115\106\000\000\001\000") },
118 {
"EPT", 0, MagicPattern(
"\305\320\323\306") },
119 {
"EXR", 0, MagicPattern(
"\166\057\061\001") },
120 {
"FAX", 0, MagicPattern(
"DFAX") },
121 {
"FIG", 0, MagicPattern(
"#FIG") },
122 {
"FITS", 0, MagicPattern(
"IT0") },
123 {
"FITS", 0, MagicPattern(
"SIMPLE") },
124 {
"FLIF", 0, MagicPattern(
"FLIF") },
125 {
"GIF", 0, MagicPattern(
"GIF8") },
126 {
"GPLT", 0, MagicPattern(
"#!/usr/local/bin/gnuplot") },
127 {
"HDF", 1, MagicPattern(
"HDF") },
128 {
"HDR", 0, MagicPattern(
"#?RADIANCE") },
129 {
"HDR", 0, MagicPattern(
"#?RGBE") },
130 {
"HEIC", 4, MagicPattern(
"ftypheic") },
131 {
"HEIC", 4, MagicPattern(
"ftypheix") },
132 {
"HEIC", 4, MagicPattern(
"ftypmif1") },
133 {
"HPGL", 0, MagicPattern(
"IN;") },
134 {
"HTML", 1, MagicPattern(
"HTML") },
135 {
"HTML", 1, MagicPattern(
"html") },
136 {
"ILBM", 8, MagicPattern(
"ILBM") },
137 {
"IPTCWTEXT", 0, MagicPattern(
"\062\000#\000\060\000=\000\042\000&\000#\000\060\000;\000&\000#\000\062\000;\000\042\000") },
138 {
"IPTCTEXT", 0, MagicPattern(
"2#0=\042�\042") },
139 {
"IPTC", 0, MagicPattern(
"\034\002") },
140 {
"JNG", 0, MagicPattern(
"\213JNG\r\n\032\n") },
141 {
"JPEG", 0, MagicPattern(
"\377\330\377") },
142 {
"J2K", 0, MagicPattern(
"\xff\x4f\xff\x51") },
143 {
"JPC", 0, MagicPattern(
"\x0d\x0a\x87\x0a") },
144 {
"JP2", 0, MagicPattern(
"\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a") },
145 {
"JXL", 0, MagicPattern(
"\xff\x0a") },
146 {
"JXL", 0, MagicPattern(
"\x00\x00\x00\x0c\x4a\x58\x4c\x20\x0d\x0a\x87\x0a") },
147 {
"MAT", 0, MagicPattern(
"MATLAB 5.0 MAT-file,") },
148 {
"MIFF", 0, MagicPattern(
"Id=ImageMagick") },
149 {
"MIFF", 0, MagicPattern(
"id=ImageMagick") },
150 {
"MNG", 0, MagicPattern(
"\212MNG\r\n\032\n") },
151 {
"MPC", 0, MagicPattern(
"id=MagickCache") },
152 {
"MPEG", 0, MagicPattern(
"\000\000\001\263") },
153 {
"MRW", 0, MagicPattern(
"\x00MRM") },
154 {
"ORF", 0, MagicPattern(
"IIRO\x08\x00\x00\x00") },
155 {
"PCD", 2048, MagicPattern(
"PCD_") },
156 {
"PCL", 0, MagicPattern(
"\033E\033") },
157 {
"PCX", 0, MagicPattern(
"\012\002") },
158 {
"PCX", 0, MagicPattern(
"\012\005") },
159 {
"PDB", 60, MagicPattern(
"vIMGView") },
160 {
"PDF", 0, MagicPattern(
"%PDF-") },
161 {
"PES", 0, MagicPattern(
"#PES") },
162 {
"PFA", 0, MagicPattern(
"%!PS-AdobeFont-1.0") },
163 {
"PFB", 6, MagicPattern(
"%!PS-AdobeFont-1.0") },
164 {
"PGX", 0, MagicPattern(
"PG ML") },
165 {
"PGX", 0, MagicPattern(
"PG LM") },
166 {
"PICT", 522, MagicPattern(
"\000\021\002\377\014\000") },
167 {
"PNG", 0, MagicPattern(
"\211PNG\r\n\032\n") },
168 {
"PBM", 0, MagicPattern(
"P1") },
169 {
"PGM", 0, MagicPattern(
"P2") },
170 {
"PPM", 0, MagicPattern(
"P3") },
171 {
"PBM", 0, MagicPattern(
"P4") },
172 {
"PGM", 0, MagicPattern(
"P5") },
173 {
"PPM", 0, MagicPattern(
"P6") },
174 {
"PAM", 0, MagicPattern(
"P7") },
175 {
"PFM", 0, MagicPattern(
"PF") },
176 {
"PFM", 0, MagicPattern(
"Pf") },
177 {
"PS", 0, MagicPattern(
"%!") },
178 {
"PS", 0, MagicPattern(
"\004%!") },
179 {
"PS", 0, MagicPattern(
"\305\320\323\306") },
180 {
"PSB", 0, MagicPattern(
"8BPB") },
181 {
"PSD", 0, MagicPattern(
"8BPS") },
182 {
"PWP", 0, MagicPattern(
"SFW95") },
183 {
"RAF", 0, MagicPattern(
"FUJIFILMCCD-RAW ") },
184 {
"RAW", 0, MagicPattern(
"IIU\x00\x08\x00\x00\x00") },
185 {
"RW2", 0, MagicPattern(
"IIU\x00\x18\x00\x00\x00") },
186 {
"RLE", 0, MagicPattern(
"\122\314") },
187 {
"SCT", 0, MagicPattern(
"CT") },
188 {
"SFW", 0, MagicPattern(
"SFW94") },
189 {
"SGI", 0, MagicPattern(
"\001\332") },
190 {
"SUN", 0, MagicPattern(
"\131\246\152\225") },
191 {
"SVG", 1, MagicPattern(
"?XML") },
192 {
"SVG", 1, MagicPattern(
"?xml") },
193 {
"SVG", 1, MagicPattern(
"SVG") },
194 {
"SVG", 1, MagicPattern(
"svg") },
195 {
"TIFF", 0, MagicPattern(
"\115\115\000\052") },
196 {
"TIFF", 0, MagicPattern(
"\111\111\052\000") },
197 {
"TIFF64", 0, MagicPattern(
"\115\115\000\053\000\010\000\000") },
198 {
"TIFF64", 0, MagicPattern(
"\111\111\053\000\010\000\000\000") },
199 {
"TTF", 0, MagicPattern(
"\000\001\000\000\000") },
200 {
"TXT", 0, MagicPattern(
"# ImageMagick pixel enumeration:") },
201 {
"VICAR", 0, MagicPattern(
"LBLSIZE") },
202 {
"VICAR", 0, MagicPattern(
"NJPL1I") },
203 {
"VIFF", 0, MagicPattern(
"\253\001") },
204 {
"WEBP", 8, MagicPattern(
"WEBP") },
205 {
"WMF", 0, MagicPattern(
"\327\315\306\232") },
206 {
"WMF", 0, MagicPattern(
"\001\000\011\000") },
207 {
"WPG", 0, MagicPattern(
"\377WPC") },
208 {
"XBM", 0, MagicPattern(
"#define") },
209 {
"XCF", 0, MagicPattern(
"gimp xcf") },
210 {
"XEF", 0, MagicPattern(
"FOVb") },
211 {
"XPM", 1, MagicPattern(
"* XPM *") }
223 static MagickBooleanType
226 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
227 static MagickBooleanType
228 LoadMagicCache(
LinkedListInfo *,
const char *,
const char *,
const size_t,
258 static int CompareMagickInfoSize(
const void *a,
const void *b)
266 if (ma->offset != mb->offset)
267 return((
int) (ma->offset-mb->offset));
268 return((
int) (mb->length-(ssize_t) ma->length));
283 cache=NewLinkedList(0);
285 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
290 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
302 options=GetConfigureOptions(filename,exception);
303 option=(
const StringInfo *) GetNextValueInLinkedList(options);
306 (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
307 status&=LoadMagicCache(cache,(
const char *)
308 GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
309 option=(
const StringInfo *) GetNextValueInLinkedList(options);
311 options=DestroyConfigureOptions(options);
317 for (i=0; i < (ssize_t) (
sizeof(MagicMap)/
sizeof(*MagicMap)); i++)
326 magic_info=(
MagicInfo *) AcquireMagickMemory(
sizeof(*magic_info));
329 (void) ThrowMagickException(exception,GetMagickModule(),
330 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",p->name);
333 (void) memset(magic_info,0,
sizeof(*magic_info));
334 magic_info->path=(
char *)
"[built-in]";
335 magic_info->name=(
char *) p->name;
336 magic_info->offset=p->offset;
337 magic_info->target=(
char *) p->magic;
338 magic_info->magic=(
unsigned char *) p->magic;
339 magic_info->length=p->length;
340 magic_info->exempt=MagickTrue;
341 magic_info->signature=MagickCoreSignature;
342 status&=InsertValueInSortedLinkedList(cache,CompareMagickInfoSize,
344 if (status == MagickFalse)
345 (void) ThrowMagickException(exception,GetMagickModule(),
346 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",magic_info->name);
380 MagickExport
const MagicInfo *GetMagicInfo(
const unsigned char *magic,
387 if (IsMagicCacheInstantiated(exception) == MagickFalse)
392 LockSemaphoreInfo(magic_semaphore);
393 ResetLinkedListIterator(magic_cache);
394 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
395 if (magic == (
const unsigned char *) NULL)
397 UnlockSemaphoreInfo(magic_semaphore);
408 assert(p->offset >= 0);
410 remaining=(MagickOffsetType) length-p->offset;
411 if (LocaleCompare(p->name,
"SVG") == 0)
412 while ((remaining > 0) && (isspace(*q) != 0))
417 if ((remaining >= (MagickOffsetType) p->length) &&
418 (memcmp(q,p->magic,p->length) == 0))
420 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
423 (
void) InsertValueInLinkedList(magic_cache,0,
424 RemoveElementByValueFromLinkedList(magic_cache,p));
425 UnlockSemaphoreInfo(magic_semaphore);
458 #if defined(__cplusplus) || defined(c_plusplus)
462 static int MagicInfoCompare(
const void *x,
const void *y)
470 if (LocaleCompare((*p)->path,(*q)->path) == 0)
471 return(LocaleCompare((*p)->name,(*q)->name));
472 return(LocaleCompare((*p)->path,(*q)->path));
475 #if defined(__cplusplus) || defined(c_plusplus)
479 MagickExport
const MagicInfo **GetMagicInfoList(
const char *pattern,
494 assert(pattern != (
char *) NULL);
495 assert(number_aliases != (
size_t *) NULL);
496 if (IsEventLogging() != MagickFalse)
497 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
499 p=GetMagicInfo((
const unsigned char *) NULL,0,exception);
502 aliases=(
const MagicInfo **) AcquireQuantumMemory((
size_t)
503 GetNumberOfElementsInLinkedList(magic_cache)+1UL,
sizeof(*aliases));
504 if (aliases == (
const MagicInfo **) NULL)
509 LockSemaphoreInfo(magic_semaphore);
510 ResetLinkedListIterator(magic_cache);
511 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
512 for (i=0; p != (
const MagicInfo *) NULL; )
514 if ((p->stealth == MagickFalse) &&
515 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
517 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
519 UnlockSemaphoreInfo(magic_semaphore);
520 qsort((
void *) aliases,(
size_t) i,
sizeof(*aliases),MagicInfoCompare);
522 *number_aliases=(size_t) i;
556 #if defined(__cplusplus) || defined(c_plusplus)
560 static int MagicCompare(
const void *x,
const void *y)
568 return(LocaleCompare(p,q));
571 #if defined(__cplusplus) || defined(c_plusplus)
575 MagickExport
char **GetMagicList(
const char *pattern,
size_t *number_aliases,
590 assert(pattern != (
char *) NULL);
591 assert(number_aliases != (
size_t *) NULL);
592 if (IsEventLogging() != MagickFalse)
593 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
595 p=GetMagicInfo((
const unsigned char *) NULL,0,exception);
597 return((
char **) NULL);
598 aliases=(
char **) AcquireQuantumMemory((
size_t)
599 GetNumberOfElementsInLinkedList(magic_cache)+1UL,
sizeof(*aliases));
600 if (aliases == (
char **) NULL)
601 return((
char **) NULL);
602 LockSemaphoreInfo(magic_semaphore);
603 ResetLinkedListIterator(magic_cache);
604 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
605 for (i=0; p != (
const MagicInfo *) NULL; )
607 if ((p->stealth == MagickFalse) &&
608 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
609 aliases[i++]=ConstantString(p->name);
610 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
612 UnlockSemaphoreInfo(magic_semaphore);
613 qsort((
void *) aliases,(
size_t) i,
sizeof(*aliases),MagicCompare);
614 aliases[i]=(
char *) NULL;
615 *number_aliases=(size_t) i;
641 MagickExport
const char *GetMagicName(
const MagicInfo *magic_info)
643 assert(magic_info != (
MagicInfo *) NULL);
644 assert(magic_info->signature == MagickCoreSignature);
645 if (IsEventLogging() != MagickFalse)
646 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
647 return(magic_info->name);
673 static MagickBooleanType IsMagicCacheInstantiated(
ExceptionInfo *exception)
678 ActivateSemaphoreInfo(&magic_semaphore);
679 LockSemaphoreInfo(magic_semaphore);
681 magic_cache=AcquireMagicCache(MagicFilename,exception);
682 UnlockSemaphoreInfo(magic_semaphore);
684 return(magic_cache != (
LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
711 MagickExport MagickBooleanType ListMagicInfo(FILE *file,
729 if (file == (
const FILE *) NULL)
731 magic_info=GetMagicInfoList(
"*",&number_aliases,exception);
732 if (magic_info == (
const MagicInfo **) NULL)
735 path=(
const char *) NULL;
736 for (i=0; i < (ssize_t) number_aliases; i++)
738 if (magic_info[i]->stealth != MagickFalse)
740 if ((path == (
const char *) NULL) ||
741 (LocaleCompare(path,magic_info[i]->path) != 0))
743 if (magic_info[i]->path != (
char *) NULL)
744 (
void) FormatLocaleFile(file,
"\nPath: %s\n\n",magic_info[i]->path);
745 (void) FormatLocaleFile(file,
"Name Offset Target\n");
746 (void) FormatLocaleFile(file,
747 "-------------------------------------------------"
748 "------------------------------\n");
750 path=magic_info[i]->path;
751 (void) FormatLocaleFile(file,
"%s",magic_info[i]->name);
752 for (j=(ssize_t) strlen(magic_info[i]->name); j <= 9; j++)
753 (
void) FormatLocaleFile(file,
" ");
754 (void) FormatLocaleFile(file,
"%6ld ",(
long) magic_info[i]->offset);
755 if (magic_info[i]->target != (
char *) NULL)
760 for (j=0; magic_info[i]->target[j] !=
'\0'; j++)
761 if (isprint((
int) ((
unsigned char) magic_info[i]->target[j])) != 0)
762 (
void) FormatLocaleFile(file,
"%c",magic_info[i]->target[j]);
764 (
void) FormatLocaleFile(file,
"\\%03o",(
unsigned int)
765 ((
unsigned char) magic_info[i]->target[j]));
767 (void) FormatLocaleFile(file,
"\n");
770 magic_info=(
const MagicInfo **) RelinquishMagickMemory((
void *) magic_info);
774 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
805 static MagickBooleanType LoadMagicCache(
LinkedListInfo *cache,
const char *xml,
806 const char *filename,
const size_t depth,
ExceptionInfo *exception)
809 keyword[MaxTextExtent],
827 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
828 "Loading magic configure file \"%s\" ...",filename);
829 if (xml == (
char *) NULL)
833 token=AcquireString(xml);
834 extent=strlen(token)+MaxTextExtent;
835 for (q=(
char *) xml; *q !=
'\0'; )
840 (void) GetNextToken(q,&q,extent,token);
843 (void) CopyMagickString(keyword,token,MaxTextExtent);
844 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
849 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
850 (
void) GetNextToken(q,&q,extent,token);
853 if (LocaleNCompare(keyword,
"<!--",4) == 0)
858 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
859 (void) GetNextToken(q,&q,extent,token);
862 if (LocaleCompare(keyword,
"<include") == 0)
867 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
869 (void) CopyMagickString(keyword,token,MaxTextExtent);
870 (void) GetNextToken(q,&q,extent,token);
873 (void) GetNextToken(q,&q,extent,token);
874 if (LocaleCompare(keyword,
"file") == 0)
876 if (depth > MagickMaxRecursionDepth)
877 (void) ThrowMagickException(exception,GetMagickModule(),
878 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
885 GetPathComponent(filename,HeadPath,path);
887 (void) ConcatenateMagickString(path,DirectorySeparator,
889 if (*token == *DirectorySeparator)
890 (void) CopyMagickString(path,token,MaxTextExtent);
892 (
void) ConcatenateMagickString(path,token,MaxTextExtent);
893 xml=FileToXML(path,~0UL);
894 if (xml != (
char *) NULL)
896 status&=LoadMagicCache(cache,xml,path,depth+1,
898 xml=(
char *) RelinquishMagickMemory(xml);
905 if (LocaleCompare(keyword,
"<magic") == 0)
910 magic_info=(
MagicInfo *) AcquireMagickMemory(
sizeof(*magic_info));
912 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
913 (void) memset(magic_info,0,
sizeof(*magic_info));
914 magic_info->path=ConstantString(filename);
915 magic_info->exempt=MagickFalse;
916 magic_info->signature=MagickCoreSignature;
921 if ((LocaleCompare(keyword,
"/>") == 0) ||
922 (LocaleCompare(keyword,
"</policy>") == 0))
924 status=AppendValueToLinkedList(cache,magic_info);
925 if (status == MagickFalse)
926 (void) ThrowMagickException(exception,GetMagickModule(),
927 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
932 (void) GetNextToken(q,(
const char **) NULL,extent,token);
935 (void) GetNextToken(q,&q,extent,token);
936 (void) GetNextToken(q,&q,extent,token);
942 if (LocaleCompare((
char *) keyword,
"name") == 0)
944 magic_info->name=ConstantString(token);
952 if (LocaleCompare((
char *) keyword,
"offset") == 0)
954 magic_info->offset=(MagickOffsetType) StringToLong(token);
962 if (LocaleCompare((
char *) keyword,
"stealth") == 0)
964 magic_info->stealth=IsMagickTrue(token);
972 if (LocaleCompare((
char *) keyword,
"target") == 0)
983 length=strlen(token);
984 magic_info->target=ConstantString(token);
985 magic_info->magic=(
unsigned char *) ConstantString(token);
987 for (p=magic_info->target; *p !=
'\0'; )
992 if (isdigit((
int) ((
unsigned char) *p)) != 0)
997 *q++=(
unsigned char) strtol(p,&end,8);
998 p+=(ptrdiff_t) (end-p);
999 magic_info->length++;
1004 case 'b': *q=
'\b';
break;
1005 case 'f': *q=
'\f';
break;
1006 case 'n': *q=
'\n';
break;
1007 case 'r': *q=
'\r';
break;
1008 case 't': *q=
'\t';
break;
1009 case 'v': *q=
'\v';
break;
1010 case 'a': *q=
'a';
break;
1011 case '?': *q=
'\?';
break;
1012 default: *q=(
unsigned char) (*p);
break;
1016 magic_info->length++;
1020 if (LocaleNCompare(p,
"&",5) == 0)
1021 (
void) CopyMagickString(p+1,p+5,length-magic_info->length);
1022 *q++=(
unsigned char) (*p++);
1023 magic_info->length++;
1033 token=(
char *) RelinquishMagickMemory(token);
1034 return(status != 0 ? MagickTrue : MagickFalse);
1056 MagickExport MagickBooleanType MagicComponentGenesis(
void)
1059 magic_semaphore=AllocateSemaphoreInfo();
1082 static void *DestroyMagicElement(
void *magic_info)
1088 if (p->exempt == MagickFalse)
1090 if (p->path != (
char *) NULL)
1091 p->path=DestroyString(p->path);
1092 if (p->name != (
char *) NULL)
1093 p->name=DestroyString(p->name);
1094 if (p->target != (
char *) NULL)
1095 p->target=DestroyString(p->target);
1096 if (p->magic != (
unsigned char *) NULL)
1097 p->magic=(
unsigned char *) RelinquishMagickMemory(p->magic);
1099 p=(
MagicInfo *) RelinquishMagickMemory(p);
1100 return((
void *) NULL);
1103 MagickExport
void MagicComponentTerminus(
void)
1106 ActivateSemaphoreInfo(&magic_semaphore);
1107 LockSemaphoreInfo(magic_semaphore);
1109 magic_cache=DestroyLinkedList(magic_cache,DestroyMagicElement);
1110 UnlockSemaphoreInfo(magic_semaphore);
1111 DestroySemaphoreInfo(&magic_semaphore);