Merge lp:~brianaker/libdrizzle/windows-support-via-mingw into lp:libdrizzle
- windows-support-via-mingw
- Merge into libdrizzle-redux
Proposed by
Brian Aker
Status: | Merged |
---|---|
Approved by: | Andrew Hutchings |
Approved revision: | 81 |
Merged at revision: | 81 |
Proposed branch: | lp:~brianaker/libdrizzle/windows-support-via-mingw |
Merge into: | lp:libdrizzle |
Diff against target: |
1359 lines (+509/-354) 24 files modified
cli/drizzle_binlogs.c (+13/-3) cli/include.am (+3/-1) configure.ac (+20/-6) libdrizzle-5.1/drizzle.h (+8/-44) libdrizzle-5.1/drizzle_client.h (+11/-2) libdrizzle-5.1/visibility.h (+9/-51) libdrizzle/binlog.cc (+1/-0) libdrizzle/common.h (+24/-8) libdrizzle/conn.cc (+55/-138) libdrizzle/drizzle.cc (+3/-1) libdrizzle/error.cc (+3/-1) libdrizzle/include.am (+11/-3) libdrizzle/poll.cc (+86/-0) libdrizzle/poll.h (+47/-0) libdrizzle/query.cc (+2/-0) libdrizzle/ssl.cc (+13/-1) libdrizzle/statement_local.h (+0/-7) libdrizzle/structs.h (+13/-5) libdrizzle/windows.hpp (+123/-0) m4/ax_platform.m4 (+10/-6) m4/bottom.m4 (+6/-23) m4/socket_send_flags.m4 (+47/-48) tests/unit/binlog.c (+0/-1) tests/unit/row.c (+1/-5) |
To merge this branch: | bzr merge lp:~brianaker/libdrizzle/windows-support-via-mingw |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Hutchings | Approve | ||
Review via email: mp+142013@code.launchpad.net |
Commit message
Description of the change
Windows support via compiling with Mingw.
To post a comment you must log in.
- 81. By Brian Aker
-
Merge mingw tree with trunk.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'cli/drizzle_binlogs.c' | |||
2 | --- cli/drizzle_binlogs.c 2013-01-05 10:27:32 +0000 | |||
3 | +++ cli/drizzle_binlogs.c 2013-01-05 15:58:23 +0000 | |||
4 | @@ -34,16 +34,26 @@ | |||
5 | 34 | * | 34 | * |
6 | 35 | */ | 35 | */ |
7 | 36 | 36 | ||
9 | 37 | #define _GNU_SOURCE 1 | 37 | #include "config.h" |
10 | 38 | |||
11 | 38 | #include <libdrizzle-5.1/libdrizzle.h> | 39 | #include <libdrizzle-5.1/libdrizzle.h> |
12 | 39 | #include <stdlib.h> | 40 | #include <stdlib.h> |
13 | 40 | #include <sys/types.h> | 41 | #include <sys/types.h> |
15 | 41 | #include <pwd.h> | 42 | |
16 | 43 | #ifdef HAVE_PWD_H | ||
17 | 44 | # include <pwd.h> | ||
18 | 45 | #endif | ||
19 | 46 | |||
20 | 42 | #include <unistd.h> | 47 | #include <unistd.h> |
21 | 43 | #include <errno.h> | 48 | #include <errno.h> |
22 | 44 | #include <argp.h> | ||
23 | 45 | #include <time.h> | 49 | #include <time.h> |
24 | 46 | 50 | ||
25 | 51 | #ifdef HAVE_ARGP_H | ||
26 | 52 | # include <argp.h> | ||
27 | 53 | #else | ||
28 | 54 | # error "drizzle_binlogs requires <argp.h>" | ||
29 | 55 | #endif | ||
30 | 56 | |||
31 | 47 | #define STR_HELPER(x) #x | 57 | #define STR_HELPER(x) #x |
32 | 48 | #define STR(x) STR_HELPER(x) | 58 | #define STR(x) STR_HELPER(x) |
33 | 49 | 59 | ||
34 | 50 | 60 | ||
35 | === modified file 'cli/include.am' | |||
36 | --- cli/include.am 2012-12-28 21:23:12 +0000 | |||
37 | +++ cli/include.am 2013-01-05 15:58:23 +0000 | |||
38 | @@ -2,10 +2,12 @@ | |||
39 | 2 | # included from Top Level Makefile.am | 2 | # included from Top Level Makefile.am |
40 | 3 | # All paths should be given relative to the root | 3 | # All paths should be given relative to the root |
41 | 4 | 4 | ||
42 | 5 | if BUILD_WIN32 | ||
43 | 6 | else | ||
44 | 5 | bin_PROGRAMS+= cli/drizzle_binlogs | 7 | bin_PROGRAMS+= cli/drizzle_binlogs |
45 | 6 | cli_drizzle_binlogs_SOURCES= cli/drizzle_binlogs.c | 8 | cli_drizzle_binlogs_SOURCES= cli/drizzle_binlogs.c |
46 | 7 | cli_drizzle_binlogs_LDADD= libdrizzle/libdrizzle.la | 9 | cli_drizzle_binlogs_LDADD= libdrizzle/libdrizzle.la |
47 | 8 | 10 | ||
48 | 9 | check_SCRIPTS+= cli/drizzle_binlogs_check.sh | 11 | check_SCRIPTS+= cli/drizzle_binlogs_check.sh |
49 | 10 | EXTRA_DIST+= ${check_SCRIPTS} | 12 | EXTRA_DIST+= ${check_SCRIPTS} |
51 | 11 | 13 | endif | |
52 | 12 | 14 | ||
53 | === modified file 'configure.ac' | |||
54 | --- configure.ac 2013-01-04 20:47:22 +0000 | |||
55 | +++ configure.ac 2013-01-05 15:58:23 +0000 | |||
56 | @@ -57,23 +57,37 @@ | |||
57 | 57 | 57 | ||
58 | 58 | # Checks for libraries. | 58 | # Checks for libraries. |
59 | 59 | AX_CXX_GCC_ABI_DEMANGLE | 59 | AX_CXX_GCC_ABI_DEMANGLE |
61 | 60 | AX_CHECK_OPENSSL | 60 | |
62 | 61 | AS_IF([test "x${target_os}" != "xmingw32"], [AX_CHECK_OPENSSL]) | ||
63 | 62 | |||
64 | 61 | AC_PATH_ZLIB | 63 | AC_PATH_ZLIB |
65 | 62 | 64 | ||
66 | 63 | # Checks for header files. | 65 | # Checks for header files. |
67 | 64 | AC_DEFUN([CHECK_FOR_CXXABI], | 66 | AC_DEFUN([CHECK_FOR_CXXABI], |
68 | 65 | [AC_LANG_PUSH([C++]) | 67 | [AC_LANG_PUSH([C++]) |
69 | 66 | AC_CHECK_HEADERS([cxxabi.h]) | 68 | AC_CHECK_HEADERS([cxxabi.h]) |
72 | 67 | AC_LANG_POP | 69 | AC_LANG_POP]) |
73 | 68 | ]) | 70 | |
74 | 69 | CHECK_FOR_CXXABI | 71 | CHECK_FOR_CXXABI |
78 | 70 | AC_CHECK_HEADERS_ONCE([errno.h]) | 72 | AC_CHECK_HEADERS([argp.h]) |
79 | 71 | AC_CHECK_HEADERS_ONCE([sys/socket.h]) | 73 | AC_CHECK_HEADERS([errno.h]) |
80 | 72 | AC_CHECK_HEADERS_ONCE([poll.h]) | 74 | AC_CHECK_HEADERS([fcntl.h]) |
81 | 75 | AC_CHECK_HEADERS([io.h]) | ||
82 | 76 | AC_CHECK_HEADERS([openssl/ssl.h]) | ||
83 | 77 | AC_CHECK_HEADERS([poll.h]) | ||
84 | 78 | AC_CHECK_HEADERS([pwd.h]) | ||
85 | 79 | AC_CHECK_HEADERS([sys/socket.h]) | ||
86 | 80 | AC_CHECK_HEADERS([windows.h]) | ||
87 | 81 | AC_CHECK_HEADERS([winsock2.h]) | ||
88 | 82 | AC_CHECK_HEADERS([ws2tcpip.h]) | ||
89 | 73 | 83 | ||
90 | 74 | # Checks for typedefs, structures, and compiler characteristics. | 84 | # Checks for typedefs, structures, and compiler characteristics. |
91 | 85 | AC_CHECK_TYPES([in_port_t]) | ||
92 | 86 | AC_TYPE_SSIZE_T | ||
93 | 87 | AC_TYPE_SIZE_T | ||
94 | 75 | 88 | ||
95 | 76 | # Checks for library functions. | 89 | # Checks for library functions. |
96 | 90 | AC_CHECK_FUNCS([fcntl]) | ||
97 | 77 | AC_CHECK_FUNCS([poll]) | 91 | AC_CHECK_FUNCS([poll]) |
98 | 78 | AC_CHECK_FUNCS([ppoll]) | 92 | AC_CHECK_FUNCS([ppoll]) |
99 | 79 | 93 | ||
100 | 80 | 94 | ||
101 | === modified file 'libdrizzle-5.1/drizzle.h' | |||
102 | --- libdrizzle-5.1/drizzle.h 2012-12-30 11:18:18 +0000 | |||
103 | +++ libdrizzle-5.1/drizzle.h 2013-01-05 15:58:23 +0000 | |||
104 | @@ -36,63 +36,27 @@ | |||
105 | 36 | 36 | ||
106 | 37 | #pragma once | 37 | #pragma once |
107 | 38 | 38 | ||
108 | 39 | #ifndef DRIZZLE_CLIENT_INTERFACE | ||
109 | 40 | # error "You need to include libdrizzle-5.1/drizzle_client.h in your application" | ||
110 | 41 | #endif | ||
111 | 42 | |||
112 | 39 | /** | 43 | /** |
113 | 40 | * @file | 44 | * @file |
114 | 41 | * @brief Drizzle Declarations | 45 | * @brief Drizzle Declarations |
115 | 42 | */ | 46 | */ |
116 | 43 | 47 | ||
117 | 44 | #include <sys/types.h> | ||
118 | 45 | |||
119 | 46 | #ifdef _WIN32 | 48 | #ifdef _WIN32 |
157 | 47 | # define WIN32_LEAN_AND_MEAN | 49 | |
158 | 48 | 50 | typedef int in_port_t; | |
159 | 49 | # include <Windows.h> | 51 | |
160 | 50 | # include <winsock2.h> | 52 | #else |
124 | 51 | # include <ws2tcpip.h> | ||
125 | 52 | # include <io.h> | ||
126 | 53 | |||
127 | 54 | # undef close | ||
128 | 55 | # define close _close | ||
129 | 56 | typedef unsigned int in_port_t; | ||
130 | 57 | typedef long ssize_t; | ||
131 | 58 | |||
132 | 59 | # define snprintf _snprintf | ||
133 | 60 | # define inline __inline | ||
134 | 61 | |||
135 | 62 | struct sockaddr_un | ||
136 | 63 | { | ||
137 | 64 | short int sun_family; | ||
138 | 65 | char sun_path[108]; | ||
139 | 66 | }; | ||
140 | 67 | |||
141 | 68 | # define poll WSAPoll | ||
142 | 69 | //# define pollfd WSAPOLLFD | ||
143 | 70 | |||
144 | 71 | #if defined(__GNUC__) | ||
145 | 72 | # include <stdbool.h> | ||
146 | 73 | #else | ||
147 | 74 | # if !defined(__cplusplus) | ||
148 | 75 | typedef enum { false = 0, true = 1 } _Bool; | ||
149 | 76 | typedef _Bool bool; | ||
150 | 77 | #endif | ||
151 | 78 | #endif | ||
152 | 79 | |||
153 | 80 | #else | ||
154 | 81 | # if !defined(__cplusplus) | ||
155 | 82 | # include <stdbool.h> | ||
156 | 83 | # endif | ||
161 | 84 | # include <sys/socket.h> | 53 | # include <sys/socket.h> |
162 | 85 | # include <netinet/in.h> | 54 | # include <netinet/in.h> |
163 | 86 | # include <arpa/inet.h> | 55 | # include <arpa/inet.h> |
164 | 87 | # include <sys/un.h> | 56 | # include <sys/un.h> |
165 | 88 | # include <netdb.h> | 57 | # include <netdb.h> |
166 | 89 | # include <poll.h> | ||
167 | 90 | #endif | ||
168 | 91 | #ifdef USE_OPENSSL | ||
169 | 92 | #include <openssl/ssl.h> | ||
170 | 93 | #endif | 58 | #endif |
171 | 94 | 59 | ||
172 | 95 | #include <libdrizzle-5.1/visibility.h> | ||
173 | 96 | #include <libdrizzle-5.1/constants.h> | 60 | #include <libdrizzle-5.1/constants.h> |
174 | 97 | #include <libdrizzle-5.1/structs.h> | 61 | #include <libdrizzle-5.1/structs.h> |
175 | 98 | #include <libdrizzle-5.1/conn.h> | 62 | #include <libdrizzle-5.1/conn.h> |
176 | 99 | 63 | ||
177 | === modified file 'libdrizzle-5.1/drizzle_client.h' | |||
178 | --- libdrizzle-5.1/drizzle_client.h 2012-12-24 10:20:04 +0000 | |||
179 | +++ libdrizzle-5.1/drizzle_client.h 2013-01-05 15:58:23 +0000 | |||
180 | @@ -42,6 +42,17 @@ | |||
181 | 42 | 42 | ||
182 | 43 | #pragma once | 43 | #pragma once |
183 | 44 | 44 | ||
184 | 45 | #ifndef DRIZZLE_CLIENT_INTERFACE | ||
185 | 46 | # define DRIZZLE_CLIENT_INTERFACE 1 | ||
186 | 47 | #endif | ||
187 | 48 | |||
188 | 49 | #include <stdbool.h> | ||
189 | 50 | #include <stdint.h> | ||
190 | 51 | #include <sys/types.h> | ||
191 | 52 | |||
192 | 53 | /* Visibility must come first */ | ||
193 | 54 | #include <libdrizzle-5.1/visibility.h> | ||
194 | 55 | |||
195 | 45 | #include <libdrizzle-5.1/drizzle.h> | 56 | #include <libdrizzle-5.1/drizzle.h> |
196 | 46 | #include <libdrizzle-5.1/conn_client.h> | 57 | #include <libdrizzle-5.1/conn_client.h> |
197 | 47 | #include <libdrizzle-5.1/handshake_client.h> | 58 | #include <libdrizzle-5.1/handshake_client.h> |
198 | @@ -52,9 +63,7 @@ | |||
199 | 52 | #include <libdrizzle-5.1/row_client.h> | 63 | #include <libdrizzle-5.1/row_client.h> |
200 | 53 | #include <libdrizzle-5.1/field_client.h> | 64 | #include <libdrizzle-5.1/field_client.h> |
201 | 54 | #include <libdrizzle-5.1/error.h> | 65 | #include <libdrizzle-5.1/error.h> |
202 | 55 | #ifdef USE_OPENSSL | ||
203 | 56 | #include <libdrizzle-5.1/ssl.h> | 66 | #include <libdrizzle-5.1/ssl.h> |
204 | 57 | #endif | ||
205 | 58 | #include <libdrizzle-5.1/binlog.h> | 67 | #include <libdrizzle-5.1/binlog.h> |
206 | 59 | #include <libdrizzle-5.1/statement.h> | 68 | #include <libdrizzle-5.1/statement.h> |
207 | 60 | #include <libdrizzle-5.1/version.h> | 69 | #include <libdrizzle-5.1/version.h> |
208 | 61 | 70 | ||
209 | === modified file 'libdrizzle-5.1/visibility.h' | |||
210 | --- libdrizzle-5.1/visibility.h 2012-12-18 11:36:28 +0000 | |||
211 | +++ libdrizzle-5.1/visibility.h 2013-01-05 15:58:23 +0000 | |||
212 | @@ -1,44 +1,11 @@ | |||
217 | 1 | /* | 1 | /* libdrizzle |
218 | 2 | * Drizzle Client & Protocol Library | 2 | * Copyright (C) 2013 Drizzle Developers Group |
215 | 3 | * | ||
216 | 4 | * Copyright (C) 2008 Eric Day (eday@oddments.org) | ||
219 | 5 | * All rights reserved. | 3 | * All rights reserved. |
220 | 6 | * | 4 | * |
256 | 7 | * Redistribution and use in source and binary forms, with or without | 5 | * Use and distribution licensed under the BSD license. See |
257 | 8 | * modification, are permitted provided that the following conditions are | 6 | * the COPYING file in the parent directory for full text. |
258 | 9 | * met: | 7 | * |
259 | 10 | * | 8 | * |
225 | 11 | * * Redistributions of source code must retain the above copyright | ||
226 | 12 | * notice, this list of conditions and the following disclaimer. | ||
227 | 13 | * | ||
228 | 14 | * * Redistributions in binary form must reproduce the above | ||
229 | 15 | * copyright notice, this list of conditions and the following disclaimer | ||
230 | 16 | * in the documentation and/or other materials provided with the | ||
231 | 17 | * distribution. | ||
232 | 18 | * | ||
233 | 19 | * * The names of its contributors may not be used to endorse or | ||
234 | 20 | * promote products derived from this software without specific prior | ||
235 | 21 | * written permission. | ||
236 | 22 | * | ||
237 | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
238 | 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
239 | 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
240 | 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
241 | 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
242 | 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
243 | 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
244 | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
245 | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
246 | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
247 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
248 | 34 | * | ||
249 | 35 | * | ||
250 | 36 | * Implementation drawn from visibility.texi in gnulib. | ||
251 | 37 | */ | ||
252 | 38 | |||
253 | 39 | /** | ||
254 | 40 | * @file | ||
255 | 41 | * @brief Visibility Control Macros | ||
260 | 42 | */ | 9 | */ |
261 | 43 | 10 | ||
262 | 44 | #pragma once | 11 | #pragma once |
263 | @@ -48,31 +15,22 @@ | |||
264 | 48 | * DRIZZLE_API is used for the public API symbols. It either DLL imports or | 15 | * DRIZZLE_API is used for the public API symbols. It either DLL imports or |
265 | 49 | * DLL exports (or does nothing for static build). | 16 | * DLL exports (or does nothing for static build). |
266 | 50 | * | 17 | * |
267 | 51 | * DRIZZLE_LOCAL is used for non-api symbols. | ||
268 | 52 | */ | 18 | */ |
269 | 53 | 19 | ||
270 | 54 | #if defined(_WIN32) | ||
271 | 55 | # define DRIZZLE_API | ||
272 | 56 | # define DRIZZLE_LOCAL | ||
273 | 57 | #else | ||
274 | 58 | #if defined(BUILDING_LIBDRIZZLE) | 20 | #if defined(BUILDING_LIBDRIZZLE) |
276 | 59 | # if defined(HAVE_VISIBILITY) | 21 | # if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY |
277 | 60 | # define DRIZZLE_API __attribute__ ((visibility("default"))) | 22 | # define DRIZZLE_API __attribute__ ((visibility("default"))) |
278 | 61 | # define DRIZZLE_LOCAL __attribute__ ((visibility("hidden"))) | ||
279 | 62 | # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) | 23 | # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) |
280 | 63 | # define DRIZZLE_API __global | 24 | # define DRIZZLE_API __global |
281 | 64 | # define DRIZZLE_API __hidden | ||
282 | 65 | # elif defined(_MSC_VER) | 25 | # elif defined(_MSC_VER) |
283 | 66 | # define DRIZZLE_API extern __declspec(dllexport) | 26 | # define DRIZZLE_API extern __declspec(dllexport) |
285 | 67 | # define DRIZZLE_LOCAL | 27 | # else |
286 | 28 | # define DRIZZLE_API | ||
287 | 68 | # endif /* defined(HAVE_VISIBILITY) */ | 29 | # endif /* defined(HAVE_VISIBILITY) */ |
288 | 69 | #else /* defined(BUILDING_LIBDRIZZLE) */ | 30 | #else /* defined(BUILDING_LIBDRIZZLE) */ |
289 | 70 | # if defined(_MSC_VER) | 31 | # if defined(_MSC_VER) |
290 | 71 | # define DRIZZLE_API extern __declspec(dllimport) | 32 | # define DRIZZLE_API extern __declspec(dllimport) |
291 | 72 | # define DRIZZLE_LOCAL | ||
292 | 73 | # else | 33 | # else |
293 | 74 | # define DRIZZLE_API | 34 | # define DRIZZLE_API |
294 | 75 | # define DRIZZLE_LOCAL | ||
295 | 76 | # endif /* defined(_MSC_VER) */ | 35 | # endif /* defined(_MSC_VER) */ |
296 | 77 | #endif /* defined(BUILDING_LIBDRIZZLE) */ | 36 | #endif /* defined(BUILDING_LIBDRIZZLE) */ |
297 | 78 | #endif /* _WIN32 */ | ||
298 | 79 | 37 | ||
299 | === modified file 'libdrizzle/binlog.cc' | |||
300 | --- libdrizzle/binlog.cc 2013-01-05 10:27:32 +0000 | |||
301 | +++ libdrizzle/binlog.cc 2013-01-05 15:58:23 +0000 | |||
302 | @@ -37,6 +37,7 @@ | |||
303 | 37 | 37 | ||
304 | 38 | #include "config.h" | 38 | #include "config.h" |
305 | 39 | #include "libdrizzle/common.h" | 39 | #include "libdrizzle/common.h" |
306 | 40 | |||
307 | 40 | #include <zlib.h> | 41 | #include <zlib.h> |
308 | 41 | 42 | ||
309 | 42 | drizzle_result_st *drizzle_start_binlog(drizzle_st *con, | 43 | drizzle_result_st *drizzle_start_binlog(drizzle_st *con, |
310 | 43 | 44 | ||
311 | === modified file 'libdrizzle/common.h' | |||
312 | --- libdrizzle/common.h 2012-12-31 07:11:30 +0000 | |||
313 | +++ libdrizzle/common.h 2013-01-05 15:58:23 +0000 | |||
314 | @@ -41,18 +41,35 @@ | |||
315 | 41 | 41 | ||
316 | 42 | #pragma once | 42 | #pragma once |
317 | 43 | 43 | ||
318 | 44 | #include "config.h" | ||
319 | 45 | |||
320 | 46 | #include <libdrizzle-5.1/drizzle_client.h> | 44 | #include <libdrizzle-5.1/drizzle_client.h> |
321 | 47 | 45 | ||
327 | 48 | #include <assert.h> | 46 | #include <cassert> |
328 | 49 | #include <errno.h> | 47 | |
329 | 50 | 48 | #ifdef HAVE_FCNTL_H | |
330 | 51 | #include <fcntl.h> | 49 | # include <fcntl.h> |
331 | 52 | #ifndef _WIN32 | 50 | #endif |
332 | 51 | |||
333 | 52 | #if defined(WIN32) || defined(__MINGW32__) | ||
334 | 53 | # include "libdrizzle/windows.hpp" | ||
335 | 54 | # define get_socket_errno() WSAGetLastError() | ||
336 | 55 | |||
337 | 56 | #else | ||
338 | 53 | # include <netinet/tcp.h> | 57 | # include <netinet/tcp.h> |
339 | 54 | # include <sys/uio.h> | 58 | # include <sys/uio.h> |
340 | 55 | # include <unistd.h> | 59 | # include <unistd.h> |
341 | 60 | # include <cerrno> | ||
342 | 61 | # define INVALID_SOCKET -1 | ||
343 | 62 | # define SOCKET_ERROR -1 | ||
344 | 63 | # define closesocket(a) close(a) | ||
345 | 64 | # define get_socket_errno() errno | ||
346 | 65 | |||
347 | 66 | #endif // defined(WIN32) || defined(__MINGW32__) | ||
348 | 67 | |||
349 | 68 | #if defined(HAVE_POLL_H) && HAVE_POLL_H | ||
350 | 69 | # include <poll.h> | ||
351 | 70 | typedef struct pollfd pollfd_t; | ||
352 | 71 | #else | ||
353 | 72 | # include "libdrizzle/poll.h" | ||
354 | 56 | #endif | 73 | #endif |
355 | 57 | 74 | ||
356 | 58 | #include <stddef.h> | 75 | #include <stddef.h> |
357 | @@ -60,7 +77,6 @@ | |||
358 | 60 | #include <stdio.h> | 77 | #include <stdio.h> |
359 | 61 | #include <stdlib.h> | 78 | #include <stdlib.h> |
360 | 62 | #include <string.h> | 79 | #include <string.h> |
361 | 63 | #include <signal.h> | ||
362 | 64 | 80 | ||
363 | 65 | #include "libdrizzle/structs.h" | 81 | #include "libdrizzle/structs.h" |
364 | 66 | #include "libdrizzle/drizzle_local.h" | 82 | #include "libdrizzle/drizzle_local.h" |
365 | 67 | 83 | ||
366 | === modified file 'libdrizzle/conn.cc' | |||
367 | --- libdrizzle/conn.cc 2013-01-05 11:41:26 +0000 | |||
368 | +++ libdrizzle/conn.cc 2013-01-05 15:58:23 +0000 | |||
369 | @@ -56,10 +56,24 @@ | |||
370 | 56 | # define FD_CLOEXEC 0 | 56 | # define FD_CLOEXEC 0 |
371 | 57 | #endif | 57 | #endif |
372 | 58 | 58 | ||
373 | 59 | #ifndef F_GETFD | ||
374 | 60 | # define F_GETFD 0 | ||
375 | 61 | #endif | ||
376 | 62 | |||
377 | 59 | #ifndef MSG_DONTWAIT | 63 | #ifndef MSG_DONTWAIT |
378 | 60 | # define MSG_DONTWAIT 0 | 64 | # define MSG_DONTWAIT 0 |
379 | 61 | #endif | 65 | #endif |
380 | 62 | 66 | ||
381 | 67 | #ifndef MSG_NOSIGNAL | ||
382 | 68 | # define MSG_NOSIGNAL 0 | ||
383 | 69 | #endif | ||
384 | 70 | |||
385 | 71 | #ifndef EWOULDBLOCK | ||
386 | 72 | # define EWOULDBLOCK EAGAIN | ||
387 | 73 | #endif | ||
388 | 74 | |||
389 | 75 | #include <cerrno> | ||
390 | 76 | |||
391 | 63 | /** | 77 | /** |
392 | 64 | * @addtogroup drizzle_static Static Connection Declarations | 78 | * @addtogroup drizzle_static Static Connection Declarations |
393 | 65 | * @ingroup drizzle_con | 79 | * @ingroup drizzle_con |
394 | @@ -75,52 +89,15 @@ | |||
395 | 75 | */ | 89 | */ |
396 | 76 | static drizzle_return_t _setsockopt(drizzle_st *con); | 90 | static drizzle_return_t _setsockopt(drizzle_st *con); |
397 | 77 | 91 | ||
399 | 78 | static void __closesocket(int& fd) | 92 | static void __closesocket(socket_t& fd) |
400 | 79 | { | 93 | { |
402 | 80 | if (fd != -1) | 94 | if (fd != INVALID_SOCKET) |
403 | 81 | { | 95 | { |
404 | 82 | (void)shutdown(fd, SHUT_RDWR); | 96 | (void)shutdown(fd, SHUT_RDWR); |
405 | 83 | (void)closesocket(fd); | 97 | (void)closesocket(fd); |
446 | 84 | fd= -1; | 98 | fd= INVALID_SOCKET; |
447 | 85 | } | 99 | } |
448 | 86 | } | 100 | } |
409 | 87 | |||
410 | 88 | #ifdef WIN32 | ||
411 | 89 | static void translate_windows_error() | ||
412 | 90 | { | ||
413 | 91 | errno= WSAGetLastError(); | ||
414 | 92 | switch(errno) { | ||
415 | 93 | case WSAEINVAL: | ||
416 | 94 | case WSAEALREADY: | ||
417 | 95 | case WSAEWOULDBLOCK: | ||
418 | 96 | errno= EINPROGRESS; | ||
419 | 97 | break; | ||
420 | 98 | case WSAECONNREFUSED: | ||
421 | 99 | errno= ECONNREFUSED; | ||
422 | 100 | break; | ||
423 | 101 | case WSAENETUNREACH: | ||
424 | 102 | errno= ENETUNREACH; | ||
425 | 103 | break; | ||
426 | 104 | case WSAETIMEDOUT: | ||
427 | 105 | errno= ETIMEDOUT; | ||
428 | 106 | break; | ||
429 | 107 | case WSAECONNRESET: | ||
430 | 108 | errno= ECONNRESET; | ||
431 | 109 | break; | ||
432 | 110 | case WSAEADDRINUSE: | ||
433 | 111 | errno= EADDRINUSE; | ||
434 | 112 | break; | ||
435 | 113 | case WSAEOPNOTSUPP: | ||
436 | 114 | errno= EOPNOTSUPP; | ||
437 | 115 | break; | ||
438 | 116 | case WSAENOPROTOOPT: | ||
439 | 117 | errno= ENOPROTOOPT; | ||
440 | 118 | break; | ||
441 | 119 | default: | ||
442 | 120 | break; | ||
443 | 121 | } | ||
444 | 122 | } | ||
445 | 123 | #endif | ||
449 | 124 | 101 | ||
450 | 125 | static bool connect_poll(drizzle_st *con) | 102 | static bool connect_poll(drizzle_st *con) |
451 | 126 | { | 103 | { |
452 | @@ -148,7 +125,11 @@ | |||
453 | 148 | 125 | ||
454 | 149 | if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) | 126 | if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) |
455 | 150 | { | 127 | { |
456 | 128 | #ifdef __MINGW32__ | ||
457 | 129 | char err; | ||
458 | 130 | #else | ||
459 | 151 | int err; | 131 | int err; |
460 | 132 | #endif | ||
461 | 152 | socklen_t len= sizeof (err); | 133 | socklen_t len= sizeof (err); |
462 | 153 | // We replace errno with err if getsockopt() passes, but err has been | 134 | // We replace errno with err if getsockopt() passes, but err has been |
463 | 154 | // set. | 135 | // set. |
464 | @@ -232,7 +213,7 @@ | |||
465 | 232 | return; | 213 | return; |
466 | 233 | } | 214 | } |
467 | 234 | 215 | ||
469 | 235 | if (con->fd == -1) | 216 | if (con->fd == INVALID_SOCKET) |
470 | 236 | { | 217 | { |
471 | 237 | return; | 218 | return; |
472 | 238 | } | 219 | } |
473 | @@ -935,7 +916,9 @@ | |||
474 | 935 | 916 | ||
475 | 936 | if (con->socket_type == DRIZZLE_CON_SOCKET_UDS) | 917 | if (con->socket_type == DRIZZLE_CON_SOCKET_UDS) |
476 | 937 | { | 918 | { |
478 | 938 | #ifndef WIN32 | 919 | #if defined _WIN32 || defined __CYGWIN__ |
479 | 920 | return DRIZZLE_RETURN_COULD_NOT_CONNECT; | ||
480 | 921 | #else // defined _WIN32 || defined __CYGWIN__ | ||
481 | 939 | if ((con->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) | 922 | if ((con->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) |
482 | 940 | { | 923 | { |
483 | 941 | con->last_errno= errno; | 924 | con->last_errno= errno; |
484 | @@ -971,9 +954,7 @@ | |||
485 | 971 | } while (0); | 954 | } while (0); |
486 | 972 | 955 | ||
487 | 973 | return DRIZZLE_RETURN_OK; | 956 | return DRIZZLE_RETURN_OK; |
491 | 974 | #else | 957 | #endif // defined _WIN32 || defined __CYGWIN__ |
489 | 975 | return DRIZZLE_RETURN_COULD_NOT_CONNECT; | ||
490 | 976 | #endif | ||
492 | 977 | } | 958 | } |
493 | 978 | else | 959 | else |
494 | 979 | { | 960 | { |
495 | @@ -1020,7 +1001,7 @@ | |||
496 | 1020 | { | 1001 | { |
497 | 1021 | int ret= connect(con->fd, con->addrinfo_next->ai_addr, con->addrinfo_next->ai_addrlen); | 1002 | int ret= connect(con->fd, con->addrinfo_next->ai_addr, con->addrinfo_next->ai_addrlen); |
498 | 1022 | 1003 | ||
500 | 1023 | #ifdef _WIN32 | 1004 | #if defined _WIN32 || defined __CYGWIN__ |
501 | 1024 | translate_windows_error(); | 1005 | translate_windows_error(); |
502 | 1025 | #endif /* _WIN32 */ | 1006 | #endif /* _WIN32 */ |
503 | 1026 | 1007 | ||
504 | @@ -1086,7 +1067,7 @@ | |||
505 | 1086 | drizzle_state_pop(con); | 1067 | drizzle_state_pop(con); |
506 | 1087 | socklen_t error_length= sizeof(error); | 1068 | socklen_t error_length= sizeof(error); |
507 | 1088 | int getsockopt_error; | 1069 | int getsockopt_error; |
509 | 1089 | if ((getsockopt_error= getsockopt(con->fd, SOL_SOCKET, SO_ERROR, (void*)&error, &error_length)) < 1) | 1070 | if ((getsockopt_error= getsockopt(con->fd, SOL_SOCKET, SO_ERROR, (char*)&error, &error_length)) < 1) |
510 | 1090 | { | 1071 | { |
511 | 1091 | drizzle_set_error(con, __func__, strerror(getsockopt_error)); | 1072 | drizzle_set_error(con, __func__, strerror(getsockopt_error)); |
512 | 1092 | return DRIZZLE_RETURN_COULD_NOT_CONNECT; | 1073 | return DRIZZLE_RETURN_COULD_NOT_CONNECT; |
513 | @@ -1177,46 +1158,10 @@ | |||
514 | 1177 | { | 1158 | { |
515 | 1178 | read_size= recv(con->fd, (char *)con->buffer_ptr + con->buffer_size, available_buffer, MSG_NOSIGNAL); | 1159 | read_size= recv(con->fd, (char *)con->buffer_ptr + con->buffer_size, available_buffer, MSG_NOSIGNAL); |
516 | 1179 | } | 1160 | } |
557 | 1180 | #ifdef _WIN32 | 1161 | |
558 | 1181 | if (_WIN32) | 1162 | #if defined _WIN32 || defined __CYGWIN__ |
559 | 1182 | { | 1163 | errno= translate_windows_error(); |
560 | 1183 | errno= WSAGetLastError(); | 1164 | #endif // defined _WIN32 || defined __CYGWIN__ |
521 | 1184 | switch (errno) | ||
522 | 1185 | { | ||
523 | 1186 | case WSAENOTCONN: | ||
524 | 1187 | case WSAEWOULDBLOCK: | ||
525 | 1188 | errno= EAGAIN; | ||
526 | 1189 | break; | ||
527 | 1190 | case WSAEINVAL: | ||
528 | 1191 | case WSAEALREADY: | ||
529 | 1192 | errno= EINPROGRESS; | ||
530 | 1193 | break; | ||
531 | 1194 | case WSAECONNREFUSED: | ||
532 | 1195 | errno= ECONNREFUSED; | ||
533 | 1196 | break; | ||
534 | 1197 | case WSAENETUNREACH: | ||
535 | 1198 | errno= ENETUNREACH; | ||
536 | 1199 | break; | ||
537 | 1200 | case WSAETIMEDOUT: | ||
538 | 1201 | errno= ETIMEDOUT; | ||
539 | 1202 | break; | ||
540 | 1203 | case WSAECONNRESET: | ||
541 | 1204 | errno= ECONNRESET; | ||
542 | 1205 | break; | ||
543 | 1206 | case WSAEADDRINUSE: | ||
544 | 1207 | errno= EADDRINUSE; | ||
545 | 1208 | break; | ||
546 | 1209 | case WSAEOPNOTSUPP: | ||
547 | 1210 | errno= EOPNOTSUPP; | ||
548 | 1211 | break; | ||
549 | 1212 | case WSAENOPROTOOPT: | ||
550 | 1213 | errno= ENOPROTOOPT; | ||
551 | 1214 | break; | ||
552 | 1215 | default: | ||
553 | 1216 | break; | ||
554 | 1217 | } | ||
555 | 1218 | } | ||
556 | 1219 | #endif /* _WIN32 */ | ||
561 | 1220 | 1165 | ||
562 | 1221 | drizzle_log_crazy(con, "read fd=%d recv=%zd ssl= %d errno=%s", | 1166 | drizzle_log_crazy(con, "read fd=%d recv=%zd ssl= %d errno=%s", |
563 | 1222 | con->fd, read_size, | 1167 | con->fd, read_size, |
564 | @@ -1337,42 +1282,9 @@ | |||
565 | 1337 | write_size= send(con->fd,(char *) con->buffer_ptr, con->buffer_size, MSG_NOSIGNAL); | 1282 | write_size= send(con->fd,(char *) con->buffer_ptr, con->buffer_size, MSG_NOSIGNAL); |
566 | 1338 | } | 1283 | } |
567 | 1339 | 1284 | ||
604 | 1340 | #ifdef _WIN32 | 1285 | #if defined _WIN32 || defined __CYGWIN__ |
605 | 1341 | errno = WSAGetLastError(); | 1286 | errno= translate_windows_error(); |
606 | 1342 | switch(errno) { | 1287 | #endif // defined _WIN32 || defined __CYGWIN__ |
571 | 1343 | case WSAENOTCONN: | ||
572 | 1344 | case WSAEWOULDBLOCK: | ||
573 | 1345 | errno= EAGAIN; | ||
574 | 1346 | break; | ||
575 | 1347 | case WSAEINVAL: | ||
576 | 1348 | case WSAEALREADY: | ||
577 | 1349 | errno= EINPROGRESS; | ||
578 | 1350 | break; | ||
579 | 1351 | case WSAECONNREFUSED: | ||
580 | 1352 | errno= ECONNREFUSED; | ||
581 | 1353 | break; | ||
582 | 1354 | case WSAENETUNREACH: | ||
583 | 1355 | errno= ENETUNREACH; | ||
584 | 1356 | break; | ||
585 | 1357 | case WSAETIMEDOUT: | ||
586 | 1358 | errno= ETIMEDOUT; | ||
587 | 1359 | break; | ||
588 | 1360 | case WSAECONNRESET: | ||
589 | 1361 | errno= ECONNRESET; | ||
590 | 1362 | break; | ||
591 | 1363 | case WSAEADDRINUSE: | ||
592 | 1364 | errno= EADDRINUSE; | ||
593 | 1365 | break; | ||
594 | 1366 | case WSAEOPNOTSUPP: | ||
595 | 1367 | errno= EOPNOTSUPP; | ||
596 | 1368 | break; | ||
597 | 1369 | case WSAENOPROTOOPT: | ||
598 | 1370 | errno= ENOPROTOOPT; | ||
599 | 1371 | break; | ||
600 | 1372 | default: | ||
601 | 1373 | break; | ||
602 | 1374 | } | ||
603 | 1375 | #endif /* _WIN32 */ | ||
607 | 1376 | 1288 | ||
608 | 1377 | drizzle_log_crazy(con, "write fd=%d return=%zd ssl=%d errno=%s", | 1289 | drizzle_log_crazy(con, "write fd=%d return=%zd ssl=%d errno=%s", |
609 | 1378 | con->fd, write_size, | 1290 | con->fd, write_size, |
610 | @@ -1448,27 +1360,32 @@ | |||
611 | 1448 | return DRIZZLE_RETURN_INVALID_ARGUMENT; | 1360 | return DRIZZLE_RETURN_INVALID_ARGUMENT; |
612 | 1449 | } | 1361 | } |
613 | 1450 | 1362 | ||
615 | 1451 | if (SOCK_CLOEXEC == 0) | 1363 | #ifdef HAVE_FCNTL |
616 | 1364 | if (HAVE_FCNTL) | ||
617 | 1452 | { | 1365 | { |
619 | 1453 | if (FD_CLOEXEC) | 1366 | if (SOCK_CLOEXEC == 0) |
620 | 1454 | { | 1367 | { |
623 | 1455 | int flags; | 1368 | if (FD_CLOEXEC and F_GETFD) |
622 | 1456 | do | ||
624 | 1457 | { | 1369 | { |
631 | 1458 | flags= fcntl(con->fd, F_GETFD, 0); | 1370 | int flags; |
626 | 1459 | } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); | ||
627 | 1460 | |||
628 | 1461 | if (flags != -1) | ||
629 | 1462 | { | ||
630 | 1463 | int rval; | ||
632 | 1464 | do | 1371 | do |
633 | 1372 | { | ||
634 | 1373 | flags= fcntl(con->fd, F_GETFD, 0); | ||
635 | 1374 | } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); | ||
636 | 1375 | |||
637 | 1376 | if (flags != -1) | ||
638 | 1465 | { | 1377 | { |
642 | 1466 | rval= fcntl (con->fd, F_SETFD, flags | FD_CLOEXEC); | 1378 | int rval; |
643 | 1467 | } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); | 1379 | do |
644 | 1468 | // we currently ignore the case where rval is -1 | 1380 | { |
645 | 1381 | rval= fcntl (con->fd, F_SETFD, flags | FD_CLOEXEC); | ||
646 | 1382 | } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); | ||
647 | 1383 | // we currently ignore the case where rval is -1 | ||
648 | 1384 | } | ||
649 | 1469 | } | 1385 | } |
650 | 1470 | } | 1386 | } |
651 | 1471 | } | 1387 | } |
652 | 1388 | #endif // HAVE_FCNTL | ||
653 | 1472 | 1389 | ||
654 | 1473 | 1390 | ||
655 | 1474 | int ret= 1; | 1391 | int ret= 1; |
656 | 1475 | 1392 | ||
657 | === modified file 'libdrizzle/drizzle.cc' | |||
658 | --- libdrizzle/drizzle.cc 2013-01-05 11:31:45 +0000 | |||
659 | +++ libdrizzle/drizzle.cc 2013-01-05 15:58:23 +0000 | |||
660 | @@ -43,6 +43,8 @@ | |||
661 | 43 | #include "config.h" | 43 | #include "config.h" |
662 | 44 | #include "libdrizzle/common.h" | 44 | #include "libdrizzle/common.h" |
663 | 45 | 45 | ||
664 | 46 | #include <cerrno> | ||
665 | 47 | |||
666 | 46 | /** | 48 | /** |
667 | 47 | * @addtogroup drizzle_static Static Drizzle Declarations | 49 | * @addtogroup drizzle_static Static Drizzle Declarations |
668 | 48 | * @ingroup drizzle | 50 | * @ingroup drizzle |
669 | @@ -242,7 +244,7 @@ | |||
670 | 242 | 244 | ||
671 | 243 | drizzle_result_free_all(con); | 245 | drizzle_result_free_all(con); |
672 | 244 | 246 | ||
674 | 245 | if (con->fd != -1) | 247 | if (con->fd != INVALID_SOCKET) |
675 | 246 | { | 248 | { |
676 | 247 | drizzle_close(con); | 249 | drizzle_close(con); |
677 | 248 | } | 250 | } |
678 | 249 | 251 | ||
679 | === modified file 'libdrizzle/error.cc' | |||
680 | --- libdrizzle/error.cc 2013-01-05 11:25:32 +0000 | |||
681 | +++ libdrizzle/error.cc 2013-01-05 15:58:23 +0000 | |||
682 | @@ -34,7 +34,9 @@ | |||
683 | 34 | * | 34 | * |
684 | 35 | */ | 35 | */ |
685 | 36 | 36 | ||
687 | 37 | #include <libdrizzle/common.h> | 37 | #include "config.h" |
688 | 38 | |||
689 | 39 | #include "libdrizzle/common.h" | ||
690 | 38 | 40 | ||
691 | 39 | const char *drizzle_strerror(const drizzle_return_t arg) | 41 | const char *drizzle_strerror(const drizzle_return_t arg) |
692 | 40 | { | 42 | { |
693 | 41 | 43 | ||
694 | === modified file 'libdrizzle/include.am' | |||
695 | --- libdrizzle/include.am 2012-12-31 07:11:30 +0000 | |||
696 | +++ libdrizzle/include.am 2013-01-05 15:58:23 +0000 | |||
697 | @@ -9,10 +9,12 @@ | |||
698 | 9 | noinst_HEADERS+= libdrizzle/datetime.h | 9 | noinst_HEADERS+= libdrizzle/datetime.h |
699 | 10 | noinst_HEADERS+= libdrizzle/drizzle_local.h | 10 | noinst_HEADERS+= libdrizzle/drizzle_local.h |
700 | 11 | noinst_HEADERS+= libdrizzle/pack.h | 11 | noinst_HEADERS+= libdrizzle/pack.h |
701 | 12 | noinst_HEADERS+= libdrizzle/poll.h | ||
702 | 12 | noinst_HEADERS+= libdrizzle/sha1.h | 13 | noinst_HEADERS+= libdrizzle/sha1.h |
703 | 13 | noinst_HEADERS+= libdrizzle/state.h | 14 | noinst_HEADERS+= libdrizzle/state.h |
704 | 14 | noinst_HEADERS+= libdrizzle/statement_local.h | 15 | noinst_HEADERS+= libdrizzle/statement_local.h |
705 | 15 | noinst_HEADERS+= libdrizzle/structs.h | 16 | noinst_HEADERS+= libdrizzle/structs.h |
706 | 17 | noinst_HEADERS+= libdrizzle/windows.hpp | ||
707 | 16 | 18 | ||
708 | 17 | lib_LTLIBRARIES+= libdrizzle/libdrizzle.la | 19 | lib_LTLIBRARIES+= libdrizzle/libdrizzle.la |
709 | 18 | libdrizzle_libdrizzle_la_SOURCES= | 20 | libdrizzle_libdrizzle_la_SOURCES= |
710 | @@ -23,12 +25,17 @@ | |||
711 | 23 | 25 | ||
712 | 24 | libdrizzle_libdrizzle_la_CFLAGS+= @OPENSSL_INCLUDES@ | 26 | libdrizzle_libdrizzle_la_CFLAGS+= @OPENSSL_INCLUDES@ |
713 | 25 | libdrizzle_libdrizzle_la_CXXFLAGS+= @OPENSSL_INCLUDES@ | 27 | libdrizzle_libdrizzle_la_CXXFLAGS+= @OPENSSL_INCLUDES@ |
714 | 28 | libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@ | ||
715 | 29 | libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@ | ||
716 | 30 | |||
717 | 26 | libdrizzle_libdrizzle_la_CFLAGS+= @ZLIB_CFLAGS@ | 31 | libdrizzle_libdrizzle_la_CFLAGS+= @ZLIB_CFLAGS@ |
718 | 27 | libdrizzle_libdrizzle_la_CXXFLAGS+= @ZLIB_CFLAGS@ | 32 | libdrizzle_libdrizzle_la_CXXFLAGS+= @ZLIB_CFLAGS@ |
720 | 28 | libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@ | 33 | libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@ |
721 | 29 | libdrizzle_libdrizzle_la_LIBADD+= @ZLIB_LIBS@ | 34 | libdrizzle_libdrizzle_la_LIBADD+= @ZLIB_LIBS@ |
724 | 30 | libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@ | 35 | |
725 | 31 | libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@ | 36 | if BUILD_WIN32 |
726 | 37 | libdrizzle_libdrizzle_la_LIBADD+= -lmingw32 -lws2_32 -lgdi32 | ||
727 | 38 | endif | ||
728 | 32 | 39 | ||
729 | 33 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/binlog.cc | 40 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/binlog.cc |
730 | 34 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/command.cc | 41 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/command.cc |
731 | @@ -43,6 +50,7 @@ | |||
732 | 43 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/drizzle.cc | 50 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/drizzle.cc |
733 | 44 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/field.cc | 51 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/field.cc |
734 | 45 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/pack.cc | 52 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/pack.cc |
735 | 53 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/poll.cc | ||
736 | 46 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/result.cc | 54 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/result.cc |
737 | 47 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/sha1.cc | 55 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/sha1.cc |
738 | 48 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/state.cc | 56 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/state.cc |
739 | 49 | 57 | ||
740 | === added file 'libdrizzle/poll.cc' | |||
741 | --- libdrizzle/poll.cc 1970-01-01 00:00:00 +0000 | |||
742 | +++ libdrizzle/poll.cc 2013-01-05 15:58:23 +0000 | |||
743 | @@ -0,0 +1,86 @@ | |||
744 | 1 | /* LibMemcached | ||
745 | 2 | * Copyright (C) 2010 Brian Aker, Trond Norbye | ||
746 | 3 | * All rights reserved. | ||
747 | 4 | * | ||
748 | 5 | * Use and distribution licensed under the BSD license. See | ||
749 | 6 | * the COPYING file in the parent directory for full text. | ||
750 | 7 | * | ||
751 | 8 | * Summary: Implementation of poll by using select | ||
752 | 9 | * | ||
753 | 10 | */ | ||
754 | 11 | |||
755 | 12 | #include "config.h" | ||
756 | 13 | |||
757 | 14 | #include "libdrizzle/common.h" | ||
758 | 15 | |||
759 | 16 | #if defined(WIN32) || defined(__MINGW32__) | ||
760 | 17 | #include "libdrizzle/poll.h" | ||
761 | 18 | |||
762 | 19 | #include <sys/time.h> | ||
763 | 20 | #include <strings.h> | ||
764 | 21 | |||
765 | 22 | int poll(struct pollfd fds[], nfds_t nfds, int tmo) | ||
766 | 23 | { | ||
767 | 24 | fd_set readfds, writefds, errorfds; | ||
768 | 25 | FD_ZERO(&readfds); | ||
769 | 26 | FD_ZERO(&writefds); | ||
770 | 27 | FD_ZERO(&errorfds); | ||
771 | 28 | |||
772 | 29 | int maxfd= 0; | ||
773 | 30 | |||
774 | 31 | for (nfds_t x= 0; x < nfds; ++x) | ||
775 | 32 | { | ||
776 | 33 | if (fds[x].events & (POLLIN | POLLOUT)) | ||
777 | 34 | { | ||
778 | 35 | #ifndef WIN32 | ||
779 | 36 | if (fds[x].fd > maxfd) | ||
780 | 37 | { | ||
781 | 38 | maxfd= fds[x].fd; | ||
782 | 39 | } | ||
783 | 40 | #endif | ||
784 | 41 | if (fds[x].events & POLLIN) | ||
785 | 42 | { | ||
786 | 43 | FD_SET(fds[x].fd, &readfds); | ||
787 | 44 | } | ||
788 | 45 | if (fds[x].events & POLLOUT) | ||
789 | 46 | { | ||
790 | 47 | FD_SET(fds[x].fd, &writefds); | ||
791 | 48 | } | ||
792 | 49 | } | ||
793 | 50 | } | ||
794 | 51 | |||
795 | 52 | struct timeval timeout= { .tv_sec = tmo / 1000, | ||
796 | 53 | .tv_usec= (tmo % 1000) * 1000 }; | ||
797 | 54 | struct timeval *tp= &timeout; | ||
798 | 55 | if (tmo == -1) | ||
799 | 56 | { | ||
800 | 57 | tp= NULL; | ||
801 | 58 | } | ||
802 | 59 | int ret= select(maxfd + 1, &readfds, &writefds, &errorfds, tp); | ||
803 | 60 | if (ret <= 0) | ||
804 | 61 | { | ||
805 | 62 | return ret; | ||
806 | 63 | } | ||
807 | 64 | |||
808 | 65 | /* Iterate through all of them because I need to clear the revent map */ | ||
809 | 66 | for (nfds_t x= 0; x < nfds; ++x) | ||
810 | 67 | { | ||
811 | 68 | fds[x].revents= 0; | ||
812 | 69 | if (FD_ISSET(fds[x].fd, &readfds)) | ||
813 | 70 | { | ||
814 | 71 | fds[x].revents |= POLLIN; | ||
815 | 72 | } | ||
816 | 73 | if (FD_ISSET(fds[x].fd, &writefds)) | ||
817 | 74 | { | ||
818 | 75 | fds[x].revents |= POLLOUT; | ||
819 | 76 | } | ||
820 | 77 | if (FD_ISSET(fds[x].fd, &errorfds)) | ||
821 | 78 | { | ||
822 | 79 | fds[x].revents |= POLLERR; | ||
823 | 80 | } | ||
824 | 81 | } | ||
825 | 82 | |||
826 | 83 | return ret; | ||
827 | 84 | } | ||
828 | 85 | |||
829 | 86 | #endif // defined(WIN32) || defined(__MINGW32__) | ||
830 | 0 | 87 | ||
831 | === added file 'libdrizzle/poll.h' | |||
832 | --- libdrizzle/poll.h 1970-01-01 00:00:00 +0000 | |||
833 | +++ libdrizzle/poll.h 2013-01-05 15:58:23 +0000 | |||
834 | @@ -0,0 +1,47 @@ | |||
835 | 1 | /* LibMemcached | ||
836 | 2 | * Copyright (C) 2010 Brian Aker, Trond Norbye | ||
837 | 3 | * All rights reserved. | ||
838 | 4 | * | ||
839 | 5 | * Use and distribution licensed under the BSD license. See | ||
840 | 6 | * the COPYING file in the parent directory for full text. | ||
841 | 7 | * | ||
842 | 8 | * Summary: Implementation of poll by using select | ||
843 | 9 | * | ||
844 | 10 | */ | ||
845 | 11 | |||
846 | 12 | #pragma once | ||
847 | 13 | |||
848 | 14 | #if defined(WIN32) || defined(__MINGW32__) | ||
849 | 15 | |||
850 | 16 | #include <winsock2.h> | ||
851 | 17 | |||
852 | 18 | #ifdef __cplusplus | ||
853 | 19 | extern "C" { | ||
854 | 20 | #endif | ||
855 | 21 | |||
856 | 22 | typedef struct pollfd | ||
857 | 23 | { | ||
858 | 24 | #ifdef WIN32 | ||
859 | 25 | SOCKET fd; | ||
860 | 26 | #else | ||
861 | 27 | int fd; | ||
862 | 28 | #endif | ||
863 | 29 | short events; | ||
864 | 30 | short revents; | ||
865 | 31 | } pollfd_t; | ||
866 | 32 | |||
867 | 33 | typedef int nfds_t; | ||
868 | 34 | |||
869 | 35 | #define POLLIN 0x0001 | ||
870 | 36 | #define POLLOUT 0x0004 | ||
871 | 37 | #define POLLERR 0x0008 | ||
872 | 38 | #define POLLHUP 0x010 /* Hung up. */ | ||
873 | 39 | #define POLLNVAL 0x020 /* Invalid polling request. */ | ||
874 | 40 | |||
875 | 41 | int poll(struct pollfd fds[], nfds_t nfds, int tmo); | ||
876 | 42 | |||
877 | 43 | #ifdef __cplusplus | ||
878 | 44 | } | ||
879 | 45 | #endif | ||
880 | 46 | |||
881 | 47 | #endif // defined(WIN32) || defined(__MINGW32__) | ||
882 | 0 | 48 | ||
883 | === modified file 'libdrizzle/query.cc' | |||
884 | --- libdrizzle/query.cc 2013-01-05 10:27:32 +0000 | |||
885 | +++ libdrizzle/query.cc 2013-01-05 15:58:23 +0000 | |||
886 | @@ -40,6 +40,8 @@ | |||
887 | 40 | * @brief Query definitions | 40 | * @brief Query definitions |
888 | 41 | */ | 41 | */ |
889 | 42 | 42 | ||
890 | 43 | #include "config.h" | ||
891 | 44 | |||
892 | 43 | #include <libdrizzle/common.h> | 45 | #include <libdrizzle/common.h> |
893 | 44 | 46 | ||
894 | 45 | drizzle_result_st *drizzle_query(drizzle_st *con, | 47 | drizzle_result_st *drizzle_query(drizzle_st *con, |
895 | 46 | 48 | ||
896 | === modified file 'libdrizzle/ssl.cc' | |||
897 | --- libdrizzle/ssl.cc 2012-12-24 10:20:04 +0000 | |||
898 | +++ libdrizzle/ssl.cc 2013-01-05 15:58:23 +0000 | |||
899 | @@ -36,10 +36,13 @@ | |||
900 | 36 | */ | 36 | */ |
901 | 37 | 37 | ||
902 | 38 | #include "config.h" | 38 | #include "config.h" |
903 | 39 | |||
904 | 39 | #include "libdrizzle/common.h" | 40 | #include "libdrizzle/common.h" |
905 | 40 | 41 | ||
906 | 41 | #include <libdrizzle-5.1/ssl.h> | 42 | #include <libdrizzle-5.1/ssl.h> |
908 | 42 | #include <openssl/ssl.h> | 43 | |
909 | 44 | #if defined(USE_OPENSSL) | ||
910 | 45 | # include <openssl/ssl.h> | ||
911 | 43 | 46 | ||
912 | 44 | drizzle_return_t drizzle_set_ssl(drizzle_st *con, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher) | 47 | drizzle_return_t drizzle_set_ssl(drizzle_st *con, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher) |
913 | 45 | { | 48 | { |
914 | @@ -85,3 +88,12 @@ | |||
915 | 85 | 88 | ||
916 | 86 | return DRIZZLE_RETURN_OK; | 89 | return DRIZZLE_RETURN_OK; |
917 | 87 | } | 90 | } |
918 | 91 | |||
919 | 92 | #else | ||
920 | 93 | |||
921 | 94 | drizzle_return_t drizzle_set_ssl(drizzle_st*, const char*, const char*, const char*, const char*, const char*) | ||
922 | 95 | { | ||
923 | 96 | return DRIZZLE_RETURN_INVALID_ARGUMENT; | ||
924 | 97 | } | ||
925 | 98 | |||
926 | 99 | #endif | ||
927 | 88 | 100 | ||
928 | === modified file 'libdrizzle/statement_local.h' | |||
929 | --- libdrizzle/statement_local.h 2013-01-05 11:25:32 +0000 | |||
930 | +++ libdrizzle/statement_local.h 2013-01-05 15:58:23 +0000 | |||
931 | @@ -41,25 +41,18 @@ | |||
932 | 41 | extern "C" { | 41 | extern "C" { |
933 | 42 | #endif | 42 | #endif |
934 | 43 | 43 | ||
935 | 44 | DRIZZLE_LOCAL | ||
936 | 45 | drizzle_return_t drizzle_stmt_set_param(drizzle_stmt_st *stmt, uint16_t param_num, drizzle_column_type_t type, void *data, uint32_t length, bool is_unsigned, bool is_allocated); | 44 | drizzle_return_t drizzle_stmt_set_param(drizzle_stmt_st *stmt, uint16_t param_num, drizzle_column_type_t type, void *data, uint32_t length, bool is_unsigned, bool is_allocated); |
937 | 46 | 45 | ||
938 | 47 | DRIZZLE_LOCAL | ||
939 | 48 | char *long_to_string(drizzle_bind_st *param, uint32_t val); | 46 | char *long_to_string(drizzle_bind_st *param, uint32_t val); |
940 | 49 | 47 | ||
941 | 50 | DRIZZLE_LOCAL | ||
942 | 51 | char *longlong_to_string(drizzle_bind_st *param, uint64_t val); | 48 | char *longlong_to_string(drizzle_bind_st *param, uint64_t val); |
943 | 52 | 49 | ||
944 | 53 | DRIZZLE_LOCAL | ||
945 | 54 | char *double_to_string(drizzle_bind_st *param, double val); | 50 | char *double_to_string(drizzle_bind_st *param, double val); |
946 | 55 | 51 | ||
947 | 56 | DRIZZLE_LOCAL | ||
948 | 57 | char *time_to_string(drizzle_bind_st *param, drizzle_datetime_st *time); | 52 | char *time_to_string(drizzle_bind_st *param, drizzle_datetime_st *time); |
949 | 58 | 53 | ||
950 | 59 | DRIZZLE_LOCAL | ||
951 | 60 | char *timestamp_to_string(drizzle_bind_st *param, drizzle_datetime_st *timestamp); | 54 | char *timestamp_to_string(drizzle_bind_st *param, drizzle_datetime_st *timestamp); |
952 | 61 | 55 | ||
953 | 62 | DRIZZLE_LOCAL | ||
954 | 63 | uint16_t drizzle_stmt_column_lookup(drizzle_result_st *result, const char *column_name, drizzle_return_t *ret_ptr); | 56 | uint16_t drizzle_stmt_column_lookup(drizzle_result_st *result, const char *column_name, drizzle_return_t *ret_ptr); |
955 | 64 | 57 | ||
956 | 65 | #ifdef __cplusplus | 58 | #ifdef __cplusplus |
957 | 66 | 59 | ||
958 | === modified file 'libdrizzle/structs.h' | |||
959 | --- libdrizzle/structs.h 2013-01-05 10:27:32 +0000 | |||
960 | +++ libdrizzle/structs.h 2013-01-05 15:58:23 +0000 | |||
961 | @@ -43,9 +43,11 @@ | |||
962 | 43 | #pragma once | 43 | #pragma once |
963 | 44 | 44 | ||
964 | 45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
967 | 46 | #ifdef USE_OPENSSL | 46 | |
968 | 47 | #include <openssl/ssl.h> | 47 | #if defined(HAVE_OPENSSL_SSL_H) |
969 | 48 | # include <openssl/ssl.h> | ||
970 | 48 | #endif | 49 | #endif |
971 | 50 | |||
972 | 49 | #ifdef NI_MAXHOST | 51 | #ifdef NI_MAXHOST |
973 | 50 | # define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST | 52 | # define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST |
974 | 51 | #else | 53 | #else |
975 | @@ -53,7 +55,7 @@ | |||
976 | 53 | #endif | 55 | #endif |
977 | 54 | 56 | ||
978 | 55 | #ifdef __cplusplus | 57 | #ifdef __cplusplus |
980 | 56 | #include <cstddef> | 58 | # include <cstddef> |
981 | 57 | #endif | 59 | #endif |
982 | 58 | 60 | ||
983 | 59 | #ifdef __cplusplus | 61 | #ifdef __cplusplus |
984 | @@ -62,6 +64,12 @@ | |||
985 | 62 | 64 | ||
986 | 63 | #include "libdrizzle/datetime.h" | 65 | #include "libdrizzle/datetime.h" |
987 | 64 | 66 | ||
988 | 67 | #if defined _WIN32 || defined __CYGWIN__ | ||
989 | 68 | typedef SOCKET socket_t; | ||
990 | 69 | #else | ||
991 | 70 | typedef int socket_t; | ||
992 | 71 | #endif | ||
993 | 72 | |||
994 | 65 | /** | 73 | /** |
995 | 66 | * @ingroup drizzle_command | 74 | * @ingroup drizzle_command |
996 | 67 | * Commands for drizzle_command functions. | 75 | * Commands for drizzle_command functions. |
997 | @@ -159,7 +167,7 @@ | |||
998 | 159 | uint32_t result_count; | 167 | uint32_t result_count; |
999 | 160 | uint32_t thread_id; | 168 | uint32_t thread_id; |
1000 | 161 | int backlog; | 169 | int backlog; |
1002 | 162 | int fd; | 170 | socket_t fd; |
1003 | 163 | size_t buffer_size; | 171 | size_t buffer_size; |
1004 | 164 | size_t command_offset; | 172 | size_t command_offset; |
1005 | 165 | size_t command_size; | 173 | size_t command_size; |
1006 | @@ -201,7 +209,7 @@ | |||
1007 | 201 | int timeout; | 209 | int timeout; |
1008 | 202 | drizzle_log_fn *log_fn; | 210 | drizzle_log_fn *log_fn; |
1009 | 203 | void *log_context; | 211 | void *log_context; |
1011 | 204 | struct pollfd pfds[1]; | 212 | pollfd_t pfds[1]; |
1012 | 205 | char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1]; | 213 | char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1]; |
1013 | 206 | char last_error[DRIZZLE_MAX_ERROR_SIZE]; | 214 | char last_error[DRIZZLE_MAX_ERROR_SIZE]; |
1014 | 207 | drizzle_stmt_st *stmt; | 215 | drizzle_stmt_st *stmt; |
1015 | 208 | 216 | ||
1016 | === added file 'libdrizzle/windows.hpp' | |||
1017 | --- libdrizzle/windows.hpp 1970-01-01 00:00:00 +0000 | |||
1018 | +++ libdrizzle/windows.hpp 2013-01-05 15:58:23 +0000 | |||
1019 | @@ -0,0 +1,123 @@ | |||
1020 | 1 | /* | ||
1021 | 2 | * Drizzle Client & Protocol Library | ||
1022 | 3 | * | ||
1023 | 4 | * Copyright (C) 2012 Drizzle Developers (http://drizzle.org) | ||
1024 | 5 | * All rights reserved. | ||
1025 | 6 | * | ||
1026 | 7 | * Redistribution and use in source and binary forms, with or without | ||
1027 | 8 | * modification, are permitted provided that the following conditions are | ||
1028 | 9 | * met: | ||
1029 | 10 | * | ||
1030 | 11 | * * Redistributions of source code must retain the above copyright | ||
1031 | 12 | * notice, this list of conditions and the following disclaimer. | ||
1032 | 13 | * | ||
1033 | 14 | * * Redistributions in binary form must reproduce the above | ||
1034 | 15 | * copyright notice, this list of conditions and the following disclaimer | ||
1035 | 16 | * in the documentation and/or other materials provided with the | ||
1036 | 17 | * distribution. | ||
1037 | 18 | * | ||
1038 | 19 | * * The names of its contributors may not be used to endorse or | ||
1039 | 20 | * promote products derived from this software without specific prior | ||
1040 | 21 | * written permission. | ||
1041 | 22 | * | ||
1042 | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
1043 | 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
1044 | 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
1045 | 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
1046 | 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
1047 | 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
1048 | 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
1049 | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
1050 | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1051 | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
1052 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
1053 | 34 | * | ||
1054 | 35 | */ | ||
1055 | 36 | |||
1056 | 37 | #pragma once | ||
1057 | 38 | |||
1058 | 39 | #ifdef __cplusplus | ||
1059 | 40 | # include <cerrno> | ||
1060 | 41 | #else | ||
1061 | 42 | # include <errno.h> | ||
1062 | 43 | #endif | ||
1063 | 44 | |||
1064 | 45 | #ifndef WIN32_LEAN_AND_MEAN | ||
1065 | 46 | # define WIN32_LEAN_AND_MEAN | ||
1066 | 47 | #endif | ||
1067 | 48 | |||
1068 | 49 | #ifndef _WIN32_WINNT | ||
1069 | 50 | # define _WIN32_WINNT 0x0501 | ||
1070 | 51 | #endif | ||
1071 | 52 | |||
1072 | 53 | #ifdef __MINGW32__ | ||
1073 | 54 | # if(_WIN32_WINNT >= 0x0501) | ||
1074 | 55 | # else | ||
1075 | 56 | # undef _WIN32_WINNT | ||
1076 | 57 | # define _WIN32_WINNT 0x0501 | ||
1077 | 58 | # endif /* _WIN32_WINNT >= 0x0501 */ | ||
1078 | 59 | #endif /* __MINGW32__ */ | ||
1079 | 60 | |||
1080 | 61 | #if defined(HAVE_WINSOCK2_H) && HAVE_WINSOCK2_H | ||
1081 | 62 | # include <winsock2.h> | ||
1082 | 63 | #endif | ||
1083 | 64 | |||
1084 | 65 | #if defined(HAVE_WS2TCPIP_H) && HAVE_WS2TCPIP_H | ||
1085 | 66 | # include <ws2tcpip.h> | ||
1086 | 67 | #endif | ||
1087 | 68 | |||
1088 | 69 | #if defined(HAVE_IO_H) && HAVE_IO_H | ||
1089 | 70 | # include <io.h> | ||
1090 | 71 | #endif | ||
1091 | 72 | |||
1092 | 73 | struct sockaddr_un | ||
1093 | 74 | { | ||
1094 | 75 | short int sun_family; | ||
1095 | 76 | char sun_path[108]; | ||
1096 | 77 | }; | ||
1097 | 78 | |||
1098 | 79 | static inline int translate_windows_error() | ||
1099 | 80 | { | ||
1100 | 81 | int local_errno= WSAGetLastError(); | ||
1101 | 82 | |||
1102 | 83 | switch(local_errno) { | ||
1103 | 84 | case WSAEINVAL: | ||
1104 | 85 | case WSAEALREADY: | ||
1105 | 86 | case WSAEWOULDBLOCK: | ||
1106 | 87 | local_errno= EINPROGRESS; | ||
1107 | 88 | break; | ||
1108 | 89 | |||
1109 | 90 | case WSAECONNREFUSED: | ||
1110 | 91 | local_errno= ECONNREFUSED; | ||
1111 | 92 | break; | ||
1112 | 93 | |||
1113 | 94 | case WSAENETUNREACH: | ||
1114 | 95 | local_errno= ENETUNREACH; | ||
1115 | 96 | break; | ||
1116 | 97 | |||
1117 | 98 | case WSAETIMEDOUT: | ||
1118 | 99 | local_errno= ETIMEDOUT; | ||
1119 | 100 | break; | ||
1120 | 101 | |||
1121 | 102 | case WSAECONNRESET: | ||
1122 | 103 | local_errno= ECONNRESET; | ||
1123 | 104 | break; | ||
1124 | 105 | |||
1125 | 106 | case WSAEADDRINUSE: | ||
1126 | 107 | local_errno= EADDRINUSE; | ||
1127 | 108 | break; | ||
1128 | 109 | |||
1129 | 110 | case WSAEOPNOTSUPP: | ||
1130 | 111 | local_errno= EOPNOTSUPP; | ||
1131 | 112 | break; | ||
1132 | 113 | |||
1133 | 114 | case WSAENOPROTOOPT: | ||
1134 | 115 | local_errno= ENOPROTOOPT; | ||
1135 | 116 | break; | ||
1136 | 117 | |||
1137 | 118 | default: | ||
1138 | 119 | break; | ||
1139 | 120 | } | ||
1140 | 121 | |||
1141 | 122 | return local_errno; | ||
1142 | 123 | } | ||
1143 | 0 | 124 | ||
1144 | === modified file 'm4/ax_platform.m4' | |||
1145 | --- m4/ax_platform.m4 2012-12-17 11:57:49 +0000 | |||
1146 | +++ m4/ax_platform.m4 2013-01-05 15:58:23 +0000 | |||
1147 | @@ -19,7 +19,8 @@ | |||
1148 | 19 | # and this notice are preserved. This file is offered as-is, without any | 19 | # and this notice are preserved. This file is offered as-is, without any |
1149 | 20 | # warranty. | 20 | # warranty. |
1150 | 21 | 21 | ||
1152 | 22 | #serial 1 | 22 | #serial 3 |
1153 | 23 | # | ||
1154 | 23 | AC_DEFUN([AX_PLATFORM], | 24 | AC_DEFUN([AX_PLATFORM], |
1155 | 24 | [AC_REQUIRE([AC_CANONICAL_HOST]) | 25 | [AC_REQUIRE([AC_CANONICAL_HOST]) |
1156 | 25 | AC_REQUIRE([AC_CANONICAL_TARGET]) | 26 | AC_REQUIRE([AC_CANONICAL_TARGET]) |
1157 | @@ -34,9 +35,8 @@ | |||
1158 | 34 | 35 | ||
1159 | 35 | AS_CASE([$target_os], | 36 | AS_CASE([$target_os], |
1160 | 36 | [*mingw32*], | 37 | [*mingw32*], |
1164 | 37 | [AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows]) | 38 | [TARGET_WINDOWS="true" |
1165 | 38 | AC_DEFINE([WINVER], [WindowsXP], [Version of Windows]) | 39 | AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows]) |
1163 | 39 | AC_DEFINE([_WIN32_WINNT], [0x0501], [Magical number to make things work]) | ||
1166 | 40 | AC_DEFINE([EAI_SYSTEM], [11], [Another magical number]) | 40 | AC_DEFINE([EAI_SYSTEM], [11], [Another magical number]) |
1167 | 41 | AH_BOTTOM([ | 41 | AH_BOTTOM([ |
1168 | 42 | #ifndef HAVE_SYS_SOCKET_H | 42 | #ifndef HAVE_SYS_SOCKET_H |
1169 | @@ -48,8 +48,12 @@ | |||
1170 | 48 | [*freebsd*],[AC_DEFINE([TARGET_OS_FREEBSD],[1],[Whether we are building for FreeBSD]) | 48 | [*freebsd*],[AC_DEFINE([TARGET_OS_FREEBSD],[1],[Whether we are building for FreeBSD]) |
1171 | 49 | AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])], | 49 | AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])], |
1172 | 50 | [*solaris*],[AC_DEFINE([TARGET_OS_SOLARIS],[1],[Whether we are building for Solaris])], | 50 | [*solaris*],[AC_DEFINE([TARGET_OS_SOLARIS],[1],[Whether we are building for Solaris])], |
1175 | 51 | [*darwin*],[AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])], | 51 | [*darwin*], |
1176 | 52 | [*linux*],[AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])]) | 52 | [TARGET_OSX="true" |
1177 | 53 | AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])], | ||
1178 | 54 | [*linux*], | ||
1179 | 55 | [TARGET_LINUX="true" | ||
1180 | 56 | AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])]) | ||
1181 | 53 | 57 | ||
1182 | 54 | AM_CONDITIONAL([BUILD_WIN32],[test "x${TARGET_WINDOWS}" = "xtrue"]) | 58 | AM_CONDITIONAL([BUILD_WIN32],[test "x${TARGET_WINDOWS}" = "xtrue"]) |
1183 | 55 | AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OSX}" = "xtrue"]) | 59 | AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OSX}" = "xtrue"]) |
1184 | 56 | 60 | ||
1185 | === modified file 'm4/bottom.m4' | |||
1186 | --- m4/bottom.m4 2012-12-17 21:04:59 +0000 | |||
1187 | +++ m4/bottom.m4 2013-01-05 15:58:23 +0000 | |||
1188 | @@ -3,6 +3,11 @@ | |||
1189 | 3 | AH_TOP([ | 3 | AH_TOP([ |
1190 | 4 | #pragma once | 4 | #pragma once |
1191 | 5 | 5 | ||
1192 | 6 | /* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */ | ||
1193 | 7 | #if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H) | ||
1194 | 8 | # error "You should include config.h as your first include file" | ||
1195 | 9 | #endif | ||
1196 | 10 | |||
1197 | 6 | ]) | 11 | ]) |
1198 | 7 | 12 | ||
1199 | 8 | AH_BOTTOM([ | 13 | AH_BOTTOM([ |
1200 | @@ -23,30 +28,8 @@ | |||
1201 | 23 | typedef unsigned long int ulong; | 28 | typedef unsigned long int ulong; |
1202 | 24 | #endif | 29 | #endif |
1203 | 25 | 30 | ||
1204 | 26 | /* To hide the platform differences between MS Windows and Unix, I am | ||
1205 | 27 | * going to use the Microsoft way and #define the Microsoft-specific | ||
1206 | 28 | * functions to the unix way. Microsoft use a separate subsystem for sockets, | ||
1207 | 29 | * but Unix normally just use a filedescriptor on the same functions. It is | ||
1208 | 30 | * a lot easier to map back to the unix way with macros than going the other | ||
1209 | 31 | * way without side effect. | ||
1210 | 32 | */ | ||
1211 | 33 | #ifdef TARGET_OS_WINDOWS | ||
1212 | 34 | #define random() rand() | ||
1213 | 35 | #define srandom(a) srand(a) | ||
1214 | 36 | #define get_socket_errno() WSAGetLastError() | ||
1215 | 37 | #else | ||
1216 | 38 | #define INVALID_SOCKET -1 | ||
1217 | 39 | #define SOCKET_ERROR -1 | ||
1218 | 40 | #define closesocket(a) close(a) | ||
1219 | 41 | #define get_socket_errno() errno | ||
1220 | 42 | #endif // TARGET_OS_WINDOWS | ||
1221 | 43 | |||
1222 | 44 | #ifndef HAVE_MSG_NOSIGNAL | ||
1223 | 45 | #define MSG_NOSIGNAL 0 | ||
1224 | 46 | #endif // HAVE_MSG_NOSIGNAL | ||
1225 | 47 | |||
1226 | 48 | #ifndef HAVE_MSG_DONTWAIT | 31 | #ifndef HAVE_MSG_DONTWAIT |
1228 | 49 | #define MSG_DONTWAIT 0 | 32 | # define MSG_DONTWAIT 0 |
1229 | 50 | #endif // HAVE_MSG_DONTWAIT | 33 | #endif // HAVE_MSG_DONTWAIT |
1230 | 51 | 34 | ||
1231 | 52 | ]) | 35 | ]) |
1232 | 53 | 36 | ||
1233 | === modified file 'm4/socket_send_flags.m4' | |||
1234 | --- m4/socket_send_flags.m4 2012-12-17 11:57:49 +0000 | |||
1235 | +++ m4/socket_send_flags.m4 2013-01-05 15:58:23 +0000 | |||
1236 | @@ -1,48 +1,47 @@ | |||
1285 | 1 | dnl Copyright (C) 2012 Data Differential LLC | 1 | # Copyright (C) 2012-2013 Data Differential LLC |
1286 | 2 | dnl Copyright (C) 2011 Trond Norbye | 2 | # Copyright (C) 2011 Trond Norbye |
1287 | 3 | dnl This file is free software; Trond Norbye | 3 | # This file is free software; Trond Norbye and Data Differential |
1288 | 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | # gives unlimited permission to copy and/or distribute it, |
1289 | 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | # with or without modifications, as long as this notice is preserved. |
1290 | 6 | dnl --------------------------------------------------------------------------- | 6 | # --------------------------------------------------------------------------- |
1291 | 7 | dnl Macro: SOCKET_SEND_FLAGS | 7 | # Macro: SOCKET_SEND_FLAGS |
1292 | 8 | dnl --------------------------------------------------------------------------- | 8 | # --------------------------------------------------------------------------- |
1293 | 9 | 9 | # | |
1294 | 10 | AC_DEFUN([SOCKET_SEND_FLAGS],[ | 10 | |
1295 | 11 | AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [ | 11 | #serial 2 |
1296 | 12 | AC_LANG_PUSH([C]) | 12 | |
1297 | 13 | AX_SAVE_FLAGS | 13 | AC_DEFUN([SOCKET_SEND_FLAGS], |
1298 | 14 | CFLAGS="$CFLAGS -I${srcdir}" | 14 | [AC_CACHE_CHECK([for MSG_NOSIGNAL],[ac_cv_msg_nosignal], |
1299 | 15 | 15 | [AC_LANG_PUSH([C]) | |
1300 | 16 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_NOSIGNAL ])], [ac_cv_msg_nosignal="yes"]) | 16 | AX_SAVE_FLAGS |
1301 | 17 | AC_LANG_POP | 17 | CFLAGS="$CFLAGS -I${srcdir}" |
1302 | 18 | AX_RESTORE_FLAGS | 18 | |
1303 | 19 | ]) | 19 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [int flags= MSG_NOSIGNAL])], [ac_cv_msg_nosignal="yes"]) |
1304 | 20 | 20 | AC_LANG_POP | |
1305 | 21 | AC_CACHE_CHECK([for MSG_DONTWAIT], [ac_cv_msg_dontwait], [ | 21 | AX_RESTORE_FLAGS]) |
1306 | 22 | AC_LANG_PUSH([C]) | 22 | |
1307 | 23 | AX_SAVE_FLAGS | 23 | AC_CACHE_CHECK([for MSG_DONTWAIT],[ac_cv_msg_dontwait], |
1308 | 24 | CFLAGS="$CFLAGS -I${srcdir}" | 24 | [AC_LANG_PUSH([C]) |
1309 | 25 | 25 | AX_SAVE_FLAGS | |
1310 | 26 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_DONTWAIT ])], [ac_cv_msg_dontwait="yes"]) | 26 | CFLAGS="$CFLAGS -I${srcdir}" |
1311 | 27 | AC_LANG_POP | 27 | |
1312 | 28 | AX_RESTORE_FLAGS | 28 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],[int flags= MSG_DONTWAIT])],[ac_cv_msg_dontwait="yes"]) |
1313 | 29 | ]) | 29 | AC_LANG_POP |
1314 | 30 | 30 | AX_RESTORE_FLAGS]) | |
1315 | 31 | AC_CACHE_CHECK([for MSG_MORE], [ac_cv_msg_more], [ | 31 | |
1316 | 32 | AC_LANG_PUSH([C]) | 32 | AC_CACHE_CHECK([for MSG_MORE],[ac_cv_msg_more], |
1317 | 33 | AX_SAVE_FLAGS | 33 | [AC_LANG_PUSH([C]) |
1318 | 34 | CFLAGS="$CFLAGS -I${srcdir}" | 34 | AX_SAVE_FLAGS |
1319 | 35 | 35 | CFLAGS="$CFLAGS -I${srcdir}" | |
1320 | 36 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_MORE ])], [ac_cv_msg_more="yes"]) | 36 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [int flags= MSG_MORE])], [ac_cv_msg_more="yes"]) |
1321 | 37 | AC_LANG_POP | 37 | AC_LANG_POP |
1322 | 38 | AX_RESTORE_FLAGS | 38 | AX_RESTORE_FLAGS]) |
1323 | 39 | ]) | 39 | |
1324 | 40 | 40 | AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[AC_DEFINE([HAVE_MSG_NOSIGNAL],[1],[Define to 1 if you have a MSG_NOSIGNAL])]) | |
1325 | 41 | AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[ AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])]) | 41 | AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[AC_DEFINE([HAVE_MSG_DONTWAIT],[1],[Define to 1 if you have a MSG_DONTWAIT])]) |
1326 | 42 | AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[ AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])]) | 42 | AS_IF([test "x$ac_cv_msg_more" = "xyes"],[AC_DEFINE([HAVE_MSG_MORE],[1],[Define to 1 if you have a MSG_MORE])]) |
1327 | 43 | AS_IF([test "x$ac_cv_msg_more" = "xyes"],[ AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a MSG_MORE])]) | 43 | ]) |
1328 | 44 | ]) | 44 | |
1329 | 45 | 45 | # --------------------------------------------------------------------------- | |
1330 | 46 | dnl --------------------------------------------------------------------------- | 46 | # End Macro: SOCKET_SEND_FLAGS |
1331 | 47 | dnl End Macro: SOCKET_SEND_FLAGS | 47 | # --------------------------------------------------------------------------- |
1284 | 48 | dnl --------------------------------------------------------------------------- | ||
1332 | 49 | 48 | ||
1333 | === modified file 'tests/unit/binlog.c' | |||
1334 | --- tests/unit/binlog.c 2012-12-31 00:06:53 +0000 | |||
1335 | +++ tests/unit/binlog.c 2013-01-05 15:58:23 +0000 | |||
1336 | @@ -38,7 +38,6 @@ | |||
1337 | 38 | #include <yatl/lite.h> | 38 | #include <yatl/lite.h> |
1338 | 39 | 39 | ||
1339 | 40 | #include <libdrizzle-5.1/libdrizzle.h> | 40 | #include <libdrizzle-5.1/libdrizzle.h> |
1340 | 41 | #include "libdrizzle/structs.h" | ||
1341 | 42 | #include <stdio.h> | 41 | #include <stdio.h> |
1342 | 43 | #include <stdlib.h> | 42 | #include <stdlib.h> |
1343 | 44 | #include <stdint.h> | 43 | #include <stdint.h> |
1344 | 45 | 44 | ||
1345 | === modified file 'tests/unit/row.c' | |||
1346 | --- tests/unit/row.c 2013-01-05 11:41:26 +0000 | |||
1347 | +++ tests/unit/row.c 2013-01-05 15:58:23 +0000 | |||
1348 | @@ -143,11 +143,7 @@ | |||
1349 | 143 | return EXIT_FAILURE; | 143 | return EXIT_FAILURE; |
1350 | 144 | } | 144 | } |
1351 | 145 | size_t *sizes= drizzle_row_field_sizes(result); | 145 | size_t *sizes= drizzle_row_field_sizes(result); |
1357 | 146 | if (sizes[0] != 1) | 146 | ASSERT_EQ(sizes[0], 1); |
1353 | 147 | { | ||
1354 | 148 | printf("Row size mismatch (4 != %lu)\n", sizes[0]); | ||
1355 | 149 | return EXIT_FAILURE; | ||
1356 | 150 | } | ||
1358 | 151 | 147 | ||
1359 | 152 | drizzle_result_free(result); | 148 | drizzle_result_free(result); |
1360 | 153 | 149 |
Incredible patch. I like you fixed poll for Windows :)