repertory/include/common.hpp
Scott E. Graves dd4724e374
Some checks failed
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head There was a failure building this commit
refactor
2023-12-10 19:40:38 -06:00

211 lines
5.6 KiB
C++

/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_COMMON_HPP_
#define INCLUDE_COMMON_HPP_
#if defined(__GNUC__)
// clang-format off
#define REPERTORY_IGNORE_WARNINGS_ENABLE() \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wconversion\"") \
_Pragma("GCC diagnostic ignored \"-Wdouble-promotion\"") \
_Pragma("GCC diagnostic ignored \"-Wduplicated-branches\"") \
_Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") \
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \
_Pragma("GCC diagnostic ignored \"-Wnull-dereference\"") \
_Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") \
_Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"") \
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
_Pragma("GCC diagnostic ignored \"-Wuseless-cast\"")
#define REPERTORY_IGNORE_WARNINGS_DISABLE() \
_Pragma("GCC diagnostic pop")
#else
#define REPERTORY_IGNORE_WARNINGS_ENABLE()
#define REPERTORY_IGNORE_WARNINGS_DISABLE()
#endif // defined(__GNUC__)
// clang-format on
#ifdef __cplusplus
REPERTORY_IGNORE_WARNINGS_ENABLE()
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <ciso646>
#include <direct.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>
#else
#include <climits>
#include <dirent.h>
#include <fcntl.h>
#include <grp.h>
#include <libgen.h>
#include <pwd.h>
#include <sys/file.h>
#include <sys/stat.h>
#ifdef __linux__
#include <sys/statfs.h>
#endif
#include <unistd.h>
#ifdef HAS_SETXATTR
#include <sys/types.h>
#include <sys/xattr.h>
#endif
#ifdef __APPLE__
#include <libproc.h>
#include <sys/attr.h>
#include <sys/vnode.h>
#endif
#if __APPLE__
#include <sys/mount.h>
#include <sys/statvfs.h>
#endif
#endif
#include <algorithm>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <deque>
#include <filesystem>
#include <fstream>
#include <future>
#include <iomanip>
#include <iostream>
#include <limits>
#include <mutex>
#include <optional>
#include <random>
#include <sstream>
#include <string>
#include <string_view>
#include <thread>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <sodium.h>
template <typename data_type>
[[nodiscard]] inline auto repertory_rand() -> data_type {
data_type ret{};
randombytes_buf(&ret, sizeof(ret));
return ret;
}
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/asio.hpp>
#include <boost/bind/bind.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/dynamic_bitset/serialization.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/serialization/vector.hpp>
#include <curl/curl.h>
#include <curl/multi.h>
#include <json.hpp>
#include <sqlite3.h>
#include <stduuid.h>
#ifdef _WIN32
#include <sddl.h>
#include <winfsp/winfsp.hpp>
#else
#if FUSE_USE_VERSION >= 30
#include <fuse.h>
#include <fuse_lowlevel.h>
#else
#include <fuse/fuse.h>
#endif
#endif
#include <pugixml.hpp>
#define CPPHTTPLIB_TCP_NODELAY true
#define CPPHTTPLIB_OPENSSL_SUPPORT
#include <httplib.h>
using json = nlohmann::json;
using namespace std::chrono_literals;
REPERTORY_IGNORE_WARNINGS_DISABLE()
#ifdef _WIN32
#ifdef CreateDirectory
#undef CreateDirectory
#endif
#ifdef CreateFile
#undef CreateFile
#endif
#ifdef DeleteFile
#undef DeleteFile
#endif
#ifdef RemoveDirectory
#undef RemoveDirectory
#endif
#ifndef _SH_DENYRW
#define _SH_DENYRW 0x10 // deny read/write mode
#endif
#ifndef _SH_DENYWR
#define _SH_DENYWR 0x20 // deny write mode
#endif
#ifndef _SH_DENYRD
#define _SH_DENYRD 0x30 // deny read mode
#endif
#ifndef _SH_DENYNO
#define _SH_DENYNO 0x40 // deny none mode
#endif
#ifndef _SH_SECURE
#define _SH_SECURE 0x80 // secure mode
#endif
#endif
#ifndef ENETDOWN
#define ENETDOWN 100
#endif
namespace repertory {
auto get_repertory_git_revision() -> const std::string &;
auto get_repertory_version() -> const std::string &;
void repertory_init();
void repertory_shutdown();
} // namespace repertory
#endif // __cplusplus
#endif // INCLUDE_COMMON_HPP_