/* This file is part of libravatarserv. * Copyright © 2018 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef LIBRAVATARSERV_HPP #define LIBRAVATARSERV_HPP #if __cplusplus >= 201703L #include #else #include #endif #include #include #include #if __cplusplus >= 201703L namespace fs = std::filesystem; #else namespace fs = std::experimental::filesystem; #endif using std::string; using std::uint16_t; using std::uint8_t; using std::int8_t; int main(); namespace settings { // settings.cpp extern fs::path avatar_dir; extern struct Settings { string default_fallback = "404"; bool redirect_nofallback = false; bool redirect_nouser = false; } settings; bool find_avatar_dir(); void read_settings(); } namespace http // http.cpp { struct Request { const string digest; const int16_t size = 0; string fallback; }; const Request parse_request(const string &request); const string get_parameter(const string &request, const string ¶meter); void send_redirect(const Request &request); } namespace hash // hash.cpp { extern std::map table; const string md5(const string &text); const string sha256(const string &text); bool fill_table(); bool is_valid(const string &digest); bool not_hex(const char &c); } namespace image // image.cpp { struct Image { uint8_t error = 0; Magick::Image image; }; const Image get(const string &digest, const uint16_t size); void write(Image &image); Image identicon(const string &digest); } #endif // LIBRAVATARSERV_HPP