You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

82 lines
1.6 KiB

#include <ranges>
#include <stack>
#include <unordered_map>
#include <vector>
#include <string>
#include <filesystem>
#include <spdlog/spdlog.h>
#include <iostream>
#include <fstream>
#include <sstream>
namespace fs = std::filesystem;
#include <chrono>
#include <cstdlib>
#include <date.h>
#ifndef UTIL_H
#define UTIL_H
#define STUPID_BREAKPOINT do {*(int *)0 = 1} while (0);
std::string
file_ext(std::string path);
template <typename TP>
std::time_t to_time_t(TP tp)
{
using namespace std::chrono;
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now()
+ system_clock::now());
return system_clock::to_time_t(sctp);
}
std::string trim_whitespace(std::string s);
std::string read_file(std::string const &fpath);
void write_file(std::string const &fpath, std::string const &content);
std::string
reformat_date(const std::string& date_time, const std::unordered_map<std::string, std::string> &properties);
namespace stgen {
fs::path
compute_target(fs::path fpath, std::unordered_map<std::string, std::string> &properties);
std::string
compute_url(fs::path path, std::unordered_map<std::string, std::string> properties);
};
namespace darkhttpd {
extern "C" {
int darkhttpd_main(int argc, const char **argv);
static void stop_running(int sig);
}
};
class server {
int spid = 0;
public:
void serve_now(std::string wroot,std::string port,std::string addr);
void stop_serving();
~server();
};
class pathHash {
public:
size_t operator()(const fs::path &k) const{
return std::hash<std::string>{}(k.string());
}
};
#endif