new license declaration text
[citadel.git] / webcit-ng / ctdlfunctions.c
1 //
2 // These utility functions loosely make up a Citadel protocol client library.
3 //
4 // Copyright (c) 2016-2022 by the citadel.org team
5 //
6 // This program is open source software.  Use, duplication, or
7 // disclosure are subject to the GNU General Public License v3.
8
9 #include "webcit.h"
10
11 // Delete one or more messages from the connected Citadel server.
12 // This function expects the session to already be "in" the room from which the messages will be deleted.
13 void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs) {
14         int i = 0;
15         char buf[1024];
16
17         if ((c == NULL) || (msgnums == NULL) || (num_msgs < 1)) {
18                 return;
19         }
20
21         i = 0;
22         strcpy(buf, "DELE ");
23         do {
24                 sprintf(&buf[strlen(buf)], "%ld", msgnums[i]);
25                 if ((((i + 1) % 50) == 0) || (i == num_msgs - 1))       // delete up to 50 messages with one server command
26                 {
27                         syslog(LOG_DEBUG, "%s", buf);
28                         ctdl_printf(c, "%s", buf);
29                         ctdl_readline(c, buf, sizeof(buf));
30                         syslog(LOG_DEBUG, "%s", buf);
31                 }
32                 else {
33                         strcat(buf, ",");
34                 }
35         } while (++i < num_msgs);
36 }