summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/cvs/os2/tcpip.h
blob: 4d19448650a11f5f259b57f5af0fdda5d078f47c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/****************************************************************
 *
 * TCPIP.H - Portable TCP/IP header file
 *
 * TCP/IP on OS/2 is an add-on and thus is not fully integrated
 * with the operating system. To ensure portability, follow
 * these rules:
 *
 *  * Always call SockInit() at the beginning of your program
 *    and check that it returns TRUE.
 *
 *  * Use SockSend() & SockRecv() instead of read(), write(),
 *    send(), or recv() when working with sockets.
 *
 *  * Use SockClose() instead of close() with sockets.
 *
 *  * Use SOCK_ERRNO when using functions that use or return
 *    sockets, such as SockSend() or accept().
 *
 *  * Use HOST_ERRNO when using gethostbyname() or gethostbyaddr()
 *    functions.
 *
 *  * As far as I can tell, getservbyname() and related functions
 *    never set any error variable.
 *
 *  * Use SockStrError() & HostStrError() to convert SOCK_ERRNO
 *    and HOST_ERRNO to error strings.
 *
 *  * In .MAK files, include $(TCPIP_MAK) & use $(TCPIPLIB)
 *    when linking applications using TCP/IP.
 *
 ****************************************************************/

#if !defined( IN_TCPIP_H )
#define IN_TCPIP_H

#include	<sys/types.h>
#include	<sys/stat.h>
#include	<sys/socket.h>
#include	<sys/ioctl.h>
#include	<netinet/in.h>
#include	<netdb.h>
#include	<errno.h>

#if defined( TCPIP_IBM )
#	include	<types.h>
#	if !defined( TCPIP_IBM_NOHIDE )
#		define send IbmSockSend
#		define recv IbmSockRecv
#	endif
#endif

#if defined( TCPIP_IBM )
#	define	BSD_SELECT
#	include	<sys/select.h>
#	include	<sys/time.h>
#	include <nerrno.h>
#	include <utils.h>
#	if defined( MICROSOFT )
#		define	SOCK_ERRNO		(tcperrno())
#	else
#		define	SOCK_ERRNO		(sock_errno())
#	endif
#	define	HOST_ERRNO		(h_errno)
#	define	SockClose(S)	soclose(S)
#	define	SockInit()		(!sock_init())
#	define	SockSend		IbmSockSend
#	define	SockRecv		IbmSockRecv

const char *HostStrError(int HostErrno);
const char *SockStrError(int SockErrno);

int IbmSockSend (int Socket, const void *Buffer, int Len, int Flags);
int IbmSockRecv (int Socket, const void *Buffer, int Len, int Flags);

#if !defined( h_errno )
extern int h_errno; /* IBM forgot to declare this in current header files */
#endif

#elif defined( __unix )
#	if defined( sgi ) /* SGI incorrectly defines FD_ZERO in sys/select.h */
#		include <bstring.h>
#	endif
#	if defined( sunos )
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
#	else
#		include <sys/select.h>
#	endif
#	include <sys/time.h>
#	include <errno.h>
#	include <arpa/inet.h>
#	define	SOCK_ERRNO		errno
#	define	HOST_ERRNO		h_errno
#	define	SockClose(S)	close(S)
#	define	SockInit()		TRUE
#	define	SockSend		send
#	define	SockRecv		recv
#	define	SockStrError(E) strerror(E)

const char *HostStrError( int HostErrno );

#else
#	error Undefined version of TCP/IP specified

#endif

#endif