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