Commit | Line | Data |
a0d0e21e |
1 | /* vmsish.h |
2 | * |
3 | * VMS-specific C header file for perl5. |
4 | * |
562a7b0c |
5 | * Last revised: 16-Sep-1998 by Charles Bailey bailey@newman.upenn.edu |
6 | * Version: 5.5.2 |
a0d0e21e |
7 | */ |
8 | |
9 | #ifndef __vmsish_h_included |
10 | #define __vmsish_h_included |
11 | |
12 | #include <descrip.h> /* for dirent struct definitions */ |
748a9306 |
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 */ |
4fdae800 |
16 | #include <stsdef.h> /* bitmasks for exit status testing */ |
748a9306 |
17 | |
4633a7c4 |
18 | /* Suppress compiler warnings from DECC for VMS-specific extensions: |
e518068a |
19 | * ADDRCONSTEXT,NEEDCONSTEXT: initialization of data with non-constant values |
20 | * (e.g. pointer fields of descriptors) |
21 | */ |
22 | #ifdef __DECC |
17f28c40 |
23 | # pragma message disable (ADDRCONSTEXT,NEEDCONSTEXT) |
e518068a |
24 | #endif |
25 | |
748a9306 |
26 | /* DEC's C compilers and gcc use incompatible definitions of _to(upp|low)er() */ |
27 | #ifdef _toupper |
28 | # undef _toupper |
29 | #endif |
30 | #define _toupper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) & ~040) |
31 | #ifdef _tolower |
32 | # undef _tolower |
33 | #endif |
34 | #define _tolower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) | 040) |
4633a7c4 |
35 | /* DECC 1.3 has a funny definition of abs; it's fixed in DECC 4.0, so this |
36 | * can go away once DECC 1.3 isn't in use any more. */ |
37 | #if defined(__ALPHA) && defined(__DECC) |
38 | #undef abs |
39 | #define abs(__x) __ABS(__x) |
40 | #undef labs |
41 | #define labs(__x) __LABS(__x) |
42 | #endif /* __ALPHA && __DECC */ |
a0d0e21e |
43 | |
44 | /* Assorted things to look like Unix */ |
45 | #ifdef __GNUC__ |
46 | #ifndef _IOLBF /* gcc's stdio.h doesn't define this */ |
47 | #define _IOLBF 1 |
48 | #endif |
748a9306 |
49 | #endif |
a0d0e21e |
50 | #include <processes.h> /* for vfork() */ |
51 | #include <unixio.h> |
a0d0e21e |
52 | #include <unixlib.h> |
53 | #include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */ |
774d564b |
54 | #if defined(__DECC) && defined(__DECC_VER) && __DECC_VER > 20000000 |
bbce6d69 |
55 | # include <unistd.h> /* DECC has this; VAXC and gcc don't */ |
56 | #endif |
bf109933 |
57 | |
09b7f37c |
58 | /* VAXC doesn't have a unary plus operator, so we need to get there indirectly */ |
59 | #if defined(VAXC) && !defined(__DECC) |
60 | # define NO_UNARY_PLUS |
61 | #endif |
62 | |
aa689395 |
63 | #ifdef NO_PERL_TYPEDEFS /* a2p; we don't want Perl's special routines */ |
64 | # define DONT_MASK_RTL_CALLS |
65 | #endif |
66 | |
562a7b0c |
67 | /* Note that we do, in fact, have this */ |
68 | #define HAS_GETENV_SV |
cc077a9f |
69 | #define HAS_GETENV_LEN |
562a7b0c |
70 | |
aa689395 |
71 | #ifndef DONT_MASK_RTL_CALLS |
72 | # ifdef getenv |
73 | # undef getenv |
74 | # endif |
562a7b0c |
75 | /* getenv used for regular logical names */ |
76 | # define getenv(v) my_getenv(v,TRUE) |
aa689395 |
77 | #endif |
a6c40364 |
78 | #define getenv_len(v,l) my_getenv_len(v,l,TRUE) |
aa689395 |
79 | |
4fdae800 |
80 | /* DECC introduces this routine in the RTL as of VMS 7.0; for now, |
81 | * we'll use ours, since it gives us the full VMS exit status. */ |
4fdae800 |
82 | #define waitpid my_waitpid |
83 | |
61bb5906 |
84 | /* Don't redeclare standard RTL routines in Perl's header files; |
85 | * VMS history or extensions makes some of the formal protoypes |
86 | * differ from the common Unix forms. |
87 | */ |
88 | #define DONT_DECLARE_STD 1 |
89 | |
bf109933 |
90 | /* Our own contribution to PerlShr's global symbols . . . */ |
562a7b0c |
91 | #define vmstrnenv Perl_vmstrnenv |
92 | #define my_trnlnm Perl_my_trnlnm |
a6c40364 |
93 | #define my_getenv_len Perl_my_getenv_len |
562a7b0c |
94 | #define prime_env_iter Perl_prime_env_iter |
95 | #define vmssetenv Perl_vmssetenv |
5c84aa53 |
96 | #if !defined(PERL_IMPLICIT_CONTEXT) |
562a7b0c |
97 | #define my_setenv Perl_my_setenv |
5c84aa53 |
98 | #define my_getenv Perl_my_getenv |
99 | #else |
100 | #define my_setenv(a,b) Perl_my_setenv(aTHX_ a,b) |
101 | #define my_getenv(a,b) Perl_my_getenv(aTHX_ a,b) |
102 | #endif |
562a7b0c |
103 | #define my_crypt Perl_my_crypt |
104 | #define my_waitpid Perl_my_waitpid |
105 | #define my_gconvert Perl_my_gconvert |
106 | #define do_rmdir Perl_do_rmdir |
107 | #define kill_file Perl_kill_file |
108 | #define my_mkdir Perl_my_mkdir |
109 | #define my_utime Perl_my_utime |
110 | #define rmsexpand Perl_rmsexpand |
111 | #define rmsexpand_ts Perl_rmsexpand_ts |
112 | #define fileify_dirspec Perl_fileify_dirspec |
113 | #define fileify_dirspec_ts Perl_fileify_dirspec_ts |
114 | #define pathify_dirspec Perl_pathify_dirspec |
115 | #define pathify_dirspec_ts Perl_pathify_dirspec_ts |
116 | #define tounixspec Perl_tounixspec |
117 | #define tounixspec_ts Perl_tounixspec_ts |
118 | #define tovmsspec Perl_tovmsspec |
119 | #define tovmsspec_ts Perl_tovmsspec_ts |
120 | #define tounixpath Perl_tounixpath |
121 | #define tounixpath_ts Perl_tounixpath_ts |
122 | #define tovmspath Perl_tovmspath |
123 | #define tovmspath_ts Perl_tovmspath_ts |
124 | #define vms_image_init Perl_vms_image_init |
125 | #define opendir Perl_opendir |
126 | #define readdir Perl_readdir |
127 | #define telldir Perl_telldir |
128 | #define seekdir Perl_seekdir |
129 | #define closedir Perl_closedir |
130 | #define vmsreaddirversions Perl_vmsreaddirversions |
131 | #define my_gmtime Perl_my_gmtime |
132 | #define my_localtime Perl_my_localtime |
133 | #define my_time Perl_my_time |
134 | #define my_sigemptyset Perl_my_sigemptyset |
135 | #define my_sigfillset Perl_my_sigfillset |
136 | #define my_sigaddset Perl_my_sigaddset |
137 | #define my_sigdelset Perl_my_sigdelset |
138 | #define my_sigismember Perl_my_sigismember |
139 | #define my_sigprocmask Perl_my_sigprocmask |
140 | #define cando_by_name Perl_cando_by_name |
141 | #define flex_fstat Perl_flex_fstat |
142 | #define flex_stat Perl_flex_stat |
143 | #define trim_unixpath Perl_trim_unixpath |
144 | #define my_vfork Perl_my_vfork |
145 | #define vms_do_aexec Perl_vms_do_aexec |
146 | #define vms_do_exec Perl_vms_do_exec |
147 | #define do_aspawn Perl_do_aspawn |
148 | #define do_spawn Perl_do_spawn |
149 | #define my_fwrite Perl_my_fwrite |
150 | #define my_flush Perl_my_flush |
151 | #define my_getpwnam Perl_my_getpwnam |
152 | #define my_getpwuid Perl_my_getpwuid |
153 | #define my_getpwent Perl_my_getpwent |
154 | #define my_endpwent Perl_my_endpwent |
155 | #define my_getlogin Perl_my_getlogin |
156 | #define rmscopy Perl_rmscopy |
157 | #define init_os_extras Perl_init_os_extras |
bf109933 |
158 | |
159 | /* Delete if at all possible, changing protections if necessary. */ |
748a9306 |
160 | #define unlink kill_file |
161 | |
0414b1a0 |
162 | /* |
163 | * Intercept calls to fork, so we know whether subsequent calls to |
164 | * exec should be handled in VMSish or Unixish style. |
165 | */ |
166 | #define fork my_vfork |
aa689395 |
167 | #ifndef DONT_MASK_RTL_CALLS /* #defined in vms.c so we see real vfork */ |
0414b1a0 |
168 | # ifdef vfork |
169 | # undef vfork |
170 | # endif |
171 | # define vfork my_vfork |
172 | #endif |
173 | |
174 | /* BIG_TIME: |
175 | * This symbol is defined if Time_t is an unsigned type on this system. |
176 | */ |
177 | #define BIG_TIME |
178 | |
0414b1a0 |
179 | /* ACME_MESS: |
180 | * This symbol, if defined, indicates that error messages should be |
181 | * should be generated in a format that allows the use of the Acme |
182 | * GUI/editor's autofind feature. |
183 | */ |
184 | #undef ACME_MESS /**/ |
e518068a |
185 | |
44a8e56a |
186 | /* ALTERNATE_SHEBANG: |
187 | * This symbol, if defined, contains a "magic" string which may be used |
188 | * as the first line of a Perl program designed to be executed directly |
189 | * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG |
190 | * begins with a character other then #, then Perl will only treat |
191 | * it as a command line if if finds the string "perl" in the first |
192 | * word; otherwise it's treated as the first line of code in the script. |
193 | * (IOW, Perl won't hand off to another interpreter via an alternate |
194 | * shebang sequence that might be legal Perl code.) |
195 | */ |
196 | #define ALTERNATE_SHEBANG "$" |
197 | |
748a9306 |
198 | /* Macros to set errno using the VAX thread-safe calls, if present */ |
199 | #if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA) |
200 | # define set_errno(v) (cma$tis_errno_set_value(v)) |
774d564b |
201 | void cma$tis_errno_set_value(int __value); /* missing in some errno.h */ |
748a9306 |
202 | # define set_vaxc_errno(v) (vaxc$errno = (v)) |
203 | #else |
204 | # define set_errno(v) (errno = (v)) |
205 | # define set_vaxc_errno(v) (vaxc$errno = (v)) |
206 | #endif |
207 | |
ff0cee69 |
208 | /* Support for 'vmsish' behaviors enabled with C<use vmsish> pragma */ |
209 | |
210 | #define COMPLEX_STATUS 1 /* We track both "POSIX" and VMS values */ |
211 | |
aa689395 |
212 | #define HINT_V_VMSISH 24 |
a0ed51b3 |
213 | #define HINT_M_VMSISH_STATUS 0x20000000 /* system, $? return VMS status */ |
214 | #define HINT_M_VMSISH_EXIT 0x40000000 /* exit(1) ==> SS$_NORMAL */ |
215 | #define HINT_M_VMSISH_TIME 0x80000000 /* times are local, not UTC */ |
6b88bc9c |
216 | #define NATIVE_HINTS (PL_hints >> HINT_V_VMSISH) /* used in op.c */ |
ff0cee69 |
217 | |
6b88bc9c |
218 | #define TEST_VMSISH(h) (PL_curcop->op_private & ((h) >> HINT_V_VMSISH)) |
ff0cee69 |
219 | #define VMSISH_STATUS TEST_VMSISH(HINT_M_VMSISH_STATUS) |
220 | #define VMSISH_EXIT TEST_VMSISH(HINT_M_VMSISH_EXIT) |
221 | #define VMSISH_TIME TEST_VMSISH(HINT_M_VMSISH_TIME) |
222 | |
562a7b0c |
223 | /* Flags for vmstrnenv() */ |
224 | #define PERL__TRNENV_SECURE 0x01 |
225 | |
748a9306 |
226 | /* Handy way to vet calls to VMS system services and RTL routines. */ |
bf109933 |
227 | #define _ckvmssts(call) STMT_START { register unsigned long int __ckvms_sts; \ |
748a9306 |
228 | if (!((__ckvms_sts=(call))&1)) { \ |
229 | set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \ |
5c84aa53 |
230 | Perl_croak(aTHX_ "Fatal VMS error (status=%d) at %s, line %d", \ |
bf109933 |
231 | __ckvms_sts,__FILE__,__LINE__); } } STMT_END |
a0d0e21e |
232 | |
0414b1a0 |
233 | /* Same thing, but don't call back to Perl's croak(); useful for errors |
234 | * occurring during startup, before Perl's state is initialized */ |
235 | #define _ckvmssts_noperl(call) STMT_START { register unsigned long int __ckvms_sts; \ |
236 | if (!((__ckvms_sts=(call))&1)) { \ |
237 | set_errno(EVMSERR); set_vaxc_errno(__ckvms_sts); \ |
238 | fprintf(Perl_debug_log,"Fatal VMS error (status=%d) at %s, line %d", \ |
239 | __ckvms_sts,__FILE__,__LINE__); lib$signal(__ckvms_sts); } } STMT_END |
240 | |
a0d0e21e |
241 | #ifdef VMS_DO_SOCKETS |
242 | #include "sockadapt.h" |
243 | #endif |
244 | |
c07a80fd |
245 | #define BIT_BUCKET "_NLA0:" |
fc1ce8cc |
246 | #define PERL_SYS_INIT(c,v) vms_image_init((c),(v)); MALLOC_INIT |
18f739ee |
247 | #define PERL_SYS_TERM() MALLOC_TERM |
8cc95fdb |
248 | #define dXSUB_SYS |
a0d0e21e |
249 | #define HAS_KILL |
250 | #define HAS_WAIT |
251 | |
e518068a |
252 | /* VMS: |
253 | * This symbol, if defined, indicates that the program is running under |
254 | * VMS. It's a symbol automagically defined by all VMS C compilers I've seen. |
255 | * Just in case, however . . . */ |
256 | #ifndef VMS |
257 | #define VMS /**/ |
258 | #endif |
259 | |
260 | /* HAS_IOCTL: |
261 | * This symbol, if defined, indicates that the ioctl() routine is |
262 | * available to set I/O characteristics |
a0d0e21e |
263 | */ |
e518068a |
264 | #undef HAS_IOCTL /**/ |
265 | |
266 | /* HAS_UTIME: |
267 | * This symbol, if defined, indicates that the routine utime() is |
268 | * available to update the access and modification times of files. |
269 | */ |
270 | #define HAS_UTIME /**/ |
a0d0e21e |
271 | |
e518068a |
272 | /* HAS_GROUP |
28e8609d |
273 | * This symbol, if defined, indicates that the getgrnam() and |
274 | * getgrgid() routines are available to get group entries. |
275 | * The getgrent() has a separate definition, HAS_GETGRENT. |
e518068a |
276 | */ |
277 | #undef HAS_GROUP /**/ |
278 | |
279 | /* HAS_PASSWD |
28e8609d |
280 | * This symbol, if defined, indicates that the getpwnam() and |
281 | * getpwuid() routines are available to get password entries. |
282 | * The getpwent() has a separate definition, HAS_GETPWENT. |
e518068a |
283 | */ |
284 | #define HAS_PASSWD /**/ |
285 | |
286 | #define HAS_KILL |
287 | #define HAS_WAIT |
288 | |
0414b1a0 |
289 | /* USEMYBINMODE |
290 | * This symbol, if defined, indicates that the program should |
291 | * use the routine my_binmode(FILE *fp, char iotype) to insure |
292 | * that a file is in "binary" mode -- that is, that no translation |
293 | * of bytes occurs on read or write operations. |
294 | */ |
562a7b0c |
295 | #undef USEMYBINMODE |
0414b1a0 |
296 | |
61bb5906 |
297 | /* Stat_t: |
298 | * This symbol holds the type used to declare buffers for information |
299 | * returned by stat(). It's usually just struct stat. It may be necessary |
300 | * to include <sys/stat.h> and <sys/types.h> to get any typedef'ed |
301 | * information. |
302 | */ |
303 | /* VMS: |
304 | * We need this typedef to point to the new type even if DONT_MASK_RTL_CALLS |
305 | * is in effect, since Perl's thread.h embeds one of these structs in its |
306 | * thread data struct, and our struct mystat is a different size from the |
307 | * regular struct stat (cf. note above about having to pad struct to work |
308 | * around bug in compiler.) |
309 | * It's OK to pass one of these to the RTL's stat(), though, since the |
310 | * fields it fills are the same in each struct. |
311 | */ |
312 | #define Stat_t struct mystat |
313 | |
314 | /* USE_STAT_RDEV: |
315 | * This symbol is defined if this system has a stat structure declaring |
316 | * st_rdev |
317 | * VMS: Field exists in POSIXish version of struct stat(), but is not used. |
318 | */ |
319 | #undef USE_STAT_RDEV /**/ |
320 | |
a0d0e21e |
321 | /* |
322 | * fwrite1() should be a routine with the same calling sequence as fwrite(), |
323 | * but which outputs all of the bytes requested as a single stream (unlike |
324 | * fwrite() itself, which on some systems outputs several distinct records |
325 | * if the number_of_items parameter is >1). |
326 | */ |
327 | #define fwrite1 my_fwrite |
328 | |
d27fe803 |
329 | /* By default, flush data all the way to disk, not just to RMS buffers */ |
330 | #define Fflush(fp) my_flush(fp) |
331 | |
a0d0e21e |
332 | /* Use our own rmdir() */ |
333 | #define rmdir(name) do_rmdir(name) |
334 | |
335 | /* Assorted fiddling with sigs . . . */ |
336 | # include <signal.h> |
337 | #define ABORT() abort() |
5f05dabc |
338 | /* VAXC's signal.h doesn't #define SIG_ERR, but provides BADSIG instead. */ |
339 | #if !defined(SIG_ERR) && defined(BADSIG) |
340 | # define SIG_ERR BADSIG |
341 | #endif |
342 | |
a0d0e21e |
343 | |
748a9306 |
344 | /* Used with our my_utime() routine in vms.c */ |
345 | struct utimbuf { |
346 | time_t actime; |
347 | time_t modtime; |
348 | }; |
349 | #define utime my_utime |
350 | |
0414b1a0 |
351 | /* This is what times() returns, but <times.h> calls it tbuffer_t on VMS |
352 | * prior to v7.0. We check the DECC manifest to see whether it's already |
353 | * done this for us, relying on the fact that perl.h #includes <time.h> |
354 | * before it #includes "vmsish.h". |
355 | */ |
a0d0e21e |
356 | |
0414b1a0 |
357 | #ifndef __TMS |
358 | struct tms { |
359 | clock_t tms_utime; /* user time */ |
360 | clock_t tms_stime; /* system time - always 0 on VMS */ |
361 | clock_t tms_cutime; /* user time, children */ |
362 | clock_t tms_cstime; /* system time, children - always 0 on VMS */ |
363 | }; |
5f05dabc |
364 | #else |
365 | /* The new headers change the times() prototype to tms from tbuffer */ |
366 | # define tbuffer_t struct tms |
0414b1a0 |
367 | #endif |
a0d0e21e |
368 | |
61bb5906 |
369 | /* Substitute our own routines for gmtime(), localtime(), and time(), |
370 | * which allow us to implement the vmsish 'time' pragma, and work |
371 | * around absence of system-level UTC support on old versions of VMS. |
e518068a |
372 | */ |
373 | #define gmtime(t) my_gmtime(t) |
ff0cee69 |
374 | #define localtime(t) my_localtime(t) |
375 | #define time(t) my_time(t) |
61bb5906 |
376 | |
377 | /* If we're using an older version of VMS whose Unix signal emulation |
378 | * isn't very POSIXish, then roll our own. |
379 | */ |
380 | #if __VMS_VER < 70000000 || __DECC_VER < 50200000 |
381 | # define HOMEGROWN_POSIX_SIGNALS |
382 | #endif |
383 | #ifdef HOMEGROWN_POSIX_SIGNALS |
384 | # define sigemptyset(t) my_sigemptyset(t) |
385 | # define sigfillset(t) my_sigfillset(t) |
386 | # define sigaddset(t, u) my_sigaddset(t, u) |
387 | # define sigdelset(t, u) my_sigdelset(t, u) |
388 | # define sigismember(t, u) my_sigismember(t, u) |
389 | # define sigprocmask(t, u, v) my_sigprocmask(t, u, v) |
09b7f37c |
390 | # ifndef _SIGSET_T |
61bb5906 |
391 | typedef int sigset_t; |
09b7f37c |
392 | # endif |
61bb5906 |
393 | /* The tools for sigprocmask() are there, just not the routine itself */ |
394 | # ifndef SIG_UNBLOCK |
395 | # define SIG_UNBLOCK 1 |
396 | # endif |
397 | # ifndef SIG_BLOCK |
398 | # define SIG_BLOCK 2 |
399 | # endif |
400 | # ifndef SIG_SETMASK |
401 | # define SIG_SETMASK 3 |
402 | # endif |
403 | # define sigaction sigvec |
404 | # define sa_flags sv_onstack |
405 | # define sa_handler sv_handler |
406 | # define sa_mask sv_mask |
407 | # define sigsuspend(set) sigpause(*set) |
408 | # define sigpending(a) (not_here("sigpending"),0) |
7b62b82b |
409 | #endif |
e518068a |
410 | |
a0d0e21e |
411 | /* VMS doesn't use a real sys_nerr, but we need this when scanning for error |
412 | * messages in text strings . . . |
413 | */ |
414 | |
415 | #define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */ |
416 | |
417 | /* Look up new %ENV values on the fly */ |
418 | #define DYNAMIC_ENV_FETCH 1 |
419 | #define ENV_HV_NAME "%EnV%VmS%" |
aa689395 |
420 | /* Special getenv function for retrieving %ENV elements. */ |
562a7b0c |
421 | #define ENVgetenv(v) my_getenv(v,FALSE) |
a6c40364 |
422 | #define ENVgetenv_len(v,l) my_getenv_len(v,l,FALSE) |
aa689395 |
423 | |
a0d0e21e |
424 | |
c07a80fd |
425 | /* Thin jacket around cuserid() tomatch Unix' calling sequence */ |
426 | #define getlogin my_getlogin |
427 | |
428 | /* Ditto for sys$hash_passwrod() . . . */ |
429 | #define crypt my_crypt |
430 | |
8cc95fdb |
431 | /* Tweak arg to mkdir first, so we can tolerate trailing /. */ |
432 | #define Mkdir(dir,mode) my_mkdir((dir),(mode)) |
433 | |
a0d0e21e |
434 | /* Use our own stat() clones, which handle Unix-style directory names */ |
435 | #define Stat(name,bufptr) flex_stat(name,bufptr) |
436 | #define Fstat(fd,bufptr) flex_fstat(fd,bufptr) |
437 | |
438 | /* Setup for the dirent routines: |
439 | * opendir(), closedir(), readdir(), seekdir(), telldir(), and |
440 | * vmsreaddirversions(), and preprocessor stuff on which these depend: |
441 | * Written by Rich $alz, <rsalz@bbn.com> in August, 1990. |
a0d0e21e |
442 | */ |
443 | /* Data structure returned by READDIR(). */ |
444 | struct dirent { |
445 | char d_name[256]; /* File name */ |
446 | int d_namlen; /* Length of d_name */ |
447 | int vms_verscount; /* Number of versions */ |
448 | int vms_versions[20]; /* Version numbers */ |
449 | }; |
450 | |
451 | /* Handle returned by opendir(), used by the other routines. You |
452 | * are not supposed to care what's inside this structure. */ |
453 | typedef struct _dirdesc { |
454 | long context; |
455 | int vms_wantversions; |
456 | unsigned long int count; |
457 | char *pattern; |
458 | struct dirent entry; |
459 | struct dsc$descriptor_s pat; |
460 | } DIR; |
461 | |
462 | #define rewinddir(dirp) seekdir((dirp), 0) |
463 | |
748a9306 |
464 | /* used for our emulation of getpw* */ |
465 | struct passwd { |
466 | char *pw_name; /* Username */ |
467 | char *pw_passwd; |
468 | Uid_t pw_uid; /* UIC member number */ |
469 | Gid_t pw_gid; /* UIC group number */ |
470 | char *pw_comment; /* Default device/directory (Unix-style) */ |
471 | char *pw_gecos; /* Owner */ |
472 | char *pw_dir; /* Default device/directory (VMS-style) */ |
473 | char *pw_shell; /* Default CLI name (eg. DCL) */ |
474 | }; |
475 | #define pw_unixdir pw_comment /* Default device/directory (Unix-style) */ |
476 | #define getpwnam my_getpwnam |
477 | #define getpwuid my_getpwuid |
478 | #define getpwent my_getpwent |
479 | #define endpwent my_endpwent |
480 | #define setpwent my_endpwent |
481 | |
482 | /* Our own stat_t substitute, since we play with st_dev and st_ino - |
483 | * we want atomic types so Unix-bound code which compares these fields |
c07a80fd |
484 | * for two files will work most of the time under VMS. |
485 | * N.B. 1. The st_ino hack assumes that sizeof(unsigned short[3]) == |
486 | * sizeof(unsigned) + sizeof(unsigned short). We can't use a union type |
487 | * to map the unsigned int we want and the unsigned short[3] the CRTL |
488 | * returns into the same member, since gcc has different ideas than DECC |
489 | * and VAXC about sizing union types. |
490 | * N.B 2. The routine cando() in vms.c assumes that &stat.st_ino is the |
491 | * address of a FID. |
748a9306 |
492 | */ |
493 | /* First, grab the system types, so we don't clobber them later */ |
494 | #include <stat.h> |
495 | /* Since we've got to match the size of the CRTL's stat_t, we need |
496 | * to mimic DECC's alignment settings. |
497 | */ |
498 | #if defined(__DECC) || defined(__DECCXX) |
499 | # pragma __member_alignment __save |
500 | # pragma __nomember_alignment |
501 | #endif |
502 | #if defined(__DECC) |
503 | # pragma __message __save |
504 | # pragma __message disable (__MISALGNDSTRCT) |
505 | # pragma __message disable (__MISALGNDMEM) |
506 | #endif |
507 | struct mystat |
508 | { |
509 | char *st_devnam; /* pointer to device name */ |
c07a80fd |
510 | unsigned st_ino; /* hack - CRTL uses unsigned short[3] for */ |
511 | unsigned short rvn; /* FID (num,seq,rvn) */ |
748a9306 |
512 | unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */ |
513 | int st_nlink; /* for compatibility - not really used */ |
514 | unsigned st_uid; /* from ACP - QIO uic field */ |
515 | unsigned short st_gid; /* group number extracted from st_uid */ |
516 | dev_t st_rdev; /* for compatibility - always zero */ |
517 | off_t st_size; /* file size in bytes */ |
518 | unsigned st_atime; /* file access time; always same as st_mtime */ |
519 | unsigned st_mtime; /* last modification time */ |
520 | unsigned st_ctime; /* file creation time */ |
521 | char st_fab_rfm; /* record format */ |
522 | char st_fab_rat; /* record attributes */ |
523 | char st_fab_fsz; /* fixed header size */ |
524 | unsigned st_dev; /* encoded device name */ |
61bb5906 |
525 | /* Pad struct out to integral number of longwords, since DECC 5.6/VAX |
526 | * has a bug in dealing with offsets in structs in which are embedded |
527 | * other structs whose size is an odd number of bytes. (An even |
528 | * number of bytes is enough to make it happy, but we go for natural |
529 | * alignment anyhow.) |
530 | */ |
531 | char st_fill1[sizeof(void *) - (3*sizeof(unsigned short) + 3*sizeof(char))%sizeof(void *)]; |
748a9306 |
532 | }; |
748a9306 |
533 | typedef unsigned mydev_t; |
c07a80fd |
534 | typedef unsigned myino_t; |
aa689395 |
535 | #ifndef DONT_MASK_RTL_CALLS /* defined for vms.c so we can see RTL calls */ |
536 | # ifdef stat |
537 | # undef stat |
538 | # endif |
539 | # define stat mystat |
540 | # define dev_t mydev_t |
541 | # define ino_t myino_t |
542 | #endif |
748a9306 |
543 | #if defined(__DECC) || defined(__DECCXX) |
544 | # pragma __member_alignment __restore |
545 | #endif |
546 | #if defined(__DECC) |
547 | # pragma __message __restore |
548 | #endif |
549 | /* Cons up a 'delete' bit for testing access */ |
550 | #define S_IDUSR (S_IWUSR | S_IXUSR) |
551 | #define S_IDGRP (S_IWGRP | S_IXGRP) |
552 | #define S_IDOTH (S_IWOTH | S_IXOTH) |
a0d0e21e |
553 | |
554 | /* Prototypes for functions unique to vms.c. Don't include replacements |
555 | * for routines in the mainline source files excluded by #ifndef VMS; |
556 | * their prototypes are already in proto.h. |
557 | * |
558 | * In order to keep Gen_ShrFls.Pl happy, functions which are to be made |
559 | * available to images linked to PerlShr.Exe must be declared between the |
560 | * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form |
20ce7b12 |
561 | * <data type><TAB>name<WHITESPACE>(<prototype args>); |
a0d0e21e |
562 | */ |
94c456c4 |
563 | |
44a8e56a |
564 | #ifdef NO_PERL_TYPEDEFS |
565 | /* We don't have Perl typedefs available (e.g. when building a2p), so |
566 | we fake them here. N.B. There is *no* guarantee that the faked |
567 | prototypes will actually match the real routines. If you want to |
568 | call Perl routines, include perl.h to get the real typedefs. */ |
569 | # ifndef bool |
570 | # define bool int |
571 | # define __MY_BOOL_TYPE_FAKE |
572 | # endif |
573 | # ifndef I32 |
574 | # define I32 int |
575 | # define __MY_I32_TYPE_FAKE |
576 | # endif |
577 | # ifndef SV |
578 | # define SV void /* Since we only see SV * in prototypes */ |
579 | # define __MY_SV_TYPE_FAKE |
580 | # endif |
581 | #endif |
582 | |
20ce7b12 |
583 | void prime_env_iter (void); |
584 | void init_os_extras (); |
c07a80fd |
585 | /* prototype section start marker; `typedef' passes through cpp */ |
586 | typedef char __VMS_PROTOTYPES__; |
20ce7b12 |
587 | int vmstrnenv (const char *, char *, unsigned long int, struct dsc$descriptor_s **, unsigned long int); |
588 | int my_trnlnm (const char *, char *, unsigned long int); |
5c84aa53 |
589 | #if !defined(PERL_IMPLICIT_CONTEXT) |
590 | char * Perl_my_getenv (const char *, bool); |
591 | #else |
592 | char * Perl_my_getenv (pTHX_ const char *, bool); |
593 | #endif |
20ce7b12 |
594 | char * my_getenv_len (const char *, unsigned long *, bool); |
595 | int vmssetenv (char *, char *, struct dsc$descriptor_s **); |
596 | char * my_crypt (const char *, const char *); |
597 | Pid_t my_waitpid (Pid_t, int *, int); |
598 | char * my_gconvert (double, int, int, char *); |
599 | int do_rmdir (char *); |
600 | int kill_file (char *); |
601 | int my_mkdir (char *, Mode_t); |
602 | int my_utime (char *, struct utimbuf *); |
603 | char * rmsexpand (char *, char *, char *, unsigned); |
604 | char * rmsexpand_ts (char *, char *, char *, unsigned); |
605 | char * fileify_dirspec (char *, char *); |
606 | char * fileify_dirspec_ts (char *, char *); |
607 | char * pathify_dirspec (char *, char *); |
608 | char * pathify_dirspec_ts (char *, char *); |
609 | char * tounixspec (char *, char *); |
610 | char * tounixspec_ts (char *, char *); |
611 | char * tovmsspec (char *, char *); |
612 | char * tovmsspec_ts (char *, char *); |
613 | char * tounixpath (char *, char *); |
614 | char * tounixpath_ts (char *, char *); |
615 | char * tovmspath (char *, char *); |
616 | char * tovmspath_ts (char *, char *); |
617 | void vms_image_init (int *, char ***); |
618 | DIR * opendir (char *); |
619 | struct dirent * readdir (DIR *); |
620 | long telldir (DIR *); |
621 | void seekdir (DIR *, long); |
622 | void closedir (DIR *); |
623 | void vmsreaddirversions (DIR *, int); |
624 | struct tm * my_gmtime (const time_t *); |
625 | struct tm * my_localtime (const time_t *); |
626 | time_t my_time (time_t *); |
61bb5906 |
627 | #ifdef HOMEGROWN_POSIX_SIGNALS |
20ce7b12 |
628 | int my_sigemptyset (sigset_t *); |
629 | int my_sigfillset (sigset_t *); |
630 | int my_sigaddset (sigset_t *, int); |
631 | int my_sigdelset (sigset_t *, int); |
632 | int my_sigismember (sigset_t *, int); |
633 | int my_sigprocmask (int, sigset_t *, sigset_t *); |
5b411029 |
634 | #endif |
20ce7b12 |
635 | I32 cando_by_name (I32, I32, char *); |
636 | int flex_fstat (int, Stat_t *); |
cc077a9f |
637 | int flex_stat (const char *, Stat_t *); |
20ce7b12 |
638 | int trim_unixpath (char *, char*, int); |
639 | int my_vfork (); |
640 | bool vms_do_aexec (SV *, SV **, SV **); |
641 | bool vms_do_exec (char *); |
642 | unsigned long int do_aspawn (void *, void **, void **); |
643 | unsigned long int do_spawn (char *); |
644 | int my_fwrite (void *, size_t, size_t, FILE *); |
645 | int my_flush (FILE *); |
646 | struct passwd * my_getpwnam (char *name); |
647 | struct passwd * my_getpwuid (Uid_t uid); |
648 | struct passwd * my_getpwent (); |
649 | void my_endpwent (); |
650 | char * my_getlogin (); |
651 | int rmscopy (char *, char *, int); |
c07a80fd |
652 | typedef char __VMS_SEPYTOTORP__; |
653 | /* prototype section end marker; `typedef' passes through cpp */ |
a0d0e21e |
654 | |
44a8e56a |
655 | #ifdef NO_PERL_TYPEDEFS /* We'll try not to scramble later files */ |
656 | # ifdef __MY_BOOL_TYPE_FAKE |
657 | # undef bool |
658 | # undef __MY_BOOL_TYPE_FAKE |
659 | # endif |
660 | # ifdef __MY_I32_TYPE_FAKE |
661 | # undef I32 |
662 | # undef __MY_I32_TYPE_FAKE |
663 | # endif |
664 | # ifdef __MY_SV_TYPE_FAKE |
665 | # undef SV |
666 | # undef __MY_SV_TYPE_FAKE |
667 | # endif |
668 | #endif |
669 | |
a0d0e21e |
670 | #ifndef VMS_DO_SOCKETS |
748a9306 |
671 | /* This relies on tricks in perl.h to pick up that these manifest constants |
672 | * are undefined and set up conversion routines. It will then redefine |
673 | * these manifest constants, so the actual values will match config.h |
674 | */ |
675 | #undef HAS_HTONS |
676 | #undef HAS_NTOHS |
677 | #undef HAS_HTONL |
678 | #undef HAS_NTOHL |
a0d0e21e |
679 | #endif |
680 | |
482b294c |
681 | #define TMPPATH "sys$scratch:perl-eXXXXXX" |
682 | |
a0d0e21e |
683 | #endif /* __vmsish_h_included */ |