This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[inseparable changes from patch from perl5.003_25 to perl5.003_26]
[perl5.git] / vms / sockadapt.h
CommitLineData
a0d0e21e
LW
1/* sockadapt.h
2 *
3 * Authors: Charles Bailey bailey@genetics.upenn.edu
4 * David Denholm denholm@conmat.phys.soton.ac.uk
4633a7c4 5 * Last Revised: 17-Mar-1995
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
4633a7c4
LW
14/* SocketShr doesn't support these routines, but the DECC RTL contains
15 * stubs with these names, designed to be used with the UCX socket
16 * library. We avoid linker collisions by substituting new names.
17 */
18#define getnetbyaddr no_getnetbyaddr
19#define getnetbyname no_getnetbyname
20#define getnetent no_getnetent
21#define setnetent no_setnetent
22#define endnetent no_endnetent
23
24
25#ifdef __GNU_CC__
a0d0e21e 26
748a9306 27/* we may not have netdb.h etc, so lets just do this here - div */
a0d0e21e
LW
28/* no harm doing this for all .c files - needed only by pp_sys.c */
29
748a9306
LW
30struct hostent {
31 char *h_name; /* official name of host */
32 char **h_aliases; /* alias list */
33 int h_addrtype; /* host address type */
34 int h_length; /* length of address */
35 char **h_addr_list; /* address */
a0d0e21e 36};
748a9306
LW
37#ifdef h_addr
38# undef h_addr
39#endif
a0d0e21e
LW
40#define h_addr h_addr_list[0]
41
748a9306
LW
42struct protoent {
43 char *p_name; /* official protocol name */
44 char **p_aliases; /* alias list */
45 int p_proto; /* protocol # */
46};
47
48struct servent {
49 char *s_name; /* official service name */
50 char **s_aliases; /* alias list */
51 int s_port; /* port # */
52 char *s_proto; /* protocol to use */
53};
54
55struct in_addr {
56 unsigned long s_addr;
57};
58
59struct sockaddr {
60 unsigned short sa_family; /* address family */
61 char sa_data[14]; /* up to 14 bytes of direct address */
62};
63
4633a7c4
LW
64/*
65 * Socket address, internet style.
66 */
67struct sockaddr_in {
68 short sin_family;
69 unsigned short sin_port;
70 struct in_addr sin_addr;
71 char sin_zero[8];
72};
73
748a9306
LW
74struct timeval {
75 long tv_sec;
76 long tv_usec;
a0d0e21e
LW
77};
78
79struct netent {
80 char *n_name;
81 char **n_aliases;
82 int n_addrtype;
83 long n_net;
84};
4633a7c4
LW
85
86/* Since socketshr.h won't declare function prototypes unless it thinks
87 * the system headers have already been included, we convince it that
88 * this is the case.
89 */
90
91#ifndef AF_INET
92# define AF_INET 2
93#endif
94#ifndef IPPROTO_TCP
95# define IPPROTO_TCP 6
96#endif
97#ifndef __INET_LOADED
98# define __INET_LOADED
99#endif
100#ifndef __NETDB_LOADED
101# define __NETDB_LOADED
102#endif
103
104/* Finally, we provide prototypes for routines not supported by SocketShr,
105 * so that the stubs in sockadapt.c won't cause complaints about
106 * undeclared routines.
107 */
108
109struct netent *getnetbyaddr( long net, int type);
110struct netent *getnetbyname( char *name);
111struct netent *getnetent();
112void setnetent();
113void endnetent();
114
115#else /* !__GNU_CC__ */
116
117/* DECC and VAXC have socket headers in the system set; they're for UCX, but
118 * we'll assume that the actual calling sequence is identical across the
119 * various TCP/IP stacks; these routines are pretty standard.
120 */
121#include <socket.h>
122#include <in.h>
123#include <inet.h>
124#include <netdb.h>
125/* However, we don't have these two in the system headers. */
126void setnetent();
127void endnetent();
128
129#endif
130
131#include <socketshr.h>
132/* socketshr.h from SocketShr 0.9D doesn't alias fileno; it's comments say
133 * that the CRTL version works OK. This isn't the case, at least with
134 * VAXC, so we use the SocketShr version.
135 * N.B. This means that sockadapt.h must be included *after* stdio.h.
136 * This is presently the case for Perl.
137 */
138#ifdef fileno
139# undef fileno
140#endif
141#define fileno si_fileno
142int si_fileno(FILE *);
84753aa1 143
144
145/* Catch erroneous results for UDP sockets -- see sockadapt.c */
146#ifdef getpeername
147# undef getpeername
148#endif
149#define getpeername my_getpeername
150int my_getpeername _((int, struct sockaddr *, int *));