2019-04-20 04:47:53 +02:00
|
|
|
/* This file is part of gitea2rss.
|
2020-10-24 16:59:41 +02:00
|
|
|
* Copyright © 2019, 2020 tastytea <tastytea@tastytea.de>
|
2019-04-20 04:47:53 +02:00
|
|
|
*
|
|
|
|
* 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 GITEA2RSS_HPP
|
|
|
|
#define GITEA2RSS_HPP
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <cstdint>
|
2020-10-24 16:59:41 +02:00
|
|
|
#include <ctime>
|
|
|
|
#include <string>
|
2019-04-20 04:47:53 +02:00
|
|
|
|
2020-10-27 12:05:50 +01:00
|
|
|
namespace gitea2rss
|
|
|
|
{
|
|
|
|
|
2019-04-20 04:47:53 +02:00
|
|
|
using std::string;
|
|
|
|
using std::uint8_t;
|
2020-10-24 16:59:41 +02:00
|
|
|
using std::chrono::system_clock;
|
2019-04-20 04:47:53 +02:00
|
|
|
|
|
|
|
extern bool cgi;
|
|
|
|
|
|
|
|
//! Fetch HTTP document.
|
2020-10-24 16:59:41 +02:00
|
|
|
string get_http(const string &url);
|
|
|
|
|
|
|
|
// CURL receive function.
|
|
|
|
size_t writer_body(char *data, size_t size, size_t nmemb);
|
2019-04-20 04:47:53 +02:00
|
|
|
|
|
|
|
//! Convert time_point to RFC 822 compliant time string.
|
2020-10-27 12:05:50 +01:00
|
|
|
string strtime(const system_clock::time_point &timepoint);
|
2019-04-20 04:47:53 +02:00
|
|
|
|
|
|
|
//! Convert ISO 8601 time string to RFC 822 time string.
|
2020-10-27 12:05:50 +01:00
|
|
|
string strtime(const string &time);
|
2019-04-20 04:47:53 +02:00
|
|
|
|
|
|
|
//! Write line of XML.
|
2020-10-24 16:59:41 +02:00
|
|
|
void write_line(uint8_t spaces, const string &tag, const string &value);
|
2019-04-20 04:47:53 +02:00
|
|
|
|
2019-04-20 10:00:15 +02:00
|
|
|
//! Write the RSS preamble and channel data.
|
|
|
|
void write_preamble(const string &url, const string &type);
|
|
|
|
|
2019-04-20 05:15:30 +02:00
|
|
|
//! Write releases.
|
2019-04-20 07:43:23 +02:00
|
|
|
uint8_t write_releases(const string &url);
|
|
|
|
|
|
|
|
//! Write tags.
|
|
|
|
uint8_t write_tags(const string &url);
|
2019-04-20 05:15:30 +02:00
|
|
|
|
2019-04-20 05:39:52 +02:00
|
|
|
//! @brief Get the base URL, without trailing slash.
|
2020-10-27 12:05:50 +01:00
|
|
|
string get_baseurl(const string &url);
|
2019-04-20 05:15:30 +02:00
|
|
|
|
2019-04-20 05:39:52 +02:00
|
|
|
//! Get the domain name.
|
2020-10-27 12:05:50 +01:00
|
|
|
string get_domain(const string &url);
|
2019-04-20 05:15:30 +02:00
|
|
|
|
2019-04-20 05:39:52 +02:00
|
|
|
//! Get the full name of the repo (user/project).
|
2020-10-27 12:05:50 +01:00
|
|
|
string get_repo(const string &url);
|
2019-04-20 05:15:30 +02:00
|
|
|
|
2019-04-20 05:39:52 +02:00
|
|
|
//! Get the project name.
|
2020-10-27 12:05:50 +01:00
|
|
|
string get_project(const string &url);
|
2019-04-20 05:15:30 +02:00
|
|
|
|
2019-04-22 08:28:10 +02:00
|
|
|
//! Escape some characters to named HTML entities.
|
2020-10-27 12:05:50 +01:00
|
|
|
string escape_some_html(string html);
|
2019-04-22 08:28:10 +02:00
|
|
|
|
2020-10-24 16:59:41 +02:00
|
|
|
//! Return environment variable or "" if it is not set.
|
|
|
|
string get_env_var(const string &variable);
|
|
|
|
|
2020-10-27 12:05:50 +01:00
|
|
|
} // namespace gitea2rss
|
|
|
|
|
2020-10-24 16:59:41 +02:00
|
|
|
#endif // GITEA2RSS_HPP
|