libravatarserv/src/libravatarserv.hpp

81 lines
1.9 KiB
C++

/* 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
#if __cplusplus >= 201703L
#include <filesystem>
#else
#include <experimental/filesystem>
#endif
#include <string>
#include <map>
#include <Magick++.h>
#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;
int main();
bool find_avatar_dir();
namespace global
{
extern fs::path avatar_dir;
}
namespace http // http.cpp
{
struct Request
{
const string digest;
const uint16_t size;
const string fallback;
};
const Request parse_request(const string &request);
const string get_parameter(const string &request, const string &parameter);
}
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();
}
namespace image // image.cpp
{
struct Image
{
uint8_t error;
Magick::Image image;
};
const Image get(const string &digest, const uint16_t size);
void write(Image &image);
}
#endif // LIBRAVATARSERV_HPP