/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % CCCC OOO N N FFFFF IIIII GGGG U U RRRR EEEEE % % C O O NN N F I G U U R R E % % C O O N N N FFF I G GG U U RRRR EEE % % C O O N NN F I G G U U R R E % % CCCC OOO N N F IIIII GGG UUU R R EEEEE % % % % % % MagickCore Image Configure Methods % % % % Software Design % % John Cristy % % July 2003 % % % % % % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % % obtain a copy of the License at % % % % http://www.imagemagick.org/script/license.php % % % % Unless required by applicable law or agreed to in writing, software % % distributed under the License is distributed on an "AS IS" BASIS, % % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % % See the License for the specific language governing permissions and % % limitations under the License. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ /* Include declarations. */ #include "magick/studio.h" #include "magick/blob.h" #include "magick/client.h" #include "magick/configure.h" #include "magick/exception.h" #include "magick/exception-private.h" #include "magick/hashmap.h" #include "magick/log.h" #include "magick/memory_.h" #include "magick/semaphore.h" #include "magick/string_.h" #include "magick/token.h" #include "magick/utility.h" #include "magick/xml-tree.h" /* Define declarations. */ #define ConfigureFilename "configure.xml" /* Typedef declarations. */ typedef struct _ConfigureMapInfo { const char *name, *value; } ConfigureMapInfo; /* Static declarations. */ static const ConfigureMapInfo ConfigureMap[] = { { "NAME", "ImageMagick" } }; static LinkedListInfo *configure_list = (LinkedListInfo *) NULL; static SemaphoreInfo *configure_semaphore = (SemaphoreInfo *) NULL; static volatile MagickBooleanType instantiate_configure = MagickFalse; /* Forward declarations. */ static MagickBooleanType InitializeConfigureList(ExceptionInfo *), LoadConfigureLists(const char *,ExceptionInfo *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + C o n f i g u r e C o m p o n e n t G e n e s i s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ConfigureComponentGenesis() instantiates the configure component. % % The format of the ConfigureComponentGenesis method is: % % MagickBooleanType ConfigureComponentGenesis(void) % */ MagickExport MagickBooleanType ConfigureComponentGenesis(void) { AcquireSemaphoreInfo(&configure_semaphore); return(MagickTrue); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + C o n f i g u r e C o m p o n e n t T e r m i n u s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ConfigureComponentTerminus() destroys the configure component. % % The format of the ConfigureComponentTerminus method is: % % ConfigureComponentTerminus(void) % */ static void *DestroyConfigureElement(void *configure_info) { register ConfigureInfo *p; p=(ConfigureInfo *) configure_info; if (p->exempt == MagickFalse) { if (p->value != (char *) NULL) p->value=DestroyString(p->value); if (p->name != (char *) NULL) p->name=DestroyString(p->name); if (p->path != (char *) NULL) p->path=DestroyString(p->path); } p=(ConfigureInfo *) RelinquishMagickMemory(p); return((void *) NULL); } MagickExport void ConfigureComponentTerminus(void) { if (configure_semaphore == (SemaphoreInfo *) NULL) AcquireSemaphoreInfo(&configure_semaphore); LockSemaphoreInfo(configure_semaphore); if (configure_list != (LinkedListInfo *) NULL) configure_list=DestroyLinkedList(configure_list,DestroyConfigureElement); configure_list=(LinkedListInfo *) NULL; instantiate_configure=MagickFalse; UnlockSemaphoreInfo(configure_semaphore); DestroySemaphoreInfo(&configure_semaphore); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % D e s t r o y C o n f i g u r e O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DestroyConfigureOptions() releases memory associated with an configure % options. % % The format of the DestroyProfiles method is: % % LinkedListInfo *DestroyConfigureOptions(Image *image) % % A description of each parameter follows: % % o image: the image. % */ static void *DestroyOptions(void *option) { return(DestroyStringInfo((StringInfo *) option)); } MagickExport LinkedListInfo *DestroyConfigureOptions(LinkedListInfo *options) { assert(options != (LinkedListInfo *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); return(DestroyLinkedList(options,DestroyOptions)); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + G e t C o n f i g u r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigureInfo() searches the configure list for the specified name and if % found returns attributes for that element. % % The format of the GetConfigureInfo method is: % % const ConfigureInfo *GetConfigureInfo(const char *name, % ExceptionInfo *exception) % % A description of each parameter follows: % % o configure_info: GetConfigureInfo() searches the configure list for the % specified name and if found returns attributes for that element. % % o name: the configure name. % % o exception: return any errors or warnings in this structure. % */ MagickExport const ConfigureInfo *GetConfigureInfo(const char *name, ExceptionInfo *exception) { register const ConfigureInfo *p; assert(exception != (ExceptionInfo *) NULL); if ((configure_list == (LinkedListInfo *) NULL) || (instantiate_configure == MagickFalse)) if (InitializeConfigureList(exception) == MagickFalse) return((const ConfigureInfo *) NULL); if ((configure_list == (LinkedListInfo *) NULL) || (IsLinkedListEmpty(configure_list) != MagickFalse)) return((const ConfigureInfo *) NULL); if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) return((const ConfigureInfo *) GetValueFromLinkedList(configure_list,0)); /* Search for configure tag. */ LockSemaphoreInfo(configure_semaphore); ResetLinkedListIterator(configure_list); p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); while (p != (const ConfigureInfo *) NULL) { if (LocaleCompare(name,p->name) == 0) break; p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); } if (p != (ConfigureInfo *) NULL) (void) InsertValueInLinkedList(configure_list,0, RemoveElementByValueFromLinkedList(configure_list,p)); UnlockSemaphoreInfo(configure_semaphore); return(p); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C o n f i g u r e I n f o L i s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigureInfoList() returns any configure options that match the % specified pattern. % % The format of the GetConfigureInfoList function is: % % const ConfigureInfo **GetConfigureInfoList(const char *pattern, % unsigned long *number_options,ExceptionInfo *exception) % % A description of each parameter follows: % % o pattern: Specifies a pointer to a text string containing a pattern. % % o number_options: This integer returns the number of configure options in % the list. % % o exception: return any errors or warnings in this structure. % */ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif static int ConfigureInfoCompare(const void *x,const void *y) { const ConfigureInfo **p, **q; p=(const ConfigureInfo **) x, q=(const ConfigureInfo **) y; if (LocaleCompare((*p)->path,(*q)->path) == 0) return(LocaleCompare((*p)->name,(*q)->name)); return(LocaleCompare((*p)->path,(*q)->path)); } #if defined(__cplusplus) || defined(c_plusplus) } #endif MagickExport const ConfigureInfo **GetConfigureInfoList(const char *pattern, unsigned long *number_options,ExceptionInfo *exception) { const ConfigureInfo **options; register const ConfigureInfo *p; register long i; /* Allocate configure list. */ assert(pattern != (char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern); assert(number_options != (unsigned long *) NULL); *number_options=0; p=GetConfigureInfo("*",exception); if (p == (const ConfigureInfo *) NULL) return((const ConfigureInfo **) NULL); options=(const ConfigureInfo **) AcquireQuantumMemory((size_t) GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options)); if (options == (const ConfigureInfo **) NULL) return((const ConfigureInfo **) NULL); /* Generate configure list. */ LockSemaphoreInfo(configure_semaphore); ResetLinkedListIterator(configure_list); p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); for (i=0; p != (const ConfigureInfo *) NULL; ) { if ((p->stealth == MagickFalse) && (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse)) options[i++]=p; p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); } UnlockSemaphoreInfo(configure_semaphore); qsort((void *) options,(size_t) i,sizeof(*options),ConfigureInfoCompare); options[i]=(ConfigureInfo *) NULL; *number_options=(unsigned long) i; return(options); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C o n f i g u r e L i s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigureList() returns any configure options that match the specified % pattern. % % The format of the GetConfigureList function is: % % char **GetConfigureList(const char *pattern, % unsigned long *number_options,ExceptionInfo *exception) % % A description of each parameter follows: % % o pattern: Specifies a pointer to a text string containing a pattern. % % o number_options: This integer returns the number of options in the list. % % o exception: return any errors or warnings in this structure. % */ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif static int ConfigureCompare(const void *x,const void *y) { register char **p, **q; p=(char **) x; q=(char **) y; return(LocaleCompare(*p,*q)); } #if defined(__cplusplus) || defined(c_plusplus) } #endif MagickExport char **GetConfigureList(const char *pattern, unsigned long *number_options,ExceptionInfo *exception) { char **options; register const ConfigureInfo *p; register long i; /* Allocate configure list. */ assert(pattern != (char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern); assert(number_options != (unsigned long *) NULL); *number_options=0; p=GetConfigureInfo("*",exception); if (p == (const ConfigureInfo *) NULL) return((char **) NULL); options=(char **) AcquireQuantumMemory((size_t) GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options)); if (options == (char **) NULL) return((char **) NULL); LockSemaphoreInfo(configure_semaphore); ResetLinkedListIterator(configure_list); p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); for (i=0; p != (const ConfigureInfo *) NULL; ) { if ((p->stealth == MagickFalse) && (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse)) options[i++]=ConstantString(p->name); p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); } UnlockSemaphoreInfo(configure_semaphore); qsort((void *) options,(size_t) i,sizeof(*options),ConfigureCompare); options[i]=(char *) NULL; *number_options=(unsigned long) i; return(options); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C o n f i g u r e O p t i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigureOption() returns the value associated with the configure option. % % The format of the GetConfigureOption method is: % % char *GetConfigureOption(const char *option) % % A description of each parameter follows: % % o configure_info: The configure info. % */ MagickExport char *GetConfigureOption(const char *option) { const char *value; const ConfigureInfo *configure_info; ExceptionInfo *exception; assert(option != (const char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",option); exception=AcquireExceptionInfo(); configure_info=GetConfigureInfo(option,exception); exception=DestroyExceptionInfo(exception); if (configure_info == (ConfigureInfo *) NULL) return((char *) NULL); value=GetConfigureValue(configure_info); if ((value == (const char *) NULL) || (*value == '\0')) return((char *) NULL); return(ConstantString(value)); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C o n f i g u r e O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigureOptions() returns any Magick configuration options associated % with the specified filename. % % The format of the GetConfigureOptions method is: % % LinkedListInfo *GetConfigureOptions(const char *filename, % ExceptionInfo *exception) % % A description of each parameter follows: % % o filename: the configure file name. % % o exception: return any errors or warnings in this structure. % */ MagickExport LinkedListInfo *GetConfigureOptions(const char *filename, ExceptionInfo *exception) { char path[MaxTextExtent]; const char *element; LinkedListInfo *options, *paths; StringInfo *xml; assert(filename != (const char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); assert(exception != (ExceptionInfo *) NULL); (void) CopyMagickString(path,filename,MaxTextExtent); /* Load XML from configuration files to linked-list. */ options=NewLinkedList(0); paths=GetConfigurePaths(filename,exception); if (paths != (LinkedListInfo *) NULL) { ResetLinkedListIterator(paths); element=(const char *) GetNextValueInLinkedList(paths); while (element != (const char *) NULL) { (void) FormatMagickString(path,MaxTextExtent,"%s%s",element,filename); (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), "Searching for configure file: \"%s\"",path); xml=ConfigureFileToStringInfo(path); if (xml != (StringInfo *) NULL) (void) AppendValueToLinkedList(options,xml); element=(const char *) GetNextValueInLinkedList(paths); } paths=DestroyLinkedList(paths,RelinquishMagickMemory); } #if defined(MAGICKCORE_WINDOWS_SUPPORT) { char *blob; blob=(char *) NTResourceToBlob(filename); if (blob != (char *) NULL) { xml=StringToStringInfo(blob); SetStringInfoPath(xml,filename); (void) AppendValueToLinkedList(options,xml); blob=DestroyString(blob); } } #endif if (GetNumberOfElementsInLinkedList(options) == 0) (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning, "UnableToOpenConfigureFile","`%s'",filename); ResetLinkedListIterator(options); return(options); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C o n f i g u r e P a t h s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigurePaths() returns any Magick configuration paths associated % with the specified filename. % % The format of the GetConfigurePaths method is: % % LinkedListInfo *GetConfigurePaths(const char *filename, % ExceptionInfo *exception) % % A description of each parameter follows: % % o filename: the configure file name. % % o exception: return any errors or warnings in this structure. % */ MagickExport LinkedListInfo *GetConfigurePaths(const char *filename, ExceptionInfo *exception) { char path[MaxTextExtent]; LinkedListInfo *paths; assert(filename != (const char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); assert(exception != (ExceptionInfo *) NULL); (void) CopyMagickString(path,filename,MaxTextExtent); paths=NewLinkedList(0); { char *configure_path; /* Search $MAGICK_CONFIGURE_PATH. */ configure_path=GetEnvironmentValue("MAGICK_CONFIGURE_PATH"); if (configure_path != (char *) NULL) { register char *p, *q; for (p=configure_path-1; p != (char *) NULL; ) { (void) CopyMagickString(path,p+1,MaxTextExtent); q=strchr(path,DirectoryListSeparator); if (q != (char *) NULL) *q='\0'; q=path+strlen(path)-1; if ((q >= path) && (*q != *DirectorySeparator)) (void) ConcatenateMagickString(path,DirectorySeparator, MaxTextExtent); (void) AppendValueToLinkedList(paths,ConstantString(path)); p=strchr(p+1,DirectoryListSeparator); } configure_path=DestroyString(configure_path); } } #if defined(MAGICKCORE_INSTALLED_SUPPORT) #if defined(MAGICKCORE_SHARE_CONFIGURE_PATH) (void) AppendValueToLinkedList(paths,ConstantString( MAGICKCORE_SHARE_CONFIGURE_PATH)); #endif #if defined(MAGICKCORE_CONFIGURE_PATH) (void) AppendValueToLinkedList(paths,ConstantString( MAGICKCORE_CONFIGURE_PATH)); #endif #if defined(MAGICKCORE_DOCUMENTATION_PATH) (void) AppendValueToLinkedList(paths,ConstantString( MAGICKCORE_DOCUMENTATION_PATH)); #endif #if defined(MAGICKCORE_SHARE_PATH) (void) AppendValueToLinkedList(paths,ConstantString(MAGICKCORE_SHARE_PATH)); #endif #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_CONFIGURE_PATH)) { char *registry_key; unsigned char *key_value; /* Locate file via registry key. */ registry_key="ConfigurePath"; key_value=NTRegistryKeyLookup(registry_key); if (key_value != (unsigned char *) NULL) { (void) FormatMagickString(path,MaxTextExtent,"%s%s",(char *) key_value, DirectorySeparator); (void) AppendValueToLinkedList(paths,ConstantString(path)); key_value=(unsigned char *) RelinquishMagickMemory(key_value); } } #endif #else { char *home; /* Search under MAGICK_HOME. */ home=GetEnvironmentValue("MAGICK_HOME"); if (home != (char *) NULL) { #if !defined(MAGICKCORE_POSIX_SUPPORT) (void) FormatMagickString(path,MaxTextExtent,"%s%s",home, DirectorySeparator); (void) AppendValueToLinkedList(paths,ConstantString(path)); #else (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/",home, MAGICKCORE_CONFIGURE_RELATIVE_PATH); (void) AppendValueToLinkedList(paths,ConstantString(path)); (void) FormatMagickString(path,MaxTextExtent,"%s/share/%s/",home, MAGICKCORE_SHARE_CONFIGURE_RELATIVE_PATH); (void) AppendValueToLinkedList(paths,ConstantString(path)); #endif home=DestroyString(home); } } if (*GetClientPath() != '\0') { #if !defined(MAGICKCORE_POSIX_SUPPORT) (void) FormatMagickString(path,MaxTextExtent,"%s%s",GetClientPath(), DirectorySeparator); (void) AppendValueToLinkedList(paths,ConstantString(path)); #else char prefix[MaxTextExtent]; /* Search based on executable directory if directory is known. */ (void) CopyMagickString(prefix,GetClientPath(),MaxTextExtent); ChopPathComponents(prefix,1); (void) FormatMagickString(path,MaxTextExtent,"%s/share/%s/",prefix, MAGICKCORE_SHARE_CONFIGURE_RELATIVE_PATH); (void) AppendValueToLinkedList(paths,ConstantString(path)); (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/",prefix, MAGICKCORE_CONFIGURE_RELATIVE_PATH); (void) AppendValueToLinkedList(paths,ConstantString(path)); #endif } #endif { char *home; home=GetEnvironmentValue("HOME"); if (home == (char *) NULL) home=GetEnvironmentValue("USERPROFILE"); if (home != (char *) NULL) { /* Search $HOME/.magick. */ (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s",home, DirectorySeparator,DirectorySeparator); (void) AppendValueToLinkedList(paths,ConstantString(path)); home=DestroyString(home); } } #if defined(MAGICKCORE_WINDOWS_SUPPORT) { char module_path[MaxTextExtent]; if ((NTGetModulePath("CORE_RL_magick_.dll",module_path) != MagickFalse) || (NTGetModulePath("CORE_DB_magick_.dll",module_path) != MagickFalse)) { char *element; /* Search module path. */ (void) FormatMagickString(path,MaxTextExtent,"%s%s",module_path, DirectorySeparator); element=(char *) RemoveElementByValueFromLinkedList(paths,path); if (element != (char *) NULL) element=DestroyString(element); (void) AppendValueToLinkedList(paths,ConstantString(path)); } if (NTGetModulePath("Magick.dll",module_path) != MagickFalse) { /* Search PerlMagick module path. */ (void) FormatMagickString(path,MaxTextExtent,"%s%s",module_path, DirectorySeparator); (void) AppendValueToLinkedList(paths,ConstantString(path)); (void) FormatMagickString(path,MaxTextExtent,"%s%s",module_path, "\\inc\\lib\\auto\\Image\\Magick\\"); (void) AppendValueToLinkedList(paths,ConstantString(path)); } } #endif /* Search current directory. */ (void) AppendValueToLinkedList(paths,ConstantString("")); return(paths); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C o n f i g u r e V a l u e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetConfigureValue() returns the value associated with the configure info. % % The format of the GetConfigureValue method is: % % const char *GetConfigureValue(const ConfigureInfo *configure_info) % % A description of each parameter follows: % % o configure_info: The configure info. % */ MagickExport const char *GetConfigureValue(const ConfigureInfo *configure_info) { (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(configure_info != (ConfigureInfo *) NULL); assert(configure_info->signature == MagickSignature); return(configure_info->value); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + I n i t i a l i z e C o n f i g u r e L i s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % InitializeConfigureList() initializes the configure list. % % The format of the InitializeConfigureList method is: % % MagickBooleanType InitializeConfigureList(ExceptionInfo *exception) % % A description of each parameter follows. % % o exception: return any errors or warnings in this structure. % */ static MagickBooleanType InitializeConfigureList(ExceptionInfo *exception) { if ((configure_list == (LinkedListInfo *) NULL) && (instantiate_configure == MagickFalse)) { if (configure_semaphore == (SemaphoreInfo *) NULL) AcquireSemaphoreInfo(&configure_semaphore); LockSemaphoreInfo(configure_semaphore); if ((configure_list == (LinkedListInfo *) NULL) && (instantiate_configure == MagickFalse)) { (void) LoadConfigureLists(ConfigureFilename,exception); instantiate_configure=MagickTrue; } UnlockSemaphoreInfo(configure_semaphore); } return(configure_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t C o n f i g u r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListConfigureInfo() lists the configure info to a file. % % The format of the ListConfigureInfo method is: % % MagickBooleanType ListConfigureInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListConfigureInfo(FILE *file, ExceptionInfo *exception) { const char *name, *path, *value; const ConfigureInfo **configure_info; long j; register long i; unsigned long number_options; if (file == (const FILE *) NULL) file=stdout; configure_info=GetConfigureInfoList("*",&number_options,exception); if (configure_info == (const ConfigureInfo **) NULL) return(MagickFalse); path=(const char *) NULL; for (i=0; i < (long) number_options; i++) { if (configure_info[i]->stealth != MagickFalse) continue; if ((path == (const char *) NULL) || (LocaleCompare(path,configure_info[i]->path) != 0)) { if (configure_info[i]->path != (char *) NULL) (void) fprintf(file,"\nPath: %s\n\n",configure_info[i]->path); (void) fprintf(file,"Name Value\n"); (void) fprintf(file,"-------------------------------------------------" "------------------------------\n"); } path=configure_info[i]->path; name="unknown"; if (configure_info[i]->name != (char *) NULL) name=configure_info[i]->name; (void) fprintf(file,"%s",name); for (j=(long) strlen(name); j <= 12; j++) (void) fprintf(file," "); (void) fprintf(file," "); value="unknown"; if (configure_info[i]->value != (char *) NULL) value=configure_info[i]->value; (void) fprintf(file,"%s",value); (void) fprintf(file,"\n"); } (void) fflush(file); configure_info=(const ConfigureInfo **) RelinquishMagickMemory((void *) configure_info); return(MagickTrue); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + L o a d C o n f i g u r e L i s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % LoadConfigureList() loads the configure configuration file which provides a % mapping between configure attributes and a configure name. % % The format of the LoadConfigureList method is: % % MagickBooleanType LoadConfigureList(const char *xml,const char *filename, % const unsigned long depth,ExceptionInfo *exception) % % A description of each parameter follows: % % o xml: The configure list in XML format. % % o filename: The configure list filename. % % o depth: depth of statements. % % o exception: return any errors or warnings in this structure. % */ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename, const unsigned long depth,ExceptionInfo *exception) { char keyword[MaxTextExtent], *token; ConfigureInfo *configure_info; const char *q; MagickBooleanType status; /* Load the configure map file. */ (void) LogMagickEvent(ConfigureEvent,GetMagickModule(), "Loading configure file \"%s\" ...",filename); if (configure_list == (LinkedListInfo *) NULL) { configure_list=NewLinkedList(0); if (configure_list == (LinkedListInfo *) NULL) { ThrowFileException(exception,ResourceLimitError, "MemoryAllocationFailed",filename); return(MagickFalse); } } status=MagickTrue; configure_info=(ConfigureInfo *) NULL; token=AcquireString((char *) xml); for (q=(char *) xml; *q != '\0'; ) { /* Interpret XML. */ GetMagickToken(q,&q,token); if (*token == '\0') break; (void) CopyMagickString(keyword,token,MaxTextExtent); if (LocaleNCompare(keyword,"",2) != 0) && (*q != '\0')) GetMagickToken(q,&q,token); continue; } if (LocaleNCompare(keyword,"