Merges for dll refactor

This commit is contained in:
2023-02-14 13:22:23 -05:00
4 changed files with 41 additions and 13 deletions

View File

@@ -9,6 +9,7 @@
#include <cstdio>
#include <cstring>
#include <cassert>
#include <filesystem>
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -23,6 +24,20 @@
#include <openssl/bio.h>
#include <openssl/pem.h>
// OpenSSL requires plain ascii pathnames. Returns empty string
// if the path cannot be converted to plain ascii.
std::string path_to_plain_ascii(const std::filesystem::path &path) {
std::wstring s = path.native();
for (wchar_t c : s) {
if ((c < 1) || (c > 127)) return "";
}
std::ostringstream oss;
for (wchar_t c : s) {
oss << ((char)c);
}
return oss.str();
}
static void set_nonblocking(SOCKET sock) {
u_long mode = 1; // 1 to enable non-blocking socket
int status = ioctlsocket(sock, FIONBIO, &mode);