summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-21 23:17:58 +0200
committerGravatar default2023-04-21 23:17:58 +0200
commit526d4e8abb27127625a228796dc9c196efcfa8bf (patch)
tree76a5c05240474df1fdfc5902bdb0fe6d70cdd203
parentMerge branch 'master' of /home/angel/git/snac2 (diff)
downloadpenes-snac2-526d4e8abb27127625a228796dc9c196efcfa8bf.tar.gz
penes-snac2-526d4e8abb27127625a228796dc9c196efcfa8bf.tar.xz
penes-snac2-526d4e8abb27127625a228796dc9c196efcfa8bf.zip
Added a new compilation variable NO_MASTODON_API.
The Mastodon API is a big and ugly beast; if you don't want it in your snac, you can compile it out by running make CFLAGS=-DNO_MASTODON_API And your snac binary will be as slim as always.
-rw-r--r--httpd.c5
-rw-r--r--mastoapi.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/httpd.c b/httpd.c
index 11f2c28..3168323 100644
--- a/httpd.c
+++ b/httpd.c
@@ -183,17 +183,21 @@ void httpd_connection(FILE *f)
183 if (status == 0) 183 if (status == 0)
184 status = activitypub_get_handler(req, q_path, &body, &b_size, &ctype); 184 status = activitypub_get_handler(req, q_path, &body, &b_size, &ctype);
185 185
186#ifndef NO_MASTODON_API
186 if (status == 0) 187 if (status == 0)
187 status = oauth_get_handler(req, q_path, &body, &b_size, &ctype); 188 status = oauth_get_handler(req, q_path, &body, &b_size, &ctype);
188 189
189 if (status == 0) 190 if (status == 0)
190 status = mastoapi_get_handler(req, q_path, &body, &b_size, &ctype); 191 status = mastoapi_get_handler(req, q_path, &body, &b_size, &ctype);
192#endif /* NO_MASTODON_API */
191 193
192 if (status == 0) 194 if (status == 0)
193 status = html_get_handler(req, q_path, &body, &b_size, &ctype); 195 status = html_get_handler(req, q_path, &body, &b_size, &ctype);
194 } 196 }
195 else 197 else
196 if (strcmp(method, "POST") == 0) { 198 if (strcmp(method, "POST") == 0) {
199
200#ifndef NO_MASTODON_API
197 if (status == 0) 201 if (status == 0)
198 status = oauth_post_handler(req, q_path, 202 status = oauth_post_handler(req, q_path,
199 payload, p_size, &body, &b_size, &ctype); 203 payload, p_size, &body, &b_size, &ctype);
@@ -201,6 +205,7 @@ void httpd_connection(FILE *f)
201 if (status == 0) 205 if (status == 0)
202 status = mastoapi_post_handler(req, q_path, 206 status = mastoapi_post_handler(req, q_path,
203 payload, p_size, &body, &b_size, &ctype); 207 payload, p_size, &body, &b_size, &ctype);
208#endif
204 209
205 if (status == 0) 210 if (status == 0)
206 status = activitypub_post_handler(req, q_path, 211 status = activitypub_post_handler(req, q_path,
diff --git a/mastoapi.c b/mastoapi.c
index 6e5fe09..3858e13 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1,6 +1,8 @@
1/* snac - A simple, minimalistic ActivityPub instance */ 1/* snac - A simple, minimalistic ActivityPub instance */
2/* copyright (c) 2022 - 2023 grunfink / MIT license */ 2/* copyright (c) 2022 - 2023 grunfink / MIT license */
3 3
4#ifndef NO_MASTODON_API
5
4#include "xs.h" 6#include "xs.h"
5#include "xs_encdec.h" 7#include "xs_encdec.h"
6#include "xs_openssl.h" 8#include "xs_openssl.h"
@@ -1453,3 +1455,5 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
1453 1455
1454 return status; 1456 return status;
1455} 1457}
1458
1459#endif /* #ifndef NO_MASTODON_API */