2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % MagickCore VMS Utility Methods %
20 % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % https://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % The directory methods are strongly based on similar methods written
45 #include "MagickCore/studio.h"
46 #include "MagickCore/string_.h"
47 #include "MagickCore/memory_.h"
48 #include "MagickCore/vms.h"
50 #if !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000))
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 % closedir() closes the named directory stream and frees the DIR structure.
64 % The format of the closedir method is:
67 % A description of each parameter follows:
69 % o entry: Specifies a pointer to a DIR structure.
73 void closedir(DIR *directory)
75 if (image->debug != MagickFalse)
76 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
77 assert(directory != (DIR *) NULL);
78 directory->pattern=DestroyString(directory->pattern);
79 directory=DestroyString(directory);
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 % opendir() opens the directory named by filename and associates a directory
96 % The format of the opendir method is:
100 % A description of each parameter follows:
102 % o entry: Specifies a pointer to a DIR structure.
106 DIR *opendir(char *name)
112 Allocate memory for handle and the pattern.
114 directory=(DIR *) AcquireMagickMemory(sizeof(DIR));
115 if (directory == (DIR *) NULL)
118 return((DIR *) NULL);
120 if (strcmp(".",name) == 0)
122 directory->pattern=(char *) AcquireQuantumMemory(strlen(name)+sizeof("*.*")+
123 1UL,sizeof(*directory->pattern));
124 if (directory->pattern == (char *) NULL)
126 directory=DestroyString(directory);
131 Initialize descriptor.
133 (void) FormatLocaleString(directory->pattern,MagickPathExtent,"%s*.*",name);
134 directory->context=0;
135 directory->pat.dsc$a_pointer=directory->pattern;
136 directory->pat.dsc$w_length=strlen(directory->pattern);
137 directory->pat.dsc$b_dtype=DSC$K_DTYPE_T;
138 directory->pat.dsc$b_class=DSC$K_CLASS_S;
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 % readdir() returns a pointer to a structure representing the directory entry
154 % at the current position in the directory stream to which entry refers.
156 % The format of the readdir
160 % A description of each parameter follows:
162 % o entry: Specifies a pointer to a DIR structure.
166 struct dirent *readdir(DIR *directory)
169 buffer[sizeof(directory->entry.d_name)];
180 struct dsc$descriptor_s
184 Initialize the result descriptor.
186 result.dsc$a_pointer=buffer;
187 result.dsc$w_length=sizeof(buffer)-2;
188 result.dsc$b_dtype=DSC$K_DTYPE_T;
189 result.dsc$b_class=DSC$K_CLASS_S;
190 status=lib$find_file(&directory->pat,&result,&directory->context);
191 if ((status == RMS$_NMF) || (directory->context == 0L))
192 return((struct dirent *) NULL);
194 Lowercase all filenames.
196 buffer[sizeof(buffer)-1]='\0';
197 for (p=buffer; *p; p++)
198 if (isupper((int) ((unsigned char) *p)))
201 Skip any directory component and just copy the name.
204 while (isspace((int) ((unsigned char) *p)) == 0)
207 p=strchr(buffer,']');
209 (void) CopyMagickString(directory->entry.d_name,p+1,MagickPathExtent);
211 (void) CopyMagickString(directory->entry.d_name,buffer,MagickPathExtent);
212 directory->entry.d_namlen=strlen(directory->entry.d_name);
213 return(&directory->entry);
215 #endif /* !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) */
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
222 % I s M a g i c k C o n f l i c t %
226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 % VMSIsMagickConflict() returns true if the image format conflicts with a
229 % logical drive (.e.g. SYS$SCRATCH:).
231 % Contributed by Forrest Cahoon (forrest@wiredaemons.com)
233 % The format of the VMSIsMagickConflict method is:
235 % MagickBooleanType VMSIsMagickConflict(const char *magick)
237 % A description of each parameter follows:
239 % o magick: Specifies the image format.
243 MagickExport MagickBooleanType VMSIsMagickConflict(const char *magick)
252 struct dsc$descriptor_s
255 assert(magick != (char *) NULL);
256 device.dsc$w_length=strlen(magick);
257 device.dsc$a_pointer=(char *) magick;
258 device.dsc$b_class=DSC$K_CLASS_S;
259 device.dsc$b_dtype=DSC$K_DTYPE_T;
260 item_list[0].ile3$w_length=sizeof(device_class);
261 item_list[0].ile3$w_code=DVI$_DEVCLASS;
262 item_list[0].ile3$ps_bufaddr=&device_class;
263 item_list[0].ile3$ps_retlen_addr=NULL;
264 (void) memset(&item_list[1],0,sizeof(item_list[1]));
265 status=sys$getdviw(0,0,&device,&item_list,0,0,0,0);
266 if ((status == SS$_NONLOCAL) ||
267 ((status & 0x01) && (device_class & (DC$_DISK | DC$_TAPE))))
271 #endif /* defined(vms) */