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