New function purge_all().

This commit is contained in:
default 2022-10-17 11:00:34 +02:00
parent 2efdcaae05
commit 3462ecc950
3 changed files with 23 additions and 12 deletions

21
data.c
View File

@ -1055,3 +1055,24 @@ void purge(snac *snac)
} }
} }
} }
void purge_all(void)
/* purge all users */
{
snac snac;
xs *list = user_list();
char *p, *uid;
srv_debug(1, xs_fmt("purge start"));
p = list;
while (xs_list_iter(&p, &uid)) {
if (user_open(&snac, uid)) {
purge(&snac);
user_free(&snac);
}
}
srv_debug(1, xs_fmt("purge end"));
}

13
main.c
View File

@ -97,18 +97,7 @@ int main(int argc, char *argv[])
} }
if (strcmp(cmd, "purge") == 0) { if (strcmp(cmd, "purge") == 0) {
/* iterate all users */ purge_all();
xs *list = user_list();
char *p, *uid;
p = list;
while (xs_list_iter(&p, &uid)) {
if (user_open(&snac, uid)) {
purge(&snac);
user_free(&snac);
}
}
return 0; return 0;
} }

1
snac.h
View File

@ -96,6 +96,7 @@ d_char *queue(snac *snac);
d_char *dequeue(snac *snac, char *fn); d_char *dequeue(snac *snac, char *fn);
void purge(snac *snac); void purge(snac *snac);
void purge_all(void);
d_char *http_signed_request(snac *snac, char *method, char *url, d_char *http_signed_request(snac *snac, char *method, char *url,
d_char *headers, d_char *headers,