Subversion Repositories Kolibri OS

Rev

Rev 4186 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4186 Rev 4417
Line 3... Line 3...
3
void ParseMail()
3
void ParseMail()
4
{
4
{
5
	dword line_off, new_buf;
5
	dword line_off, new_buf;
6
	char tline[256];
6
	char tline[256];
Line 7... Line 7...
7
 
7
 
8
	if ( mailend-mailstart > 9) && (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
8
	if ( mailend-mailstart > 9) if (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
-
 
9
	{
9
	{
10
		aim = STOP;
10
		mailend -= 5;
11
		mailend -= 5;
11
		DSBYTE[mailend] = '\0';
12
		DSBYTE[mailend] = '\0';
12
		if (strstr(mailstart, "+OK")!=mailstart) 
13
		if (strstr(mailstart, "+OK")!=mailstart) 
13
		{
14
		{
14
			aim = GET_ANSWER_RETR;
15
			aim = GET_ANSWER_RETR;
15
			mailend = mailstart;
16
			mailend = mailstart;
16
			debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR");
17
			debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR");
17
			return;
18
			return;
18
		}
-
 
19
		aim=NULL;
19
		}
20
		mailsize = mailend - mailstart;
-
 
21
 
20
		mailsize = mailend - mailstart;
22
		debug("Getting QP");
21
		debug("Getting QP");
23
		if (strstri(mailstart, "quoted-printable")!=0)
22
		if (strstri(mailstart, "quoted-printable")!=0)
24
		{
23
		{
25
			new_buf = malloc(mailsize);
24
			new_buf = malloc(mailsize);
Line 31... Line 30...
31
				mailstart = new_buf;
30
				mailstart = new_buf;
32
				mailsize = strlen(mailstart);
31
				mailsize = strlen(mailstart);
33
				mailend = mailsize + mailstart;
32
				mailend = mailsize + mailstart;
34
			}
33
			}
35
		}
34
		}
-
 
35
		debug("ProcessBase64");
-
 
36
		ProcessBase64();
36
		debug("GetHeaders: From, To, Date, Subject");
37
		debug("GetHeaders: From, To, Date, Subject");
37
		GetHeader(#from, "\nFrom:");
38
		GetHeader(#from, "\nFrom:");
38
		GetHeader(#to,   "\nTo:");
39
		GetHeader(#to,   "\nTo:");
39
		GetHeader(#date, "\nDate:");
40
		GetHeader(#date, "\nDate:");
40
		GetHeader(#subj, "\nSubject:");
41
		GetHeader(#subj, "\nSubject:");
41
		debug("Get mdata");
42
		debug("Get mdata");
42
		mdata = strstr(mailstart, "\x0a\x0d") + 3;		// 0x0d 0x0a, 0x0a
43
		mdata = strstr(mailstart, "\x0a\x0d") + 3;
43
		debug("ConvertToDOS");
44
		debug("ConvertToDOS");
44
		ConvertToDOS(mdata, mailstart);
45
		ConvertToDOS(mdata, mailstart);
45
		debug("FromHTMLtoTXT");
46
		debug("FromHTMLtoTXT");
46
		FromHTMLtoTXT();
47
		FromHTMLtoTXT();
47
		letter_view.first = letter_view.count = 0;
48
		letter_view.first = letter_view.count = 0;
Line 149... Line 150...
149
	char tmpbuf[512];
150
	char tmpbuf[512];
150
	dword Qoff;
151
	dword Qoff;
151
	int q_start, b_start;
152
	int q_start, b_start;
Line 152... Line 153...
152
 
153
 
-
 
154
	strcpyb(mailstart, workstr, searchstr, "\n");
153
	strcpyb(mailstart, workstr, searchstr, "\n");
155
	/*
154
	debug(searchstr);
156
	debug(searchstr);
155
	debug(workstr);
157
	debug(workstr);
156
	if (strlen(workstr)<8) return;
158
	if (strlen(workstr)<8) return;
157
	q_start = strstri(workstr, "?Q?");
159
	q_start = strstri(workstr, "?Q?");
Line 171... Line 173...
171
		base64_decode stdcall (b_start, #tmpbuf, strlen(b_start)-5);
173
		base64_decode stdcall (b_start, #tmpbuf, strlen(b_start)-5);
172
		ConvertToDOS(#tmpbuf, workstr);	
174
		ConvertToDOS(#tmpbuf, workstr);	
173
		strcpy(workstr, #tmpbuf);
175
		strcpy(workstr, #tmpbuf);
174
	}
176
	}
175
	if (strlen(workstr)+10*6-Form.cwidth>0) { workstr=Form.cwidth/6+workstr-12; DSBYTE[workstr]='\0';}
177
	if (strlen(workstr)+10*6-Form.cwidth>0) { workstr=Form.cwidth/6+workstr-12; DSBYTE[workstr]='\0';}
-
 
178
	*/
176
}
179
}
177
180
 
-
 
181
 
-
 
182
 
-
 
183
void ProcessBase64()
-
 
184
{
-
 
185
	int b_start, b_end, b_size, b_buf;
-
 
186
	int clean_mailstart;
-
 
187
 
-
 
188
	b_start = strstr(mailstart, "?B?");
-
 
189
	debug("b_size");
-
 
190
	debugi(b_start);
-
 
191
	if (b_start)
-
 
192
	{
-
 
193
		b_end = strstr(b_start, "?=");
-
 
194
		debug("b_end");
-
 
195
		debugi(b_end);
-
 
196
		b_size = b_end - b_start;
-
 
197
		debug("b_size");
-
 
198
		debugi(b_size);
-
 
199
		b_buf = malloc(b_size);
-
 
200
		strcpyb(mailstart, b_buf, "?B?", "?=");
-
 
201
		debug("b_buf");
-
 
202
		debug(b_buf);
-
 
203
 
-
 
204
		base64_decode stdcall (b_buf, b_buf, b_size-3);
-
 
205
		ConvertToDOS(b_buf, mailstart);	
-
 
206
		if (b_size
-
 
207
 
-
 
208
		clean_mailstart = malloc(strlen(mailstart));
-
 
209
		strlcpy(clean_mailstart, mailstart, b_start-mailstart);
-
 
210
		strcat(clean_mailstart, b_buf);
-
 
211
		strcat(clean_mailstart, b_end+2);
-
 
212
		free(b_buf);
-
 
213
		free(mailstart);
-
 
214
		mailsize = strlen(clean_mailstart);
-
 
215
		mailstart = clean_mailstart;
-
 
216
		mailend = mailstart + mailsize;
-
 
217
		ProcessBase64();
-
 
218
	}
-
 
219
}
-
 
220
 
-
 
221
 
-
 
222
//
-
 
223
178
224