/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d M P R I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadMPRImage() reads a Magick Persistent Registry image as a blob from % memory. It allocates the memory necessary for the new Image structure and % returns a pointer to the new image. % % The format of the ReadMPRImage method is: % % Image *ReadMPRImage(const ImageInfo *image_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadMPRImage(const ImageInfo *image_info,ExceptionInfo *exception) { Image *image; assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=(Image *) GetImageRegistry(ImageRegistryType,image_info->filename, exception); if (image != (Image *) NULL) (void) SyncImageSettings(image_info,image); return(image); }
static MagickBooleanType GetPathTemplate(char *path) { char *directory; ExceptionInfo *exception; MagickBooleanType status; register char *p; struct stat attributes; (void) CopyMagickString(path,"magick-XXXXXXXX",MaxTextExtent); exception=AcquireExceptionInfo(); directory=(char *) GetImageRegistry(StringRegistryType,"temporary-path", exception); exception=DestroyExceptionInfo(exception); if (directory == (char *) NULL) directory=GetEnvironmentValue("MAGICK_TEMPORARY_PATH"); if (directory == (char *) NULL) directory=GetEnvironmentValue("MAGICK_TMPDIR"); if (directory == (char *) NULL) directory=GetPolicyValue("temporary-path"); if (directory == (char *) NULL) directory=GetEnvironmentValue("TMPDIR"); #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__OS2__) if (directory == (char *) NULL) directory=GetEnvironmentValue("TMP"); if (directory == (char *) NULL) directory=GetEnvironmentValue("TEMP"); #endif #if defined(__VMS) if (directory == (char *) NULL) directory=GetEnvironmentValue("MTMPDIR"); #endif #if defined(P_tmpdir) if (directory == (char *) NULL) directory=ConstantString(P_tmpdir); #endif if (directory == (char *) NULL) return(MagickTrue); if (strlen(directory) > (MaxTextExtent-15)) { directory=DestroyString(directory); return(MagickTrue); } status=GetPathAttributes(directory,&attributes); if ((status == MagickFalse) || !S_ISDIR(attributes.st_mode)) { directory=DestroyString(directory); return(MagickTrue); } if (directory[strlen(directory)-1] == *DirectorySeparator) (void) FormatLocaleString(path,MaxTextExtent,"%smagick-XXXXXXXX",directory); else (void) FormatLocaleString(path,MaxTextExtent,"%s%smagick-XXXXXXXX", directory,DirectorySeparator); directory=DestroyString(directory); if (*DirectorySeparator != '/') for (p=path; *p != '\0'; p++) if (*p == *DirectorySeparator) *p='/'; return(MagickTrue); }
MagickExport MagickBooleanType GetPathTemplate(char *path) { char *directory, *value; ExceptionInfo *exception; MagickBooleanType status; struct stat attributes; (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20gXXXXXXXXXXXX", (double) getpid()); exception=AcquireExceptionInfo(); directory=(char *) GetImageRegistry(StringRegistryType,"temporary-path", exception); exception=DestroyExceptionInfo(exception); if (directory == (char *) NULL) directory=GetEnvironmentValue("MAGICK_TEMPORARY_PATH"); if (directory == (char *) NULL) directory=GetEnvironmentValue("MAGICK_TMPDIR"); if (directory == (char *) NULL) directory=GetEnvironmentValue("TMPDIR"); #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__OS2__) || defined(__CYGWIN__) if (directory == (char *) NULL) directory=GetEnvironmentValue("TMP"); if (directory == (char *) NULL) directory=GetEnvironmentValue("TEMP"); #endif #if defined(__VMS) if (directory == (char *) NULL) directory=GetEnvironmentValue("MTMPDIR"); #endif #if defined(P_tmpdir) if (directory == (char *) NULL) directory=ConstantString(P_tmpdir); #endif if (directory == (char *) NULL) return(MagickTrue); value=GetPolicyValue("temporary-path"); if (value != (char *) NULL) (void) CloneString(&directory,value); if (strlen(directory) > (MagickPathExtent-25)) { directory=DestroyString(directory); return(MagickFalse); } status=GetPathAttributes(directory,&attributes); if ((status == MagickFalse) || !S_ISDIR(attributes.st_mode)) { directory=DestroyString(directory); return(MagickFalse); } if (directory[strlen(directory)-1] == *DirectorySeparator) (void) FormatLocaleString(path,MagickPathExtent, "%smagick-%.20gXXXXXXXXXXXX",directory,(double) getpid()); else (void) FormatLocaleString(path,MagickPathExtent, "%s%smagick-%.20gXXXXXXXXXXXX",directory,DirectorySeparator,(double) getpid()); directory=DestroyString(directory); #if defined(MAGICKCORE_WINDOWS_SUPPORT) { register char *p; /* Ghostscript does not like backslashes so we need to replace them. The forward slash also works under Windows. */ for (p=(path[1] == *DirectorySeparator ? path+2 : path); *p != '\0'; p++) if (*p == *DirectorySeparator) *p='/'; } #endif return(MagickTrue); }
static MagickBooleanType GetPathTemplate(char *path) { char *directory; const char *temporary_path; ExceptionInfo *exception; int status; register char *p; struct stat file_info; (void) CopyMagickString(path,"magick-XXXXXXXX",MaxTextExtent); directory=(char *) NULL; exception=AcquireExceptionInfo(); temporary_path=(const char *) GetImageRegistry(StringRegistryType, "temporary-path",exception); exception=DestroyExceptionInfo(exception); if (temporary_path != (char *) NULL) directory=ConstantString(temporary_path); if (directory == (char *) NULL) directory=GetEnvironmentValue("MAGICK_TMPDIR"); if (directory == (char *) NULL) directory=GetEnvironmentValue("TMPDIR"); #if defined(__WINDOWS__) if (directory == (char *) NULL) directory=GetEnvironmentValue("TMP"); if (directory == (char *) NULL) directory=GetEnvironmentValue("TEMP"); #endif #if defined(__VMS) if (directory == (char *) NULL) directory=GetEnvironmentValue("MTMPDIR"); #endif #if defined(P_tmpdir) if (directory == (char *) NULL) directory=ConstantString(P_tmpdir); #endif if (directory == (char *) NULL) return(MagickTrue); if (strlen(directory) > (MaxTextExtent-15)) { directory=DestroyString(directory); return(MagickTrue); } status=stat(directory,&file_info); if ((status != 0) || !S_ISDIR(file_info.st_mode)) { directory=DestroyString(directory); return(MagickTrue); } if (directory[strlen(directory)-1] == *DirectorySeparator) (void) FormatMagickString(path,MaxTextExtent,"%smagick-XXXXXXXX",directory); else (void) FormatMagickString(path,MaxTextExtent,"%s%smagick-XXXXXXXX", directory,DirectorySeparator); directory=DestroyString(directory); if (*DirectorySeparator != '/') for (p=path; *p != '\0'; p++) if (*p == *DirectorySeparator) *p='/'; return(MagickTrue); }