Merge lp:~brianaker/libdrizzle/windows-support-via-mingw into lp:libdrizzle

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
Reviewer Review Type Date Requested Status
Andrew Hutchings Approve
Review via email: mp+142013@code.launchpad.net

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.

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Incredible patch. I like you fixed poll for Windows :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cli/drizzle_binlogs.c'
--- cli/drizzle_binlogs.c 2013-01-05 10:27:32 +0000
+++ cli/drizzle_binlogs.c 2013-01-05 15:58:23 +0000
@@ -34,16 +34,26 @@
34 *34 *
35 */35 */
3636
37#define _GNU_SOURCE 137#include "config.h"
38
38#include <libdrizzle-5.1/libdrizzle.h>39#include <libdrizzle-5.1/libdrizzle.h>
39#include <stdlib.h>40#include <stdlib.h>
40#include <sys/types.h>41#include <sys/types.h>
41#include <pwd.h>42
43#ifdef HAVE_PWD_H
44# include <pwd.h>
45#endif
46
42#include <unistd.h>47#include <unistd.h>
43#include <errno.h>48#include <errno.h>
44#include <argp.h>
45#include <time.h>49#include <time.h>
4650
51#ifdef HAVE_ARGP_H
52# include <argp.h>
53#else
54# error "drizzle_binlogs requires <argp.h>"
55#endif
56
47#define STR_HELPER(x) #x57#define STR_HELPER(x) #x
48#define STR(x) STR_HELPER(x)58#define STR(x) STR_HELPER(x)
4959
5060
=== modified file 'cli/include.am'
--- cli/include.am 2012-12-28 21:23:12 +0000
+++ cli/include.am 2013-01-05 15:58:23 +0000
@@ -2,10 +2,12 @@
2# included from Top Level Makefile.am2# included from Top Level Makefile.am
3# All paths should be given relative to the root3# All paths should be given relative to the root
44
5if BUILD_WIN32
6else
5bin_PROGRAMS+= cli/drizzle_binlogs7bin_PROGRAMS+= cli/drizzle_binlogs
6cli_drizzle_binlogs_SOURCES= cli/drizzle_binlogs.c8cli_drizzle_binlogs_SOURCES= cli/drizzle_binlogs.c
7cli_drizzle_binlogs_LDADD= libdrizzle/libdrizzle.la9cli_drizzle_binlogs_LDADD= libdrizzle/libdrizzle.la
810
9check_SCRIPTS+= cli/drizzle_binlogs_check.sh11check_SCRIPTS+= cli/drizzle_binlogs_check.sh
10EXTRA_DIST+= ${check_SCRIPTS}12EXTRA_DIST+= ${check_SCRIPTS}
1113endif
1214
=== modified file 'configure.ac'
--- configure.ac 2013-01-04 20:47:22 +0000
+++ configure.ac 2013-01-05 15:58:23 +0000
@@ -57,23 +57,37 @@
5757
58# Checks for libraries.58# Checks for libraries.
59AX_CXX_GCC_ABI_DEMANGLE59AX_CXX_GCC_ABI_DEMANGLE
60AX_CHECK_OPENSSL60
61AS_IF([test "x${target_os}" != "xmingw32"], [AX_CHECK_OPENSSL])
62
61AC_PATH_ZLIB63AC_PATH_ZLIB
6264
63# Checks for header files.65# Checks for header files.
64AC_DEFUN([CHECK_FOR_CXXABI],66AC_DEFUN([CHECK_FOR_CXXABI],
65 [AC_LANG_PUSH([C++])67 [AC_LANG_PUSH([C++])
66 AC_CHECK_HEADERS([cxxabi.h])68 AC_CHECK_HEADERS([cxxabi.h])
67 AC_LANG_POP69 AC_LANG_POP])
68 ])70
69CHECK_FOR_CXXABI71CHECK_FOR_CXXABI
70AC_CHECK_HEADERS_ONCE([errno.h])72AC_CHECK_HEADERS([argp.h])
71AC_CHECK_HEADERS_ONCE([sys/socket.h])73AC_CHECK_HEADERS([errno.h])
72AC_CHECK_HEADERS_ONCE([poll.h])74AC_CHECK_HEADERS([fcntl.h])
75AC_CHECK_HEADERS([io.h])
76AC_CHECK_HEADERS([openssl/ssl.h])
77AC_CHECK_HEADERS([poll.h])
78AC_CHECK_HEADERS([pwd.h])
79AC_CHECK_HEADERS([sys/socket.h])
80AC_CHECK_HEADERS([windows.h])
81AC_CHECK_HEADERS([winsock2.h])
82AC_CHECK_HEADERS([ws2tcpip.h])
7383
74# Checks for typedefs, structures, and compiler characteristics.84# Checks for typedefs, structures, and compiler characteristics.
85AC_CHECK_TYPES([in_port_t])
86AC_TYPE_SSIZE_T
87AC_TYPE_SIZE_T
7588
76# Checks for library functions.89# Checks for library functions.
90AC_CHECK_FUNCS([fcntl])
77AC_CHECK_FUNCS([poll])91AC_CHECK_FUNCS([poll])
78AC_CHECK_FUNCS([ppoll])92AC_CHECK_FUNCS([ppoll])
7993
8094
=== modified file 'libdrizzle-5.1/drizzle.h'
--- libdrizzle-5.1/drizzle.h 2012-12-30 11:18:18 +0000
+++ libdrizzle-5.1/drizzle.h 2013-01-05 15:58:23 +0000
@@ -36,63 +36,27 @@
3636
37#pragma once37#pragma once
3838
39#ifndef DRIZZLE_CLIENT_INTERFACE
40# error "You need to include libdrizzle-5.1/drizzle_client.h in your application"
41#endif
42
39/**43/**
40 * @file44 * @file
41 * @brief Drizzle Declarations45 * @brief Drizzle Declarations
42 */46 */
4347
44#include <sys/types.h>
45
46#ifdef _WIN3248#ifdef _WIN32
47# define WIN32_LEAN_AND_MEAN49
4850typedef int in_port_t;
49# include <Windows.h>51
50# include <winsock2.h>52#else
51# include <ws2tcpip.h>
52# include <io.h>
53
54# undef close
55# define close _close
56typedef unsigned int in_port_t;
57typedef long ssize_t;
58
59# define snprintf _snprintf
60# define inline __inline
61
62struct sockaddr_un
63{
64 short int sun_family;
65 char sun_path[108];
66};
67
68# define poll WSAPoll
69//# define pollfd WSAPOLLFD
70
71#if defined(__GNUC__)
72# include <stdbool.h>
73#else
74# if !defined(__cplusplus)
75typedef enum { false = 0, true = 1 } _Bool;
76typedef _Bool bool;
77#endif
78#endif
79
80#else
81# if !defined(__cplusplus)
82# include <stdbool.h>
83# endif
84# include <sys/socket.h>53# include <sys/socket.h>
85# include <netinet/in.h>54# include <netinet/in.h>
86# include <arpa/inet.h>55# include <arpa/inet.h>
87# include <sys/un.h>56# include <sys/un.h>
88# include <netdb.h>57# include <netdb.h>
89# include <poll.h>
90#endif
91#ifdef USE_OPENSSL
92#include <openssl/ssl.h>
93#endif58#endif
9459
95#include <libdrizzle-5.1/visibility.h>
96#include <libdrizzle-5.1/constants.h>60#include <libdrizzle-5.1/constants.h>
97#include <libdrizzle-5.1/structs.h>61#include <libdrizzle-5.1/structs.h>
98#include <libdrizzle-5.1/conn.h>62#include <libdrizzle-5.1/conn.h>
9963
=== modified file 'libdrizzle-5.1/drizzle_client.h'
--- libdrizzle-5.1/drizzle_client.h 2012-12-24 10:20:04 +0000
+++ libdrizzle-5.1/drizzle_client.h 2013-01-05 15:58:23 +0000
@@ -42,6 +42,17 @@
4242
43#pragma once43#pragma once
4444
45#ifndef DRIZZLE_CLIENT_INTERFACE
46# define DRIZZLE_CLIENT_INTERFACE 1
47#endif
48
49#include <stdbool.h>
50#include <stdint.h>
51#include <sys/types.h>
52
53/* Visibility must come first */
54#include <libdrizzle-5.1/visibility.h>
55
45#include <libdrizzle-5.1/drizzle.h>56#include <libdrizzle-5.1/drizzle.h>
46#include <libdrizzle-5.1/conn_client.h>57#include <libdrizzle-5.1/conn_client.h>
47#include <libdrizzle-5.1/handshake_client.h>58#include <libdrizzle-5.1/handshake_client.h>
@@ -52,9 +63,7 @@
52#include <libdrizzle-5.1/row_client.h>63#include <libdrizzle-5.1/row_client.h>
53#include <libdrizzle-5.1/field_client.h>64#include <libdrizzle-5.1/field_client.h>
54#include <libdrizzle-5.1/error.h>65#include <libdrizzle-5.1/error.h>
55#ifdef USE_OPENSSL
56#include <libdrizzle-5.1/ssl.h>66#include <libdrizzle-5.1/ssl.h>
57#endif
58#include <libdrizzle-5.1/binlog.h>67#include <libdrizzle-5.1/binlog.h>
59#include <libdrizzle-5.1/statement.h>68#include <libdrizzle-5.1/statement.h>
60#include <libdrizzle-5.1/version.h>69#include <libdrizzle-5.1/version.h>
6170
=== modified file 'libdrizzle-5.1/visibility.h'
--- libdrizzle-5.1/visibility.h 2012-12-18 11:36:28 +0000
+++ libdrizzle-5.1/visibility.h 2013-01-05 15:58:23 +0000
@@ -1,44 +1,11 @@
1/*1/* libdrizzle
2 * Drizzle Client & Protocol Library2 * Copyright (C) 2013 Drizzle Developers Group
3 *
4 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5 * All rights reserved.3 * All rights reserved.
6 *4 *
7 * Redistribution and use in source and binary forms, with or without5 * Use and distribution licensed under the BSD license. See
8 * modification, are permitted provided that the following conditions are6 * the COPYING file in the parent directory for full text.
9 * met:7 *
10 *8 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
21 * written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 *
36 * Implementation drawn from visibility.texi in gnulib.
37 */
38
39/**
40 * @file
41 * @brief Visibility Control Macros
42 */9 */
4310
44#pragma once11#pragma once
@@ -48,31 +15,22 @@
48 * DRIZZLE_API is used for the public API symbols. It either DLL imports or15 * DRIZZLE_API is used for the public API symbols. It either DLL imports or
49 * DLL exports (or does nothing for static build).16 * DLL exports (or does nothing for static build).
50 *17 *
51 * DRIZZLE_LOCAL is used for non-api symbols.
52 */18 */
5319
54#if defined(_WIN32)
55# define DRIZZLE_API
56# define DRIZZLE_LOCAL
57#else
58#if defined(BUILDING_LIBDRIZZLE)20#if defined(BUILDING_LIBDRIZZLE)
59# if defined(HAVE_VISIBILITY)21# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
60# define DRIZZLE_API __attribute__ ((visibility("default")))22# define DRIZZLE_API __attribute__ ((visibility("default")))
61# define DRIZZLE_LOCAL __attribute__ ((visibility("hidden")))
62# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)23# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
63# define DRIZZLE_API __global24# define DRIZZLE_API __global
64# define DRIZZLE_API __hidden
65# elif defined(_MSC_VER)25# elif defined(_MSC_VER)
66# define DRIZZLE_API extern __declspec(dllexport) 26# define DRIZZLE_API extern __declspec(dllexport)
67# define DRIZZLE_LOCAL27# else
28# define DRIZZLE_API
68# endif /* defined(HAVE_VISIBILITY) */29# endif /* defined(HAVE_VISIBILITY) */
69#else /* defined(BUILDING_LIBDRIZZLE) */30#else /* defined(BUILDING_LIBDRIZZLE) */
70# if defined(_MSC_VER)31# if defined(_MSC_VER)
71# define DRIZZLE_API extern __declspec(dllimport) 32# define DRIZZLE_API extern __declspec(dllimport)
72# define DRIZZLE_LOCAL
73# else33# else
74# define DRIZZLE_API34# define DRIZZLE_API
75# define DRIZZLE_LOCAL
76# endif /* defined(_MSC_VER) */35# endif /* defined(_MSC_VER) */
77#endif /* defined(BUILDING_LIBDRIZZLE) */36#endif /* defined(BUILDING_LIBDRIZZLE) */
78#endif /* _WIN32 */
7937
=== modified file 'libdrizzle/binlog.cc'
--- libdrizzle/binlog.cc 2013-01-05 10:27:32 +0000
+++ libdrizzle/binlog.cc 2013-01-05 15:58:23 +0000
@@ -37,6 +37,7 @@
3737
38#include "config.h"38#include "config.h"
39#include "libdrizzle/common.h"39#include "libdrizzle/common.h"
40
40#include <zlib.h>41#include <zlib.h>
4142
42drizzle_result_st *drizzle_start_binlog(drizzle_st *con,43drizzle_result_st *drizzle_start_binlog(drizzle_st *con,
4344
=== modified file 'libdrizzle/common.h'
--- libdrizzle/common.h 2012-12-31 07:11:30 +0000
+++ libdrizzle/common.h 2013-01-05 15:58:23 +0000
@@ -41,18 +41,35 @@
4141
42#pragma once42#pragma once
4343
44#include "config.h"
45
46#include <libdrizzle-5.1/drizzle_client.h>44#include <libdrizzle-5.1/drizzle_client.h>
4745
48#include <assert.h>46#include <cassert>
49#include <errno.h>47
5048#ifdef HAVE_FCNTL_H
51#include <fcntl.h>49# include <fcntl.h>
52#ifndef _WIN3250#endif
51
52#if defined(WIN32) || defined(__MINGW32__)
53# include "libdrizzle/windows.hpp"
54# define get_socket_errno() WSAGetLastError()
55
56#else
53# include <netinet/tcp.h>57# include <netinet/tcp.h>
54# include <sys/uio.h>58# include <sys/uio.h>
55# include <unistd.h>59# include <unistd.h>
60# include <cerrno>
61# define INVALID_SOCKET -1
62# define SOCKET_ERROR -1
63# define closesocket(a) close(a)
64# define get_socket_errno() errno
65
66#endif // defined(WIN32) || defined(__MINGW32__)
67
68#if defined(HAVE_POLL_H) && HAVE_POLL_H
69# include <poll.h>
70typedef struct pollfd pollfd_t;
71#else
72# include "libdrizzle/poll.h"
56#endif73#endif
5774
58#include <stddef.h>75#include <stddef.h>
@@ -60,7 +77,6 @@
60#include <stdio.h>77#include <stdio.h>
61#include <stdlib.h>78#include <stdlib.h>
62#include <string.h>79#include <string.h>
63#include <signal.h>
6480
65#include "libdrizzle/structs.h"81#include "libdrizzle/structs.h"
66#include "libdrizzle/drizzle_local.h"82#include "libdrizzle/drizzle_local.h"
6783
=== modified file 'libdrizzle/conn.cc'
--- libdrizzle/conn.cc 2013-01-05 11:41:26 +0000
+++ libdrizzle/conn.cc 2013-01-05 15:58:23 +0000
@@ -56,10 +56,24 @@
56# define FD_CLOEXEC 056# define FD_CLOEXEC 0
57#endif57#endif
5858
59#ifndef F_GETFD
60# define F_GETFD 0
61#endif
62
59#ifndef MSG_DONTWAIT63#ifndef MSG_DONTWAIT
60# define MSG_DONTWAIT 064# define MSG_DONTWAIT 0
61#endif65#endif
6266
67#ifndef MSG_NOSIGNAL
68# define MSG_NOSIGNAL 0
69#endif
70
71#ifndef EWOULDBLOCK
72# define EWOULDBLOCK EAGAIN
73#endif
74
75#include <cerrno>
76
63/**77/**
64 * @addtogroup drizzle_static Static Connection Declarations78 * @addtogroup drizzle_static Static Connection Declarations
65 * @ingroup drizzle_con79 * @ingroup drizzle_con
@@ -75,52 +89,15 @@
75 */89 */
76static drizzle_return_t _setsockopt(drizzle_st *con);90static drizzle_return_t _setsockopt(drizzle_st *con);
7791
78static void __closesocket(int& fd)92static void __closesocket(socket_t& fd)
79{93{
80 if (fd != -1)94 if (fd != INVALID_SOCKET)
81 {95 {
82 (void)shutdown(fd, SHUT_RDWR);96 (void)shutdown(fd, SHUT_RDWR);
83 (void)closesocket(fd);97 (void)closesocket(fd);
84 fd= -1;98 fd= INVALID_SOCKET;
85 }99 }
86}100}
87
88#ifdef WIN32
89static void translate_windows_error()
90{
91 errno= WSAGetLastError();
92 switch(errno) {
93 case WSAEINVAL:
94 case WSAEALREADY:
95 case WSAEWOULDBLOCK:
96 errno= EINPROGRESS;
97 break;
98 case WSAECONNREFUSED:
99 errno= ECONNREFUSED;
100 break;
101 case WSAENETUNREACH:
102 errno= ENETUNREACH;
103 break;
104 case WSAETIMEDOUT:
105 errno= ETIMEDOUT;
106 break;
107 case WSAECONNRESET:
108 errno= ECONNRESET;
109 break;
110 case WSAEADDRINUSE:
111 errno= EADDRINUSE;
112 break;
113 case WSAEOPNOTSUPP:
114 errno= EOPNOTSUPP;
115 break;
116 case WSAENOPROTOOPT:
117 errno= ENOPROTOOPT;
118 break;
119 default:
120 break;
121 }
122}
123#endif
124101
125static bool connect_poll(drizzle_st *con)102static bool connect_poll(drizzle_st *con)
126{103{
@@ -148,7 +125,11 @@
148125
149 if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))126 if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))
150 {127 {
128#ifdef __MINGW32__
129 char err;
130#else
151 int err;131 int err;
132#endif
152 socklen_t len= sizeof (err);133 socklen_t len= sizeof (err);
153 // We replace errno with err if getsockopt() passes, but err has been134 // We replace errno with err if getsockopt() passes, but err has been
154 // set.135 // set.
@@ -232,7 +213,7 @@
232 return;213 return;
233 }214 }
234215
235 if (con->fd == -1)216 if (con->fd == INVALID_SOCKET)
236 {217 {
237 return;218 return;
238 }219 }
@@ -935,7 +916,9 @@
935916
936 if (con->socket_type == DRIZZLE_CON_SOCKET_UDS)917 if (con->socket_type == DRIZZLE_CON_SOCKET_UDS)
937 {918 {
938#ifndef WIN32919#if defined _WIN32 || defined __CYGWIN__
920 return DRIZZLE_RETURN_COULD_NOT_CONNECT;
921#else // defined _WIN32 || defined __CYGWIN__
939 if ((con->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)922 if ((con->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
940 {923 {
941 con->last_errno= errno;924 con->last_errno= errno;
@@ -971,9 +954,7 @@
971 } while (0);954 } while (0);
972955
973 return DRIZZLE_RETURN_OK;956 return DRIZZLE_RETURN_OK;
974#else957#endif // defined _WIN32 || defined __CYGWIN__
975 return DRIZZLE_RETURN_COULD_NOT_CONNECT;
976#endif
977 }958 }
978 else959 else
979 {960 {
@@ -1020,7 +1001,7 @@
1020 {1001 {
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);
10221003
1023#ifdef _WIN321004#if defined _WIN32 || defined __CYGWIN__
1024 translate_windows_error();1005 translate_windows_error();
1025#endif /* _WIN32 */1006#endif /* _WIN32 */
10261007
@@ -1086,7 +1067,7 @@
1086 drizzle_state_pop(con);1067 drizzle_state_pop(con);
1087 socklen_t error_length= sizeof(error);1068 socklen_t error_length= sizeof(error);
1088 int getsockopt_error;1069 int getsockopt_error;
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)
1090 {1071 {
1091 drizzle_set_error(con, __func__, strerror(getsockopt_error));1072 drizzle_set_error(con, __func__, strerror(getsockopt_error));
1092 return DRIZZLE_RETURN_COULD_NOT_CONNECT;1073 return DRIZZLE_RETURN_COULD_NOT_CONNECT;
@@ -1177,46 +1158,10 @@
1177 {1158 {
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);
1179 }1160 }
1180#ifdef _WIN321161
1181 if (_WIN32)1162#if defined _WIN32 || defined __CYGWIN__
1182 {1163 errno= translate_windows_error();
1183 errno= WSAGetLastError();1164#endif // defined _WIN32 || defined __CYGWIN__
1184 switch (errno)
1185 {
1186 case WSAENOTCONN:
1187 case WSAEWOULDBLOCK:
1188 errno= EAGAIN;
1189 break;
1190 case WSAEINVAL:
1191 case WSAEALREADY:
1192 errno= EINPROGRESS;
1193 break;
1194 case WSAECONNREFUSED:
1195 errno= ECONNREFUSED;
1196 break;
1197 case WSAENETUNREACH:
1198 errno= ENETUNREACH;
1199 break;
1200 case WSAETIMEDOUT:
1201 errno= ETIMEDOUT;
1202 break;
1203 case WSAECONNRESET:
1204 errno= ECONNRESET;
1205 break;
1206 case WSAEADDRINUSE:
1207 errno= EADDRINUSE;
1208 break;
1209 case WSAEOPNOTSUPP:
1210 errno= EOPNOTSUPP;
1211 break;
1212 case WSAENOPROTOOPT:
1213 errno= ENOPROTOOPT;
1214 break;
1215 default:
1216 break;
1217 }
1218 }
1219#endif /* _WIN32 */
12201165
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",
1222 con->fd, read_size, 1167 con->fd, read_size,
@@ -1337,42 +1282,9 @@
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);
1338 }1283 }
13391284
1340#ifdef _WIN321285#if defined _WIN32 || defined __CYGWIN__
1341 errno = WSAGetLastError();1286 errno= translate_windows_error();
1342 switch(errno) {1287#endif // defined _WIN32 || defined __CYGWIN__
1343 case WSAENOTCONN:
1344 case WSAEWOULDBLOCK:
1345 errno= EAGAIN;
1346 break;
1347 case WSAEINVAL:
1348 case WSAEALREADY:
1349 errno= EINPROGRESS;
1350 break;
1351 case WSAECONNREFUSED:
1352 errno= ECONNREFUSED;
1353 break;
1354 case WSAENETUNREACH:
1355 errno= ENETUNREACH;
1356 break;
1357 case WSAETIMEDOUT:
1358 errno= ETIMEDOUT;
1359 break;
1360 case WSAECONNRESET:
1361 errno= ECONNRESET;
1362 break;
1363 case WSAEADDRINUSE:
1364 errno= EADDRINUSE;
1365 break;
1366 case WSAEOPNOTSUPP:
1367 errno= EOPNOTSUPP;
1368 break;
1369 case WSAENOPROTOOPT:
1370 errno= ENOPROTOOPT;
1371 break;
1372 default:
1373 break;
1374 }
1375#endif /* _WIN32 */
13761288
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",
1378 con->fd, write_size,1290 con->fd, write_size,
@@ -1448,27 +1360,32 @@
1448 return DRIZZLE_RETURN_INVALID_ARGUMENT;1360 return DRIZZLE_RETURN_INVALID_ARGUMENT;
1449 }1361 }
14501362
1451 if (SOCK_CLOEXEC == 0)1363#ifdef HAVE_FCNTL
1364 if (HAVE_FCNTL)
1452 {1365 {
1453 if (FD_CLOEXEC)1366 if (SOCK_CLOEXEC == 0)
1454 {1367 {
1455 int flags;1368 if (FD_CLOEXEC and F_GETFD)
1456 do
1457 {1369 {
1458 flags= fcntl(con->fd, F_GETFD, 0);1370 int flags;
1459 } while (flags == -1 and (errno == EINTR or errno == EAGAIN));
1460
1461 if (flags != -1)
1462 {
1463 int rval;
1464 do1371 do
1372 {
1373 flags= fcntl(con->fd, F_GETFD, 0);
1374 } while (flags == -1 and (errno == EINTR or errno == EAGAIN));
1375
1376 if (flags != -1)
1465 { 1377 {
1466 rval= fcntl (con->fd, F_SETFD, flags | FD_CLOEXEC);1378 int rval;
1467 } while (rval == -1 && (errno == EINTR or errno == EAGAIN));1379 do
1468 // we currently ignore the case where rval is -11380 {
1381 rval= fcntl (con->fd, F_SETFD, flags | FD_CLOEXEC);
1382 } while (rval == -1 && (errno == EINTR or errno == EAGAIN));
1383 // we currently ignore the case where rval is -1
1384 }
1469 }1385 }
1470 }1386 }
1471 }1387 }
1388#endif // HAVE_FCNTL
1472 1389
14731390
1474 int ret= 1;1391 int ret= 1;
14751392
=== modified file 'libdrizzle/drizzle.cc'
--- libdrizzle/drizzle.cc 2013-01-05 11:31:45 +0000
+++ libdrizzle/drizzle.cc 2013-01-05 15:58:23 +0000
@@ -43,6 +43,8 @@
43#include "config.h"43#include "config.h"
44#include "libdrizzle/common.h"44#include "libdrizzle/common.h"
4545
46#include <cerrno>
47
46/**48/**
47 * @addtogroup drizzle_static Static Drizzle Declarations49 * @addtogroup drizzle_static Static Drizzle Declarations
48 * @ingroup drizzle50 * @ingroup drizzle
@@ -242,7 +244,7 @@
242244
243 drizzle_result_free_all(con);245 drizzle_result_free_all(con);
244246
245 if (con->fd != -1)247 if (con->fd != INVALID_SOCKET)
246 {248 {
247 drizzle_close(con);249 drizzle_close(con);
248 }250 }
249251
=== modified file 'libdrizzle/error.cc'
--- libdrizzle/error.cc 2013-01-05 11:25:32 +0000
+++ libdrizzle/error.cc 2013-01-05 15:58:23 +0000
@@ -34,7 +34,9 @@
34 *34 *
35 */35 */
3636
37#include <libdrizzle/common.h>37#include "config.h"
38
39#include "libdrizzle/common.h"
3840
39const char *drizzle_strerror(const drizzle_return_t arg)41const char *drizzle_strerror(const drizzle_return_t arg)
40{42{
4143
=== modified file 'libdrizzle/include.am'
--- libdrizzle/include.am 2012-12-31 07:11:30 +0000
+++ libdrizzle/include.am 2013-01-05 15:58:23 +0000
@@ -9,10 +9,12 @@
9noinst_HEADERS+= libdrizzle/datetime.h9noinst_HEADERS+= libdrizzle/datetime.h
10noinst_HEADERS+= libdrizzle/drizzle_local.h10noinst_HEADERS+= libdrizzle/drizzle_local.h
11noinst_HEADERS+= libdrizzle/pack.h11noinst_HEADERS+= libdrizzle/pack.h
12noinst_HEADERS+= libdrizzle/poll.h
12noinst_HEADERS+= libdrizzle/sha1.h13noinst_HEADERS+= libdrizzle/sha1.h
13noinst_HEADERS+= libdrizzle/state.h14noinst_HEADERS+= libdrizzle/state.h
14noinst_HEADERS+= libdrizzle/statement_local.h15noinst_HEADERS+= libdrizzle/statement_local.h
15noinst_HEADERS+= libdrizzle/structs.h16noinst_HEADERS+= libdrizzle/structs.h
17noinst_HEADERS+= libdrizzle/windows.hpp
1618
17lib_LTLIBRARIES+= libdrizzle/libdrizzle.la19lib_LTLIBRARIES+= libdrizzle/libdrizzle.la
18libdrizzle_libdrizzle_la_SOURCES=20libdrizzle_libdrizzle_la_SOURCES=
@@ -23,12 +25,17 @@
2325
24libdrizzle_libdrizzle_la_CFLAGS+= @OPENSSL_INCLUDES@26libdrizzle_libdrizzle_la_CFLAGS+= @OPENSSL_INCLUDES@
25libdrizzle_libdrizzle_la_CXXFLAGS+= @OPENSSL_INCLUDES@27libdrizzle_libdrizzle_la_CXXFLAGS+= @OPENSSL_INCLUDES@
28libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@
29libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@
30
26libdrizzle_libdrizzle_la_CFLAGS+= @ZLIB_CFLAGS@31libdrizzle_libdrizzle_la_CFLAGS+= @ZLIB_CFLAGS@
27libdrizzle_libdrizzle_la_CXXFLAGS+= @ZLIB_CFLAGS@32libdrizzle_libdrizzle_la_CXXFLAGS+= @ZLIB_CFLAGS@
28libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@33libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@
29libdrizzle_libdrizzle_la_LIBADD+= @ZLIB_LIBS@34libdrizzle_libdrizzle_la_LIBADD+= @ZLIB_LIBS@
30libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@35
31libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@36if BUILD_WIN32
37libdrizzle_libdrizzle_la_LIBADD+= -lmingw32 -lws2_32 -lgdi32
38endif
3239
33libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/binlog.cc40libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/binlog.cc
34libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/command.cc41libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/command.cc
@@ -43,6 +50,7 @@
43libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/drizzle.cc50libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/drizzle.cc
44libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/field.cc51libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/field.cc
45libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/pack.cc52libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/pack.cc
53libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/poll.cc
46libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/result.cc54libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/result.cc
47libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/sha1.cc55libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/sha1.cc
48libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/state.cc56libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/state.cc
4957
=== added file 'libdrizzle/poll.cc'
--- libdrizzle/poll.cc 1970-01-01 00:00:00 +0000
+++ libdrizzle/poll.cc 2013-01-05 15:58:23 +0000
@@ -0,0 +1,86 @@
1/* LibMemcached
2 * Copyright (C) 2010 Brian Aker, Trond Norbye
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: Implementation of poll by using select
9 *
10 */
11
12#include "config.h"
13
14#include "libdrizzle/common.h"
15
16#if defined(WIN32) || defined(__MINGW32__)
17#include "libdrizzle/poll.h"
18
19#include <sys/time.h>
20#include <strings.h>
21
22int poll(struct pollfd fds[], nfds_t nfds, int tmo)
23{
24 fd_set readfds, writefds, errorfds;
25 FD_ZERO(&readfds);
26 FD_ZERO(&writefds);
27 FD_ZERO(&errorfds);
28
29 int maxfd= 0;
30
31 for (nfds_t x= 0; x < nfds; ++x)
32 {
33 if (fds[x].events & (POLLIN | POLLOUT))
34 {
35#ifndef WIN32
36 if (fds[x].fd > maxfd)
37 {
38 maxfd= fds[x].fd;
39 }
40#endif
41 if (fds[x].events & POLLIN)
42 {
43 FD_SET(fds[x].fd, &readfds);
44 }
45 if (fds[x].events & POLLOUT)
46 {
47 FD_SET(fds[x].fd, &writefds);
48 }
49 }
50 }
51
52 struct timeval timeout= { .tv_sec = tmo / 1000,
53 .tv_usec= (tmo % 1000) * 1000 };
54 struct timeval *tp= &timeout;
55 if (tmo == -1)
56 {
57 tp= NULL;
58 }
59 int ret= select(maxfd + 1, &readfds, &writefds, &errorfds, tp);
60 if (ret <= 0)
61 {
62 return ret;
63 }
64
65 /* Iterate through all of them because I need to clear the revent map */
66 for (nfds_t x= 0; x < nfds; ++x)
67 {
68 fds[x].revents= 0;
69 if (FD_ISSET(fds[x].fd, &readfds))
70 {
71 fds[x].revents |= POLLIN;
72 }
73 if (FD_ISSET(fds[x].fd, &writefds))
74 {
75 fds[x].revents |= POLLOUT;
76 }
77 if (FD_ISSET(fds[x].fd, &errorfds))
78 {
79 fds[x].revents |= POLLERR;
80 }
81 }
82
83 return ret;
84}
85
86#endif // defined(WIN32) || defined(__MINGW32__)
087
=== added file 'libdrizzle/poll.h'
--- libdrizzle/poll.h 1970-01-01 00:00:00 +0000
+++ libdrizzle/poll.h 2013-01-05 15:58:23 +0000
@@ -0,0 +1,47 @@
1/* LibMemcached
2 * Copyright (C) 2010 Brian Aker, Trond Norbye
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: Implementation of poll by using select
9 *
10 */
11
12#pragma once
13
14#if defined(WIN32) || defined(__MINGW32__)
15
16#include <winsock2.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22typedef struct pollfd
23{
24#ifdef WIN32
25 SOCKET fd;
26#else
27 int fd;
28#endif
29 short events;
30 short revents;
31} pollfd_t;
32
33typedef int nfds_t;
34
35#define POLLIN 0x0001
36#define POLLOUT 0x0004
37#define POLLERR 0x0008
38#define POLLHUP 0x010 /* Hung up. */
39#define POLLNVAL 0x020 /* Invalid polling request. */
40
41int poll(struct pollfd fds[], nfds_t nfds, int tmo);
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif // defined(WIN32) || defined(__MINGW32__)
048
=== modified file 'libdrizzle/query.cc'
--- libdrizzle/query.cc 2013-01-05 10:27:32 +0000
+++ libdrizzle/query.cc 2013-01-05 15:58:23 +0000
@@ -40,6 +40,8 @@
40 * @brief Query definitions40 * @brief Query definitions
41 */41 */
4242
43#include "config.h"
44
43#include <libdrizzle/common.h>45#include <libdrizzle/common.h>
4446
45drizzle_result_st *drizzle_query(drizzle_st *con,47drizzle_result_st *drizzle_query(drizzle_st *con,
4648
=== modified file 'libdrizzle/ssl.cc'
--- libdrizzle/ssl.cc 2012-12-24 10:20:04 +0000
+++ libdrizzle/ssl.cc 2013-01-05 15:58:23 +0000
@@ -36,10 +36,13 @@
36 */36 */
3737
38#include "config.h"38#include "config.h"
39
39#include "libdrizzle/common.h"40#include "libdrizzle/common.h"
4041
41#include <libdrizzle-5.1/ssl.h>42#include <libdrizzle-5.1/ssl.h>
42#include <openssl/ssl.h>43
44#if defined(USE_OPENSSL)
45# include <openssl/ssl.h>
4346
44drizzle_return_t drizzle_set_ssl(drizzle_st *con, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher)47drizzle_return_t drizzle_set_ssl(drizzle_st *con, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher)
45{48{
@@ -85,3 +88,12 @@
8588
86 return DRIZZLE_RETURN_OK;89 return DRIZZLE_RETURN_OK;
87}90}
91
92#else
93
94drizzle_return_t drizzle_set_ssl(drizzle_st*, const char*, const char*, const char*, const char*, const char*)
95{
96 return DRIZZLE_RETURN_INVALID_ARGUMENT;
97}
98
99#endif
88100
=== modified file 'libdrizzle/statement_local.h'
--- libdrizzle/statement_local.h 2013-01-05 11:25:32 +0000
+++ libdrizzle/statement_local.h 2013-01-05 15:58:23 +0000
@@ -41,25 +41,18 @@
41extern "C" {41extern "C" {
42#endif42#endif
4343
44DRIZZLE_LOCAL
45drizzle_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);44drizzle_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);
4645
47DRIZZLE_LOCAL
48char *long_to_string(drizzle_bind_st *param, uint32_t val);46char *long_to_string(drizzle_bind_st *param, uint32_t val);
4947
50DRIZZLE_LOCAL
51char *longlong_to_string(drizzle_bind_st *param, uint64_t val);48char *longlong_to_string(drizzle_bind_st *param, uint64_t val);
5249
53DRIZZLE_LOCAL
54char *double_to_string(drizzle_bind_st *param, double val);50char *double_to_string(drizzle_bind_st *param, double val);
5551
56DRIZZLE_LOCAL
57char *time_to_string(drizzle_bind_st *param, drizzle_datetime_st *time);52char *time_to_string(drizzle_bind_st *param, drizzle_datetime_st *time);
5853
59DRIZZLE_LOCAL
60char *timestamp_to_string(drizzle_bind_st *param, drizzle_datetime_st *timestamp);54char *timestamp_to_string(drizzle_bind_st *param, drizzle_datetime_st *timestamp);
6155
62DRIZZLE_LOCAL
63uint16_t drizzle_stmt_column_lookup(drizzle_result_st *result, const char *column_name, drizzle_return_t *ret_ptr);56uint16_t drizzle_stmt_column_lookup(drizzle_result_st *result, const char *column_name, drizzle_return_t *ret_ptr);
6457
65#ifdef __cplusplus58#ifdef __cplusplus
6659
=== modified file 'libdrizzle/structs.h'
--- libdrizzle/structs.h 2013-01-05 10:27:32 +0000
+++ libdrizzle/structs.h 2013-01-05 15:58:23 +0000
@@ -43,9 +43,11 @@
43#pragma once43#pragma once
4444
45#include <sys/types.h>45#include <sys/types.h>
46#ifdef USE_OPENSSL46
47#include <openssl/ssl.h>47#if defined(HAVE_OPENSSL_SSL_H)
48# include <openssl/ssl.h>
48#endif49#endif
50
49#ifdef NI_MAXHOST51#ifdef NI_MAXHOST
50# define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST52# define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST
51#else53#else
@@ -53,7 +55,7 @@
53#endif55#endif
5456
55#ifdef __cplusplus57#ifdef __cplusplus
56#include <cstddef>58# include <cstddef>
57#endif59#endif
5860
59#ifdef __cplusplus61#ifdef __cplusplus
@@ -62,6 +64,12 @@
6264
63#include "libdrizzle/datetime.h"65#include "libdrizzle/datetime.h"
6466
67#if defined _WIN32 || defined __CYGWIN__
68typedef SOCKET socket_t;
69#else
70typedef int socket_t;
71#endif
72
65/**73/**
66 * @ingroup drizzle_command 74 * @ingroup drizzle_command
67 * Commands for drizzle_command functions.75 * Commands for drizzle_command functions.
@@ -159,7 +167,7 @@
159 uint32_t result_count;167 uint32_t result_count;
160 uint32_t thread_id;168 uint32_t thread_id;
161 int backlog;169 int backlog;
162 int fd;170 socket_t fd;
163 size_t buffer_size;171 size_t buffer_size;
164 size_t command_offset;172 size_t command_offset;
165 size_t command_size;173 size_t command_size;
@@ -201,7 +209,7 @@
201 int timeout;209 int timeout;
202 drizzle_log_fn *log_fn;210 drizzle_log_fn *log_fn;
203 void *log_context;211 void *log_context;
204 struct pollfd pfds[1];212 pollfd_t pfds[1];
205 char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];213 char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1];
206 char last_error[DRIZZLE_MAX_ERROR_SIZE];214 char last_error[DRIZZLE_MAX_ERROR_SIZE];
207 drizzle_stmt_st *stmt;215 drizzle_stmt_st *stmt;
208216
=== added file 'libdrizzle/windows.hpp'
--- libdrizzle/windows.hpp 1970-01-01 00:00:00 +0000
+++ libdrizzle/windows.hpp 2013-01-05 15:58:23 +0000
@@ -0,0 +1,123 @@
1/*
2 * Drizzle Client & Protocol Library
3 *
4 * Copyright (C) 2012 Drizzle Developers (http://drizzle.org)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
21 * written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
36
37#pragma once
38
39#ifdef __cplusplus
40# include <cerrno>
41#else
42# include <errno.h>
43#endif
44
45#ifndef WIN32_LEAN_AND_MEAN
46# define WIN32_LEAN_AND_MEAN
47#endif
48
49#ifndef _WIN32_WINNT
50# define _WIN32_WINNT 0x0501
51#endif
52
53#ifdef __MINGW32__
54# if(_WIN32_WINNT >= 0x0501)
55# else
56# undef _WIN32_WINNT
57# define _WIN32_WINNT 0x0501
58# endif /* _WIN32_WINNT >= 0x0501 */
59#endif /* __MINGW32__ */
60
61#if defined(HAVE_WINSOCK2_H) && HAVE_WINSOCK2_H
62# include <winsock2.h>
63#endif
64
65#if defined(HAVE_WS2TCPIP_H) && HAVE_WS2TCPIP_H
66# include <ws2tcpip.h>
67#endif
68
69#if defined(HAVE_IO_H) && HAVE_IO_H
70# include <io.h>
71#endif
72
73struct sockaddr_un
74{
75 short int sun_family;
76 char sun_path[108];
77};
78
79static inline int translate_windows_error()
80{
81 int local_errno= WSAGetLastError();
82
83 switch(local_errno) {
84 case WSAEINVAL:
85 case WSAEALREADY:
86 case WSAEWOULDBLOCK:
87 local_errno= EINPROGRESS;
88 break;
89
90 case WSAECONNREFUSED:
91 local_errno= ECONNREFUSED;
92 break;
93
94 case WSAENETUNREACH:
95 local_errno= ENETUNREACH;
96 break;
97
98 case WSAETIMEDOUT:
99 local_errno= ETIMEDOUT;
100 break;
101
102 case WSAECONNRESET:
103 local_errno= ECONNRESET;
104 break;
105
106 case WSAEADDRINUSE:
107 local_errno= EADDRINUSE;
108 break;
109
110 case WSAEOPNOTSUPP:
111 local_errno= EOPNOTSUPP;
112 break;
113
114 case WSAENOPROTOOPT:
115 local_errno= ENOPROTOOPT;
116 break;
117
118 default:
119 break;
120 }
121
122 return local_errno;
123}
0124
=== modified file 'm4/ax_platform.m4'
--- m4/ax_platform.m4 2012-12-17 11:57:49 +0000
+++ m4/ax_platform.m4 2013-01-05 15:58:23 +0000
@@ -19,7 +19,8 @@
19# and this notice are preserved. This file is offered as-is, without any19# and this notice are preserved. This file is offered as-is, without any
20# warranty.20# warranty.
2121
22#serial 122#serial 3
23#
23 AC_DEFUN([AX_PLATFORM],24 AC_DEFUN([AX_PLATFORM],
24 [AC_REQUIRE([AC_CANONICAL_HOST])25 [AC_REQUIRE([AC_CANONICAL_HOST])
25 AC_REQUIRE([AC_CANONICAL_TARGET])26 AC_REQUIRE([AC_CANONICAL_TARGET])
@@ -34,9 +35,8 @@
3435
35 AS_CASE([$target_os],36 AS_CASE([$target_os],
36 [*mingw32*],37 [*mingw32*],
37 [AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows])38 [TARGET_WINDOWS="true"
38 AC_DEFINE([WINVER], [WindowsXP], [Version of Windows])39 AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows])
39 AC_DEFINE([_WIN32_WINNT], [0x0501], [Magical number to make things work])
40 AC_DEFINE([EAI_SYSTEM], [11], [Another magical number])40 AC_DEFINE([EAI_SYSTEM], [11], [Another magical number])
41 AH_BOTTOM([41 AH_BOTTOM([
42#ifndef HAVE_SYS_SOCKET_H42#ifndef HAVE_SYS_SOCKET_H
@@ -48,8 +48,12 @@
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])
49 AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])],49 AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])],
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])],
51 [*darwin*],[AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])],51 [*darwin*],
52 [*linux*],[AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])])52 [TARGET_OSX="true"
53 AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])],
54 [*linux*],
55 [TARGET_LINUX="true"
56 AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])])
5357
54 AM_CONDITIONAL([BUILD_WIN32],[test "x${TARGET_WINDOWS}" = "xtrue"])58 AM_CONDITIONAL([BUILD_WIN32],[test "x${TARGET_WINDOWS}" = "xtrue"])
55 AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OSX}" = "xtrue"])59 AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OSX}" = "xtrue"])
5660
=== modified file 'm4/bottom.m4'
--- m4/bottom.m4 2012-12-17 21:04:59 +0000
+++ m4/bottom.m4 2013-01-05 15:58:23 +0000
@@ -3,6 +3,11 @@
3AH_TOP([3AH_TOP([
4#pragma once4#pragma once
55
6/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */
7#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H)
8# error "You should include config.h as your first include file"
9#endif
10
6])11])
712
8AH_BOTTOM([13AH_BOTTOM([
@@ -23,30 +28,8 @@
23typedef unsigned long int ulong;28typedef unsigned long int ulong;
24#endif29#endif
2530
26/* To hide the platform differences between MS Windows and Unix, I am
27 * going to use the Microsoft way and #define the Microsoft-specific
28 * functions to the unix way. Microsoft use a separate subsystem for sockets,
29 * but Unix normally just use a filedescriptor on the same functions. It is
30 * a lot easier to map back to the unix way with macros than going the other
31 * way without side effect.
32 */
33#ifdef TARGET_OS_WINDOWS
34#define random() rand()
35#define srandom(a) srand(a)
36#define get_socket_errno() WSAGetLastError()
37#else
38#define INVALID_SOCKET -1
39#define SOCKET_ERROR -1
40#define closesocket(a) close(a)
41#define get_socket_errno() errno
42#endif // TARGET_OS_WINDOWS
43
44#ifndef HAVE_MSG_NOSIGNAL
45#define MSG_NOSIGNAL 0
46#endif // HAVE_MSG_NOSIGNAL
47
48#ifndef HAVE_MSG_DONTWAIT31#ifndef HAVE_MSG_DONTWAIT
49#define MSG_DONTWAIT 032# define MSG_DONTWAIT 0
50#endif // HAVE_MSG_DONTWAIT33#endif // HAVE_MSG_DONTWAIT
5134
52])35])
5336
=== modified file 'm4/socket_send_flags.m4'
--- m4/socket_send_flags.m4 2012-12-17 11:57:49 +0000
+++ m4/socket_send_flags.m4 2013-01-05 15:58:23 +0000
@@ -1,48 +1,47 @@
1dnl Copyright (C) 2012 Data Differential LLC1# Copyright (C) 2012-2013 Data Differential LLC
2dnl Copyright (C) 2011 Trond Norbye2# Copyright (C) 2011 Trond Norbye
3dnl This file is free software; Trond Norbye3# This file is free software; Trond Norbye and Data Differential
4dnl gives unlimited permission to copy and/or distribute it,4# gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.5# with or without modifications, as long as this notice is preserved.
6dnl ---------------------------------------------------------------------------6# ---------------------------------------------------------------------------
7dnl Macro: SOCKET_SEND_FLAGS7# Macro: SOCKET_SEND_FLAGS
8dnl ---------------------------------------------------------------------------8# ---------------------------------------------------------------------------
99#
10AC_DEFUN([SOCKET_SEND_FLAGS],[10
11 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [11#serial 2
12 AC_LANG_PUSH([C])12
13 AX_SAVE_FLAGS13AC_DEFUN([SOCKET_SEND_FLAGS],
14 CFLAGS="$CFLAGS -I${srcdir}"14 [AC_CACHE_CHECK([for MSG_NOSIGNAL],[ac_cv_msg_nosignal],
1515 [AC_LANG_PUSH([C])
16 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_NOSIGNAL ])], [ac_cv_msg_nosignal="yes"])16 AX_SAVE_FLAGS
17 AC_LANG_POP17 CFLAGS="$CFLAGS -I${srcdir}"
18 AX_RESTORE_FLAGS18
19 ])19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [int flags= MSG_NOSIGNAL])], [ac_cv_msg_nosignal="yes"])
2020 AC_LANG_POP
21 AC_CACHE_CHECK([for MSG_DONTWAIT], [ac_cv_msg_dontwait], [21 AX_RESTORE_FLAGS])
22 AC_LANG_PUSH([C])22
23 AX_SAVE_FLAGS23 AC_CACHE_CHECK([for MSG_DONTWAIT],[ac_cv_msg_dontwait],
24 CFLAGS="$CFLAGS -I${srcdir}"24 [AC_LANG_PUSH([C])
2525 AX_SAVE_FLAGS
26 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_DONTWAIT ])], [ac_cv_msg_dontwait="yes"])26 CFLAGS="$CFLAGS -I${srcdir}"
27 AC_LANG_POP27
28 AX_RESTORE_FLAGS28 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],[int flags= MSG_DONTWAIT])],[ac_cv_msg_dontwait="yes"])
29 ])29 AC_LANG_POP
3030 AX_RESTORE_FLAGS])
31 AC_CACHE_CHECK([for MSG_MORE], [ac_cv_msg_more], [31
32 AC_LANG_PUSH([C])32 AC_CACHE_CHECK([for MSG_MORE],[ac_cv_msg_more],
33 AX_SAVE_FLAGS33 [AC_LANG_PUSH([C])
34 CFLAGS="$CFLAGS -I${srcdir}"34 AX_SAVE_FLAGS
3535 CFLAGS="$CFLAGS -I${srcdir}"
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"])
37 AC_LANG_POP37 AC_LANG_POP
38 AX_RESTORE_FLAGS38 AX_RESTORE_FLAGS])
39 ])39
4040 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_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])])
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])])
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 ])
44])44
4545# ---------------------------------------------------------------------------
46dnl ---------------------------------------------------------------------------46# End Macro: SOCKET_SEND_FLAGS
47dnl End Macro: SOCKET_SEND_FLAGS47# ---------------------------------------------------------------------------
48dnl ---------------------------------------------------------------------------
4948
=== modified file 'tests/unit/binlog.c'
--- tests/unit/binlog.c 2012-12-31 00:06:53 +0000
+++ tests/unit/binlog.c 2013-01-05 15:58:23 +0000
@@ -38,7 +38,6 @@
38#include <yatl/lite.h>38#include <yatl/lite.h>
3939
40#include <libdrizzle-5.1/libdrizzle.h>40#include <libdrizzle-5.1/libdrizzle.h>
41#include "libdrizzle/structs.h"
42#include <stdio.h>41#include <stdio.h>
43#include <stdlib.h>42#include <stdlib.h>
44#include <stdint.h>43#include <stdint.h>
4544
=== modified file 'tests/unit/row.c'
--- tests/unit/row.c 2013-01-05 11:41:26 +0000
+++ tests/unit/row.c 2013-01-05 15:58:23 +0000
@@ -143,11 +143,7 @@
143 return EXIT_FAILURE;143 return EXIT_FAILURE;
144 }144 }
145 size_t *sizes= drizzle_row_field_sizes(result);145 size_t *sizes= drizzle_row_field_sizes(result);
146 if (sizes[0] != 1)146 ASSERT_EQ(sizes[0], 1);
147 {
148 printf("Row size mismatch (4 != %lu)\n", sizes[0]);
149 return EXIT_FAILURE;
150 }
151147
152 drizzle_result_free(result);148 drizzle_result_free(result);
153149

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: