Commit | Line | Data |
a0d0e21e |
1 | /* vmsish.h |
2 | * |
3 | * VMS-specific C header file for perl5. |
4 | * |
748a9306 |
5 | * Last revised: 12-Dec-1994 by Charles Bailey bailey@genetics.upenn.edu |
a0d0e21e |
6 | */ |
7 | |
8 | #ifndef __vmsish_h_included |
9 | #define __vmsish_h_included |
10 | |
11 | #include <descrip.h> /* for dirent struct definitions */ |
748a9306 |
12 | #include <libdef.h> /* status codes for various places */ |
13 | #include <rmsdef.h> /* at which errno and vaxc$errno are */ |
14 | #include <ssdef.h> /* explicitly set in the perl source code */ |
15 | |
4633a7c4 |
16 | /* Suppress compiler warnings from DECC for VMS-specific extensions: |
17 | * GLOBALEXT, NOSHAREEXT: global[dr]ef declarations |
18 | * ADDRCONSTEXT: initialization of data with non-constant values |
19 | * (e.g. pointer fields of descriptors) |
20 | */ |
21 | #ifdef __DECC |
22 | # pragma message disable (GLOBALEXT,NOSHAREEXT,ADDRCONSTEXT) |
23 | #endif |
24 | |
748a9306 |
25 | /* DEC's C compilers and gcc use incompatible definitions of _to(upp|low)er() */ |
26 | #ifdef _toupper |
27 | # undef _toupper |
28 | #endif |
29 | #define _toupper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) & ~040) |
30 | #ifdef _tolower |
31 | # undef _tolower |
32 | #endif |
33 | #define _tolower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) | 040) |
4633a7c4 |
34 | /* DECC 1.3 has a funny definition of abs; it's fixed in DECC 4.0, so this |
35 | * can go away once DECC 1.3 isn't in use any more. */ |
36 | #if defined(__ALPHA) && defined(__DECC) |
37 | #undef abs |
38 | #define abs(__x) __ABS(__x) |
39 | #undef labs |
40 | #define labs(__x) __LABS(__x) |
41 | #endif /* __ALPHA && __DECC */ |
a0d0e21e |
42 | |
43 | /* Assorted things to look like Unix */ |
44 | #ifdef __GNUC__ |
45 | #ifndef _IOLBF /* gcc's stdio.h doesn't define this */ |
46 | #define _IOLBF 1 |
47 | #endif |
748a9306 |
48 | #endif |
a0d0e21e |
49 | #include <processes.h> /* for vfork() */ |
50 | #include <unixio.h> |
a0d0e21e |
51 | #include <unixlib.h> |
52 | #include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */ |
748a9306 |
53 | #define unlink kill_file |
54 | |
55 | /* Macros to set errno using the VAX thread-safe calls, if present */ |
56 | #if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA) |
57 | # define set_errno(v) (cma$tis_errno_set_value(v)) |
58 | # define set_vaxc_errno(v) (vaxc$errno = (v)) |
59 | #else |
60 | # define set_errno(v) (errno = (v)) |
61 | # define set_vaxc_errno(v) (vaxc$errno = (v)) |
62 | #endif |
63 | |
64 | /* Handy way to vet calls to VMS system services and RTL routines. */ |
65 | #define _ckvmssts(call) { register unsigned long int __ckvms_sts; \ |
66 | if (!((__ckvms_sts=(call))&1)) { \ |
67 | set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \ |
68 | croak("Fatal VMS error at %s, line %d",__FILE__,__LINE__); } } |
a0d0e21e |
69 | |
70 | #ifdef VMS_DO_SOCKETS |
71 | #include "sockadapt.h" |
72 | #endif |
73 | |
74 | /* |
75 | * The following symbols are defined (or undefined) according to the RTL |
76 | * support VMS provides for the corresponding functions. These don't |
77 | * appear in config.h, so they're dealt with here. |
78 | */ |
79 | #define HAS_KILL |
80 | #define HAS_WAIT |
81 | |
82 | /* The VMS C RTL has vfork() but not fork(). Both actually work in a way |
83 | * that's somewhere between Unix vfork() and VMS lib$spawn(), so it's |
84 | * probably not a good idea to use them much. That said, we'll try to |
85 | * use vfork() in either case. |
86 | */ |
87 | #define fork vfork |
88 | |
89 | /* |
90 | * fwrite1() should be a routine with the same calling sequence as fwrite(), |
91 | * but which outputs all of the bytes requested as a single stream (unlike |
92 | * fwrite() itself, which on some systems outputs several distinct records |
93 | * if the number_of_items parameter is >1). |
94 | */ |
95 | #define fwrite1 my_fwrite |
96 | |
97 | /* Use our own rmdir() */ |
98 | #define rmdir(name) do_rmdir(name) |
99 | |
100 | /* Assorted fiddling with sigs . . . */ |
101 | # include <signal.h> |
102 | #define ABORT() abort() |
103 | |
748a9306 |
104 | /* Used with our my_utime() routine in vms.c */ |
105 | struct utimbuf { |
106 | time_t actime; |
107 | time_t modtime; |
108 | }; |
109 | #define utime my_utime |
110 | |
a0d0e21e |
111 | /* This is what times() returns, but <times.h> calls it tbuffer_t on VMS */ |
112 | |
113 | struct tms { |
114 | clock_t tms_utime; /* user time */ |
115 | clock_t tms_stime; /* system time - always 0 on VMS */ |
116 | clock_t tms_cutime; /* user time, children */ |
117 | clock_t tms_cstime; /* system time, children - always 0 on VMS */ |
118 | }; |
119 | |
120 | /* VMS doesn't use a real sys_nerr, but we need this when scanning for error |
121 | * messages in text strings . . . |
122 | */ |
123 | |
124 | #define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */ |
125 | |
126 | /* Look up new %ENV values on the fly */ |
127 | #define DYNAMIC_ENV_FETCH 1 |
128 | #define ENV_HV_NAME "%EnV%VmS%" |
129 | |
130 | /* Use our own stat() clones, which handle Unix-style directory names */ |
131 | #define Stat(name,bufptr) flex_stat(name,bufptr) |
132 | #define Fstat(fd,bufptr) flex_fstat(fd,bufptr) |
133 | |
134 | /* Setup for the dirent routines: |
135 | * opendir(), closedir(), readdir(), seekdir(), telldir(), and |
136 | * vmsreaddirversions(), and preprocessor stuff on which these depend: |
137 | * Written by Rich $alz, <rsalz@bbn.com> in August, 1990. |
138 | * This code has no copyright. |
139 | */ |
140 | /* Data structure returned by READDIR(). */ |
141 | struct dirent { |
142 | char d_name[256]; /* File name */ |
143 | int d_namlen; /* Length of d_name */ |
144 | int vms_verscount; /* Number of versions */ |
145 | int vms_versions[20]; /* Version numbers */ |
146 | }; |
147 | |
148 | /* Handle returned by opendir(), used by the other routines. You |
149 | * are not supposed to care what's inside this structure. */ |
150 | typedef struct _dirdesc { |
151 | long context; |
152 | int vms_wantversions; |
153 | unsigned long int count; |
154 | char *pattern; |
155 | struct dirent entry; |
156 | struct dsc$descriptor_s pat; |
157 | } DIR; |
158 | |
159 | #define rewinddir(dirp) seekdir((dirp), 0) |
160 | |
748a9306 |
161 | /* used for our emulation of getpw* */ |
162 | struct passwd { |
163 | char *pw_name; /* Username */ |
164 | char *pw_passwd; |
165 | Uid_t pw_uid; /* UIC member number */ |
166 | Gid_t pw_gid; /* UIC group number */ |
167 | char *pw_comment; /* Default device/directory (Unix-style) */ |
168 | char *pw_gecos; /* Owner */ |
169 | char *pw_dir; /* Default device/directory (VMS-style) */ |
170 | char *pw_shell; /* Default CLI name (eg. DCL) */ |
171 | }; |
172 | #define pw_unixdir pw_comment /* Default device/directory (Unix-style) */ |
173 | #define getpwnam my_getpwnam |
174 | #define getpwuid my_getpwuid |
175 | #define getpwent my_getpwent |
176 | #define endpwent my_endpwent |
177 | #define setpwent my_endpwent |
178 | |
179 | /* Our own stat_t substitute, since we play with st_dev and st_ino - |
180 | * we want atomic types so Unix-bound code which compares these fields |
181 | * for two files will work most of the time under VMS |
182 | */ |
183 | /* First, grab the system types, so we don't clobber them later */ |
184 | #include <stat.h> |
185 | /* Since we've got to match the size of the CRTL's stat_t, we need |
186 | * to mimic DECC's alignment settings. |
187 | */ |
188 | #if defined(__DECC) || defined(__DECCXX) |
189 | # pragma __member_alignment __save |
190 | # pragma __nomember_alignment |
191 | #endif |
192 | #if defined(__DECC) |
193 | # pragma __message __save |
194 | # pragma __message disable (__MISALGNDSTRCT) |
195 | # pragma __message disable (__MISALGNDMEM) |
196 | #endif |
197 | struct mystat |
198 | { |
199 | char *st_devnam; /* pointer to device name */ |
200 | union { |
201 | unsigned short fid[3]; |
202 | unsigned long st_ino_mostly; |
203 | } st_inode_u; |
204 | unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */ |
205 | int st_nlink; /* for compatibility - not really used */ |
206 | unsigned st_uid; /* from ACP - QIO uic field */ |
207 | unsigned short st_gid; /* group number extracted from st_uid */ |
208 | dev_t st_rdev; /* for compatibility - always zero */ |
209 | off_t st_size; /* file size in bytes */ |
210 | unsigned st_atime; /* file access time; always same as st_mtime */ |
211 | unsigned st_mtime; /* last modification time */ |
212 | unsigned st_ctime; /* file creation time */ |
213 | char st_fab_rfm; /* record format */ |
214 | char st_fab_rat; /* record attributes */ |
215 | char st_fab_fsz; /* fixed header size */ |
216 | unsigned st_dev; /* encoded device name */ |
217 | }; |
218 | #ifdef st_ino |
219 | # undef st_ino |
220 | #endif |
221 | #define st_ino st_inode_u.st_ino_mostly |
222 | #define stat mystat |
223 | typedef unsigned mydev_t; |
224 | #define dev_t mydev_t |
225 | typedef unsigned long myino_t; |
226 | #define ino_t myino_t |
227 | #if defined(__DECC) || defined(__DECCXX) |
228 | # pragma __member_alignment __restore |
229 | #endif |
230 | #if defined(__DECC) |
231 | # pragma __message __restore |
232 | #endif |
233 | /* Cons up a 'delete' bit for testing access */ |
234 | #define S_IDUSR (S_IWUSR | S_IXUSR) |
235 | #define S_IDGRP (S_IWGRP | S_IXGRP) |
236 | #define S_IDOTH (S_IWOTH | S_IXOTH) |
a0d0e21e |
237 | |
238 | /* Prototypes for functions unique to vms.c. Don't include replacements |
239 | * for routines in the mainline source files excluded by #ifndef VMS; |
240 | * their prototypes are already in proto.h. |
241 | * |
242 | * In order to keep Gen_ShrFls.Pl happy, functions which are to be made |
243 | * available to images linked to PerlShr.Exe must be declared between the |
244 | * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form |
245 | * <data type><TAB>name<WHITESPACE>_((<prototype args>)); |
246 | */ |
247 | typedef char __VMS_PROTOTYPES__; /* prototype section start marker */ |
248 | char * my_getenv _((char *)); |
a0d0e21e |
249 | unsigned long int waitpid _((unsigned long int, int *, int)); |
a0d0e21e |
250 | char * my_gconvert _((double, int, int, char *)); |
251 | int do_rmdir _((char *)); |
252 | int kill_file _((char *)); |
748a9306 |
253 | int my_utime _((char *, struct utimbuf *)); |
a0d0e21e |
254 | char * fileify_dirspec _((char *, char *)); |
255 | char * fileify_dirspec_ts _((char *, char *)); |
256 | char * pathify_dirspec _((char *, char *)); |
257 | char * pathify_dirspec_ts _((char *, char *)); |
258 | char * tounixspec _((char *, char *)); |
259 | char * tounixspec_ts _((char *, char *)); |
260 | char * tovmsspec _((char *, char *)); |
261 | char * tovmsspec_ts _((char *, char *)); |
262 | char * tounixpath _((char *, char *)); |
263 | char * tounixpath_ts _((char *, char *)); |
264 | char * tovmspath _((char *, char *)); |
265 | char * tovmspath_ts _((char *, char *)); |
266 | void getredirection _(()); |
267 | DIR * opendir _((char *)); |
268 | struct dirent * readdir _((DIR *)); |
269 | long telldir _((DIR *)); |
270 | void seekdir _((DIR *, long)); |
271 | void closedir _((DIR *)); |
272 | void vmsreaddirversions _((DIR *, int)); |
273 | void getredirection _((int *, char ***)); |
748a9306 |
274 | I32 cando_by_name _((I32, I32, char *)); |
275 | int flex_fstat _((int, struct stat *)); |
276 | int flex_stat _((char *, struct stat *)); |
a0d0e21e |
277 | int trim_unixpath _((char *, char*)); |
748a9306 |
278 | bool vms_do_aexec _((SV *, SV **, SV **)); |
a0d0e21e |
279 | bool vms_do_exec _((char *)); |
748a9306 |
280 | unsigned long int do_aspawn _((SV *, SV **, SV **)); |
a0d0e21e |
281 | unsigned long int do_spawn _((char *)); |
282 | int my_fwrite _((void *, size_t, size_t, FILE *)); |
748a9306 |
283 | struct passwd * my_getpwnam _((char *name)); |
284 | struct passwd * my_getpwuid _((Uid_t uid)); |
285 | struct passwd * my_getpwent _(()); |
286 | void my_endpwent _(()); |
287 | void init_os_extras _(()); |
a0d0e21e |
288 | typedef char __VMS_SEPYTOTORP__; /* prototype section end marker */ |
289 | |
290 | #ifndef VMS_DO_SOCKETS |
748a9306 |
291 | /* This relies on tricks in perl.h to pick up that these manifest constants |
292 | * are undefined and set up conversion routines. It will then redefine |
293 | * these manifest constants, so the actual values will match config.h |
294 | */ |
295 | #undef HAS_HTONS |
296 | #undef HAS_NTOHS |
297 | #undef HAS_HTONL |
298 | #undef HAS_NTOHL |
a0d0e21e |
299 | #endif |
300 | |
301 | #endif /* __vmsish_h_included */ |