diff options
| author | 2025-04-18 09:12:44 +0200 | |
|---|---|---|
| committer | 2025-04-18 09:12:44 +0200 | |
| commit | 9b863605f9b0e888986b01f07c634637b5186bb6 (patch) | |
| tree | a9ec2a4cc6548ceb9bf17974501cd7cb07d24d35 /main.c | |
| parent | New command-line option 'add_to_list'. (diff) | |
| download | penes-snac2-9b863605f9b0e888986b01f07c634637b5186bb6.tar.gz penes-snac2-9b863605f9b0e888986b01f07c634637b5186bb6.tar.xz penes-snac2-9b863605f9b0e888986b01f07c634637b5186bb6.zip | |
Renamed command-line option to 'list_add' and added new 'list_del'.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 34 |
1 files changed, 31 insertions, 3 deletions
| @@ -63,7 +63,8 @@ int usage(void) | |||
| 63 | printf("list_members {basedir} {uid} {name} Returns the list of accounts inside a list\n"); | 63 | printf("list_members {basedir} {uid} {name} Returns the list of accounts inside a list\n"); |
| 64 | printf("create_list {basedir} {uid} {name} Creates a new list\n"); | 64 | printf("create_list {basedir} {uid} {name} Creates a new list\n"); |
| 65 | printf("delete_list {basedir} {uid} {name} Deletes an existing list\n"); | 65 | printf("delete_list {basedir} {uid} {name} Deletes an existing list\n"); |
| 66 | printf("add_to_list {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n"); | 66 | printf("list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n"); |
| 67 | printf("list_del {basedir} {uid} {name} {acct} Deletes an account (@user@host or actor url) from a list\n"); | ||
| 67 | 68 | ||
| 68 | return 1; | 69 | return 1; |
| 69 | } | 70 | } |
| @@ -348,7 +349,7 @@ int main(int argc, char *argv[]) | |||
| 348 | return 0; | 349 | return 0; |
| 349 | } | 350 | } |
| 350 | 351 | ||
| 351 | if (strcmp(cmd, "add_to_list") == 0) { /** **/ | 352 | if (strcmp(cmd, "list_add") == 0) { /** **/ |
| 352 | const char *account = GET_ARGV(); | 353 | const char *account = GET_ARGV(); |
| 353 | 354 | ||
| 354 | if (account != NULL) { | 355 | if (account != NULL) { |
| @@ -362,7 +363,34 @@ int main(int argc, char *argv[]) | |||
| 362 | xs *md5 = xs_md5_hex(actor, strlen(actor)); | 363 | xs *md5 = xs_md5_hex(actor, strlen(actor)); |
| 363 | 364 | ||
| 364 | list_content(&snac, lid, md5, 1); | 365 | list_content(&snac, lid, md5, 1); |
| 365 | printf("Actor %s (%s) added to list %s (%s)\n", actor, uid, url, lid); | 366 | printf("Actor %s (%s) added to list '%s' (%s)\n", actor, uid, url, lid); |
| 367 | } | ||
| 368 | else | ||
| 369 | fprintf(stderr, "Cannot resolve account '%s'\n", account); | ||
| 370 | } | ||
| 371 | else | ||
| 372 | fprintf(stderr, "Cannot find a list named '%s'\n", url); | ||
| 373 | |||
| 374 | } | ||
| 375 | |||
| 376 | return 0; | ||
| 377 | } | ||
| 378 | |||
| 379 | if (strcmp(cmd, "list_del") == 0) { /** **/ | ||
| 380 | const char *account = GET_ARGV(); | ||
| 381 | |||
| 382 | if (account != NULL) { | ||
| 383 | xs *lid = list_maint(&snac, url, 4); | ||
| 384 | |||
| 385 | if (lid != NULL) { | ||
| 386 | xs *actor = NULL; | ||
| 387 | xs *uid = NULL; | ||
| 388 | |||
| 389 | if (valid_status(webfinger_request(account, &actor, &uid))) { | ||
| 390 | xs *md5 = xs_md5_hex(actor, strlen(actor)); | ||
| 391 | |||
| 392 | list_content(&snac, lid, md5, 2); | ||
| 393 | printf("Actor %s (%s) deleted from list '%s' (%s)\n", actor, uid, url, lid); | ||
| 366 | } | 394 | } |
| 367 | else | 395 | else |
| 368 | fprintf(stderr, "Cannot resolve account '%s'\n", account); | 396 | fprintf(stderr, "Cannot resolve account '%s'\n", account); |