Fix macros

\nWe could use __VA_OPT__(,), but this is for a very new version of GCC

FossilOrigin-Name: cd18b7747d55d6251bcabad7350629303e313b0f053a06a41fa7b188969b2071
This commit is contained in:
nekobit 2022-08-24 12:36:19 +00:00
parent 06867d36f5
commit 62e782c8f7
5 changed files with 25 additions and 26 deletions

View File

@ -31,10 +31,10 @@ void redirect(REQUEST_T req, char* status, char* location)
{
char* loc_str = location ? location : "/";
FPRINTF("Status: %s\r\n"
"Location: %s\r\n\r\n"
REDIR_HTML_BEGIN "Redirecting to <a href=\"\">%s</a>..." REDIR_HTML_END,
status,
loc_str,
loc_str);
PRINTF("Status: %s\r\n"
"Location: %s\r\n\r\n"
REDIR_HTML_BEGIN "Redirecting to <a href=\"\">%s</a>..." REDIR_HTML_END,
status,
loc_str,
loc_str);
}

View File

@ -34,7 +34,7 @@ void set_config_str(FCGX_Request* req,
{
if (ssn->post.set.is_set && post->is_set && page == curr_page)
{
FPRINTF("Set-Cookie: %s=%s; HttpOnly; Path=/; Max-Age=31536000; SameSite=Strict;\r\n",
PRINTF("Set-Cookie: %s=%s; HttpOnly; Path=/; Max-Age=31536000; SameSite=Strict;\r\n",
cookie_name, keypstr(post));
}
@ -59,7 +59,7 @@ void set_config_int(FCGX_Request* req,
{
if (ssn->post.set.is_set && page == curr_page)
{
FPRINTF("Set-Cookie: %s=%d; HttpOnly; Path=/; Max-Age=31536000; SameSite=Strict;\r\n",
PRINTF("Set-Cookie: %s=%d; HttpOnly; Path=/; Max-Age=31536000; SameSite=Strict;\r\n",
cookie_name, post_bool_intp(post));
}

View File

@ -34,8 +34,8 @@
static void apply_access_token(REQUEST_T req, char* token)
{
FPRINTF("Set-Cookie: access_token=%s; Path=/; Max-Age=31536000\r\n", token);
PRINTF("Set-Cookie: logged_in=t; Path=/; Max-Age=31536000\r\n");
PRINTF("Set-Cookie: access_token=%s; Path=/; Max-Age=31536000\r\n", token);
PUT("Set-Cookie: logged_in=t; Path=/; Max-Age=31536000\r\n");
// if config_url_prefix is empty, make it root
redirect(req, REDIRECT_303, config_url_prefix &&
config_url_prefix[0] != '\0' ? config_url_prefix : "/");
@ -100,9 +100,9 @@ void content_login_oauth(PATH_ARGS)
decode_url, encode_id, urlify_redirect_url);
// Set cookie and redirect
FPRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=3153600\r\n", decode_url);
FPRINTF("Set-Cookie: client_id=%s; Path=/; Max-Age=3153600\r\n", app.client_id);
FPRINTF("Set-Cookie: client_secret=%s; Path=/; Max-Age=3153600\r\n", app.client_secret);
PRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=3153600\r\n", decode_url);
PRINTF("Set-Cookie: client_id=%s; Path=/; Max-Age=3153600\r\n", app.client_id);
PRINTF("Set-Cookie: client_secret=%s; Path=/; Max-Age=3153600\r\n", app.client_secret);
redirect(req, REDIRECT_303, url);
free(url);
@ -185,10 +185,10 @@ void content_login(PATH_ARGS)
}
else {
if (url_link)
FPRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=31536000\r\n", url_link);
PRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=31536000\r\n", url_link);
else
// Clear
PRINTF("Set-Cookie: instance_url=; Path=/; Max-Age=-1\r\n");
PUT("Set-Cookie: instance_url=; Path=/; Max-Age=-1\r\n");
apply_access_token(req, token.access_token);
free(url_link);

View File

@ -20,13 +20,12 @@
#define REQUEST_H
#ifdef SINGLE_THREADED
#define FPRINTF(str, ...) fprintf(str, __VA_ARGS__)
#define PRINTF(str) puts(str)
#define PRINTF(str, ...) printf(str, __VA_ARGS__)
#define PUT(str) printf(str)
#define REQUEST_T void*
#else
#define FPRINTF(str, ...) FCGX_FPrintF(req->out, str, __VA_ARGS__)
// If this adds a newline (it shouldn't) then this is probably
#define PRINTF(str) FCGX_PutS(str, req->out)
#define PRINTF(str, ...) FCGX_FPrintF(req->out, str, __VA_ARGS__)
#define PUT(str) FCGX_FPrintF(req->out, str)
#define REQUEST_T FCGX_Request*
#endif

View File

@ -30,7 +30,7 @@
#include "error.h"
#include "string_helpers.h"
void content_timeline(FCGX_Request* req,
void content_timeline(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
struct mstdnt_storage* storage,
@ -78,7 +78,7 @@ void content_timeline(FCGX_Request* req,
Safefree(dup);
}
void tl_home(FCGX_Request* req, struct session* ssn, mastodont_t* api, int local)
void tl_home(REQUEST_T req, struct session* ssn, mastodont_t* api, int local)
{
struct mstdnt_args m_args = { 0 };
set_mstdnt_args(&m_args, ssn);
@ -109,7 +109,7 @@ void tl_home(FCGX_Request* req, struct session* ssn, mastodont_t* api, int local
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_HOME, NULL, 1, 0);
}
void tl_direct(FCGX_Request* req, struct session* ssn, mastodont_t* api)
void tl_direct(REQUEST_T req, struct session* ssn, mastodont_t* api)
{
struct mstdnt_args m_args = { 0 };
set_mstdnt_args(&m_args, ssn);
@ -137,7 +137,7 @@ void tl_direct(FCGX_Request* req, struct session* ssn, mastodont_t* api)
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_DIRECT, "Direct", 0, 0);
}
void tl_public(FCGX_Request* req, struct session* ssn, mastodont_t* api, int local, enum base_category cat)
void tl_public(REQUEST_T req, struct session* ssn, mastodont_t* api, int local, enum base_category cat)
{
struct mstdnt_args m_args = { 0 };
set_mstdnt_args(&m_args, ssn);
@ -167,7 +167,7 @@ void tl_public(FCGX_Request* req, struct session* ssn, mastodont_t* api, int loc
content_timeline(req, ssn, api, &storage, statuses, statuses_len, cat, NULL, 1, 0);
}
void tl_list(FCGX_Request* req, struct session* ssn, mastodont_t* api, char* list_id)
void tl_list(REQUEST_T req, struct session* ssn, mastodont_t* api, char* list_id)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
@ -195,7 +195,7 @@ void tl_list(FCGX_Request* req, struct session* ssn, mastodont_t* api, char* lis
}
void tl_tag(FCGX_Request* req, struct session* ssn, mastodont_t* api, char* tag_id)
void tl_tag(REQUEST_T req, struct session* ssn, mastodont_t* api, char* tag_id)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);