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 {
"CRW", 0, MagicPattern(
"II\x1a\x00\x00\x00HEAPCCDR") },
107 {
"DCM", 128, MagicPattern(
"DICM") },
108 {
"DCX", 0, MagicPattern(
"\261\150\336\72") },
109 {
"DIB", 0, MagicPattern(
"\050\000") },
110 {
"DDS", 0, MagicPattern(
"DDS ") },
111 {
"DJVU", 0, MagicPattern(
"AT&TFORM") },
112 {
"DOT", 0, MagicPattern(
"digraph") },
113 {
"DPX", 0, MagicPattern(
"SDPX") },
114 {
"DPX", 0, MagicPattern(
"XPDS") },
115 {
"EMF", 40, MagicPattern(
"\040\105\115\106\000\000\001\000") },
116 {
"EPT", 0, MagicPattern(
"\305\320\323\306") },
117 {
"EXR", 0, MagicPattern(
"\166\057\061\001") },
118 {
"FAX", 0, MagicPattern(
"DFAX") },
119 {
"FIG", 0, MagicPattern(
"#FIG") },
120 {
"FITS", 0, MagicPattern(
"IT0") },
121 {
"FITS", 0, MagicPattern(
"SIMPLE") },
122 {
"FLIF", 0, MagicPattern(
"FLIF") },
123 {
"GIF", 0, MagicPattern(
"GIF8") },
124 {
"GPLT", 0, MagicPattern(
"#!/usr/local/bin/gnuplot") },
125 {
"HDF", 1, MagicPattern(
"HDF") },
126 {
"HDR", 0, MagicPattern(
"#?RADIANCE") },
127 {
"HDR", 0, MagicPattern(
"#?RGBE") },
128 {
"HEIC", 4, MagicPattern(
"ftypheic") },
129 {
"HEIC", 4, MagicPattern(
"ftypheix") },
130 {
"HEIC", 4, MagicPattern(
"ftypmif1") },
131 {
"HPGL", 0, MagicPattern(
"IN;") },
132 {
"HTML", 1, MagicPattern(
"HTML") },
133 {
"HTML", 1, MagicPattern(
"html") },
134 {
"ILBM", 8, MagicPattern(
"ILBM") },
135 {
"IPTCWTEXT", 0, MagicPattern(
"\062\000#\000\060\000=\000\042\000&\000#\000\060\000;\000&\000#\000\062\000;\000\042\000") },
136 {
"IPTCTEXT", 0, MagicPattern(
"2#0=\042�\042") },
137 {
"IPTC", 0, MagicPattern(
"\034\002") },
138 {
"JNG", 0, MagicPattern(
"\213JNG\r\n\032\n") },
139 {
"JPEG", 0, MagicPattern(
"\377\330\377") },
140 {
"J2K", 0, MagicPattern(
"\xff\x4f\xff\x51") },
141 {
"JPC", 0, MagicPattern(
"\x0d\x0a\x87\x0a") },
142 {
"JP2", 0, MagicPattern(
"\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a") },
143 {
"MAT", 0, MagicPattern(
"MATLAB 5.0 MAT-file,") },
144 {
"MIFF", 0, MagicPattern(
"Id=ImageMagick") },
145 {
"MIFF", 0, MagicPattern(
"id=ImageMagick") },
146 {
"MNG", 0, MagicPattern(
"\212MNG\r\n\032\n") },
147 {
"MPC", 0, MagicPattern(
"id=MagickCache") },
148 {
"MPEG", 0, MagicPattern(
"\000\000\001\263") },
149 {
"MRW", 0, MagicPattern(
"\x00MRM") },
150 {
"ORF", 0, MagicPattern(
"IIRO\x08\x00\x00\x00") },
151 {
"PCD", 2048, MagicPattern(
"PCD_") },
152 {
"PCL", 0, MagicPattern(
"\033E\033") },
153 {
"PCX", 0, MagicPattern(
"\012\002") },
154 {
"PCX", 0, MagicPattern(
"\012\005") },
155 {
"PDB", 60, MagicPattern(
"vIMGView") },
156 {
"PDF", 0, MagicPattern(
"%PDF-") },
157 {
"PES", 0, MagicPattern(
"#PES") },
158 {
"PFA", 0, MagicPattern(
"%!PS-AdobeFont-1.0") },
159 {
"PFB", 6, MagicPattern(
"%!PS-AdobeFont-1.0") },
160 {
"PGX", 0, MagicPattern(
"PG ML") },
161 {
"PGX", 0, MagicPattern(
"PG LM") },
162 {
"PICT", 522, MagicPattern(
"\000\021\002\377\014\000") },
163 {
"PNG", 0, MagicPattern(
"\211PNG\r\n\032\n") },
164 {
"PBM", 0, MagicPattern(
"P1") },
165 {
"PGM", 0, MagicPattern(
"P2") },
166 {
"PPM", 0, MagicPattern(
"P3") },
167 {
"PBM", 0, MagicPattern(
"P4") },
168 {
"PGM", 0, MagicPattern(
"P5") },
169 {
"PPM", 0, MagicPattern(
"P6") },
170 {
"PAM", 0, MagicPattern(
"P7") },
171 {
"PFM", 0, MagicPattern(
"PF") },
172 {
"PFM", 0, MagicPattern(
"Pf") },
173 {
"PS", 0, MagicPattern(
"%!") },
174 {
"PS", 0, MagicPattern(
"\004%!") },
175 {
"PS", 0, MagicPattern(
"\305\320\323\306") },
176 {
"PSB", 0, MagicPattern(
"8BPB") },
177 {
"PSD", 0, MagicPattern(
"8BPS") },
178 {
"PWP", 0, MagicPattern(
"SFW95") },
179 {
"RAF", 0, MagicPattern(
"FUJIFILMCCD-RAW ") },
180 {
"RLE", 0, MagicPattern(
"\122\314") },
181 {
"SCT", 0, MagicPattern(
"CT") },
182 {
"SFW", 0, MagicPattern(
"SFW94") },
183 {
"SGI", 0, MagicPattern(
"\001\332") },
184 {
"SUN", 0, MagicPattern(
"\131\246\152\225") },
185 {
"SVG", 1, MagicPattern(
"?XML") },
186 {
"SVG", 1, MagicPattern(
"?xml") },
187 {
"SVG", 1, MagicPattern(
"SVG") },
188 {
"SVG", 1, MagicPattern(
"svg") },
189 {
"TIFF", 0, MagicPattern(
"\115\115\000\052") },
190 {
"TIFF", 0, MagicPattern(
"\111\111\052\000") },
191 {
"TIFF64", 0, MagicPattern(
"\115\115\000\053\000\010\000\000") },
192 {
"TIFF64", 0, MagicPattern(
"\111\111\053\000\010\000\000\000") },
193 {
"TTF", 0, MagicPattern(
"\000\001\000\000\000") },
194 {
"TXT", 0, MagicPattern(
"# ImageMagick pixel enumeration:") },
195 {
"VICAR", 0, MagicPattern(
"LBLSIZE") },
196 {
"VICAR", 0, MagicPattern(
"NJPL1I") },
197 {
"VIFF", 0, MagicPattern(
"\253\001") },
198 {
"WEBP", 8, MagicPattern(
"WEBP") },
199 {
"WMF", 0, MagicPattern(
"\327\315\306\232") },
200 {
"WMF", 0, MagicPattern(
"\001\000\011\000") },
201 {
"WPG", 0, MagicPattern(
"\377WPC") },
202 {
"XBM", 0, MagicPattern(
"#define") },
203 {
"XCF", 0, MagicPattern(
"gimp xcf") },
204 {
"XEF", 0, MagicPattern(
"FOVb") },
205 {
"XPM", 1, MagicPattern(
"* XPM *") }
217 static MagickBooleanType
220 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
221 static MagickBooleanType
222 LoadMagicCache(
LinkedListInfo *,
const char *,
const char *,
const size_t,
252 static int CompareMagickInfoSize(
const void *a,
const void *b)
260 if (ma->offset != mb->offset)
261 return((
int) (ma->offset-mb->offset));
262 return((
int) (mb->length-(ssize_t) ma->length));
277 cache=NewLinkedList(0);
279 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
284 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
296 options=GetConfigureOptions(filename,exception);
297 option=(
const StringInfo *) GetNextValueInLinkedList(options);
300 (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
301 status&=LoadMagicCache(cache,(
const char *)
302 GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
303 option=(
const StringInfo *) GetNextValueInLinkedList(options);
305 options=DestroyConfigureOptions(options);
311 for (i=0; i < (ssize_t) (
sizeof(MagicMap)/
sizeof(*MagicMap)); i++)
320 magic_info=(
MagicInfo *) AcquireMagickMemory(
sizeof(*magic_info));
323 (void) ThrowMagickException(exception,GetMagickModule(),
324 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",p->name);
327 (void) memset(magic_info,0,
sizeof(*magic_info));
328 magic_info->path=(
char *)
"[built-in]";
329 magic_info->name=(
char *) p->name;
330 magic_info->offset=p->offset;
331 magic_info->target=(
char *) p->magic;
332 magic_info->magic=(
unsigned char *) p->magic;
333 magic_info->length=p->length;
334 magic_info->exempt=MagickTrue;
335 magic_info->signature=MagickCoreSignature;
336 status&=InsertValueInSortedLinkedList(cache,CompareMagickInfoSize,
338 if (status == MagickFalse)
339 (void) ThrowMagickException(exception,GetMagickModule(),
340 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",magic_info->name);
374 MagickExport
const MagicInfo *GetMagicInfo(
const unsigned char *magic,
381 if (IsMagicCacheInstantiated(exception) == MagickFalse)
386 LockSemaphoreInfo(magic_semaphore);
387 ResetLinkedListIterator(magic_cache);
388 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
389 if (magic == (
const unsigned char *) NULL)
391 UnlockSemaphoreInfo(magic_semaphore);
402 assert(p->offset >= 0);
404 remaining=(MagickOffsetType) length-p->offset;
405 if (LocaleCompare(p->name,
"SVG") == 0)
407 while ((remaining > 0) && (isspace(*q) != 0))
413 if ((remaining >= p->length) && (memcmp(q,p->magic,p->length) == 0))
415 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
418 (
void) InsertValueInLinkedList(magic_cache,0,
419 RemoveElementByValueFromLinkedList(magic_cache,p));
420 UnlockSemaphoreInfo(magic_semaphore);
453 #if defined(__cplusplus) || defined(c_plusplus)
457 static int MagicInfoCompare(
const void *x,
const void *y)
465 if (LocaleCompare((*p)->path,(*q)->path) == 0)
466 return(LocaleCompare((*p)->name,(*q)->name));
467 return(LocaleCompare((*p)->path,(*q)->path));
470 #if defined(__cplusplus) || defined(c_plusplus)
474 MagickExport
const MagicInfo **GetMagicInfoList(
const char *pattern,
489 assert(pattern != (
char *) NULL);
490 assert(number_aliases != (
size_t *) NULL);
491 if (IsEventLogging() != MagickFalse)
492 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
494 p=GetMagicInfo((
const unsigned char *) NULL,0,exception);
497 aliases=(
const MagicInfo **) AcquireQuantumMemory((
size_t)
498 GetNumberOfElementsInLinkedList(magic_cache)+1UL,
sizeof(*aliases));
499 if (aliases == (
const MagicInfo **) NULL)
504 LockSemaphoreInfo(magic_semaphore);
505 ResetLinkedListIterator(magic_cache);
506 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
507 for (i=0; p != (
const MagicInfo *) NULL; )
509 if ((p->stealth == MagickFalse) &&
510 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
512 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
514 UnlockSemaphoreInfo(magic_semaphore);
515 qsort((
void *) aliases,(
size_t) i,
sizeof(*aliases),MagicInfoCompare);
517 *number_aliases=(size_t) i;
551 #if defined(__cplusplus) || defined(c_plusplus)
555 static int MagicCompare(
const void *x,
const void *y)
563 return(LocaleCompare(p,q));
566 #if defined(__cplusplus) || defined(c_plusplus)
570 MagickExport
char **GetMagicList(
const char *pattern,
size_t *number_aliases,
585 assert(pattern != (
char *) NULL);
586 assert(number_aliases != (
size_t *) NULL);
587 if (IsEventLogging() != MagickFalse)
588 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
590 p=GetMagicInfo((
const unsigned char *) NULL,0,exception);
592 return((
char **) NULL);
593 aliases=(
char **) AcquireQuantumMemory((
size_t)
594 GetNumberOfElementsInLinkedList(magic_cache)+1UL,
sizeof(*aliases));
595 if (aliases == (
char **) NULL)
596 return((
char **) NULL);
597 LockSemaphoreInfo(magic_semaphore);
598 ResetLinkedListIterator(magic_cache);
599 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
600 for (i=0; p != (
const MagicInfo *) NULL; )
602 if ((p->stealth == MagickFalse) &&
603 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
604 aliases[i++]=ConstantString(p->name);
605 p=(
const MagicInfo *) GetNextValueInLinkedList(magic_cache);
607 UnlockSemaphoreInfo(magic_semaphore);
608 qsort((
void *) aliases,(
size_t) i,
sizeof(*aliases),MagicCompare);
609 aliases[i]=(
char *) NULL;
610 *number_aliases=(size_t) i;
636 MagickExport
const char *GetMagicName(
const MagicInfo *magic_info)
638 assert(magic_info != (
MagicInfo *) NULL);
639 assert(magic_info->signature == MagickCoreSignature);
640 if (IsEventLogging() != MagickFalse)
641 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
642 return(magic_info->name);
668 static MagickBooleanType IsMagicCacheInstantiated(
ExceptionInfo *exception)
673 ActivateSemaphoreInfo(&magic_semaphore);
674 LockSemaphoreInfo(magic_semaphore);
676 magic_cache=AcquireMagicCache(MagicFilename,exception);
677 UnlockSemaphoreInfo(magic_semaphore);
679 return(magic_cache != (
LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
706 MagickExport MagickBooleanType ListMagicInfo(FILE *file,
724 if (file == (
const FILE *) NULL)
726 magic_info=GetMagicInfoList(
"*",&number_aliases,exception);
727 if (magic_info == (
const MagicInfo **) NULL)
730 path=(
const char *) NULL;
731 for (i=0; i < (ssize_t) number_aliases; i++)
733 if (magic_info[i]->stealth != MagickFalse)
735 if ((path == (
const char *) NULL) ||
736 (LocaleCompare(path,magic_info[i]->path) != 0))
738 if (magic_info[i]->path != (
char *) NULL)
739 (
void) FormatLocaleFile(file,
"\nPath: %s\n\n",magic_info[i]->path);
740 (void) FormatLocaleFile(file,
"Name Offset Target\n");
741 (void) FormatLocaleFile(file,
742 "-------------------------------------------------"
743 "------------------------------\n");
745 path=magic_info[i]->path;
746 (void) FormatLocaleFile(file,
"%s",magic_info[i]->name);
747 for (j=(ssize_t) strlen(magic_info[i]->name); j <= 9; j++)
748 (
void) FormatLocaleFile(file,
" ");
749 (void) FormatLocaleFile(file,
"%6ld ",(
long) magic_info[i]->offset);
750 if (magic_info[i]->target != (
char *) NULL)
755 for (j=0; magic_info[i]->target[j] !=
'\0'; j++)
756 if (isprint((
int) ((
unsigned char) magic_info[i]->target[j])) != 0)
757 (
void) FormatLocaleFile(file,
"%c",magic_info[i]->target[j]);
759 (
void) FormatLocaleFile(file,
"\\%03o",(
unsigned int)
760 ((
unsigned char) magic_info[i]->target[j]));
762 (void) FormatLocaleFile(file,
"\n");
765 magic_info=(
const MagicInfo **) RelinquishMagickMemory((
void *) magic_info);
769 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
800 static MagickBooleanType LoadMagicCache(
LinkedListInfo *cache,
const char *xml,
801 const char *filename,
const size_t depth,
ExceptionInfo *exception)
804 keyword[MaxTextExtent],
822 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
823 "Loading magic configure file \"%s\" ...",filename);
824 if (xml == (
char *) NULL)
828 token=AcquireString(xml);
829 extent=strlen(token)+MaxTextExtent;
830 for (q=(
char *) xml; *q !=
'\0'; )
835 (void) GetNextToken(q,&q,extent,token);
838 (void) CopyMagickString(keyword,token,MaxTextExtent);
839 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
844 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
845 (
void) GetNextToken(q,&q,extent,token);
848 if (LocaleNCompare(keyword,
"<!--",4) == 0)
853 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
854 (void) GetNextToken(q,&q,extent,token);
857 if (LocaleCompare(keyword,
"<include") == 0)
862 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
864 (void) CopyMagickString(keyword,token,MaxTextExtent);
865 (void) GetNextToken(q,&q,extent,token);
868 (void) GetNextToken(q,&q,extent,token);
869 if (LocaleCompare(keyword,
"file") == 0)
871 if (depth > MagickMaxRecursionDepth)
872 (void) ThrowMagickException(exception,GetMagickModule(),
873 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
880 GetPathComponent(filename,HeadPath,path);
882 (void) ConcatenateMagickString(path,DirectorySeparator,
884 if (*token == *DirectorySeparator)
885 (void) CopyMagickString(path,token,MaxTextExtent);
887 (
void) ConcatenateMagickString(path,token,MaxTextExtent);
888 xml=FileToXML(path,~0UL);
889 if (xml != (
char *) NULL)
891 status&=LoadMagicCache(cache,xml,path,depth+1,
893 xml=(
char *) RelinquishMagickMemory(xml);
900 if (LocaleCompare(keyword,
"<magic") == 0)
905 magic_info=(
MagicInfo *) AcquireMagickMemory(
sizeof(*magic_info));
907 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
908 (void) memset(magic_info,0,
sizeof(*magic_info));
909 magic_info->path=ConstantString(filename);
910 magic_info->exempt=MagickFalse;
911 magic_info->signature=MagickCoreSignature;
916 if ((LocaleCompare(keyword,
"/>") == 0) ||
917 (LocaleCompare(keyword,
"</policy>") == 0))
919 status=AppendValueToLinkedList(cache,magic_info);
920 if (status == MagickFalse)
921 (void) ThrowMagickException(exception,GetMagickModule(),
922 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
927 (void) GetNextToken(q,(
const char **) NULL,extent,token);
930 (void) GetNextToken(q,&q,extent,token);
931 (void) GetNextToken(q,&q,extent,token);
937 if (LocaleCompare((
char *) keyword,
"name") == 0)
939 magic_info->name=ConstantString(token);
947 if (LocaleCompare((
char *) keyword,
"offset") == 0)
949 magic_info->offset=(MagickOffsetType) StringToLong(token);
957 if (LocaleCompare((
char *) keyword,
"stealth") == 0)
959 magic_info->stealth=IsMagickTrue(token);
967 if (LocaleCompare((
char *) keyword,
"target") == 0)
978 length=strlen(token);
979 magic_info->target=ConstantString(token);
980 magic_info->magic=(
unsigned char *) ConstantString(token);
982 for (p=magic_info->target; *p !=
'\0'; )
987 if (isdigit((
int) ((
unsigned char) *p)) != 0)
992 *q++=(
unsigned char) strtol(p,&end,8);
994 magic_info->length++;
999 case 'b': *q=
'\b';
break;
1000 case 'f': *q=
'\f';
break;
1001 case 'n': *q=
'\n';
break;
1002 case 'r': *q=
'\r';
break;
1003 case 't': *q=
'\t';
break;
1004 case 'v': *q=
'\v';
break;
1005 case 'a': *q=
'a';
break;
1006 case '?': *q=
'\?';
break;
1007 default: *q=(
unsigned char) (*p);
break;
1011 magic_info->length++;
1015 if (LocaleNCompare(p,
"&",5) == 0)
1016 (
void) CopyMagickString(p+1,p+5,length-magic_info->length);
1017 *q++=(
unsigned char) (*p++);
1018 magic_info->length++;
1028 token=(
char *) RelinquishMagickMemory(token);
1029 return(status != 0 ? MagickTrue : MagickFalse);
1051 MagickExport MagickBooleanType MagicComponentGenesis(
void)
1054 magic_semaphore=AllocateSemaphoreInfo();
1077 static void *DestroyMagicElement(
void *magic_info)
1083 if (p->exempt == MagickFalse)
1085 if (p->path != (
char *) NULL)
1086 p->path=DestroyString(p->path);
1087 if (p->name != (
char *) NULL)
1088 p->name=DestroyString(p->name);
1089 if (p->target != (
char *) NULL)
1090 p->target=DestroyString(p->target);
1091 if (p->magic != (
unsigned char *) NULL)
1092 p->magic=(
unsigned char *) RelinquishMagickMemory(p->magic);
1094 p=(
MagicInfo *) RelinquishMagickMemory(p);
1095 return((
void *) NULL);
1098 MagickExport
void MagicComponentTerminus(
void)
1101 ActivateSemaphoreInfo(&magic_semaphore);
1102 LockSemaphoreInfo(magic_semaphore);
1104 magic_cache=DestroyLinkedList(magic_cache,DestroyMagicElement);
1105 UnlockSemaphoreInfo(magic_semaphore);
1106 DestroySemaphoreInfo(&magic_semaphore);