source: trunk/third/perl/vms/sockadapt.h @ 14545

Revision 14545, 4.7 KB checked in by ghudson, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14544, which included commits to RCS files with non-trunk default branches.
Line 
1/*  sockadapt.h
2 *
3 *  Authors: Charles Bailey  bailey@newman.upenn.edu
4 *           David Denholm  denholm@conmat.phys.soton.ac.uk
5 *  Last Revised:  4-Mar-1997
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 *
11 *  This version is set up for perl5 with socketshr 0.9D TCP/IP support.
12 */
13
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#if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
28#else
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);
37#endif
38#  if defined(__DECC) && defined(__DECC_VER) && (__DECC_VER >= 50200000) && !defined(Sock_size_t)
39#    define Sock_size_t unsigned int
40#  endif
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     */
47
48
49#ifdef __GNU_CC__
50
51/* we may not have netdb.h etc, so lets just do this here  - div */
52/* no harm doing this for all .c files - needed only by pp_sys.c */
53
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 */
60};
61#ifdef h_addr
62#   undef h_addr
63#endif
64#define h_addr h_addr_list[0]
65
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
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
98struct timeval {
99    long tv_sec;
100    long tv_usec;
101};
102
103struct netent {
104        char *n_name;
105        char **n_aliases;
106        int n_addrtype;
107        long n_net;
108};
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();
136void setnetent(int);
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>
148
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
158
159#include <netdb.h>
160#endif
161
162/* We don't have these two in the system headers. */
163void setnetent(int);
164void endnetent();
165
166#include <socketshr.h>
167/* socketshr.h from SocketShr 0.9D doesn't alias fileno; its comments say
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 *);
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
185int my_getpeername (int, struct sockaddr *, int *);
186
187#endif /* SOCKETSHR stuff */
188#endif /* include guard */
Note: See TracBrowser for help on using the repository browser.