xref: /openbsd-src/gnu/usr.bin/cvs/os2/tcpip.h (revision a4afd6dad3fba28f80e70208181c06c482259988)
1 /****************************************************************
2  *
3  * TCPIP.H - Portable TCP/IP header file
4  *
5  * TCP/IP on OS/2 is an add-on and thus is not fully integrated
6  * with the operating system. To ensure portability, follow
7  * these rules:
8  *
9  *  * Always call SockInit() at the beginning of your program
10  *    and check that it returns TRUE.
11  *
12  *  * Use SockSend() & SockRecv() instead of read(), write(),
13  *    send(), or recv() when working with sockets.
14  *
15  *  * Use SockClose() instead of close() with sockets.
16  *
17  *  * Use SOCK_ERRNO when using functions that use or return
18  *    sockets, such as SockSend() or accept().
19  *
20  *  * Use HOST_ERRNO when using gethostbyname() or gethostbyaddr()
21  *    functions.
22  *
23  *  * As far as I can tell, getservbyname() and related functions
24  *    never set any error variable.
25  *
26  *  * Use SockStrError() & HostStrError() to convert SOCK_ERRNO
27  *    and HOST_ERRNO to error strings.
28  *
29  *  * In .MAK files, include $(TCPIP_MAK) & use $(TCPIPLIB)
30  *    when linking applications using TCP/IP.
31  *
32  ****************************************************************/
33 
34 #if !defined( IN_TCPIP_H )
35 #define IN_TCPIP_H
36 
37 #include	<sys/types.h>
38 #include	<sys/stat.h>
39 #include	<sys/socket.h>
40 #include	<sys/ioctl.h>
41 #include	<netinet/in.h>
42 #include	<netdb.h>
43 #include	<errno.h>
44 
45 #if defined( TCPIP_IBM )
46 #	include	<types.h>
47 #	if !defined( TCPIP_IBM_NOHIDE )
48 #		define send IbmSockSend
49 #		define recv IbmSockRecv
50 #	endif
51 #endif
52 
53 #if defined( TCPIP_IBM )
54 #	define	BSD_SELECT
55 #	include	<sys/select.h>
56 #	include	<sys/time.h>
57 #	include <nerrno.h>
58 #	include <utils.h>
59 #	if defined( MICROSOFT )
60 #		define	SOCK_ERRNO		(tcperrno())
61 #	else
62 #		define	SOCK_ERRNO		(sock_errno())
63 #	endif
64 #	define	HOST_ERRNO		(h_errno)
65 #	define	SockClose(S)	soclose(S)
66 #	define	SockInit()		(!sock_init())
67 #	define	SockSend		IbmSockSend
68 #	define	SockRecv		IbmSockRecv
69 
70 const char *HostStrError(int HostErrno);
71 const char *SockStrError(int SockErrno);
72 
73 int IbmSockSend (int Socket, const void *Buffer, int Len, int Flags);
74 int IbmSockRecv (int Socket, const void *Buffer, int Len, int Flags);
75 
76 #if !defined( h_errno )
77 extern int h_errno; /* IBM forgot to declare this in current header files */
78 #endif
79 
80 #elif defined( __unix )
81 #	if defined( sgi ) /* SGI incorrectly defines FD_ZERO in sys/select.h */
82 #		include <bstring.h>
83 #	endif
84 #	if defined( sunos )
85 extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
86 #	else
87 #		include <sys/select.h>
88 #	endif
89 #	include <sys/time.h>
90 #	include <errno.h>
91 #	include <arpa/inet.h>
92 #	define	SOCK_ERRNO		errno
93 #	define	HOST_ERRNO		h_errno
94 #	define	SockClose(S)	close(S)
95 #	define	SockInit()		TRUE
96 #	define	SockSend		send
97 #	define	SockRecv		recv
98 #	define	SockStrError(E) strerror(E)
99 
100 const char *HostStrError( int HostErrno );
101 
102 #else
103 #	error Undefined version of TCP/IP specified
104 
105 #endif
106 
107 #endif
108