Corrections to complete the port to MingW

This commit is contained in:
2023-02-20 18:03:34 -05:00
parent 6c8ee78041
commit 3eebe7dc33
2 changed files with 24 additions and 4 deletions

View File

@@ -11,6 +11,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <string> #include <string>
#include <filesystem>
#include <poll.h> #include <poll.h>
#include <sys/time.h> #include <sys/time.h>

View File

@@ -3,18 +3,22 @@
#include "drvutil.hpp" #include "drvutil.hpp"
#include "sslutil.hpp" #include "sslutil.hpp"
#include "../cpp/enginewrapper.hpp" #include "../core/enginewrapper.hpp"
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
#include <map>
#include <vector>
#include <string>
#include <filesystem> #include <filesystem>
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <synchapi.h> #include <synchapi.h>
#include <sysinfoapi.h> #include <sysinfoapi.h>
#include <libloaderapi.h>
#include <windows.h> #include <windows.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
@@ -194,7 +198,7 @@ static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std
} }
int status = WSAPoll(pollvec, pollcount, mstimeout); int status = WSAPoll(pollvec, pollcount, mstimeout);
if (status < 0) { if (status < 0) {
err = strerror_str(WSAGetLastError()); err = drvutil::strerror_str(WSAGetLastError());
return -1; return -1;
} }
return status; return status;
@@ -266,13 +270,28 @@ static void ssl_load_certificate_authorities(SSL_CTX *ctx) {
CertCloseStore(hStore, 0); CertCloseStore(hStore, 0);
} }
// Load the DLL if it's not already loaded. Stores
// the handle in a global variable.
static void load_engine_dll() {
// Not actually implemented yet. Currently, the engine
// is linked right into the executable.
}
static void call_init_engine_wrapper(EngineWrapper *w) {
load_engine_dll();
using InitFn = void (*)(EngineWrapper *);
InitFn initfn = (InitFn)GetProcAddress(GetModuleHandle(NULL), "init_engine_wrapper");
assert(initfn != nullptr);
initfn(w);
}
#include "driver-common.cpp" #include "driver-common.cpp"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
init_winsock(); init_winsock();
OPENSSL_init_ssl(0, NULL); assert(OPENSSL_init_ssl(0, NULL) == 1);
SourceDB::register_lua_builtins(); sslutil::clear_all_errors();
Driver driver; Driver driver;
return driver.drive(argc, argv); return driver.drive(argc, argv);
} }