- char wefw[1024] = "";
- char msgn[256] = "";
- char from[256] = "";
- char node[256] = "";
- char rfca[256] = "";
- char rcpt[SIZ] = "";
- char cccc[SIZ] = "";
- serv_printf("MSG0 %ld|1", replying_to);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-
- if ( (!strncasecmp(buf, "subj=", 5)) && (strlen(buf) > 5) ) {
- StrBuf *subj = NewStrBuf();
- if (!strcasecmp(bstr("replying_mode"), "forward")) {
- if (strncasecmp(&buf[5], "Fw:", 3)) {
- StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
- }
- }
- else {
- if (strncasecmp(&buf[5], "Re:", 3)) {
- StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
- }
- }
- StrBufAppendBufPlain(subj, &buf[5], -1, 0);
- PutBstr(HKEY("subject"), subj);
- }
-
- else if (!strncasecmp(buf, "wefw=", 5)) {
- int rrtok;
- int rrlen;
- safestrncpy(wefw, &buf[5], sizeof wefw);
-
- /* Trim down excessively long lists of thread references. We eliminate the
- * second one in the list so that the thread root remains intact.
- */
- rrtok = num_tokens(wefw, '|');
- rrlen = strlen(wefw);
- if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
- remove_token(wefw, 1, '|');
- }
- }
-
- else if (!strncasecmp(buf, "msgn=", 5)) {
- safestrncpy(msgn, &buf[5], sizeof msgn);
- }
-
- else if (!strncasecmp(buf, "from=", 5)) {
- safestrncpy(from, &buf[5], sizeof from);
- for (i=0; i<strlen(from); ++i) {
- if (from[i] == ',') from[i] = ' ';
- }
- }
-
- else if (!strncasecmp(buf, "rcpt=", 5)) {
- safestrncpy(rcpt, &buf[5], sizeof rcpt);
- }
-
- else if (!strncasecmp(buf, "cccc=", 5)) {
- safestrncpy(cccc, &buf[5], sizeof cccc);
- }
-
- else if (!strncasecmp(buf, "node=", 5)) {
- safestrncpy(node, &buf[5], sizeof node);
- }
+ long len;
+ StrBuf *wefw = NULL;
+ StrBuf *msgn = NULL;
+ StrBuf *from = NULL;
+ StrBuf *rfca = NULL;
+ StrBuf *rcpt = NULL;
+ StrBuf *cccc = NULL;
+ StrBuf *replyto = NULL;
+ StrBuf *nvto = NULL;
+ int message_originated_locally = 0;
+ serv_printf("MSG0 %ld|1", replying_to);
+
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
+ while (len = StrBuf_ServGetln(Line), (len >= 0) && ((len != 3) || strcmp(ChrPtr(Line), "000"))) {
+ eMessageField which;
+ if ((StrLength(Line) > 4) && (ChrPtr(Line)[4] == '=') && GetFieldFromMnemonic(&which, ChrPtr(Line)))
+ switch (which) {
+ case eMsgSubject:{
+ StrBuf *subj = NewStrBuf();
+ StrBuf *FlatSubject;
+
+ if (ReplyMode == eForward) {
+ if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+ }
+ }
+ else {
+ if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+ }
+ }
+ StrBufAppendBufPlain(subj, ChrPtr(Line) + 5, StrLength(Line) - 5, 0);
+ FlatSubject = NewStrBufPlain(NULL, StrLength(subj));
+ StrBuf_RFC822_to_Utf8(FlatSubject, subj, NULL, NULL);
+
+ PutBstr(HKEY("subject"), FlatSubject);
+ }
+ break;
+
+ case eIsLocal:{
+ message_originated_locally = 1;
+ break;
+ }
+
+ case eWeferences:
+ {
+ int rrtok;
+ int rrlen;
+
+ wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+
+ /* Trim down excessively long lists of thread references. We eliminate the
+ * second one in the list so that the thread root remains intact.
+ */
+ rrtok = num_tokens(ChrPtr(wefw), '|');
+ rrlen = StrLength(wefw);
+ if (((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10)) {
+ StrBufRemove_token(wefw, 1, '|');
+ }
+ break;
+ }
+
+ case emessageId:
+ msgn = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+
+ case eAuthor:{
+ StrBuf *FlatFrom;
+ from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ FlatFrom = NewStrBufPlain(NULL, StrLength(from));
+ StrBuf_RFC822_to_Utf8(FlatFrom, from, NULL, NULL);
+ FreeStrBuf(&from);
+ from = FlatFrom;
+ for (i = 0; i < StrLength(from); ++i) {
+ if (ChrPtr(from)[i] == ',')
+ StrBufPeek(from, NULL, i, ' ');
+ }
+ break;
+ }
+ case eRecipient:
+ rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+ case eCarbonCopY:
+ cccc = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+ case eReplyTo:
+ replyto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+ case erFc822Addr:{
+ StrBuf *FlatRFCA;
+ rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ FlatRFCA = NewStrBufPlain(NULL, StrLength(rfca));
+ StrBuf_RFC822_to_Utf8(FlatRFCA, rfca, NULL, NULL);
+ FreeStrBuf(&rfca);
+ rfca = FlatRFCA;
+ break;
+ }
+ case eenVelopeTo:
+ nvto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ putbstr("nvto", nvto);
+ break;
+ case eXclusivID:
+ case eJournal:
+ case eListID:
+ case eMesageText:
+ case eMessagePath:
+ case eSpecialField:
+ case eTimestamp:
+ case eHeaderOnly:
+ case eFormatType:
+ case eMessagePart:
+ case eSubFolder:
+ case eLastHeader:
+ break;