A few changes for mingw port (not done yet)

This commit is contained in:
2023-02-20 16:59:10 -05:00
parent f9aafee165
commit 8e2d37a73a
138 changed files with 49 additions and 25 deletions

View File

@@ -9,6 +9,12 @@
#include <string.h>
#include <iostream>
#if defined(_WIN32)
#include <profileapi.h>
#elif defined(__linux__)
#include <time.h>
#endif
namespace drvutil {
@@ -198,7 +204,7 @@ void strerror_safe(int errnum, char errbuf[256]) {
if (status != 0) {
snprintf(errbuf, 256, "unknown errno %d", errnum);
}
);
}
#endif
@@ -252,7 +258,7 @@ std::string strerror_str(int errnum) {
base_ = qpc();
}
double get() {
return (qpc() - base) * freq_;
return (qpc() - base_) * freq_;
}
};

View File

@@ -87,12 +87,17 @@ std::string error_string() {
}
}
std::string path_to_plain_ascii(const std::filesystem::path &path) {
std::string s = path.native();
for (char c : s) {
if ((c < 1) || (c > 127)) return "";
// Make sure the path only contains printable ascii characters,
// and no control characters or unicode characters.
std::string path_to_plain_printable_ascii(const std::filesystem::path &path) {
auto s = path.native();
std::string result(' ', s.size());
for (int i = 0; i < int(s.size()); i++) {
auto c = s[i];
if ((c < 32) || (c > 126)) return "";
result[i] = c;
}
return s;
return result;
}
void clear_all_errors() {
@@ -170,7 +175,7 @@ void ctx_load_cert_from_directory(SSL_CTX *ctx, const std::string &dir) {
std::vector<std::string> cert_paths;
for (const auto & entry : std::filesystem::directory_iterator(dir)) {
std::string fn = path_to_plain_ascii(entry.path());
std::string fn = path_to_plain_printable_ascii(entry.path());
if (fn.empty()) {
std::cerr << "Ignoring file with non-ascii filename: " << entry.path() << std::endl;
} else {