Commit | Line | Data |
a0d0e21e |
1 | /* vmsish.h |
2 | * |
3 | * VMS-specific C header file for perl5. |
4 | * |
5 | * Last revised: 09-Oct-1994 by Charles Bailey bailey@genetics.upenn.edu |
6 | */ |
7 | |
8 | #ifndef __vmsish_h_included |
9 | #define __vmsish_h_included |
10 | |
11 | #include <descrip.h> /* for dirent struct definitions */ |
12 | |
13 | /* Assorted things to look like Unix */ |
14 | #ifdef __GNUC__ |
15 | #ifndef _IOLBF /* gcc's stdio.h doesn't define this */ |
16 | #define _IOLBF 1 |
17 | #endif |
18 | #else |
19 | #include <processes.h> /* for vfork() */ |
20 | #include <unixio.h> |
21 | #endif |
22 | #include <unixlib.h> |
23 | #include <file.h> /* it's not <sys/file.h>, so don't use I_SYS_FILE */ |
24 | #define unlink remove |
25 | |
26 | #ifdef VMS_DO_SOCKETS |
27 | #include "sockadapt.h" |
28 | #endif |
29 | |
30 | /* |
31 | * The following symbols are defined (or undefined) according to the RTL |
32 | * support VMS provides for the corresponding functions. These don't |
33 | * appear in config.h, so they're dealt with here. |
34 | */ |
35 | #define HAS_KILL |
36 | #define HAS_WAIT |
37 | |
38 | /* The VMS C RTL has vfork() but not fork(). Both actually work in a way |
39 | * that's somewhere between Unix vfork() and VMS lib$spawn(), so it's |
40 | * probably not a good idea to use them much. That said, we'll try to |
41 | * use vfork() in either case. |
42 | */ |
43 | #define fork vfork |
44 | |
45 | /* |
46 | * fwrite1() should be a routine with the same calling sequence as fwrite(), |
47 | * but which outputs all of the bytes requested as a single stream (unlike |
48 | * fwrite() itself, which on some systems outputs several distinct records |
49 | * if the number_of_items parameter is >1). |
50 | */ |
51 | #define fwrite1 my_fwrite |
52 | |
53 | /* Use our own rmdir() */ |
54 | #define rmdir(name) do_rmdir(name) |
55 | |
56 | /* Assorted fiddling with sigs . . . */ |
57 | # include <signal.h> |
58 | #define ABORT() abort() |
59 | |
60 | /* This is what times() returns, but <times.h> calls it tbuffer_t on VMS */ |
61 | |
62 | struct tms { |
63 | clock_t tms_utime; /* user time */ |
64 | clock_t tms_stime; /* system time - always 0 on VMS */ |
65 | clock_t tms_cutime; /* user time, children */ |
66 | clock_t tms_cstime; /* system time, children - always 0 on VMS */ |
67 | }; |
68 | |
69 | /* VMS doesn't use a real sys_nerr, but we need this when scanning for error |
70 | * messages in text strings . . . |
71 | */ |
72 | |
73 | #define sys_nerr EVMSERR /* EVMSERR is as high as we can go. */ |
74 | |
75 | /* Look up new %ENV values on the fly */ |
76 | #define DYNAMIC_ENV_FETCH 1 |
77 | #define ENV_HV_NAME "%EnV%VmS%" |
78 | |
79 | /* Use our own stat() clones, which handle Unix-style directory names */ |
80 | #define Stat(name,bufptr) flex_stat(name,bufptr) |
81 | #define Fstat(fd,bufptr) flex_fstat(fd,bufptr) |
82 | |
83 | /* Setup for the dirent routines: |
84 | * opendir(), closedir(), readdir(), seekdir(), telldir(), and |
85 | * vmsreaddirversions(), and preprocessor stuff on which these depend: |
86 | * Written by Rich $alz, <rsalz@bbn.com> in August, 1990. |
87 | * This code has no copyright. |
88 | */ |
89 | /* Data structure returned by READDIR(). */ |
90 | struct dirent { |
91 | char d_name[256]; /* File name */ |
92 | int d_namlen; /* Length of d_name */ |
93 | int vms_verscount; /* Number of versions */ |
94 | int vms_versions[20]; /* Version numbers */ |
95 | }; |
96 | |
97 | /* Handle returned by opendir(), used by the other routines. You |
98 | * are not supposed to care what's inside this structure. */ |
99 | typedef struct _dirdesc { |
100 | long context; |
101 | int vms_wantversions; |
102 | unsigned long int count; |
103 | char *pattern; |
104 | struct dirent entry; |
105 | struct dsc$descriptor_s pat; |
106 | } DIR; |
107 | |
108 | #define rewinddir(dirp) seekdir((dirp), 0) |
109 | |
110 | |
111 | /* Prototypes for functions unique to vms.c. Don't include replacements |
112 | * for routines in the mainline source files excluded by #ifndef VMS; |
113 | * their prototypes are already in proto.h. |
114 | * |
115 | * In order to keep Gen_ShrFls.Pl happy, functions which are to be made |
116 | * available to images linked to PerlShr.Exe must be declared between the |
117 | * __VMS_PROTOTYPES__ and __VMS_SEPYTOTORP__ lines, and must be in the form |
118 | * <data type><TAB>name<WHITESPACE>_((<prototype args>)); |
119 | */ |
120 | typedef char __VMS_PROTOTYPES__; /* prototype section start marker */ |
121 | char * my_getenv _((char *)); |
122 | #ifndef HAS_WAITPID /* Not a real waitpid - use only with popen from vms.c! */ |
123 | unsigned long int waitpid _((unsigned long int, int *, int)); |
124 | #endif |
125 | char * my_gconvert _((double, int, int, char *)); |
126 | int do_rmdir _((char *)); |
127 | int kill_file _((char *)); |
128 | char * fileify_dirspec _((char *, char *)); |
129 | char * fileify_dirspec_ts _((char *, char *)); |
130 | char * pathify_dirspec _((char *, char *)); |
131 | char * pathify_dirspec_ts _((char *, char *)); |
132 | char * tounixspec _((char *, char *)); |
133 | char * tounixspec_ts _((char *, char *)); |
134 | char * tovmsspec _((char *, char *)); |
135 | char * tovmsspec_ts _((char *, char *)); |
136 | char * tounixpath _((char *, char *)); |
137 | char * tounixpath_ts _((char *, char *)); |
138 | char * tovmspath _((char *, char *)); |
139 | char * tovmspath_ts _((char *, char *)); |
140 | void getredirection _(()); |
141 | DIR * opendir _((char *)); |
142 | struct dirent * readdir _((DIR *)); |
143 | long telldir _((DIR *)); |
144 | void seekdir _((DIR *, long)); |
145 | void closedir _((DIR *)); |
146 | void vmsreaddirversions _((DIR *, int)); |
147 | void getredirection _((int *, char ***)); |
148 | int flex_fstat _((int, stat_t *)); |
149 | int flex_stat _((char *, stat_t *)); |
150 | int trim_unixpath _((char *, char*)); |
151 | struct sv; /* forward declaration for vms_do_aexec and do_aspawn */ |
152 | /* real declaration is in sv.h */ |
153 | #define bool char /* This must match handy.h */ |
154 | bool vms_do_aexec _((struct sv *, struct sv **, struct sv **)); |
155 | bool vms_do_exec _((char *)); |
156 | unsigned long int do_aspawn _((struct sv *, struct sv **, struct sv **)); |
157 | unsigned long int do_spawn _((char *)); |
158 | int my_fwrite _((void *, size_t, size_t, FILE *)); |
159 | typedef char __VMS_SEPYTOTORP__; /* prototype section end marker */ |
160 | |
161 | #ifndef VMS_DO_SOCKETS |
162 | /***** The following four #defines are temporary, and should be removed, |
163 | * along with the corresponding routines in vms.c, when TCP/IP support |
164 | * is integrated into the VMS port of perl5. (The temporary hacks are |
165 | * here for now so pack can handle type N elements.) |
166 | * - C. Bailey 26-Aug-1994 |
167 | *****/ |
168 | unsigned short int tmp_shortflip _((unsigned short int)); |
169 | unsigned long int tmp_longflip _((unsigned long int)); |
170 | #define htons(us) tmp_shortflip(us) |
171 | #define ntohs(us) tmp_shortflip(us) |
172 | #define htonl(ul) tmp_longflip(ul) |
173 | #define ntohl(ul) tmp_longflip(ul) |
174 | #endif |
175 | |
176 | #endif /* __vmsish_h_included */ |