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