indent -kr -i8 -l132 on everything in webcit-ng
[citadel.git] / webcit-ng / ctdlfunctions.c
1 /*
2  * These utility functions loosely make up a Citadel protocol client library.
3  *
4  * Copyright (c) 2016-2018 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #include "webcit.h"
16
17
18 /*
19  * Delete one or more messages from the connected Citadel server.
20  * This function expects the session to already be "in" the room from which the messages will be deleted.
21  */
22 void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs)
23 {
24         int i = 0;
25         char buf[1024];
26
27         if ((c == NULL) || (msgnums == NULL) || (num_msgs < 1)) {
28                 return;
29         }
30
31         i = 0;
32         strcpy(buf, "DELE ");
33         do {
34                 sprintf(&buf[strlen(buf)], "%ld", msgnums[i]);
35                 if ((((i + 1) % 50) == 0) || (i == num_msgs - 1))       // delete up to 50 messages with one server command
36                 {
37                         syslog(LOG_DEBUG, "%s", buf);
38                         ctdl_printf(c, "%s", buf);
39                         ctdl_readline(c, buf, sizeof(buf));
40                         syslog(LOG_DEBUG, "%s", buf);
41                 } else {
42                         strcat(buf, ",");
43                 }
44         } while (++i < num_msgs);
45 }