-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Implements the message store.
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
int a, b;
char aaa[300], bbb[300];
+ TRACE;
remove_any_whitespace_to_the_left_or_right_of_at_symbol(name);
+ TRACE;
fp = fopen("network/mail.aliases", "r");
if (fp == NULL)
fp = fopen("/dev/null", "r");
if (fp == NULL)
return (MES_ERROR);
+ TRACE;
strcpy(aaa, "");
strcpy(bbb, "");
while (fgets(aaa, sizeof aaa, fp) != NULL) {
if (!strcasecmp(name, aaa))
strcpy(name, bbb);
}
+ TRACE;
fclose(fp);
lprintf(7, "Mail is being forwarded to %s\n", name);
}
/* determine local or remote type, see citadel.h */
+ TRACE;
for (a = 0; a < strlen(name); ++a)
if (name[a] == '!')
return (MES_INTERNET);
+ TRACE;
for (a = 0; a < strlen(name); ++a)
if (name[a] == '@')
for (b = a; b < strlen(name); ++b)
if (name[b] == '.')
return (MES_INTERNET);
b = 0;
+ TRACE;
for (a = 0; a < strlen(name); ++a)
if (name[a] == '@')
++b;
GETSN: do {
a = getstring(fp, aaa);
} while ((a >= 0) && (strcasecmp(aaa, bbb)));
+ TRACE;
a = getstring(fp, aaa);
if (!strncmp(aaa, "use ", 4)) {
strcpy(bbb, &aaa[4]);
goto GETSN;
}
fclose(fp);
+ TRACE;
if (!strncmp(aaa, "uum", 3)) {
strcpy(bbb, name);
for (a = 0; a < strlen(bbb); ++a) {
}
return (MES_ERROR);
}
+ TRACE;
lprintf(9, "returning MES_LOCAL\n");
return (MES_LOCAL);
}
/*
* API function to perform an operation for each qualifying message in the
- * current room.
+ * current room. (Returns the number of messages processed.)
*/
-void CtdlForEachMessage(int mode, long ref,
+int CtdlForEachMessage(int mode, long ref,
+ int moderation_level,
char *content_type,
struct CtdlMessage *compare,
void (*CallBack) (long msgnum))
struct cdbdata *cdbfr;
long *msglist = NULL;
int num_msgs = 0;
+ int num_processed = 0;
long thismsg;
struct SuppMsgInfo smi;
struct CtdlMessage *msg;
num_msgs = cdbfr->len / sizeof(long);
cdb_free(cdbfr);
} else {
- return; /* No messages at all? No further action. */
+ return 0; /* No messages at all? No further action. */
}
- /* If the caller is looking for a specific MIME type, then filter
- * out all messages which are not of the type requested.
- */
- if (num_msgs > 0)
- if (content_type != NULL)
- if (strlen(content_type) > 0)
- for (a = 0; a < num_msgs; ++a) {
- GetSuppMsgInfo(&smi, msglist[a]);
- if (strcasecmp(smi.smi_content_type, content_type)) {
- msglist[a] = 0L;
- }
- }
+ if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) {
+ GetSuppMsgInfo(&smi, msglist[a]);
+
+ /* Filter out messages that are moderated below the level
+ * currently being viewed at.
+ */
+ if (smi.smi_mod < moderation_level) {
+ msglist[a] = 0L;
+ }
+
+ /* If the caller is looking for a specific MIME type, filter
+ * out all messages which are not of the type requested.
+ */
+ if (content_type != NULL) if (strlen(content_type) > 0) {
+ if (strcasecmp(smi.smi_content_type, content_type)) {
+ msglist[a] = 0L;
+ }
+ }
+ }
num_msgs = sort_msglist(msglist, num_msgs);
|| ((mode == MSGS_LAST) && (a >= (num_msgs - ref)))
|| ((mode == MSGS_FIRST) && (a < ref))
|| ((mode == MSGS_GT) && (thismsg > ref))
+ || ((mode == MSGS_EQ) && (thismsg == ref))
)
) {
- CallBack(thismsg);
+ if (CallBack) CallBack(thismsg);
+ ++num_processed;
}
}
phree(msglist); /* Clean up */
+ return num_processed;
}
cprintf("%d Message list...\n", LISTING_FOLLOWS);
}
- CtdlForEachMessage(mode, cm_ref, NULL, template, simple_listing);
+ CtdlForEachMessage(mode, cm_ref,
+ CC->usersupp.moderation_filter,
+ NULL, template, simple_listing);
if (template != NULL) CtdlFreeMessage(template);
cprintf("000\n");
}
lprintf(9, "older!\n");
/* Existing isn't newer? Then delete the old one(s). */
- CtdlDeleteMessages(CC->quickroom.QRname, msgnum, NULL);
+ CtdlDeleteMessages(CC->quickroom.QRname, msgnum, "");
}
memset(template, 0, sizeof(struct CtdlMessage));
template->cm_fields['E'] = strdoop(msg->cm_fields['E']);
- CtdlForEachMessage(MSGS_ALL, 0L, NULL, template, check_repl);
+ CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template, check_repl);
/* If a newer message exists with the same Extended ID, abort
* this save.
*/
int CtdlDeleteMessages(char *room_name, /* which room */
long dmsgnum, /* or "0" for any */
- char *content_type /* or NULL for any */
+ char *content_type /* or "" for any */
)
{
if ((dmsgnum == 0L) || (msglist[i] == dmsgnum)) {
delete_this |= 0x01;
}
- if (content_type == NULL) {
+ if (strlen(content_type) == 0) {
delete_this |= 0x02;
} else {
GetSuppMsgInfo(&smi, msglist[i]);
}
delnum = extract_long(delstr, 0);
- num_deleted = CtdlDeleteMessages(CC->quickroom.QRname, delnum, NULL);
+ num_deleted = CtdlDeleteMessages(CC->quickroom.QRname, delnum, "");
if (num_deleted) {
cprintf("%d %d message%s deleted.\n", OK,
/* Now delete the message from the source room,
* if this is a 'move' rather than a 'copy' operation.
*/
- if (is_copy == 0) CtdlDeleteMessages(CC->quickroom.QRname, num, NULL);
+ if (is_copy == 0) CtdlDeleteMessages(CC->quickroom.QRname, num, "");
cprintf("%d Message %s.\n", OK, (is_copy ? "copied" : "moved") );
}
/* We want the last (and probably only) config in this room */
begin_critical_section(S_CONFIG);
config_msgnum = (-1L);
- CtdlForEachMessage(MSGS_LAST, 1, sysconfname, NULL,
+ CtdlForEachMessage(MSGS_LAST, 1, (-127), sysconfname, NULL,
CtdlGetSysConfigBackend);
msgnum = config_msgnum;
end_critical_section(S_CONFIG);