NCBI C++ ToolKit
sysdep_private.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3  * Copyright (C) 2010 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _tds_sysdep_private_h_
22 #define _tds_sysdep_private_h_
23 
24 #include <config.h>
25 
26 #define TDS_ADDITIONAL_SPACE 16
27 
28 #ifdef MSG_NOSIGNAL
29 # define TDS_NOSIGNAL MSG_NOSIGNAL
30 #else
31 # define TDS_NOSIGNAL 0L
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #if 0
38 }
39 #endif
40 #endif
41 
42 #ifdef __INCvxWorksh
43 #include <ioLib.h> /* for FIONBIO */
44 #endif /* __INCvxWorksh */
45 
46 #if defined(DOS32X)
47 #define READSOCKET(a,b,c) recv((a), (b), (c), TDS_NOSIGNAL)
48 #define WRITESOCKET(a,b,c) send((a), (b), (c), TDS_NOSIGNAL)
49 #define CLOSESOCKET(a) closesocket((a))
50 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (char*)(c))
51 #define SOCKLEN_T int
52 #define select select_s
53 typedef int pid_t;
54 #define strcasecmp stricmp
55 #define strncasecmp strnicmp
56 /* TODO this has nothing to do with ip ... */
57 #define getpid() _gethostid()
58 #endif /* defined(DOS32X) */
59 
60 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64)
61 #include <winsock2.h>
62 #include <ws2tcpip.h>
63 #include <windows.h>
64 #define READSOCKET(a,b,c) recv((a), (char *) (b), (c), TDS_NOSIGNAL)
65 #define WRITESOCKET(a,b,c) send((a), (const char *) (b), (c), TDS_NOSIGNAL)
66 #define CLOSESOCKET(a) closesocket((a))
67 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c))
68 #define SOCKLEN_T int
69 int tds_socket_init(void);
70 #define INITSOCKET() tds_socket_init()
71 void tds_socket_done(void);
72 #define DONESOCKET() tds_socket_done()
73 #define NETDB_REENTRANT 1 /* BSD-style netdb interface is reentrant */
74 
75 #define TDSSOCK_EINTR WSAEINTR
76 #define TDSSOCK_EINPROGRESS WSAEWOULDBLOCK
77 #define TDSSOCK_ETIMEDOUT WSAETIMEDOUT
78 #define TDSSOCK_WOULDBLOCK(e) ((e)==WSAEWOULDBLOCK)
79 #define TDSSOCK_ECONNRESET WSAECONNRESET
80 #define sock_errno WSAGetLastError()
81 #define set_sock_errno(err) WSASetLastError(err)
82 #define sock_strerror(n) tds_prwsaerror(n)
83 #define sock_strerror_free(s) tds_prwsaerror_free(s)
84 #ifndef __MINGW32__
85 typedef DWORD pid_t;
86 #endif
87 #undef strcasecmp
88 #define strcasecmp stricmp
89 #undef strncasecmp
90 #define strncasecmp strnicmp
91 #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF)
92 #define snprintf _snprintf
93 #endif
94 
95 #ifndef WIN32
96 #define WIN32 1
97 #endif
98 
99 #if defined(_WIN64) && !defined(WIN64)
100 #define WIN64 1
101 #endif
102 
103 #define TDS_SDIR_SEPARATOR "\\"
104 
105 /* use macros to use new style names */
106 #if defined(__MSVCRT__) || defined(_MSC_VER)
107 /* Use API as always present and not causing problems */
108 #undef getpid
109 #define getpid() GetCurrentProcessId()
110 #define strdup(s) _strdup(s)
111 #define unlink(f) _unlink(f)
112 #define putenv(s) _putenv(s)
113 #undef fileno
114 #define fileno(f) _fileno(f)
115 #define stricmp(s1,s2) _stricmp(s1,s2)
116 #define strnicmp(s1,s2,n) _strnicmp(s1,s2,n)
117 #endif
118 
119 #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */
120 
121 #ifndef sock_errno
122 #define sock_errno errno
123 #endif
124 
125 #ifndef set_sock_errno
126 #define set_sock_errno(err) do { errno = (err); } while(0)
127 #endif
128 
129 #ifndef sock_strerror
130 #define sock_strerror(n) strerror(n)
131 #define sock_strerror_free(s) do {} while(0)
132 #endif
133 
134 #ifndef TDSSOCK_EINTR
135 #define TDSSOCK_EINTR EINTR
136 #endif
137 
138 #ifndef TDSSOCK_EINPROGRESS
139 #define TDSSOCK_EINPROGRESS EINPROGRESS
140 #endif
141 
142 #ifndef TDSSOCK_ETIMEDOUT
143 #define TDSSOCK_ETIMEDOUT ETIMEDOUT
144 #endif
145 
146 #ifndef TDSSOCK_WOULDBLOCK
147 # if defined(EWOULDBLOCK) && EAGAIN != EWOULDBLOCK
148 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN||(e)==EWOULDBLOCK)
149 # else
150 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN)
151 # endif
152 #endif
153 
154 #ifndef TDSSOCK_ECONNRESET
155 #define TDSSOCK_ECONNRESET ECONNRESET
156 #endif
157 
158 #ifndef INITSOCKET
159 #define INITSOCKET() 0
160 #endif /* !INITSOCKET */
161 
162 #ifndef DONESOCKET
163 #define DONESOCKET() do { } while(0)
164 #endif /* !DONESOCKET */
165 
166 #ifndef READSOCKET
167 # ifdef MSG_NOSIGNAL
168 # define READSOCKET(s,b,l) recv((s), (b), (l), MSG_NOSIGNAL)
169 # else
170 # define READSOCKET(s,b,l) read((s), (b), (l))
171 # endif
172 #endif /* !READSOCKET */
173 
174 #ifndef WRITESOCKET
175 # ifdef MSG_NOSIGNAL
176 # define WRITESOCKET(s,b,l) send((s), (b), (l), MSG_NOSIGNAL)
177 # else
178 # define WRITESOCKET(s,b,l) write((s), (b), (l))
179 # endif
180 #endif /* !WRITESOCKET */
181 
182 #ifndef CLOSESOCKET
183 #define CLOSESOCKET(s) close((s))
184 #endif /* !CLOSESOCKET */
185 
186 #ifndef IOCTLSOCKET
187 #define IOCTLSOCKET(s,b,l) ioctl((s), (b), (l))
188 #endif /* !IOCTLSOCKET */
189 
190 #ifndef SOCKLEN_T
191 # define SOCKLEN_T socklen_t
192 #endif
193 
194 #if !defined(__WIN32__) && !defined(_WIN32) && !defined(WIN32)
195 typedef int TDS_SYS_SOCKET;
196 #define INVALID_SOCKET -1
197 #define TDS_IS_SOCKET_INVALID(s) ((s) < 0)
198 #else
199 typedef SOCKET TDS_SYS_SOCKET;
200 #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET)
201 #endif
202 
203 #define tds_accept accept
204 #define tds_getpeername getpeername
205 #define tds_getsockopt getsockopt
206 #define tds_getsockname getsockname
207 #define tds_recvfrom recvfrom
208 
209 #if defined(__hpux__) && SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
210 # if HAVE__XPG_ACCEPT
211 # undef tds_accept
212 # define tds_accept _xpg_accept
213 # elif HAVE___ACCEPT
214 # undef tds_accept
215 # define tds_accept __accept
216 # endif
217 # if HAVE__XPG_GETPEERNAME
218 # undef tds_getpeername
219 # define tds_getpeername _xpg_getpeername
220 # elif HAVE___GETPEERNAME
221 # undef tds_getpeername
222 # define tds_getpeername __getpeername
223 # endif
224 # if HAVE__XPG_GETSOCKOPT
225 # undef tds_getsockopt
226 # define tds_getsockopt _xpg_getsockopt
227 # elif HAVE___GETSOCKOPT
228 # undef tds_getsockopt
229 # define tds_getsockopt __getsockopt
230 # endif
231 # if HAVE__XPG_GETSOCKNAME
232 # undef tds_getsockname
233 # define tds_getsockname _xpg_getsockname
234 # elif HAVE___GETSOCKNAME
235 # undef tds_getsockname
236 # define tds_getsockname __getsockname
237 # endif
238 # if HAVE__XPG_RECVFROM
239 # undef tds_recvfrom
240 # define tds_recvfrom _xpg_recvfrom
241 # elif HAVE___RECVFROM
242 # undef tds_recvfrom
243 # define tds_recvfrom __recvfrom
244 # endif
245 #endif
246 
247 #ifndef TDS_SDIR_SEPARATOR
248 #define TDS_SDIR_SEPARATOR "/"
249 #endif /* !TDS_SDIR_SEPARATOR */
250 
251 #ifdef HAVE_INTTYPES_H
252 #include <inttypes.h>
253 #endif
254 
255 #ifndef PRId64
256 #define PRId64 TDS_I64_PREFIX "d"
257 #endif
258 #ifndef PRIu64
259 #define PRIu64 TDS_I64_PREFIX "u"
260 #endif
261 #ifndef PRIx64
262 #define PRIx64 TDS_I64_PREFIX "x"
263 #endif
264 
265 #ifdef __cplusplus
266 #if 0
267 {
268 #endif
269 }
270 #endif
271 
272 #endif /* _tds_sysdep_private_h_ */
int TDS_SYS_SOCKET
unsigned int DWORD
Definition: sqltypes.h:98
Modified on Wed May 15 15:08:03 2024 by modify_doxy.py rev. 669887