3 * VMS-specific C header file for perl5.
5 * Last revised: 01-Oct-1995 by Charles Bailey bailey@genetics.upenn.edu
9 #ifndef __vmsish_h_included
10 #define __vmsish_h_included
12 #include <descrip.h> /* for dirent struct definitions */
13 #include <libdef.h> /* status codes for various places */
14 #include <rmsdef.h> /* at which errno and vaxc$errno are */
15 #include <ssdef.h> /* explicitly set in the perl source code */
17 /* Suppress compiler warnings from DECC for VMS-specific extensions:
18 * GLOBALEXT, NOSHAREEXT: global[dr]ef declarations
19 * ADDRCONSTEXT: initialization of data with non-constant values
20 * (e.g. pointer fields of descriptors)
23 # pragma message disable (GLOBALEXT,NOSHAREEXT,ADDRCONSTEXT)
26 /* Suppress compiler warnings from DECC for VMS-specific extensions:
27 * GLOBALEXT, NOSHAREEXT: global[dr]ef declarations
28 * ADDRCONSTEXT,NEEDCONSTEXT: initialization of data with non-constant values
29 * (e.g. pointer fields of descriptors)
32 # pragma message disable (GLOBALEXT,NOSHAREEXT,ADDRCONSTEXT,NEEDCONSTEXT)
35 /* DEC's C compilers and gcc use incompatible definitions of _to(upp|low)er() */
39 #define _toupper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) & ~040)
43 #define _tolower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) | 040)
44 /* DECC 1.3 has a funny definition of abs; it's fixed in DECC 4.0, so this
45 * can go away once DECC 1.3 isn't in use any more. */
46 #if defined(__ALPHA) && defined(__DECC)
48 #define abs(__x) __ABS(__x)
50 #define labs(__x) __LABS(__x)
51 #endif /* __ALPHA && __DECC */
53 /* Assorted things to look like Unix */
55 #ifndef _IOLBF /* gcc's stdio.h doesn't define this */
59 #include <processes.h> /* for vfork() */
62 #include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */
63 #define unlink kill_file
65 /* The VMS C RTL has vfork() but not fork(). Both actually work in a way
66 * that's somewhere between Unix vfork() and VMS lib$spawn(), so it's
67 * probably not a good idea to use them much. That said, we'll try to
68 * use vfork() in either case.
72 /* Macros to set errno using the VAX thread-safe calls, if present */
73 #if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA)
74 # define set_errno(v) (cma$tis_errno_set_value(v))
75 # define set_vaxc_errno(v) (vaxc$errno = (v))
77 # define set_errno(v) (errno = (v))
78 # define set_vaxc_errno(v) (vaxc$errno = (v))
81 /* Handy way to vet calls to VMS system services and RTL routines. */
82 #define _ckvmssts(call) do { register unsigned long int __ckvms_sts; \
83 if (!((__ckvms_sts=(call))&1)) { \
84 set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \
85 croak("Fatal VMS error (status=%d) at %s, line %d", \
86 __ckvms_sts,__FILE__,__LINE__); } } while (0);
89 #include "sockadapt.h"
96 * This symbol, if defined, indicates that the program is running under
97 * VMS. It's a symbol automagically defined by all VMS C compilers I've seen.
98 * Just in case, however . . . */
104 * This symbol, if defined, indicates that the ioctl() routine is
105 * available to set I/O characteristics
107 #undef HAS_IOCTL /**/
110 * This symbol, if defined, indicates that the routine utime() is
111 * available to update the access and modification times of files.
113 #define HAS_UTIME /**/
116 * This symbol, if defined, indicates that the getgrnam(),
117 * getgrgid(), and getgrent() routines are available to
120 #undef HAS_GROUP /**/
123 * This symbol, if defined, indicates that the getpwnam(),
124 * getpwuid(), and getpwent() routines are available to
125 * get password entries.
127 #define HAS_PASSWD /**/
133 * fwrite1() should be a routine with the same calling sequence as fwrite(),
134 * but which outputs all of the bytes requested as a single stream (unlike
135 * fwrite() itself, which on some systems outputs several distinct records
136 * if the number_of_items parameter is >1).
138 #define fwrite1 my_fwrite
140 /* Use our own rmdir() */
141 #define rmdir(name) do_rmdir(name)
143 /* Assorted fiddling with sigs . . . */
145 #define ABORT() abort()
147 /* Used with our my_utime() routine in vms.c */
152 #define utime my_utime
154 /* This is what times() returns, but <times.h> calls it tbuffer_t on VMS */
157 clock_t tms_utime; /* user time */
158 clock_t tms_stime; /* system time - always 0 on VMS */
159 clock_t tms_cutime; /* user time, children */
160 clock_t tms_cstime; /* system time, children - always 0 on VMS */
163 /* Prior to VMS 7.0, the CRTL gmtime() routine was a stub which always
164 * returned NULL. Substitute our own routine, which uses the logical
165 * SYS$TIMEZONE_DIFFERENTIAL, whcih the native UTC support routines
166 * in VMS 6.0 or later use.*
168 #define gmtime(t) my_gmtime(t)
170 /* VMS doesn't use a real sys_nerr, but we need this when scanning for error
171 * messages in text strings . . .
174 #define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */
176 /* Look up new %ENV values on the fly */
177 #define DYNAMIC_ENV_FETCH 1
178 #define ENV_HV_NAME "%EnV%VmS%"
180 /* Use our own stat() clones, which handle Unix-style directory names */
181 #define Stat(name,bufptr) flex_stat(name,bufptr)
182 #define Fstat(fd,bufptr) flex_fstat(fd,bufptr)
184 /* Setup for the dirent routines:
185 * opendir(), closedir(), readdir(), seekdir(), telldir(), and
186 * vmsreaddirversions(), and preprocessor stuff on which these depend:
187 * Written by Rich $alz, <rsalz@bbn.com> in August, 1990.
188 * This code has no copyright.
190 /* Data structure returned by READDIR(). */
192 char d_name[256]; /* File name */
193 int d_namlen; /* Length of d_name */
194 int vms_verscount; /* Number of versions */
195 int vms_versions[20]; /* Version numbers */
198 /* Handle returned by opendir(), used by the other routines. You
199 * are not supposed to care what's inside this structure. */
200 typedef struct _dirdesc {
202 int vms_wantversions;
203 unsigned long int count;
206 struct dsc$descriptor_s pat;
209 #define rewinddir(dirp) seekdir((dirp), 0)
211 /* used for our emulation of getpw* */
213 char *pw_name; /* Username */
215 Uid_t pw_uid; /* UIC member number */
216 Gid_t pw_gid; /* UIC group number */
217 char *pw_comment; /* Default device/directory (Unix-style) */
218 char *pw_gecos; /* Owner */
219 char *pw_dir; /* Default device/directory (VMS-style) */
220 char *pw_shell; /* Default CLI name (eg. DCL) */
222 #define pw_unixdir pw_comment /* Default device/directory (Unix-style) */
223 #define getpwnam my_getpwnam
224 #define getpwuid my_getpwuid
225 #define getpwent my_getpwent
226 #define endpwent my_endpwent
227 #define setpwent my_endpwent
229 /* Our own stat_t substitute, since we play with st_dev and st_ino -
230 * we want atomic types so Unix-bound code which compares these fields
231 * for two files will work most of the time under VMS
233 /* First, grab the system types, so we don't clobber them later */
235 /* Since we've got to match the size of the CRTL's stat_t, we need
236 * to mimic DECC's alignment settings.
238 #if defined(__DECC) || defined(__DECCXX)
239 # pragma __member_alignment __save
240 # pragma __nomember_alignment
243 # pragma __message __save
244 # pragma __message disable (__MISALGNDSTRCT)
245 # pragma __message disable (__MISALGNDMEM)
249 char *st_devnam; /* pointer to device name */
251 unsigned short fid[3];
252 unsigned long st_ino_mostly;
254 unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */
255 int st_nlink; /* for compatibility - not really used */
256 unsigned st_uid; /* from ACP - QIO uic field */
257 unsigned short st_gid; /* group number extracted from st_uid */
258 dev_t st_rdev; /* for compatibility - always zero */
259 off_t st_size; /* file size in bytes */
260 unsigned st_atime; /* file access time; always same as st_mtime */
261 unsigned st_mtime; /* last modification time */
262 unsigned st_ctime; /* file creation time */
263 char st_fab_rfm; /* record format */
264 char st_fab_rat; /* record attributes */
265 char st_fab_fsz; /* fixed header size */
266 unsigned st_dev; /* encoded device name */
271 #define st_ino st_inode_u.st_ino_mostly
273 typedef unsigned mydev_t;
274 #define dev_t mydev_t
275 typedef unsigned long myino_t;
276 #define ino_t myino_t
277 #if defined(__DECC) || defined(__DECCXX)
278 # pragma __member_alignment __restore
281 # pragma __message __restore
283 /* Cons up a 'delete' bit for testing access */
284 #define S_IDUSR (S_IWUSR | S_IXUSR)
285 #define S_IDGRP (S_IWGRP | S_IXGRP)
286 #define S_IDOTH (S_IWOTH | S_IXOTH)
288 /* Prototypes for functions unique to vms.c. Don't include replacements
289 * for routines in the mainline source files excluded by #ifndef VMS;
290 * their prototypes are already in proto.h.
292 * In order to keep Gen_ShrFls.Pl happy, functions which are to be made
293 * available to images linked to PerlShr.Exe must be declared between the
294 * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form
295 * <data type><TAB>name<WHITESPACE>_((<prototype args>));
297 typedef char __VMS_PROTOTYPES__; /* prototype section start marker */
298 char * my_getenv _((char *));
299 unsigned long int waitpid _((unsigned long int, int *, int));
300 char * my_gconvert _((double, int, int, char *));
301 int do_rmdir _((char *));
302 int kill_file _((char *));
303 int my_utime _((char *, struct utimbuf *));
304 char * fileify_dirspec _((char *, char *));
305 char * fileify_dirspec_ts _((char *, char *));
306 char * pathify_dirspec _((char *, char *));
307 char * pathify_dirspec_ts _((char *, char *));
308 char * tounixspec _((char *, char *));
309 char * tounixspec_ts _((char *, char *));
310 char * tovmsspec _((char *, char *));
311 char * tovmsspec_ts _((char *, char *));
312 char * tounixpath _((char *, char *));
313 char * tounixpath_ts _((char *, char *));
314 char * tovmspath _((char *, char *));
315 char * tovmspath_ts _((char *, char *));
316 void getredirection _(());
317 DIR * opendir _((char *));
318 struct dirent * readdir _((DIR *));
319 long telldir _((DIR *));
320 void seekdir _((DIR *, long));
321 void closedir _((DIR *));
322 void vmsreaddirversions _((DIR *, int));
323 void getredirection _((int *, char ***));
324 struct tm *my_gmtime _((const time_t *));
325 I32 cando_by_name _((I32, I32, char *));
326 int flex_fstat _((int, struct stat *));
327 int flex_stat _((char *, struct stat *));
328 int trim_unixpath _((char *, char*));
329 bool vms_do_aexec _((SV *, SV **, SV **));
330 bool vms_do_exec _((char *));
331 unsigned long int do_aspawn _((SV *, SV **, SV **));
332 unsigned long int do_spawn _((char *));
333 int my_fwrite _((void *, size_t, size_t, FILE *));
334 struct passwd * my_getpwnam _((char *name));
335 struct passwd * my_getpwuid _((Uid_t uid));
336 struct passwd * my_getpwent _(());
337 void my_endpwent _(());
338 void init_os_extras _(());
339 typedef char __VMS_SEPYTOTORP__; /* prototype section end marker */
341 #ifndef VMS_DO_SOCKETS
342 /* This relies on tricks in perl.h to pick up that these manifest constants
343 * are undefined and set up conversion routines. It will then redefine
344 * these manifest constants, so the actual values will match config.h
352 #endif /* __vmsish_h_included */