/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t C l i e n t P a t h % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetClientPath returns the current client name. % % The format of the GetClientPath method is: % % const char *GetClientPath(void) % */ MagickExport const char *GetClientPath(void) { return(SetClientPath((const char *) NULL)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + R e a d C o n f i g u r e F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadConfigureFile reads the color configuration file which maps % color strings with a particular image format. % % The format of the ReadConfigureFile method is: % % unsigned int ReadConfigureFile(const char *basename, % const unsigned long depth,ExceptionInfo *exception) % % A description of each parameter follows: % % o status: Method ReadConfigureFile returns True if at least one color % is defined otherwise False. % % o basename: The color configuration filename. % % o depth: depth of <include /> statements. % % o exception: Return any errors or warnings in this structure. % % */ #if defined(MSWINDOWS) static void CatDelegatePath(char *path, const char *binpath, const char *command) { strcpy(path,binpath); strcat(path,command); if (IsAccessibleNoLogging(path)) return; strcpy(path,command); return; } #endif /* defined(MSWINDOWS) */ static unsigned int ReadConfigureFile(const char *basename, const unsigned long depth,ExceptionInfo *exception) { char keyword[MaxTextExtent], path[MaxTextExtent], *q, *token, *xml; size_t length; /* Read the delegates configure file. */ (void) strcpy(path,basename); if (depth == 0) xml=(char *) GetConfigureBlob(basename,path,&length,exception); else xml=(char *) FileToBlob(basename,&length,exception); if (xml == (char *) NULL) xml=AllocateString(DelegateMap); token=AllocateString(xml); for (q=xml; *q != '\0'; ) { /* Interpret XML. */ GetToken(q,&q,token); if (*token == '\0') break; (void) strlcpy(keyword,token,MaxTextExtent); if (LocaleNCompare(keyword,"<!--",4) == 0) { /* Comment element. */ while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0')) GetToken(q,&q,token); continue; } if (LocaleCompare(keyword,"<include") == 0) { /* Include element. */ while ((*token != '>') && (*q != '\0')) { (void) strlcpy(keyword,token,MaxTextExtent); GetToken(q,&q,token); if (*token != '=') continue; GetToken(q,&q,token); if (LocaleCompare(keyword,"file") == 0) { if (depth > 200) ThrowException(exception,ConfigureError,IncludeElementNestedTooDeeply,path); else { char filename[MaxTextExtent]; GetPathComponent(path,HeadPath,filename); if (*filename != '\0') (void) strlcat(filename,DirectorySeparator,MaxTextExtent); (void) strlcat(filename,token,MaxTextExtent); (void) ReadConfigureFile(filename,depth+1,exception); } if (delegate_list != (DelegateInfo *) NULL) while (delegate_list->next != (DelegateInfo *) NULL) delegate_list=delegate_list->next; } } continue; } if (LocaleCompare(keyword,"<delegate") == 0) { DelegateInfo *delegate_info; /* Allocate memory for the delegate list. */ delegate_info=MagickAllocateMemory(DelegateInfo *,sizeof(DelegateInfo)); if (delegate_info == (DelegateInfo *) NULL) MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed, UnableToAllocateDelegateInfo); (void) memset(delegate_info,0,sizeof(DelegateInfo)); delegate_info->path=AcquireString(path); delegate_info->signature=MagickSignature; if (delegate_list == (DelegateInfo *) NULL) { delegate_list=delegate_info; continue; } delegate_list->next=delegate_info; delegate_info->previous=delegate_list; delegate_list=delegate_list->next; continue; } if (delegate_list == (DelegateInfo *) NULL) continue; GetToken(q,(char **) NULL,token); if (*token != '=') continue; GetToken(q,&q,token); GetToken(q,&q,token); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare((char *) keyword,"command") == 0) { delegate_list->commands=AllocateString(token); #if defined(MSWINDOWS) if (strchr(delegate_list->commands,'@') != (char *) NULL) { char BinPath[MaxTextExtent], path[MaxTextExtent]; BinPath[0]=0; /* Substitute @PSDelegate@ with path to Ghostscript */ NTGhostscriptEXE(path,MaxTextExtent-1); SubstituteString((char **) &delegate_list->commands, "@PSDelegate@",path); # if defined(UseInstalledMagick) # if defined(MagickBinPath) strcpy(BinPath,MagickBinPath); # else { char *key, *key_value; /* Obtain installation path from registry */ key="BinPath"; key_value=NTRegistryKeyLookup(key); if (!key_value) { ThrowException(exception,ConfigureError, RegistryKeyLookupFailed,key); } else { strcpy(BinPath,key_value); MagickFreeMemory(key_value); } } # endif /* defined(MagickBinPath) */ # else /* Base path off of client path */ strcpy(BinPath,SetClientPath(NULL)); # endif /* defined(UseInstalledMagick) */ if ((BinPath[0] != 0) && (BinPath[strlen(BinPath)-1] != *DirectorySeparator)) strcat(BinPath,DirectorySeparator); /* Substitute @GMDelegate@ with path to gm.exe */ CatDelegatePath(path,BinPath,"gm.exe"); SubstituteString((char **) &delegate_list->commands, "@GMDelegate@",path); /* Substitute @GMDisplayDelegate@ with path to gmdisplay.exe */ CatDelegatePath(path,BinPath,"gmdisplay.exe"); SubstituteString((char **) &delegate_list->commands, "@GMDisplayDelegate@",path); /* Substitute @MPEGDecodeDelegate@ with path to mpeg2dec.exe */ CatDelegatePath(path,BinPath,"mpeg2dec.exe"); SubstituteString((char **) &delegate_list->commands, "@MPEGDecodeDelegate@",path); /* Substitute @MPEGEncodeDelegate@ with path to mpeg2enc.exe */ CatDelegatePath(path,BinPath,"mpeg2enc.exe"); SubstituteString((char **) &delegate_list->commands, "@MPEGEncodeDelegate@",path); /* Substitute @HPGLDecodeDelegate@ with path to hp2xx.exe */ CatDelegatePath(path,BinPath,"hp2xx.exe"); SubstituteString((char **) &delegate_list->commands, "@HPGLDecodeDelegate@",path); } #endif /* defined(MSWINDOWS) */ } /* LocaleCompare */ break; } case 'D': case 'd': { if (LocaleCompare((char *) keyword,"decode") == 0) { delegate_list->decode=AcquireString(token); delegate_list->mode=1; break; } break; } case 'E': case 'e': { if (LocaleCompare((char *) keyword,"encode") == 0) { delegate_list->encode=AcquireString(token); delegate_list->mode=(-1); break; } break; } case 'M': case 'm': { if (LocaleCompare((char *) keyword,"mode") == 0) { delegate_list->mode=1; if (LocaleCompare(token,"bi") == 0) delegate_list->mode=0; else if (LocaleCompare(token,"encode") == 0) delegate_list->mode=(-1); break; } break; } case 'S': case 's': { if (LocaleCompare((char *) keyword,"stealth") == 0) { delegate_list->stealth=LocaleCompare(token,"True") == 0; break; } break; } default: break; } }