A few changes for mingw port (not done yet)
This commit is contained in:
@@ -1,4 +1,27 @@
|
||||
|
||||
ifeq ($(OS),mingw)
|
||||
EXE=main.exe
|
||||
LIBS=-L./ext/openssl-mingw -lssl -lcrypto -lws2_32 -lcrypt32 -lcryptui
|
||||
LUAFLAGS=-DLUA_USE_APICHECK -DLUA_COMPAT_ALL
|
||||
OPT=-g -O0
|
||||
DRIVER=driver-mingw
|
||||
else ifeq ($(OS),linux)
|
||||
EXE=main
|
||||
LIBS=-L./ext/openssl-linux -lssl -lcrypto
|
||||
LUAFLAGS=-DLUA_USE_APICHECK -DLUA_USE_POSIX
|
||||
OPT=-g -O0
|
||||
DRIVER=driver-linux
|
||||
else
|
||||
# In this case, any attempt to build luprex will trigger an error,
|
||||
# But making 'clean' will still work.
|
||||
ERROR=$(error You must specify OS=linux or OS=mingw)
|
||||
EXE=$(ERROR)
|
||||
LIBS=$(ERROR)
|
||||
LUAFLAGS=$(ERROR)
|
||||
OPT=$(ERROR)
|
||||
DRIVER=driver-xxx
|
||||
endif
|
||||
|
||||
|
||||
OBJ_ERIS=\
|
||||
obj/eris/lapi.o \
|
||||
@@ -35,7 +58,6 @@ OBJ_ERIS=\
|
||||
obj/eris/linit.o \
|
||||
obj/eris/eris.o \
|
||||
|
||||
|
||||
OBJ_CORE=\
|
||||
obj/core/invocation.o\
|
||||
obj/core/spookyv2.o\
|
||||
@@ -71,37 +93,28 @@ OBJ_CORE=\
|
||||
obj/core/eng-tests.o\
|
||||
obj/core/printbuffer.o\
|
||||
|
||||
|
||||
OBJ_DRV=\
|
||||
obj/drv/drvutil.o\
|
||||
obj/drv/sslutil.o\
|
||||
obj/drv/$(DRIVER).o
|
||||
|
||||
|
||||
ifeq ($(OS),linux)
|
||||
|
||||
OPT=-g -O0
|
||||
|
||||
main: $(OBJ_DRV) $(OBJ_CORE) $(OBJ_ERIS) obj/drv/driver-linux.o
|
||||
g++ $(OPT) -std=c++17 -export-dynamic -Wall -o $@ $(OBJ_DRV) $(OBJ_CORE) $(OBJ_ERIS) obj/drv/driver-linux.o -L./ext/openssl-linux -lssl -lcrypto -ldl
|
||||
$(EXE): $(OBJ_ERIS) $(OBJ_CORE) $(OBJ_DRV)
|
||||
g++ $(OPT) -std=c++17 -export-dynamic -Wall -o $@ $(OBJ_ERIS) $(OBJ_CORE) $(OBJ_DRV) $(LIBS)
|
||||
|
||||
obj/eris/%.o: ext/eris-master/src/%.c
|
||||
gcc $(OPT) -Wall -fvisibility=hidden -DLUA_USE_APICHECK -DLUA_USE_POSIX -c -MMD $< -o $@
|
||||
gcc $(OPT) -Wall -fvisibility=hidden $(LUAFLAGS) -c -MMD $< -o $@
|
||||
|
||||
obj/core/%.o: cpp/core/%.cpp
|
||||
g++ $(OPT) -Wall -fvisibility=hidden -std=c++17 -I./ext/eris-master/src -I./cpp/wrap -I./cpp/core -c -MMD $< -o $@
|
||||
|
||||
obj/drv/%.o: cpp/drv/%.cpp
|
||||
g++ $(OPT) -Wall -fvisibility=hidden -std=c++17 -I./ext/openssl -I./src/drv -c -MMD $< -o $@
|
||||
|
||||
-include obj/drv/driver-linux.d
|
||||
|
||||
endif
|
||||
g++ $(OPT) -Wall -fvisibility=hidden -std=c++17 -I./ext -I./src/drv -c -MMD $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f main.exe main obj/*/*.*
|
||||
rm -f main.exe main obj/core/*.* obj/drv/*.* obj/eris/*.*
|
||||
|
||||
-include $(OBJ_ERIS:%.o=%.d)
|
||||
-include $(OBJ_CORE:%.o=%.d)
|
||||
-include $(OBJ_DRV:%.o=%.d)
|
||||
|
||||
-include $(OBJ_ERIS:%.o=%.d)
|
||||
|
||||
|
||||
@@ -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_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user