diff options
author | default <nobody@localhost> | 2022-09-25 09:07:43 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-25 09:07:43 +0200 |
commit | 4f328eec1f428d4e87adeb4c4eaf1e81afe26913 (patch) | |
tree | a3636038d0347efb593f1bf580fbe67d3ab0bed1 /main.c | |
parent | 5792ef5d24bd58f5c74a37c43d80720c46a6758a (diff) |
Some fixes to timeline_add().
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 68 |
1 files changed, 52 insertions, 16 deletions
@@ -9,11 +9,47 @@ int usage(void) { - printf("usage:\n"); + printf("snac - A simple, minimalistic ActivityPub instance\n"); + printf("Copyright (c) 2022 grunfink - MIT license\n"); + printf("\n"); + printf("Commands:\n"); + printf("\n"); + printf("init [{basedir}] Initializes the database\n"); + printf("httpd {basedir} Starts the HTTPD daemon\n"); + printf("webfinger {basedir} {user} Queries about a @user@host or actor\n"); + printf("queue {basedir} {uid} Processes a user queue\n"); +// printf("check {basedir} [{uid}] Checks the database\n"); +// printf("purge {basedir} [{uid}] Purges old data\n"); +// printf("adduser {basedir} [{uid}] Adds a new user\n"); + +// printf("update {basedir} {uid} Sends a user update to followers\n"); +// printf("passwd {basedir} {uid} Sets the password for {uid}\n"); +// printf("follow {basedir} {uid} {actor} Follows an actor\n"); +// printf("unfollow {basedir} {uid} {actor} Unfollows an actor\n"); +// printf("mute {basedir} {uid} {actor} Mutes an actor\n"); +// printf("unmute {basedir} {uid} {actor} Unmutes an actor\n"); +// printf("like {basedir} {uid} {url} Likes an url\n"); +// printf("announce {basedir} {uid} {url} Announces (boosts) an url\n"); +// printf("note {basedir} {uid} {'text'} Sends a note to followers\n"); + + printf("request {basedir} {uid} {url} Requests an object\n"); + printf("actor {basedir} {uid} {url} Requests an actor\n"); + return 1; } +char *get_argv(int *argi, int argc, char *argv[]) +{ + if (*argi < argc) + return argv[(*argi)++]; + else + return NULL; +} + + +#define GET_ARGV() get_argv(&argi, argc, argv) + int main(int argc, char *argv[]) { char *cmd; @@ -23,21 +59,20 @@ int main(int argc, char *argv[]) int argi = 1; snac snac; - argc--; - if (argc < argi) + if ((cmd = GET_ARGV()) == NULL) return usage(); - cmd = argv[argi++]; - if (strcmp(cmd, "init") == 0) { + /* initialize the database */ + /* ... */ + basedir = GET_ARGV(); + return 0; } - if (argc < argi) + if ((basedir = GET_ARGV()) == NULL) return usage(); - basedir = argv[argi++]; - if (!srv_open(basedir)) { srv_log(xs_fmt("error opening database at %s", basedir)); return 1; @@ -48,11 +83,9 @@ int main(int argc, char *argv[]) return 0; } - if (argc < argi) + if ((user = GET_ARGV()) == NULL) return usage(); - user = argv[argi++]; - if (strcmp(cmd, "webfinger") == 0) { xs *actor = NULL; xs *uid = NULL; @@ -69,16 +102,19 @@ int main(int argc, char *argv[]) return 0; } - if (argc < argi) - return usage(); - - url = argv[argi++]; - if (!user_open(&snac, user)) { printf("error in user '%s'\n", user); return 1; } + if (strcmp(cmd, "queue") == 0) { + process_queue(&snac); + return 0; + } + + if ((url = GET_ARGV()) == NULL) + return usage(); + if (strcmp(cmd, "request") == 0) { int status; xs *data = NULL; |