quickie_message also needs to set this.
* to the actual mail address so others get a valid
* reply-to-header.
*/
* to the actual mail address so others get a valid
* reply-to-header.
*/
- msg->cm_fields[eenVelopeTo] = strdup(valid->recp_orgroom);
+ CM_SetField(msg, eenVelopeTo, valid->recp_orgroom, strlen(valid->recp_orgroom));
commandSiz = sizeof(config.c_pager_program) +
strlen(PagerNo) +
commandSiz = sizeof(config.c_pager_program) +
strlen(PagerNo) +
- strlen(msg->cm_fields[eExtnotify]) + 5;
+ msg->cm_lengths[eExtnotify] + 5;
command = malloc(commandSiz);
command = malloc(commandSiz);
if (fieldptr != NULL) free(fieldptr);
/* message ID */
if (fieldptr != NULL) free(fieldptr);
/* message ID */
- len = strlen(msg->cm_fields[emessageId]);
+ len = msg->cm_lengths[emessageId];
if ((len == 0) || (
(msg->cm_fields[emessageId][0] == '<') &&
if ((len == 0) || (
(msg->cm_fields[emessageId][0] == '<') &&
need_to_free_msg = 1;
}
if (msg != NULL) {
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (strlen(msg->cm_fields[eMesageText]) > atoi(itemlist[pos+1].Key)) {
+ if (msg->cm_lengths[eMesageText] > atoi(itemlist[pos+1].Key)) {
need_to_free_msg = 1;
}
if (msg != NULL) {
need_to_free_msg = 1;
}
if (msg != NULL) {
- if (strlen(msg->cm_fields[eMesageText]) < atoi(itemlist[pos+1].Key)) {
+ if (msg->cm_lengths[eMesageText] < atoi(itemlist[pos+1].Key)) {
Subject = NewStrBufPlain(HKEY("(no subject)"));
}
else {
Subject = NewStrBufPlain(HKEY("(no subject)"));
}
else {
- Subject = NewStrBufPlain(
- msg->cm_fields[eMsgSubject], -1);
+ Subject = NewStrBufPlain(CM_KEY(msg, eMsgSubject));
}
FlatSubject = NewStrBufPlain(NULL, StrLength(Subject));
StrBuf_RFC822_to_Utf8(FlatSubject, Subject, NULL, NULL);
}
FlatSubject = NewStrBufPlain(NULL, StrLength(Subject));
StrBuf_RFC822_to_Utf8(FlatSubject, Subject, NULL, NULL);
- Buf = NewStrBufPlain(msg->cm_fields[eNodeName], -1);
+ Buf = NewStrBufPlain(CM_KEY(msg, eNodeName));
if (CtdlIsValidNode(NULL,
NULL,
Buf,
if (CtdlIsValidNode(NULL,
NULL,
Buf,
if (strcasecmp(msg->cm_fields[eDestination], config.c_nodename)) {
/* route the message */
if (strcasecmp(msg->cm_fields[eDestination], config.c_nodename)) {
/* route the message */
- Buf = NewStrBufPlain(msg->cm_fields[eDestination], -1);
+ Buf = NewStrBufPlain(CM_KEY(msg,eDestination));
if (CtdlIsValidNode(&nexthop,
NULL,
Buf,
if (CtdlIsValidNode(&nexthop,
NULL,
Buf,
}
/* Generate the message ID */
}
/* Generate the message ID */
- msgid = NewStrBufPlain(msg->cm_fields[emessageId], -1);
+ msgid = NewStrBufPlain(CM_KEY(msg, emessageId));
if (haschar(ChrPtr(msgid), '@') == 0) {
StrBufAppendBufPlain(msgid, HKEY("@"), 0);
if (!CM_IsEmpty(msg, eNodeName)) {
if (haschar(ChrPtr(msgid), '@') == 0) {
StrBufAppendBufPlain(msgid, HKEY("@"), 0);
if (!CM_IsEmpty(msg, eNodeName)) {
- StrBufAppendBufPlain(msgid, msg->cm_fields[eNodeName], -1, 0);
+ StrBufAppendBufPlain(msgid, CM_KEY(msg, eNodeName), 0);
}
else {
FreeStrBuf(&msgid);
}
else {
FreeStrBuf(&msgid);
*/
strcpy(uuid, "");
p = msg->cm_fields[eMesageText];
*/
strcpy(uuid, "");
p = msg->cm_fields[eMesageText];
+ a = msg->cm_lengths[eMesageText];
while (--a > 0) {
if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */
safestrncpy(uuid, p + 16, sizeof(uuid));
while (--a > 0) {
if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */
safestrncpy(uuid, p + 16, sizeof(uuid));
if ((v->summary) && (!IsEmptyStr(v->summary))) {
CM_SetField(msg, eMsgSubject, v->summary, strlen(v->summary));
if ((v->summary) && (!IsEmptyStr(v->summary))) {
CM_SetField(msg, eMsgSubject, v->summary, strlen(v->summary));
- if (strlen(msg->cm_fields[eMsgSubject]) > 72) {
+ if (msg->cm_lengths[eMsgSubject] > 72) {
strcpy(&msg->cm_fields[eMsgSubject][68], "...");
CM_CutFieldAt(msg, eMsgSubject, 72);
}
strcpy(&msg->cm_fields[eMsgSubject][68], "...");
CM_CutFieldAt(msg, eMsgSubject, 72);
}
/* 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.
*/
/* 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[eExclusiveID]) >= 9)
- && (!strcasecmp(&msg->cm_fields[eExclusiveID][strlen(msg->cm_fields[eExclusiveID])-9], "_HISTORY_"))
+ if ( (msg->cm_lengths[eExclusiveID] >= 9)
+ && (!strcasecmp(&msg->cm_fields[eExclusiveID][msg->cm_lengths[eExclusiveID]-9], "_HISTORY_"))
) {
syslog(LOG_DEBUG, "History page not being historied\n");
return(0);
) {
syslog(LOG_DEBUG, "History page not being historied\n");
return(0);
if (old_msg != NULL) {
fp = fopen(diff_old_filename, "w");
if (old_msg != NULL) {
fp = fopen(diff_old_filename, "w");
- rv = fwrite(old_msg->cm_fields[eMesageText], strlen(old_msg->cm_fields[eMesageText]), 1, fp);
+ rv = fwrite(old_msg->cm_fields[eMesageText], old_msg->cm_lengths[eMesageText], 1, fp);
fclose(fp);
CM_Free(old_msg);
}
fp = fopen(diff_new_filename, "w");
fclose(fp);
CM_Free(old_msg);
}
fp = fopen(diff_new_filename, "w");
- rv = fwrite(msg->cm_fields[eMesageText], strlen(msg->cm_fields[eMesageText]), 1, fp);
+ rv = fwrite(msg->cm_fields[eMesageText], msg->cm_lengths[eMesageText], 1, fp);
fclose(fp);
snprintf(diff_cmd, sizeof diff_cmd,
fclose(fp);
snprintf(diff_cmd, sizeof diff_cmd,
CtdlMakeTempFileName(temp, sizeof temp);
fp = fopen(temp, "w");
if (fp != NULL) {
CtdlMakeTempFileName(temp, sizeof temp);
fp = fopen(temp, "w");
if (fp != NULL) {
- r = fwrite(msg->cm_fields[eMesageText], strlen(msg->cm_fields[eMesageText]), 1, fp);
+ r = fwrite(msg->cm_fields[eMesageText], msg->cm_lengths[eMesageText], 1, fp);
if ((Author != NULL) && (*Author == NULL))
{
if ((Author != NULL) && (*Author == NULL))
{
- *Author = TheMessage->cm_fields[eAuthor];
- TheMessage->cm_fields[eAuthor] = NULL;
+ long len;
+ CM_GetAsField(TheMessage, eAuthor, Author, &len);
}
if ((Address != NULL) && (*Address == NULL))
{
}
if ((Address != NULL) && (*Address == NULL))
{
- *Address = TheMessage->cm_fields[erFc822Addr];
- TheMessage->cm_fields[erFc822Addr] = NULL;
+ long len;
+ CM_GetAsField(TheMessage, erFc822Addr, Address, &len);
}
CM_Free(TheMessage);
TheMessage = NULL;
}
CM_Free(TheMessage);
TheMessage = NULL;
retcode = CtdlOutputPreLoadedMsg(TheMessage, mode, headers_only, do_proto, crlf, flags);
if ((Author != NULL) && (*Author == NULL))
{
retcode = CtdlOutputPreLoadedMsg(TheMessage, mode, headers_only, do_proto, crlf, flags);
if ((Author != NULL) && (*Author == NULL))
{
- *Author = TheMessage->cm_fields[eAuthor];
- TheMessage->cm_fields[eAuthor] = NULL;
+ long len;
+ CM_GetAsField(TheMessage, eAuthor, Author, &len);
}
if ((Address != NULL) && (*Address == NULL))
{
}
if ((Address != NULL) && (*Address == NULL))
{
- *Address = TheMessage->cm_fields[erFc822Addr];
- TheMessage->cm_fields[erFc822Addr] = NULL;
+ long len;
+ CM_GetAsField(TheMessage, erFc822Addr, Address, &len);
* Pad it with spaces in order to avoid changing the RFC822 length of the message.
*/
if ( (flags & SUPPRESS_ENV_TO) && (!CM_IsEmpty(TheMessage, eenVelopeTo)) ) {
* Pad it with spaces in order to avoid changing the RFC822 length of the message.
*/
if ( (flags & SUPPRESS_ENV_TO) && (!CM_IsEmpty(TheMessage, eenVelopeTo)) ) {
- memset(TheMessage->cm_fields[eenVelopeTo], ' ', strlen(TheMessage->cm_fields[eenVelopeTo]));
+ memset(TheMessage->cm_fields[eenVelopeTo], ' ', TheMessage->cm_lengths[eenVelopeTo]);
}
/* Are we downloading a MIME component? */
}
/* Are we downloading a MIME component? */
struct ser_ret smr;
int is_bigmsg = 0;
char *holdM = NULL;
struct ser_ret smr;
int is_bigmsg = 0;
char *holdM = NULL;
/* Get a new message number */
newmsgid = get_new_message_number();
/* Get a new message number */
newmsgid = get_new_message_number();
is_bigmsg = 1;
holdM = msg->cm_fields[eMesageText];
msg->cm_fields[eMesageText] = NULL;
is_bigmsg = 1;
holdM = msg->cm_fields[eMesageText];
msg->cm_fields[eMesageText] = NULL;
- oldMLen = msg->cm_lengths[eMesageText];
+ holdMLen = msg->cm_lengths[eMesageText];
msg->cm_lengths[eMesageText] = 0;
}
}
msg->cm_lengths[eMesageText] = 0;
}
}
if (is_bigmsg) {
msg->cm_fields[eMesageText] = holdM;
if (is_bigmsg) {
msg->cm_fields[eMesageText] = holdM;
+ msg->cm_lengths[eMesageText] = holdMLen;
&newmsgid,
(int)sizeof(long),
holdM,
&newmsgid,
(int)sizeof(long),
holdM,
msg->cm_format_type = format_type;
if (from != NULL) {
msg->cm_format_type = format_type;
if (from != NULL) {
- msg->cm_fields[eAuthor] = strdup(from);
+ CM_SetField(msg, eAuthor, from, strlen(from));
}
else if (fromaddr != NULL) {
}
else if (fromaddr != NULL) {
- msg->cm_fields[eAuthor] = strdup(fromaddr);
- if (strchr(msg->cm_fields[eAuthor], '@')) {
- *strchr(msg->cm_fields[eAuthor], '@') = 0;
+ char *pAt;
+ CM_SetField(msg, eAuthor, fromaddr, strlen(fromaddr));
+ pAt = strchr(msg->cm_fields[eAuthor], '@');
+ if (pAt != NULL) {
+ CM_CutFieldAt(msg, eAuthor, pAt - msg->cm_fields[eAuthor]);
}
}
else {
msg->cm_fields[eAuthor] = strdup("Citadel");
}
}
}
else {
msg->cm_fields[eAuthor] = strdup("Citadel");
}
- 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 (fromaddr != NULL) CM_SetField(msg, erFc822Addr, fromaddr, strlen(fromaddr));
+ if (room != NULL) CM_SetField(msg, eOriginalRoom, room, strlen(room));
+ CM_SetField(msg, eNodeName, NODENAME, strlen(NODENAME));
- msg->cm_fields[eRecipient] = strdup(to);
+ CM_SetField(msg, eRecipient, to, strlen(to));
recp = validate_recipients(to, NULL, 0);
}
if (subject != NULL) {
recp = validate_recipients(to, NULL, 0);
}
if (subject != NULL) {
- msg->cm_fields[eMsgSubject] = strdup(subject);
+ CM_SetField(msg, eMsgSubject, subject, strlen(subject));
- msg->cm_fields[eMesageText] = strdup(text);
+ CM_SetField(msg, eMesageText, text, strlen(text));
CtdlSubmitMsg(msg, recp, room, 0);
CM_Free(msg);
CtdlSubmitMsg(msg, recp, room, 0);
CM_Free(msg);