libravatarserv/src/libravatarserv.hpp

94 lines
2.3 KiB
C++
Raw Permalink Normal View History

2018-11-24 11:00:07 +01:00
/* This file is part of libravatarserv.
* Copyright © 2018 tastytea <tastytea@tastytea.de>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef LIBRAVATARSERV_HPP
#define LIBRAVATARSERV_HPP
2018-11-25 06:00:45 +01:00
#if __cplusplus >= 201703L
#include <filesystem>
#else
#include <experimental/filesystem>
#endif
#include <string>
#include <map>
#include <Magick++/Image.h>
2018-11-24 11:00:07 +01:00
2018-11-25 06:00:45 +01:00
#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;
2018-11-25 06:00:45 +01:00
int main();
namespace settings
{ // settings.cpp
2018-11-25 06:00:45 +01:00
extern fs::path avatar_dir;
extern struct Settings
{
2018-11-28 14:56:15 +01:00
string default_fallback = "404";
bool redirect_nofallback = false;
bool redirect_nouser = false;
} settings;
bool find_avatar_dir();
void read_settings();
2018-11-25 06:00:45 +01:00
}
namespace http // http.cpp
{
struct Request
{
const string digest;
const int16_t size = 0;
string fallback;
};
const Request parse_request(const string &request);
2018-11-26 04:17:34 +01:00
const string get_parameter(const string &request, const string &parameter);
void send_redirect(const Request &request);
}
2018-11-25 06:00:45 +01:00
namespace hash // hash.cpp
{
extern std::map<const string, const string> table;
const string md5(const string &text);
const string sha256(const string &text);
bool fill_table();
2018-11-30 06:48:45 +01:00
bool is_valid(const string &digest);
bool not_hex(const char &c);
2018-11-25 06:00:45 +01:00
}
namespace image // image.cpp
2018-11-25 06:00:45 +01:00
{
struct Image
{
uint8_t error = 0;
2018-11-25 06:00:45 +01:00
Magick::Image image;
};
const Image get(const string &digest, const uint16_t size);
void write(Image &image);
2018-11-27 09:59:02 +01:00
Image identicon(const string &digest);
2018-11-25 06:00:45 +01:00
}
2018-11-24 11:00:07 +01:00
#endif // LIBRAVATARSERV_HPP