18
#if __VMS_VER < 70000000
24
static struct FAB *dfab;
28
dfab = (struct FAB *) xmalloc (sizeof (struct FAB));
31
printf ("Error mallocing for FAB\n");
35
dnam = (struct NAM *) xmalloc (sizeof (struct NAM));
38
printf ("Error mallocing for NAM\n");
43
searchspec = (char *) xmalloc (MAXNAMLEN + 1);
46
printf ("Error mallocing for searchspec\n");
52
sprintf (searchspec, "%s*.*;", dspec);
55
dfab->fab$l_fna = searchspec;
56
dfab->fab$b_fns = strlen (searchspec);
57
dfab->fab$l_nam = dnam;
60
dnam->nam$l_esa = searchspec;
61
dnam->nam$b_ess = MAXNAMLEN;
63
if (! (sys$parse (dfab) & 1))
74
#define uppercasify(str) \
78
for (tmp = (str); *tmp != '\0'; tmp++) \
80
*tmp = toupper (*tmp); \
88
static struct direct *dentry;
89
static char resultspec[MAXNAMLEN + 1];
92
dentry = (struct direct *) xmalloc (sizeof (struct direct));
95
printf ("Error mallocing for direct\n");
99
dfd->fab$l_nam->nam$l_rsa = resultspec;
100
dfd->fab$l_nam->nam$b_rss = MAXNAMLEN;
105
if (!((i = sys$search (dfd)) & 1))
108
printf ("sys$search failed with %d\n", i);
114
if (dfd->fab$l_nam->nam$w_fid == 0)
115
dentry->d_fileno = 1;
117
dentry->d_fileno = dfd->fab$l_nam->nam$w_fid[0]
118
+ dfd->fab$l_nam->nam$w_fid[1] << 16;
119
dentry->d_reclen = sizeof (struct direct);
121
if (!strcmp(dfd->fab$l_nam->nam$l_type, ".DIR"))
122
dentry->d_namlen = dfd->fab$l_nam->nam$b_name;
125
dentry->d_namlen = dfd->fab$l_nam->nam$b_name + dfd->fab$l_nam->nam$b_type;
126
strncpy (dentry->d_name, dfd->fab$l_nam->nam$l_name, dentry->d_namlen);
127
dentry->d_name[dentry->d_namlen] = '\0';
128
uppercasify (dentry->d_name);
130
uvUnFixRCSSeparator(dentry->d_name);
142
free (dfd->fab$l_nam->nam$l_esa);
143
free (dfd->fab$l_nam);
147
#endif /* compiled for OpenVMS prior to V7.x */
153
static char buf[512];
156
return (getcwd (cwd, 512));
158
return (getcwd (buf, 512));
169
static struct FAB Fab;
170
static struct NAM Nam;
171
static struct fibdef Fib; /* short fib */
172
static struct dsc$descriptor FibDesc =
173
{ sizeof (Fib), DSC$K_DTYPE_Z, DSC$K_CLASS_S, (char *) &Fib };
174
static struct dsc$descriptor_s DevDesc =
175
{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &Nam.nam$t_dvi[1] };
176
static char EName[NAM$C_MAXRSS];
177
static char RName[NAM$C_MAXRSS];
178
static struct dsc$descriptor_s FileName =
179
{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 };
180
static struct dsc$descriptor_s string =
181
{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0 };
182
static unsigned long Rdate[2];
183
static unsigned long Cdate[2];
184
static struct atrdef Atr[] =
188
{ sizeof (Rdate), ATR$C_REVDATE, (unsigned int) &Rdate[0] },
190
{ sizeof (Cdate), ATR$C_CREDATE, (unsigned int) &Cdate[0] },
193
{ sizeof (Rdate), ATR$C_REVDATE, &Rdate[0] },
195
{ sizeof (Cdate), ATR$C_CREDATE, &Cdate[0]},
199
static short int DevChan;
200
static short int iosb[4];
202
name = vmsify (name, 0);
204
/* initialize RMS structures, we need a NAM to retrieve the FID */
206
Fab.fab$l_fna = name; /* name of file */
207
Fab.fab$b_fns = strlen (name);
208
Fab.fab$l_nam = &Nam; /* FAB has an associated NAM */
211
Nam.nam$l_esa = EName; /* expanded filename */
212
Nam.nam$b_ess = sizeof (EName);
213
Nam.nam$l_rsa = RName; /* resultant filename */
214
Nam.nam$b_rss = sizeof (RName);
216
/* do $PARSE and $SEARCH here */
217
status = sys$parse (&Fab);
221
DevDesc.dsc$w_length = Nam.nam$t_dvi[0];
222
status = sys$assign (&DevDesc, &DevChan, 0, 0);
226
FileName.dsc$a_pointer = Nam.nam$l_name;
227
FileName.dsc$w_length = Nam.nam$b_name + Nam.nam$b_type + Nam.nam$b_ver;
229
/* Initialize the FIB */
230
for (i = 0; i < 3; i++)
233
Fib.fib$w_fid[i] = Nam.nam$w_fid[i];
234
Fib.fib$w_did[i] = Nam.nam$w_did[i];
236
Fib.fib$r_fid_overlay.fib$w_fid[i] = Nam.nam$w_fid[i];
237
Fib.fib$r_did_overlay.fib$w_did[i] = Nam.nam$w_did[i];
241
status = sys$qiow (0, DevChan, IO$_ACCESS, &iosb, 0, 0,
242
&FibDesc, &FileName, 0, 0, &Atr, 0);
243
sys$dassgn (DevChan);
250
status = stat (name, buf);
254
buf->st_mtime = ((Rdate[0] >> 24) & 0xff) + ((Rdate[1] << 8) & 0xffffff00);
255
buf->st_ctime = ((Cdate[0] >> 24) & 0xff) + ((Cdate[1] << 8) & 0xffffff00);
264
static long int date[2];
266
static struct dsc$descriptor date_str =
267
{ 26, DSC$K_DTYPE_T, DSC$K_CLASS_S, str };
269
date[0] = (tval & 0xff) << 24;
270
date[1] = ((tval >> 8) & 0xffffff);
272
if ((date[0] == 0) && (date[1] == 0))
275
sys$asctim (0, &date_str, date, 0);