Skip to content

SQLiteCloud Integration with Static Dependencies (libCurl/OpenSSL) #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion C/sqcloud.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@
#include <pthread.h>
#include <inttypes.h>
#endif
#ifdef __MINGW32__
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#define ioctl ioctlsocket
#define strndup(s,n) mem_string_ndup_win(s,n)

static char* mem_string_ndup_win(const char* s, size_t n) {
char* res = (char*)malloc(n + 1);
if (res) {
memcpy(res, s, n);
res[n] = '\0';
}
return res;
}
#else
#include <unistd.h>
#include <sys/ioctl.h>
#endif

#include <inttypes.h>

#ifndef SQLITECLOUD_DISABLE_TLS

Expand Down Expand Up @@ -1780,7 +1801,14 @@ static bool internal_connect (SQCloudConnection *connection, const char *hostnam

// turn on non-blocking
unsigned long ioctl_blocking = 1; /* ~0; //TRUE; */
// ioctl(sock_current, FIONBIO, &ioctl_blocking);
#ifdef __MINGW32__
u_long mode = (u_long)ioctl_blocking;
ioctlsocket(sock_current, FIONBIO, &mode);
#else
ioctl(sock_current, FIONBIO, &ioctl_blocking);
#endif


// initiate non-blocking connect ignoring return code
rc = connect(sock_current, addr->ai_addr, addr->ai_addrlen);
Expand Down Expand Up @@ -1877,8 +1905,13 @@ static bool internal_connect (SQCloudConnection *connection, const char *hostnam

// turn off non-blocking
int ioctl_blocking = 0; /* ~0; //TRUE; */
// ioctl(sockfd, FIONBIO, &ioctl_blocking);
#ifdef _WIN32
u_long mode = ioctl_blocking ? 0 : 1;
ioctlsocket(sockfd, FIONBIO, &mode);
#else
ioctl(sockfd, FIONBIO, &ioctl_blocking);

#endif
// finalize connection
if (mainfd) {
connection->fd = sockfd;
Expand Down