/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t C o d e r I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetCoderInfo searches the coder list for the specified name and if found % returns attributes for that coder. % % The format of the GetCoderInfo method is: % % const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception) % % A description of each parameter follows: % % o name: The coder name. % % o exception: Return any errors or warnings in this structure. % % */ MagickExport const CoderInfo *GetCoderInfo(const char *name, ExceptionInfo *exception) { register const CoderInfo *p; assert(exception != (ExceptionInfo *) NULL); if ((coder_list == (SplayTreeInfo *) NULL) || (instantiate_coder == MagickFalse)) if (InitializeCoderList(exception) == MagickFalse) return((const CoderInfo *) NULL); if ((coder_list == (SplayTreeInfo *) NULL) || (GetNumberOfNodesInSplayTree(coder_list) == 0)) return((const CoderInfo *) NULL); if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) { ResetSplayTreeIterator(coder_list); return((const CoderInfo *) GetNextValueInSplayTree(coder_list)); } /* Search for requested coder. */ AcquireSemaphoreInfo(&coder_semaphore); ResetSplayTreeIterator(coder_list); p=(const CoderInfo *) GetNextValueInSplayTree(coder_list); while (p != (const CoderInfo *) NULL) { if (LocaleCompare(name,p->magick) == 0) break; p=(const CoderInfo *) GetNextValueInSplayTree(coder_list); } RelinquishSemaphoreInfo(coder_semaphore); return(p); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t L o c a l e I n f o _ % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetLocaleInfo_() searches the locale list for the specified tag and if % found returns attributes for that element. % % The format of the GetLocaleInfo method is: % % const LocaleInfo *GetLocaleInfo_(const char *tag, % ExceptionInfo *exception) % % A description of each parameter follows: % % o tag: The locale tag. % % o exception: Return any errors or warnings in this structure. % % */ MagickExport const LocaleInfo *GetLocaleInfo_(const char *tag, ExceptionInfo *exception) { register const LocaleInfo *p; assert(exception != (ExceptionInfo *) NULL); if ((locale_list == (SplayTreeInfo *) NULL) || (instantiate_locale == MagickFalse)) if (InitializeLocaleList(exception) == MagickFalse) return((const LocaleInfo *) NULL); if ((locale_list == (SplayTreeInfo *) NULL) || (GetNumberOfNodesInSplayTree(locale_list) == 0)) return((const LocaleInfo *) NULL); if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0)) { ResetSplayTreeIterator(locale_list); return((const LocaleInfo *) GetNextValueInSplayTree(locale_list)); } /* Search for named tag. */ AcquireSemaphoreInfo(&locale_semaphore); ResetSplayTreeIterator(locale_list); p=(const LocaleInfo *) GetNextValueInSplayTree(locale_list); while (p != (const LocaleInfo *) NULL) { if (LocaleCompare(tag,p->tag) == 0) break; p=(const LocaleInfo *) GetNextValueInSplayTree(locale_list); } RelinquishSemaphoreInfo(locale_semaphore); return(p); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e l i n q u i s h U n i q u e F i l e R e s o u r c e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % RelinquishUniqueFileResource() relinquishes a unique file resource. % % The format of the RelinquishUniqueFileResource() method is: % % MagickBooleanType RelinquishUniqueFileResource(const char *path) % % A description of each parameter follows: % % o name: the name of the temporary resource. % */ MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path) { char cache_path[MaxTextExtent]; assert(path != (const char *) NULL); (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path); if (temporary_resources != (SplayTreeInfo *) NULL) { register char *p; ResetSplayTreeIterator(temporary_resources); p=(char *) GetNextKeyInSplayTree(temporary_resources); while (p != (char *) NULL) { if (LocaleCompare(p,path) == 0) break; p=(char *) GetNextKeyInSplayTree(temporary_resources); } if (p != (char *) NULL) (void) DeleteNodeFromSplayTree(temporary_resources,p); } (void) CopyMagickString(cache_path,path,MaxTextExtent); AppendImageFormat("cache",cache_path); (void) remove_utf8(cache_path); return(remove_utf8(path) == 0 ? MagickTrue : MagickFalse); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t I m a g e A r t i f a c t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetImageArtifact() gets a value associated with an image artifact. % % Note, the artifact is a constant. Do not attempt to free it. % % The format of the GetImageArtifact method is: % % const char *GetImageArtifact(const Image *image,const char *key) % % A description of each parameter follows: % % o image: the image. % % o key: the key. % */ MagickExport const char *GetImageArtifact(const Image *image, const char *artifact) { register const char *p; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); p=(const char *) NULL; if (artifact == (const char *) NULL) { ResetSplayTreeIterator((SplayTreeInfo *) image->artifacts); p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *) image->artifacts); return(p); } if (image->artifacts != (void *) NULL) { p=(const char *) GetValueFromSplayTree((SplayTreeInfo *) image->artifacts,artifact); if (p != (const char *) NULL) return(p); } return(p); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e s e t I m a g e R e g i s t r y I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ResetImageRegistryIterator() resets the registry iterator. Use it in % conjunction with GetNextImageRegistry() to iterate over all the values % in the image registry. % % The format of the ResetImageRegistryIterator method is: % % ResetImageRegistryIterator(void) % */ MagickExport void ResetImageRegistryIterator(void) { if (IsEventLogging() != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); if (registry == (void *) NULL) return; ResetSplayTreeIterator(registry); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e s e t I m a g e A r t i f a c t I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ResetImageArtifactIterator() resets the image artifact iterator. Use it % in conjunction with GetNextImageArtifact() to iterate over all the values % associated with an image artifact. % % Alternatively you can use GetImageArtifact() with a NULL artifact field to % reset the iterator and return the first artifact. % % The format of the ResetImageArtifactIterator method is: % % ResetImageArtifactIterator(Image *image) % % A description of each parameter follows: % % o image: the image. % */ MagickExport void ResetImageArtifactIterator(const Image *image) { assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (image->artifacts == (void *) NULL) return; ResetSplayTreeIterator((SplayTreeInfo *) image->artifacts); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + A s y n c h r o n o u s R e s o u r c e C o m p o n e n t T e r m i n u s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AsynchronousResourceComponentTerminus() destroys the resource environment. % It differs from ResourceComponentTerminus() in that it can be called from a % asynchronous signal handler. % % The format of the ResourceComponentTerminus() method is: % % ResourceComponentTerminus(void) % */ MagickPrivate void AsynchronousResourceComponentTerminus(void) { const char *path; if (temporary_resources == (SplayTreeInfo *) NULL) return; /* Remove any lingering temporary files. */ ResetSplayTreeIterator(temporary_resources); path=(const char *) GetNextKeyInSplayTree(temporary_resources); while (path != (const char *) NULL) { (void) remove_utf8(path); path=(const char *) GetNextKeyInSplayTree(temporary_resources); } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t T y p e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetTypeInfo searches the type list for the specified name and if found % returns attributes for that type. % % The format of the GetTypeInfo method is: % % const TypeInfo *GetTypeInfo(const char *name,ExceptionInfo *exception) % % A description of each parameter follows: % % o name: the type name. % % o exception: return any errors or warnings in this structure. % */ MagickExport const TypeInfo *GetTypeInfo(const char *name, ExceptionInfo *exception) { assert(exception != (ExceptionInfo *) NULL); if ((type_list == (SplayTreeInfo *) NULL) || (instantiate_type == MagickFalse)) if (InitializeTypeList(exception) == MagickFalse) return((const TypeInfo *) NULL); if ((type_list == (SplayTreeInfo *) NULL) || (GetNumberOfNodesInSplayTree(type_list) == 0)) return((const TypeInfo *) NULL); if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) { ResetSplayTreeIterator(type_list); return((const TypeInfo *) GetNextValueInSplayTree(type_list)); } return((const TypeInfo *) GetValueFromSplayTree(type_list,name)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t L o c a l e I n f o _ % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetLocaleInfo_() searches the locale list for the specified tag and if % found returns attributes for that element. % % The format of the GetLocaleInfo method is: % % const LocaleInfo *GetLocaleInfo_(const char *tag, % ExceptionInfo *exception) % % A description of each parameter follows: % % o tag: the locale tag. % % o exception: return any errors or warnings in this structure. % */ MagickExport const LocaleInfo *GetLocaleInfo_(const char *tag, ExceptionInfo *exception) { assert(exception != (ExceptionInfo *) NULL); if ((locale_list == (SplayTreeInfo *) NULL) || (instantiate_locale == MagickFalse)) if (InitializeLocaleList(exception) == MagickFalse) return((const LocaleInfo *) NULL); if ((locale_list == (SplayTreeInfo *) NULL) || (GetNumberOfNodesInSplayTree(locale_list) == 0)) return((const LocaleInfo *) NULL); if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0)) { ResetSplayTreeIterator(locale_list); return((const LocaleInfo *) GetNextValueInSplayTree(locale_list)); } return((const LocaleInfo *) GetValueFromSplayTree(locale_list,tag)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + A s y n c h r o n o u s D e s t r o y M a g i c k R e s o u r c e s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AsynchronousDestroyMagickResources() destroys the resource environment. % It differs from DestroyMagickResources() in that it can be called from a % asynchronous signal handler. % % The format of the DestroyMagickResources() method is: % % DestroyMagickResources(void) % */ MagickExport void AsynchronousDestroyMagickResources(void) { const char *path; if (temporary_resources == (SplayTreeInfo *) NULL) return; /* Remove any lingering temporary files. */ ResetSplayTreeIterator(temporary_resources); path=(const char *) GetNextKeyInSplayTree(temporary_resources); while (path != (const char *) NULL) { (void) remove(path); path=(const char *) GetNextKeyInSplayTree(temporary_resources); } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t C o d e r I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetCoderInfo searches the coder list for the specified name and if found % returns attributes for that coder. % % The format of the GetCoderInfo method is: % % const CoderInfo *GetCoderInfo(const char *name,ExceptionInfo *exception) % % A description of each parameter follows: % % o name: the coder name. % % o exception: return any errors or warnings in this structure. % */ MagickExport const CoderInfo *GetCoderInfo(const char *name, ExceptionInfo *exception) { const CoderInfo *coder_info; assert(exception != (ExceptionInfo *) NULL); if (IsCoderTreeInstantiated(exception) == MagickFalse) return((const CoderInfo *) NULL); LockSemaphoreInfo(coder_semaphore); if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) { ResetSplayTreeIterator(coder_cache); coder_info=(const CoderInfo *) GetNextValueInSplayTree(coder_cache); UnlockSemaphoreInfo(coder_semaphore); return(coder_info); } coder_info=(const CoderInfo *) GetValueFromSplayTree(coder_cache,name); UnlockSemaphoreInfo(coder_semaphore); return(coder_info); }
MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family, const StyleType style,const StretchType stretch,const size_t weight, ExceptionInfo *exception) { typedef struct _Fontmap { const char *name, *substitute; } Fontmap; const TypeInfo *type_info; register const TypeInfo *p; register ssize_t i; ssize_t range; static const Fontmap fontmap[] = { { "fixed", "courier" }, { "modern","courier" }, { "monotype corsiva", "courier" }, { "news gothic", "helvetica" }, { "system", "courier" }, { "terminal", "courier" }, { "wingdings", "symbol" }, { NULL, NULL } }; size_t max_score, score; /* Check for an exact type match. */ (void) GetTypeInfo("*",exception); if (type_list == (SplayTreeInfo *) NULL) return((TypeInfo *) NULL); LockSemaphoreInfo(type_semaphore); ResetSplayTreeIterator(type_list); type_info=(const TypeInfo *) NULL; p=(const TypeInfo *) GetNextValueInSplayTree(type_list); while (p != (const TypeInfo *) NULL) { if (p->family == (char *) NULL) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if (family == (const char *) NULL) { if ((LocaleCompare(p->family,"arial") != 0) && (LocaleCompare(p->family,"helvetica") != 0)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } } else if (LocaleCompare(p->family,family) != 0) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if ((style != UndefinedStyle) && (style != AnyStyle) && (p->style != style)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if ((stretch != UndefinedStretch) && (stretch != AnyStretch) && (p->stretch != stretch)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if ((weight != 0) && (p->weight != weight)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } type_info=p; break; } UnlockSemaphoreInfo(type_semaphore); if (type_info != (const TypeInfo *) NULL) return(type_info); /* Check for types in the same family. */ max_score=0; LockSemaphoreInfo(type_semaphore); ResetSplayTreeIterator(type_list); p=(const TypeInfo *) GetNextValueInSplayTree(type_list); while (p != (const TypeInfo *) NULL) { if (p->family == (char *) NULL) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if (family == (const char *) NULL) { if ((LocaleCompare(p->family,"arial") != 0) && (LocaleCompare(p->family,"helvetica") != 0)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } } else if (LocaleCompare(p->family,family) != 0) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } score=0; if ((style == UndefinedStyle) || (style == AnyStyle) || (p->style == style)) score+=32; else if (((style == ItalicStyle) || (style == ObliqueStyle)) && ((p->style == ItalicStyle) || (p->style == ObliqueStyle))) score+=25; if (weight == 0) score+=16; else score+=(16*(800-((ssize_t) MagickMax(MagickMin(weight,900),p->weight)- (ssize_t) MagickMin(MagickMin(weight,900),p->weight))))/800; if ((stretch == UndefinedStretch) || (stretch == AnyStretch)) score+=8; else { range=(ssize_t) UltraExpandedStretch-(ssize_t) NormalStretch; score+=(8*(range-((ssize_t) MagickMax(stretch,p->stretch)- (ssize_t) MagickMin(stretch,p->stretch))))/range; } if (score > max_score) { max_score=score; type_info=p; } p=(const TypeInfo *) GetNextValueInSplayTree(type_list); } UnlockSemaphoreInfo(type_semaphore); if (type_info != (const TypeInfo *) NULL) return(type_info); /* Check for table-based substitution match. */ for (i=0; fontmap[i].name != (char *) NULL; i++) { if (family == (const char *) NULL) { if ((LocaleCompare(fontmap[i].name,"arial") != 0) && (LocaleCompare(fontmap[i].name,"helvetica") != 0)) continue; } else if (LocaleCompare(fontmap[i].name,family) != 0) continue; type_info=GetTypeInfoByFamily(fontmap[i].substitute,style,stretch,weight, exception); break; } if (type_info != (const TypeInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(),TypeError, "FontSubstitutionRequired","`%s'",type_info->family); return(type_info); } if (family != (const char *) NULL) type_info=GetTypeInfoByFamily((const char *) NULL,style,stretch,weight, exception); return(type_info); }