/* Verbose logging callback */
void cdb_verbose_err(const DB_ENV *dbenv, const char *errpfx, const char *msg)
{
+ int *FOO = NULL;
syslog(LOG_ALERT, "DB: %s", msg);
cit_backtrace();
+ *FOO = 1;
}
msg = CtdlFetchMessage(msgnum, 0);
if (msg == NULL) return;
- if (msg->cm_fields['E'] != NULL) {
- index_message_by_euid(msg->cm_fields['E'], &CC->room, msgnum);
+ if (msg->cm_fields[eExclusiveID] != NULL) {
+ index_message_by_euid(msg->cm_fields[eExclusiveID], &CC->room, msgnum);
}
CtdlFreeMessage(msg);
}
parsed_date = parsedate(value);
if (parsed_date < 0L) parsed_date = time(NULL);
snprintf(buf, sizeof buf, "%ld", (long)parsed_date );
- if (msg->cm_fields['T'] == NULL)
- msg->cm_fields['T'] = strdup(buf);
+ if (msg->cm_fields[eTimestamp] == NULL)
+ msg->cm_fields[eTimestamp] = strdup(buf);
processed = 1;
}
process_rfc822_addr(value, user, node, name);
syslog(LOG_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
snprintf(addr, sizeof addr, "%s@%s", user, node);
- if (msg->cm_fields['A'] == NULL)
- msg->cm_fields['A'] = strdup(name);
- if (msg->cm_fields['F'] == NULL)
- msg->cm_fields['F'] = strdup(addr);
+ if (msg->cm_fields[eAuthor] == NULL)
+ msg->cm_fields[eAuthor] = strdup(name);
+ if (msg->cm_fields[erFc822Addr] == NULL)
+ msg->cm_fields[erFc822Addr] = strdup(addr);
processed = 1;
}
else if (!strcasecmp(key, "Subject")) {
- if (msg->cm_fields['U'] == NULL)
- msg->cm_fields['U'] = strndup(value, valuelen);
+ if (msg->cm_fields[eMsgSubject] == NULL)
+ msg->cm_fields[eMsgSubject] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "List-ID")) {
- if (msg->cm_fields['L'] == NULL)
- msg->cm_fields['L'] = strndup(value, valuelen);
+ if (msg->cm_fields[eListID] == NULL)
+ msg->cm_fields[eListID] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "To")) {
- if (msg->cm_fields['R'] == NULL)
- msg->cm_fields['R'] = strndup(value, valuelen);
+ if (msg->cm_fields[eRecipient] == NULL)
+ msg->cm_fields[eRecipient] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "CC")) {
- if (msg->cm_fields['Y'] == NULL)
- msg->cm_fields['Y'] = strndup(value, valuelen);
+ if (msg->cm_fields[eCarbonCopY] == NULL)
+ msg->cm_fields[eCarbonCopY] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "Message-ID")) {
- if (msg->cm_fields['I'] != NULL) {
+ if (msg->cm_fields[emessageId] != NULL) {
syslog(LOG_WARNING, "duplicate message id\n");
}
- if (msg->cm_fields['I'] == NULL) {
- msg->cm_fields['I'] = strndup(value, valuelen);
+ if (msg->cm_fields[emessageId] == NULL) {
+ msg->cm_fields[emessageId] = strndup(value, valuelen);
/* Strip angle brackets */
- while (haschar(msg->cm_fields['I'], '<') > 0) {
- strcpy(&msg->cm_fields['I'][0],
- &msg->cm_fields['I'][1]);
+ while (haschar(msg->cm_fields[emessageId], '<') > 0) {
+ strcpy(&msg->cm_fields[emessageId][0],
+ &msg->cm_fields[emessageId][1]);
}
- for (i = 0; i<strlen(msg->cm_fields['I']); ++i)
- if (msg->cm_fields['I'][i] == '>')
- msg->cm_fields['I'][i] = 0;
+ for (i = 0; i<strlen(msg->cm_fields[emessageId]); ++i)
+ if (msg->cm_fields[emessageId][i] == '>')
+ msg->cm_fields[emessageId][i] = 0;
}
processed = 1;
}
else if (!strcasecmp(key, "Return-Path")) {
- if (msg->cm_fields['P'] == NULL)
- msg->cm_fields['P'] = strndup(value, valuelen);
+ if (msg->cm_fields[eMessagePath] == NULL)
+ msg->cm_fields[eMessagePath] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "Envelope-To")) {
- if (msg->cm_fields['V'] == NULL)
- msg->cm_fields['V'] = strndup(value, valuelen);
+ if (msg->cm_fields[eenVelopeTo] == NULL)
+ msg->cm_fields[eenVelopeTo] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "References")) {
- if (msg->cm_fields['W'] != NULL) {
- free(msg->cm_fields['W']);
+ if (msg->cm_fields[eWeferences] != NULL) {
+ free(msg->cm_fields[eWeferences]);
}
- msg->cm_fields['W'] = strndup(value, valuelen);
+ msg->cm_fields[eWeferences] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "Reply-To")) {
- if (msg->cm_fields['K'] != NULL) {
- free(msg->cm_fields['K']);
+ if (msg->cm_fields[eReplyTo] != NULL) {
+ free(msg->cm_fields[eReplyTo]);
}
- msg->cm_fields['K'] = strndup(value, valuelen);
+ msg->cm_fields[eReplyTo] = strndup(value, valuelen);
processed = 1;
}
else if (!strcasecmp(key, "In-reply-to")) {
- if (msg->cm_fields['W'] == NULL) { /* References: supersedes In-reply-to: */
- msg->cm_fields['W'] = strndup(value, valuelen);
+ if (msg->cm_fields[eWeferences] == NULL) { /* References: supersedes In-reply-to: */
+ msg->cm_fields[eWeferences] = strndup(value, valuelen);
}
processed = 1;
}
if (pos < totalend)
StrBufAppendBufPlain(OtherHeaders, pos, totalend - pos, 0);
FreeStrBuf(rfc822);
- msg->cm_fields['M'] = SmashStrBuf(&OtherHeaders);
+ msg->cm_fields[eMesageText] = SmashStrBuf(&OtherHeaders);
/* Follow-up sanity checks... */
/* If there's no timestamp on this message, set it to now. */
- if (msg->cm_fields['T'] == NULL) {
+ if (msg->cm_fields[eTimestamp] == NULL) {
snprintf(buf, sizeof buf, "%ld", (long)time(NULL));
- msg->cm_fields['T'] = strdup(buf);
+ msg->cm_fields[eTimestamp] = strdup(buf);
}
/* If a W (references, or rather, Wefewences) field is present, we
* have to convert it from RFC822 format to Citadel format.
*/
- if (msg->cm_fields['W'] != NULL) {
- convert_references_to_wefewences(msg->cm_fields['W']);
+ if (msg->cm_fields[eWeferences] != NULL) {
+ convert_references_to_wefewences(msg->cm_fields[eWeferences]);
}
return msg;
char user[256], node[256], name[256];
int is_harvestable;
int i, j, h;
- int field = 0;
+ eMsgField field = 0;
if (msg == NULL) return(NULL);
is_harvestable = 1;
strcpy(addr, "");
- if (msg->cm_fields['A'] != NULL) {
- strcat(addr, msg->cm_fields['A']);
+ if (msg->cm_fields[eAuthor] != NULL) {
+ strcat(addr, msg->cm_fields[eAuthor]);
}
- if (msg->cm_fields['F'] != NULL) {
+ if (msg->cm_fields[erFc822Addr] != NULL) {
strcat(addr, " <");
- strcat(addr, msg->cm_fields['F']);
+ strcat(addr, msg->cm_fields[erFc822Addr]);
strcat(addr, ">");
- if (IsDirectory(msg->cm_fields['F'], 0)) {
+ if (IsDirectory(msg->cm_fields[erFc822Addr], 0)) {
is_harvestable = 0;
}
}
/* Scan both the R (To) and Y (CC) fields */
for (i = 0; i < 2; ++i) {
- if (i == 0) field = 'R' ;
- if (i == 1) field = 'Y' ;
+ if (i == 0) field = eRecipient;
+ if (i == 1) field = eCarbonCopY;
if (msg->cm_fields[field] != NULL) {
for (j=0; j<num_tokens(msg->cm_fields[field], ','); ++j) {
struct jnlq *jptr = NULL;
/* Avoid double journaling! */
- if (msg->cm_fields['J'] != NULL) {
+ if (msg->cm_fields[eJournal] != NULL) {
FreeStrBuf(&saved_rfc822_version);
return;
}
}
memset(jptr, 0, sizeof(struct jnlq));
if (recps != NULL) memcpy(&jptr->recps, recps, sizeof(struct recptypes));
- if (msg->cm_fields['A'] != NULL) jptr->from = strdup(msg->cm_fields['A']);
- if (msg->cm_fields['N'] != NULL) jptr->node = strdup(msg->cm_fields['N']);
- if (msg->cm_fields['F'] != NULL) jptr->rfca = strdup(msg->cm_fields['F']);
- if (msg->cm_fields['U'] != NULL) jptr->subj = strdup(msg->cm_fields['U']);
- if (msg->cm_fields['I'] != NULL) jptr->msgn = strdup(msg->cm_fields['I']);
+ if (msg->cm_fields[eAuthor] != NULL) jptr->from = strdup(msg->cm_fields[eAuthor]);
+ if (msg->cm_fields[eNodeName] != NULL) jptr->node = strdup(msg->cm_fields[eNodeName]);
+ if (msg->cm_fields[erFc822Addr] != NULL) jptr->rfca = strdup(msg->cm_fields[erFc822Addr]);
+ if (msg->cm_fields[eMsgSubject] != NULL) jptr->subj = strdup(msg->cm_fields[eMsgSubject]);
+ if (msg->cm_fields[emessageId] != NULL) jptr->msgn = strdup(msg->cm_fields[emessageId]);
jptr->rfc822 = SmashStrBuf(&saved_rfc822_version);
/* Add to the queue */
journal_msg->cm_magic = CTDLMESSAGE_MAGIC;
journal_msg->cm_anon_type = MES_NORMAL;
journal_msg->cm_format_type = FMT_RFC822;
- journal_msg->cm_fields['J'] = strdup("is journal");
- journal_msg->cm_fields['A'] = jmsg->from;
- journal_msg->cm_fields['N'] = jmsg->node;
- journal_msg->cm_fields['F'] = jmsg->rfca;
- journal_msg->cm_fields['U'] = jmsg->subj;
+ journal_msg->cm_fields[eJournal] = strdup("is journal");
+ journal_msg->cm_fields[eAuthor] = jmsg->from;
+ journal_msg->cm_fields[eNodeName] = jmsg->node;
+ journal_msg->cm_fields[erFc822Addr] = jmsg->rfca;
+ journal_msg->cm_fields[eMsgSubject] = jmsg->subj;
sprintf(mime_boundary, "--Citadel-Journal-%08lx-%04x--", time(NULL), ++seq);
message_text = malloc(strlen(jmsg->rfc822) + sizeof(struct recptypes) + 1024);
,
mime_boundary,
mime_boundary,
- ( journal_msg->cm_fields['A'] ? journal_msg->cm_fields['A'] : "(null)" )
+ ( journal_msg->cm_fields[eAuthor] ? journal_msg->cm_fields[eAuthor] : "(null)" )
);
- if (journal_msg->cm_fields['F']) {
+ if (journal_msg->cm_fields[erFc822Addr]) {
sprintf(&message_text[strlen(message_text)], "<%s>",
- journal_msg->cm_fields['F']);
+ journal_msg->cm_fields[erFc822Addr]);
}
- else if (journal_msg->cm_fields['N']) {
+ else if (journal_msg->cm_fields[eNodeName]) {
sprintf(&message_text[strlen(message_text)], "@ %s",
- journal_msg->cm_fields['N']);
+ journal_msg->cm_fields[eNodeName]);
}
sprintf(&message_text[strlen(message_text)],
mime_boundary
);
- journal_msg->cm_fields['M'] = message_text;
+ journal_msg->cm_fields[eMesageText] = message_text;
free(jmsg->rfc822);
free(jmsg->msgn);
msg = CtdlFetchMessage(msgnum, 1);
if (msg == NULL) return;
- v = vcard_load(msg->cm_fields['M']);
+ v = vcard_load(msg->cm_fields[eMesageText]);
CtdlFreeMessage(msg);
/*
/*
* If the message doesn't have an EUID, give it one.
*/
- if (msg->cm_fields['E'] == NULL)
+ if (msg->cm_fields[eExclusiveID] == NULL)
{
char uuid[BLOG_EUIDBUF_SIZE];
generate_uuid(uuid);
- msg->cm_fields['E'] = strdup(uuid);
+ msg->cm_fields[eExclusiveID] = strdup(uuid);
}
/*
* We also want to define a maximum length, whether we generated it or not.
*/
- else if (strlen(msg->cm_fields['E']) >= BLOG_EUIDBUF_SIZE) {
- msg->cm_fields['E'][BLOG_EUIDBUF_SIZE-1] = 0;
+ else if (strlen(msg->cm_fields[eExclusiveID]) >= BLOG_EUIDBUF_SIZE) {
+ msg->cm_fields[eExclusiveID][BLOG_EUIDBUF_SIZE-1] = 0;
}
/* Now allow the save to complete. */
msg->cm_magic = CTDLMESSAGE_MAGIC;
msg->cm_anon_type = MES_NORMAL;
msg->cm_format_type = 4;
- msg->cm_fields['A'] = strdup(CC->user.fullname);
- msg->cm_fields['O'] = strdup(CC->room.QRname);
- msg->cm_fields['N'] = strdup(config.c_nodename);
- msg->cm_fields['H'] = strdup(config.c_humannode);
- msg->cm_fields['M'] = malloc(strlen(ser) + 40);
- strcpy(msg->cm_fields['M'], "Content-type: text/calendar\r\n\r\n");
- strcat(msg->cm_fields['M'], ser);
+ msg->cm_fields[eAuthor] = strdup(CC->user.fullname);
+ msg->cm_fields[eOriginalRoom] = strdup(CC->room.QRname);
+ msg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ msg->cm_fields[eHumanNode] = strdup(config.c_humannode);
+ msg->cm_fields[eMesageText] = malloc(strlen(ser) + 40);
+ strcpy(msg->cm_fields[eMesageText], "Content-type: text/calendar\r\n\r\n");
+ strcat(msg->cm_fields[eMesageText], ser);
/* Now write the data */
CtdlSubmitMsg(msg, NULL, "", QP_EADDR);
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_part, /* callback function */
NULL, NULL,
return(2); /* internal error */
}
oec.c = NULL;
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_original_event, /* callback function */
NULL, NULL,
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_part, /* callback function */
NULL, NULL,
if (msg == NULL) return;
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_part, /* callback function */
NULL, NULL,
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, partnum);
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_part, /* callback function */
NULL, NULL,
if (msg == NULL) return;
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_part, /* callback function */
NULL, NULL,
if (msg == NULL) return;
memset(&ird, 0, sizeof ird);
strcpy(ird.desired_partnum, "_HUNT_");
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_locate_part, /* callback function */
NULL, NULL,
if (p != NULL) {
safestrncpy(buf, icalproperty_get_comment(p), sizeof buf);
if (!IsEmptyStr(buf)) {
- if (msg->cm_fields['E'] != NULL) {
- free(msg->cm_fields['E']);
+ if (msg->cm_fields[eExclusiveID] != NULL) {
+ free(msg->cm_fields[eExclusiveID]);
}
- msg->cm_fields['E'] = strdup(buf);
+ msg->cm_fields[eExclusiveID] = strdup(buf);
syslog(LOG_DEBUG, "Saving calendar UID <%s>\n", buf);
}
}
if (p != NULL) {
safestrncpy(buf, icalproperty_get_comment(p), sizeof buf);
if (!IsEmptyStr(buf)) {
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
+ if (msg->cm_fields[eMsgSubject] != NULL) {
+ free(msg->cm_fields[eMsgSubject]);
}
- msg->cm_fields['U'] = rfc2047encode(buf, strlen(buf));
+ msg->cm_fields[eMsgSubject] = rfc2047encode(buf, strlen(buf));
}
}
time_t idtstart;
idtstart = icaltime_as_timet(icalproperty_get_dtstart(p));
if (idtstart > 0) {
- if (msg->cm_fields['T'] != NULL) {
- free(msg->cm_fields['T']);
+ if (msg->cm_fields[eTimestamp] != NULL) {
+ free(msg->cm_fields[eTimestamp]);
}
- msg->cm_fields['T'] = strdup("000000000000000000");
- sprintf(msg->cm_fields['T'], "%ld", idtstart);
+ msg->cm_fields[eTimestamp] = strdup("000000000000000000");
+ sprintf(msg->cm_fields[eTimestamp], "%ld", idtstart);
}
}
return(1); /* You tried to save a non-RFC822 message! */
}
- if (msg->cm_fields['M'] == NULL) {
+ if (msg->cm_fields[eMesageText] == NULL) {
return(1); /* You tried to save a null message! */
}
/* Do all of our lovely back-end parsing */
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_obj_beforesave_backend,
NULL, NULL,
if (msg->cm_format_type != 4) return(1);
/* Reject null messages */
- if (msg->cm_fields['M'] == NULL) return(1);
+ if (msg->cm_fields[eMesageText] == NULL) return(1);
/* Now recurse through it looking for our icalendar data */
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*ical_obj_aftersave_backend,
NULL, NULL,
}
if (is_virus) {
- if (msg->cm_fields['0'] != NULL) {
- free(msg->cm_fields['0']);
+ if (msg->cm_fields[eErrorMsg] != NULL) {
+ free(msg->cm_fields[eErrorMsg]);
}
- msg->cm_fields['0'] = strdup("message rejected by virus filter");
+ msg->cm_fields[eErrorMsg] = strdup("message rejected by virus filter");
}
bail: close(sock);
{
/* Copy to a safe place */
- msg->cm_fields['G'] = malloc (CTX->signature->length * 2);
- CtdlEncodeBase64(msg->cm_fields['G'], CTX->signature->data, CTX->signature->length, 0);
+ msg->cm_fields[eErrorMsg] = malloc (CTX->signature->length * 2);
+ CtdlEncodeBase64(msg->cm_fields[eErrorMsg], CTX->signature->data, CTX->signature->length, 0);
}
free(msgtext);
msg = CtdlFetchMessage(delnum, 0); /* dont need body */
if (msg != NULL) {
- xtime = atol(msg->cm_fields['T']);
+ xtime = atol(msg->cm_fields[eTimestamp]);
CtdlFreeMessage(msg);
} else {
xtime = 0L;
for (a = 0; a < num_msgs; ++a) {
msg = CtdlFetchMessage(msglist[a], 1);
if (msg != NULL) {
- if ((msg->cm_fields['U'] != NULL) &&
- (strncasecmp(msg->cm_fields['U'],
+ if ((msg->cm_fields[eMsgSubject] != NULL) &&
+ (strncasecmp(msg->cm_fields[eMsgSubject],
PAGER_CONFIG_MESSAGE,
strlen(PAGER_CONFIG_MESSAGE)) == 0))
{
// Do a simple string search to see if 'funambol' is selected as the
// type. This string would be at the very top of the message contents.
- configMsg = msg->cm_fields['M'];
- msg->cm_fields['M'] = NULL;
+ configMsg = msg->cm_fields[eMesageText];
+ msg->cm_fields[eMesageText] = NULL;
CtdlFreeMessage(msg);
/* here we would find the pager number... */
Ctx = (NotifyContext*) usrdata;
msg = CtdlFetchMessage(NotifyMsgnum, 1);
- if ( msg->cm_fields['2'] != NULL)
+ if ( msg->cm_fields[eExtnotify] != NULL)
{
Type = extNotify_getConfigMessage(
- msg->cm_fields['2'],
+ msg->cm_fields[eExtnotify],
&PagerNo,
&FreeMe);
- pch = strstr(msg->cm_fields['M'], "msgid|");
+ pch = strstr(msg->cm_fields[eMesageText], "msgid|");
if (pch != NULL)
msgnum = atol(pch + sizeof("msgid"));
notify_http_server(remoteurl,
file_funambol_msg,
strlen(file_funambol_msg),/*GNA*/
- msg->cm_fields['2'],
- msg->cm_fields['I'],
+ msg->cm_fields[eExtnotify],
+ msg->cm_fields[emessageId],
msgnum,
NULL);
break;
notify_http_server(URLBuf,
ChrPtr(FileBuf),
StrLength(FileBuf),
- msg->cm_fields['2'],
- msg->cm_fields['I'],
+ msg->cm_fields[eExtnotify],
+ msg->cm_fields[emessageId],
msgnum,
NULL);
}
commandSiz = sizeof(config.c_pager_program) +
strlen(PagerNo) +
- strlen(msg->cm_fields['2']) + 5;
+ strlen(msg->cm_fields[eExtnotify]) + 5;
command = malloc(commandSiz);
"%s %s -u %s",
config.c_pager_program,
PagerNo,
- msg->cm_fields['2']);
+ msg->cm_fields[eExtnotify]);
system(command);
free(command);
return;
}
- if (msg->cm_fields['1'] != NULL) {
+ if (msg->cm_fields[eSuppressIdx] != NULL) {
syslog(LOG_DEBUG, "ft_index_message() excluded msg %ld", msgnum);
CtdlFreeMessage(msg);
return;
time_t msgdate;
if (!msg) return;
- if (msg->cm_fields['T'] != NULL) {
- msgdate = atol(msg->cm_fields['T']);
+ if (msg->cm_fields[eTimestamp] != NULL) {
+ msgdate = atol(msg->cm_fields[eTimestamp]);
}
else {
msgdate = time(NULL);
/* For everything else, we do stuff. */
IAPuts("(("); /* open double-parens */
- plain_imap_strout(msg->cm_fields['A']); /* personal name */
+ plain_imap_strout(msg->cm_fields[eAuthor]); /* personal name */
IAPuts(" NIL "); /* source route (not used) */
- if (msg->cm_fields['F'] != NULL) {
- process_rfc822_addr(msg->cm_fields['F'], user, node, name);
+ if (msg->cm_fields[erFc822Addr] != NULL) {
+ process_rfc822_addr(msg->cm_fields[erFc822Addr], user, node, name);
plain_imap_strout(user); /* mailbox name (user id) */
IAPuts(" ");
if (!strcasecmp(node, config.c_nodename)) {
}
}
else {
- plain_imap_strout(msg->cm_fields['A']); /* mailbox name (user id) */
+ plain_imap_strout(msg->cm_fields[eAuthor]); /* mailbox name (user id) */
IAPuts(" ");
- plain_imap_strout(msg->cm_fields['N']); /* host name */
+ plain_imap_strout(msg->cm_fields[eNodeName]); /* host name */
}
IAPuts(")) "); /* close double-parens */
if (!msg) return;
/* Parse the message date into an IMAP-format date string */
- if (msg->cm_fields['T'] != NULL) {
- msgdate = atol(msg->cm_fields['T']);
+ if (msg->cm_fields[eTimestamp] != NULL) {
+ msgdate = atol(msg->cm_fields[eTimestamp]);
}
else {
msgdate = time(NULL);
IAPuts(" ");
/* Subject */
- plain_imap_strout(msg->cm_fields['U']);
+ plain_imap_strout(msg->cm_fields[eMsgSubject]);
IAPuts(" ");
/* From */
imap_output_envelope_from(msg);
/* Sender (default to same as 'From' if not present) */
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Sender");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "Sender");
if (fieldptr != NULL) {
imap_output_envelope_addr(fieldptr);
free(fieldptr);
}
/* Reply-to */
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Reply-to");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "Reply-to");
if (fieldptr != NULL) {
imap_output_envelope_addr(fieldptr);
free(fieldptr);
}
/* To */
- imap_output_envelope_addr(msg->cm_fields['R']);
+ imap_output_envelope_addr(msg->cm_fields[eRecipient]);
/* Cc (we do it this way because there might be a legacy non-Citadel Cc: field present) */
- fieldptr = msg->cm_fields['Y'];
+ fieldptr = msg->cm_fields[eCarbonCopY];
if (fieldptr != NULL) {
imap_output_envelope_addr(fieldptr);
}
else {
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Cc");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "Cc");
imap_output_envelope_addr(fieldptr);
if (fieldptr != NULL) free(fieldptr);
}
/* Bcc */
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Bcc");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "Bcc");
imap_output_envelope_addr(fieldptr);
if (fieldptr != NULL) free(fieldptr);
/* In-reply-to */
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "In-reply-to");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "In-reply-to");
plain_imap_strout(fieldptr);
IAPuts(" ");
if (fieldptr != NULL) free(fieldptr);
/* message ID */
- len = strlen(msg->cm_fields['I']);
+ len = strlen(msg->cm_fields[emessageId]);
if ((len == 0) || (
- (msg->cm_fields['I'][0] == '<') &&
- (msg->cm_fields['I'][len - 1] == '>'))
+ (msg->cm_fields[emessageId][0] == '<') &&
+ (msg->cm_fields[emessageId][len - 1] == '>'))
)
{
- plain_imap_strout(msg->cm_fields['I']);
+ plain_imap_strout(msg->cm_fields[emessageId]);
}
else
{
char *Buf = malloc(len + 3);
long pos = 0;
- if (msg->cm_fields['I'][0] != '<')
+ if (msg->cm_fields[emessageId][0] != '<')
{
Buf[pos] = '<';
pos ++;
}
- memcpy(&Buf[pos], msg->cm_fields['I'], len);
+ memcpy(&Buf[pos], msg->cm_fields[emessageId], len);
pos += len;
- if (msg->cm_fields['I'][len] != '>')
+ if (msg->cm_fields[emessageId][len] != '>')
{
Buf[pos] = '>';
pos++;
* (Note value of 1 passed as 'dont_decode' so client gets it encoded)
*/
else {
- mime_parser(msg->cm_fields['M'], NULL,
+ mime_parser(msg->cm_fields[eMesageText], NULL,
*imap_load_part, NULL, NULL,
section,
1
/* For messages already stored in RFC822 format, we have to parse. */
IAPuts("BODYSTRUCTURE ");
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*imap_fetch_bodystructure_part, /* part */
*imap_fetch_bodystructure_pre, /* pre-multi */
*/
if (CC->logged_in) {
if ( ((CC->room.QRflags & QR_MAILBOX) == 0) && (config.c_imap_keep_from == 0)) {
- if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']);
- if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']);
- if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']);
- msg->cm_fields['A'] = strdup(CC->user.fullname);
- msg->cm_fields['N'] = strdup(config.c_nodename);
- msg->cm_fields['H'] = strdup(config.c_humannode);
+ if (msg->cm_fields[eAuthor] != NULL) free(msg->cm_fields[eAuthor]);
+ if (msg->cm_fields[eNodeName] != NULL) free(msg->cm_fields[eNodeName]);
+ if (msg->cm_fields[eHumanNode] != NULL) free(msg->cm_fields[eHumanNode]);
+ msg->cm_fields[eAuthor] = strdup(CC->user.fullname);
+ msg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ msg->cm_fields[eHumanNode] = strdup(config.c_humannode);
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Bcc");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "Bcc");
if (fieldptr != NULL) {
if (bmstrcasestr(fieldptr, itemlist[pos+1].Key)) {
match = 1;
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (msg->cm_fields['T'] != NULL) {
+ if (msg->cm_fields[eTimestamp] != NULL) {
if (imap_datecmp(itemlist[pos+1].Key,
- atol(msg->cm_fields['T'])) < 0) {
+ atol(msg->cm_fields[eTimestamp])) < 0) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (bmstrcasestr(msg->cm_fields['M'], itemlist[pos+1].Key)) {
+ if (bmstrcasestr(msg->cm_fields[eMesageText], itemlist[pos+1].Key)) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- fieldptr = msg->cm_fields['Y'];
+ fieldptr = msg->cm_fields[eCarbonCopY];
if (fieldptr != NULL) {
if (bmstrcasestr(fieldptr, itemlist[pos+1].Key)) {
match = 1;
}
}
else {
- fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Cc");
+ fieldptr = rfc822_fetch_field(msg->cm_fields[eMesageText], "Cc");
if (fieldptr != NULL) {
if (bmstrcasestr(fieldptr, itemlist[pos+1].Key)) {
match = 1;
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (bmstrcasestr(msg->cm_fields['A'], itemlist[pos+1].Key)) {
+ if (bmstrcasestr(msg->cm_fields[eAuthor], itemlist[pos+1].Key)) {
match = 1;
}
- if (bmstrcasestr(msg->cm_fields['F'], itemlist[pos+1].Key)) {
+ if (bmstrcasestr(msg->cm_fields[erFc822Addr], itemlist[pos+1].Key)) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (strlen(msg->cm_fields['M']) > atoi(itemlist[pos+1].Key)) {
+ if (strlen(msg->cm_fields[eMesageText]) > atoi(itemlist[pos+1].Key)) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (msg->cm_fields['T'] != NULL) {
+ if (msg->cm_fields[eTimestamp] != NULL) {
if (imap_datecmp(itemlist[pos+1].Key,
- atol(msg->cm_fields['T'])) == 0) {
+ atol(msg->cm_fields[eTimestamp])) == 0) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (msg->cm_fields['T'] != NULL) {
+ if (msg->cm_fields[eTimestamp] != NULL) {
if (imap_datecmp(itemlist[pos+1].Key,
- atol(msg->cm_fields['T'])) < 0) {
+ atol(msg->cm_fields[eTimestamp])) < 0) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (msg->cm_fields['T'] != NULL) {
+ if (msg->cm_fields[eTimestamp] != NULL) {
if (imap_datecmp(itemlist[pos+1].Key,
- atol(msg->cm_fields['T'])) == 0) {
+ atol(msg->cm_fields[eTimestamp])) == 0) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (msg->cm_fields['T'] != NULL) {
+ if (msg->cm_fields[eTimestamp] != NULL) {
if (imap_datecmp(itemlist[pos+1].Key,
- atol(msg->cm_fields['T'])) >= 0) {
+ atol(msg->cm_fields[eTimestamp])) >= 0) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (msg->cm_fields['T'] != NULL) {
+ if (msg->cm_fields[eTimestamp] != NULL) {
if (imap_datecmp(itemlist[pos+1].Key,
- atol(msg->cm_fields['T'])) >= 0) {
+ atol(msg->cm_fields[eTimestamp])) >= 0) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (strlen(msg->cm_fields['M']) < atoi(itemlist[pos+1].Key)) {
+ if (strlen(msg->cm_fields[eMesageText]) < atoi(itemlist[pos+1].Key)) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (bmstrcasestr(msg->cm_fields['U'], itemlist[pos+1].Key)) {
+ if (bmstrcasestr(msg->cm_fields[eMsgSubject], itemlist[pos+1].Key)) {
match = 1;
}
}
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (bmstrcasestr(msg->cm_fields['R'], itemlist[pos+1].Key)) {
+ if (bmstrcasestr(msg->cm_fields[eRecipient], itemlist[pos+1].Key)) {
match = 1;
}
}
char *conf;
char buf[SIZ];
- if (msg->cm_fields['M']==NULL) return;
- conf = strdup(msg->cm_fields['M']);
+ if (msg->cm_fields[eMesageText]==NULL) return;
+ conf = strdup(msg->cm_fields[eMesageText]);
if (conf != NULL) {
do {
/* If this isn't the configuration room, or if this isn't a MIME
* message, don't bother.
*/
- if (strcasecmp(msg->cm_fields['O'], SYSCONFIGROOM)) return(0);
+ if (strcasecmp(msg->cm_fields[eOriginalRoom], SYSCONFIGROOM)) return(0);
if (msg->cm_format_type != 4) return(0);
- ptr = msg->cm_fields['M'];
+ ptr = msg->cm_fields[eMesageText];
while (ptr != NULL) {
linelen = strcspn(ptr, "\n");
msg->cm_anon_type = MES_NORMAL;
msg->cm_format_type = FMT_RFC822;
if (!IsEmptyStr(im->usernames[0])) {
- msg->cm_fields['A'] = strdup(im->usernames[0]);
+ msg->cm_fields[eAuthor] = strdup(im->usernames[0]);
} else {
- msg->cm_fields['A'] = strdup("Citadel");
+ msg->cm_fields[eAuthor] = strdup("Citadel");
}
if (!IsEmptyStr(im->usernames[1])) {
- msg->cm_fields['R'] = strdup(im->usernames[1]);
+ msg->cm_fields[eRecipient] = strdup(im->usernames[1]);
}
- msg->cm_fields['O'] = strdup(PAGELOGROOM);
- msg->cm_fields['N'] = strdup(NODENAME);
- msg->cm_fields['M'] = SmashStrBuf(&im->conversation); /* we own this memory now */
+ msg->cm_fields[eOriginalRoom] = strdup(PAGELOGROOM);
+ msg->cm_fields[eNodeName] = strdup(NODENAME);
+ msg->cm_fields[eMesageText] = SmashStrBuf(&im->conversation); /* we own this memory now */
/* Start with usernums[1] because it's guaranteed to be higher than usernums[0],
* so if there's only one party, usernums[0] will be zero but usernums[1] won't.
zap_room = 0;
zap_node = 0;
- if (msg->cm_fields['A'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['A'], fptr->fl_user))
+ if (msg->cm_fields[eAuthor] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields[eAuthor], fptr->fl_user))
|| (fptr->fl_user[0] == 0) ) {
zap_user = 1;
}
}
- if (msg->cm_fields['C'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['C'], fptr->fl_room))
+ if (msg->cm_fields[eRemoteRoom] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields[eRemoteRoom], fptr->fl_room))
|| (fptr->fl_room[0] == 0) ) {
zap_room = 1;
}
}
- if (msg->cm_fields['O'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['O'], fptr->fl_room))
+ if (msg->cm_fields[eOriginalRoom] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields[eOriginalRoom], fptr->fl_room))
|| (fptr->fl_room[0] == 0) ) {
zap_room = 1;
}
}
- if (msg->cm_fields['N'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['N'], fptr->fl_node))
+ if (msg->cm_fields[eNodeName] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields[eNodeName], fptr->fl_node))
|| (fptr->fl_node[0] == 0) ) {
zap_node = 1;
}
int rlen;
char *pCh;
- if (msg->cm_fields['U'] == NULL) {
+ if (msg->cm_fields[eMsgSubject] == NULL) {
Subject = NewStrBufPlain(HKEY("(no subject)"));
}
else {
Subject = NewStrBufPlain(
- msg->cm_fields['U'], -1);
+ msg->cm_fields[eMsgSubject], -1);
}
FlatSubject = NewStrBufPlain(NULL, StrLength(Subject));
StrBuf_RFC822_to_Utf8(FlatSubject, Subject, NULL, NULL);
StrBufRFC2047encode(&Subject, FlatSubject);
}
- if (msg->cm_fields['U'] != NULL)
- free (msg->cm_fields['U']);
- msg->cm_fields['U'] = SmashStrBuf(&Subject);
+ if (msg->cm_fields[eMsgSubject] != NULL)
+ free (msg->cm_fields[eMsgSubject]);
+ msg->cm_fields[eMsgSubject] = SmashStrBuf(&Subject);
FreeStrBuf(&FlatSubject);
}
msg->cm_anon_type = MES_NORMAL;
sprintf(buf, "%ld", time(NULL));
- msg->cm_fields['T'] = strdup(buf);
- msg->cm_fields['A'] = strdup(CC->room.QRname);
+ msg->cm_fields[eTimestamp] = strdup(buf);
+ msg->cm_fields[eAuthor] = strdup(CC->room.QRname);
snprintf(buf, sizeof buf, "[%s]", CC->room.QRname);
- msg->cm_fields['U'] = strdup(buf);
+ msg->cm_fields[eMsgSubject] = strdup(buf);
- CtdlMsgSetCM_Fields(msg, 'F', SKEY(sc->Users[roommailalias]));
- CtdlMsgSetCM_Fields(msg, 'R', SKEY(sc->Users[roommailalias]));
+ CtdlMsgSetCM_Fields(msg, erFc822Addr, SKEY(sc->Users[roommailalias]));
+ CtdlMsgSetCM_Fields(msg, eRecipient, SKEY(sc->Users[roommailalias]));
/* Set the 'List-ID' header */
- CtdlMsgSetCM_Fields(msg, 'L', SKEY(sc->ListID));
+ CtdlMsgSetCM_Fields(msg, eListID, SKEY(sc->ListID));
/*
* Go fetch the contents of the digest
fseek(sc->digestfp, 0L, SEEK_END);
msglen = ftell(sc->digestfp);
- msg->cm_fields['M'] = malloc(msglen + 1);
+ msg->cm_fields[eMesageText] = malloc(msglen + 1);
fseek(sc->digestfp, 0L, SEEK_SET);
- fread(msg->cm_fields['M'], (size_t)msglen, 1, sc->digestfp);
- msg->cm_fields['M'][msglen] = '\0';
+ fread(msg->cm_fields[eMesageText], (size_t)msglen, 1, sc->digestfp);
+ msg->cm_fields[eMesageText][msglen] = '\0';
fclose(sc->digestfp);
sc->digestfp = NULL;
"------------------------------------"
"-------\n");
fprintf(sc->digestfp, "From: ");
- if (msg->cm_fields['A'] != NULL) {
+ if (msg->cm_fields[eAuthor] != NULL) {
fprintf(sc->digestfp,
"%s ",
- msg->cm_fields['A']);
+ msg->cm_fields[eAuthor]);
}
- if (msg->cm_fields['F'] != NULL) {
+ if (msg->cm_fields[erFc822Addr] != NULL) {
fprintf(sc->digestfp,
"<%s> ",
- msg->cm_fields['F']);
+ msg->cm_fields[erFc822Addr]);
}
- else if (msg->cm_fields['N'] != NULL) {
+ else if (msg->cm_fields[eNodeName] != NULL) {
fprintf(sc->digestfp,
"@%s ",
- msg->cm_fields['N']);
+ msg->cm_fields[eNodeName]);
}
fprintf(sc->digestfp, "\n");
- if (msg->cm_fields['U'] != NULL) {
+ if (msg->cm_fields[eMsgSubject] != NULL) {
fprintf(sc->digestfp,
"Subject: %s\n",
- msg->cm_fields['U']);
+ msg->cm_fields[eMsgSubject]);
}
CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
msg = CtdlDuplicateMessage(omsg);
- CtdlMsgSetCM_Fields(msg, 'K', SKEY(sc->Users[roommailalias]));
+ CtdlMsgSetCM_Fields(msg, eListID, SKEY(sc->Users[roommailalias]));
/* if there is no other recipient, Set the recipient
* of the list message to the email address of the
* room itself.
*/
- if ((msg->cm_fields['R'] == NULL) ||
- IsEmptyStr(msg->cm_fields['R']))
+ if ((msg->cm_fields[eRecipient] == NULL) ||
+ IsEmptyStr(msg->cm_fields[eRecipient]))
{
- CtdlMsgSetCM_Fields(msg, 'R', SKEY(sc->Users[roommailalias]));
+ CtdlMsgSetCM_Fields(msg, eRecipient, SKEY(sc->Users[roommailalias]));
}
/* Set the 'List-ID' header */
- CtdlMsgSetCM_Fields(msg, 'L', SKEY(sc->ListID));
+ CtdlMsgSetCM_Fields(msg, eListID, SKEY(sc->ListID));
/* Prepend "[List name]" to the subject */
* is rude...
*/
ok_to_participate = 0;
- if (msg->cm_fields['N'] != NULL) {
- if (!strcasecmp(msg->cm_fields['N'],
+ if (msg->cm_fields[eNodeName] != NULL) {
+ if (!strcasecmp(msg->cm_fields[eNodeName],
config.c_nodename)) {
ok_to_participate = 1;
}
- Buf = NewStrBufPlain(msg->cm_fields['N'], -1);
+ Buf = NewStrBufPlain(msg->cm_fields[eNodeName], -1);
if (CtdlIsValidNode(NULL,
NULL,
Buf,
* room itself, so the remote listserv doesn't
* reject us.
*/
- CtdlMsgSetCM_Fields(msg, 'F', SKEY(sc->Users[roommailalias]));
+ CtdlMsgSetCM_Fields(msg, erFc822Addr, SKEY(sc->Users[roommailalias]));
valid = validate_recipients(ChrPtr(sc->Users[participate]) , NULL, 0);
- CtdlMsgSetCM_Fields(msg, 'R', SKEY(sc->Users[roommailalias]));
+ CtdlMsgSetCM_Fields(msg, eRecipient, SKEY(sc->Users[roommailalias]));
CtdlSubmitMsg(msg, valid, "", 0);
free_recipients(valid);
}
/* Prepend our node name to the Path field whenever
* sending a message to another IGnet node
*/
- if (msg->cm_fields['P'] == NULL)
+ if (msg->cm_fields[eMessagePath] == NULL)
{
- msg->cm_fields['P'] = strdup("username");
+ msg->cm_fields[eMessagePath] = strdup("username");
}
- newpath_len = strlen(msg->cm_fields['P']) +
+ newpath_len = strlen(msg->cm_fields[eMessagePath]) +
strlen(config.c_nodename) + 2;
newpath = malloc(newpath_len);
snprintf(newpath, newpath_len, "%s!%s",
- config.c_nodename, msg->cm_fields['P']);
- free(msg->cm_fields['P']);
- msg->cm_fields['P'] = newpath;
+ config.c_nodename, msg->cm_fields[eMessagePath]);
+ free(msg->cm_fields[eMessagePath]);
+ msg->cm_fields[eMessagePath] = newpath;
/*
* Determine if this message is set to be deleted
* after sending out on the network
*/
- if (msg->cm_fields['S'] != NULL) {
- if (!strcasecmp(msg->cm_fields['S'], "CANCEL")) {
+ if (msg->cm_fields[eSpecialField] != NULL) {
+ if (!strcasecmp(msg->cm_fields[eSpecialField], "CANCEL")) {
*delete_after_send = 1;
}
}
}
/* Check for split horizon */
- QN_syslog(LOG_DEBUG, "Path is %s\n", msg->cm_fields['P']);
- bang = num_tokens(msg->cm_fields['P'], '!');
+ QN_syslog(LOG_DEBUG, "Path is %s\n", msg->cm_fields[eMessagePath]);
+ bang = num_tokens(msg->cm_fields[eMessagePath], '!');
if (bang > 1) {
for (i=0; i<(bang-1); ++i) {
extract_token(buf,
- msg->cm_fields['P'],
+ msg->cm_fields[eMessagePath],
i, '!',
sizeof buf);
* room on the far end by setting the C field
* correctly
*/
- if (msg->cm_fields['C'] != NULL) {
- free(msg->cm_fields['C']);
+ if (msg->cm_fields[eRemoteRoom] != NULL) {
+ free(msg->cm_fields[eRemoteRoom]);
}
if (StrLength(RemoteRoom) > 0) {
- msg->cm_fields['C'] =
+ msg->cm_fields[eRemoteRoom] =
strdup(ChrPtr(RemoteRoom));
}
else {
- msg->cm_fields['C'] =
+ msg->cm_fields[eRemoteRoom] =
strdup(CC->room.QRname);
}
}
/* Check for message routing */
- if (msg->cm_fields['D'] != NULL) {
- if (strcasecmp(msg->cm_fields['D'], config.c_nodename)) {
+ if (msg->cm_fields[eDestination] != NULL) {
+ if (strcasecmp(msg->cm_fields[eDestination], config.c_nodename)) {
/* route the message */
- Buf = NewStrBufPlain(msg->cm_fields['D'], -1);
+ Buf = NewStrBufPlain(msg->cm_fields[eDestination], -1);
if (CtdlIsValidNode(&nexthop,
NULL,
Buf,
the_netmap) == 0)
{
/* prepend our node to the path */
- if (msg->cm_fields['P'] != NULL) {
- oldpath = msg->cm_fields['P'];
- msg->cm_fields['P'] = NULL;
+ if (msg->cm_fields[eMessagePath] != NULL) {
+ oldpath = msg->cm_fields[eMessagePath];
+ msg->cm_fields[eMessagePath] = NULL;
}
else {
oldpath = strdup("unknown_user");
}
size = strlen(oldpath) + SIZ;
- msg->cm_fields['P'] = malloc(size);
- snprintf(msg->cm_fields['P'], size, "%s!%s",
+ msg->cm_fields[eMessagePath] = malloc(size);
+ snprintf(msg->cm_fields[eMessagePath], size, "%s!%s",
config.c_nodename, oldpath);
free(oldpath);
}
/* Learn network topology from the path */
- if ((msg->cm_fields['N'] != NULL) && (msg->cm_fields['P'] != NULL)) {
- NetworkLearnTopology(msg->cm_fields['N'],
- msg->cm_fields['P'],
+ if ((msg->cm_fields[eNodeName] != NULL) && (msg->cm_fields[eMessagePath] != NULL)) {
+ NetworkLearnTopology(msg->cm_fields[eNodeName],
+ msg->cm_fields[eMessagePath],
the_netmap,
netmap_changed);
}
/* Is the sending node giving us a very persuasive suggestion about
* which room this message should be saved in? If so, go with that.
*/
- if (msg->cm_fields['C'] != NULL) {
- safestrncpy(target_room, msg->cm_fields['C'], sizeof target_room);
+ if (msg->cm_fields[eRemoteRoom] != NULL) {
+ safestrncpy(target_room, msg->cm_fields[eRemoteRoom], sizeof target_room);
}
/* Otherwise, does it have a recipient? If so, validate it... */
- else if (msg->cm_fields['R'] != NULL) {
- recp = validate_recipients(msg->cm_fields['R'], NULL, 0);
+ else if (msg->cm_fields[eRecipient] != NULL) {
+ recp = validate_recipients(msg->cm_fields[eRecipient], NULL, 0);
if (recp != NULL) if (recp->num_error != 0) {
network_bounce(msg,
"A message you sent could not be delivered due to an invalid address.\n"
}
/* Our last shot at finding a home for this message is to see if
- * it has the O field (Originating room) set.
+ * it has the eOriginalRoom (O) field (Originating room) set.
*/
- else if (msg->cm_fields['O'] != NULL) {
- safestrncpy(target_room, msg->cm_fields['O'], sizeof target_room);
+ else if (msg->cm_fields[eOriginalRoom] != NULL) {
+ safestrncpy(target_room, msg->cm_fields[eOriginalRoom], sizeof target_room);
}
/* Strip out fields that are only relevant during transit */
- if (msg->cm_fields['D'] != NULL) {
- free(msg->cm_fields['D']);
- msg->cm_fields['D'] = NULL;
+ if (msg->cm_fields[eDestination] != NULL) {
+ free(msg->cm_fields[eDestination]);
+ msg->cm_fields[eDestination] = NULL;
}
- if (msg->cm_fields['C'] != NULL) {
- free(msg->cm_fields['C']);
- msg->cm_fields['C'] = NULL;
+ if (msg->cm_fields[eRemoteRoom] != NULL) {
+ free(msg->cm_fields[eRemoteRoom]);
+ msg->cm_fields[eRemoteRoom] = NULL;
}
/* save the message into a room */
time_t now;
/* Bail out if we can't generate a message ID */
- if ((msg == NULL) || (msg->cm_fields['I'] == NULL) || (IsEmptyStr(msg->cm_fields['I'])))
+ if ((msg == NULL) || (msg->cm_fields[emessageId] == NULL) || (IsEmptyStr(msg->cm_fields[emessageId])))
{
return(0);
}
/* Generate the message ID */
- msgid = NewStrBufPlain(msg->cm_fields['I'], -1);
+ msgid = NewStrBufPlain(msg->cm_fields[emessageId], -1);
if (haschar(ChrPtr(msgid), '@') == 0) {
StrBufAppendBufPlain(msgid, HKEY("@"), 0);
- if (msg->cm_fields['N'] != NULL) {
- StrBufAppendBufPlain(msgid, msg->cm_fields['N'], -1, 0);
+ if (msg->cm_fields[eNodeName] != NULL) {
+ StrBufAppendBufPlain(msgid, msg->cm_fields[eNodeName], -1, 0);
}
else {
FreeStrBuf(&msgid);
/*
* Give it a fresh message ID
*/
- if (msg->cm_fields['I'] != NULL) {
- free(msg->cm_fields['I']);
+ if (msg->cm_fields[emessageId] != NULL) {
+ free(msg->cm_fields[emessageId]);
}
snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s",
(long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn);
- msg->cm_fields['I'] = strdup(buf);
+ msg->cm_fields[emessageId] = strdup(buf);
/*
* FIXME ... right now we're just sending a bounce; we really want to
* include the text of the bounced message.
*/
- if (msg->cm_fields['M'] != NULL) {
- free(msg->cm_fields['M']);
+ if (msg->cm_fields[eMesageText] != NULL) {
+ free(msg->cm_fields[eMesageText]);
}
- msg->cm_fields['M'] = strdup(reason);
+ msg->cm_fields[eMesageText] = strdup(reason);
msg->cm_format_type = 0;
/*
* Turn the message around
*/
- if (msg->cm_fields['R'] == NULL) {
- free(msg->cm_fields['R']);
+ if (msg->cm_fields[eRecipient] == NULL) {
+ free(msg->cm_fields[eRecipient]);
}
- if (msg->cm_fields['D'] == NULL) {
- free(msg->cm_fields['D']);
+ if (msg->cm_fields[eDestination] == NULL) {
+ free(msg->cm_fields[eDestination]);
}
snprintf(recipient, sizeof recipient, "%s@%s",
- msg->cm_fields['A'], msg->cm_fields['N']);
+ msg->cm_fields[eAuthor], msg->cm_fields[eNodeName]);
- if (msg->cm_fields['A'] == NULL) {
- free(msg->cm_fields['A']);
+ if (msg->cm_fields[eAuthor] == NULL) {
+ free(msg->cm_fields[eAuthor]);
}
- if (msg->cm_fields['N'] == NULL) {
- free(msg->cm_fields['N']);
+ if (msg->cm_fields[eNodeName] == NULL) {
+ free(msg->cm_fields[eNodeName]);
}
- if (msg->cm_fields['U'] == NULL) {
- free(msg->cm_fields['U']);
+ if (msg->cm_fields[eMsgSubject] == NULL) {
+ free(msg->cm_fields[eMsgSubject]);
}
- msg->cm_fields['A'] = strdup(BOUNCESOURCE);
- msg->cm_fields['N'] = strdup(config.c_nodename);
- msg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
+ msg->cm_fields[eAuthor] = strdup(BOUNCESOURCE);
+ msg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ msg->cm_fields[eMsgSubject] = strdup("Delivery Status Notification (Failure)");
/* prepend our node to the path */
- if (msg->cm_fields['P'] != NULL) {
- oldpath = msg->cm_fields['P'];
- msg->cm_fields['P'] = NULL;
+ if (msg->cm_fields[eMessagePath] != NULL) {
+ oldpath = msg->cm_fields[eMessagePath];
+ msg->cm_fields[eMessagePath] = NULL;
}
else {
oldpath = strdup("unknown_user");
}
size = strlen(oldpath) + SIZ;
- msg->cm_fields['P'] = malloc(size);
- snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath);
+ msg->cm_fields[eMessagePath] = malloc(size);
+ snprintf(msg->cm_fields[eMessagePath], size, "%s!%s", config.c_nodename, oldpath);
free(oldpath);
/* Now submit the message */
* any existing message containing that UUID.
*/
strcpy(uuid, "");
- p = msg->cm_fields['M'];
+ p = msg->cm_fields[eMesageText];
a = strlen(p);
while (--a > 0) {
if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */
syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid);
if (!IsEmptyStr(uuid)) {
- if (msg->cm_fields['E'] != NULL) {
- free(msg->cm_fields['E']);
+ if (msg->cm_fields[eExclusiveID] != NULL) {
+ free(msg->cm_fields[eExclusiveID]);
}
- msg->cm_fields['E'] = strdup(uuid);
+ msg->cm_fields[eExclusiveID] = strdup(uuid);
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
+ if (msg->cm_fields[eMsgSubject] != NULL) {
+ free(msg->cm_fields[eMsgSubject]);
}
- msg->cm_fields['U'] = strdup(uuid);
+ msg->cm_fields[eMsgSubject] = strdup(uuid);
}
}
p++;
/* Modern clients are using vNote format. Check for one... */
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*notes_extract_vnote,
NULL, NULL,
if (v->uid) if (!IsEmptyStr(v->uid)) {
syslog(LOG_DEBUG, "UID of vNote is: %s\n", v->uid);
- if (msg->cm_fields['E'] != NULL) {
- free(msg->cm_fields['E']);
+ if (msg->cm_fields[eExclusiveID] != NULL) {
+ free(msg->cm_fields[eExclusiveID]);
}
- msg->cm_fields['E'] = strdup(v->uid);
+ msg->cm_fields[eExclusiveID] = strdup(v->uid);
}
/* Set the message Subject to the vNote Summary */
if (v->summary) if (!IsEmptyStr(v->summary)) {
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
+ if (msg->cm_fields[eMsgSubject] != NULL) {
+ free(msg->cm_fields[eMsgSubject]);
}
- msg->cm_fields['U'] = strdup(v->summary);
- if (strlen(msg->cm_fields['U']) > 72) {
- strcpy(&msg->cm_fields['U'][68], "...");
+ msg->cm_fields[eMsgSubject] = strdup(v->summary);
+ if (strlen(msg->cm_fields[eMsgSubject]) > 72) {
+ strcpy(&msg->cm_fields[eMsgSubject][68], "...");
}
}
/* gather the cheaply computed information now... */
if (ri->guid != NULL) {
- SaveMsg->Msg.cm_fields['E'] = strdup(ChrPtr(ri->guid));
+ SaveMsg->Msg.cm_fields[eExclusiveID] = strdup(ChrPtr(ri->guid));
}
SaveMsg->MsgGUID = guid;
if (ri->pubdate <= 0) {
ri->pubdate = time(NULL); /// TODO: use event time!
}
- SaveMsg->Msg.cm_fields['T'] = malloc(64);
- snprintf(SaveMsg->Msg.cm_fields['T'], 64, "%ld", ri->pubdate);
+ SaveMsg->Msg.cm_fields[eTimestamp] = malloc(64);
+ snprintf(SaveMsg->Msg.cm_fields[eTimestamp], 64, "%ld", ri->pubdate);
if (ri->channel_title != NULL) {
if (StrLength(ri->channel_title) > 0) {
- SaveMsg->Msg.cm_fields['O'] =
+ SaveMsg->Msg.cm_fields[eOriginalRoom] =
strdup(ChrPtr(ri->channel_title));
}
}
if (!FromAt && StrLength (SaveMsg->author_email) > 0)
{
StrBufRFC2047encode(&Encoded, SaveMsg->author_or_creator);
- SaveMsg->Msg.cm_fields['A'] = SmashStrBuf(&Encoded);
- SaveMsg->Msg.cm_fields['P'] =
+ SaveMsg->Msg.cm_fields[eAuthor] = SmashStrBuf(&Encoded);
+ SaveMsg->Msg.cm_fields[eMessagePath] =
SmashStrBuf(&SaveMsg->author_email);
}
else
{
if (FromAt)
{
- SaveMsg->Msg.cm_fields['A'] =
+ SaveMsg->Msg.cm_fields[eAuthor] =
SmashStrBuf(&SaveMsg->author_or_creator);
- SaveMsg->Msg.cm_fields['P'] =
- strdup(SaveMsg->Msg.cm_fields['A']);
+ SaveMsg->Msg.cm_fields[eMessagePath] =
+ strdup(SaveMsg->Msg.cm_fields[eAuthor]);
}
else
{
StrBufRFC2047encode(&Encoded,
SaveMsg->author_or_creator);
- SaveMsg->Msg.cm_fields['A'] =
+ SaveMsg->Msg.cm_fields[eAuthor] =
SmashStrBuf(&Encoded);
- SaveMsg->Msg.cm_fields['P'] =
+ SaveMsg->Msg.cm_fields[eMessagePath] =
strdup("rss@localhost");
}
}
}
else {
- SaveMsg->Msg.cm_fields['A'] = strdup("rss");
+ SaveMsg->Msg.cm_fields[eAuthor] = strdup("rss");
}
- SaveMsg->Msg.cm_fields['N'] = strdup(NODENAME);
+ SaveMsg->Msg.cm_fields[eNodeName] = strdup(NODENAME);
if (SaveMsg->title != NULL) {
long len;
char *Sbj;
StrBufTrim(Encoded);
StrBufRFC2047encode(&QPEncoded, Encoded);
- SaveMsg->Msg.cm_fields['U'] = SmashStrBuf(&QPEncoded);
+ SaveMsg->Msg.cm_fields[eMsgSubject] = SmashStrBuf(&QPEncoded);
FreeStrBuf(&Encoded);
}
if (SaveMsg->link == NULL)
if (rss_format_item(IO, RSSAggr->ThisMsg))
{
- RSSAggr->ThisMsg->Msg.cm_fields['M'] =
+ RSSAggr->ThisMsg->Msg.cm_fields[eMesageText] =
SmashStrBuf(&RSSAggr->ThisMsg->Message);
CtdlSubmitMsg(&RSSAggr->ThisMsg->Msg, &RSSAggr->recp, NULL, 0);
my.u = u; /* Hand off a pointer to the rest of this info */
/* Keep track of the recipient so we can do handling based on it later */
- process_rfc822_addr(msg->cm_fields['R'], my.recp_user, my.recp_node, my.recp_name);
+ process_rfc822_addr(msg->cm_fields[eRecipient], my.recp_user, my.recp_node, my.recp_name);
/* Keep track of the sender so we can use it for REJECT and VACATION responses */
- if (msg->cm_fields['F'] != NULL) {
- safestrncpy(my.sender, msg->cm_fields['F'], sizeof my.sender);
+ if (msg->cm_fields[erFc822Addr] != NULL) {
+ safestrncpy(my.sender, msg->cm_fields[erFc822Addr], sizeof my.sender);
}
- else if ( (msg->cm_fields['A'] != NULL) && (msg->cm_fields['N'] != NULL) ) {
- snprintf(my.sender, sizeof my.sender, "%s@%s", msg->cm_fields['A'], msg->cm_fields['N']);
+ else if ( (msg->cm_fields[eAuthor] != NULL) && (msg->cm_fields[eNodeName] != NULL) ) {
+ snprintf(my.sender, sizeof my.sender, "%s@%s", msg->cm_fields[eAuthor], msg->cm_fields[eNodeName]);
}
- else if (msg->cm_fields['A'] != NULL) {
- safestrncpy(my.sender, msg->cm_fields['A'], sizeof my.sender);
+ else if (msg->cm_fields[eAuthor] != NULL) {
+ safestrncpy(my.sender, msg->cm_fields[eAuthor], sizeof my.sender);
}
else {
strcpy(my.sender, "");
}
/* Keep track of the subject so we can use it for VACATION responses */
- if (msg->cm_fields['U'] != NULL) {
- safestrncpy(my.subject, msg->cm_fields['U'], sizeof my.subject);
+ if (msg->cm_fields[eMsgSubject] != NULL) {
+ safestrncpy(my.subject, msg->cm_fields[eMsgSubject], sizeof my.subject);
}
else {
strcpy(my.subject, "");
}
/* Keep track of the envelope-from address (use body-from if not found) */
- if (msg->cm_fields['P'] != NULL) {
- safestrncpy(my.envelope_from, msg->cm_fields['P'], sizeof my.envelope_from);
+ if (msg->cm_fields[eMessagePath] != NULL) {
+ safestrncpy(my.envelope_from, msg->cm_fields[eMessagePath], sizeof my.envelope_from);
stripallbut(my.envelope_from, '<', '>');
}
- else if (msg->cm_fields['F'] != NULL) {
- safestrncpy(my.envelope_from, msg->cm_fields['F'], sizeof my.envelope_from);
+ else if (msg->cm_fields[erFc822Addr] != NULL) {
+ safestrncpy(my.envelope_from, msg->cm_fields[erFc822Addr], sizeof my.envelope_from);
stripallbut(my.envelope_from, '<', '>');
}
else {
}
/* Keep track of the envelope-to address (use body-to if not found) */
- if (msg->cm_fields['V'] != NULL) {
- safestrncpy(my.envelope_to, msg->cm_fields['V'], sizeof my.envelope_to);
+ if (msg->cm_fields[eenVelopeTo] != NULL) {
+ safestrncpy(my.envelope_to, msg->cm_fields[eenVelopeTo], sizeof my.envelope_to);
stripallbut(my.envelope_to, '<', '>');
}
- else if (msg->cm_fields['R'] != NULL) {
- safestrncpy(my.envelope_to, msg->cm_fields['R'], sizeof my.envelope_to);
- if (msg->cm_fields['D'] != NULL) {
+ else if (msg->cm_fields[eRecipient] != NULL) {
+ safestrncpy(my.envelope_to, msg->cm_fields[eRecipient], sizeof my.envelope_to);
+ if (msg->cm_fields[eDestination] != NULL) {
strcat(my.envelope_to, "@");
- strcat(my.envelope_to, msg->cm_fields['D']);
+ strcat(my.envelope_to, msg->cm_fields[eDestination]);
}
stripallbut(my.envelope_to, '<', '>');
}
return;
}
- conf = msg->cm_fields['M'];
- msg->cm_fields['M'] = NULL;
+ conf = msg->cm_fields[eMesageText];
+ msg->cm_fields[eMesageText] = NULL;
CtdlFreeMessage(msg);
if (conf != NULL) {
return;
}
- if ( (msg->cm_fields['U']) && (!strcasecmp(msg->cm_fields['U'], "__ WebCit Preferences __")) ) {
+ if ( (msg->cm_fields[eMsgSubject]) && (!strcasecmp(msg->cm_fields[eMsgSubject], "__ WebCit Preferences __")) ) {
/* This is it! Change ownership of the message text so it doesn't get freed. */
- *webcit_conf = (char *)msg->cm_fields['M'];
- msg->cm_fields['M'] = NULL;
+ *webcit_conf = (char *)msg->cm_fields[eMesageText];
+ msg->cm_fields[eMesageText] = NULL;
}
CtdlFreeMessage(msg);
}
if ( (CCC->logged_in) && (config.c_rfc822_strict_from != CFG_SMTP_FROM_NOFILTER) ) {
int validemail = 0;
- if (!IsEmptyStr(msg->cm_fields['F']) &&
+ if (!IsEmptyStr(msg->cm_fields[erFc822Addr]) &&
((config.c_rfc822_strict_from == CFG_SMTP_FROM_CORRECT) ||
(config.c_rfc822_strict_from == CFG_SMTP_FROM_REJECT) ) )
{
if (!IsEmptyStr(CCC->cs_inet_email))
- validemail = strcmp(CCC->cs_inet_email, msg->cm_fields['F']) == 0;
+ validemail = strcmp(CCC->cs_inet_email, msg->cm_fields[erFc822Addr]) == 0;
if ((!validemail) &&
(!IsEmptyStr(CCC->cs_inet_other_emails)))
{
for (i=0; i < num_secondary_emails && !validemail; ++i) {
char buf[256];
extract_token(buf, CCC->cs_inet_other_emails,i,'|',sizeof CCC->cs_inet_other_emails);
- validemail = strcmp(buf, msg->cm_fields['F']) == 0;
+ validemail = strcmp(buf, msg->cm_fields[erFc822Addr]) == 0;
}
}
}
if (!validemail && (config.c_rfc822_strict_from == CFG_SMTP_FROM_REJECT)) {
- syslog(LOG_ERR, "invalid sender '%s' - rejecting this message", msg->cm_fields['F']);
- cprintf("550 Invalid sender '%s' - rejecting this message.\r\n", msg->cm_fields['F']);
+ syslog(LOG_ERR, "invalid sender '%s' - rejecting this message", msg->cm_fields[erFc822Addr]);
+ cprintf("550 Invalid sender '%s' - rejecting this message.\r\n", msg->cm_fields[erFc822Addr]);
return;
}
- if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']);
- if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']);
- if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']);
- if (msg->cm_fields['O'] != NULL) free(msg->cm_fields['O']);
- msg->cm_fields['A'] = strdup(CCC->user.fullname);
- msg->cm_fields['N'] = strdup(config.c_nodename);
- msg->cm_fields['H'] = strdup(config.c_humannode);
- msg->cm_fields['O'] = strdup(MAILROOM);
+ if (msg->cm_fields[eAuthor] != NULL) free(msg->cm_fields[eAuthor]);
+ if (msg->cm_fields[eNodeName] != NULL) free(msg->cm_fields[eNodeName]);
+ if (msg->cm_fields[eHumanNode] != NULL) free(msg->cm_fields[eHumanNode]);
+ if (msg->cm_fields[eOriginalRoom] != NULL) free(msg->cm_fields[eOriginalRoom]);
+ msg->cm_fields[eAuthor] = strdup(CCC->user.fullname);
+ msg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ msg->cm_fields[eHumanNode] = strdup(config.c_humannode);
+ msg->cm_fields[eOriginalRoom] = strdup(MAILROOM);
if (!validemail) {
- if (msg->cm_fields['F'] != NULL) free(msg->cm_fields['F']);
- msg->cm_fields['F'] = strdup(CCC->cs_inet_email);
+ if (msg->cm_fields[erFc822Addr] != NULL) free(msg->cm_fields[erFc822Addr]);
+ msg->cm_fields[erFc822Addr] = strdup(CCC->cs_inet_email);
}
}
/* Set the "envelope from" address */
- if (msg->cm_fields['P'] != NULL) {
- free(msg->cm_fields['P']);
+ if (msg->cm_fields[eMessagePath] != NULL) {
+ free(msg->cm_fields[eMessagePath]);
}
- msg->cm_fields['P'] = strdup(ChrPtr(sSMTP->from));
+ msg->cm_fields[eMessagePath] = strdup(ChrPtr(sSMTP->from));
/* Set the "envelope to" address */
- if (msg->cm_fields['V'] != NULL) {
- free(msg->cm_fields['V']);
+ if (msg->cm_fields[eenVelopeTo] != NULL) {
+ free(msg->cm_fields[eenVelopeTo]);
}
- msg->cm_fields['V'] = strdup(ChrPtr(sSMTP->recipients));
+ msg->cm_fields[eenVelopeTo] = strdup(ChrPtr(sSMTP->recipients));
/* Submit the message into the Citadel system. */
valid = validate_recipients(
if (scan_errors > 0) { /* We don't want this message! */
- if (msg->cm_fields['0'] == NULL) {
- msg->cm_fields['0'] = strdup("Message rejected by filter");
+ if (msg->cm_fields[eErrorMsg] == NULL) {
+ msg->cm_fields[eErrorMsg] = strdup("Message rejected by filter");
}
- StrBufPrintf(sSMTP->OneRcpt, "550 %s\r\n", msg->cm_fields['0']);
+ StrBufPrintf(sSMTP->OneRcpt, "550 %s\r\n", msg->cm_fields[eErrorMsg]);
}
else { /* Ok, we'll accept this message. */
msg->cm_magic = CTDLMESSAGE_MAGIC;
msg->cm_anon_type = MES_NORMAL;
msg->cm_format_type = FMT_RFC822;
- msg->cm_fields['M'] = SmashStrBuf(&Msg->QMsgData);
- msg->cm_fields['U'] = strdup("QMSG");
+ msg->cm_fields[eMesageText] = SmashStrBuf(&Msg->QMsgData);
+ msg->cm_fields[eMsgSubject] = strdup("QMSG");
Msg->MyQItem->QueMsgID =
CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
EVS_syslog(LOG_DEBUG, "%ld", Msg->MyQItem->QueMsgID);
bmsg->cm_anon_type = MES_NORMAL;
bmsg->cm_format_type = FMT_RFC822;
- bmsg->cm_fields['O'] = strdup(MAILROOM);
- bmsg->cm_fields['A'] = strdup("Citadel");
- bmsg->cm_fields['N'] = strdup(config.c_nodename);
- bmsg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
- bmsg->cm_fields['M'] = SmashStrBuf(&BounceMB);
+ bmsg->cm_fields[eOriginalRoom] = strdup(MAILROOM);
+ bmsg->cm_fields[eAuthor] = strdup("Citadel");
+ bmsg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ bmsg->cm_fields[eMsgSubject] = strdup("Delivery Status Notification (Failure)");
+ bmsg->cm_fields[eMesageText] = SmashStrBuf(&BounceMB);
/* First try the user who sent the message */
if (StrLength(MyQItem->BounceTo) == 0) {
return;
}
- pch = instr = msg->cm_fields['M'];
+ pch = instr = msg->cm_fields[eMesageText];
/* Strip out the headers (no not amd any other non-instruction) line */
while (pch != NULL) {
bmsg->cm_magic = CTDLMESSAGE_MAGIC;
bmsg->cm_anon_type = MES_NORMAL;
bmsg->cm_format_type = FMT_RFC822;
- bmsg->cm_fields['A'] = strdup("Citadel");
- bmsg->cm_fields['O'] = strdup(MAILROOM);
- bmsg->cm_fields['N'] = strdup(config.c_nodename);
- bmsg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
+ bmsg->cm_fields[eAuthor] = strdup("Citadel");
+ bmsg->cm_fields[eOriginalRoom] = strdup(MAILROOM);
+ bmsg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ bmsg->cm_fields[eMsgSubject] = strdup("Delivery Status Notification (Failure)");
StrBufAppendBufPlain(
BounceMB,
HKEY("Content-type: multipart/mixed; boundary=\""), 0);
StrBufAppendBufPlain(BounceMB, HKEY("--"), 0);
StrBufAppendBuf(BounceMB, boundary, 0);
StrBufAppendBufPlain(BounceMB, HKEY("--\r\n"), 0);
- if (bmsg->cm_fields['A'] != NULL)
- free(bmsg->cm_fields['A']);
- bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB);
+ if (bmsg->cm_fields[eAuthor] != NULL)
+ free(bmsg->cm_fields[eAuthor]);
+ bmsg->cm_fields[eAuthor] = SmashStrBuf(&BounceMB);
/* Deliver the bounce if there's anything worth mentioning */
syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
if (num_bounces > 0) {
sprintf(cur,"\r\nX-Spam-Status: %s, score=%s required=%s\r\n", sastatus, sascore, saoutof);
headerlen = strlen(buf);
- oldmsgsize = strlen(msg->cm_fields['M']) + 1;
+ oldmsgsize = strlen(msg->cm_fields[eMesageText]) + 1;
newmsgsize = headerlen + oldmsgsize;
- msg->cm_fields['M'] = realloc(msg->cm_fields['M'], newmsgsize);
+ msg->cm_fields[eMesageText] = realloc(msg->cm_fields[eMesageText], newmsgsize);
- memmove(msg->cm_fields['M']+headerlen,msg->cm_fields['M'],oldmsgsize);
- memcpy(msg->cm_fields['M'],buf,headerlen);
+ memmove(msg->cm_fields[eMesageText]+headerlen,msg->cm_fields[eMesageText],oldmsgsize);
+ memcpy(msg->cm_fields[eMesageText],buf,headerlen);
} else {
syslog(LOG_DEBUG, "reject spam code used");
}
if (is_spam) {
- if (msg->cm_fields['0'] != NULL) {
- free(msg->cm_fields['0']);
+ if (msg->cm_fields[eErrorMsg] != NULL) {
+ free(msg->cm_fields[eErrorMsg]);
}
- msg->cm_fields['0'] = strdup("message rejected by spam filter");
+ msg->cm_fields[eErrorMsg] = strdup("message rejected by spam filter");
}
}
int instance = 0;
int found_something = 0;
- if (msg->cm_fields['A'] == NULL) return;
- if (msg->cm_fields['N'] == NULL) return;
+ if (msg->cm_fields[eAuthor] == NULL) return;
+ if (msg->cm_fields[eNodeName] == NULL) return;
snprintf(citadel_address, sizeof citadel_address, "%s @ %s",
- msg->cm_fields['A'], msg->cm_fields['N']);
+ msg->cm_fields[eAuthor], msg->cm_fields[eNodeName]);
- v = vcard_load(msg->cm_fields['M']);
+ v = vcard_load(msg->cm_fields[eMesageText]);
if (v == NULL) return;
/* Go through the vCard searching for *all* instances of
/* Ok, if we got this far, look into the situation further... */
- ptr = msg->cm_fields['M'];
+ ptr = msg->cm_fields[eMesageText];
if (ptr == NULL) return(0);
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*vcard_extract_vcard,
NULL, NULL,
CtdlDeleteMessages(CCC->room.QRname, NULL, 0, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$");
/* Make the author of the message the name of the user. */
- if (msg->cm_fields['A'] != NULL) {
- free(msg->cm_fields['A']);
+ if (msg->cm_fields[eAuthor] != NULL) {
+ free(msg->cm_fields[eAuthor]);
}
- msg->cm_fields['A'] = strdup(usbuf.fullname);
+ msg->cm_fields[eAuthor] = strdup(usbuf.fullname);
}
/* Insert or replace RFC2739-compliant free/busy URL */
/* Enforce local UID policy if applicable */
if (yes_my_citadel_config) {
- snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields['A'], NODENAME);
+ snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields[eAuthor], NODENAME);
vcard_set_prop(v, "UID", buf, 0);
}
/*
* Set the EUID of the message to the UID of the vCard.
*/
- if (msg->cm_fields['E'] != NULL)
+ if (msg->cm_fields[eExclusiveID] != NULL)
{
- free(msg->cm_fields['E']);
- msg->cm_fields['E'] = NULL;
+ free(msg->cm_fields[eExclusiveID]);
+ msg->cm_fields[eExclusiveID] = NULL;
}
s = vcard_get_prop(v, "UID", 1, 0, 0);
if (s != NULL) {
- msg->cm_fields['E'] = strdup(s);
- if (msg->cm_fields['U'] == NULL) {
- msg->cm_fields['U'] = strdup(s);
+ msg->cm_fields[eExclusiveID] = strdup(s);
+ if (msg->cm_fields[eMsgSubject] == NULL) {
+ msg->cm_fields[eMsgSubject] = strdup(s);
}
}
s = vcard_get_prop(v, "N", 1, 0, 0);
}
if (s != NULL) {
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
+ if (msg->cm_fields[eMsgSubject] != NULL) {
+ free(msg->cm_fields[eMsgSubject]);
}
- msg->cm_fields['U'] = strdup(s);
+ msg->cm_fields[eMsgSubject] = strdup(s);
}
/* Re-serialize it back into the msg body */
ser = vcard_serialize(v);
if (ser != NULL) {
- msg->cm_fields['M'] = realloc(msg->cm_fields['M'], strlen(ser) + 1024);
- sprintf(msg->cm_fields['M'],
+ msg->cm_fields[eMesageText] = realloc(msg->cm_fields[eMesageText], strlen(ser) + 1024);
+ sprintf(msg->cm_fields[eMesageText],
"Content-type: " VCARD_MIME_TYPE
"\r\n\r\n%s\r\n", ser);
free(ser);
if (!is_UserConf && !is_GAB) return(0);
- ptr = msg->cm_fields['M'];
+ ptr = msg->cm_fields[eMesageText];
if (ptr == NULL) return(0);
NewStrBufDupAppendFlush(&CCC->StatusMessage, NULL, NULL, 0);
* copy it to the Global Address Book room.
*/
- I = atol(msg->cm_fields['3']);
+ I = atol(msg->cm_fields[eVltMsgNum]);
if (I <= 0L) return(0);
/* Store our Internet return address in memory */
if (is_MY_UserConf) {
- v = vcard_load(msg->cm_fields['M']);
+ v = vcard_load(msg->cm_fields[eMesageText]);
extract_inet_email_addrs(CCC->cs_inet_email, sizeof CCC->cs_inet_email,
CCC->cs_inet_other_emails, sizeof CCC->cs_inet_other_emails,
v, 1);
msg = CtdlFetchMessage(VCmsgnum, 1);
if (msg == NULL) return vcard_new();
- v = vcard_load(msg->cm_fields['M']);
+ v = vcard_load(msg->cm_fields[eMesageText]);
CtdlFreeMessage(msg);
return v;
}
msg->cm_magic = CTDLMESSAGE_MAGIC;
msg->cm_anon_type = MES_NORMAL;
msg->cm_format_type = 0;
- msg->cm_fields['A'] = strdup(usbuf->fullname);
- msg->cm_fields['O'] = strdup(ADDRESS_BOOK_ROOM);
- msg->cm_fields['N'] = strdup(NODENAME);
- msg->cm_fields['M'] = strdup("Purge this vCard\n");
+ msg->cm_fields[eAuthor] = strdup(usbuf->fullname);
+ msg->cm_fields[eOriginalRoom] = strdup(ADDRESS_BOOK_ROOM);
+ msg->cm_fields[eNodeName] = strdup(NODENAME);
+ msg->cm_fields[eMesageText] = strdup("Purge this vCard\n");
snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
- msg->cm_fields['A'], NODENAME);
- msg->cm_fields['E'] = strdup(buf);
+ msg->cm_fields[eAuthor], NODENAME);
+ msg->cm_fields[eExclusiveID] = strdup(buf);
- msg->cm_fields['S'] = strdup("CANCEL");
+ msg->cm_fields[eSpecialField] = strdup("CANCEL");
CtdlSubmitMsg(msg, NULL, ADDRESS_BOOK_ROOM, QP_EADDR);
CtdlFreeMessage(msg);
if (msg->cm_format_type != 4) return(0);
- ptr = msg->cm_fields['M'];
+ ptr = msg->cm_fields[eMesageText];
if (ptr == NULL) return(0);
while (ptr != NULL) {
msg = CtdlFetchMessage(msgnum, 1);
if (msg == NULL) return;
- ptr = msg->cm_fields['M'];
+ ptr = msg->cm_fields[eMesageText];
if (ptr == NULL) goto EOH;
while (ptr != NULL) {
linelen = strcspn(ptr, "\n");
msg = CtdlFetchMessage(msgnum, 1);
if (msg == NULL) return;
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*dvca_mime_callback, /* callback function */
NULL, NULL,
msg = CtdlFetchMessage(msgnum, 1);
if (msg == NULL) return;
- v = vcard_load(msg->cm_fields['M']);
+ v = vcard_load(msg->cm_fields[eMesageText]);
CtdlFreeMessage(msg);
i = 0;
vmsg->cm_magic = CTDLMESSAGE_MAGIC;
vmsg->cm_anon_type = MES_NORMAL;
vmsg->cm_format_type = FMT_RFC822;
- vmsg->cm_fields['A'] = strdup("Citadel");
- vmsg->cm_fields['E'] = strdup(vcard_get_prop(v, "UID", 1, 0, 0));
+ vmsg->cm_fields[eAuthor] = strdup("Citadel");
+ vmsg->cm_fields[eExclusiveID] = strdup(vcard_get_prop(v, "UID", 1, 0, 0));
ser = vcard_serialize(v);
if (ser != NULL) {
- vmsg->cm_fields['M'] = malloc(strlen(ser) + 1024);
- sprintf(vmsg->cm_fields['M'],
+ vmsg->cm_fields[eMesageText] = malloc(strlen(ser) + 1024);
+ sprintf(vmsg->cm_fields[eMesageText],
"Content-type: " VCARD_MIME_TYPE
"\r\n\r\n%s\r\n", ser);
free(ser);
if (msg->cm_format_type != 4) return(0);
/* If there's no EUID we can't do this. Reject the post. */
- if (msg->cm_fields['E'] == NULL) return(1);
+ if (msg->cm_fields[eExclusiveID] == NULL) return(1);
- snprintf(history_page, sizeof history_page, "%s_HISTORY_", msg->cm_fields['E']);
+ snprintf(history_page, sizeof history_page, "%s_HISTORY_", msg->cm_fields[eExclusiveID]);
/* Make sure we're saving a real wiki page rather than a wiki history page.
* This is important in order to avoid recursing infinitely into this hook.
*/
- if ( (strlen(msg->cm_fields['E']) >= 9)
- && (!strcasecmp(&msg->cm_fields['E'][strlen(msg->cm_fields['E'])-9], "_HISTORY_"))
+ if ( (strlen(msg->cm_fields[eExclusiveID]) >= 9)
+ && (!strcasecmp(&msg->cm_fields[eExclusiveID][strlen(msg->cm_fields[eExclusiveID])-9], "_HISTORY_"))
) {
syslog(LOG_DEBUG, "History page not being historied\n");
return(0);
}
/* If there's no message text, obviously this is all b0rken and shouldn't happen at all */
- if (msg->cm_fields['M'] == NULL) return(0);
+ if (msg->cm_fields[eMesageText] == NULL) return(0);
/* Set the message subject identical to the page name */
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
+ if (msg->cm_fields[eMsgSubject] != NULL) {
+ free(msg->cm_fields[eMsgSubject]);
}
- msg->cm_fields['U'] = strdup(msg->cm_fields['E']);
+ msg->cm_fields[eMsgSubject] = strdup(msg->cm_fields[eExclusiveID]);
/* See if we can retrieve the previous version. */
- old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields['E'], &CCC->room);
+ old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields[eExclusiveID], &CCC->room);
if (old_msgnum > 0L) {
old_msg = CtdlFetchMessage(old_msgnum, 1);
}
old_msg = NULL;
}
- if ((old_msg != NULL) && (old_msg->cm_fields['M'] == NULL)) { /* old version is corrupt? */
+ if ((old_msg != NULL) && (old_msg->cm_fields[eMesageText] == NULL)) { /* old version is corrupt? */
CtdlFreeMessage(old_msg);
old_msg = NULL;
}
/* If no changes were made, don't bother saving it again */
- if ((old_msg != NULL) && (!strcmp(msg->cm_fields['M'], old_msg->cm_fields['M']))) {
+ if ((old_msg != NULL) && (!strcmp(msg->cm_fields[eMesageText], old_msg->cm_fields[eMesageText]))) {
CtdlFreeMessage(old_msg);
return(1);
}
if (old_msg != NULL) {
fp = fopen(diff_old_filename, "w");
- rv = fwrite(old_msg->cm_fields['M'], strlen(old_msg->cm_fields['M']), 1, fp);
+ rv = fwrite(old_msg->cm_fields[eMesageText], strlen(old_msg->cm_fields[eMesageText]), 1, fp);
fclose(fp);
CtdlFreeMessage(old_msg);
}
fp = fopen(diff_new_filename, "w");
- rv = fwrite(msg->cm_fields['M'], strlen(msg->cm_fields['M']), 1, fp);
+ rv = fwrite(msg->cm_fields[eMesageText], strlen(msg->cm_fields[eMesageText]), 1, fp);
fclose(fp);
snprintf(diff_cmd, sizeof diff_cmd,
history_msg->cm_magic = CTDLMESSAGE_MAGIC;
history_msg->cm_anon_type = MES_NORMAL;
history_msg->cm_format_type = FMT_RFC822;
- history_msg->cm_fields['A'] = strdup("Citadel");
- history_msg->cm_fields['R'] = strdup(CCC->room.QRname);
- history_msg->cm_fields['E'] = strdup(history_page);
- history_msg->cm_fields['U'] = strdup(history_page);
- history_msg->cm_fields['1'] = strdup("1"); /* suppress full text indexing */
+ history_msg->cm_fields[eAuthor] = strdup("Citadel");
+ history_msg->cm_fields[eRecipient] = strdup(CCC->room.QRname);
+ history_msg->cm_fields[eExclusiveID] = strdup(history_page);
+ history_msg->cm_fields[eMsgSubject] = strdup(history_page);
+ history_msg->cm_fields[eSuppressIdx] = strdup("1"); /* suppress full text indexing */
snprintf(boundary, sizeof boundary, "Citadel--Multipart--%04x--%08lx", getpid(), time(NULL));
- history_msg->cm_fields['M'] = malloc(1024);
- snprintf(history_msg->cm_fields['M'], 1024,
+ history_msg->cm_fields[eMesageText] = malloc(1024);
+ snprintf(history_msg->cm_fields[eMesageText], 1024,
"Content-type: multipart/mixed; boundary=\"%s\"\n\n"
"This is a Citadel wiki history encoded as multipart MIME.\n"
"Each part is comprised of a diff script representing one change set.\n"
/* Remove the Message-ID from the old version of the history message. This will cause a brand
* new one to be generated, avoiding an uninitentional hit of the loop zapper when we replicate.
*/
- if (history_msg->cm_fields['I'] != NULL) {
- free(history_msg->cm_fields['I']);
- history_msg->cm_fields['I'] = NULL;
+ if (history_msg->cm_fields[emessageId] != NULL) {
+ free(history_msg->cm_fields[emessageId]);
+ history_msg->cm_fields[emessageId] = NULL;
}
/* Figure out the boundary string. We do this even when we generated the
*/
strcpy(boundary, "");
- ptr = history_msg->cm_fields['M'];
+ ptr = history_msg->cm_fields[eMesageText];
do {
ptr = memreadline(ptr, buf, sizeof buf);
if (*ptr != 0) {
*/
if (!IsEmptyStr(boundary)) {
snprintf(prefixed_boundary, sizeof prefixed_boundary, "--%s", boundary);
- history_msg->cm_fields['M'] = realloc(history_msg->cm_fields['M'],
- strlen(history_msg->cm_fields['M']) + strlen(diffbuf) + 1024
+ history_msg->cm_fields[eMesageText] = realloc(history_msg->cm_fields[eMesageText],
+ strlen(history_msg->cm_fields[eMesageText]) + strlen(diffbuf) + 1024
);
- ptr = bmstrcasestr(history_msg->cm_fields['M'], prefixed_boundary);
+ ptr = bmstrcasestr(history_msg->cm_fields[eMesageText], prefixed_boundary);
if (ptr != NULL) {
char *the_rest_of_it = strdup(ptr);
char uuid[64];
free(the_rest_of_it);
}
- history_msg->cm_fields['T'] = realloc(history_msg->cm_fields['T'], 32);
- if (history_msg->cm_fields['T'] != NULL) {
- snprintf(history_msg->cm_fields['T'], 32, "%ld", time(NULL));
+ history_msg->cm_fields[eTimestamp] = realloc(history_msg->cm_fields[eTimestamp], 32);
+ if (history_msg->cm_fields[eTimestamp] != NULL) {
+ snprintf(history_msg->cm_fields[eTimestamp], 32, "%ld", time(NULL));
}
CtdlSubmitMsg(history_msg, NULL, "", 0);
msg = NULL;
}
- if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) {
+ if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) {
CtdlFreeMessage(msg);
msg = NULL;
}
cprintf("%d Revision history for '%s'\n", LISTING_FOLLOWS, pagename);
- mime_parser(msg->cm_fields['M'], NULL, *wiki_history_callback, NULL, NULL, NULL, 0);
+ mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_history_callback, NULL, NULL, NULL, 0);
cprintf("000\n");
CtdlFreeMessage(msg);
msg = NULL;
}
- if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) {
+ if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) {
CtdlFreeMessage(msg);
msg = NULL;
}
CtdlMakeTempFileName(temp, sizeof temp);
fp = fopen(temp, "w");
if (fp != NULL) {
- r = fwrite(msg->cm_fields['M'], strlen(msg->cm_fields['M']), 1, fp);
+ r = fwrite(msg->cm_fields[eMesageText], strlen(msg->cm_fields[eMesageText]), 1, fp);
fclose(fp);
}
else {
msg = NULL;
}
- if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) {
+ if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) {
CtdlFreeMessage(msg);
msg = NULL;
}
hecbd.stop_when = rev;
striplt(hecbd.stop_when);
- mime_parser(msg->cm_fields['M'], NULL, *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
+ mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
CtdlFreeMessage(msg);
/* Were we successful? */
fseek(fp, 0L, SEEK_END);
len = ftell(fp);
fseek(fp, 0L, SEEK_SET);
- msg->cm_fields['M'] = malloc(len + 1);
- rv = fread(msg->cm_fields['M'], len, 1, fp);
+ msg->cm_fields[eMesageText] = malloc(len + 1);
+ rv = fread(msg->cm_fields[eMesageText], len, 1, fp);
syslog(LOG_DEBUG, "did %d blocks of %ld bytes\n", rv, len);
- msg->cm_fields['M'][len] = 0;
+ msg->cm_fields[eMesageText][len] = 0;
fclose(fp);
}
if (len <= 0) {
msgnum = (-1L);
}
else if (!strcasecmp(operation, "fetch")) {
- msg->cm_fields['A'] = strdup("Citadel");
+ msg->cm_fields[eAuthor] = strdup("Citadel");
CtdlCreateRoom(wwm, 5, "", 0, 1, 1, VIEW_BBS); /* Not an error if already exists */
msgnum = CtdlSubmitMsg(msg, NULL, wwm, 0); /* Store the revision here */
}
else if (!strcasecmp(operation, "revert")) {
snprintf(timestamp, sizeof timestamp, "%ld", time(NULL));
- msg->cm_fields['T'] = strdup(timestamp);
- msg->cm_fields['A'] = strdup(CC->user.fullname);
- msg->cm_fields['F'] = strdup(CC->cs_inet_email);
- msg->cm_fields['O'] = strdup(CC->room.QRname);
- msg->cm_fields['N'] = strdup(NODENAME);
- msg->cm_fields['E'] = strdup(pagename);
+ msg->cm_fields[eTimestamp] = strdup(timestamp);
+ msg->cm_fields[eAuthor] = strdup(CC->user.fullname);
+ msg->cm_fields[erFc822Addr] = strdup(CC->cs_inet_email);
+ msg->cm_fields[eOriginalRoom] = strdup(CC->room.QRname);
+ msg->cm_fields[eNodeName] = strdup(NODENAME);
+ msg->cm_fields[eExclusiveID] = strdup(pagename);
msgnum = CtdlSubmitMsg(msg, NULL, "", 0); /* Replace the current revision */
}
else {
/* now add anyone we find into the hashlist */
/* skip past the headers */
- ptr = strstr(msg->cm_fields['M'], "\n\n");
+ ptr = strstr(msg->cm_fields[eMesageText], "\n\n");
if (ptr != NULL) {
ptr += 2;
}
else {
- ptr = strstr(msg->cm_fields['M'], "\n\r\n");
+ ptr = strstr(msg->cm_fields[eMesageText], "\n\r\n");
if (ptr != NULL) {
ptr += 3;
}
NULL /* Z */
};
-void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, const char which, const char *buf, long length)
+eMsgField FieldOrder[] = {
+/* Important fields */
+ emessageId ,
+ eMessagePath ,
+ eTimestamp ,
+ eAuthor ,
+ erFc822Addr ,
+ eOriginalRoom,
+ eNodeName ,
+ eHumanNode ,
+ eRecipient ,
+ eDestination ,
+/* Semi-important fields */
+ eBig_message ,
+ eRemoteRoom ,
+ eExclusiveID ,
+ eWeferences ,
+ eJournal ,
+/* G is not used yet, may become virus signature*/
+ eReplyTo ,
+ eListID ,
+/* Q is not used yet */
+ eSpecialField,
+ eenVelopeTo ,
+/* X is not used yet */
+/* Z is not used yet */
+ eCarbonCopY ,
+ eMsgSubject ,
+/* internal only */
+ eErrorMsg ,
+ eSuppressIdx ,
+ eExtnotify ,
+/* Message text (MUST be last) */
+ eMesageText
+/* Not saved to disk:
+ eVltMsgNum
+*/
+};
+
+static const long NDiskFields = sizeof(FieldOrder) / sizeof(eMsgField);
+void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, eMsgField which, const char *buf, long length)
{
if (Msg->cm_fields[which] != NULL)
free (Msg->cm_fields[which]);
cprintf("%ld|%s|%s|%s|%s|%s|\n",
msgnum,
- (msg->cm_fields['T'] ? msg->cm_fields['T'] : "0"),
- (msg->cm_fields['A'] ? msg->cm_fields['A'] : ""),
- (msg->cm_fields['N'] ? msg->cm_fields['N'] : ""),
- (msg->cm_fields['F'] ? msg->cm_fields['F'] : ""),
- (msg->cm_fields['U'] ? msg->cm_fields['U'] : "")
+ (msg->cm_fields[eTimestamp] ? msg->cm_fields[eTimestamp] : "0"),
+ (msg->cm_fields[eAuthor] ? msg->cm_fields[eAuthor] : ""),
+ (msg->cm_fields[eNodeName] ? msg->cm_fields[eNodeName] : ""),
+ (msg->cm_fields[erFc822Addr] ? msg->cm_fields[erFc822Addr] : ""),
+ (msg->cm_fields[eMsgSubject] ? msg->cm_fields[eMsgSubject] : "")
);
CtdlFreeMessage(msg);
}
cprintf("%ld|%s|%s\n",
msgnum,
- (msg->cm_fields['E'] ? msg->cm_fields['E'] : ""),
- (msg->cm_fields['T'] ? msg->cm_fields['T'] : "0"));
+ (msg->cm_fields[eExclusiveID] ? msg->cm_fields[eExclusiveID] : ""),
+ (msg->cm_fields[eTimestamp] ? msg->cm_fields[eTimestamp] : "0"));
CtdlFreeMessage(msg);
}
* so go ahead and fetch that. Failing that, just set a dummy
* body so other code doesn't barf.
*/
- if ( (ret->cm_fields['M'] == NULL) && (with_body) ) {
+ if ( (ret->cm_fields[eMesageText] == NULL) && (with_body) ) {
dmsgtext = cdb_fetch(CDB_BIGMSGS, &msgnum, sizeof(long));
if (dmsgtext != NULL) {
- ret->cm_fields['M'] = dmsgtext->ptr;
+ ret->cm_fields[eMesageText] = dmsgtext->ptr;
dmsgtext->ptr = NULL;
cdb_free(dmsgtext);
}
}
- if (ret->cm_fields['M'] == NULL) {
- ret->cm_fields['M'] = strdup("\r\n\r\n (no text)\r\n");
+ if (ret->cm_fields[eMesageText] == NULL) {
+ ret->cm_fields[eMesageText] = strdup("\r\n\r\n (no text)\r\n");
}
/* Perform "before read" hooks (aborting if any return nonzero) */
if (section) if (!IsEmptyStr(section)) if (strcmp(section, "0")) {
memset(&encap, 0, sizeof encap);
safestrncpy(encap.desired_section, section, sizeof encap.desired_section);
- mime_parser(TheMessage->cm_fields['M'],
+ mime_parser(TheMessage->cm_fields[eMesageText],
NULL,
*extract_encapsulated_message,
NULL, NULL, (void *)&encap, 0
if ((Author != NULL) && (*Author == NULL))
{
- *Author = TheMessage->cm_fields['A'];
- TheMessage->cm_fields['A'] = NULL;
+ *Author = TheMessage->cm_fields[eAuthor];
+ TheMessage->cm_fields[eAuthor] = NULL;
}
if ((Address != NULL) && (*Address == NULL))
{
- *Address = TheMessage->cm_fields['F'];
- TheMessage->cm_fields['F'] = NULL;
+ *Address = TheMessage->cm_fields[erFc822Addr];
+ TheMessage->cm_fields[erFc822Addr] = NULL;
}
CtdlFreeMessage(TheMessage);
TheMessage = NULL;
retcode = CtdlOutputPreLoadedMsg(TheMessage, mode, headers_only, do_proto, crlf, flags);
if ((Author != NULL) && (*Author == NULL))
{
- *Author = TheMessage->cm_fields['A'];
- TheMessage->cm_fields['A'] = NULL;
+ *Author = TheMessage->cm_fields[eAuthor];
+ TheMessage->cm_fields[eAuthor] = NULL;
}
if ((Address != NULL) && (*Address == NULL))
{
- *Address = TheMessage->cm_fields['F'];
- TheMessage->cm_fields['F'] = NULL;
+ *Address = TheMessage->cm_fields[erFc822Addr];
+ TheMessage->cm_fields[erFc822Addr] = NULL;
}
CtdlFreeMessage(TheMessage);
struct CtdlMessage *TheMessage,
int do_proto) /* do Citadel protocol responses? */
{
- char allkeys[30];
- int i, k, n;
+ int i;
int suppress_f = 0;
char buf[SIZ];
char display_name[256];
/* begin header processing loop for Citadel message format */
safestrncpy(display_name, "<unknown>", sizeof display_name);
- if (TheMessage->cm_fields['A']) {
- strcpy(buf, TheMessage->cm_fields['A']);
+ if (TheMessage->cm_fields[eAuthor]) {
+ strcpy(buf, TheMessage->cm_fields[eAuthor]);
if (TheMessage->cm_anon_type == MES_ANONONLY) {
safestrncpy(display_name, "****", sizeof display_name);
}
* local Citadel network.
*/
suppress_f = 0;
- if (TheMessage->cm_fields['N'] != NULL)
- if (!IsEmptyStr(TheMessage->cm_fields['N']))
- if (haschar(TheMessage->cm_fields['N'], '.') == 0) {
+ if (TheMessage->cm_fields[eNodeName] != NULL)
+ if (!IsEmptyStr(TheMessage->cm_fields[eNodeName]))
+ if (haschar(TheMessage->cm_fields[eNodeName], '.') == 0) {
suppress_f = 1;
}
/* Now spew the header fields in the order we like them. */
- n = safestrncpy(allkeys, FORDER, sizeof allkeys);
- for (i=0; i<n; ++i) {
- k = (int) allkeys[i];
- if (k != 'M') {
- if ( (TheMessage->cm_fields[k] != NULL)
- && (msgkeys[k] != NULL) ) {
- if ((k == 'V') || (k == 'R') || (k == 'Y')) {
- sanitize_truncated_recipient(TheMessage->cm_fields[k]);
+ for (i=0; i< NDiskFields; ++i) {
+ eMsgField Field;
+ Field = FieldOrder[i];
+ if (Field != eMesageText) {
+ if ( (TheMessage->cm_fields[Field] != NULL)
+ && (msgkeys[Field] != NULL) ) {
+ if ((Field == eenVelopeTo) ||
+ (Field == eRecipient) ||
+ (Field == eCarbonCopY)) {
+ sanitize_truncated_recipient(TheMessage->cm_fields[Field]);
}
- if (k == 'A') {
+ if (Field == eAuthor) {
if (do_proto) cprintf("%s=%s\n",
- msgkeys[k],
+ msgkeys[Field],
display_name);
}
- else if ((k == 'F') && (suppress_f)) {
+ else if ((Field == erFc822Addr) && (suppress_f)) {
/* do nothing */
}
/* Masquerade display name if needed */
else {
if (do_proto) cprintf("%s=%s\n",
- msgkeys[k],
- TheMessage->cm_fields[k]
+ msgkeys[Field],
+ TheMessage->cm_fields[Field]
);
}
}
if (TheMessage->cm_fields[i]) {
mptr = mpptr = TheMessage->cm_fields[i];
- if (i == 'A') {
+ if (i == eAuthor) {
safestrncpy(luser, mptr, sizeof_luser);
safestrncpy(suser, mptr, sizeof_suser);
}
else if (i == 'P') {
cprintf("Return-Path: %s%s", mptr, nl);
}
- else if (i == 'L') {
+ else if (i == eListID) {
cprintf("List-ID: %s%s", mptr, nl);
}
else if (i == 'V') {
}
else if (i == 'I')
safestrncpy(mid, mptr, sizeof_mid); /// TODO: detect @ here and copy @nodename in if not found.
- else if (i == 'F')
+ else if (i == erFc822Addr)
safestrncpy(fuser, mptr, sizeof_fuser);
/* else if (i == 'O')
cprintf("X-Citadel-Room: %s%s",
}
}
}
- else if (i == 'K') {
+ else if (i == eReplyTo) {
hptr = mptr;
while ((*hptr != '\0') && isspace(*hptr))
hptr ++;
int nllen = strlen(nl);
char *mptr;
- mptr = TheMessage->cm_fields['M'];
+ mptr = TheMessage->cm_fields[eMesageText];
prev_ch = '\0';
int nllen = strlen (nl);
char *mptr;
- mptr = TheMessage->cm_fields['M'];
+ mptr = TheMessage->cm_fields[eMesageText];
if (mode == MT_MIME) {
cprintf("Content-type: text/plain\n\n");
/* Suppress envelope recipients if required to avoid disclosing BCC addresses.
* Pad it with spaces in order to avoid changing the RFC822 length of the message.
*/
- if ( (flags & SUPPRESS_ENV_TO) && (TheMessage->cm_fields['V'] != NULL) ) {
- memset(TheMessage->cm_fields['V'], ' ', strlen(TheMessage->cm_fields['V']));
+ if ( (flags & SUPPRESS_ENV_TO) && (TheMessage->cm_fields[eenVelopeTo] != NULL) ) {
+ memset(TheMessage->cm_fields[eenVelopeTo], ' ', strlen(TheMessage->cm_fields[eenVelopeTo]));
}
/* Are we downloading a MIME component? */
ERROR + RESOURCE_BUSY);
} else {
/* Parse the message text component */
- mptr = TheMessage->cm_fields['M'];
+ mptr = TheMessage->cm_fields[eMesageText];
mime_parser(mptr, NULL, *mime_download, NULL, NULL, NULL, 0);
/* If there's no file open by this time, the requested
* section wasn't found, so print an error
/* Parse the message text component */
int found_it = 0;
- mptr = TheMessage->cm_fields['M'];
+ mptr = TheMessage->cm_fields[eMesageText];
mime_parser(mptr, NULL, *mime_spew_section, NULL, NULL, (void *)&found_it, 0);
/* If section wasn't found, print an error
*/
/* Tell the client about the MIME parts in this message */
if (TheMessage->cm_format_type == FMT_RFC822) {
if ( (mode == MT_CITADEL) || (mode == MT_MIME) ) {
- mptr = TheMessage->cm_fields['M'];
+ mptr = TheMessage->cm_fields[eMesageText];
memset(&ma, 0, sizeof(struct ma_info));
mime_parser(mptr, NULL,
(do_proto ? *list_this_part : NULL),
* message to the reader's screen width.
*/
if (TheMessage->cm_format_type == FMT_CITADEL) {
- mptr = TheMessage->cm_fields['M'];
+ mptr = TheMessage->cm_fields[eMesageText];
if (mode == MT_MIME) {
cprintf("Content-type: text/x-citadel-variformat\n\n");
ReplicationChecks(msg);
/* If the message has an Exclusive ID, index that... */
- if (msg->cm_fields['E'] != NULL) {
- index_message_by_euid(msg->cm_fields['E'], &CCC->room, msgid);
+ if (msg->cm_fields[eExclusiveID] != NULL) {
+ index_message_by_euid(msg->cm_fields[eExclusiveID], &CCC->room, msgid);
}
/* Free up the memory we may have allocated */
);
/* Generate an ID if we don't have one already */
- if (msg->cm_fields['I']==NULL) {
- msg->cm_fields['I'] = strdup(msgidbuf);
+ if (msg->cm_fields[emessageId]==NULL) {
+ msg->cm_fields[emessageId] = strdup(msgidbuf);
}
/* If the message is big, set its body aside for storage elsewhere */
- if (msg->cm_fields['M'] != NULL) {
- if (strlen(msg->cm_fields['M']) > BIGMSG) {
+ if (msg->cm_fields[eMesageText] != NULL) {
+ if (strlen(msg->cm_fields[eMesageText]) > BIGMSG) {
is_bigmsg = 1;
- holdM = msg->cm_fields['M'];
- msg->cm_fields['M'] = NULL;
+ holdM = msg->cm_fields[eMesageText];
+ msg->cm_fields[eMesageText] = NULL;
}
}
serialize_message(&smr, msg);
if (is_bigmsg) {
- msg->cm_fields['M'] = holdM;
+ msg->cm_fields[eMesageText] = holdM;
}
if (smr.len == 0) {
struct CitContext *CCC = CC;
size_t wlen, fieldlen;
int i;
- static char *forder = FORDER;
- int n = sizeof(FORDER) - 1;
- long lengths[sizeof(FORDER)];
+ long lengths[NDiskFields];
memset(lengths, 0, sizeof(lengths));
}
ret->len = 3;
- for (i=0; i<n; ++i)
- if (msg->cm_fields[(int)forder[i]] != NULL)
+ for (i=0; i < NDiskFields; ++i)
+ if (msg->cm_fields[FieldOrder[i]] != NULL)
{
- lengths[i] = strlen(msg->cm_fields[(int)forder[i]]);
+ lengths[i] = strlen(msg->cm_fields[FieldOrder[i]]);
ret->len += lengths[i] + 2;
}
ret->ser[2] = msg->cm_format_type;
wlen = 3;
- for (i=0; i<n; ++i)
- if (msg->cm_fields[(int)forder[i]] != NULL)
+ for (i=0; i < NDiskFields; ++i)
+ if (msg->cm_fields[FieldOrder[i]] != NULL)
{
fieldlen = lengths[i];
- ret->ser[wlen++] = (char)forder[i];
+ ret->ser[wlen++] = (char)FieldOrder[i];
memcpy(&ret->ser[wlen],
- msg->cm_fields[(int)forder[i]],
+ msg->cm_fields[FieldOrder[i]],
fieldlen+1);
wlen = wlen + fieldlen + 1;
/* No exclusive id? Don't do anything. */
if (msg == NULL) return;
- if (msg->cm_fields['E'] == NULL) return;
- if (IsEmptyStr(msg->cm_fields['E'])) return;
+ if (msg->cm_fields[eExclusiveID] == NULL) return;
+ if (IsEmptyStr(msg->cm_fields[eExclusiveID])) return;
/*MSG_syslog(LOG_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
- msg->cm_fields['E'], CCC->room.QRname);*/
+ msg->cm_fields[eExclusiveID], CCC->room.QRname);*/
- old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields['E'], &CCC->room);
+ old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields[eExclusiveID], &CCC->room);
if (old_msgnum > 0L) {
MSG_syslog(LOG_DEBUG, "ReplicationChecks() replacing message %ld\n", old_msgnum);
CtdlDeleteMessages(CCC->room.QRname, &old_msgnum, 1, "");
/* If this message has no timestamp, we take the liberty of
* giving it one, right now.
*/
- if (msg->cm_fields['T'] == NULL) {
+ if (msg->cm_fields[eTimestamp] == NULL) {
snprintf(generated_timestamp, sizeof generated_timestamp, "%ld", (long)time(NULL));
- msg->cm_fields['T'] = strdup(generated_timestamp);
+ msg->cm_fields[eTimestamp] = strdup(generated_timestamp);
}
/* If this message has no path, we generate one.
*/
- if (msg->cm_fields['P'] == NULL) {
- if (msg->cm_fields['A'] != NULL) {
- msg->cm_fields['P'] = strdup(msg->cm_fields['A']);
- for (a=0; !IsEmptyStr(&msg->cm_fields['P'][a]); ++a) {
- if (isspace(msg->cm_fields['P'][a])) {
- msg->cm_fields['P'][a] = ' ';
+ if (msg->cm_fields[eMessagePath] == NULL) {
+ if (msg->cm_fields[eAuthor] != NULL) {
+ msg->cm_fields[eMessagePath] = strdup(msg->cm_fields[eAuthor]);
+ for (a=0; !IsEmptyStr(&msg->cm_fields[eMessagePath][a]); ++a) {
+ if (isspace(msg->cm_fields[eMessagePath][a])) {
+ msg->cm_fields[eMessagePath][a] = ' ';
}
}
}
else {
- msg->cm_fields['P'] = strdup("unknown");
+ msg->cm_fields[eMessagePath] = strdup("unknown");
}
}
}
/* Learn about what's inside, because it's what's inside that counts */
- if (msg->cm_fields['M'] == NULL) {
+ if (msg->cm_fields[eMesageText] == NULL) {
MSGM_syslog(LOG_ERR, "ERROR: attempt to save message with NULL body\n");
return(-2);
}
break;
case 4:
strcpy(content_type, "text/plain");
- mptr = bmstrcasestr(msg->cm_fields['M'], "Content-type:");
+ mptr = bmstrcasestr(msg->cm_fields[eMesageText], "Content-type:");
if (mptr != NULL) {
char *aptr;
safestrncpy(content_type, &mptr[13], sizeof content_type);
/*
* If this message has no O (room) field, generate one.
*/
- if (msg->cm_fields['O'] == NULL) {
- msg->cm_fields['O'] = strdup(CCC->room.QRname);
+ if (msg->cm_fields[eOriginalRoom] == NULL) {
+ msg->cm_fields[eOriginalRoom] = strdup(CCC->room.QRname);
}
/* Perform "before save" hooks (aborting if any return nonzero) */
snprintf(bounce_to, sizeof bounce_to, "%s@%s", CCC->user.fullname, config.c_nodename);
}
else {
- snprintf(bounce_to, sizeof bounce_to, "%s@%s", msg->cm_fields['A'], msg->cm_fields['N']);
+ snprintf(bounce_to, sizeof bounce_to, "%s@%s", msg->cm_fields[eAuthor], msg->cm_fields[eNodeName]);
}
/* If this is private, local mail, make a copy in the
imsg->cm_magic = CTDLMESSAGE_MAGIC;
imsg->cm_anon_type = MES_NORMAL;
imsg->cm_format_type = FMT_RFC822;
- imsg->cm_fields['U'] = strdup("QMSG");
- imsg->cm_fields['A'] = strdup("Citadel");
- imsg->cm_fields['J'] = strdup("do not journal");
- imsg->cm_fields['M'] = instr; /* imsg owns this memory now */
- imsg->cm_fields['2'] = strdup(recipient);
+ imsg->cm_fields[eMsgSubject] = strdup("QMSG");
+ imsg->cm_fields[eAuthor] = strdup("Citadel");
+ imsg->cm_fields[eJournal] = strdup("do not journal");
+ imsg->cm_fields[eMesageText] = instr; /* imsg owns this memory now */
+ imsg->cm_fields[eExtnotify] = strdup(recipient);
CtdlSubmitMsg(imsg, NULL, FNBL_QUEUE_ROOM, 0);
CtdlFreeMessage(imsg);
}
/* Perform "after save" hooks */
MSGM_syslog(LOG_DEBUG, "Performing after-save hooks\n");
- if (msg->cm_fields['3'] != NULL) free(msg->cm_fields['3']);
- msg->cm_fields['3'] = malloc(20);
- snprintf(msg->cm_fields['3'], 20, "%ld", newmsgid);
+ if (msg->cm_fields[eVltMsgNum] != NULL) free(msg->cm_fields[eVltMsgNum]);
+ msg->cm_fields[eVltMsgNum] = malloc(20);
+ snprintf(msg->cm_fields[eVltMsgNum], 20, "%ld", newmsgid);
PerformMessageHooks(msg, EVT_AFTERSAVE);
- free(msg->cm_fields['3']);
- msg->cm_fields['3'] = NULL;
+ free(msg->cm_fields[eVltMsgNum]);
+ msg->cm_fields[eVltMsgNum] = NULL;
/* For IGnet mail, we have to save a new copy into the spooler for
* each recipient, with the R and D fields set to the recipient and
extract_token(recipient, recps->recp_ignet, i,
'|', sizeof recipient);
- hold_R = msg->cm_fields['R'];
- hold_D = msg->cm_fields['D'];
- msg->cm_fields['R'] = malloc(SIZ);
- msg->cm_fields['D'] = malloc(128);
- extract_token(msg->cm_fields['R'], recipient, 0, '@', SIZ);
- extract_token(msg->cm_fields['D'], recipient, 1, '@', 128);
+ hold_R = msg->cm_fields[eRecipient];
+ hold_D = msg->cm_fields[eDestination];
+ msg->cm_fields[eRecipient] = malloc(SIZ);
+ msg->cm_fields[eDestination] = malloc(128);
+ extract_token(msg->cm_fields[eRecipient], recipient, 0, '@', SIZ);
+ extract_token(msg->cm_fields[eDestination], recipient, 1, '@', 128);
serialize_message(&smr, msg);
if (smr.len > 0) {
free(smr.ser);
}
- free(msg->cm_fields['R']);
- free(msg->cm_fields['D']);
- msg->cm_fields['R'] = hold_R;
- msg->cm_fields['D'] = hold_D;
+ free(msg->cm_fields[eRecipient]);
+ free(msg->cm_fields[eDestination]);
+ msg->cm_fields[eRecipient] = hold_R;
+ msg->cm_fields[eDestination] = hold_D;
}
/* Go back to the room we started from */
imsg->cm_magic = CTDLMESSAGE_MAGIC;
imsg->cm_anon_type = MES_NORMAL;
imsg->cm_format_type = FMT_RFC822;
- imsg->cm_fields['U'] = strdup("QMSG");
- imsg->cm_fields['A'] = strdup("Citadel");
- imsg->cm_fields['J'] = strdup("do not journal");
- imsg->cm_fields['M'] = SmashStrBuf(&SpoolMsg); /* imsg owns this memory now */
+ imsg->cm_fields[eMsgSubject] = strdup("QMSG");
+ imsg->cm_fields[eAuthor] = strdup("Citadel");
+ imsg->cm_fields[eJournal] = strdup("do not journal");
+ imsg->cm_fields[eMesageText] = SmashStrBuf(&SpoolMsg); /* imsg owns this memory now */
CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
CtdlFreeMessage(imsg);
}
/*
* Determine whether this message qualifies for journaling.
*/
- if (msg->cm_fields['J'] != NULL) {
+ if (msg->cm_fields[eJournal] != NULL) {
qualified_for_journaling = 0;
}
else {
msg->cm_format_type = format_type;
if (from != NULL) {
- msg->cm_fields['A'] = strdup(from);
+ msg->cm_fields[eAuthor] = strdup(from);
}
else if (fromaddr != NULL) {
- msg->cm_fields['A'] = strdup(fromaddr);
- if (strchr(msg->cm_fields['A'], '@')) {
- *strchr(msg->cm_fields['A'], '@') = 0;
+ msg->cm_fields[eAuthor] = strdup(fromaddr);
+ if (strchr(msg->cm_fields[eAuthor], '@')) {
+ *strchr(msg->cm_fields[eAuthor], '@') = 0;
}
}
else {
- msg->cm_fields['A'] = strdup("Citadel");
+ msg->cm_fields[eAuthor] = strdup("Citadel");
}
- if (fromaddr != NULL) msg->cm_fields['F'] = strdup(fromaddr);
- if (room != NULL) msg->cm_fields['O'] = strdup(room);
- msg->cm_fields['N'] = strdup(NODENAME);
+ if (fromaddr != NULL) msg->cm_fields[erFc822Addr] = strdup(fromaddr);
+ if (room != NULL) msg->cm_fields[eOriginalRoom] = strdup(room);
+ msg->cm_fields[eNodeName] = strdup(NODENAME);
if (to != NULL) {
- msg->cm_fields['R'] = strdup(to);
+ msg->cm_fields[eRecipient] = strdup(to);
recp = validate_recipients(to, NULL, 0);
}
if (subject != NULL) {
- msg->cm_fields['U'] = strdup(subject);
+ msg->cm_fields[eMsgSubject] = strdup(subject);
}
- msg->cm_fields['M'] = strdup(text);
+ msg->cm_fields[eMesageText] = strdup(text);
CtdlSubmitMsg(msg, recp, room, 0);
CtdlFreeMessage(msg);
if (my_email == NULL) my_email = "";
if (!IsEmptyStr(my_email)) {
- msg->cm_fields['P'] = strdup(my_email);
+ msg->cm_fields[eMessagePath] = strdup(my_email);
}
else {
snprintf(buf, sizeof buf, "%s", author->fullname);
- msg->cm_fields['P'] = strdup(buf);
+ msg->cm_fields[eMessagePath] = strdup(buf);
}
- convert_spaces_to_underscores(msg->cm_fields['P']);
+ convert_spaces_to_underscores(msg->cm_fields[eMessagePath]);
snprintf(buf, sizeof buf, "%ld", (long)time(NULL)); /* timestamp */
- msg->cm_fields['T'] = strdup(buf);
+ msg->cm_fields[eTimestamp] = strdup(buf);
if ((fake_name != NULL) && (fake_name[0])) { /* author */
FakeAuthor = NewStrBufPlain (fake_name, -1);
FakeAuthor = NewStrBufPlain (author->fullname, -1);
}
StrBufRFC2047encode(&FakeEncAuthor, FakeAuthor);
- msg->cm_fields['A'] = SmashStrBuf(&FakeEncAuthor);
+ msg->cm_fields[eAuthor] = SmashStrBuf(&FakeEncAuthor);
FreeStrBuf(&FakeAuthor);
if (CC->room.QRflags & QR_MAILBOX) { /* room */
- msg->cm_fields['O'] = strdup(&CC->room.QRname[11]);
+ msg->cm_fields[eOriginalRoom] = strdup(&CC->room.QRname[11]);
}
else {
- msg->cm_fields['O'] = strdup(CC->room.QRname);
+ msg->cm_fields[eOriginalRoom] = strdup(CC->room.QRname);
}
- msg->cm_fields['N'] = strdup(NODENAME); /* nodename */
- msg->cm_fields['H'] = strdup(HUMANNODE); /* hnodename */
+ msg->cm_fields[eNodeName] = strdup(NODENAME); /* nodename */
+ msg->cm_fields[eHumanNode] = strdup(HUMANNODE); /* hnodename */
if ((recipient != NULL) && (recipient[0] != 0)) {
- msg->cm_fields['R'] = strdup(recipient);
+ msg->cm_fields[eRecipient] = strdup(recipient);
}
if ((recp_cc != NULL) && (recp_cc[0] != 0)) {
- msg->cm_fields['Y'] = strdup(recp_cc);
+ msg->cm_fields[eCarbonCopY] = strdup(recp_cc);
}
if (dest_node[0] != 0) {
- msg->cm_fields['D'] = strdup(dest_node);
+ msg->cm_fields[eDestination] = strdup(dest_node);
}
if (!IsEmptyStr(my_email)) {
- msg->cm_fields['F'] = strdup(my_email);
+ msg->cm_fields[erFc822Addr] = strdup(my_email);
}
else if ( (author == &CC->user) && (!IsEmptyStr(CC->cs_inet_email)) ) {
- msg->cm_fields['F'] = strdup(CC->cs_inet_email);
+ msg->cm_fields[erFc822Addr] = strdup(CC->cs_inet_email);
}
if (subject != NULL) {
(IsAscii = isascii(subject[i]) != 0 ))
i++;
if (IsAscii != 0)
- msg->cm_fields['U'] = strdup(subject);
+ msg->cm_fields[eMsgSubject] = strdup(subject);
else /* ok, we've got utf8 in the string. */
{
- msg->cm_fields['U'] = rfc2047encode(subject, length);
+ msg->cm_fields[eMsgSubject] = rfc2047encode(subject, length);
}
}
}
if (supplied_euid != NULL) {
- msg->cm_fields['E'] = strdup(supplied_euid);
+ msg->cm_fields[eExclusiveID] = strdup(supplied_euid);
}
if ((references != NULL) && (!IsEmptyStr(references))) {
- if (msg->cm_fields['W'] != NULL)
- free(msg->cm_fields['W']);
- msg->cm_fields['W'] = strdup(references);
+ if (msg->cm_fields[eWeferences] != NULL)
+ free(msg->cm_fields[eWeferences]);
+ msg->cm_fields[eWeferences] = strdup(references);
}
if (preformatted_text != NULL) {
- msg->cm_fields['M'] = preformatted_text;
+ msg->cm_fields[eMesageText] = preformatted_text;
}
else {
- msg->cm_fields['M'] = CtdlReadMessageBody(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
+ msg->cm_fields[eMesageText] = CtdlReadMessageBody(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
}
return(msg);
* to the actual mail address so others get a valid
* reply-to-header.
*/
- msg->cm_fields['V'] = strdup(valid->recp_orgroom);
+ msg->cm_fields[eenVelopeTo] = strdup(valid->recp_orgroom);
}
if (msg != NULL) {
client_write(HKEY("Internal error.\n"));
}
- if (msg->cm_fields['E'] != NULL) {
- cprintf("%s\n", msg->cm_fields['E']);
+ if (msg->cm_fields[eExclusiveID] != NULL) {
+ cprintf("%s\n", msg->cm_fields[eExclusiveID]);
} else {
cprintf("\n");
}
msg->cm_magic = CTDLMESSAGE_MAGIC;
msg->cm_anon_type = MES_NORMAL;
msg->cm_format_type = 4;
- msg->cm_fields['A'] = strdup(CCC->user.fullname);
- msg->cm_fields['O'] = strdup(req_room);
- msg->cm_fields['N'] = strdup(config.c_nodename);
- msg->cm_fields['H'] = strdup(config.c_humannode);
+ msg->cm_fields[eAuthor] = strdup(CCC->user.fullname);
+ msg->cm_fields[eOriginalRoom] = strdup(req_room);
+ msg->cm_fields[eNodeName] = strdup(config.c_nodename);
+ msg->cm_fields[eHumanNode] = strdup(config.c_humannode);
msg->cm_flags = flags;
- msg->cm_fields['M'] = encoded_message;
+ msg->cm_fields[eMesageText] = encoded_message;
/* Create the requested room if we have to. */
if (CtdlGetRoom(&qrbuf, roomname) != 0) {
else {
msg = CtdlFetchMessage(msgnum, 1);
if (msg != NULL) {
- conf = strdup(msg->cm_fields['M']);
+ conf = strdup(msg->cm_fields[eMesageText]);
CtdlFreeMessage(msg);
}
else {
);
struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
struct CtdlMessage * CtdlDuplicateMessage(struct CtdlMessage *OrgMsg);
-void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, const char which, const char *buf, long length);
+void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
void CtdlFreeMessage(struct CtdlMessage *msg);
void CtdlFreeMessageContents(struct CtdlMessage *msg);
void serialize_message(struct ser_ret *, struct CtdlMessage *);
-
-
#ifndef SERVER_H
#define SERVER_H
S_NETSPOOL,
S_XMPP_QUEUE,
S_SCHEDULE_LIST,
- S_SINGLE_USER,
- S_LDAP,
+ S_SINGLE_USER,
+ S_LDAP,
S_IM_LOGS,
MAX_SEMAPHORES
};
/*
* Message format types in the database
*/
-#define FMT_CITADEL 0 /* Citadel vari-format (proprietary) */
+#define FMT_CITADEL 0 /* Citadel vari-format (proprietary) */
#define FMT_FIXED 1 /* Fixed format (proprietary) */
#define FMT_RFC822 4 /* Standard (headers are in M field) */
};
-/*
+/*
* Event types can't be enum'ed, because they must remain consistent between
* builds (to allow for binary modules built somewhere else)
*/
};
-/*
+/*
* Serialization routines use this struct to return a pointer and a length
*/
struct ser_ret {
- size_t len;
- unsigned char *ser;
+ size_t len;
+ unsigned char *ser;
};
-/* Preferred field order */
+/* Preferred field order */
/* ********** Important fields */
/* *************** Semi-important fields */
-/* ** internal only */
-/* * Message text (MUST be last) */
-#define FORDER "IPTAFONHRDBCEWJGKLQSVXZYU12M"
+/* ** internal only */
+/* * Message text (MUST be last) */
+///#define FORDER "IPTAFONHRDBCEWJGKLQSVXZYU12M"
+
+typedef enum _MsgField {
+ eAuthor = 'A',
+ eBig_message = 'B',
+ eRemoteRoom = 'C',
+ eDestination = 'D',
+ eExclusiveID = 'E',
+ erFc822Addr = 'F',
+ eHumanNode = 'H',
+ emessageId = 'I',
+ eJournal = 'J',
+ eReplyTo = 'K',
+ eListID = 'L',
+ eMesageText = 'M',
+ eNodeName = 'N',
+ eOriginalRoom = 'O',
+ eMessagePath = 'P',
+ eRecipient = 'R',
+ eSpecialField = 'S',
+ eTimestamp = 'T',
+ eMsgSubject = 'U',
+ eenVelopeTo = 'V',
+ eWeferences = 'W',
+ eCarbonCopY = 'Y',
+ eErrorMsg = '0',
+ eSuppressIdx = '1',
+ eExtnotify = '2',
+ eVltMsgNum = '3'
+}eMsgField;
#endif /* SERVER_H */
usernum -- these are assigned sequentially, and NEVER REUSED. This is
important because it allows us to use this number in other data structures
-without having to worry about users being added/removed later on, as you'll
+ without having to worry about users being added/removed later on, as you'll
see later in this document.
as message ID's first. To provide later downward compatability
all software should be written to IGNORE fields not currently defined.
- The type bytes currently defined are:
-
-BYTE Mnemonic Comments
-
-A Author Name of originator of message.
-B Big message This is a flag which indicates that the message is
- big, and Citadel is storing the body in a separate
- record. You will never see this field because the
- internal API handles it.
-D Destination Contains name of the system this message should
+ The type bytes currently defined are:
+
+BYTE Mnemonic Enum / Comments
+
+A Author eAuthor
+ Name of originator of message.
+B Big message eBig_message
+ This is a flag which indicates that the message is
+ big, and Citadel is storing the body in a separate
+ record. You will never see this field because the
+ internal API handles it.
+C RemoteRoom eRemoteRoom
+ when sent via Citadel Networking, this is the room
+ its going to be put on the remote site.
+D Destination eDestination
+ Contains name of the system this message should
be sent to, for mail routing (private mail only).
-E Exclusive ID A persistent alphanumeric Message ID used for
+E Exclusive ID eExclusiveID
+ A persistent alphanumeric Message ID used for
network replication. When a message arrives that
contains an Exclusive ID, any existing messages which
contain the same Exclusive ID and are *older* than this
message should be deleted. If there exist any messages
with the same Exclusive ID that are *newer*, then this
message should be dropped.
-F rFc822 address For Internet mail, this is the delivery address of the
+F rFc822 address erFc822Addr
+ For Internet mail, this is the delivery address of the
message author.
-H Human node name Human-readable name of system message originated on.
-I Message ID An RFC822-compatible message ID for this message.
-J Journal The presence of this field indicates that the message
+H Human node name eHumanNode
+ Human-readable name of system message originated on.
+I Message ID emessageId
+ An RFC822-compatible message ID for this message.
+J Journal eJournal
+ The presence of this field indicates that the message
is disqualified from being journaled, perhaps because
it is itself a journalized message and we wish to
avoid double journaling.
-K Reply-To the Reply-To header for mailinglist outbound messages
-L List-ID Mailing list identification, as per RFC 2919
-M Message Text Normal ASCII, newlines seperated by CR's or LF's,
- null terminated as always.
-N Nodename Contains node name of system message originated on.
-O Room Room of origin.
-P Path Complete path of message, as in the UseNet news
+K Reply-To eReplyTo
+ the Reply-To header for mailinglist outbound messages
+L List-ID eListID
+ Mailing list identification, as per RFC 2919
+M Message Text eMesageText
+ Normal ASCII, newlines seperated by CR's or LF's,
+ null terminated as always.
+N Nodename eNodeName
+ Contains node name of system message originated on.
+O Room eOriginalRoom - Room of origin.
+P Path eMessagePath
+ Complete path of message, as in the UseNet news
standard. A user should be able to send Internet mail
to this path. (Note that your system name will not be
tacked onto this until you're sending the message to
someone else)
-R Recipient Only present in Mail messages.
-S Special field Only meaningful for messages being spooled over a
- network. Usually means that the message isn't really
- a message, but rather some other network function:
- -> "S" followed by "FILE" (followed by a null, of
- course) means that the message text is actually an
- IGnet/Open file transfer. (OBSOLETE)
+R Recipient eRecipient - Only present in Mail messages.
+S Special field eSpecialField
+ Only meaningful for messages being spooled over a
+ network. Usually means that the message isn't really
+ a message, but rather some other network function:
+ -> "S" followed by "FILE" (followed by a null, of
+ course) means that the message text is actually an
+ IGnet/Open file transfer. (OBSOLETE)
-> "S" followed by "CANCEL" means that this message
should be deleted from the local message base once
it has been replicated to all network systems.
-T date/Time Unix timestamp containing the creation date/time of
+T date/Time eTimestamp
+ Unix timestamp containing the creation date/time of
the message.
-U sUbject Optional. Developers may choose whether they wish to
- generate or display subject fields.
-V enVelope-to The recipient specified in incoming SMTP messages.
-W Wefewences Previous message ID's for conversation threading. When
+U sUbject eMsgSubject - Optional.
+ Developers may choose whether they wish to
+ generate or display subject fields.
+V enVelope-to eenVelopeTo
+ The recipient specified in incoming SMTP messages.
+W Wefewences eWeferences
+ Previous message ID's for conversation threading. When
converting from RFC822 we use References: if present, or
In-Reply-To: otherwise.
(Who in extnotify spool messages which don't need to know
other message ids)
-Y carbon copY Optional, and only in Mail messages.
-0 Error This field is typically never found in a message on
+Y carbon copY eCarbonCopY
+ Optional, and only in Mail messages.
+0 Error eErrorMsg
+ This field is typically never found in a message on
disk or in transit. Message scanning modules are
expected to fill in this field when rejecting a message
with an explanation as to what happened (virus found,
message looks like spam, etc.)
-1 suppress index The presence of this field indicates that the message is
+1 suppress index eSuppressIdx
+ The presence of this field indicates that the message is
disqualified from being added to the full text index.
-2 extnotify Used internally by the serv_extnotify module.
-3 msgnum Used internally to pass the local message number in the
+2 extnotify eExtnotify - Used internally by the serv_extnotify module.
+3 msgnum eVltMsgNum
+ Used internally to pass the local message number in the
database to after-save hooks. Discarded afterwards.
EXAMPLE