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