We no longer need to copy recipients_in to recipients, because we no longer
destructively tokenize it. Now we non-destructively tokenize it into an array.
Also I discovered that there is an unused parameter in that call. Removed it
and the one place where it was being non-functionally called.
//
// Copyright (c) 1987-2024 by the citadel.org team
//
//
// Copyright (c) 1987-2024 by the citadel.org team
//
-// This program is open source software. Use, duplication, or disclosure
-// is subject to the terms of the GNU General Public License, version 3.
+// This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License version 3.
#include "sysdep.h"
#include <stdlib.h>
#include "sysdep.h"
#include <stdlib.h>
//
// Caller needs to free the result using free_recipients()
//
//
// Caller needs to free the result using free_recipients()
//
-struct recptypes *validate_recipients(char *supplied_recipients, const char *RemoteIdentifier, int Flags) {
+struct recptypes *validate_recipients(char *recipients_in, const char *REMOVE_THIS_UNUSED_VARIABLE, int Flags) {
- char *recipients = NULL;
char append[SIZ];
long len;
int mailtype;
char append[SIZ];
long len;
int mailtype;
if (ret == NULL) return(NULL);
memset(ret, 0, sizeof(struct recptypes)); // set all values to null/zero
if (ret == NULL) return(NULL);
memset(ret, 0, sizeof(struct recptypes)); // set all values to null/zero
- if (supplied_recipients == NULL) {
- recipients = strdup("");
- }
- else {
- recipients = strdup(supplied_recipients);
- }
-
- len = strlen(recipients) + 1024; // allocate memory
+ len = strlen(recipients_in) + 1024; // allocate memory
ret->errormsg = malloc(len);
ret->recp_local = malloc(len);
ret->recp_internet = malloc(len);
ret->errormsg = malloc(len);
ret->recp_local = malloc(len);
ret->recp_internet = malloc(len);
ret->display_recp[0] = 0;
ret->recptypes_magic = RECPTYPES_MAGIC;
ret->display_recp[0] = 0;
ret->recptypes_magic = RECPTYPES_MAGIC;
- Array *recp_array = split_recps(supplied_recipients, NULL);
+ Array *recp_array = split_recps(recipients_in, NULL);
char *aliases = CtdlGetSysConfig(GLOBAL_ALIASES); // First hit the Global Alias Table
char *aliases = CtdlGetSysConfig(GLOBAL_ALIASES); // First hit the Global Alias Table
ret->num_local, ret->num_room, ret->num_internet, ret->num_error
);
ret->num_local, ret->num_room, ret->num_internet, ret->num_error
);
if (recp_array) {
array_free(recp_array);
}
if (recp_array) {
array_free(recp_array);
}
// message included in the specified range.
//
// Set is_uid to 1 to fetch by UID instead of sequence number.
// message included in the specified range.
//
// Set is_uid to 1 to fetch by UID instead of sequence number.
-void imap_pick_range(const char *supplied_range, int is_uid) {
+void imap_pick_range(const char *range_in, int is_uid) {
citimap *Imap = IMAP;
int i;
int num_sets;
int s;
char setstr[SIZ], lostr[SIZ], histr[SIZ];
long lo, hi;
citimap *Imap = IMAP;
int i;
int num_sets;
int s;
char setstr[SIZ], lostr[SIZ], histr[SIZ];
long lo, hi;
- char actual_range[SIZ];
// Handle the "ALL" macro
// Handle the "ALL" macro
- if (!strcasecmp(supplied_range, "ALL")) {
- safestrncpy(actual_range, "1:*", sizeof actual_range);
+ if (!strcasecmp(range_in, "ALL")) {
+ safestrncpy(range, "1:*", sizeof range);
- safestrncpy(actual_range, supplied_range, sizeof actual_range);
+ safestrncpy(range, range_in, sizeof range);
}
// Clear out the IMAP_SELECTED flags for all messages.
}
// Clear out the IMAP_SELECTED flags for all messages.
}
// Now set it for all specified messages.
}
// Now set it for all specified messages.
- num_sets = num_tokens(actual_range, ',');
+ num_sets = num_tokens(range, ',');
for (s=0; s<num_sets; ++s) {
for (s=0; s<num_sets; ++s) {
- extract_token(setstr, actual_range, s, ',', sizeof setstr);
+ extract_token(setstr, range, s, ',', sizeof setstr);
extract_token(lostr, setstr, 0, ':', sizeof lostr);
if (num_tokens(setstr, ':') >= 2) {
extract_token(lostr, setstr, 0, ':', sizeof lostr);
if (num_tokens(setstr, ':') >= 2) {
-/*
- * Implements IMAP's gratuitously complex SEARCH command.
- *
- * Copyright (c) 2001-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.
- */
+// Implements IMAP's gratuitously complex SEARCH command.
+//
+// Copyright (c) 2001-2024 by the citadel.org team
+//
+// This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License v3.
#include "../../ctdl_module.h"
#include "../../sysdep.h"
#include "../../ctdl_module.h"
#include "../../sysdep.h"
* message after it has been fetched from the disk. This function returns
* nonzero if there is a match.
*
* message after it has been fetched from the disk. This function returns
* nonzero if there is a match.
*
- * supplied_msg MAY be used to pass a pointer to the message in memory,
+ * msg_in MAY be used to pass a pointer to the message in memory,
* if for some reason it's already been loaded. If not, the message will
* be loaded only if one or more search criteria require it.
*/
* if for some reason it's already been loaded. If not, the message will
* be loaded only if one or more search criteria require it.
*/
-int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg,
+int imap_do_search_msg(int seq, struct CtdlMessage *msg_in,
int num_items, ConstStr *itemlist, int is_uid) {
citimap *Imap = IMAP;
int num_items, ConstStr *itemlist, int is_uid) {
citimap *Imap = IMAP;
if (num_items == 0) {
return(0);
}
if (num_items == 0) {
return(0);
}
/* Initially we start at the beginning. */
pos = 0;
/* Initially we start at the beginning. */
pos = 0;
const char *smtp_get_Recipients(void) {
struct citsmtp *sSMTP = SMTP;
const char *smtp_get_Recipients(void) {
struct citsmtp *sSMTP = SMTP;
else return ChrPtr(sSMTP->from);
}
else return ChrPtr(sSMTP->from);
}
int num_bounces = 0;
int bounce_this = 0;
struct CtdlMessage *bmsg = NULL;
int num_bounces = 0;
int bounce_this = 0;
struct CtdlMessage *bmsg = NULL;
- struct recptypes *valid;
int successful_bounce = 0;
static int seq = 0;
StrBuf *BounceMB;
int successful_bounce = 0;
static int seq = 0;
StrBuf *BounceMB;
else {
syslog(LOG_DEBUG, "bounce to user <%s>", bounceto);
}
else {
syslog(LOG_DEBUG, "bounce to user <%s>", bounceto);
}
- /* Can we deliver the bounce to the original sender? */
- valid = validate_recipients(bounceto, smtp_get_Recipients (), 0);
- if (valid != NULL) {
- if (valid->num_error == 0) {
- CtdlSubmitMsg(bmsg, valid, "");
- successful_bounce = 1;
- }
- }
/* If not, post it in the Aide> room */
if (successful_bounce == 0) {
CtdlSubmitMsg(bmsg, NULL, CtdlGetConfigStr("c_aideroom"));
}
/* If not, post it in the Aide> room */
if (successful_bounce == 0) {
CtdlSubmitMsg(bmsg, NULL, CtdlGetConfigStr("c_aideroom"));
}
- /* Free up the memory we used */
- if (valid != NULL) {
- free_recipients(valid);
- }
}
FreeStrBuf(&boundary);
CM_Free(bmsg);
}
FreeStrBuf(&boundary);
CM_Free(bmsg);
// (Returns 0 for success, nonzero for failure)
// roomname may be NULL to use the current room
//
// (Returns 0 for success, nonzero for failure)
// roomname may be NULL to use the current room
//
-// Note that the 'supplied_msg' field may be set to NULL, in which case
+// Note that the 'msg_in' field may be set to NULL, in which case
// the message will be fetched from disk, by number, if we need to perform
// replication checks. This adds an additional database read, so if the
// caller already has the message in memory then it should be supplied. (Obviously
// this mode of operation only works if we're saving a single message.)
//
int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
// the message will be fetched from disk, by number, if we need to perform
// replication checks. This adds an additional database read, so if the
// caller already has the message in memory then it should be supplied. (Obviously
// this mode of operation only works if we're saving a single message.)
//
int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
- int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj
+ int do_repl_check, struct CtdlMessage *msg_in, int suppress_refcount_adj
) {
int i, j, unique;
char hold_rm[ROOMNAMELEN];
) {
int i, j, unique;
char hold_rm[ROOMNAMELEN];
// Sanity checks
if (newmsgidlist == NULL) return(ERROR + INTERNAL_ERROR);
if (num_newmsgs < 1) return(ERROR + INTERNAL_ERROR);
// Sanity checks
if (newmsgidlist == NULL) return(ERROR + INTERNAL_ERROR);
if (num_newmsgs < 1) return(ERROR + INTERNAL_ERROR);
- if (num_newmsgs > 1) supplied_msg = NULL;
+ if (num_newmsgs > 1) msg_in = NULL;
// Now the regular stuff
if (CtdlGetRoomLock(&CC->room, ((roomname != NULL) ? roomname : CC->room.QRname) ) != 0) {
// Now the regular stuff
if (CtdlGetRoomLock(&CC->room, ((roomname != NULL) ? roomname : CC->room.QRname) ) != 0) {
for (i=0; i<num_msgs_to_be_merged; ++i) {
msgid = msgs_to_be_merged[i];
for (i=0; i<num_msgs_to_be_merged; ++i) {
msgid = msgs_to_be_merged[i];
- if (supplied_msg != NULL) {
- msg = supplied_msg;
+ if (msg_in != NULL) {
+ msg = msg_in;
}
else {
msg = CtdlFetchMessage(msgid, 0);
}
else {
msg = CtdlFetchMessage(msgid, 0);
}
// Free up the memory we may have allocated
}
// Free up the memory we may have allocated
- if (msg != supplied_msg) {
// This is the same as CtdlSaveMsgPointersInRoom() but it only accepts a single message.
// This is the same as CtdlSaveMsgPointersInRoom() but it only accepts a single message.
-int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *supplied_msg) {
- return CtdlSaveMsgPointersInRoom(roomname, &msgid, 1, do_repl_check, supplied_msg, 0);
+int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg_in) {
+ return CtdlSaveMsgPointersInRoom(roomname, &msgid, 1, do_repl_check, msg_in, 0);
char *fake_name, // who we're masquerading as
char *my_email, // which of my email addresses to use (empty is ok)
char *subject, // Subject (optional)
char *fake_name, // who we're masquerading as
char *my_email, // which of my email addresses to use (empty is ok)
char *subject, // Subject (optional)
- char *supplied_euid, // ...or NULL if this is irrelevant
+ char *euid_in, // ...or NULL if this is irrelevant
char *preformatted_text, // ...or NULL to read text from client
char *references // Thread references
) {
char *preformatted_text, // ...or NULL to read text from client
char *references // Thread references
) {
(my_email)?strlen(my_email): 0,
subject, // Subject (optional)
(subject)?strlen(subject): 0,
(my_email)?strlen(my_email): 0,
subject, // Subject (optional)
(subject)?strlen(subject): 0,
- supplied_euid, // ...or NULL if this is irrelevant
- (supplied_euid)?strlen(supplied_euid):0,
+ euid_in, // ...or NULL if this is irrelevant
+ (euid_in)?strlen(euid_in):0,
preformatted_text, // ...or NULL to read text from client
(preformatted_text)?strlen(preformatted_text) : 0,
references, // Thread references
preformatted_text, // ...or NULL to read text from client
(preformatted_text)?strlen(preformatted_text) : 0,
references, // Thread references
long myelen,
char *subject, // Subject (optional)
long subjlen,
long myelen,
char *subject, // Subject (optional)
long subjlen,
- char *supplied_euid, // ...or NULL if this is irrelevant
+ char *euid_in, // ...or NULL if this is irrelevant
long euidlen,
char *preformatted_text, // ...or NULL to read text from client
long textlen,
long euidlen,
char *preformatted_text, // ...or NULL to read text from client
long textlen,
- CM_SetField(msg, eExclusiveID, supplied_euid);
+ CM_SetField(msg, eExclusiveID, euid_in);