diff --git a/luprex/cpp/drv/driver-linux.cpp b/luprex/cpp/drv/driver-linux.cpp index 3fed47fe..559e22bf 100644 --- a/luprex/cpp/drv/driver-linux.cpp +++ b/luprex/cpp/drv/driver-linux.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/luprex/cpp/drv/driver-mingw.cpp b/luprex/cpp/drv/driver-mingw.cpp index b539eb3b..a1e4318e 100644 --- a/luprex/cpp/drv/driver-mingw.cpp +++ b/luprex/cpp/drv/driver-mingw.cpp @@ -3,18 +3,22 @@ #include "drvutil.hpp" #include "sslutil.hpp" -#include "../cpp/enginewrapper.hpp" +#include "../core/enginewrapper.hpp" #include #include #include #include +#include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -194,7 +198,7 @@ static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std } int status = WSAPoll(pollvec, pollcount, mstimeout); if (status < 0) { - err = strerror_str(WSAGetLastError()); + err = drvutil::strerror_str(WSAGetLastError()); return -1; } return status; @@ -266,13 +270,28 @@ static void ssl_load_certificate_authorities(SSL_CTX *ctx) { 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" int main(int argc, char **argv) { init_winsock(); - OPENSSL_init_ssl(0, NULL); - SourceDB::register_lua_builtins(); + assert(OPENSSL_init_ssl(0, NULL) == 1); + sslutil::clear_all_errors(); Driver driver; return driver.drive(argc, argv); }