-/*
- * Inbox handling rules
- *
- * Copyright (c) 1987-2020 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+// Inbox handling rules
+//
+// Copyright (c) 1987-2022 by the citadel.org team
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
#include "sysdep.h"
#include <stdlib.h>
#include <pwd.h>
#include <errno.h>
#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
+#include <time.h>
#include <sys/wait.h>
#include <string.h>
#include <limits.h>
#include "ctdl_module.h"
-/*
- * The next sections are enums and keys that drive the serialize/deserialize functions for the inbox rules/state configuration.
- */
+// The next sections are enums and keys that drive the serialize/deserialize functions for the inbox rules/state configuration.
// Fields to be compared
enum {
return NULL;
}
- /* Make a copy of the supplied buffer because we're going to shit all over it with strtok_r() */
+ // Make a copy of the supplied buffer because we're going to shit all over it with strtok_r()
char *sr = strdup(serialized_rules);
if (!sr) {
return NULL;
while ((token = strtok_r(rest, "\n", &rest))) {
// For backwards compatibility, "# WEBCIT_RULE" is an alias for "rule".
- // Prior to version 930, WebCit converted its rules to Sieve scripts, but saved the rules as comments for later re-editing.
- // Now, the rules hidden in the comments become the real rules.
+ // Prior to version 930, WebCit converted its rules to Sieve scripts, but saved the rules as comments for
+ // later re-editing. Now, the rules hidden in the comments become the real rules.
if (!strncasecmp(token, "# WEBCIT_RULE|", 14)) {
strcpy(token, "rule|");
strcpy(&token[5], &token[14]);
// We have a rule , now parse it
char rtoken[SIZ];
int nt = num_tokens(decoded_rule, '|');
- for (int t=0; t<nt; ++t) {
+ int t = 0;
+ for (t=0; t<nt; ++t) {
extract_token(rtoken, decoded_rule, t, '|', sizeof(rtoken));
striplt(rtoken);
switch(t) {
return(1); // don't delete the inbox copy if this failed
}
- recptypes *valid = validate_recipients(rule->redirect_to, NULL, 0);
+ struct recptypes *valid = validate_recipients(rule->redirect_to, NULL, 0);
if (valid == NULL) {
syslog(LOG_WARNING, "inboxrules: inbox_do_redirect() invalid recipient <%s>", rule->redirect_to);
return(1); // don't delete the inbox copy if this failed
return(1); // don't delete the inbox copy if this failed
}
- CtdlSubmitMsg(msg, valid, NULL, 0); // send the message to the new recipient
+ CtdlSubmitMsg(msg, valid, NULL); // send the message to the new recipient
free_recipients(valid);
CM_Free(msg);
return(0); // delete the inbox copy
}
-/*
- * Perform the "reject" action (delete the message, and tell the sender we deleted it)
- */
+// Perform the "reject" action (delete the message, and tell the sender we deleted it)
void inbox_do_reject(struct irule *rule, struct CtdlMessage *msg) {
syslog(LOG_DEBUG, "inbox_do_reject: sender: <%s>, reject", msg->cm_fields[erFc822Addr]);
// Deliver the message
quickie_message(
- NULL,
+ " ",
msg->cm_fields[eenVelopeTo],
sender,
- NULL,
+ MAILROOM,
reject_text,
FMT_RFC822,
"Delivery status notification"
}
-/*
- * Perform the "vacation" action (send an automatic response)
- */
+// Perform the "vacation" action (send an automatic response)
void inbox_do_vacation(struct irule *rule, struct CtdlMessage *msg) {
syslog(LOG_DEBUG, "inbox_do_vacation: sender: <%s>, vacation", msg->cm_fields[erFc822Addr]);
// Deliver the auto-reply.
quickie_message(
- NULL,
+ "",
msg->cm_fields[eenVelopeTo],
sender,
- NULL,
+ MAILROOM,
ChrPtr(reject_text),
FMT_RFC822,
"Delivery status notification"
* Perform inbox processing for all rooms which require it
*/
void perform_inbox_processing(void) {
+ int i = 0;
+
if (num_urip == 0) {
return; // no action required
}
- for (int i=0; i<num_urip; ++i) {
+ for (i=0; i<num_urip; ++i) {
do_inbox_processing_for_user(users_requiring_inbox_processing[i]);
}
* If it's someone's inbox, we have to check for inbox rules
*/
int serv_inboxrules_roomhook(struct ctdlroom *room) {
+ int i = 0;
// Is this someone's inbox?
if (!strcasecmp(&room->QRname[11], MAILROOM)) {
// first check to see if this user is already on the list
if (num_urip > 0) {
- for (int i=0; i<=num_urip; ++i) {
+ for (i=0; i<=num_urip; ++i) {
if (users_requiring_inbox_processing[i] == usernum) { // already on the list!
return(0);
}