-/* $Id$ */
+/*
+ * $Id$
+ *
+ * Implements the message store.
+ *
+ */
#include "sysdep.h"
#include <stdlib.h>
{
int i;
- for (i = 0; i < strlen(name); ++i)
+stov: for (i = 0; i < strlen(name); ++i) {
if (name[i] == '@') {
if (i > 0)
if (isspace(name[i - 1])) {
strcpy(&name[i - 1], &name[i]);
- i = 0;
+ goto stov; /* start over */
}
while (isspace(name[i + 1])) {
strcpy(&name[i + 1], &name[i + 2]);
}
}
+ }
}
-void simple_listing(long msgnum)
+void simple_listing(long msgnum, void *userdata)
{
cprintf("%ld\n", msgnum);
}
/*
* 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))
+ void (*CallBack) (long, void *),
+ void *userdata)
{
int a;
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. */
}
|| ((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, userdata);
+ ++num_processed;
}
}
phree(msglist); /* Clean up */
+ return num_processed;
}
CtdlForEachMessage(mode, cm_ref,
CC->usersupp.moderation_filter,
- NULL, template, simple_listing);
+ NULL, template, simple_listing, NULL);
if (template != NULL) CtdlFreeMessage(template);
cprintf("000\n");
}
else if (i == 'R')
cprintf("To: %s%s", mptr, nl);
else if (i == 'T') {
- generate_rfc822_datestamp(datestamp,
- atol(mptr) );
+ datestring(datestamp, atol(mptr),
+ DATESTRING_RFC822 );
cprintf("Date: %s%s", datestamp, nl);
}
}
{
long msgid;
- CtdlAllocUserData(SYM_DESIRED_SECTION, 64);
+ CtdlAllocUserData(SYM_DESIRED_SECTION, 256);
msgid = extract_long(cmdbuf, 0);
extract(desired_section, cmdbuf, 1);
/*
* Back end for the ReplicationChecks() function
*/
-void check_repl(long msgnum) {
+void check_repl(long msgnum, void *userdata) {
struct CtdlMessage *msg;
time_t timestamp = (-1L);
memset(template, 0, sizeof(struct CtdlMessage));
template->cm_fields['E'] = strdoop(msg->cm_fields['E']);
- CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template, check_repl);
+ CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template,
+ check_repl, NULL);
/* If a newer message exists with the same Extended ID, abort
* this save.
-void CtdlGetSysConfigBackend(long msgnum) {
+void CtdlGetSysConfigBackend(long msgnum, void *userdata) {
config_msgnum = msgnum;
}
begin_critical_section(S_CONFIG);
config_msgnum = (-1L);
CtdlForEachMessage(MSGS_LAST, 1, (-127), sysconfname, NULL,
- CtdlGetSysConfigBackend);
+ CtdlGetSysConfigBackend, NULL);
msgnum = config_msgnum;
end_critical_section(S_CONFIG);