Added path_to_plain_ascii for use by driver-ssl
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
#include "driver-util.hpp"
|
||||
#include "driver-ssl.hpp"
|
||||
#include "drivenengine.hpp"
|
||||
#include "util.hpp"
|
||||
#include "source.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <filesystem>
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
@@ -29,6 +29,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);
|
||||
|
||||
Reference in New Issue
Block a user