Fix FreeBSD compilation
This commit is contained in:
parent
319bc9e436
commit
4be3dfcd77
|
@ -32,6 +32,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
list(APPEND COMMON_LIBRARIES "stdc++fs")
|
||||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
|
||||
# Usenetsearch common library --------------------------------------------------
|
||||
|
||||
add_library(usenetsearch
|
||||
|
@ -60,7 +65,7 @@ target_include_directories(usenetsearch
|
|||
)
|
||||
|
||||
target_link_libraries(usenetsearch
|
||||
PUBLIC ${OPENSSL_LIBRARIES} stdc++fs
|
||||
PUBLIC ${OPENSSL_LIBRARIES} ${COMMON_LIBRARIES}
|
||||
)
|
||||
|
||||
# Indexer executable -----------------------------------------------------------
|
||||
|
@ -70,7 +75,7 @@ add_executable(usenetindexd
|
|||
)
|
||||
|
||||
target_link_libraries(usenetindexd
|
||||
PUBLIC ${OPENSSL_LIBRARIES} stdc++fs
|
||||
PUBLIC ${OPENSSL_LIBRARIES} ${COMMON_LIBRARIES}
|
||||
PRIVATE usenetsearch
|
||||
)
|
||||
|
||||
|
@ -86,7 +91,7 @@ add_executable(usenetfind
|
|||
)
|
||||
|
||||
target_link_libraries(usenetfind
|
||||
PUBLIC ${OPENSSL_LIBRARIES} stdc++fs
|
||||
PUBLIC ${OPENSSL_LIBRARIES} ${COMMON_LIBRARIES}
|
||||
PRIVATE usenetsearch
|
||||
)
|
||||
|
||||
|
@ -102,7 +107,7 @@ add_executable(dbdump
|
|||
)
|
||||
|
||||
target_link_libraries(dbdump
|
||||
PUBLIC ${OPENSSL_LIBRARIES} stdc++fs
|
||||
PUBLIC ${OPENSSL_LIBRARIES} ${COMMON_LIBRARIES}
|
||||
PRIVATE usenetsearch
|
||||
)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "usenetsearch/Serialize.h"
|
||||
#include "usenetsearch/UsenetClient.h"
|
||||
|
||||
#include <array>
|
||||
#include <codecvt>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace usenetsearch {
|
||||
|
||||
|
|
|
@ -85,8 +85,15 @@ template<typename T>
|
|||
T StringLeftTrim(const T& str)
|
||||
{
|
||||
T s = str;
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
s.erase(s.begin(),
|
||||
std::find_if(
|
||||
s.begin(),
|
||||
s.end(),
|
||||
[](char c){
|
||||
return !std::isspace(c);
|
||||
}
|
||||
)
|
||||
);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -105,10 +112,15 @@ T StringRemove(const T& subject, const T& toErase)
|
|||
template<typename T>
|
||||
T StringRightTrim(const T& str)
|
||||
{
|
||||
T s = str;
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
|
||||
s.end());
|
||||
T s(str);
|
||||
s.erase(std::find_if(
|
||||
s.rbegin(),
|
||||
s.rend(),
|
||||
[](unsigned char c){
|
||||
return !std::isspace(c);
|
||||
}
|
||||
).base(), s.end()
|
||||
);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include "usenetsearch/Logger.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <thread>
|
||||
|
||||
|
|
|
@ -127,7 +127,11 @@ void SerializableFile::Close()
|
|||
|
||||
void SerializableFile::Open(const std::string& fileName)
|
||||
{
|
||||
#ifdef __linux__
|
||||
const int flags{O_RDWR|O_NOATIME|O_CREAT};
|
||||
#else
|
||||
const int flags{O_RDWR|O_CREAT};
|
||||
#endif
|
||||
int ret = open(fileName.c_str(), flags, 0644);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
@ -22,11 +22,13 @@
|
|||
#include <openssl/md5.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <codecvt>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "usenetsearch/Dns.h"
|
||||
|
||||
#include <netinet/in.h> // sockaddr_in
|
||||
#include <sys/socket.h> // AF_INET etc...
|
||||
#include <unistd.h> // close(), read(), write()
|
||||
|
||||
#include <cerrno>
|
||||
|
|
Loading…
Reference in New Issue