|
MagickCore
6.7.7
|
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % V V M M SSSSS % 00007 % V V MM MM SS % 00008 % V V M M M SSS % 00009 % V V M M SS % 00010 % V M M SSSSS % 00011 % % 00012 % % 00013 % MagickCore VMS Utility Methods % 00014 % % 00015 % Software Design % 00016 % John Cristy % 00017 % October 1994 % 00018 % % 00019 % % 00020 % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % 00021 % dedicated to making software imaging solutions freely available. % 00022 % % 00023 % You may not use this file except in compliance with the License. You may % 00024 % obtain a copy of the License at % 00025 % % 00026 % http://www.imagemagick.org/script/license.php % 00027 % % 00028 % Unless required by applicable law or agreed to in writing, software % 00029 % distributed under the License is distributed on an "AS IS" BASIS, % 00030 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00031 % See the License for the specific language governing permissions and % 00032 % limitations under the License. % 00033 % % 00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00035 % 00036 % The directory methods are strongly based on similar methods written 00037 % by Rich Salz. 00038 % 00039 */ 00040 00041 #if defined(vms) 00042 /* 00043 Include declarations. 00044 */ 00045 #include "MagickCore/studio.h" 00046 #include "MagickCore/string_.h" 00047 #include "MagickCore/memory_.h" 00048 #include "MagickCore/vms.h" 00049 00050 #if !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) 00051 /* 00052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00053 % % 00054 % % 00055 % % 00056 % c l o s e d i r % 00057 % % 00058 % % 00059 % % 00060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00061 % 00062 % closedir() closes the named directory stream and frees the DIR structure. 00063 % 00064 % The format of the closedir method is: 00065 % 00066 % 00067 % A description of each parameter follows: 00068 % 00069 % o entry: Specifies a pointer to a DIR structure. 00070 % 00071 % 00072 */ 00073 void closedir(DIR *directory) 00074 { 00075 if (image->debug != MagickFalse) 00076 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 00077 assert(directory != (DIR *) NULL); 00078 directory->pattern=DestroyString(directory->pattern); 00079 directory=DestroyString(directory); 00080 } 00081 00082 /* 00083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00084 % % 00085 % % 00086 % % 00087 % o p e n d i r % 00088 % % 00089 % % 00090 % % 00091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00092 % 00093 % opendir() opens the directory named by filename and associates a directory 00094 % stream with it. 00095 % 00096 % The format of the opendir method is: 00097 % 00098 % opendir(entry) 00099 % 00100 % A description of each parameter follows: 00101 % 00102 % o entry: Specifies a pointer to a DIR structure. 00103 % 00104 % 00105 */ 00106 DIR *opendir(char *name) 00107 { 00108 DIR 00109 *directory; 00110 00111 /* 00112 Allocate memory for handle and the pattern. 00113 */ 00114 directory=(DIR *) AcquireMagickMemory(sizeof(DIR)); 00115 if (directory == (DIR *) NULL) 00116 { 00117 errno=ENOMEM; 00118 return((DIR *) NULL); 00119 } 00120 if (strcmp(".",name) == 0) 00121 name=""; 00122 directory->pattern=(char *) AcquireQuantumMemory(strlen(name)+sizeof("*.*")+ 00123 1UL,sizeof(*directory->pattern)); 00124 if (directory->pattern == (char *) NULL) 00125 { 00126 directory=DestroyString(directory); 00127 errno=ENOMEM; 00128 return(NULL); 00129 } 00130 /* 00131 Initialize descriptor. 00132 */ 00133 (void) FormatLocaleString(directory->pattern,MaxTextExtent,"%s*.*",name); 00134 directory->context=0; 00135 directory->pat.dsc$a_pointer=directory->pattern; 00136 directory->pat.dsc$w_length=strlen(directory->pattern); 00137 directory->pat.dsc$b_dtype=DSC$K_DTYPE_T; 00138 directory->pat.dsc$b_class=DSC$K_CLASS_S; 00139 return(directory); 00140 } 00141 00142 /* 00143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00144 % % 00145 % % 00146 % % 00147 % r e a d d i r % 00148 % % 00149 % % 00150 % % 00151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00152 % 00153 % readdir() returns a pointer to a structure representing the directory entry 00154 % at the current position in the directory stream to which entry refers. 00155 % 00156 % The format of the readdir 00157 % 00158 % readdir(entry) 00159 % 00160 % A description of each parameter follows: 00161 % 00162 % o entry: Specifies a pointer to a DIR structure. 00163 % 00164 % 00165 */ 00166 struct dirent *readdir(DIR *directory) 00167 { 00168 char 00169 buffer[sizeof(directory->entry.d_name)]; 00170 00171 int 00172 status; 00173 00174 register char 00175 *p; 00176 00177 register int 00178 i; 00179 00180 struct dsc$descriptor_s 00181 result; 00182 00183 /* 00184 Initialize the result descriptor. 00185 */ 00186 result.dsc$a_pointer=buffer; 00187 result.dsc$w_length=sizeof(buffer)-2; 00188 result.dsc$b_dtype=DSC$K_DTYPE_T; 00189 result.dsc$b_class=DSC$K_CLASS_S; 00190 status=lib$find_file(&directory->pat,&result,&directory->context); 00191 if ((status == RMS$_NMF) || (directory->context == 0L)) 00192 return((struct dirent *) NULL); 00193 /* 00194 Lowercase all filenames. 00195 */ 00196 buffer[sizeof(buffer)-1]='\0'; 00197 for (p=buffer; *p; p++) 00198 if (isupper((unsigned char) *p)) 00199 *p=tolower(*p); 00200 /* 00201 Skip any directory component and just copy the name. 00202 */ 00203 p=buffer; 00204 while (isspace((unsigned char) *p) == 0) 00205 p++; 00206 *p='\0'; 00207 p=strchr(buffer,']'); 00208 if (p) 00209 (void) CopyMagickString(directory->entry.d_name,p+1,MaxTextExtent); 00210 else 00211 (void) CopyMagickString(directory->entry.d_name,buffer,MaxTextExtent); 00212 directory->entry.d_namlen=strlen(directory->entry.d_name); 00213 return(&directory->entry); 00214 } 00215 #endif /* !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) */ 00216 00217 /* 00218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00219 % % 00220 % % 00221 % % 00222 % I s M a g i c k C o n f l i c t % 00223 % % 00224 % % 00225 % % 00226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00227 % 00228 % VMSIsMagickConflict() returns true if the image format conflicts with a 00229 % logical drive (.e.g. SYS$SCRATCH:). 00230 % 00231 % Contributed by Forrest Cahoon (forrest@wiredaemons.com) 00232 % 00233 % The format of the VMSIsMagickConflict method is: 00234 % 00235 % MagickBooleanType VMSIsMagickConflict(const char *magick) 00236 % 00237 % A description of each parameter follows: 00238 % 00239 % o magick: Specifies the image format. 00240 % 00241 % 00242 */ 00243 MagickExport MagickBooleanType VMSIsMagickConflict(const char *magick) 00244 { 00245 ile3 00246 item_list[2]; 00247 00248 int 00249 device_class, 00250 status; 00251 00252 struct dsc$descriptor_s 00253 device; 00254 00255 assert(magick != (char *) NULL); 00256 device.dsc$w_length=strlen(magick); 00257 device.dsc$a_pointer=(char *) magick; 00258 device.dsc$b_class=DSC$K_CLASS_S; 00259 device.dsc$b_dtype=DSC$K_DTYPE_T; 00260 item_list[0].ile3$w_length=sizeof(device_class); 00261 item_list[0].ile3$w_code=DVI$_DEVCLASS; 00262 item_list[0].ile3$ps_bufaddr=&device_class; 00263 item_list[0].ile3$ps_retlen_addr=NULL; 00264 (void) ResetMagickMemory(&item_list[1],0,sizeof(item_list[1])); 00265 status=sys$getdviw(0,0,&device,&item_list,0,0,0,0); 00266 if ((status == SS$_NONLOCAL) || 00267 ((status & 0x01) && (device_class & (DC$_DISK | DC$_TAPE)))) 00268 return(MagickTrue); 00269 return(MagickFalse); 00270 } 00271 #endif /* defined(vms) */