From 951fbe7c1ee0b3554af22d6ae0d1d51c1642ae0f Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 18 Aug 2013 10:29:11 +0200 Subject: [PATCH] use an Enum for the cm_fields vector instead of nameless chars --- citadel/database.c | 2 + citadel/euidindex.c | 4 +- citadel/internet_addressing.c | 96 ++--- citadel/journaling.c | 34 +- .../autocompletion/serv_autocompletion.c | 2 +- citadel/modules/blog/serv_blog.c | 8 +- citadel/modules/calendar/serv_calendar.c | 56 +-- citadel/modules/clamav/serv_virus.c | 6 +- citadel/modules/dspam/serv_dspam.c | 4 +- citadel/modules/expire/serv_expire.c | 2 +- citadel/modules/extnotify/extnotify_main.c | 26 +- citadel/modules/fulltext/serv_fulltext.c | 2 +- citadel/modules/imap/imap_fetch.c | 52 +-- citadel/modules/imap/imap_misc.c | 12 +- citadel/modules/imap/imap_search.c | 44 +-- citadel/modules/inetcfg/serv_inetcfg.c | 8 +- citadel/modules/instmsg/serv_instmsg.c | 12 +- citadel/modules/network/serv_netfilter.c | 16 +- citadel/modules/network/serv_netmail.c | 94 ++--- citadel/modules/network/serv_netspool.c | 48 +-- citadel/modules/network/serv_network.c | 58 +-- citadel/modules/notes/serv_notes.c | 32 +- citadel/modules/rssclient/rss_atom_parser.c | 8 +- citadel/modules/rssclient/serv_rssclient.c | 22 +- citadel/modules/sieve/serv_sieve.c | 42 +-- citadel/modules/smtp/serv_smtp.c | 54 +-- citadel/modules/smtp/serv_smtpeventclient.c | 4 +- citadel/modules/smtp/serv_smtpqueue.c | 12 +- citadel/modules/smtp/smtp_util.c | 14 +- citadel/modules/spam/serv_spam.c | 14 +- citadel/modules/vcard/serv_vcard.c | 80 ++-- citadel/modules/wiki/serv_wiki.c | 92 ++--- citadel/modules/xmpp/xmpp_presence.c | 4 +- citadel/msgbase.c | 353 ++++++++++-------- citadel/msgbase.h | 2 +- citadel/server.h | 53 ++- citadel/techdoc/hack.txt | 105 ++++-- 37 files changed, 785 insertions(+), 692 deletions(-) diff --git a/citadel/database.c b/citadel/database.c index 398f1eb0f..724ee0f94 100644 --- a/citadel/database.c +++ b/citadel/database.c @@ -97,8 +97,10 @@ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg) /* 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; } diff --git a/citadel/euidindex.c b/citadel/euidindex.c index dbc89adaa..bcf0606ed 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -162,8 +162,8 @@ void rebuild_euid_index_for_msg(long msgnum, void *userdata) { 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); } diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 3237007d6..b4663fc36 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -590,8 +590,8 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) { 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; } @@ -599,89 +599,89 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) { 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; icm_fields['I']); ++i) - if (msg->cm_fields['I'][i] == '>') - msg->cm_fields['I'][i] = 0; + for (i = 0; icm_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; } @@ -818,21 +818,21 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822) 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; @@ -1018,20 +1018,20 @@ char *harvest_collected_addresses(struct CtdlMessage *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; } } @@ -1047,8 +1047,8 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) { /* 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; jcm_fields[field], ','); ++j) { diff --git a/citadel/journaling.c b/citadel/journaling.c index 6d68d0874..26c273694 100644 --- a/citadel/journaling.c +++ b/citadel/journaling.c @@ -59,7 +59,7 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg, struct jnlq *jptr = NULL; /* Avoid double journaling! */ - if (msg->cm_fields['J'] != NULL) { + if (msg->cm_fields[eJournal] != NULL) { FreeStrBuf(&saved_rfc822_version); return; } @@ -71,11 +71,11 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg, } 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 */ @@ -150,11 +150,11 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { 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); @@ -177,16 +177,16 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { , 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)], @@ -238,7 +238,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) { mime_boundary ); - journal_msg->cm_fields['M'] = message_text; + journal_msg->cm_fields[eMesageText] = message_text; free(jmsg->rfc822); free(jmsg->msgn); diff --git a/citadel/modules/autocompletion/serv_autocompletion.c b/citadel/modules/autocompletion/serv_autocompletion.c index f84020e7a..8bb5da021 100644 --- a/citadel/modules/autocompletion/serv_autocompletion.c +++ b/citadel/modules/autocompletion/serv_autocompletion.c @@ -62,7 +62,7 @@ void hunt_for_autocomplete(long msgnum, char *search_string) { msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) return; - v = vcard_load(msg->cm_fields['M']); + v = vcard_load(msg->cm_fields[eMesageText]); CtdlFreeMessage(msg); /* diff --git a/citadel/modules/blog/serv_blog.c b/citadel/modules/blog/serv_blog.c index fb95d613b..4424d46b8 100644 --- a/citadel/modules/blog/serv_blog.c +++ b/citadel/modules/blog/serv_blog.c @@ -72,18 +72,18 @@ int blog_upload_beforesave(struct CtdlMessage *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. */ diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index d9236bd33..0d971d9d9 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -140,13 +140,13 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) { 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); @@ -376,7 +376,7 @@ void ical_respond(long msgnum, char *partnum, char *action) { 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, @@ -632,7 +632,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { 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, @@ -719,7 +719,7 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) { 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, @@ -1151,7 +1151,7 @@ void ical_hunt_for_conflicts_backend(long msgnum, void *data) { 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, @@ -1220,7 +1220,7 @@ void ical_conflicts(long msgnum, char *partnum) { 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, @@ -1401,7 +1401,7 @@ void ical_freebusy_backend(long msgnum, void *data) { 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, @@ -1602,7 +1602,7 @@ void ical_getics_backend(long msgnum, void *data) { 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, @@ -2336,10 +2336,10 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum, 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); } } @@ -2350,10 +2350,10 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum, 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)); } } @@ -2364,11 +2364,11 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum, 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); } } @@ -2405,12 +2405,12 @@ int ical_obj_beforesave(struct CtdlMessage *msg) 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, @@ -2476,10 +2476,10 @@ int ical_obj_aftersave(struct CtdlMessage *msg) 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, diff --git a/citadel/modules/clamav/serv_virus.c b/citadel/modules/clamav/serv_virus.c index c4b8a5d4f..6f2dd0418 100644 --- a/citadel/modules/clamav/serv_virus.c +++ b/citadel/modules/clamav/serv_virus.c @@ -180,10 +180,10 @@ int clamd(struct CtdlMessage *msg) { } 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); diff --git a/citadel/modules/dspam/serv_dspam.c b/citadel/modules/dspam/serv_dspam.c index 86e8b30b0..28a9a8d74 100644 --- a/citadel/modules/dspam/serv_dspam.c +++ b/citadel/modules/dspam/serv_dspam.c @@ -168,8 +168,8 @@ void dspam_do_msg(long msgnum, void *userdata) { /* 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); diff --git a/citadel/modules/expire/serv_expire.c b/citadel/modules/expire/serv_expire.c index 7da3ef84e..93ad7e313 100644 --- a/citadel/modules/expire/serv_expire.c +++ b/citadel/modules/expire/serv_expire.c @@ -199,7 +199,7 @@ void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) { 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; diff --git a/citadel/modules/extnotify/extnotify_main.c b/citadel/modules/extnotify/extnotify_main.c index a519548fa..826704cf4 100644 --- a/citadel/modules/extnotify/extnotify_main.c +++ b/citadel/modules/extnotify/extnotify_main.c @@ -185,8 +185,8 @@ eNotifyType extNotify_getConfigMessage(char *username, 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)) { @@ -204,8 +204,8 @@ eNotifyType extNotify_getConfigMessage(char *username, // 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... */ @@ -280,14 +280,14 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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")); @@ -303,8 +303,8 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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; @@ -336,8 +336,8 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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); } @@ -351,7 +351,7 @@ void process_notify(long NotifyMsgnum, void *usrdata) commandSiz = sizeof(config.c_pager_program) + strlen(PagerNo) + - strlen(msg->cm_fields['2']) + 5; + strlen(msg->cm_fields[eExtnotify]) + 5; command = malloc(commandSiz); @@ -360,7 +360,7 @@ void process_notify(long NotifyMsgnum, void *usrdata) "%s %s -u %s", config.c_pager_program, PagerNo, - msg->cm_fields['2']); + msg->cm_fields[eExtnotify]); system(command); free(command); diff --git a/citadel/modules/fulltext/serv_fulltext.c b/citadel/modules/fulltext/serv_fulltext.c index 8e6687788..547caaefd 100644 --- a/citadel/modules/fulltext/serv_fulltext.c +++ b/citadel/modules/fulltext/serv_fulltext.c @@ -126,7 +126,7 @@ void ft_index_message(long msgnum, int op) { 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; diff --git a/citadel/modules/imap/imap_fetch.c b/citadel/modules/imap/imap_fetch.c index 396e6070c..b9319610c 100644 --- a/citadel/modules/imap/imap_fetch.c +++ b/citadel/modules/imap/imap_fetch.c @@ -110,8 +110,8 @@ void imap_fetch_internaldate(struct CtdlMessage *msg) { 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); @@ -355,12 +355,12 @@ void imap_output_envelope_from(struct CtdlMessage *msg) { /* 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)) { @@ -371,9 +371,9 @@ void imap_output_envelope_from(struct CtdlMessage *msg) { } } 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 */ @@ -445,8 +445,8 @@ void imap_fetch_envelope(struct CtdlMessage *msg) { 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); @@ -466,14 +466,14 @@ void imap_fetch_envelope(struct CtdlMessage *msg) { 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); @@ -483,7 +483,7 @@ void imap_fetch_envelope(struct CtdlMessage *msg) { } /* 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); @@ -493,53 +493,53 @@ void imap_fetch_envelope(struct CtdlMessage *msg) { } /* 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++; @@ -752,7 +752,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) { * (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 @@ -1019,7 +1019,7 @@ void imap_fetch_bodystructure (long msgnum, const char *item, /* 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 */ diff --git a/citadel/modules/imap/imap_misc.c b/citadel/modules/imap/imap_misc.c index e7b3d69fe..ede4b2fd7 100644 --- a/citadel/modules/imap/imap_misc.c +++ b/citadel/modules/imap/imap_misc.c @@ -384,12 +384,12 @@ void imap_append(int num_parms, ConstStr *Params) { */ 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); } } diff --git a/citadel/modules/imap/imap_search.c b/citadel/modules/imap/imap_search.c index 8cc3fd3d6..387e747c9 100644 --- a/citadel/modules/imap/imap_search.c +++ b/citadel/modules/imap/imap_search.c @@ -125,7 +125,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; @@ -142,9 +142,9 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -168,7 +168,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -183,14 +183,14 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; @@ -229,10 +229,10 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -281,7 +281,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -308,9 +308,9 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -338,9 +338,9 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -354,9 +354,9 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -370,9 +370,9 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -386,9 +386,9 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -402,7 +402,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -415,7 +415,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } @@ -443,7 +443,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *supplied_msg, 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; } } diff --git a/citadel/modules/inetcfg/serv_inetcfg.c b/citadel/modules/inetcfg/serv_inetcfg.c index e3be75c80..8aa98b2d1 100644 --- a/citadel/modules/inetcfg/serv_inetcfg.c +++ b/citadel/modules/inetcfg/serv_inetcfg.c @@ -66,8 +66,8 @@ void inetcfg_setTo(struct CtdlMessage *msg) { 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 { @@ -92,10 +92,10 @@ int inetcfg_aftersave(struct CtdlMessage *msg) { /* 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"); diff --git a/citadel/modules/instmsg/serv_instmsg.c b/citadel/modules/instmsg/serv_instmsg.c index d84ce6244..cb4101a97 100644 --- a/citadel/modules/instmsg/serv_instmsg.c +++ b/citadel/modules/instmsg/serv_instmsg.c @@ -459,16 +459,16 @@ void flush_individual_conversation(struct imlog *im) { 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. diff --git a/citadel/modules/network/serv_netfilter.c b/citadel/modules/network/serv_netfilter.c index 1473385ae..0c2ca0e58 100644 --- a/citadel/modules/network/serv_netfilter.c +++ b/citadel/modules/network/serv_netfilter.c @@ -149,29 +149,29 @@ int filter_the_idiots(struct CtdlMessage *msg, char *target_room) { 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; } diff --git a/citadel/modules/network/serv_netmail.c b/citadel/modules/network/serv_netmail.c index b84c5dea2..a8086b83b 100644 --- a/citadel/modules/network/serv_netmail.c +++ b/citadel/modules/network/serv_netmail.c @@ -133,12 +133,12 @@ static void ListCalculateSubject(struct CtdlMessage *msg) 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); @@ -165,9 +165,9 @@ static void ListCalculateSubject(struct CtdlMessage *msg) 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); } @@ -199,16 +199,16 @@ void network_deliver_digest(SpoolControl *sc) 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 @@ -216,10 +216,10 @@ void network_deliver_digest(SpoolControl *sc) 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; @@ -263,26 +263,26 @@ void network_process_digest(SpoolControl *sc, struct CtdlMessage *omsg, long *de "------------------------------------" "-------\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); @@ -327,20 +327,20 @@ void network_process_list(SpoolControl *sc, struct CtdlMessage *omsg, long *dele 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 */ @@ -403,13 +403,13 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon * 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, @@ -426,11 +426,11 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon * 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); } @@ -467,24 +467,24 @@ void network_process_ignetpush(SpoolControl *sc, struct CtdlMessage *omsg, long /* 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; } } @@ -514,12 +514,12 @@ void network_process_ignetpush(SpoolControl *sc, struct CtdlMessage *omsg, long } /* 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); @@ -545,15 +545,15 @@ void network_process_ignetpush(SpoolControl *sc, struct CtdlMessage *omsg, long * 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); } diff --git a/citadel/modules/network/serv_netspool.c b/citadel/modules/network/serv_netspool.c index 900292e95..3700ee42b 100644 --- a/citadel/modules/network/serv_netspool.c +++ b/citadel/modules/network/serv_netspool.c @@ -445,11 +445,11 @@ void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, } /* 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, @@ -457,16 +457,16 @@ void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, 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); @@ -525,9 +525,9 @@ void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, } /* 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); } @@ -535,13 +535,13 @@ void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, /* 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" @@ -555,20 +555,20 @@ void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, } /* 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 */ diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 254a01a28..1f0a680ca 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -111,17 +111,17 @@ int network_usetable(struct CtdlMessage *msg) 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); @@ -366,64 +366,64 @@ void network_bounce(struct CtdlMessage *msg, char *reason) /* * 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 */ diff --git a/citadel/modules/notes/serv_notes.c b/citadel/modules/notes/serv_notes.c index 396ea5be6..bf1de8d06 100644 --- a/citadel/modules/notes/serv_notes.c +++ b/citadel/modules/notes/serv_notes.c @@ -106,7 +106,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg) * 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 */ @@ -121,15 +121,15 @@ int serv_notes_beforesave(struct CtdlMessage *msg) 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++; @@ -137,7 +137,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg) /* 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, @@ -151,21 +151,21 @@ int serv_notes_beforesave(struct CtdlMessage *msg) 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], "..."); } } diff --git a/citadel/modules/rssclient/rss_atom_parser.c b/citadel/modules/rssclient/rss_atom_parser.c index 0a09f2c37..681cf8a14 100644 --- a/citadel/modules/rssclient/rss_atom_parser.c +++ b/citadel/modules/rssclient/rss_atom_parser.c @@ -675,7 +675,7 @@ void rss_remember_item(rss_item *ri, rss_aggregator *RSSAggr) /* 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; @@ -683,11 +683,11 @@ void rss_remember_item(rss_item *ri, rss_aggregator *RSSAggr) 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)); } } diff --git a/citadel/modules/rssclient/serv_rssclient.c b/citadel/modules/rssclient/serv_rssclient.c index d31a59af4..059cd1b47 100644 --- a/citadel/modules/rssclient/serv_rssclient.c +++ b/citadel/modules/rssclient/serv_rssclient.c @@ -307,36 +307,36 @@ int rss_format_item(AsyncIO *IO, networker_save_message *SaveMsg) 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; @@ -358,7 +358,7 @@ int rss_format_item(AsyncIO *IO, networker_save_message *SaveMsg) 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) @@ -398,7 +398,7 @@ eNextState RSSSaveMessage(AsyncIO *IO) 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); diff --git a/citadel/modules/sieve/serv_sieve.c b/citadel/modules/sieve/serv_sieve.c index abce872ce..d7a558472 100644 --- a/citadel/modules/sieve/serv_sieve.c +++ b/citadel/modules/sieve/serv_sieve.c @@ -583,37 +583,37 @@ void sieve_do_msg(long msgnum, void *userdata) { 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 { @@ -630,15 +630,15 @@ void sieve_do_msg(long msgnum, void *userdata) { } /* 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, '<', '>'); } @@ -754,8 +754,8 @@ void get_sieve_config_backend(long msgnum, void *userdata) { 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) { diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index 813d303a4..ad9137ff3 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -320,10 +320,10 @@ void smtp_webcit_preferences_hack_backend(long msgnum, void *userdata) { 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); } @@ -813,12 +813,12 @@ void smtp_data(long offset, long flags) 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))) { @@ -828,43 +828,43 @@ void smtp_data(long offset, long flags) 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( @@ -886,11 +886,11 @@ void smtp_data(long offset, long flags) 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. */ diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 209c964b2..5eddfc1b6 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -222,8 +222,8 @@ eNextState FinalizeMessageSend_DB(AsyncIO *IO) 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); diff --git a/citadel/modules/smtp/serv_smtpqueue.c b/citadel/modules/smtp/serv_smtpqueue.c index 52433b90f..6ff9e35c8 100644 --- a/citadel/modules/smtp/serv_smtpqueue.c +++ b/citadel/modules/smtp/serv_smtpqueue.c @@ -700,11 +700,11 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt, ParsedURL *Relay) 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) { @@ -848,7 +848,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { 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) { diff --git a/citadel/modules/smtp/smtp_util.c b/citadel/modules/smtp/smtp_util.c index 292bebf47..dd4c80751 100644 --- a/citadel/modules/smtp/smtp_util.c +++ b/citadel/modules/smtp/smtp_util.c @@ -161,10 +161,10 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) 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); @@ -286,9 +286,9 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) 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) { diff --git a/citadel/modules/spam/serv_spam.c b/citadel/modules/spam/serv_spam.c index 7c24672ef..f27e22441 100644 --- a/citadel/modules/spam/serv_spam.c +++ b/citadel/modules/spam/serv_spam.c @@ -165,13 +165,13 @@ int spam_assassin(struct CtdlMessage *msg) { 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"); @@ -180,10 +180,10 @@ int spam_assassin(struct CtdlMessage *msg) { } 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"); } } diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 1512c66b7..10516c3fd 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -94,12 +94,12 @@ void vcard_extract_internet_addresses(struct CtdlMessage *msg, int (*callback)(c 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 @@ -373,10 +373,10 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { /* 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, @@ -425,10 +425,10 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { 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 */ @@ -451,23 +451,23 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { /* 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); } } @@ -479,17 +479,17 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { 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); @@ -538,7 +538,7 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { 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); @@ -557,12 +557,12 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { * 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); @@ -652,7 +652,7 @@ struct vCard *vcard_get_user(struct ctdluser *u) { 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; } @@ -905,16 +905,16 @@ void vcard_purge(struct ctdluser *usbuf) { 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); @@ -936,7 +936,7 @@ int vcard_extract_from_network(struct CtdlMessage *msg, char *target_room) { 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) { @@ -979,7 +979,7 @@ void vcard_delete_remove(char *room, long msgnum) { 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"); @@ -1102,7 +1102,7 @@ void dvca_callback(long msgnum, void *userdata) { 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, @@ -1325,7 +1325,7 @@ void strip_addresses_already_have(long msgnum, void *userdata) { 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; @@ -1377,12 +1377,12 @@ void store_this_ha(struct addresses_to_be_filed *aptr) { 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); diff --git a/citadel/modules/wiki/serv_wiki.c b/citadel/modules/wiki/serv_wiki.c index 07e5eed41..799a3f322 100644 --- a/citadel/modules/wiki/serv_wiki.c +++ b/citadel/modules/wiki/serv_wiki.c @@ -100,31 +100,31 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { 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); } @@ -132,13 +132,13 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { 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); } @@ -152,13 +152,13 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { 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, @@ -217,14 +217,14 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { 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" @@ -240,9 +240,9 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { /* 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 @@ -250,7 +250,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { */ strcpy(boundary, ""); - ptr = history_msg->cm_fields['M']; + ptr = history_msg->cm_fields[eMesageText]; do { ptr = memreadline(ptr, buf, sizeof buf); if (*ptr != 0) { @@ -280,10 +280,10 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { */ 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]; @@ -313,9 +313,9 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) { 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); @@ -377,7 +377,7 @@ void wiki_history(char *pagename) { msg = NULL; } - if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) { + if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) { CtdlFreeMessage(msg); msg = NULL; } @@ -389,7 +389,7 @@ void wiki_history(char *pagename) { 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); @@ -509,7 +509,7 @@ void wiki_rev(char *pagename, char *rev, char *operation) msg = NULL; } - if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) { + if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) { CtdlFreeMessage(msg); msg = NULL; } @@ -524,7 +524,7 @@ void wiki_rev(char *pagename, char *rev, char *operation) 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 { @@ -543,7 +543,7 @@ void wiki_rev(char *pagename, char *rev, char *operation) msg = NULL; } - if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) { + if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) { CtdlFreeMessage(msg); msg = NULL; } @@ -562,7 +562,7 @@ void wiki_rev(char *pagename, char *rev, char *operation) 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? */ @@ -585,17 +585,17 @@ void wiki_rev(char *pagename, char *rev, char *operation) 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 */ @@ -619,12 +619,12 @@ void wiki_rev(char *pagename, char *rev, char *operation) } 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 { diff --git a/citadel/modules/xmpp/xmpp_presence.c b/citadel/modules/xmpp/xmpp_presence.c index d4e69316a..1fa5b1d12 100644 --- a/citadel/modules/xmpp/xmpp_presence.c +++ b/citadel/modules/xmpp/xmpp_presence.c @@ -238,12 +238,12 @@ void xmpp_fetch_mortuary_backend(long msgnum, void *userdata) { /* 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; } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index cb94c8f89..be3a87628 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -116,7 +116,47 @@ char *msgkeys[] = { 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]); @@ -289,11 +329,11 @@ void headers_listing(long msgnum, void *userdata) 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); } @@ -313,8 +353,8 @@ void headers_euid(long msgnum, void *userdata) 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); } @@ -1260,16 +1300,16 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body) * 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) */ @@ -1787,7 +1827,7 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ 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 @@ -1795,13 +1835,13 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ 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; @@ -1835,13 +1875,13 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ 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); @@ -2005,16 +2045,15 @@ void OutputCtdlMsgHeaders( 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, "", 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); } @@ -2038,35 +2077,37 @@ void OutputCtdlMsgHeaders( * 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; icm_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] ); } } @@ -2097,7 +2138,7 @@ void OutputRFC822MsgHeaders( 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); } @@ -2111,7 +2152,7 @@ void OutputRFC822MsgHeaders( 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') { @@ -2129,7 +2170,7 @@ void OutputRFC822MsgHeaders( } 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", @@ -2173,7 +2214,7 @@ void OutputRFC822MsgHeaders( } } } - else if (i == 'K') { + else if (i == eReplyTo) { hptr = mptr; while ((*hptr != '\0') && isspace(*hptr)) hptr ++; @@ -2205,7 +2246,7 @@ void Dump_RFC822HeadersBody( int nllen = strlen(nl); char *mptr; - mptr = TheMessage->cm_fields['M']; + mptr = TheMessage->cm_fields[eMesageText]; prev_ch = '\0'; @@ -2286,7 +2327,7 @@ void DumpFormatFixed( 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"); @@ -2388,8 +2429,8 @@ int CtdlOutputPreLoadedMsg( /* 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? */ @@ -2404,7 +2445,7 @@ int CtdlOutputPreLoadedMsg( 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 @@ -2431,7 +2472,7 @@ int CtdlOutputPreLoadedMsg( /* 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 */ @@ -2529,7 +2570,7 @@ START_TEXT: /* 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), @@ -2570,7 +2611,7 @@ START_TEXT: * 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"); @@ -2876,8 +2917,8 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms 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 */ @@ -2953,16 +2994,16 @@ long send_message(struct CtdlMessage *msg) { ); /* 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; } } @@ -2970,7 +3011,7 @@ long send_message(struct CtdlMessage *msg) { serialize_message(&smr, msg); if (is_bigmsg) { - msg->cm_fields['M'] = holdM; + msg->cm_fields[eMesageText] = holdM; } if (smr.len == 0) { @@ -3020,9 +3061,7 @@ void serialize_message(struct ser_ret *ret, /* return values */ 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)); @@ -3037,10 +3076,10 @@ void serialize_message(struct ser_ret *ret, /* return values */ } ret->len = 3; - for (i=0; icm_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; } @@ -3058,14 +3097,14 @@ void serialize_message(struct ser_ret *ret, /* return values */ ret->ser[2] = msg->cm_format_type; wlen = 3; - for (i=0; icm_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; @@ -3095,12 +3134,12 @@ void ReplicationChecks(struct CtdlMessage *msg) { /* 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, ""); @@ -3152,24 +3191,24 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* 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"); } } @@ -3181,7 +3220,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* 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); } @@ -3195,7 +3234,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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); @@ -3245,8 +3284,8 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* * 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) */ @@ -3341,7 +3380,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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 @@ -3375,11 +3414,11 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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); } @@ -3392,12 +3431,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* 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 @@ -3412,12 +3451,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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) { @@ -3437,10 +3476,10 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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 */ @@ -3496,10 +3535,10 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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); } @@ -3527,7 +3566,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ /* * Determine whether this message qualifies for journaling. */ - if (msg->cm_fields['J'] != NULL) { + if (msg->cm_fields[eJournal] != NULL) { qualified_for_journaling = 0; } else { @@ -3582,29 +3621,29 @@ void quickie_message(const char *from, 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); @@ -3983,16 +4022,16 @@ struct CtdlMessage *CtdlMakeMessage( 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); @@ -4001,34 +4040,34 @@ struct CtdlMessage *CtdlMakeMessage( 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) { @@ -4044,30 +4083,30 @@ struct CtdlMessage *CtdlMakeMessage( (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); @@ -4754,7 +4793,7 @@ void cmd_ent0(char *entargs) * 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) { @@ -4772,8 +4811,8 @@ void cmd_ent0(char *entargs) 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"); } @@ -5441,13 +5480,13 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ 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) { @@ -5506,7 +5545,7 @@ char *CtdlGetSysConfig(char *sysconfname) { else { msg = CtdlFetchMessage(msgnum, 1); if (msg != NULL) { - conf = strdup(msg->cm_fields['M']); + conf = strdup(msg->cm_fields[eMesageText]); CtdlFreeMessage(msg); } else { diff --git a/citadel/msgbase.h b/citadel/msgbase.h index e9f8a3f84..d6b21b094 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -164,7 +164,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ ); 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 *); diff --git a/citadel/server.h b/citadel/server.h index cd8034d19..10e8bee73 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -1,5 +1,3 @@ - - #ifndef SERVER_H #define SERVER_H @@ -138,8 +136,8 @@ enum { S_NETSPOOL, S_XMPP_QUEUE, S_SCHEDULE_LIST, - S_SINGLE_USER, - S_LDAP, + S_SINGLE_USER, + S_LDAP, S_IM_LOGS, MAX_SEMAPHORES }; @@ -167,7 +165,7 @@ enum { /* * 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) */ @@ -198,7 +196,7 @@ struct cdbdata { }; -/* +/* * Event types can't be enum'ed, because they must remain consistent between * builds (to allow for binary modules built somewhere else) */ @@ -275,12 +273,12 @@ struct arcq { }; -/* +/* * 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; }; @@ -294,11 +292,40 @@ struct UseTable { -/* 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 */ diff --git a/citadel/techdoc/hack.txt b/citadel/techdoc/hack.txt index c4fec985d..f88432690 100644 --- a/citadel/techdoc/hack.txt +++ b/citadel/techdoc/hack.txt @@ -48,7 +48,7 @@ a separate Citadel password. 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. @@ -227,73 +227,98 @@ can do wildcard matching without worrying about unpacking binary data such 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 -- 2.30.2