MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
vms.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % V V M M SSSSS %
7 % V V MM MM SS %
8 % V V M M M SSS %
9 % V V M M SS %
10 % V M M SSSSS %
11 % %
12 % %
13 % MagickCore VMS Utility Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % October 1994 %
18 % %
19 % %
20 % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % https://www.imagemagick.org/script/license.php %
27 % %
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. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 % The directory methods are strongly based on similar methods written
37 % by Rich Salz.
38 %
39 */
40 
41 #if defined(vms)
42 /*
43  Include declarations.
44 */
45 #include "MagickCore/studio.h"
46 #include "MagickCore/string_.h"
47 #include "MagickCore/memory_.h"
48 #include "MagickCore/vms.h"
49 
50 #if !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000))
51 /*
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 % %
54 % %
55 % %
56 % c l o s e d i r %
57 % %
58 % %
59 % %
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %
62 % closedir() closes the named directory stream and frees the DIR structure.
63 %
64 % The format of the closedir method is:
65 %
66 %
67 % A description of each parameter follows:
68 %
69 % o entry: Specifies a pointer to a DIR structure.
70 %
71 %
72 */
73 void closedir(DIR *directory)
74 {
75  if (image->debug != MagickFalse)
77  assert(directory != (DIR *) NULL);
78  directory->pattern=DestroyString(directory->pattern);
79  directory=DestroyString(directory);
80 }
81 
82 /*
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 % %
85 % %
86 % %
87 % o p e n d i r %
88 % %
89 % %
90 % %
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 %
93 % opendir() opens the directory named by filename and associates a directory
94 % stream with it.
95 %
96 % The format of the opendir method is:
97 %
98 % opendir(entry)
99 %
100 % A description of each parameter follows:
101 %
102 % o entry: Specifies a pointer to a DIR structure.
103 %
104 %
105 */
106 DIR *opendir(char *name)
107 {
108  DIR
109  *directory;
110 
111  /*
112  Allocate memory for handle and the pattern.
113  */
114  directory=(DIR *) AcquireMagickMemory(sizeof(DIR));
115  if (directory == (DIR *) NULL)
116  {
117  errno=ENOMEM;
118  return((DIR *) NULL);
119  }
120  if (strcmp(".",name) == 0)
121  name="";
122  directory->pattern=(char *) AcquireQuantumMemory(strlen(name)+sizeof("*.*")+
123  1UL,sizeof(*directory->pattern));
124  if (directory->pattern == (char *) NULL)
125  {
126  directory=DestroyString(directory);
127  errno=ENOMEM;
128  return(NULL);
129  }
130  /*
131  Initialize descriptor.
132  */
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;
139  return(directory);
140 }
141 
142 /*
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144 % %
145 % %
146 % %
147 % r e a d d i r %
148 % %
149 % %
150 % %
151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
152 %
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.
155 %
156 % The format of the readdir
157 %
158 % readdir(entry)
159 %
160 % A description of each parameter follows:
161 %
162 % o entry: Specifies a pointer to a DIR structure.
163 %
164 %
165 */
166 struct dirent *readdir(DIR *directory)
167 {
168  char
169  buffer[sizeof(directory->entry.d_name)];
170 
171  int
172  status;
173 
174  register char
175  *p;
176 
177  register int
178  i;
179 
180  struct dsc$descriptor_s
181  result;
182 
183  /*
184  Initialize the result descriptor.
185  */
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);
193  /*
194  Lowercase all filenames.
195  */
196  buffer[sizeof(buffer)-1]='\0';
197  for (p=buffer; *p; p++)
198  if (isupper((int) ((unsigned char) *p)))
199  *p=tolower(*p);
200  /*
201  Skip any directory component and just copy the name.
202  */
203  p=buffer;
204  while (isspace((int) ((unsigned char) *p)) == 0)
205  p++;
206  *p='\0';
207  p=strchr(buffer,']');
208  if (p)
209  (void) CopyMagickString(directory->entry.d_name,p+1,MagickPathExtent);
210  else
211  (void) CopyMagickString(directory->entry.d_name,buffer,MagickPathExtent);
212  directory->entry.d_namlen=strlen(directory->entry.d_name);
213  return(&directory->entry);
214 }
215 #endif /* !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) */
216 
217 /*
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219 % %
220 % %
221 % %
222 % I s M a g i c k C o n f l i c t %
223 % %
224 % %
225 % %
226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
227 %
228 % VMSIsMagickConflict() returns true if the image format conflicts with a
229 % logical drive (.e.g. SYS$SCRATCH:).
230 %
231 % Contributed by Forrest Cahoon (forrest@wiredaemons.com)
232 %
233 % The format of the VMSIsMagickConflict method is:
234 %
235 % MagickBooleanType VMSIsMagickConflict(const char *magick)
236 %
237 % A description of each parameter follows:
238 %
239 % o magick: Specifies the image format.
240 %
241 %
242 */
244 {
245  ile3
246  item_list[2];
247 
248  int
249  device_class,
250  status;
251 
252  struct dsc$descriptor_s
253  device;
254 
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) ResetMagickMemory(&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))))
268  return(MagickTrue);
269  return(MagickFalse);
270 }
271 #endif /* defined(vms) */
#define lib
Definition: vms.h:763
char d_name[255]
Definition: vms.h:944
char * pattern
Definition: vms.h:956
long context
Definition: vms.h:953
struct dsc $descriptor_s pat
Definition: vms.h:961
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:473
Definition: vms.h:941
DIR * opendir(char *)
Definition: log.h:52
MagickBooleanType
Definition: magick-type.h:156
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1164
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:529
Definition: vms.h:950
struct dirent * readdir(DIR *)
MagickExport MagickBooleanType VMSIsMagickConflict(const char *)
#define MagickPathExtent
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1397
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:742
Definition: vms.h:918
struct dirent entry
Definition: vms.h:958
#define GetMagickModule()
Definition: log.h:28
void closedir(DIR *)
MagickExport char * DestroyString(char *string)
Definition: string.c:810
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:458
#define sys
Definition: vms.h:863
#define MagickExport
int d_namlen
Definition: vms.h:947