diff --git a/data.c b/data.c index be58c09..0d7765c 100644 --- a/data.c +++ b/data.c @@ -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")); +} diff --git a/main.c b/main.c index db691eb..0c13819 100644 --- a/main.c +++ b/main.c @@ -97,18 +97,7 @@ int main(int argc, char *argv[]) } if (strcmp(cmd, "purge") == 0) { - /* iterate all users */ - 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); - } - } - + purge_all(); return 0; } diff --git a/snac.h b/snac.h index eacc795..b3e50b7 100644 --- a/snac.h +++ b/snac.h @@ -96,6 +96,7 @@ d_char *queue(snac *snac); d_char *dequeue(snac *snac, char *fn); void purge(snac *snac); +void purge_all(void); d_char *http_signed_request(snac *snac, char *method, char *url, d_char *headers,