Prepare files for public release

This commit is contained in:
2026-01-24 10:26:37 -05:00
parent 2f358c30e6
commit d89c636e2f
28 changed files with 2013 additions and 0 deletions

24
include/util/ip.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef IP_UTIL_H
#define IP_UTIL_H
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#define CLOSE_SOCKET closesocket
#pragma comment(lib, "ws2_32.lib")
typedef SOCKET socket_t;
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#define CLOSE_SOCKET close
typedef int socket_t;
#endif
bool is_valid_ipv4(const std::string &ip) {
struct in_addr addr;
return inet_pton(AF_INET, ip.c_str(), &addr) == 1;
}
#endif // IP_UTIL_H

32
include/util/log.h Normal file
View File

@@ -0,0 +1,32 @@
//
// Created by sligh on 2026-01-09.
//
#ifndef LOG_H
#define LOG_H
#define ERRBUF_SIZE 300
#include "spdlog/spdlog.h"
#ifdef _WIN32
void print_errno() {
char errbuf[ERRBUF_SIZE];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, WSAGetLastError(), 0, errbuf, sizeof(errbuf),
NULL);
spdlog::error("{}", errbuf);
}
#else
#include <errno.h>
#include <string.h>
void print_errno() {
spdlog::error("{}", strerror(errno));
}
#endif
#endif //LOG_H

23
include/util/string.h Normal file
View File

@@ -0,0 +1,23 @@
//
// Created by Johnathon Slightham on 2025-07-05.
//
#ifndef STRING_H
#define STRING_H
#include <sstream>
#include <string>
#include <vector>
inline std::vector<std::string> split(const std::string &str, const char delimiter) {
std::vector<std::string> result;
std::stringstream ss(str);
std::string token;
while (std::getline(ss, token, delimiter)) {
result.push_back(token);
}
return result;
}
#endif //STRING_H