summaryrefslogtreecommitdiffstats
path: root/maildrop/messageinfo.C
blob: a7c339edf3ae0424f1d58cdb640ae9c20c7addef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "config.h"
#include	"messageinfo.h"
#include	"message.h"
#include	<ctype.h>

void MessageInfo::info(Message &msg)
{
Buffer	buf;

	msg.Rewind();
	fromname.set("MAILER-DAEMON");

	for (;;)
	{
		buf.reset();
		if (msg.appendline(buf) < 0)	return;

		int	l=buf.Length();

		const char *p=buf;

		if (l && p[l-1] == '\n')
		{
			--l;
			buf.Length(l);
		}

		if (l == 0)	break;

		p=buf;
		if (strncasecmp(p, "Return-Path:", 12))
			continue;

		p += 12;
		l -= 12;

		while (*p && *p != '\n' && isspace(*p) && l)
		{
			++p;
			--l;
		}

		if (l && *p == '<')
		{
			++p;
			--l;
		}

		int i;

		for (i=0; i<l; i++)
		{
			if (!p[i])
				break;
			if (p[i] == '>')
				break;
			if (isspace(p[i]))
				break;
		}
		fromname.reset();
		fromname.append(p, i);
		break;
	}
}