ref: 494b0cda3dad99e3e1076acea474cf5b19b0c1d8
parent: fd7780e65a6516f7cf68ca14a21eee0f32e40704
author: Julien Blanchard <julien@typed-hole.org>
date: Fri Mar 1 08:41:09 EST 2024
Add --debug flag
--- a/masto9.c
+++ b/masto9.c
@@ -7,6 +7,9 @@
#include "masto9.h"
+int debug_mode;
+#define dprint(...) if(debug_mode)fprint(2, __VA_ARGS__);
+
static UserPasswd *
getcredentials(char *host)
{
@@ -27,6 +30,7 @@
url = esmprint("https://%s/api/v1/%s", host, endpoint);
response = httpget(token, url);
+ dprint("mastodonget:response: %s\n", response);
if((obj = jsonparse(response)) == nil)
sysfatal("mastodonget: jsonparse: not json");
@@ -214,6 +218,7 @@
url = esmprint("https://%s/api/v1/media", host);
response = upload(token, url, filepath);
+ dprint("postattachment:response: %s\n", response);
if((obj = jsonparse(response)) == nil)
sysfatal("postattachment: jsonparse: not json");
@@ -321,6 +326,13 @@
usage();
JSONfmtinstall();
+
+ // Check for debug flag
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--debug") == 0) {
+ debug_mode = 1;
+ }
+ }
host = argv[1];
cmd = argv[2];