Commit | Line | Data |
a0d0e21e |
1 | /* sockadapt.h |
2 | * |
3 | * Authors: Charles Bailey bailey@genetics.upenn.edu |
4 | * David Denholm denholm@conmat.phys.soton.ac.uk |
9607fc9c |
5 | * Last Revised: 4-Mar-1997 |
a0d0e21e |
6 | * |
7 | * This file should include any other header files and procide any |
8 | * declarations, typedefs, and prototypes needed by perl for TCP/IP |
9 | * operations. |
10 | * |
748a9306 |
11 | * This version is set up for perl5 with socketshr 0.9D TCP/IP support. |
a0d0e21e |
12 | */ |
13 | |
9607fc9c |
14 | #ifndef __SOCKADAPT_INCLUDED |
15 | #define __SOCKADAPT_INCLUDED 1 |
16 | |
17 | #if defined(DECCRTL_SOCKETS) |
18 | /* Use builtin socket interface in DECCRTL and |
19 | * UCX emulation in whatever TCP/IP stack is present. |
20 | * Provide prototypes for missing routines; stubs are |
21 | * in sockadapt.c. |
22 | */ |
23 | # include <socket.h> |
24 | # include <inet.h> |
25 | # include <in.h> |
26 | # include <netdb.h> |
27 | void sethostent(int); |
28 | void endhostent(void); |
29 | void setnetent(int); |
30 | void endnetent(void); |
31 | void setprotoent(int); |
32 | void endprotoent(void); |
33 | void setservent(int); |
34 | void endservent(void); |
d27fe803 |
35 | # if defined(__DECC) && defined(__DECC_VER) && (__DECC_VER >= 50200000) |
36 | # define Sock_size_t unsigned int |
37 | # endif |
9607fc9c |
38 | |
39 | #else |
40 | /* Pull in SOCKETSHR's header, and set up structures for |
41 | * gcc, whose basic header file set doesn't include the |
42 | * TCP/IP stuff. |
43 | */ |
4633a7c4 |
44 | |
45 | |
46 | #ifdef __GNU_CC__ |
a0d0e21e |
47 | |
748a9306 |
48 | /* we may not have netdb.h etc, so lets just do this here - div */ |
a0d0e21e |
49 | /* no harm doing this for all .c files - needed only by pp_sys.c */ |
50 | |
748a9306 |
51 | struct hostent { |
52 | char *h_name; /* official name of host */ |
53 | char **h_aliases; /* alias list */ |
54 | int h_addrtype; /* host address type */ |
55 | int h_length; /* length of address */ |
56 | char **h_addr_list; /* address */ |
a0d0e21e |
57 | }; |
748a9306 |
58 | #ifdef h_addr |
59 | # undef h_addr |
60 | #endif |
a0d0e21e |
61 | #define h_addr h_addr_list[0] |
62 | |
748a9306 |
63 | struct protoent { |
64 | char *p_name; /* official protocol name */ |
65 | char **p_aliases; /* alias list */ |
66 | int p_proto; /* protocol # */ |
67 | }; |
68 | |
69 | struct servent { |
70 | char *s_name; /* official service name */ |
71 | char **s_aliases; /* alias list */ |
72 | int s_port; /* port # */ |
73 | char *s_proto; /* protocol to use */ |
74 | }; |
75 | |
76 | struct in_addr { |
77 | unsigned long s_addr; |
78 | }; |
79 | |
80 | struct sockaddr { |
81 | unsigned short sa_family; /* address family */ |
82 | char sa_data[14]; /* up to 14 bytes of direct address */ |
83 | }; |
84 | |
4633a7c4 |
85 | /* |
86 | * Socket address, internet style. |
87 | */ |
88 | struct sockaddr_in { |
89 | short sin_family; |
90 | unsigned short sin_port; |
91 | struct in_addr sin_addr; |
92 | char sin_zero[8]; |
93 | }; |
94 | |
748a9306 |
95 | struct timeval { |
96 | long tv_sec; |
97 | long tv_usec; |
a0d0e21e |
98 | }; |
99 | |
100 | struct netent { |
101 | char *n_name; |
102 | char **n_aliases; |
103 | int n_addrtype; |
104 | long n_net; |
105 | }; |
4633a7c4 |
106 | |
107 | /* Since socketshr.h won't declare function prototypes unless it thinks |
108 | * the system headers have already been included, we convince it that |
109 | * this is the case. |
110 | */ |
111 | |
112 | #ifndef AF_INET |
113 | # define AF_INET 2 |
114 | #endif |
115 | #ifndef IPPROTO_TCP |
116 | # define IPPROTO_TCP 6 |
117 | #endif |
118 | #ifndef __INET_LOADED |
119 | # define __INET_LOADED |
120 | #endif |
121 | #ifndef __NETDB_LOADED |
122 | # define __NETDB_LOADED |
123 | #endif |
124 | |
125 | /* Finally, we provide prototypes for routines not supported by SocketShr, |
126 | * so that the stubs in sockadapt.c won't cause complaints about |
127 | * undeclared routines. |
128 | */ |
129 | |
130 | struct netent *getnetbyaddr( long net, int type); |
131 | struct netent *getnetbyname( char *name); |
132 | struct netent *getnetent(); |
9607fc9c |
133 | void setnetent(int); |
4633a7c4 |
134 | void endnetent(); |
135 | |
136 | #else /* !__GNU_CC__ */ |
137 | |
138 | /* DECC and VAXC have socket headers in the system set; they're for UCX, but |
139 | * we'll assume that the actual calling sequence is identical across the |
140 | * various TCP/IP stacks; these routines are pretty standard. |
141 | */ |
142 | #include <socket.h> |
143 | #include <in.h> |
144 | #include <inet.h> |
145 | #include <netdb.h> |
4633a7c4 |
146 | |
9607fc9c |
147 | /* SocketShr doesn't support these routines, but the DECC RTL contains |
148 | * stubs with these names, designed to be used with the UCX socket |
149 | * library. We avoid linker collisions by substituting new names. |
150 | */ |
151 | #define getnetbyaddr no_getnetbyaddr |
152 | #define getnetbyname no_getnetbyname |
153 | #define getnetent no_getnetent |
154 | #define setnetent no_setnetent |
155 | #define endnetent no_endnetent |
4633a7c4 |
156 | #endif |
157 | |
2ae324a7 |
158 | /* We don't have these two in the system headers. */ |
159 | void setnetent(int); |
160 | void endnetent(); |
161 | |
4633a7c4 |
162 | #include <socketshr.h> |
9607fc9c |
163 | /* socketshr.h from SocketShr 0.9D doesn't alias fileno; its comments say |
4633a7c4 |
164 | * that the CRTL version works OK. This isn't the case, at least with |
165 | * VAXC, so we use the SocketShr version. |
166 | * N.B. This means that sockadapt.h must be included *after* stdio.h. |
167 | * This is presently the case for Perl. |
168 | */ |
169 | #ifdef fileno |
170 | # undef fileno |
171 | #endif |
172 | #define fileno si_fileno |
173 | int si_fileno(FILE *); |
84753aa1 |
174 | |
175 | |
176 | /* Catch erroneous results for UDP sockets -- see sockadapt.c */ |
177 | #ifdef getpeername |
178 | # undef getpeername |
179 | #endif |
180 | #define getpeername my_getpeername |
181 | int my_getpeername _((int, struct sockaddr *, int *)); |
9607fc9c |
182 | |
183 | #endif /* SOCKETSHR stuff */ |
184 | #endif /* include guard */ |