FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tds_sysdep_private.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tds_sysdep_private_h_
21 #define _tds_sysdep_private_h_
22 
23 /* $Id: tds_sysdep_private.h,v 1.23.2.1 2008/03/11 08:27:35 freddy77 Exp $ */
24 
25 #undef TDS_RCSID
26 #if defined(__GNUC__) && __GNUC__ >= 3
27 #define TDS_RCSID(name, id) \
28  static const char rcsid_##name[] __attribute__ ((unused)) = id
29 #else
30 #define TDS_RCSID(name, id) \
31  static const char rcsid_##name[] = id; \
32  static const void *const no_unused_##name##_warn[] = { rcsid_##name, no_unused_##name##_warn }
33 #endif
34 
35 #define TDS_ADDITIONAL_SPACE 0
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #if 0
41 }
42 #endif
43 #endif
44 
45 #ifdef __INCvxWorksh
46 #include <ioLib.h> /* for FIONBIO */
47 #endif /* __INCvxWorksh */
48 
49 #if defined(DOS32X)
50 #define READSOCKET(a,b,c) recv((a), (b), (c), 0L)
51 #define WRITESOCKET(a,b,c) send((a), (b), (c), 0L)
52 #define CLOSESOCKET(a) closesocket((a))
53 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (char*)(c))
54 #define select select_s
55 typedef int pid_t;
56 #define strcasecmp stricmp
57 #define strncasecmp strnicmp
58 #define vsnprintf _vsnprintf
59 /* TODO this has nothing to do with ip ... */
60 #define getpid() _gethostid()
61 #endif /* defined(DOS32X) */
62 
63 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
64 #include <windows.h>
65 #define READSOCKET(a,b,c) recv((a), (b), (c), 0L)
66 #define WRITESOCKET(a,b,c) send((a), (b), (c), 0L)
67 #define CLOSESOCKET(a) closesocket((a))
68 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c))
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 sock_errno WSAGetLastError()
78 #ifndef __MINGW32__
79 typedef DWORD pid_t;
80 #endif
81 #define strcasecmp stricmp
82 #define strncasecmp strnicmp
83 #define atoll _atoi64
84 #define vsnprintf _vsnprintf
85 
86 #ifndef WIN32
87 #define WIN32 1
88 #endif
89 
90 #if defined(_WIN64) && !defined(WIN64)
91 #define WIN64 1
92 #endif
93 
94 #define TDS_SDIR_SEPARATOR "\\"
95 
96 /* use macros to use new style names */
97 #ifdef __MSVCRT__
98 #define getpid() _getpid()
99 #define strdup(s) _strdup(s)
100 #define stricmp(s1,s2) _stricmp(s1,s2)
101 #define strnicmp(s1,s2,n) _strnicmp(s1,s2,n)
102 #endif
103 
104 #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */
105 
106 #ifndef sock_errno
107 #define sock_errno errno
108 #endif
109 
110 #ifndef TDSSOCK_EINTR
111 #define TDSSOCK_EINTR EINTR
112 #endif
113 
114 #ifndef TDSSOCK_EINPROGRESS
115 #define TDSSOCK_EINPROGRESS EINPROGRESS
116 #endif
117 
118 #ifndef INITSOCKET
119 #define INITSOCKET() 0
120 #endif /* !INITSOCKET */
121 
122 #ifndef DONESOCKET
123 #define DONESOCKET() do { } while(0)
124 #endif /* !DONESOCKET */
125 
126 #ifndef READSOCKET
127 #define READSOCKET(a,b,c) read((a), (b), (c))
128 #endif /* !READSOCKET */
129 
130 #ifndef WRITESOCKET
131 #define WRITESOCKET(a,b,c) write((a), (b), (c))
132 #endif /* !WRITESOCKET */
133 
134 #ifndef CLOSESOCKET
135 #define CLOSESOCKET(a) close((a))
136 #endif /* !CLOSESOCKET */
137 
138 #ifndef IOCTLSOCKET
139 #define IOCTLSOCKET(a,b,c) ioctl((a), (b), (c))
140 #endif /* !IOCTLSOCKET */
141 
142 #ifndef TDS_SDIR_SEPARATOR
143 #define TDS_SDIR_SEPARATOR "/"
144 #endif /* !TDS_SDIR_SEPARATOR */
145 
146 #ifdef __cplusplus
147 #if 0
148 {
149 #endif
150 }
151 #endif
152 
153 #endif /* _tds_sysdep_private_h_ */