aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui-stats.h
blob: 4f13dba5500f698f34578653cf5a2035dfa8c8ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef UI_STATS_H
#define UI_STATS_H

#include "cgit.h"

struct cgit_period {
	const char code;
	const char *name;
	int max_periods;
	int count;

	/* Convert a tm value to the first day in the period */
	void (*trunc)(struct tm *tm);

	/* Update tm value to start of next/previous period */
	void (*dec)(struct tm *tm);
	void (*inc)(struct tm *tm);

	/* Pretty-print a tm value */
	char *(*pretty)(struct tm *tm);
};

extern int cgit_find_stats_period(const char *expr, struct cgit_period **period);

extern void cgit_show_stats(struct cgit_context *ctx);

#endif /* UI_STATS_H */
/span>= mastodonpp; using std::cout; using std::cerr; using std::endl; using std::to_string; using std::string_view; using std::vector; int main(int argc, char *argv[]) { const vector<string_view> args(argv, argv + argc); if (args.size() <= 3) { cerr << "Usage: " << args[0] << " <instance hostname> <access token> <name>\n"; return 1; } const auto name{args[3]}; try { // Initialize an Instance and a Connection. masto::Instance instance{args[1], args[2]}; masto::Connection connection{instance}; // Update the settings. const auto answer{connection.patch( masto::API::v1::accounts_update_credentials, { {"display_name", name}, })}; if (answer) { cout << "Successfully changed display name.\n"; } else { if (answer.curl_error_code == 0) { // If it is no libcurl error, it must be an HTTP error. cerr << "HTTP status: " << answer.http_status << endl; } else { // Network errors like “Couldn't resolve host.”. cerr << "libcurl error " << to_string(answer.curl_error_code) << ": " << answer.error_message << endl; } } } catch (const masto::CURLException &e) { // Only libcurl errors that are not network errors will be thrown. // There went probably something wrong with the initialization. cerr << e.what() << endl; } return 0; }