-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathhsocket.h
160 lines (138 loc) · 6.1 KB
/
hsocket.h
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* HSOCKET.H (c) Copyright Roger Bowler, 2005-2012 */
/* Equates for socket functions */
/* */
/* Released under "The Q Public License Version 1" */
/* (http://www.hercules-390.org/herclic.html) as modifications to */
/* Hercules. */
/* This header file contains equates for the socket functions */
/* and constants whose values differ between Unix and Winsock */
#if !defined(_HSOCKET_H)
#define _HSOCKET_H
#ifndef _HSOCKET_C_
#ifndef _HUTIL_DLL_
#define HSOCK_DLL_IMPORT DLL_IMPORT
#else
#define HSOCK_DLL_IMPORT extern
#endif
#else
#define HSOCK_DLL_IMPORT DLL_EXPORT
#endif
/*-------------------------------------------------------------------*/
/* Socket related constants related to 'shutdown' API call */
/*-------------------------------------------------------------------*/
#ifdef _MSVC_
/* Map SUS\*nix constants to Windows socket equivalents */
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
#endif
#if defined(_WINSOCKAPI_)
/*-------------------------------------------------------------------*/
/* Equates for systems which use the Winsock API */
/*-------------------------------------------------------------------*/
#define get_HSO_errno() ((int)WSAGetLastError())
#define set_HSO_errno(e) (WSASetLastError(e))
#define HSO_errno get_HSO_errno()
#define HSO_EINTR WSAEINTR
#define HSO_EBADF WSAEBADF
#define HSO_EACCES WSAEACCES
#define HSO_EFAULT WSAEFAULT
#define HSO_EINVAL WSAEINVAL
#define HSO_EMFILE WSAEMFILE
#define HSO_EWOULDBLOCK WSAEWOULDBLOCK
#define HSO_EAGAIN WSAEWOULDBLOCK
#define HSO_EINPROGRESS WSAEINPROGRESS
#define HSO_EALREADY WSAEALREADY
#define HSO_ENOTSOCK WSAENOTSOCK
#define HSO_EDESTADDRREQ WSAEDESTADDRREQ
#define HSO_EMSGSIZE WSAEMSGSIZE
#define HSO_EPROTOTYPE WSAEPROTOTYPE
#define HSO_ENOPROTOOPT WSAENOPROTOOPT
#define HSO_EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define HSO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#define HSO_EOPNOTSUPP WSAEOPNOTSUPP
#define HSO_EPFNOSUPPORT WSAEPFNOSUPPORT
#define HSO_EAFNOSUPPORT WSAEAFNOSUPPORT
#define HSO_EADDRINUSE WSAEADDRINUSE
#define HSO_EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define HSO_ENETDOWN WSAENETDOWN
#define HSO_ENETUNREACH WSAENETUNREACH
#define HSO_ENETRESET WSAENETRESET
#define HSO_ECONNABORTED WSAECONNABORTED
#define HSO_ECONNRESET WSAECONNRESET
#define HSO_ENOBUFS WSAENOBUFS
#define HSO_EISCONN WSAEISCONN
#define HSO_ENOTCONN WSAENOTCONN
#define HSO_ESHUTDOWN WSAESHUTDOWN
#define HSO_ETOOMANYREFS WSAETOOMANYREFS
#define HSO_ETIMEDOUT WSAETIMEDOUT
#define HSO_ECONNREFUSED WSAECONNREFUSED
#define HSO_ELOOP WSAELOOP
#define HSO_ENAMETOOLONG WSAENAMETOOLONG
#define HSO_EHOSTDOWN WSAEHOSTDOWN
#define HSO_EHOSTUNREACH WSAEHOSTUNREACH
#define HSO_ENOTEMPTY WSAENOTEMPTY
#define HSO_EPROCLIM WSAEPROCLIM
#define HSO_EUSERS WSAEUSERS
#define HSO_EDQUOT WSAEDQUOT
#define HSO_ESTALE WSAESTALE
#define HSO_EREMOTE WSAEREMOTE
#else
/*-------------------------------------------------------------------*/
/* Equates for systems which use the Berkeley sockets API */
/*-------------------------------------------------------------------*/
#define get_HSO_errno() (errno)
#define set_HSO_errno(e) (errno=(e))
#define HSO_errno get_HSO_errno()
#define HSO_EINTR EINTR
#define HSO_EBADF EBADF
#define HSO_EACCES EACCES
#define HSO_EFAULT EFAULT
#define HSO_EINVAL EINVAL
#define HSO_EMFILE EMFILE
#define HSO_EWOULDBLOCK EWOULDBLOCK
#define HSO_EAGAIN EAGAIN
#define HSO_EINPROGRESS EINPROGRESS
#define HSO_EALREADY EALREADY
#define HSO_ENOTSOCK ENOTSOCK
#define HSO_EDESTADDRREQ EDESTADDRREQ
#define HSO_EMSGSIZE EMSGSIZE
#define HSO_EPROTOTYPE EPROTOTYPE
#define HSO_ENOPROTOOPT ENOPROTOOPT
#define HSO_EPROTONOSUPPORT EPROTONOSUPPORT
#define HSO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
#define HSO_EOPNOTSUPP EOPNOTSUPP
#define HSO_EPFNOSUPPORT EPFNOSUPPORT
#define HSO_EAFNOSUPPORT EAFNOSUPPORT
#define HSO_EADDRINUSE EADDRINUSE
#define HSO_EADDRNOTAVAIL EADDRNOTAVAIL
#define HSO_ENETDOWN ENETDOWN
#define HSO_ENETUNREACH ENETUNREACH
#define HSO_ENETRESET ENETRESET
#define HSO_ECONNABORTED ECONNABORTED
#define HSO_ECONNRESET ECONNRESET
#define HSO_ENOBUFS ENOBUFS
#define HSO_EISCONN EISCONN
#define HSO_ENOTCONN ENOTCONN
#define HSO_ESHUTDOWN ESHUTDOWN
#define HSO_ETOOMANYREFS ETOOMANYREFS
#define HSO_ETIMEDOUT ETIMEDOUT
#define HSO_ECONNREFUSED ECONNREFUSED
#define HSO_ELOOP ELOOP
#define HSO_ENAMETOOLONG ENAMETOOLONG
#define HSO_EHOSTDOWN EHOSTDOWN
#define HSO_EHOSTUNREACH EHOSTUNREACH
#define HSO_ENOTEMPTY ENOTEMPTY
#define HSO_EPROCLIM EPROCLIM
#define HSO_EUSERS EUSERS
#define HSO_EDQUOT EDQUOT
#define HSO_ESTALE ESTALE
#define HSO_EREMOTE EREMOTE
#endif
/*-------------------------------------------------------------------*/
/* Local function definitions */
/*-------------------------------------------------------------------*/
HSOCK_DLL_IMPORT int read_socket(int fd, void *ptr, int nbytes);
HSOCK_DLL_IMPORT int write_socket(int fd, const void *ptr, int nbytes);
HSOCK_DLL_IMPORT int disable_nagle(int fd);
#endif /*!defined(_HSOCKET_H)*/