… | |
… | |
15 | */ |
15 | */ |
16 | |
16 | |
17 | /* |
17 | /* |
18 | * These are very central functions of UUDeview. Here, we scan a file |
18 | * These are very central functions of UUDeview. Here, we scan a file |
19 | * and decide whether it contains encoded data or not. ScanPart() must |
19 | * and decide whether it contains encoded data or not. ScanPart() must |
20 | * be called repeatedly on the same file until feof(file). Each time, |
20 | * be called repeatedly on the same file until FP_feof(file). Each time, |
21 | * it returns information about the next part found within. |
21 | * it returns information about the next part found within. |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #ifdef HAVE_CONFIG_H |
24 | #ifdef HAVE_CONFIG_H |
25 | #include "config.h" |
25 | #include "config.h" |
… | |
… | |
32 | #include <os2.h> |
32 | #include <os2.h> |
33 | #endif |
33 | #endif |
34 | |
34 | |
35 | #include <stdio.h> |
35 | #include <stdio.h> |
36 | #include <ctype.h> |
36 | #include <ctype.h> |
37 | |
|
|
38 | #ifdef STDC_HEADERS |
|
|
39 | #include <stdlib.h> |
37 | #include <stdlib.h> |
40 | #include <string.h> |
38 | #include <string.h> |
41 | #endif |
|
|
42 | #ifdef HAVE_MALLOC_H |
|
|
43 | #include <malloc.h> |
39 | #include <errno.h> |
44 | #endif |
40 | |
45 | #ifdef HAVE_UNISTD_H |
41 | #ifdef HAVE_UNISTD_H |
46 | #include <unistd.h> |
42 | #include <unistd.h> |
47 | #endif |
|
|
48 | #ifdef HAVE_MEMORY_H |
|
|
49 | #include <memory.h> |
|
|
50 | #endif |
|
|
51 | #ifdef HAVE_ERRNO_H |
|
|
52 | #include <errno.h> |
|
|
53 | #endif |
43 | #endif |
54 | |
44 | |
55 | #include <uudeview.h> |
45 | #include <uudeview.h> |
56 | #include <uuint.h> |
46 | #include <uuint.h> |
57 | #include <fptools.h> |
47 | #include <fptools.h> |
58 | #include <uustring.h> |
48 | #include <uustring.h> |
59 | |
|
|
60 | char * uuscan_id = "$Id: uuscan.c,v 1.3.2.5 2004/04/18 19:55:46 root Exp $"; |
|
|
61 | |
49 | |
62 | /* |
50 | /* |
63 | * Header fields we recognize as such. See RFC822. We add "From ", |
51 | * Header fields we recognize as such. See RFC822. We add "From ", |
64 | * the usual marker for a beginning of a new message, and a couple |
52 | * the usual marker for a beginning of a new message, and a couple |
65 | * of usual MDA, News and MIME headers. |
53 | * of usual MDA, News and MIME headers. |
66 | * We make a distinction of MIME headers as we need the difference |
54 | * We make a distinction of MIME headers as we need the difference |
67 | * to scan the bodies from partial multipart messages. |
55 | * to scan the bodies from partial multipart messages. |
68 | */ |
56 | */ |
69 | |
57 | |
70 | static char *knownmsgheaders[] = { |
58 | #define LSTR(s) { (s), sizeof (s) - 1 } |
71 | "From ", "Return-Path:", "Received:", "Reply-To:", |
|
|
72 | "From:", "Sender:", "Resent-Reply-To:", "Resent-From:", |
|
|
73 | "Resent-Sender:", "Date:", "Resent-Date:", "To:", |
|
|
74 | "Resent-To:", "Cc:", "Bcc:", "Resent-bcc:", |
|
|
75 | "Message-ID:", "Resent-Message-Id:", "In-Reply-To:", |
|
|
76 | "References:", "Keywords:", "Subject:", "Comments:", |
|
|
77 | |
|
|
78 | "Delivery-Date:", "Posted-Date:", "Received-Date:", |
|
|
79 | "Precedence:", |
|
|
80 | |
59 | |
81 | "Path:", "Newsgroups:", "Organization:", "Lines:", |
60 | struct lstr { |
82 | "NNTP-Posting-Host:", |
61 | const char *str; |
83 | NULL |
62 | int len; |
84 | }; |
63 | }; |
85 | |
64 | |
86 | static char *knownmimeheaders[] = { |
65 | #define MAX_KNOWNHEADERLEN 28 /* max. length of a known header */ |
|
|
66 | |
|
|
67 | static const struct lstr knownheaders[] = { |
|
|
68 | /* "From " handled in IsKnownHeader */ |
|
|
69 | |
|
|
70 | /* knownmsgheaders */ |
|
|
71 | LSTR ("Return-Path"), LSTR ("Received"), LSTR ("Reply-To"), |
|
|
72 | LSTR ("From"), LSTR ("Sender"), LSTR ("Resent-Reply-To"), LSTR ("Resent-From"), |
|
|
73 | LSTR ("Resent-Sender"), LSTR ("Date"), LSTR ("Resent-Date"), LSTR ("To"), |
|
|
74 | LSTR ("Resent-To"), LSTR ("Cc"), LSTR ("Bcc"), LSTR ("Resent-bcc"), |
|
|
75 | LSTR ("Message-ID"), LSTR ("Resent-Message-Id"), LSTR ("In-Reply-To"), |
|
|
76 | LSTR ("References"), LSTR ("Keywords"), LSTR ("Subject"), LSTR ("Comments"), |
|
|
77 | |
|
|
78 | LSTR ("Delivery-Date"), LSTR ("Posted-Date"), LSTR ("Received-Date"), |
|
|
79 | LSTR ("Precedence"), |
|
|
80 | |
|
|
81 | LSTR ("Path"), LSTR ("Newsgroups"), LSTR ("Organization"), LSTR ("Lines"), |
|
|
82 | LSTR ("NNTP-Posting-Host"), |
|
|
83 | |
|
|
84 | /* knownminehaders */ |
87 | "Mime-Version:", "Content-Transfer-Encoding:", |
85 | LSTR ("Mime-Version"), LSTR ("Content-Transfer-Encoding"), |
88 | "Content-Type:", "Content-Disposition:", |
86 | LSTR ("Content-Type"), LSTR ("Content-Disposition"), |
89 | "Content-Description:", "Content-Length:", |
87 | LSTR ("Content-Description"), LSTR ("Content-Length") |
90 | NULL |
|
|
91 | }; |
88 | }; |
92 | |
89 | |
93 | /* |
90 | /* |
94 | * for MIME (plaintext) parts without filename |
91 | * for MIME (plaintext) parts without filename |
95 | */ |
92 | */ |
… | |
… | |
129 | |
126 | |
130 | /* |
127 | /* |
131 | * Macro: print cancellation message in UUScanPart |
128 | * Macro: print cancellation message in UUScanPart |
132 | */ |
129 | */ |
133 | |
130 | |
134 | #define SPCANCEL() {UUMessage(uuscan_id,__LINE__,UUMSG_NOTE,uustring(S_SCAN_CANCEL));*errcode=UURET_CANCEL;goto ScanPartEmergency;} |
131 | #define SPCANCEL() { UUMessage (UUMSG_NOTE, uustring(S_SCAN_CANCEL)); *errcode = UURET_CANCEL; goto ScanPartEmergency; } |
135 | |
132 | |
136 | /* |
133 | /* |
137 | * Is line empty? A line is empty if it is composed of whitespace. |
134 | * Is line empty? A line is empty if it is composed of whitespace. |
138 | */ |
135 | */ |
139 | |
136 | |
… | |
… | |
165 | * if the calling function just coincidentally noticed that this is |
162 | * if the calling function just coincidentally noticed that this is |
166 | * a header. |
163 | * a header. |
167 | * RFC0822 does not specify a maximum length for headers, but we |
164 | * RFC0822 does not specify a maximum length for headers, but we |
168 | * truncate everything beyond an insane value of 1024 characters. |
165 | * truncate everything beyond an insane value of 1024 characters. |
169 | */ |
166 | */ |
|
|
167 | /* (schmorp)every later rfc says 998 octets max */ |
170 | |
168 | |
171 | static char * |
169 | static char * |
172 | ScanHeaderLine (FILE *datei, char *initial) |
170 | ScanHeaderLine (FILE *datei, char *initial) |
173 | { |
171 | { |
174 | char *ptr=uuscan_shlline; |
172 | char *ptr=uuscan_shlline; |
175 | char *ptr2, *p1, *p2, *p3; |
173 | char *ptr2, *p2, *p3; |
176 | int llength, c; |
174 | int llength, c; |
177 | long curpos; |
175 | long curpos; |
178 | int hadcr; |
|
|
179 | |
176 | |
180 | if (initial) { |
177 | if (initial) { |
181 | _FP_strncpy (uuscan_shlline, initial, 1024); |
178 | FP_strncpy (uuscan_shlline, initial, 1024); |
182 | } |
|
|
183 | else { |
179 | } else { |
184 | /* read first line */ |
180 | /* read first line */ |
185 | if (feof (datei) || ferror (datei)) |
181 | if (FP_feof (datei) || ferror (datei)) |
186 | return NULL; |
182 | return NULL; |
187 | if (_FP_fgets (uuscan_shlline, 1023, datei) == NULL) |
183 | if (FP_fgets (uuscan_shlline, 1024, datei) == NULL) |
188 | return NULL; |
184 | return NULL; |
189 | uuscan_shlline[1023] = '\0'; |
|
|
190 | } |
185 | } |
191 | |
186 | |
192 | llength = strlen (uuscan_shlline); |
187 | llength = strlen (uuscan_shlline); |
193 | hadcr = 0; |
|
|
194 | |
188 | |
195 | /* strip whitespace at end */ |
189 | /* strip whitespace at end */ |
196 | ptr = uuscan_shlline + llength; |
190 | ptr = uuscan_shlline + llength; |
197 | while (llength && isspace(*(ptr-1))) { |
191 | while (llength && isspace(*(ptr-1))) { |
198 | if (*(ptr-1) == '\012' || *(ptr-1) == '\015') |
|
|
199 | hadcr = 1; |
|
|
200 | ptr--; llength--; |
192 | ptr--; llength--; |
201 | } |
193 | } |
202 | if (llength == 0) { |
194 | if (llength == 0) |
203 | uuscan_shlline[0] = '\0'; |
|
|
204 | return uuscan_shlline; |
195 | return uuscan_shlline; |
205 | } |
|
|
206 | |
196 | |
207 | while (!feof (datei)) { |
197 | while (!FP_feof (datei)) { |
208 | c = fgetc (datei); |
198 | c = FP_getc (datei); |
209 | if (feof (datei)) |
199 | if (c == EOF) |
210 | break; |
200 | break; |
211 | |
201 | |
212 | /* |
202 | if (c != ' ' && c != '\t') |
213 | * If the line didn't have a CR, it was longer than 256 characters |
203 | { |
214 | * and is continued anyway. |
|
|
215 | */ |
|
|
216 | |
|
|
217 | if (hadcr==1 && c != ' ' && c != '\t') { |
|
|
218 | /* no LWSP-char, header line does not continue */ |
|
|
219 | ungetc (c, datei); |
204 | ungetc (c, datei); |
220 | break; |
205 | break; |
221 | } |
206 | } |
|
|
207 | |
222 | while (!feof (datei) && (c == ' ' || c == '\t')) |
208 | while (!FP_feof (datei) && (c == ' ' || c == '\t')) |
223 | c = fgetc (datei); |
209 | c = FP_getc (datei); |
224 | |
210 | |
225 | if (!feof (datei)) |
211 | if (!FP_feof (datei)) |
226 | ungetc (c, datei); /* push back for fgets() */ |
212 | ungetc (c, datei); /* push back for fgets() */ |
227 | |
213 | else |
228 | /* insert a single LWSP */ |
|
|
229 | if (hadcr==1 && llength < 1023) { |
|
|
230 | *ptr++ = ' '; |
|
|
231 | llength++; |
|
|
232 | } |
|
|
233 | *ptr = '\0'; /* make lint happier */ |
|
|
234 | |
|
|
235 | if (feof (datei)) |
|
|
236 | break; |
214 | break; |
237 | |
215 | |
238 | /* read next line */ |
216 | /* read next line */ |
239 | curpos = ftell (datei); |
217 | curpos = ftell (datei); |
240 | if (_FP_fgets (uugen_inbuffer, 255, datei) == NULL) |
218 | if (FP_fgets (uugen_inbuffer, 1024, datei) == NULL) |
241 | break; |
219 | break; |
242 | uugen_inbuffer[255] = '\0'; |
|
|
243 | |
220 | |
244 | if (IsLineEmpty (uugen_inbuffer)) { /* oops */ |
221 | if (IsLineEmpty (uugen_inbuffer)) { /* oops */ |
245 | fseek (datei, curpos, SEEK_SET); |
222 | fseek (datei, curpos, SEEK_SET); |
246 | break; |
223 | break; |
247 | } |
224 | } |
248 | |
225 | |
249 | _FP_strncpy (ptr, uugen_inbuffer, 1024-llength); |
226 | FP_strncpy (ptr, uugen_inbuffer, 1024-llength); |
250 | |
227 | |
251 | /* |
|
|
252 | * see if line was terminated with CR. Otherwise, it continues ... |
|
|
253 | */ |
|
|
254 | c = strlen (ptr); |
228 | c = strlen (ptr); |
255 | if (c>0 && (ptr[c-1] == '\012' || ptr[c-1] == '\015')) |
|
|
256 | hadcr = 1; |
|
|
257 | else |
|
|
258 | hadcr = 0; |
|
|
259 | |
229 | |
260 | /* |
230 | /* |
261 | * strip whitespace |
231 | * strip whitespace |
262 | */ |
232 | */ |
263 | |
233 | |
… | |
… | |
285 | * Look for =? magic |
255 | * Look for =? magic |
286 | */ |
256 | */ |
287 | |
257 | |
288 | if (*ptr == '=' && *(ptr+1) == '?') { |
258 | if (*ptr == '=' && *(ptr+1) == '?') { |
289 | /* |
259 | /* |
290 | * Let p1 point to the charset, look for next question mark |
260 | * Let p2 point to the charset, look for next question mark |
291 | */ |
261 | */ |
292 | |
262 | |
293 | p1 = p2 = ptr+2; |
263 | p2 = ptr+2; |
294 | |
264 | |
295 | while (*p2 && *p2 != '?') { |
265 | while (*p2 && *p2 != '?') { |
296 | p2++; |
266 | p2++; |
297 | } |
267 | } |
298 | |
268 | |
… | |
… | |
367 | |
337 | |
368 | if (*attribute == '"') { |
338 | if (*attribute == '"') { |
369 | /* quoted-string */ |
339 | /* quoted-string */ |
370 | attribute++; |
340 | attribute++; |
371 | while (*attribute && *attribute != '"' && length < 255) { |
341 | while (*attribute && *attribute != '"' && length < 255) { |
|
|
342 | if (*attribute == '\\' |
|
|
343 | && (attribute[1] == '"' |
|
|
344 | || attribute[1] == '\015' |
|
|
345 | || attribute[1] == '\\')) |
|
|
346 | /* we dequote only the three characters that MUST be quoted, since |
|
|
347 | * microsoft is obviously unable to correctly implement even mime headers: |
|
|
348 | * filename="c:\xxx". *sigh* |
|
|
349 | */ |
|
|
350 | *ptr++ = *++attribute; |
|
|
351 | else |
372 | *ptr++ = *attribute++; |
352 | *ptr++ = *attribute; |
|
|
353 | attribute++; |
373 | length++; |
354 | length++; |
374 | } |
355 | } |
375 | *ptr = '\0'; |
356 | *ptr = '\0'; |
376 | } |
357 | } |
377 | else { |
358 | else { |
… | |
… | |
410 | { |
391 | { |
411 | char **variable=NULL; |
392 | char **variable=NULL; |
412 | char *value, *ptr, *thenew; |
393 | char *value, *ptr, *thenew; |
413 | int delimit, length; |
394 | int delimit, length; |
414 | |
395 | |
|
|
396 | value = 0; delimit = 0; /* calm down gcc */ |
|
|
397 | |
415 | if (line == NULL) |
398 | if (line == NULL) |
416 | return theheaders; |
399 | return theheaders; |
417 | |
400 | |
418 | if (_FP_strnicmp (line, "From:", 5) == 0) { |
401 | if (FP_strnicmp_fast (line, "From:", 5) == 0) { |
419 | if (theheaders->from) return theheaders; |
402 | if (theheaders->from) return theheaders; |
420 | variable = &theheaders->from; |
403 | variable = &theheaders->from; |
421 | value = line+5; |
404 | value = line+5; |
422 | delimit = 0; |
405 | delimit = 0; |
423 | } |
406 | } |
424 | else if (_FP_strnicmp (line, "Subject:", 8) == 0) { |
407 | else if (FP_strnicmp_fast (line, "Subject:", 8) == 0) { |
425 | if (theheaders->subject) return theheaders; |
408 | if (theheaders->subject) return theheaders; |
426 | variable = &theheaders->subject; |
409 | variable = &theheaders->subject; |
427 | value = line+8; |
410 | value = line+8; |
428 | delimit = 0; |
411 | delimit = 0; |
429 | } |
412 | } |
430 | else if (_FP_strnicmp (line, "To:", 3) == 0) { |
413 | else if (FP_strnicmp_fast (line, "To:", 3) == 0) { |
431 | if (theheaders->rcpt) return theheaders; |
414 | if (theheaders->rcpt) return theheaders; |
432 | variable = &theheaders->rcpt; |
415 | variable = &theheaders->rcpt; |
433 | value = line+3; |
416 | value = line+3; |
434 | delimit = 0; |
417 | delimit = 0; |
435 | } |
418 | } |
436 | else if (_FP_strnicmp (line, "Date:", 5) == 0) { |
419 | else if (FP_strnicmp_fast (line, "Date:", 5) == 0) { |
437 | if (theheaders->date) return theheaders; |
420 | if (theheaders->date) return theheaders; |
438 | variable = &theheaders->date; |
421 | variable = &theheaders->date; |
439 | value = line+5; |
422 | value = line+5; |
440 | delimit = 0; |
423 | delimit = 0; |
441 | } |
424 | } |
442 | else if (_FP_strnicmp (line, "Mime-Version:", 13) == 0) { |
425 | else if (FP_strnicmp_fast (line, "Mime-Version:", 13) == 0) { |
443 | if (theheaders->mimevers) return theheaders; |
426 | if (theheaders->mimevers) return theheaders; |
444 | variable = &theheaders->mimevers; |
427 | variable = &theheaders->mimevers; |
445 | value = line+13; |
428 | value = line+13; |
446 | delimit = 0; |
429 | delimit = 0; |
447 | } |
430 | } |
448 | else if (_FP_strnicmp (line, "Content-Type:", 13) == 0) { |
431 | else if (FP_strnicmp_fast (line, "Content-Type:", 13) == 0) { |
449 | if (theheaders->ctype) return theheaders; |
432 | if (theheaders->ctype) return theheaders; |
450 | variable = &theheaders->ctype; |
433 | variable = &theheaders->ctype; |
451 | value = line+13; |
434 | value = line+13; |
452 | delimit = ';'; |
435 | delimit = ';'; |
453 | |
436 | |
454 | /* we can probably extract more information */ |
437 | /* we can probably extract more information */ |
455 | if ((ptr = _FP_stristr (line, "boundary")) != NULL) { |
438 | if ((ptr = FP_stristr (line, "boundary")) != NULL) { |
456 | if ((thenew = ParseValue (ptr))) { |
439 | if ((thenew = ParseValue (ptr))) { |
457 | if (theheaders->boundary) free (theheaders->boundary); |
440 | if (theheaders->boundary) free (theheaders->boundary); |
458 | theheaders->boundary = _FP_strdup (thenew); |
441 | theheaders->boundary = FP_strdup (thenew); |
459 | } |
|
|
460 | } |
442 | } |
|
|
443 | } |
461 | if ((ptr = _FP_stristr (line, "name")) != NULL) { |
444 | if ((ptr = FP_stristr (line, "name")) != NULL) { |
462 | if ((thenew = ParseValue (ptr))) { |
445 | if ((thenew = ParseValue (ptr))) { |
463 | if (theheaders->fname) free (theheaders->fname); |
446 | if (theheaders->fname) free (theheaders->fname); |
464 | theheaders->fname = _FP_strdup (thenew); |
447 | theheaders->fname = FP_strdup (thenew); |
465 | } |
|
|
466 | } |
448 | } |
|
|
449 | } |
467 | if ((ptr = _FP_stristr (line, "id")) != NULL) { |
450 | if ((ptr = FP_stristr (line, "id")) != NULL) { |
468 | if ((thenew = ParseValue (ptr))) { |
451 | if ((thenew = ParseValue (ptr))) { |
469 | if (theheaders->mimeid) free (theheaders->mimeid); |
452 | if (theheaders->mimeid) free (theheaders->mimeid); |
470 | theheaders->mimeid = _FP_strdup (thenew); |
453 | theheaders->mimeid = FP_strdup (thenew); |
471 | } |
|
|
472 | } |
454 | } |
|
|
455 | } |
473 | if ((ptr = _FP_stristr (line, "number")) != NULL) { |
456 | if ((ptr = FP_stristr (line, "number")) != NULL) { |
474 | if ((thenew = ParseValue (ptr))) { |
457 | if ((thenew = ParseValue (ptr))) { |
475 | theheaders->partno = atoi (thenew); |
458 | theheaders->partno = atoi (thenew); |
476 | } |
459 | } |
477 | } |
460 | } |
478 | if ((ptr = _FP_stristr (line, "total")) != NULL) { |
461 | if ((ptr = FP_stristr (line, "total")) != NULL) { |
479 | if ((thenew = ParseValue (ptr))) { |
462 | if ((thenew = ParseValue (ptr))) { |
480 | theheaders->numparts = atoi (thenew); |
463 | theheaders->numparts = atoi (thenew); |
481 | } |
464 | } |
482 | } |
465 | } |
483 | } |
466 | } |
484 | else if (_FP_strnicmp (line, "Content-Transfer-Encoding:", 26) == 0) { |
467 | else if (FP_strnicmp_fast (line, "Content-Transfer-Encoding:", 26) == 0) { |
485 | if (theheaders->ctenc) return theheaders; |
468 | if (theheaders->ctenc) return theheaders; |
486 | variable = &theheaders->ctenc; |
469 | variable = &theheaders->ctenc; |
487 | value = line+26; |
470 | value = line+26; |
488 | delimit = ';'; |
471 | delimit = ';'; |
489 | } |
472 | } |
490 | else if (_FP_strnicmp (line, "Content-Disposition:", 20) == 0) { |
473 | else if (FP_strnicmp_fast (line, "Content-Disposition:", 20) == 0) { |
491 | /* |
474 | /* |
492 | * Some encoders mention the original filename as parameter to |
475 | * Some encoders mention the original filename as parameter to |
493 | * Content-Type, others as parameter to Content-Disposition. We |
476 | * Content-Type, others as parameter to Content-Disposition. We |
494 | * do prefer the first solution, but accept this situation, too. |
477 | * do prefer the first solution, but accept this situation, too. |
495 | * TODO: Read RFC1806 |
478 | * TODO: Read RFC1806 |
496 | */ |
479 | */ |
497 | if ((ptr = _FP_stristr (line, "name")) != NULL) { |
480 | if ((ptr = FP_stristr (line, "name")) != NULL) { |
498 | if (theheaders->fname == NULL && (thenew=ParseValue(ptr)) != NULL) { |
481 | if (theheaders->fname == NULL && (thenew=ParseValue(ptr)) != NULL) { |
499 | theheaders->fname = _FP_strdup (thenew); |
482 | theheaders->fname = FP_strdup (thenew); |
500 | } |
483 | } |
501 | } |
484 | } |
502 | variable = NULL; |
485 | variable = NULL; |
503 | } |
486 | } |
504 | else { |
487 | else { |
… | |
… | |
516 | ptr = uuscan_phtext; |
499 | ptr = uuscan_phtext; |
517 | |
500 | |
518 | while (isspace (*value)) |
501 | while (isspace (*value)) |
519 | value++; |
502 | value++; |
520 | while (*value && (delimit==0 || *value!=delimit) && |
503 | while (*value && (delimit==0 || *value!=delimit) && |
521 | *value != '\012' && *value != '\015' && length < 255) { |
504 | *value && length < 255) { |
522 | *ptr++ = *value++; |
505 | *ptr++ = *value++; |
523 | length++; |
506 | length++; |
524 | } |
507 | } |
525 | while (length && isspace(*(ptr-1))) { |
508 | while (length && isspace(*(ptr-1))) { |
526 | ptr--; length--; |
509 | ptr--; length--; |
527 | } |
510 | } |
528 | *ptr = '\0'; |
511 | *ptr = '\0'; |
529 | |
512 | |
530 | if ((*variable = _FP_strdup (uuscan_phtext)) == NULL) |
513 | if ((*variable = FP_strdup (uuscan_phtext)) == NULL) |
531 | return NULL; |
514 | return NULL; |
532 | } |
515 | } |
533 | |
516 | |
534 | return theheaders; |
517 | return theheaders; |
535 | } |
518 | } |
… | |
… | |
539 | */ |
522 | */ |
540 | |
523 | |
541 | static int |
524 | static int |
542 | IsKnownHeader (char *line) |
525 | IsKnownHeader (char *line) |
543 | { |
526 | { |
544 | char **iter = knownmsgheaders; |
527 | const char *sep; |
|
|
528 | int len, i; |
545 | |
529 | |
546 | while (iter && *iter) { |
530 | /* "From " handled specially */ |
547 | if (_FP_strnicmp (line, *iter, strlen (*iter)) == 0) |
531 | /* we assume the buffer is at least 5 bytes long */ |
|
|
532 | if (line [4] == ' ' && line [1] == 'r' && line [2] == 'o' && line [3] == 'm' |
|
|
533 | && (line [0] == 'f' || line [0] == 'F')) |
|
|
534 | return 1; |
|
|
535 | |
|
|
536 | sep = memchr (line, ':', MAX_KNOWNHEADERLEN); |
|
|
537 | |
|
|
538 | /* fast reject, the majority of calls are simple rejects */ |
|
|
539 | if (!sep) |
|
|
540 | return 0; |
|
|
541 | |
|
|
542 | len = sep - line; /* length of part before ':' */ |
|
|
543 | |
|
|
544 | for (i = 0; i < sizeof (knownheaders) / sizeof (knownheaders [0]); ++i) |
|
|
545 | if (len == knownheaders [i].len && FP_strnicmp_fast (line, knownheaders [i].str, len) == 0) |
548 | return 1; |
546 | return 1; |
549 | iter++; |
|
|
550 | } |
|
|
551 | |
|
|
552 | iter = knownmimeheaders; |
|
|
553 | |
|
|
554 | while (iter && *iter) { |
|
|
555 | if (_FP_strnicmp (line, *iter, strlen (*iter)) == 0) |
|
|
556 | return 2; |
|
|
557 | iter++; |
|
|
558 | } |
|
|
559 | |
547 | |
560 | return 0; |
548 | return 0; |
561 | } |
549 | } |
562 | |
550 | |
563 | /* |
551 | /* |
… | |
… | |
567 | int |
555 | int |
568 | UUScanHeader (FILE *datei, headers *envelope) |
556 | UUScanHeader (FILE *datei, headers *envelope) |
569 | { |
557 | { |
570 | char *ptr; |
558 | char *ptr; |
571 | |
559 | |
572 | while (!feof (datei)) { |
560 | while (!FP_feof (datei)) { |
573 | if ((ptr = ScanHeaderLine (datei, NULL)) == NULL) |
561 | if ((ptr = ScanHeaderLine (datei, NULL)) == NULL) |
574 | break; |
562 | break; |
575 | if (*ptr == '\0' || *ptr == '\012' || *ptr == '\015') |
563 | if (*ptr == '\0') |
576 | break; |
564 | break; |
577 | ParseHeader (envelope, ptr); |
565 | ParseHeader (envelope, ptr); |
578 | } |
566 | } |
579 | return 0; |
567 | return 0; |
580 | } |
568 | } |
… | |
… | |
590 | * 1 if we found a new header and 2 if we found a boundary. |
578 | * 1 if we found a new header and 2 if we found a boundary. |
591 | * In MIME message bodies (not multiparts), we also disable our reduced |
579 | * In MIME message bodies (not multiparts), we also disable our reduced |
592 | * MIME handling. |
580 | * MIME handling. |
593 | */ |
581 | */ |
594 | |
582 | |
595 | static int |
583 | ecb_hot static int |
596 | ScanData (FILE *datei, char *fname, int *errcode, |
584 | ScanData (FILE *datei, char *fname, int *errcode, |
597 | char *boundary, int ismime, int checkheaders, |
585 | char *boundary, int ismime, int checkheaders, |
598 | fileread *result) |
586 | fileread *result) |
599 | { |
587 | { |
600 | char *line=uuscan_sdline, *bhds1=uuscan_sdbhds1, *bhds2=uuscan_sdbhds2; |
588 | char *line=uuscan_sdline, *bhds1=uuscan_sdbhds1, *bhds2=uuscan_sdbhds2; |
… | |
… | |
604 | int bhflag=0, vflag, haddh=0, hadct=0; |
592 | int bhflag=0, vflag, haddh=0, hadct=0; |
605 | int bhrpc=0, bhnf=0, c, hcount, lcount, blen=0; |
593 | int bhrpc=0, bhnf=0, c, hcount, lcount, blen=0; |
606 | int encoding=0, dflag=0, ctline=42; |
594 | int encoding=0, dflag=0, ctline=42; |
607 | int dontcare=0, hadnl=0; |
595 | int dontcare=0, hadnl=0; |
608 | long preheaders=0, oldposition; |
596 | long preheaders=0, oldposition; |
609 | long yefilesize=0, yepartends=0; |
597 | long yepartends=0; |
610 | size_t dcc, bhopc; |
598 | size_t dcc, bhopc; |
611 | |
599 | |
612 | *errcode = UURET_OK; |
600 | *errcode = UURET_OK; |
613 | (void) UUDecodeLine (NULL, NULL, 0); /* init */ |
601 | (void) UUDecodeLine (NULL, NULL, 0); /* init */ |
614 | bhdsp = bhds2; |
602 | bhdsp = bhds2; |
615 | |
603 | |
616 | if (datei == NULL || feof (datei)) |
604 | if (datei == NULL || FP_feof (datei)) |
617 | return -1; |
605 | return -1; |
618 | |
606 | |
619 | result->startpos = ftell (datei); |
607 | result->startpos = ftell (datei); |
620 | hcount = lcount = 0; |
608 | hcount = lcount = 0; |
621 | |
609 | |
… | |
… | |
627 | iscnt = 0; |
615 | iscnt = 0; |
628 | |
616 | |
629 | if (boundary) |
617 | if (boundary) |
630 | blen = strlen (boundary); |
618 | blen = strlen (boundary); |
631 | |
619 | |
632 | while (!feof (datei)) { |
620 | while (!FP_feof (datei)) { |
633 | oldposition = ftell (datei); |
621 | oldposition = ftell (datei); |
634 | if (_FP_fgets (line, 255, datei) == NULL) |
622 | if (FP_fgets (line, 1024, datei) == NULL) |
635 | break; |
623 | break; |
636 | if (ferror (datei)) |
624 | if (ferror (datei)) |
637 | break; |
625 | break; |
638 | |
626 | |
639 | line[255] = '\0'; /* For Safety of string functions */ |
|
|
640 | |
|
|
641 | /* |
627 | /* |
642 | * Make Busy Polls |
628 | * Make Busy Polls |
643 | */ |
629 | */ |
644 | |
630 | |
645 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
631 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
646 | UUMessage (uuscan_id, __LINE__, UUMSG_NOTE, |
632 | UUMessage (UUMSG_NOTE, uustring (S_SCAN_CANCEL)); |
647 | uustring (S_SCAN_CANCEL)); |
|
|
648 | *errcode = UURET_CANCEL; |
633 | *errcode = UURET_CANCEL; |
649 | break; |
634 | break; |
650 | } |
635 | } |
651 | |
636 | |
652 | if (IsLineEmpty (line)) { /* line empty? */ |
637 | if (IsLineEmpty (line)) { /* line empty? */ |
… | |
… | |
697 | } |
682 | } |
698 | else { |
683 | else { |
699 | dontcare=0; |
684 | dontcare=0; |
700 | } |
685 | } |
701 | |
686 | |
702 | if (boundary != NULL && |
687 | if (boundary != NULL && |
703 | line[0] == '-' && line[1] == '-' && |
688 | line[0] == '-' && line[1] == '-' && |
704 | strncmp (line+2, boundary, blen) == 0) { |
689 | strncmp (line+2, boundary, blen) == 0) { |
705 | fseek (datei, oldposition, SEEK_SET); |
690 | fseek (datei, oldposition, SEEK_SET); |
706 | break; |
691 | break; |
707 | } |
692 | } |
708 | if (boundary != NULL && line[0] == 'C' && line[1] == 'o' && |
693 | if (boundary != NULL && line[0] == 'C' && line[1] == 'o' && |
709 | _FP_strnicmp (line, "Content-Type:", 13) == 0) { |
694 | FP_strnicmp_fast (line, "Content-Type:", 13) == 0) { |
710 | ptr = ScanHeaderLine (datei, line); |
695 | ptr = ScanHeaderLine (datei, line); |
711 | p2 = (ptr)?_FP_stristr(ptr,"boundary"):NULL; |
696 | p2 = (ptr)?FP_stristr(ptr,"boundary"):NULL; |
712 | p3 = (p2)?ParseValue(p2):NULL; |
697 | p3 = (p2)?ParseValue(p2):NULL; |
713 | |
698 | |
714 | if (p3 && strcmp (p3, boundary) == 0) { |
699 | if (p3 && strcmp (p3, boundary) == 0) { |
715 | fseek (datei, oldposition, SEEK_SET); |
700 | fseek (datei, oldposition, SEEK_SET); |
716 | break; |
701 | break; |
… | |
… | |
718 | else { |
703 | else { |
719 | p3 = NULL; |
704 | p3 = NULL; |
720 | } |
705 | } |
721 | } |
706 | } |
722 | |
707 | |
723 | if (strncmp (line, "begin ", 6) == 0 || |
708 | if (strncmp (line, "begin ", 6) == 0 || |
724 | _FP_strnicmp (line, "<pre>begin ", 11) == 0) { |
709 | FP_strnicmp_fast (line, "<pre>begin ", 11) == 0) { |
725 | if ((result->begin || result->end || |
710 | if ((result->begin || result->end || |
726 | result->uudet == B64ENCODED || |
711 | result->uudet == B64ENCODED || |
727 | result->uudet == BH_ENCODED) && !uu_more_mime) { |
712 | result->uudet == BH_ENCODED) && !uu_more_mime) { |
728 | fseek (datei, oldposition, SEEK_SET); |
713 | fseek (datei, oldposition, SEEK_SET); |
729 | break; |
714 | break; |
730 | } |
715 | } |
731 | |
716 | |
732 | if (*line == '<') |
717 | if (*line == '<') |
733 | ptr = line + 10; |
718 | ptr = line + 10; |
734 | else |
719 | else |
735 | ptr = line + 5; |
720 | ptr = line + 5; |
736 | |
721 | |
737 | while (*ptr == ' ') ptr++; |
722 | while (*ptr == ' ') ptr++; |
738 | while (isdigit (*ptr)) |
723 | while (isdigit (*ptr)) |
739 | result->mode = result->mode * 8 + *ptr++ - '0'; |
724 | result->mode = result->mode * 8 + *ptr++ - '0'; |
740 | while (*ptr == ' ') ptr++; |
725 | while (*ptr == ' ') ptr++; |
741 | |
726 | |
742 | /* |
727 | /* |
743 | * We may have picked up a filename from a uuenview-style header |
728 | * We may have picked up a filename from a uuenview-style header |
744 | */ |
729 | */ |
745 | _FP_free (result->filename); |
730 | FP_free (result->filename); |
746 | result->filename = _FP_strdup (ptr); |
731 | result->filename = FP_strdup (ptr); |
747 | result->begin = 1; |
732 | result->begin = 1; |
748 | |
733 | |
749 | while (isspace (result->filename[strlen(result->filename)-1])) |
734 | while (isspace (result->filename[strlen(result->filename)-1])) |
750 | result->filename[strlen(result->filename)-1] = '\0'; |
735 | result->filename[strlen(result->filename)-1] = '\0'; |
751 | |
736 | |
… | |
… | |
770 | |
755 | |
771 | /* |
756 | /* |
772 | * Detect a UUDeview-Style header |
757 | * Detect a UUDeview-Style header |
773 | */ |
758 | */ |
774 | |
759 | |
775 | if (_FP_strnicmp (line, "_=_ Part ", 9) == 0 && |
760 | if (FP_strnicmp_fast (line, "_=_ Part ", 9) == 0 && |
776 | result->uudet != YENC_ENCODED) { |
761 | result->uudet != YENC_ENCODED) { |
777 | if (result->uudet) { |
762 | if (result->uudet) { |
778 | fseek (datei, oldposition, SEEK_SET); |
763 | fseek (datei, oldposition, SEEK_SET); |
779 | break; |
764 | break; |
780 | } |
765 | } |
781 | result->partno = atoi (line + 8); |
766 | result->partno = atoi (line + 8); |
782 | if ((ptr = _FP_stristr (line, "of file ")) != NULL) { |
767 | if ((ptr = FP_stristr (line, "of file ")) != NULL) { |
783 | ptr += 8; |
768 | ptr += 8; |
784 | while (isspace (*ptr)) ptr++; |
769 | while (isspace (*ptr)) ptr++; |
785 | p2 = ptr; |
770 | p2 = ptr; |
786 | while (isalnum(*p2) || |
771 | while (isalnum(*p2) || |
787 | *p2 == '.' || *p2=='_' || *p2 == '-' || |
772 | *p2 == '.' || *p2=='_' || *p2 == '-' || |
788 | *p2 == '!' || *p2=='@' || *p2 == '$') |
773 | *p2 == '!' || *p2=='@' || *p2 == '$') |
789 | p2++; |
774 | p2++; |
790 | c = *p2; *p2 = '\0'; |
775 | c = *p2; *p2 = '\0'; |
791 | if (p2 != ptr && result->filename == NULL) |
776 | if (p2 != ptr && result->filename == NULL) |
792 | result->filename = _FP_strdup (ptr); |
777 | result->filename = FP_strdup (ptr); |
793 | else if (p2 - ptr > 5 && strchr (ptr, '.') != NULL) { |
778 | else if (p2 - ptr > 5 && strchr (ptr, '.') != NULL) { |
794 | /* |
779 | /* |
795 | * This file name looks good, too. Let's use it |
780 | * This file name looks good, too. Let's use it |
796 | */ |
781 | */ |
797 | _FP_free (result->filename); |
782 | FP_free (result->filename); |
798 | result->filename = _FP_strdup (ptr); |
783 | result->filename = FP_strdup (ptr); |
799 | } |
784 | } |
800 | *p2 = c; |
785 | *p2 = c; |
801 | } |
786 | } |
802 | } |
787 | } |
803 | |
788 | |
… | |
… | |
805 | * Some reduced MIME handling. Only use if boundary == NULL. Also |
790 | * Some reduced MIME handling. Only use if boundary == NULL. Also |
806 | * accept the "X-Orcl-Content-Type" used by some braindead program. |
791 | * accept the "X-Orcl-Content-Type" used by some braindead program. |
807 | */ |
792 | */ |
808 | if (boundary == NULL && !ismime && !uu_more_mime && |
793 | if (boundary == NULL && !ismime && !uu_more_mime && |
809 | result->uudet != YENC_ENCODED) { |
794 | result->uudet != YENC_ENCODED) { |
810 | if (_FP_strnicmp (line, "Content-Type", 12) == 0 || |
795 | if (FP_strnicmp_fast (line, "Content-Type", 12) == 0 || |
811 | _FP_strnicmp (line, "X-Orcl-Content-Type", 19) == 0) { |
796 | FP_strnicmp_fast (line, "X-Orcl-Content-Type", 19) == 0) { |
812 | /* |
797 | /* |
813 | * We use Content-Type to mark a new attachment and split the file. |
798 | * We use Content-Type to mark a new attachment and split the file. |
814 | * However, we do not split if we haven't found anything encoded yet. |
799 | * However, we do not split if we haven't found anything encoded yet. |
815 | */ |
800 | */ |
816 | if (result->uudet) { |
801 | if (result->uudet) { |
817 | fseek (datei, oldposition, SEEK_SET); |
802 | fseek (datei, oldposition, SEEK_SET); |
818 | break; |
803 | break; |
819 | } |
804 | } |
820 | if ((ptr = strchr (line, ':')) != NULL) { |
805 | if ((ptr = strchr (line, ':')) != NULL) { |
821 | ptr++; |
806 | ptr++; |
822 | while (isspace (*ptr)) ptr++; p2 = ptr; |
807 | while (isspace (*ptr)) ptr++; |
|
|
808 | p2 = ptr; |
823 | while (!isspace (*p2) && *p2 != ';') p2++; |
809 | while (*p2 && !isspace (*p2) && *p2 != ';') p2++; |
824 | c = *p2; *p2 = '\0'; |
810 | c = *p2; *p2 = '\0'; |
825 | if (p2 != ptr) { |
811 | if (p2 != ptr) { |
826 | _FP_free (result->mimetype); |
812 | FP_free (result->mimetype); |
827 | result->mimetype = _FP_strdup (ptr); |
813 | result->mimetype = FP_strdup (ptr); |
828 | } |
814 | } |
829 | *p2 = c; |
815 | *p2 = c; |
830 | } |
816 | } |
831 | ctline=0; |
817 | ctline=0; |
832 | hadct=1; |
818 | hadct=1; |
833 | } |
819 | } |
834 | if ((ptr = _FP_stristr (line, "number=")) && ctline<4) { |
820 | if ((ptr = FP_stristr (line, "number=")) && ctline<4) { |
835 | ptr += 7; if (*ptr == '"') ptr++; |
821 | ptr += 7; if (*ptr == '"') ptr++; |
836 | result->partno = atoi (ptr); |
822 | result->partno = atoi (ptr); |
837 | } |
823 | } |
838 | if ((ptr = _FP_stristr (line, "total=")) && ctline<4) { |
824 | if ((ptr = FP_stristr (line, "total=")) && ctline<4) { |
839 | ptr += 6; if (*ptr == '"') ptr++; |
825 | ptr += 6; if (*ptr == '"') ptr++; |
840 | result->maxpno = atoi (ptr); |
826 | result->maxpno = atoi (ptr); |
841 | } |
827 | } |
842 | if ((ptr = _FP_stristr (line, "name=")) && ctline<4) { |
828 | if ((ptr = FP_stristr (line, "name=")) && ctline<4) { |
843 | ptr += 5; |
829 | ptr += 5; |
844 | while (isspace (*ptr)) ptr++; |
830 | while (isspace (*ptr)) ptr++; |
845 | if (*ptr == '"' && *(ptr+1) && (p2 = strchr (ptr+2, '"')) != NULL) { |
831 | if (*ptr == '"' && *(ptr+1) && (p2 = strchr (ptr+2, '"')) != NULL) { |
846 | c = *p2; *p2 = '\0'; |
832 | c = *p2; *p2 = '\0'; |
847 | _FP_free (result->filename); |
833 | FP_free (result->filename); |
848 | result->filename = _FP_strdup (ptr+1); |
834 | result->filename = FP_strdup (ptr+1); |
849 | *p2 = c; |
835 | *p2 = c; |
850 | } |
836 | } |
851 | else if (*ptr=='\''&&*(ptr+1)&&(p2 = strchr(ptr+2, '\'')) != NULL) { |
837 | else if (*ptr=='\''&&*(ptr+1)&&(p2 = strchr(ptr+2, '\'')) != NULL) { |
852 | c = *p2; *p2 = '\0'; |
838 | c = *p2; *p2 = '\0'; |
853 | _FP_free (result->filename); |
839 | FP_free (result->filename); |
854 | result->filename = _FP_strdup (ptr+1); |
840 | result->filename = FP_strdup (ptr+1); |
855 | *p2 = c; |
841 | *p2 = c; |
856 | } |
842 | } |
857 | else { |
843 | else { |
858 | p2 = ptr; |
844 | p2 = ptr; |
859 | while (isalnum(*p2) || |
845 | while (isalnum(*p2) || |
860 | *p2 == '.' || *p2=='_' || *p2 == '-' || |
846 | *p2 == '.' || *p2=='_' || *p2 == '-' || |
861 | *p2 == '!' || *p2=='@' || *p2 == '$') |
847 | *p2 == '!' || *p2=='@' || *p2 == '$') |
862 | p2++; |
848 | p2++; |
863 | c = *p2; *p2 = '\0'; |
849 | c = *p2; *p2 = '\0'; |
864 | if (p2 != ptr && result->filename == NULL) |
850 | if (p2 != ptr && result->filename == NULL) |
865 | result->filename = _FP_strdup (ptr); |
851 | result->filename = FP_strdup (ptr); |
866 | else if (p2 - ptr > 5 && strchr (ptr, '.') != NULL) { |
852 | else if (p2 - ptr > 5 && strchr (ptr, '.') != NULL) { |
867 | /* |
853 | /* |
868 | * This file name looks good, too. Let's use it |
854 | * This file name looks good, too. Let's use it |
869 | */ |
855 | */ |
870 | _FP_free (result->filename); |
856 | FP_free (result->filename); |
871 | result->filename = _FP_strdup (ptr); |
857 | result->filename = FP_strdup (ptr); |
872 | } |
858 | } |
873 | *p2 = c; |
859 | *p2 = c; |
874 | } |
860 | } |
875 | } |
861 | } |
876 | if ((ptr = _FP_stristr (line, "id=")) && ctline<4) { |
862 | if ((ptr = FP_stristr (line, "id=")) && ctline<4) { |
877 | p2 = ptr += 3; |
863 | p2 = ptr += 3; |
878 | if (*p2 == '"') { |
864 | if (*p2 == '"') { |
879 | p2 = strchr (++ptr, '"'); |
865 | p2 = strchr (++ptr, '"'); |
880 | } |
866 | } |
881 | else { |
867 | else { |
… | |
… | |
883 | p2++; |
869 | p2++; |
884 | } |
870 | } |
885 | if (p2 && *p2 && p2!=ptr) { |
871 | if (p2 && *p2 && p2!=ptr) { |
886 | c = *p2; *p2 = '\0'; |
872 | c = *p2; *p2 = '\0'; |
887 | if (result->mimeid) |
873 | if (result->mimeid) |
888 | _FP_free (result->mimeid); |
874 | FP_free (result->mimeid); |
889 | result->mimeid = _FP_strdup (ptr); |
875 | result->mimeid = FP_strdup (ptr); |
890 | *p2 = c; |
876 | *p2 = c; |
891 | } |
877 | } |
892 | } |
878 | } |
893 | |
879 | |
894 | /* |
880 | /* |
895 | * Handling for very short Base64 files. |
881 | * Handling for very short Base64 files. |
896 | */ |
882 | */ |
897 | if (uu_tinyb64 && !ismime && !uu_more_mime) { |
883 | if (uu_tinyb64 && !ismime && !uu_more_mime) { |
898 | if (line[0] == '-' && line[1] == '-') { |
884 | if (line[0] == '-' && line[1] == '-') { |
899 | if (dflag && (encoding==B64ENCODED || result->uudet==B64ENCODED)) { |
885 | if (dflag && (encoding==B64ENCODED || result->uudet==B64ENCODED)) { |
… | |
… | |
915 | * a boundary, followed by a Content-* line, try to use it. |
901 | * a boundary, followed by a Content-* line, try to use it. |
916 | */ |
902 | */ |
917 | |
903 | |
918 | if (boundary == NULL && !ismime && !uu_more_mime && dflag <= 1 && |
904 | if (boundary == NULL && !ismime && !uu_more_mime && dflag <= 1 && |
919 | line[0] == '-' && line[1] == '-' && strlen(line+2)>10 && |
905 | line[0] == '-' && line[1] == '-' && strlen(line+2)>10 && |
920 | (((ptr = _FP_strrstr (line+2, "--")) == NULL) || |
906 | (((ptr = FP_strrstr (line+2, "--")) == NULL) || |
921 | (*(ptr+2) != '\012' && *(ptr+2) != '\015')) && |
907 | ptr[2]) && |
922 | _FP_strstr (line+2, "_=_") != NULL) { |
908 | FP_strstr (line+2, "_=_") != NULL) { |
|
|
909 | |
|
|
910 | long oldposition = ftell (datei); /* refresh oldpositition so the comment below becomes true */ |
|
|
911 | |
923 | if (_FP_fgets (line, 255, datei) == NULL) { |
912 | if (FP_fgets (line, 1024, datei) == NULL) { |
924 | break; |
913 | break; |
925 | } |
914 | } |
926 | if (_FP_strnicmp (line, "Content-", 8) == 0) { |
915 | if (FP_strnicmp_fast (line, "Content-", 8) == 0) { |
927 | /* |
916 | /* |
928 | * Okay, let's do it. This breaks out of ScanData. ScanPart will |
917 | * Okay, let's do it. This breaks out of ScanData. ScanPart will |
929 | * recognize the boundary on the next call and use it. |
918 | * recognize the boundary on the next call and use it. |
930 | */ |
919 | */ |
931 | fseek (datei, oldposition, SEEK_SET); |
920 | fseek (datei, oldposition, SEEK_SET); |
… | |
… | |
936 | /* |
925 | /* |
937 | * Detection for yEnc encoding |
926 | * Detection for yEnc encoding |
938 | */ |
927 | */ |
939 | |
928 | |
940 | if (strncmp (line, "=ybegin ", 8) == 0 && |
929 | if (strncmp (line, "=ybegin ", 8) == 0 && |
941 | _FP_strstr (line, " name=") != NULL) { |
930 | FP_strstr (line, " name=") != NULL) { |
942 | if ((result->begin || result->end || result->uudet) && !uu_more_mime) { |
931 | if ((result->begin || result->end || result->uudet) && !uu_more_mime) { |
943 | fseek (datei, oldposition, SEEK_SET); |
932 | fseek (datei, oldposition, SEEK_SET); |
944 | break; |
933 | break; |
945 | } |
934 | } |
946 | |
935 | |
947 | /* |
936 | /* |
948 | * name continues to the end of the line |
937 | * name continues to the end of the line |
949 | */ |
938 | */ |
950 | |
939 | |
951 | _FP_free (result->filename); |
|
|
952 | ptr = _FP_strstr (line, " name=") + 6; |
940 | ptr = FP_strstr (line, " name=") + 6; |
|
|
941 | |
|
|
942 | /* newsbin pro 5.0 (at least) is braindamaged enough to put (null) here */ |
|
|
943 | /* create something sensible, trust a windows program to fuck it up */ |
|
|
944 | if (strncmp (ptr, "(null)", 6)) |
|
|
945 | { |
|
|
946 | FP_free (result->filename); |
953 | result->filename = _FP_strdup (ptr); |
947 | result->filename = FP_strdup (ptr); |
954 | |
948 | |
955 | while (isspace (result->filename[strlen(result->filename)-1])) |
949 | while (isspace (result->filename[strlen(result->filename)-1])) |
956 | result->filename[strlen(result->filename)-1] = '\0'; |
950 | result->filename[strlen(result->filename)-1] = '\0'; |
|
|
951 | } |
957 | |
952 | |
958 | /* |
953 | /* |
959 | * Determine size |
954 | * Determine size |
960 | */ |
955 | */ |
961 | |
956 | |
962 | if ((ptr = _FP_strstr (line, " size=")) != NULL) { |
957 | if ((ptr = FP_strstr (line, " size=")) != NULL) { |
963 | ptr += 6; |
958 | ptr += 6; |
964 | yefilesize = atoi (ptr); |
959 | result->yefilesize = atol (ptr); |
965 | } |
960 | } |
966 | else { |
961 | else { |
967 | yefilesize = -1; |
962 | result->yefilesize = -1; |
968 | } |
963 | } |
969 | |
964 | |
970 | /* |
965 | /* |
971 | * check for multipart file and read =ypart line |
966 | * check for multipart file and read =ypart line |
972 | */ |
967 | */ |
973 | |
968 | |
974 | if ((ptr = _FP_strstr (line, " part=")) != NULL) { |
969 | if ((ptr = FP_strstr (line, " part=")) != NULL) { |
975 | result->partno = atoi (ptr + 6); |
970 | result->partno = atoi (ptr + 6); |
976 | |
971 | |
977 | if (result->partno == 1) { |
972 | if (result->partno == 1) { |
978 | result->begin = 1; |
973 | result->begin = 1; |
979 | } |
974 | } |
980 | |
975 | |
|
|
976 | if ((ptr = FP_strstr (line, " total="))) |
|
|
977 | result->maxpno = atoi (ptr + 7); |
|
|
978 | |
981 | if (_FP_fgets (line, 255, datei) == NULL) { |
979 | if (FP_fgets (line, 1024, datei) == NULL) { |
982 | break; |
980 | break; |
983 | } |
981 | } |
984 | |
|
|
985 | line[255] = '\0'; |
|
|
986 | |
982 | |
987 | if (strncmp (line, "=ypart ", 7) != 0) { |
983 | if (strncmp (line, "=ypart ", 7) != 0) { |
988 | break; |
984 | break; |
989 | } |
985 | } |
990 | |
986 | |
991 | if ((ptr = _FP_strstr (line, " end=")) == NULL) { |
987 | if ((ptr = FP_strstr (line, " end=")) == NULL) { |
992 | break; |
988 | break; |
993 | } |
989 | } |
994 | |
990 | |
995 | yepartends = atoi (ptr + 5); |
991 | yepartends = atol (ptr + 5); |
996 | } |
992 | } |
997 | else { |
993 | else { |
998 | result->partno = 1; |
994 | result->partno = 1; |
999 | result->begin = 1; |
995 | result->begin = 1; |
1000 | } |
996 | } |
… | |
… | |
1005 | |
1001 | |
1006 | result->uudet = YENC_ENCODED; |
1002 | result->uudet = YENC_ENCODED; |
1007 | continue; |
1003 | continue; |
1008 | } |
1004 | } |
1009 | |
1005 | |
1010 | if (strncmp (line, "=yend ", 6) == 0 && |
1006 | if (strncmp (line, "=yend ", 6) == 0 && result->uudet == YENC_ENCODED) { |
1011 | result->uudet == YENC_ENCODED) { |
1007 | if (yepartends == 0) { |
1012 | if (yepartends == 0 || yepartends >= yefilesize) { |
1008 | if (!result->maxpno || result->maxpno == result->partno) |
|
|
1009 | result->end = 1; |
|
|
1010 | } else if (yepartends >= result->yefilesize) { |
1013 | result->end = 1; |
1011 | result->end = 1; |
1014 | } |
1012 | } |
1015 | #if 0 |
1013 | #if 0 |
1016 | if (!uu_more_mime) |
1014 | if (!uu_more_mime) |
1017 | break; |
1015 | break; |
… | |
… | |
1089 | * data bytes. We try to extract it here |
1087 | * data bytes. We try to extract it here |
1090 | */ |
1088 | */ |
1091 | if (vflag == BH_ENCODED && bhnf == 0 && result->filename == NULL) { |
1089 | if (vflag == BH_ENCODED && bhnf == 0 && result->filename == NULL) { |
1092 | if (bhdsp == bhds2 || |
1090 | if (bhdsp == bhds2 || |
1093 | ((bhdsp-bhds2) <= (int) bhds2[0] && |
1091 | ((bhdsp-bhds2) <= (int) bhds2[0] && |
1094 | (bhdsp-bhds2) < 256)) { |
1092 | (bhdsp-bhds2) < 256)) { |
1095 | dcc = UUDecodeLine (line, bhds1, BH_ENCODED); |
1093 | dcc = UUDecodeLine (line, bhds1, BH_ENCODED); |
1096 | UUbhdecomp (bhds1, bhdsp, &bhl, &bhrpc, |
1094 | UUbhdecomp (bhds1, bhdsp, &bhl, &bhrpc, |
1097 | dcc, 256-(bhdsp-bhds2), &bhopc); |
1095 | dcc, 256-(bhdsp-bhds2), &bhopc); |
1098 | bhdsp += bhopc; |
1096 | bhdsp += bhopc; |
1099 | } |
1097 | } |
1100 | if ((bhdsp-bhds2) > (int) bhds2[0] && bhds2[0]>0 && |
1098 | if ((bhdsp-bhds2) > (int) bhds2[0] && bhds2[0]>0 && |
1101 | result->filename==NULL) { |
1099 | result->filename==NULL) { |
1102 | memcpy (bhds1, bhds2+1, (int) bhds2[0]); |
1100 | memcpy (bhds1, bhds2+1, (int) bhds2[0]); |
1103 | bhds1[(int)bhds2[0]]='\0'; |
1101 | bhds1[(int)bhds2[0]]='\0'; |
1104 | result->filename = _FP_strdup (bhds1); |
1102 | result->filename = FP_strdup (bhds1); |
1105 | bhnf = 1; |
1103 | bhnf = 1; |
1106 | } |
1104 | } |
1107 | else if (bhdsp-bhds2 >= 256 && bhds2[0]>0) { |
1105 | else if (bhdsp-bhds2 >= 256 && bhds2[0]>0) { |
1108 | memcpy (bhds1, bhds2+1, 255); |
1106 | memcpy (bhds1, bhds2+1, 255); |
1109 | bhds1[255] = '\0'; |
1107 | bhds1[255] = '\0'; |
1110 | result->filename = _FP_strdup (bhds1); |
1108 | result->filename = FP_strdup (bhds1); |
1111 | bhnf = 1; |
1109 | bhnf = 1; |
1112 | } |
1110 | } |
1113 | else if (bhds2[0] <= 0) |
1111 | else if (bhds2[0] <= 0) |
1114 | bhnf = 1; |
1112 | bhnf = 1; |
1115 | } |
1113 | } |
… | |
… | |
1184 | * an "end" |
1182 | * an "end" |
1185 | */ |
1183 | */ |
1186 | |
1184 | |
1187 | hcount = lcount = 0; |
1185 | hcount = lcount = 0; |
1188 | |
1186 | |
1189 | while (!feof (datei)) { |
1187 | while (!FP_feof (datei)) { |
1190 | /* |
1188 | /* |
1191 | * Make Busy Polls |
1189 | * Make Busy Polls |
1192 | */ |
1190 | */ |
1193 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
1191 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
1194 | UUMessage (uuscan_id, __LINE__, UUMSG_NOTE, |
1192 | UUMessage (UUMSG_NOTE, uustring (S_SCAN_CANCEL)); |
1195 | uustring (S_SCAN_CANCEL)); |
|
|
1196 | *errcode = UURET_CANCEL; |
1193 | *errcode = UURET_CANCEL; |
1197 | break; |
1194 | break; |
1198 | } |
1195 | } |
1199 | |
1196 | |
1200 | oldposition = ftell (datei); |
1197 | oldposition = ftell (datei); |
1201 | if (_FP_fgets (line, 255, datei) == NULL) |
1198 | if (FP_fgets (line, 1024, datei) == NULL) |
1202 | break; |
1199 | break; |
1203 | if (ferror (datei)) |
1200 | if (ferror (datei)) |
1204 | break; |
1201 | break; |
1205 | |
|
|
1206 | line[255] = '\0'; |
|
|
1207 | |
1202 | |
1208 | /* |
1203 | /* |
1209 | * Stop scanning at an empty line or a MIME-boundary. |
1204 | * Stop scanning at an empty line or a MIME-boundary. |
1210 | */ |
1205 | */ |
1211 | if (IsLineEmpty (line)) |
1206 | if (IsLineEmpty (line)) |
… | |
… | |
1285 | * in the outer loop |
1280 | * in the outer loop |
1286 | */ |
1281 | */ |
1287 | |
1282 | |
1288 | continue; |
1283 | continue; |
1289 | } |
1284 | } |
1290 | |
1285 | |
1291 | /* |
1286 | /* |
1292 | * Select the encoding with the best "history" |
1287 | * Select the encoding with the best "history" |
1293 | */ |
1288 | */ |
1294 | |
1289 | |
1295 | cbb64 = isb64[(iscnt-1)%10]; |
1290 | cbb64 = isb64[(iscnt-1)%10]; |
… | |
… | |
1364 | } |
1359 | } |
1365 | } /* if (!uudet) */ |
1360 | } /* if (!uudet) */ |
1366 | /* |
1361 | /* |
1367 | * End of scanning loop |
1362 | * End of scanning loop |
1368 | */ |
1363 | */ |
1369 | } /* while (!feof (datei)) */ |
1364 | } /* while (!FP_feof (datei)) */ |
1370 | |
1365 | |
1371 | if (feof (datei)) |
1366 | if (FP_feof (datei)) |
1372 | oldposition = ftell (datei); |
1367 | oldposition = ftell (datei); |
1373 | |
1368 | |
1374 | if (dflag && encoding == B64ENCODED && haddh) |
1369 | if (dflag && encoding == B64ENCODED && haddh) |
1375 | result->uudet = B64ENCODED; |
1370 | result->uudet = B64ENCODED; |
1376 | else if (dflag && encoding == BH_ENCODED) |
1371 | else if (dflag && encoding == BH_ENCODED) |
… | |
… | |
1435 | if (boundary && line[0] == '-' && line[1] == '-' && |
1430 | if (boundary && line[0] == '-' && line[1] == '-' && |
1436 | strncmp (line+2, boundary, blen) == 0) |
1431 | strncmp (line+2, boundary, blen) == 0) |
1437 | return 2; |
1432 | return 2; |
1438 | else if (boundary && p3 && |
1433 | else if (boundary && p3 && |
1439 | line[0] == 'C' && line[1] == 'o' && |
1434 | line[0] == 'C' && line[1] == 'o' && |
1440 | _FP_strnicmp (line, "Content-Type:", 13) == 0 && |
1435 | FP_strnicmp_fast (line, "Content-Type:", 13) == 0 && |
1441 | strcmp (p3, boundary) == 0) |
1436 | strcmp (p3, boundary) == 0) |
1442 | return 2; |
1437 | return 2; |
1443 | else if (IsKnownHeader (line)) |
1438 | else if (IsKnownHeader (line)) |
1444 | return 1; |
1439 | return 1; |
1445 | |
1440 | |
… | |
… | |
1449 | /* |
1444 | /* |
1450 | * This is the main scanning function. |
1445 | * This is the main scanning function. |
1451 | */ |
1446 | */ |
1452 | |
1447 | |
1453 | fileread * |
1448 | fileread * |
1454 | ScanPart (FILE *datei, char *fname, int *errcode) |
1449 | UUScanPart (FILE *datei, char *fname, int *errcode) |
1455 | { |
1450 | { |
1456 | int ecount, hcount, lcount; |
1451 | int ecount, hcount, lcount; |
1457 | int bhflag, begflag, vflag, blen=0, res; |
1452 | int bhflag, begflag, vflag, blen=0, res; |
1458 | long preheaders, prevpos=0, preenc, before; |
1453 | long preheaders, prevpos=0, preenc, before; |
1459 | char *line=uuscan_spline; |
1454 | char *line=uuscan_spline; |
1460 | fileread *result; |
1455 | fileread *result; |
1461 | char *ptr1, *ptr2; |
1456 | char *ptr1, *ptr2; |
1462 | |
1457 | |
1463 | (void) UUDecodeLine (NULL, NULL, 0); /* init */ |
1458 | (void) UUDecodeLine (NULL, NULL, 0); /* init */ |
1464 | if (datei == NULL || feof (datei)) { |
1459 | if (datei == NULL || FP_feof (datei)) { |
1465 | *errcode = UURET_OK; |
1460 | *errcode = UURET_OK; |
1466 | return NULL; |
1461 | return NULL; |
1467 | } |
1462 | } |
1468 | |
1463 | |
1469 | *errcode = UURET_OK; |
1464 | *errcode = UURET_OK; |
… | |
… | |
1485 | /* mimseqno = 1; */ |
1480 | /* mimseqno = 1; */ |
1486 | |
1481 | |
1487 | while (mssdepth) { |
1482 | while (mssdepth) { |
1488 | mssdepth--; |
1483 | mssdepth--; |
1489 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1484 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1490 | _FP_free (multistack[mssdepth].source); |
1485 | FP_free (multistack[mssdepth].source); |
1491 | } |
1486 | } |
1492 | |
1487 | |
1493 | UUkillheaders (&sstate.envelope); |
1488 | UUkillheaders (&sstate.envelope); |
1494 | memset (&sstate.envelope, 0, sizeof (headers)); |
1489 | memset (&sstate.envelope, 0, sizeof (headers)); |
1495 | |
1490 | |
1496 | _FP_free (sstate.source); |
1491 | FP_free (sstate.source); |
1497 | if ((sstate.source = _FP_strdup (fname)) == NULL) { |
1492 | if ((sstate.source = FP_strdup (fname)) == NULL) { |
1498 | *errcode = UURET_NOMEM; |
1493 | *errcode = UURET_NOMEM; |
1499 | _FP_free (result); |
1494 | FP_free (result); |
1500 | return NULL; |
1495 | return NULL; |
1501 | } |
1496 | } |
1502 | |
1497 | |
1503 | /* ignore empty lines at the beginning of a file */ |
1498 | /* ignore empty lines at the beginning of a file */ |
1504 | preheaders = ftell (datei); |
1499 | preheaders = ftell (datei); |
1505 | while (!feof (datei)) { |
1500 | while (!FP_feof (datei)) { |
1506 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1501 | if (UUBUSYPOLL(preheaders,progress.fsize)) SPCANCEL(); |
1507 | if (_FP_fgets (line, 255, datei) == NULL) |
1502 | if (FP_fgets (line, 1024, datei) == NULL) |
1508 | break; |
1503 | break; |
1509 | line[255] = '\0'; |
|
|
1510 | if (!IsLineEmpty (line)) { |
1504 | if (!IsLineEmpty (line)) { |
1511 | fseek (datei, preheaders, SEEK_SET); |
1505 | fseek (datei, preheaders, SEEK_SET); |
1512 | break; |
1506 | break; |
1513 | } |
1507 | } |
1514 | preheaders = ftell (datei); |
1508 | preheaders = ftell (datei); |
1515 | } |
1509 | } |
1516 | } |
1510 | } |
1517 | |
1511 | |
1518 | if (ferror(datei) || feof(datei)) { |
1512 | if (ferror(datei) || FP_feof(datei)) { |
1519 | _FP_free (result); |
1513 | FP_free (result); |
1520 | return NULL; |
1514 | return NULL; |
1521 | } |
1515 | } |
1522 | |
1516 | |
1523 | /* |
1517 | /* |
1524 | * If we are confident that this is a mail folder and are at the |
1518 | * If we are confident that this is a mail folder and are at the |
… | |
… | |
1536 | */ |
1530 | */ |
1537 | |
1531 | |
1538 | while (mssdepth) { |
1532 | while (mssdepth) { |
1539 | mssdepth--; |
1533 | mssdepth--; |
1540 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1534 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1541 | _FP_free (multistack[mssdepth].source); |
1535 | FP_free (multistack[mssdepth].source); |
1542 | } |
1536 | } |
1543 | |
1537 | |
1544 | prevpos = ftell (datei); |
1538 | prevpos = ftell (datei); |
1545 | if (_FP_fgets (line, 255, datei) == NULL) { |
1539 | if (FP_fgets (line, 1024, datei) == NULL) { |
1546 | _FP_free (result); |
1540 | FP_free (result); |
1547 | return NULL; |
1541 | return NULL; |
1548 | } |
1542 | } |
1549 | line[255] = '\0'; |
|
|
1550 | |
1543 | |
1551 | /* |
1544 | /* |
1552 | * Special handling for AOL folder files, which start off with a boundary. |
1545 | * Special handling for AOL folder files, which start off with a boundary. |
1553 | * We recognize them by a valid boundary line as the first line of a file. |
1546 | * We recognize them by a valid boundary line as the first line of a file. |
1554 | * Note that the rest of the scanning code becomes suspicious if a boun- |
1547 | * Note that the rest of the scanning code becomes suspicious if a boun- |
1555 | * dary does never appear in a file -- this should save us from grave |
1548 | * dary does never appear in a file -- this should save us from grave |
1556 | * false detection errors |
1549 | * false detection errors |
1557 | */ |
1550 | */ |
1558 | |
1551 | |
1559 | if (!feof (datei) && line[0] == '-' && line[1] == '-' && line[2]) { |
1552 | if (!FP_feof (datei) && line[0] == '-' && line[1] == '-' && line[2]) { |
1560 | while (line[strlen(line)-1] == '\012' || |
|
|
1561 | line[strlen(line)-1] == '\015') { |
|
|
1562 | line[strlen(line)-1] = '\0'; |
|
|
1563 | } |
|
|
1564 | |
|
|
1565 | sstate.ismime = 1; |
1553 | sstate.ismime = 1; |
1566 | sstate.envelope.mimevers = _FP_strdup ("1.0"); |
1554 | sstate.envelope.mimevers = FP_strdup ("1.0"); |
1567 | sstate.envelope.boundary = _FP_strdup (line+2); |
1555 | sstate.envelope.boundary = FP_strdup (line+2); |
1568 | sstate.envelope.ctype = _FP_strdup ("multipart/mixed"); |
1556 | sstate.envelope.ctype = FP_strdup ("multipart/mixed"); |
1569 | sstate.mimestate = MS_SUBPART; |
1557 | sstate.mimestate = MS_SUBPART; |
1570 | |
1558 | |
1571 | *errcode = UURET_CONT; |
1559 | *errcode = UURET_CONT; |
1572 | _FP_free (result); |
1560 | FP_free (result); |
1573 | return NULL; |
1561 | return NULL; |
1574 | } |
1562 | } |
1575 | |
1563 | |
1576 | /* |
1564 | /* |
1577 | * Normal behavior: look for a RFC 822 header |
1565 | * Normal behavior: look for a RFC 822 header |
1578 | */ |
1566 | */ |
1579 | |
1567 | |
1580 | while (!feof (datei) && !IsLineEmpty (line)) { |
1568 | while (!FP_feof (datei) && !IsLineEmpty (line)) { |
1581 | if (IsKnownHeader (line)) |
1569 | if (IsKnownHeader (line)) |
1582 | hcount++; |
1570 | hcount++; |
1583 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1571 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1584 | if (IsHeaderLine (line)) { |
1572 | if (IsHeaderLine (line)) { |
1585 | ptr1 = ScanHeaderLine (datei, line); |
1573 | ptr1 = ScanHeaderLine (datei, line); |
1586 | if (ParseHeader (&sstate.envelope, ptr1) == NULL) { |
1574 | if (ParseHeader (&sstate.envelope, ptr1) == NULL) { |
1587 | *errcode = UURET_NOMEM; |
1575 | *errcode = UURET_NOMEM; |
1588 | _FP_free (result); |
1576 | FP_free (result); |
1589 | return NULL; |
1577 | return NULL; |
1590 | } |
1578 | } |
1591 | } |
1579 | } |
1592 | /* |
1580 | /* |
1593 | * if we've read too many lines without finding headers, then |
1581 | * if we've read too many lines without finding headers, then |
… | |
… | |
1598 | fseek (datei, prevpos, SEEK_SET); |
1586 | fseek (datei, prevpos, SEEK_SET); |
1599 | line[0] = '\0'; |
1587 | line[0] = '\0'; |
1600 | break; |
1588 | break; |
1601 | } |
1589 | } |
1602 | |
1590 | |
1603 | if (_FP_fgets (line, 255, datei) == NULL) |
1591 | if (FP_fgets (line, 1024, datei) == NULL) { |
1604 | break; |
1592 | /* If we are at eof without finding headers, there probably isn't */ |
1605 | line[255] = '\0'; |
1593 | if (hcount < hlcount.afternl) |
|
|
1594 | fseek (datei, prevpos, SEEK_SET); |
|
|
1595 | break; |
|
|
1596 | } |
1606 | } |
1597 | } |
1607 | |
1598 | |
1608 | /* skip empty lines */ |
1599 | /* skip empty lines */ |
1609 | prevpos = ftell (datei); |
1600 | prevpos = ftell (datei); |
1610 | if (IsLineEmpty (line)) { |
1601 | if (IsLineEmpty (line)) { |
1611 | while (!feof (datei)) { |
1602 | while (!FP_feof (datei)) { |
1612 | if (_FP_fgets (line, 255, datei) == NULL) |
1603 | if (FP_fgets (line, 1024, datei) == NULL) |
1613 | break; |
1604 | break; |
1614 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1605 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1615 | if (!IsLineEmpty (line)) { |
1606 | if (!IsLineEmpty (line)) { |
1616 | fseek (datei, prevpos, SEEK_SET); |
1607 | fseek (datei, prevpos, SEEK_SET); |
1617 | line[255] = '\0'; |
|
|
1618 | break; |
1608 | break; |
1619 | } |
1609 | } |
1620 | prevpos = ftell (datei); |
1610 | prevpos = ftell (datei); |
1621 | } |
1611 | } |
1622 | } |
1612 | } |
… | |
… | |
1632 | sstate.envelope.ctenc == NULL && |
1622 | sstate.envelope.ctenc == NULL && |
1633 | IsKnownHeader (line)) { |
1623 | IsKnownHeader (line)) { |
1634 | /* |
1624 | /* |
1635 | * see above |
1625 | * see above |
1636 | */ |
1626 | */ |
1637 | if (_FP_fgets (line, 255, datei) == NULL) { |
1627 | FP_fgets (line, 1024, datei); |
1638 | line[0] = '\012'; |
|
|
1639 | line[1] = '\0'; |
|
|
1640 | } |
|
|
1641 | line[255] = '\0'; |
|
|
1642 | |
1628 | |
1643 | while (!feof (datei) && !IsLineEmpty (line)) { |
1629 | while (!FP_feof (datei) && !IsLineEmpty (line)) { |
1644 | if (IsKnownHeader (line)) |
1630 | if (IsKnownHeader (line)) |
1645 | hcount++; |
1631 | hcount++; |
1646 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1632 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1647 | ptr1 = ScanHeaderLine (datei, line); |
1633 | ptr1 = ScanHeaderLine (datei, line); |
1648 | if (ParseHeader (&sstate.envelope, ptr1) == NULL) { |
1634 | if (ParseHeader (&sstate.envelope, ptr1) == NULL) { |
1649 | *errcode = UURET_NOMEM; |
1635 | *errcode = UURET_NOMEM; |
1650 | _FP_free (result); |
1636 | FP_free (result); |
1651 | return NULL; |
1637 | return NULL; |
1652 | } |
1638 | } |
|
|
1639 | |
1653 | if (_FP_fgets (line, 255, datei) == NULL) |
1640 | if (FP_fgets (line, 1024, datei) == NULL) |
1654 | break; |
1641 | break; |
1655 | line[255] = '\0'; |
|
|
1656 | } |
1642 | } |
1657 | /* skip empty lines */ |
1643 | /* skip empty lines */ |
1658 | prevpos = ftell (datei); |
1644 | prevpos = ftell (datei); |
1659 | while (!feof (datei)) { |
1645 | while (!FP_feof (datei)) { |
1660 | if (_FP_fgets (line, 255, datei) == NULL) |
1646 | if (FP_fgets (line, 1024, datei) == NULL) |
1661 | break; |
1647 | break; |
1662 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1648 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1663 | if (!IsLineEmpty (line)) { |
1649 | if (!IsLineEmpty (line)) { |
1664 | fseek (datei, prevpos, SEEK_SET); |
1650 | fseek (datei, prevpos, SEEK_SET); |
1665 | line[255] = '\0'; |
|
|
1666 | break; |
1651 | break; |
1667 | } |
1652 | } |
1668 | prevpos = ftell (datei); |
1653 | prevpos = ftell (datei); |
1669 | } |
1654 | } |
1670 | } |
1655 | } |
… | |
… | |
1675 | * MIME message |
1660 | * MIME message |
1676 | * if mimevers is not set but there are other well-known MIME |
1661 | * if mimevers is not set but there are other well-known MIME |
1677 | * headers, don't be too picky about it. |
1662 | * headers, don't be too picky about it. |
1678 | */ |
1663 | */ |
1679 | if (sstate.envelope.ctype && sstate.envelope.mimevers==NULL && |
1664 | if (sstate.envelope.ctype && sstate.envelope.mimevers==NULL && |
1680 | _FP_stristr (sstate.envelope.ctype, "multipart") != NULL && |
1665 | FP_stristr (sstate.envelope.ctype, "multipart") != NULL && |
1681 | sstate.envelope.boundary != NULL) { |
1666 | sstate.envelope.boundary != NULL) { |
1682 | sstate.envelope.mimevers = _FP_strdup ("1.0"); |
1667 | sstate.envelope.mimevers = FP_strdup ("1.0"); |
1683 | hcount = hlcount.afternl; |
1668 | hcount = hlcount.afternl; |
1684 | } |
1669 | } |
1685 | else if (sstate.envelope.mimevers==NULL && sstate.envelope.ctype && |
1670 | else if (sstate.envelope.mimevers==NULL && sstate.envelope.ctype && |
1686 | sstate.envelope.fname && sstate.envelope.ctenc) { |
1671 | sstate.envelope.fname && sstate.envelope.ctenc) { |
1687 | sstate.envelope.mimevers = _FP_strdup ("1.0"); |
1672 | sstate.envelope.mimevers = FP_strdup ("1.0"); |
1688 | hcount = hlcount.afternl; |
1673 | hcount = hlcount.afternl; |
1689 | } |
1674 | } |
1690 | |
1675 | |
1691 | if (sstate.envelope.mimevers != NULL) { |
1676 | if (sstate.envelope.mimevers != NULL) { |
1692 | /* this is a MIME file. check the Content-Type */ |
1677 | /* this is a MIME file. check the Content-Type */ |
1693 | sstate.ismime = 1; |
1678 | sstate.ismime = 1; |
1694 | if (_FP_stristr (sstate.envelope.ctype, "multipart") != NULL) { |
1679 | if (FP_stristr (sstate.envelope.ctype, "multipart") != NULL) { |
1695 | if (sstate.envelope.boundary == NULL) { |
1680 | if (sstate.envelope.boundary == NULL) { |
1696 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1681 | UUMessage (UUMSG_WARNING, uustring (S_MIME_NO_BOUNDARY)); |
1697 | uustring (S_MIME_NO_BOUNDARY)); |
|
|
1698 | sstate.mimestate = MS_BODY; |
1682 | sstate.mimestate = MS_BODY; |
1699 | _FP_free (sstate.envelope.ctype); |
1683 | FP_free (sstate.envelope.ctype); |
1700 | sstate.envelope.ctype = _FP_strdup ("text/plain"); |
1684 | sstate.envelope.ctype = FP_strdup ("text/plain"); |
1701 | } |
1685 | } |
1702 | else { |
1686 | else { |
1703 | sstate.mimestate = MS_PREAMBLE; |
1687 | sstate.mimestate = MS_PREAMBLE; |
1704 | } |
1688 | } |
1705 | } |
1689 | } |
… | |
… | |
1713 | sstate.isfolder = 0; |
1697 | sstate.isfolder = 0; |
1714 | sstate.ismime = 0; |
1698 | sstate.ismime = 0; |
1715 | } |
1699 | } |
1716 | } |
1700 | } |
1717 | |
1701 | |
1718 | if (feof (datei) || ferror (datei)) { /* oops */ |
1702 | if (FP_feof (datei) || ferror (datei)) { /* oops */ |
1719 | _FP_free (result); |
1703 | FP_free (result); |
1720 | return NULL; |
1704 | return NULL; |
1721 | } |
1705 | } |
1722 | |
1706 | |
1723 | /* |
1707 | /* |
1724 | * Handle MIME stuff |
1708 | * Handle MIME stuff |
… | |
… | |
1734 | prevpos = ftell (datei); |
1718 | prevpos = ftell (datei); |
1735 | preheaders = ftell (datei); |
1719 | preheaders = ftell (datei); |
1736 | |
1720 | |
1737 | blen = strlen (sstate.envelope.boundary); |
1721 | blen = strlen (sstate.envelope.boundary); |
1738 | lcount = 0; |
1722 | lcount = 0; |
1739 | |
1723 | |
1740 | while (!feof (datei)) { |
1724 | while (!FP_feof (datei)) { |
1741 | if (_FP_fgets (line, 255, datei) == NULL) { |
1725 | if (FP_fgets (line, 1024, datei) == NULL) |
1742 | line[0] = '\0'; |
|
|
1743 | break; |
1726 | break; |
1744 | } |
|
|
1745 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1727 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1746 | if (line[0] == '-' && line[1] == '-' && |
1728 | if (line[0] == '-' && line[1] == '-' && |
1747 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
1729 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
1748 | break; |
1730 | break; |
1749 | if (!IsLineEmpty (line)) |
1731 | if (!IsLineEmpty (line)) |
1750 | lcount++; |
1732 | lcount++; |
1751 | |
1733 | |
1752 | prevpos = ftell (datei); |
1734 | prevpos = ftell (datei); |
1753 | } |
1735 | } |
1754 | if (feof (datei) || ferror (datei)) { |
1736 | if (FP_feof (datei) || ferror (datei)) { |
1755 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1737 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
1756 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
1757 | /* |
1738 | /* |
1758 | * restart and try again; don't restart if uu_fast_scanning |
1739 | * restart and try again; don't restart if uu_fast_scanning |
1759 | */ |
1740 | */ |
1760 | sstate.isfolder = 0; |
1741 | sstate.isfolder = 0; |
1761 | sstate.ismime = 0; |
1742 | sstate.ismime = 0; |
… | |
… | |
1763 | |
1744 | |
1764 | if (!uu_fast_scanning) { |
1745 | if (!uu_fast_scanning) { |
1765 | *errcode = UURET_CONT; |
1746 | *errcode = UURET_CONT; |
1766 | fseek (datei, preheaders, SEEK_SET); |
1747 | fseek (datei, preheaders, SEEK_SET); |
1767 | } |
1748 | } |
1768 | _FP_free (result); |
1749 | FP_free (result); |
1769 | return NULL; |
1750 | return NULL; |
1770 | } |
1751 | } |
1771 | if (line[0] == '-' && line[1] == '-' && |
1752 | if (line[0] == '-' && line[1] == '-' && |
1772 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) { |
1753 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) { |
1773 | ptr1 = line + 2 + blen; |
1754 | ptr1 = line + 2 + blen; |
… | |
… | |
1778 | else { |
1759 | else { |
1779 | sstate.mimestate = MS_SUBPART; |
1760 | sstate.mimestate = MS_SUBPART; |
1780 | } |
1761 | } |
1781 | } |
1762 | } |
1782 | else { /* shouldn't happen */ |
1763 | else { /* shouldn't happen */ |
1783 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1764 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
1784 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
1785 | /* |
1765 | /* |
1786 | * restart and try again; don't restart if uu_fast_scanning |
1766 | * restart and try again; don't restart if uu_fast_scanning |
1787 | */ |
1767 | */ |
1788 | sstate.isfolder = 0; |
1768 | sstate.isfolder = 0; |
1789 | sstate.ismime = 0; |
1769 | sstate.ismime = 0; |
… | |
… | |
1791 | |
1771 | |
1792 | if (!uu_fast_scanning) { |
1772 | if (!uu_fast_scanning) { |
1793 | *errcode = UURET_CONT; |
1773 | *errcode = UURET_CONT; |
1794 | fseek (datei, preheaders, SEEK_SET); |
1774 | fseek (datei, preheaders, SEEK_SET); |
1795 | } |
1775 | } |
1796 | _FP_free (result); |
1776 | FP_free (result); |
1797 | return NULL; |
1777 | return NULL; |
1798 | } |
1778 | } |
1799 | /* produce result if uu_usepreamble is set */ |
1779 | /* produce result if uu_usepreamble is set */ |
1800 | if (uu_usepreamble && lcount) { |
1780 | if (uu_usepreamble && lcount) { |
1801 | sprintf (line, "%04d.txt", ++mimseqno); |
1781 | sprintf (line, "%04d.txt", ++mimseqno); |
1802 | result->subject = _FP_strdup (sstate.envelope.subject); |
1782 | result->subject = FP_strdup (sstate.envelope.subject); |
1803 | result->filename = _FP_strdup (line); |
1783 | result->filename = FP_strdup (line); |
1804 | result->origin = _FP_strdup (sstate.envelope.from); |
1784 | result->origin = FP_strdup (sstate.envelope.from); |
1805 | result->mimeid = _FP_strdup (sstate.envelope.mimeid); |
1785 | result->mimeid = FP_strdup (sstate.envelope.mimeid); |
1806 | result->mimetype = _FP_strdup ("text/plain"); |
1786 | result->mimetype = FP_strdup ("text/plain"); |
1807 | result->mode = 0644; |
1787 | result->mode = 0644; |
1808 | result->uudet = PT_ENCODED; /* plain text */ |
1788 | result->uudet = PT_ENCODED; /* plain text */ |
1809 | result->sfname = _FP_strdup (fname); |
1789 | result->sfname = FP_strdup (fname); |
1810 | result->flags = FL_SINGLE | FL_PROPER; |
1790 | result->flags = FL_SINGLE | FL_PROPER; |
1811 | /* result->startpos set from above */ |
1791 | /* result->startpos set from above */ |
1812 | result->length = prevpos - result->startpos; |
1792 | result->length = prevpos - result->startpos; |
1813 | result->partno = 1; |
1793 | result->partno = 1; |
1814 | |
1794 | |
… | |
… | |
1825 | /* MIME message, let's continue */ |
1805 | /* MIME message, let's continue */ |
1826 | if (*errcode == UURET_OK) |
1806 | if (*errcode == UURET_OK) |
1827 | *errcode = UURET_CONT; |
1807 | *errcode = UURET_CONT; |
1828 | |
1808 | |
1829 | /* otherwise, just return NULL */ |
1809 | /* otherwise, just return NULL */ |
1830 | _FP_free (result); |
1810 | FP_free (result); |
1831 | return NULL; |
1811 | return NULL; |
1832 | } |
1812 | } |
1833 | |
1813 | |
1834 | /* |
1814 | /* |
1835 | * Read Epilogue, the plain text after the last boundary. |
1815 | * Read Epilogue, the plain text after the last boundary. |
… | |
… | |
1861 | */ |
1841 | */ |
1862 | if (uu_fast_scanning && mssdepth == 0) { |
1842 | if (uu_fast_scanning && mssdepth == 0) { |
1863 | /* |
1843 | /* |
1864 | * check if the epilogue is empty |
1844 | * check if the epilogue is empty |
1865 | */ |
1845 | */ |
1866 | while (!feof (datei) && !ferror (datei) && lcount<10 && res==0) { |
1846 | while (!FP_feof (datei) && !ferror (datei) && lcount<10 && res==0) { |
1867 | if (_FP_fgets (line, 255, datei) == NULL) |
1847 | if (FP_fgets (line, 1024, datei) == NULL) |
1868 | break; |
1848 | break; |
1869 | if (!IsLineEmpty (line)) |
1849 | if (!IsLineEmpty (line)) |
1870 | res++; |
1850 | res++; |
1871 | lcount++; |
1851 | lcount++; |
1872 | } |
1852 | } |
1873 | if (uu_usepreamble && res) { |
1853 | if (uu_usepreamble && res) { |
1874 | sprintf (line, "%04d.txt", ++mimseqno); |
1854 | sprintf (line, "%04d.txt", ++mimseqno); |
1875 | result->subject = _FP_strdup (sstate.envelope.subject); |
1855 | result->subject = FP_strdup (sstate.envelope.subject); |
1876 | result->filename = _FP_strdup (line); |
1856 | result->filename = FP_strdup (line); |
1877 | result->origin = _FP_strdup (sstate.envelope.from); |
1857 | result->origin = FP_strdup (sstate.envelope.from); |
1878 | result->mimeid = _FP_strdup (sstate.envelope.mimeid); |
1858 | result->mimeid = FP_strdup (sstate.envelope.mimeid); |
1879 | result->mimetype = _FP_strdup ("text/plain"); |
1859 | result->mimetype = FP_strdup ("text/plain"); |
1880 | result->mode = 0644; |
1860 | result->mode = 0644; |
1881 | result->uudet = PT_ENCODED; /* plain text */ |
1861 | result->uudet = PT_ENCODED; /* plain text */ |
1882 | result->sfname = _FP_strdup (fname); |
1862 | result->sfname = FP_strdup (fname); |
1883 | result->flags = FL_SINGLE | FL_PROPER | FL_TOEND; |
1863 | result->flags = FL_SINGLE | FL_PROPER | FL_TOEND; |
1884 | result->partno = 1; |
1864 | result->partno = 1; |
1885 | /* result->startpos set from above */ |
1865 | /* result->startpos set from above */ |
1886 | result->length = progress.fsize - result->startpos; |
1866 | result->length = progress.fsize - result->startpos; |
1887 | |
1867 | |
… | |
… | |
1890 | *errcode = UURET_NOMEM; |
1870 | *errcode = UURET_NOMEM; |
1891 | } |
1871 | } |
1892 | |
1872 | |
1893 | return result; |
1873 | return result; |
1894 | } |
1874 | } |
1895 | _FP_free (result); |
1875 | FP_free (result); |
1896 | return NULL; |
1876 | return NULL; |
1897 | } |
1877 | } |
1898 | |
1878 | |
1899 | if (mssdepth > 0) |
1879 | if (mssdepth > 0) |
1900 | blen = strlen (multistack[mssdepth-1].envelope.boundary); |
1880 | blen = strlen (multistack[mssdepth-1].envelope.boundary); |
1901 | |
1881 | |
1902 | while (!feof (datei)) { |
1882 | while (!FP_feof (datei)) { |
1903 | if (_FP_fgets (line, 255, datei) == NULL) { |
1883 | if (FP_fgets (line, 1024, datei) == NULL) |
1904 | line[0] = '\0'; |
|
|
1905 | break; |
1884 | break; |
1906 | } |
|
|
1907 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1885 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1908 | line[255] = '\0'; |
|
|
1909 | /* check for parent boundary */ |
1886 | /* check for parent boundary */ |
1910 | if (mssdepth > 0 && line[0] == '-' && line[1] == '-' && |
1887 | if (mssdepth > 0 && line[0] == '-' && line[1] == '-' && |
1911 | strncmp (line+2, |
1888 | strncmp (line+2, |
1912 | multistack[mssdepth-1].envelope.boundary, blen) == 0) |
1889 | multistack[mssdepth-1].envelope.boundary, blen) == 0) |
1913 | break; |
1890 | break; |
… | |
… | |
1917 | (void) ScanHeaderLine (datei, line); |
1894 | (void) ScanHeaderLine (datei, line); |
1918 | if (hcount == 0) { |
1895 | if (hcount == 0) { |
1919 | preheaders = prevpos; |
1896 | preheaders = prevpos; |
1920 | lcount = 0; |
1897 | lcount = 0; |
1921 | } |
1898 | } |
1922 | hcount++; |
1899 | hcount++; |
1923 | lcount++; |
1900 | lcount++; |
1924 | |
1901 | |
1925 | if (hcount >= hlcount.restart) { |
1902 | if (hcount >= hlcount.restart) { |
1926 | /* okay, new headers */ |
1903 | /* okay, new headers */ |
1927 | break; |
1904 | break; |
… | |
… | |
1938 | hcount = lcount = 0; |
1915 | hcount = lcount = 0; |
1939 | } |
1916 | } |
1940 | |
1917 | |
1941 | /* check for begin and encoded data only at outermost level */ |
1918 | /* check for begin and encoded data only at outermost level */ |
1942 | if (mssdepth == 0 && !uu_more_mime) { |
1919 | if (mssdepth == 0 && !uu_more_mime) { |
1943 | if (strncmp (line, "begin ", 6) == 0 || |
1920 | if (strncmp (line, "begin ", 6) == 0 || |
1944 | _FP_strnicmp (line, "<pre>begin ", 11) == 0) { |
1921 | FP_strnicmp_fast (line, "<pre>begin ", 11) == 0) { |
1945 | preenc = prevpos; |
1922 | preenc = prevpos; |
1946 | begflag = 1; |
1923 | begflag = 1; |
1947 | } |
1924 | } |
1948 | else if (strncmp (line, "end", 3) == 0 && begflag) { |
1925 | else if (strncmp (line, "end", 3) == 0 && begflag) { |
1949 | ecount = ELC_COUNT; |
1926 | ecount = ELC_COUNT; |
… | |
… | |
1954 | /* very short BinHex file follows */ |
1931 | /* very short BinHex file follows */ |
1955 | preenc = prevpos; |
1932 | preenc = prevpos; |
1956 | break; |
1933 | break; |
1957 | } |
1934 | } |
1958 | /* remember that XX can easily be mistaken as Base64 */ |
1935 | /* remember that XX can easily be mistaken as Base64 */ |
1959 | if ((vflag == UU_ENCODED || vflag == XX_ENCODED || |
1936 | if ((vflag == UU_ENCODED || vflag == XX_ENCODED || vflag == B64ENCODED) && begflag) { |
1960 | vflag == B64ENCODED) && begflag) { |
|
|
1961 | if (++ecount >= ELC_COUNT) |
1937 | if (++ecount >= ELC_COUNT) |
1962 | break; |
1938 | break; |
1963 | } |
1939 | } |
1964 | else { |
1940 | else { |
1965 | begflag = 0; |
1941 | begflag = 0; |
… | |
… | |
1982 | strncmp (line+2, |
1958 | strncmp (line+2, |
1983 | multistack[mssdepth-1].envelope.boundary, blen) == 0) { |
1959 | multistack[mssdepth-1].envelope.boundary, blen) == 0) { |
1984 | /* restore previous state */ |
1960 | /* restore previous state */ |
1985 | mssdepth--; |
1961 | mssdepth--; |
1986 | UUkillheaders (&sstate.envelope); |
1962 | UUkillheaders (&sstate.envelope); |
1987 | _FP_free (sstate.source); |
1963 | FP_free (sstate.source); |
1988 | memcpy (&sstate, &(multistack[mssdepth]), sizeof (scanstate)); |
1964 | memcpy (&sstate, &(multistack[mssdepth]), sizeof (scanstate)); |
1989 | |
1965 | |
1990 | ptr1 = line + 2 + strlen (sstate.envelope.boundary); |
1966 | ptr1 = line + 2 + strlen (sstate.envelope.boundary); |
1991 | |
1967 | |
1992 | if (*ptr1 == '-' && *(ptr1+1) == '-') { |
1968 | if (*ptr1 == '-' && *(ptr1+1) == '-') { |
… | |
… | |
1997 | } |
1973 | } |
1998 | result->length = prevpos - result->startpos; |
1974 | result->length = prevpos - result->startpos; |
1999 | *errcode = UURET_CONT; |
1975 | *errcode = UURET_CONT; |
2000 | } |
1976 | } |
2001 | else if (mssdepth > 0) { |
1977 | else if (mssdepth > 0) { |
2002 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1978 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
2003 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
2004 | /* |
1979 | /* |
2005 | * restart and try again; don't restart if uu_fast_scanning |
1980 | * restart and try again; don't restart if uu_fast_scanning |
2006 | */ |
1981 | */ |
2007 | sstate.isfolder = 0; |
1982 | sstate.isfolder = 0; |
2008 | sstate.ismime = 0; |
1983 | sstate.ismime = 0; |
2009 | sstate.mimestate = MS_BODY; |
1984 | sstate.mimestate = MS_BODY; |
2010 | |
1985 | |
2011 | while (mssdepth) { |
1986 | while (mssdepth) { |
2012 | mssdepth--; |
1987 | mssdepth--; |
2013 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1988 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2014 | _FP_free (multistack[mssdepth].source); |
1989 | FP_free (multistack[mssdepth].source); |
2015 | } |
1990 | } |
2016 | |
1991 | |
2017 | if (!uu_fast_scanning) { |
1992 | if (!uu_fast_scanning) { |
2018 | *errcode = UURET_CONT; |
1993 | *errcode = UURET_CONT; |
2019 | fseek (datei, preheaders, SEEK_SET); |
1994 | fseek (datei, preheaders, SEEK_SET); |
2020 | } |
1995 | } |
2021 | _FP_free (result); |
1996 | FP_free (result); |
2022 | return NULL; |
1997 | return NULL; |
2023 | } |
1998 | } |
2024 | else if (IsKnownHeader (line)) { |
1999 | else if (IsKnownHeader (line)) { |
2025 | /* new message follows */ |
2000 | /* new message follows */ |
2026 | sstate.isfolder = 1; |
2001 | sstate.isfolder = 1; |
… | |
… | |
2039 | } |
2014 | } |
2040 | |
2015 | |
2041 | /* produce result if uu_usepreamble is set */ |
2016 | /* produce result if uu_usepreamble is set */ |
2042 | if (uu_usepreamble && res) { |
2017 | if (uu_usepreamble && res) { |
2043 | sprintf (line, "%04d.txt", ++mimseqno); |
2018 | sprintf (line, "%04d.txt", ++mimseqno); |
2044 | result->subject = _FP_strdup (sstate.envelope.subject); |
2019 | result->subject = FP_strdup (sstate.envelope.subject); |
2045 | result->filename = _FP_strdup (line); |
2020 | result->filename = FP_strdup (line); |
2046 | result->origin = _FP_strdup (sstate.envelope.from); |
2021 | result->origin = FP_strdup (sstate.envelope.from); |
2047 | result->mimeid = _FP_strdup (sstate.envelope.mimeid); |
2022 | result->mimeid = FP_strdup (sstate.envelope.mimeid); |
2048 | result->mimetype = _FP_strdup ("text/plain"); |
2023 | result->mimetype = FP_strdup ("text/plain"); |
2049 | result->mode = 0644; |
2024 | result->mode = 0644; |
2050 | result->uudet = PT_ENCODED; /* plain text */ |
2025 | result->uudet = PT_ENCODED; /* plain text */ |
2051 | result->sfname = _FP_strdup (fname); |
2026 | result->sfname = FP_strdup (fname); |
2052 | result->flags = FL_SINGLE | FL_PROPER; |
2027 | result->flags = FL_SINGLE | FL_PROPER; |
2053 | result->partno = 1; |
2028 | result->partno = 1; |
2054 | /* result->startpos set from above */ |
2029 | /* result->startpos set from above */ |
2055 | /* result->length set from above */ |
2030 | /* result->length set from above */ |
2056 | |
2031 | |
… | |
… | |
2060 | } |
2035 | } |
2061 | |
2036 | |
2062 | return result; |
2037 | return result; |
2063 | } |
2038 | } |
2064 | /* otherwise, just return NULL */ |
2039 | /* otherwise, just return NULL */ |
2065 | _FP_free (result); |
2040 | FP_free (result); |
2066 | return NULL; |
2041 | return NULL; |
2067 | } |
2042 | } |
2068 | |
2043 | |
2069 | /* |
2044 | /* |
2070 | * Scan a new part from a Multipart message. Check for a new local |
2045 | * Scan a new part from a Multipart message. Check for a new local |
… | |
… | |
2072 | * evaluate its Content-Type and Content-Transfer-Encoding. If this |
2047 | * evaluate its Content-Type and Content-Transfer-Encoding. If this |
2073 | * is another Multipart/something, push the current state onto our |
2048 | * is another Multipart/something, push the current state onto our |
2074 | * stack and dive into the new environment, starting with another |
2049 | * stack and dive into the new environment, starting with another |
2075 | * preamble. |
2050 | * preamble. |
2076 | */ |
2051 | */ |
2077 | |
2052 | |
2078 | if (sstate.ismime && sstate.mimestate == MS_SUBPART) { |
2053 | if (sstate.ismime && sstate.mimestate == MS_SUBPART) { |
2079 | memset (&localenv, 0, sizeof (headers)); |
2054 | memset (&localenv, 0, sizeof (headers)); |
2080 | result->startpos = ftell (datei); |
2055 | result->startpos = ftell (datei); |
2081 | prevpos = ftell (datei); |
2056 | prevpos = ftell (datei); |
2082 | hcount = 0; |
2057 | hcount = 0; |
… | |
… | |
2084 | |
2059 | |
2085 | /* |
2060 | /* |
2086 | * Duplicate some data from outer envelope |
2061 | * Duplicate some data from outer envelope |
2087 | */ |
2062 | */ |
2088 | |
2063 | |
2089 | localenv.mimevers = _FP_strdup (sstate.envelope.mimevers); |
2064 | localenv.mimevers = FP_strdup (sstate.envelope.mimevers); |
2090 | localenv.from = _FP_strdup (sstate.envelope.from); |
2065 | localenv.from = FP_strdup (sstate.envelope.from); |
2091 | localenv.subject = _FP_strdup (sstate.envelope.subject); |
2066 | localenv.subject = FP_strdup (sstate.envelope.subject); |
2092 | localenv.rcpt = _FP_strdup (sstate.envelope.rcpt); |
2067 | localenv.rcpt = FP_strdup (sstate.envelope.rcpt); |
2093 | localenv.date = _FP_strdup (sstate.envelope.date); |
2068 | localenv.date = FP_strdup (sstate.envelope.date); |
2094 | |
2069 | |
2095 | if ((sstate.envelope.mimevers != NULL && localenv.mimevers == NULL) || |
2070 | if ((sstate.envelope.mimevers != NULL && localenv.mimevers == NULL) || |
2096 | (sstate.envelope.from != NULL && localenv.from == NULL) || |
2071 | (sstate.envelope.from != NULL && localenv.from == NULL) || |
2097 | (sstate.envelope.subject != NULL && localenv.subject == NULL) || |
2072 | (sstate.envelope.subject != NULL && localenv.subject == NULL) || |
2098 | (sstate.envelope.rcpt != NULL && localenv.rcpt == NULL) || |
2073 | (sstate.envelope.rcpt != NULL && localenv.rcpt == NULL) || |
2099 | (sstate.envelope.date != NULL && localenv.date == NULL)) { |
2074 | (sstate.envelope.date != NULL && localenv.date == NULL)) { |
2100 | |
2075 | |
2101 | while (mssdepth) { |
2076 | while (mssdepth) { |
2102 | mssdepth--; |
2077 | mssdepth--; |
2103 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2078 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2104 | _FP_free (multistack[mssdepth].source); |
2079 | FP_free (multistack[mssdepth].source); |
2105 | } |
2080 | } |
2106 | sstate.isfolder = 0; |
2081 | sstate.isfolder = 0; |
2107 | sstate.ismime = 0; |
2082 | sstate.ismime = 0; |
2108 | |
2083 | |
2109 | UUkillheaders (&localenv); |
2084 | UUkillheaders (&localenv); |
2110 | *errcode = UURET_NOMEM; |
2085 | *errcode = UURET_NOMEM; |
2111 | _FP_free (result); |
2086 | FP_free (result); |
2112 | return NULL; |
2087 | return NULL; |
2113 | } |
2088 | } |
2114 | |
2089 | |
2115 | /* Scan subheader. But what if there is no subheader? */ |
2090 | /* Scan subheader. But what if there is no subheader? */ |
2116 | hcount = 0; |
2091 | hcount = 0; |
2117 | lcount = 0; |
2092 | lcount = 0; |
2118 | preheaders = prevpos; |
2093 | preheaders = prevpos; |
2119 | |
2094 | |
2120 | if (_FP_fgets (line, 255, datei) == NULL) { |
2095 | if (FP_fgets (line, 1024, datei) == NULL) { |
2121 | sstate.isfolder = 0; |
2096 | sstate.isfolder = 0; |
2122 | sstate.ismime = 0; |
2097 | sstate.ismime = 0; |
2123 | while (mssdepth) { |
2098 | while (mssdepth) { |
2124 | mssdepth--; |
2099 | mssdepth--; |
2125 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2100 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2126 | _FP_free (multistack[mssdepth].source); |
2101 | FP_free (multistack[mssdepth].source); |
2127 | } |
2102 | } |
2128 | UUkillheaders (&localenv); |
2103 | UUkillheaders (&localenv); |
2129 | _FP_free (result); |
2104 | FP_free (result); |
2130 | return NULL; |
2105 | return NULL; |
2131 | } |
2106 | } |
2132 | line[255] = '\0'; |
|
|
2133 | |
2107 | |
2134 | while (!feof (datei) && !IsLineEmpty (line)) { |
2108 | while (!FP_feof (datei) && !IsLineEmpty (line)) { |
2135 | if (IsKnownHeader (line)) |
2109 | if (IsKnownHeader (line)) |
2136 | hcount++; |
2110 | hcount++; |
2137 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2111 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2138 | if (lcount > WAITHEADER && hcount == 0) { |
2112 | if (lcount > WAITHEADER && hcount == 0) { |
2139 | fseek (datei, preheaders, SEEK_SET); |
2113 | fseek (datei, preheaders, SEEK_SET); |
… | |
… | |
2147 | if (line[0] == '-' && line[1] == '-') |
2121 | if (line[0] == '-' && line[1] == '-') |
2148 | break; |
2122 | break; |
2149 | |
2123 | |
2150 | prevpos = ftell (datei); |
2124 | prevpos = ftell (datei); |
2151 | |
2125 | |
2152 | if (_FP_fgets (line, 255, datei) == NULL) |
2126 | if (FP_fgets (line, 1024, datei) == NULL) |
2153 | break; |
2127 | break; |
2154 | line[255] = '\0'; |
|
|
2155 | lcount++; |
2128 | lcount++; |
2156 | } |
2129 | } |
2157 | if (line[0] == '-' && line[1] == '-') { |
2130 | if (line[0] == '-' && line[1] == '-') { |
2158 | /* |
2131 | /* |
2159 | * this shouldn't happen, there must always be an empty line, |
2132 | * this shouldn't happen, there must always be an empty line, |
… | |
… | |
2161 | * boundary, so that it gets handled below |
2134 | * boundary, so that it gets handled below |
2162 | */ |
2135 | */ |
2163 | fseek (datei, prevpos, SEEK_SET); |
2136 | fseek (datei, prevpos, SEEK_SET); |
2164 | } |
2137 | } |
2165 | |
2138 | |
2166 | if (_FP_stristr (localenv.ctype, "multipart") != NULL) { |
2139 | if (FP_stristr (localenv.ctype, "multipart") != NULL) { |
2167 | /* oh no, not again */ |
2140 | /* oh no, not again */ |
2168 | if (mssdepth >= MSMAXDEPTH) { |
2141 | if (mssdepth >= MSMAXDEPTH) { |
2169 | /* Argh, what an isane message. Treat as plain text */ |
2142 | /* Argh, what an isane message. Treat as plain text */ |
2170 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2143 | UUMessage (UUMSG_WARNING, uustring (S_MIME_MULTI_DEPTH)); |
2171 | uustring (S_MIME_MULTI_DEPTH)); |
|
|
2172 | } |
2144 | } |
2173 | else if (localenv.boundary == NULL) { |
2145 | else if (localenv.boundary == NULL) { |
2174 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2146 | UUMessage (UUMSG_WARNING, uustring (S_MIME_NO_BOUNDARY)); |
2175 | uustring (S_MIME_NO_BOUNDARY)); |
|
|
2176 | } |
2147 | } |
2177 | else { |
2148 | else { |
2178 | memcpy (&multistack[mssdepth], &sstate, sizeof (scanstate)); |
2149 | memcpy (&multistack[mssdepth], &sstate, sizeof (scanstate)); |
2179 | memcpy (&sstate.envelope, &localenv, sizeof (headers)); |
2150 | memcpy (&sstate.envelope, &localenv, sizeof (headers)); |
2180 | memset (&localenv, 0, sizeof (headers)); |
2151 | memset (&localenv, 0, sizeof (headers)); |
2181 | sstate.mimestate = MS_PREAMBLE; |
2152 | sstate.mimestate = MS_PREAMBLE; |
2182 | if ((sstate.source = _FP_strdup (sstate.source)) == NULL) |
2153 | if ((sstate.source = FP_strdup (sstate.source)) == NULL) |
2183 | *errcode = UURET_NOMEM; |
2154 | *errcode = UURET_NOMEM; |
2184 | |
2155 | |
2185 | if (*errcode == UURET_OK) |
2156 | if (*errcode == UURET_OK) |
2186 | *errcode = UURET_CONT; |
2157 | *errcode = UURET_CONT; |
2187 | |
2158 | |
2188 | mssdepth++; |
2159 | mssdepth++; |
2189 | /* need a restart */ |
2160 | /* need a restart */ |
2190 | _FP_free (result); |
2161 | FP_free (result); |
2191 | return NULL; |
2162 | return NULL; |
2192 | } |
2163 | } |
2193 | } |
2164 | } |
2194 | |
2165 | |
2195 | /* |
2166 | /* |
… | |
… | |
2203 | * text. |
2174 | * text. |
2204 | * This is done because users might `attach' a uuencoded file, which |
2175 | * This is done because users might `attach' a uuencoded file, which |
2205 | * would then be correctly typed as `text/plain'. |
2176 | * would then be correctly typed as `text/plain'. |
2206 | */ |
2177 | */ |
2207 | |
2178 | |
2208 | if (_FP_stristr (localenv.ctenc, "base64") != NULL) |
2179 | if (FP_stristr (localenv.ctenc, "base64") != NULL) |
2209 | result->uudet = B64ENCODED; |
2180 | result->uudet = B64ENCODED; |
2210 | else if (_FP_stristr (localenv.ctenc, "x-uue") != NULL) { |
2181 | else if (FP_stristr (localenv.ctenc, "x-uue") != NULL) { |
2211 | result->uudet = UU_ENCODED; |
2182 | result->uudet = UU_ENCODED; |
2212 | result->begin = result->end = 1; |
2183 | result->begin = result->end = 1; |
2213 | } |
2184 | } |
2214 | else if (_FP_stristr (localenv.ctenc, "x-yenc") != NULL) { |
2185 | else if (FP_stristr (localenv.ctenc, "x-yenc") != NULL) { |
2215 | result->uudet = YENC_ENCODED; |
2186 | result->uudet = YENC_ENCODED; |
2216 | result->begin = result->end = 1; |
2187 | result->begin = result->end = 1; |
2217 | } |
2188 | } |
2218 | else if (_FP_stristr (localenv.ctenc, "quoted-printable") != NULL) |
2189 | else if (FP_stristr (localenv.ctenc, "quoted-printable") != NULL) |
2219 | result->uudet = QP_ENCODED; |
2190 | result->uudet = QP_ENCODED; |
2220 | else if (_FP_stristr (localenv.ctenc, "7bit") != NULL || |
2191 | else if (FP_stristr (localenv.ctenc, "7bit") != NULL || |
2221 | _FP_stristr (localenv.ctenc, "8bit") != NULL) |
2192 | FP_stristr (localenv.ctenc, "8bit") != NULL) |
2222 | result->uudet = PT_ENCODED; |
2193 | result->uudet = PT_ENCODED; |
2223 | else if (_FP_stristr (localenv.ctype, "multipart") != NULL || |
2194 | else if (FP_stristr (localenv.ctype, "multipart") != NULL || |
2224 | _FP_stristr (localenv.ctype, "message") != NULL) |
2195 | FP_stristr (localenv.ctype, "message") != NULL) |
2225 | result->uudet = PT_ENCODED; |
2196 | result->uudet = PT_ENCODED; |
2226 | |
2197 | |
2227 | /* |
2198 | /* |
2228 | * If we're switched to MIME-only mode, handle as text |
2199 | * If we're switched to MIME-only mode, handle as text |
2229 | */ |
2200 | */ |
… | |
… | |
2238 | */ |
2209 | */ |
2239 | result->startpos = ftell (datei); |
2210 | result->startpos = ftell (datei); |
2240 | prevpos = ftell (datei); |
2211 | prevpos = ftell (datei); |
2241 | blen = strlen (sstate.envelope.boundary); |
2212 | blen = strlen (sstate.envelope.boundary); |
2242 | lcount = 0; |
2213 | lcount = 0; |
2243 | |
2214 | |
2244 | while (!feof (datei)) { |
2215 | while (!FP_feof (datei)) { |
2245 | if (_FP_fgets (line, 255, datei) == NULL) { |
2216 | if (FP_fgets (line, 1024, datei) == NULL) |
2246 | line[0] = '\0'; |
|
|
2247 | break; |
2217 | break; |
2248 | } |
|
|
2249 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2218 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2250 | line[255] = '\0'; |
2219 | line[255] = '\0'; |
2251 | if (line[0] == '-' && line[1] == '-' && |
2220 | if (line[0] == '-' && line[1] == '-' && |
2252 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2221 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2253 | break; |
2222 | break; |
… | |
… | |
2259 | * This check here doesn't cover folded header lines, but we don't |
2228 | * This check here doesn't cover folded header lines, but we don't |
2260 | * want to slow down scanning too much. We just check for |
2229 | * want to slow down scanning too much. We just check for |
2261 | * Content-Type: multipart/... boundary="same-boundary" |
2230 | * Content-Type: multipart/... boundary="same-boundary" |
2262 | */ |
2231 | */ |
2263 | if (line[0] == 'C' && line[1] == 'o' && |
2232 | if (line[0] == 'C' && line[1] == 'o' && |
2264 | _FP_strnicmp (line, "Content-Type:", 13) == 0) { |
2233 | FP_strnicmp_fast (line, "Content-Type:", 13) == 0) { |
2265 | ptr1 = ScanHeaderLine (datei, line); |
2234 | ptr1 = ScanHeaderLine (datei, line); |
2266 | ptr2 = (ptr1)?_FP_stristr(ptr1,"boundary"):NULL; |
2235 | ptr2 = (ptr1)?FP_stristr(ptr1,"boundary"):NULL; |
2267 | ptr1 = (ptr2)?ParseValue(ptr2):NULL; |
2236 | ptr1 = (ptr2)?ParseValue(ptr2):NULL; |
2268 | if (ptr1 && strcmp (ptr1, sstate.envelope.boundary) == 0) |
2237 | if (ptr1 && strcmp (ptr1, sstate.envelope.boundary) == 0) |
2269 | break; |
2238 | break; |
2270 | for (res=0; ptr1 && res<mssdepth; res++) |
2239 | for (res=0; ptr1 && res<mssdepth; res++) |
2271 | if (strcmp (ptr1, multistack[res].envelope.boundary) == 0) |
2240 | if (strcmp (ptr1, multistack[res].envelope.boundary) == 0) |
… | |
… | |
2284 | sstate.mimestate = MS_EPILOGUE; |
2253 | sstate.mimestate = MS_EPILOGUE; |
2285 | else |
2254 | else |
2286 | sstate.mimestate = MS_SUBPART; |
2255 | sstate.mimestate = MS_SUBPART; |
2287 | } |
2256 | } |
2288 | else { |
2257 | else { |
2289 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2258 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
2290 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
2291 | |
2259 | |
2292 | while (mssdepth) { |
2260 | while (mssdepth) { |
2293 | mssdepth--; |
2261 | mssdepth--; |
2294 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2262 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2295 | _FP_free (multistack[mssdepth].source); |
2263 | FP_free (multistack[mssdepth].source); |
2296 | } |
2264 | } |
2297 | /* |
2265 | /* |
2298 | * Don't retry if uu_fast_scanning |
2266 | * Don't retry if uu_fast_scanning |
2299 | */ |
2267 | */ |
2300 | |
2268 | |
2301 | if (uu_fast_scanning) { |
2269 | if (uu_fast_scanning) { |
2302 | UUkillheaders (&localenv); |
2270 | UUkillheaders (&localenv); |
2303 | sstate.isfolder = 0; |
2271 | sstate.isfolder = 0; |
2304 | sstate.ismime = 0; |
2272 | sstate.ismime = 0; |
2305 | sstate.mimestate = MS_BODY; |
2273 | sstate.mimestate = MS_BODY; |
2306 | _FP_free (result); |
2274 | FP_free (result); |
2307 | return NULL; |
2275 | return NULL; |
2308 | } |
2276 | } |
2309 | |
2277 | |
2310 | /* |
2278 | /* |
2311 | * Retry, but listening to headers this time |
2279 | * Retry, but listening to headers this time |
… | |
… | |
2345 | } |
2313 | } |
2346 | /* produce result if uu_handletext is set */ |
2314 | /* produce result if uu_handletext is set */ |
2347 | /* or if the file is explicitely named */ |
2315 | /* or if the file is explicitely named */ |
2348 | if (result->uudet == B64ENCODED || lcount) { |
2316 | if (result->uudet == B64ENCODED || lcount) { |
2349 | if (localenv.fname) { |
2317 | if (localenv.fname) { |
2350 | _FP_free (result->filename); |
2318 | FP_free (result->filename); |
2351 | if ((result->filename = _FP_strdup (localenv.fname)) == NULL) |
2319 | if ((result->filename = FP_strdup (localenv.fname)) == NULL) |
2352 | *errcode = UURET_NOMEM; |
2320 | *errcode = UURET_NOMEM; |
2353 | } |
2321 | } |
2354 | else if ((result->uudet==QP_ENCODED||result->uudet==PT_ENCODED) && |
2322 | else if ((result->uudet==QP_ENCODED||result->uudet==PT_ENCODED) && |
2355 | result->filename == NULL && uu_handletext) { |
2323 | result->filename == NULL && uu_handletext) { |
2356 | sprintf (line, "%04d.txt", ++mimseqno); |
2324 | sprintf (line, "%04d.txt", ++mimseqno); |
2357 | if ((result->filename = _FP_strdup (line)) == NULL) |
2325 | if ((result->filename = FP_strdup (line)) == NULL) |
2358 | *errcode = UURET_NOMEM; |
2326 | *errcode = UURET_NOMEM; |
2359 | } |
2327 | } |
2360 | result->subject = _FP_strdup (localenv.subject); |
2328 | result->subject = FP_strdup (localenv.subject); |
2361 | result->origin = _FP_strdup (localenv.from); |
2329 | result->origin = FP_strdup (localenv.from); |
2362 | result->mimeid = _FP_strdup (localenv.mimeid); |
2330 | result->mimeid = FP_strdup (localenv.mimeid); |
2363 | result->mimetype = _FP_strdup (localenv.ctype); |
2331 | result->mimetype = FP_strdup (localenv.ctype); |
2364 | result->mode = 0644; |
2332 | result->mode = 0644; |
2365 | result->sfname = _FP_strdup (fname); |
2333 | result->sfname = FP_strdup (fname); |
2366 | result->flags = FL_SINGLE | FL_PROPER; |
2334 | result->flags = FL_SINGLE | FL_PROPER; |
2367 | result->partno = 1; |
2335 | result->partno = 1; |
2368 | /* result->uudet determined above */ |
2336 | /* result->uudet determined above */ |
2369 | /* result->startpos set from above */ |
2337 | /* result->startpos set from above */ |
2370 | result->length = prevpos - result->startpos; |
2338 | result->length = prevpos - result->startpos; |
… | |
… | |
2374 | *errcode = UURET_NOMEM; |
2342 | *errcode = UURET_NOMEM; |
2375 | } |
2343 | } |
2376 | } |
2344 | } |
2377 | else { |
2345 | else { |
2378 | /* don't produce a result */ |
2346 | /* don't produce a result */ |
2379 | _FP_free (result); |
2347 | FP_free (result); |
2380 | result = NULL; |
2348 | result = NULL; |
2381 | } |
2349 | } |
2382 | if (*errcode == UURET_OK) |
2350 | if (*errcode == UURET_OK) |
2383 | *errcode = UURET_CONT; |
2351 | *errcode = UURET_CONT; |
2384 | /* |
2352 | /* |
… | |
… | |
2408 | * we should really be at a boundary here, but check again |
2376 | * we should really be at a boundary here, but check again |
2409 | */ |
2377 | */ |
2410 | blen = strlen (sstate.envelope.boundary); |
2378 | blen = strlen (sstate.envelope.boundary); |
2411 | prevpos = ftell (datei); |
2379 | prevpos = ftell (datei); |
2412 | |
2380 | |
2413 | while (!feof (datei)) { |
2381 | while (!FP_feof (datei)) { |
2414 | if (_FP_fgets (line, 255, datei) == NULL) { |
2382 | if (FP_fgets (line, 1024, datei) == NULL) |
2415 | line[0] = '\0'; |
|
|
2416 | break; |
2383 | break; |
2417 | } |
|
|
2418 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2384 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2419 | line[255] = '\0'; |
|
|
2420 | if (line[0] == '-' && line[1] == '-' && |
2385 | if (line[0] == '-' && line[1] == '-' && |
2421 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2386 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2422 | break; |
2387 | break; |
2423 | if (line[0] == 'C' && line[1] == 'o' && |
2388 | if (line[0] == 'C' && line[1] == 'o' && |
2424 | _FP_strnicmp (line, "Content-Type:", 13) == 0) { |
2389 | FP_strnicmp_fast (line, "Content-Type:", 13) == 0) { |
2425 | ptr1 = ScanHeaderLine (datei, line); |
2390 | ptr1 = ScanHeaderLine (datei, line); |
2426 | ptr2 = (ptr1)?_FP_stristr(ptr1,"boundary"):NULL; |
2391 | ptr2 = (ptr1)?FP_stristr(ptr1,"boundary"):NULL; |
2427 | ptr1 = (ptr2)?ParseValue(ptr2):NULL; |
2392 | ptr1 = (ptr2)?ParseValue(ptr2):NULL; |
2428 | if (ptr1 && strcmp (ptr1, sstate.envelope.boundary) == 0) |
2393 | if (ptr1 && strcmp (ptr1, sstate.envelope.boundary) == 0) |
2429 | break; |
2394 | break; |
2430 | } |
2395 | } |
2431 | prevpos = ftell (datei); |
2396 | prevpos = ftell (datei); |
… | |
… | |
2440 | sstate.mimestate = MS_EPILOGUE; |
2405 | sstate.mimestate = MS_EPILOGUE; |
2441 | else |
2406 | else |
2442 | sstate.mimestate = MS_SUBPART; |
2407 | sstate.mimestate = MS_SUBPART; |
2443 | } |
2408 | } |
2444 | else { |
2409 | else { |
2445 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2410 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
2446 | uustring (S_MIME_B_NOT_FOUND)); |
2411 | |
2447 | |
|
|
2448 | while (mssdepth) { |
2412 | while (mssdepth) { |
2449 | mssdepth--; |
2413 | mssdepth--; |
2450 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2414 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2451 | _FP_free (multistack[mssdepth].source); |
2415 | FP_free (multistack[mssdepth].source); |
2452 | } |
2416 | } |
2453 | |
2417 | |
2454 | if (uu_fast_scanning) { |
2418 | if (uu_fast_scanning) { |
2455 | UUkillheaders (&localenv); |
2419 | UUkillheaders (&localenv); |
2456 | sstate.isfolder = 0; |
2420 | sstate.isfolder = 0; |
2457 | sstate.ismime = 0; |
2421 | sstate.ismime = 0; |
2458 | sstate.mimestate = MS_BODY; |
2422 | sstate.mimestate = MS_BODY; |
2459 | _FP_free (result); |
2423 | FP_free (result); |
2460 | return NULL; |
2424 | return NULL; |
2461 | } |
2425 | } |
2462 | |
2426 | |
2463 | /* |
2427 | /* |
2464 | * Retry, listening to headers this time |
2428 | * Retry, listening to headers this time |
2465 | */ |
2429 | */ |
2466 | fseek (datei, result->startpos, SEEK_SET); |
2430 | fseek (datei, result->startpos, SEEK_SET); |
2467 | |
2431 | |
2468 | UUkillfread (result); |
2432 | UUkillfread (result); |
2469 | if ((result = (fileread *) malloc (sizeof (fileread))) == NULL) { |
2433 | if ((result = (fileread *) malloc (sizeof (fileread))) == NULL) { |
2470 | *errcode = UURET_NOMEM; |
2434 | *errcode = UURET_NOMEM; |
2471 | sstate.isfolder = 0; |
2435 | sstate.isfolder = 0; |
2472 | sstate.ismime = 0; |
2436 | sstate.ismime = 0; |
… | |
… | |
2501 | * If this file has been nicely MIME so far, then be very suspicious |
2465 | * If this file has been nicely MIME so far, then be very suspicious |
2502 | * if ScanData reports anything else. So do a double check, and if |
2466 | * if ScanData reports anything else. So do a double check, and if |
2503 | * it doesn't hold up, handle as plain text instead. |
2467 | * it doesn't hold up, handle as plain text instead. |
2504 | */ |
2468 | */ |
2505 | |
2469 | |
|
|
2470 | if (sstate.ismime && sstate.mimestate == MS_SUBPART && |
2506 | if (strcmp (localenv.mimevers, "1.0") == 0 && |
2471 | strcmp (localenv.mimevers, "1.0") == 0 && |
2507 | _FP_stristr (localenv.ctype, "text") != NULL && |
2472 | FP_stristr (localenv.ctype, "text") != NULL && |
2508 | sstate.ismime && sstate.mimestate == MS_SUBPART && |
|
|
2509 | !uu_desperate) { |
2473 | !uu_desperate) { |
2510 | if (result->uudet == UU_ENCODED && !(result->begin || result->end)) { |
2474 | if (result->uudet == UU_ENCODED && !(result->begin || result->end)) { |
2511 | result->uudet = 0; |
2475 | result->uudet = 0; |
2512 | } |
2476 | } |
2513 | } |
2477 | } |
… | |
… | |
2519 | if (result->uudet == 0) { |
2483 | if (result->uudet == 0) { |
2520 | result->uudet = PT_ENCODED; /* plain text */ |
2484 | result->uudet = PT_ENCODED; /* plain text */ |
2521 | } |
2485 | } |
2522 | |
2486 | |
2523 | if (localenv.fname) { |
2487 | if (localenv.fname) { |
2524 | _FP_free (result->filename); |
2488 | FP_free (result->filename); |
2525 | if ((result->filename = _FP_strdup (localenv.fname)) == NULL) |
2489 | if ((result->filename = FP_strdup (localenv.fname)) == NULL) |
2526 | *errcode = UURET_NOMEM; |
2490 | *errcode = UURET_NOMEM; |
2527 | } |
2491 | } |
2528 | else if ((result->uudet==QP_ENCODED || result->uudet==PT_ENCODED) && |
2492 | else if ((result->uudet==QP_ENCODED || result->uudet==PT_ENCODED) && |
2529 | result->filename==NULL && uu_handletext) { |
2493 | result->filename==NULL && uu_handletext) { |
2530 | sprintf (line, "%04d.txt", ++mimseqno); |
2494 | sprintf (line, "%04d.txt", ++mimseqno); |
2531 | if ((result->filename = _FP_strdup (line)) == NULL) |
2495 | if ((result->filename = FP_strdup (line)) == NULL) |
2532 | *errcode = UURET_NOMEM; |
2496 | *errcode = UURET_NOMEM; |
2533 | } |
2497 | } |
2534 | else { |
2498 | else { |
2535 | /* assign a filename lateron */ |
2499 | /* assign a filename lateron */ |
2536 | } |
2500 | } |
2537 | if (result->mimetype) _FP_free (result->mimetype); |
2501 | if (result->mimetype) FP_free (result->mimetype); |
2538 | if (result->uudet) { |
2502 | if (result->uudet) { |
2539 | if (_FP_stristr (localenv.ctype, "text") != NULL && |
2503 | if (FP_stristr (localenv.ctype, "text") != NULL && |
2540 | result->uudet != QP_ENCODED && result->uudet != PT_ENCODED) |
2504 | result->uudet != QP_ENCODED && result->uudet != PT_ENCODED) |
2541 | result->mimetype = NULL; /* better don't set it */ |
2505 | result->mimetype = NULL; /* better don't set it */ |
2542 | else |
2506 | else |
2543 | result->mimetype = _FP_strdup (localenv.ctype); |
2507 | result->mimetype = FP_strdup (localenv.ctype); |
2544 | } |
2508 | } |
2545 | if (result->origin) _FP_free (result->origin); |
2509 | if (result->origin) FP_free (result->origin); |
2546 | result->origin = _FP_strdup (localenv.from); |
2510 | result->origin = FP_strdup (localenv.from); |
2547 | |
2511 | |
2548 | if (result->subject) _FP_free (result->subject); |
2512 | if (result->subject) FP_free (result->subject); |
2549 | result->subject = _FP_strdup (localenv.subject); |
2513 | result->subject = FP_strdup (localenv.subject); |
2550 | |
2514 | |
2551 | if (result->sfname == NULL) |
2515 | if (result->sfname == NULL) |
2552 | if ((result->sfname = _FP_strdup (fname)) == NULL) |
2516 | if ((result->sfname = FP_strdup (fname)) == NULL) |
2553 | *errcode = UURET_NOMEM; |
2517 | *errcode = UURET_NOMEM; |
2554 | |
2518 | |
2555 | result->length = prevpos - result->startpos; |
2519 | result->length = prevpos - result->startpos; |
2556 | result->flags = FL_SINGLE | FL_PROPER; |
2520 | result->flags = FL_SINGLE | FL_PROPER; |
2557 | result->partno = 1; |
2521 | result->partno = 1; |
… | |
… | |
2568 | |
2532 | |
2569 | /* |
2533 | /* |
2570 | * kill local envelope |
2534 | * kill local envelope |
2571 | */ |
2535 | */ |
2572 | UUkillheaders (&localenv); |
2536 | UUkillheaders (&localenv); |
2573 | |
2537 | |
2574 | return result; |
2538 | return result; |
2575 | } |
2539 | } |
2576 | |
2540 | |
2577 | /* |
2541 | /* |
2578 | * All right, so we're not in a Multipart message. Phew, took quite |
2542 | * All right, so we're not in a Multipart message. Phew, took quite |
2579 | * long to figure this out. But this might still be a MIME message |
2543 | * long to figure this out. But this might still be a MIME message |
2580 | * body. And if it's a message/partial, we need more special handling |
2544 | * body. And if it's a message/partial, we need more special handling |
2581 | */ |
2545 | */ |
2582 | |
2546 | |
2583 | if (sstate.isfolder && sstate.ismime && sstate.mimestate == MS_BODY && |
2547 | if (sstate.isfolder && sstate.ismime && sstate.mimestate == MS_BODY && |
2584 | _FP_stristr (sstate.envelope.ctype, "message") != NULL && |
2548 | FP_stristr (sstate.envelope.ctype, "message") != NULL && |
2585 | _FP_stristr (sstate.envelope.ctype, "partial") != NULL) { |
2549 | FP_stristr (sstate.envelope.ctype, "partial") != NULL) { |
2586 | |
2550 | |
2587 | result->startpos = ftell (datei); |
2551 | result->startpos = ftell (datei); |
2588 | |
2552 | |
2589 | if (sstate.envelope.partno == 1) { |
2553 | if (sstate.envelope.partno == 1) { |
2590 | /* read local envelope */ |
2554 | /* read local envelope */ |
2591 | UUkillheaders (&localenv); |
2555 | UUkillheaders (&localenv); |
2592 | memset (&localenv, 0, sizeof (headers)); |
2556 | memset (&localenv, 0, sizeof (headers)); |
2593 | |
2557 | |
2594 | /* skip over blank lines first */ |
2558 | /* skip over blank lines first */ |
2595 | prevpos = ftell (datei); |
2559 | prevpos = ftell (datei); |
2596 | while (!feof (datei)) { |
2560 | while (!FP_feof (datei)) { |
2597 | if (_FP_fgets (line, 255, datei) == NULL) |
2561 | if (FP_fgets (line, 1024, datei) == NULL) |
2598 | break; |
2562 | break; |
2599 | line[255] = '\0'; |
|
|
2600 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2563 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2601 | if (!IsLineEmpty (line)) |
2564 | if (!IsLineEmpty (line)) |
2602 | break; |
2565 | break; |
2603 | prevpos = ftell (datei); |
2566 | prevpos = ftell (datei); |
2604 | } |
2567 | } |
2605 | /* Next, read header. But what if there is no subheader? */ |
2568 | /* Next, read header. But what if there is no subheader? */ |
2606 | hcount = 0; |
2569 | hcount = 0; |
2607 | lcount = 0; |
2570 | lcount = 0; |
2608 | preheaders = prevpos; |
2571 | preheaders = prevpos; |
2609 | |
2572 | |
2610 | while (!feof (datei) && !IsLineEmpty (line)) { |
2573 | while (!FP_feof (datei) && !IsLineEmpty (line)) { |
2611 | if (IsKnownHeader (line)) |
2574 | if (IsKnownHeader (line)) |
2612 | hcount++; |
2575 | hcount++; |
2613 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2576 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2614 | if (lcount > WAITHEADER && hcount == 0) { |
2577 | if (lcount > WAITHEADER && hcount == 0) { |
2615 | fseek (datei, preheaders, SEEK_SET); |
2578 | fseek (datei, preheaders, SEEK_SET); |
… | |
… | |
2617 | } |
2580 | } |
2618 | ptr1 = ScanHeaderLine (datei, line); |
2581 | ptr1 = ScanHeaderLine (datei, line); |
2619 | if (ParseHeader (&localenv, ptr1) == NULL) |
2582 | if (ParseHeader (&localenv, ptr1) == NULL) |
2620 | *errcode = UURET_NOMEM; |
2583 | *errcode = UURET_NOMEM; |
2621 | |
2584 | |
2622 | if (_FP_fgets (line, 255, datei) == NULL) |
2585 | if (FP_fgets (line, 1024, datei) == NULL) |
2623 | break; |
2586 | break; |
2624 | line[255] = '\0'; |
|
|
2625 | lcount++; |
2587 | lcount++; |
2626 | } |
2588 | } |
2627 | prevpos = ftell (datei); |
2589 | prevpos = ftell (datei); |
2628 | /* |
2590 | /* |
2629 | * Examine local header. We're mostly interested in the Content-Type |
2591 | * Examine local header. We're mostly interested in the Content-Type |
2630 | * and the Content-Transfer-Encoding. |
2592 | * and the Content-Transfer-Encoding. |
2631 | */ |
2593 | */ |
2632 | if (_FP_stristr (localenv.ctype, "multipart") != NULL) { |
2594 | if (FP_stristr (localenv.ctype, "multipart") != NULL) { |
2633 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2595 | UUMessage (UUMSG_WARNING, uustring (S_MIME_PART_MULTI)); |
2634 | uustring (S_MIME_PART_MULTI)); |
|
|
2635 | } |
2596 | } |
2636 | if (localenv.subject) |
2597 | if (localenv.subject) |
2637 | result->subject = _FP_strdup (localenv.subject); |
2598 | result->subject = FP_strdup (localenv.subject); |
2638 | else |
2599 | else |
2639 | result->subject = _FP_strdup (sstate.envelope.subject); |
2600 | result->subject = FP_strdup (sstate.envelope.subject); |
2640 | |
2601 | |
2641 | if (localenv.from) |
2602 | if (localenv.from) |
2642 | result->origin = _FP_strdup (localenv.from); |
2603 | result->origin = FP_strdup (localenv.from); |
2643 | else |
2604 | else |
2644 | result->origin = _FP_strdup (sstate.envelope.from); |
2605 | result->origin = FP_strdup (sstate.envelope.from); |
2645 | |
2606 | |
2646 | if (localenv.ctype) |
2607 | if (localenv.ctype) |
2647 | result->mimetype = _FP_strdup (localenv.ctype); |
2608 | result->mimetype = FP_strdup (localenv.ctype); |
2648 | else |
2609 | else |
2649 | result->mimetype = _FP_strdup ("text/plain"); |
2610 | result->mimetype = FP_strdup ("text/plain"); |
2650 | |
2611 | |
2651 | if (_FP_stristr (localenv.ctenc, "quoted-printable") != NULL) |
2612 | if (FP_stristr (localenv.ctenc, "quoted-printable") != NULL) |
2652 | result->uudet = QP_ENCODED; |
2613 | result->uudet = QP_ENCODED; |
2653 | else if (_FP_stristr (localenv.ctenc, "base64") != NULL) |
2614 | else if (FP_stristr (localenv.ctenc, "base64") != NULL) |
2654 | result->uudet = B64ENCODED; |
2615 | result->uudet = B64ENCODED; |
2655 | else if (_FP_stristr (localenv.ctenc, "x-uue") != NULL) { |
2616 | else if (FP_stristr (localenv.ctenc, "x-uue") != NULL) { |
2656 | result->uudet = UU_ENCODED; |
2617 | result->uudet = UU_ENCODED; |
2657 | result->begin = result->end = 1; |
2618 | result->begin = result->end = 1; |
2658 | } |
2619 | } |
2659 | else if (_FP_stristr (localenv.ctenc, "x-yenc") != NULL) { |
2620 | else if (FP_stristr (localenv.ctenc, "x-yenc") != NULL) { |
2660 | result->uudet = YENC_ENCODED; |
2621 | result->uudet = YENC_ENCODED; |
2661 | result->begin = result->end = 1; |
2622 | result->begin = result->end = 1; |
2662 | } |
2623 | } |
2663 | else if (_FP_stristr (localenv.ctenc, "7bit") != NULL || |
2624 | else if (FP_stristr (localenv.ctenc, "7bit") != NULL || |
2664 | _FP_stristr (localenv.ctenc, "8bit") != NULL) |
2625 | FP_stristr (localenv.ctenc, "8bit") != NULL) |
2665 | result->uudet = PT_ENCODED; |
2626 | result->uudet = PT_ENCODED; |
2666 | else if (_FP_stristr (localenv.ctype, "multipart") != NULL || |
2627 | else if (FP_stristr (localenv.ctype, "multipart") != NULL || |
2667 | _FP_stristr (localenv.ctype, "message") != NULL) |
2628 | FP_stristr (localenv.ctype, "message") != NULL) |
2668 | result->uudet = PT_ENCODED; |
2629 | result->uudet = PT_ENCODED; |
2669 | |
2630 | |
2670 | /* |
2631 | /* |
2671 | * If we're switched to MIME-only mode, handle as text |
2632 | * If we're switched to MIME-only mode, handle as text |
2672 | */ |
2633 | */ |
… | |
… | |
2699 | } |
2660 | } |
2700 | else if (result->uudet != 0) { |
2661 | else if (result->uudet != 0) { |
2701 | hcount = lcount = 0; |
2662 | hcount = lcount = 0; |
2702 | prevpos = ftell (datei); |
2663 | prevpos = ftell (datei); |
2703 | |
2664 | |
2704 | if (_FP_stristr (localenv.ctype, "message") != NULL && |
2665 | if (FP_stristr (localenv.ctype, "message") != NULL && |
2705 | _FP_stristr (localenv.ctype, "rfc822") != NULL) { |
2666 | FP_stristr (localenv.ctype, "rfc822") != NULL) { |
2706 | /* |
2667 | /* |
2707 | * skip over empty lines and local header |
2668 | * skip over empty lines and local header |
2708 | */ |
2669 | */ |
2709 | preheaders = ftell (datei); |
2670 | preheaders = ftell (datei); |
2710 | while (!feof (datei)) { |
2671 | while (!FP_feof (datei)) { |
2711 | if (_FP_fgets (line, 255, datei) == NULL) |
2672 | if (FP_fgets (line, 1024, datei) == NULL) |
2712 | break; |
2673 | break; |
2713 | line[255] = '\0'; |
|
|
2714 | if (!IsLineEmpty (line)) { |
2674 | if (!IsLineEmpty (line)) { |
2715 | break; |
2675 | break; |
2716 | } |
2676 | } |
2717 | } |
2677 | } |
2718 | |
2678 | |
2719 | while (!feof (datei) && !IsLineEmpty (line)) { |
2679 | while (!FP_feof (datei) && !IsLineEmpty (line)) { |
2720 | if (IsKnownHeader (line)) |
2680 | if (IsKnownHeader (line)) |
2721 | hcount++; |
2681 | hcount++; |
2722 | lcount++; |
2682 | lcount++; |
2723 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2683 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2724 | break; |
2684 | break; |
2725 | |
2685 | |
2726 | if (_FP_fgets (line, 255, datei) == NULL) |
2686 | if (FP_fgets (line, 1024, datei) == NULL) |
2727 | break; |
2687 | break; |
2728 | line[255] = '\0'; |
|
|
2729 | } |
2688 | } |
2730 | if (hcount < hlcount.afternl) |
2689 | if (hcount < hlcount.afternl) |
2731 | fseek (datei, preheaders, SEEK_SET); |
2690 | fseek (datei, preheaders, SEEK_SET); |
2732 | hcount = lcount = 0; |
2691 | hcount = lcount = 0; |
2733 | } |
2692 | } |
2734 | |
2693 | |
2735 | /* |
2694 | /* |
2736 | * look for next header |
2695 | * look for next header |
2737 | */ |
2696 | */ |
2738 | |
2697 | |
2739 | while (!feof (datei)) { |
2698 | while (!FP_feof (datei)) { |
2740 | if (_FP_fgets (line, 255, datei) == NULL) |
2699 | if (FP_fgets (line, 1024, datei) == NULL) |
2741 | break; |
2700 | break; |
2742 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2701 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2743 | if (ferror (datei)) |
2702 | if (ferror (datei)) |
2744 | break; |
2703 | break; |
2745 | line[255] = '\0'; |
|
|
2746 | |
2704 | |
2747 | if ((vflag = IsKnownHeader (line))) { |
2705 | if ((vflag = IsKnownHeader (line))) { |
2748 | (void) ScanHeaderLine (datei, line); |
2706 | (void) ScanHeaderLine (datei, line); |
2749 | |
2707 | |
2750 | if (result->uudet != PT_ENCODED || vflag == 1) { |
2708 | if (result->uudet != PT_ENCODED || vflag == 1) { |
… | |
… | |
2793 | } |
2751 | } |
2794 | /* |
2752 | /* |
2795 | * produce result |
2753 | * produce result |
2796 | */ |
2754 | */ |
2797 | if (localenv.fname) { |
2755 | if (localenv.fname) { |
2798 | _FP_free (result->filename); |
2756 | FP_free (result->filename); |
2799 | if ((result->filename = _FP_strdup (localenv.fname)) == NULL) |
2757 | if ((result->filename = FP_strdup (localenv.fname)) == NULL) |
2800 | *errcode = UURET_NOMEM; |
2758 | *errcode = UURET_NOMEM; |
2801 | } |
2759 | } |
2802 | else if (sstate.envelope.fname) { |
2760 | else if (sstate.envelope.fname) { |
2803 | _FP_free (result->filename); |
2761 | FP_free (result->filename); |
2804 | if ((result->filename = _FP_strdup (sstate.envelope.fname)) == NULL) |
2762 | if ((result->filename = FP_strdup (sstate.envelope.fname)) == NULL) |
2805 | *errcode = UURET_NOMEM; |
2763 | *errcode = UURET_NOMEM; |
2806 | } |
2764 | } |
2807 | else if ((result->uudet==QP_ENCODED || result->uudet==PT_ENCODED) && |
2765 | else if ((result->uudet==QP_ENCODED || result->uudet==PT_ENCODED) && |
2808 | result->filename == NULL) { |
2766 | result->filename == NULL) { |
2809 | sprintf (line, "%04d.txt", ++mimseqno); |
2767 | sprintf (line, "%04d.txt", ++mimseqno); |
2810 | if ((result->filename = _FP_strdup (line)) == NULL) |
2768 | if ((result->filename = FP_strdup (line)) == NULL) |
2811 | *errcode = UURET_NOMEM; |
2769 | *errcode = UURET_NOMEM; |
2812 | } |
2770 | } |
2813 | else { |
2771 | else { |
2814 | /* assign a filename lateron */ |
2772 | /* assign a filename lateron */ |
2815 | } |
2773 | } |
2816 | if (result->subject == NULL) { |
2774 | if (result->subject == NULL) { |
2817 | if (sstate.envelope.subject) |
2775 | if (sstate.envelope.subject) |
2818 | result->subject = _FP_strdup (sstate.envelope.subject); |
2776 | result->subject = FP_strdup (sstate.envelope.subject); |
2819 | } |
2777 | } |
2820 | result->partno = sstate.envelope.partno; |
2778 | result->partno = sstate.envelope.partno; |
2821 | result->maxpno = sstate.envelope.numparts; |
2779 | result->maxpno = sstate.envelope.numparts; |
2822 | result->flags = FL_PARTIAL | |
2780 | result->flags = FL_PARTIAL | |
2823 | ((res==1 || uu_fast_scanning) ? FL_PROPER : 0) | |
2781 | ((res==1 || uu_fast_scanning) ? FL_PROPER : 0) | |
2824 | ((uu_fast_scanning) ? FL_TOEND : 0); |
2782 | ((uu_fast_scanning) ? FL_TOEND : 0); |
2825 | result->mimeid = _FP_strdup (sstate.envelope.mimeid); |
2783 | result->mimeid = FP_strdup (sstate.envelope.mimeid); |
2826 | if (result->partno == 1) |
2784 | if (result->partno == 1) |
2827 | result->begin = 1; |
2785 | result->begin = 1; |
2828 | |
2786 | |
2829 | if (uu_fast_scanning) |
2787 | if (uu_fast_scanning) |
2830 | result->length = progress.fsize - result->startpos; |
2788 | result->length = progress.fsize - result->startpos; |
2831 | else |
2789 | else |
2832 | result->length = prevpos - result->startpos; |
2790 | result->length = prevpos - result->startpos; |
2833 | |
2791 | |
2834 | if (result->sfname == NULL) |
2792 | if (result->sfname == NULL) |
2835 | result->sfname = _FP_strdup (fname); |
2793 | result->sfname = FP_strdup (fname); |
2836 | |
2794 | |
2837 | if (result->mode == 0) |
2795 | if (result->mode == 0) |
2838 | result->mode = 0644; |
2796 | result->mode = 0644; |
2839 | |
2797 | |
2840 | /* |
2798 | /* |
… | |
… | |
2846 | * new headers found |
2804 | * new headers found |
2847 | */ |
2805 | */ |
2848 | sstate.isfolder = 1; |
2806 | sstate.isfolder = 1; |
2849 | sstate.ismime = 0; |
2807 | sstate.ismime = 0; |
2850 | sstate.mimestate = MS_HEADERS; |
2808 | sstate.mimestate = MS_HEADERS; |
2851 | |
2809 | |
2852 | UUkillheaders (&sstate.envelope); |
2810 | UUkillheaders (&sstate.envelope); |
2853 | memset (&sstate.envelope, 0, sizeof (headers)); |
2811 | memset (&sstate.envelope, 0, sizeof (headers)); |
2854 | } |
2812 | } |
2855 | else { |
2813 | else { |
2856 | /* |
2814 | /* |
… | |
… | |
2874 | * decode a plain-text segment with a filename. |
2832 | * decode a plain-text segment with a filename. |
2875 | */ |
2833 | */ |
2876 | |
2834 | |
2877 | if (sstate.isfolder && sstate.ismime && |
2835 | if (sstate.isfolder && sstate.ismime && |
2878 | sstate.mimestate == MS_BODY && |
2836 | sstate.mimestate == MS_BODY && |
2879 | (_FP_stristr (sstate.envelope.ctenc, "quoted-printable") != NULL || |
2837 | (FP_stristr (sstate.envelope.ctenc, "quoted-printable") != NULL || |
2880 | _FP_stristr (sstate.envelope.ctenc, "base64") != NULL || |
2838 | FP_stristr (sstate.envelope.ctenc, "base64") != NULL || |
2881 | _FP_stristr (sstate.envelope.ctenc, "x-uue") != NULL || |
2839 | FP_stristr (sstate.envelope.ctenc, "x-uue") != NULL || |
2882 | _FP_stristr (sstate.envelope.ctenc, "x-yenc") != NULL || |
2840 | FP_stristr (sstate.envelope.ctenc, "x-yenc") != NULL || |
2883 | _FP_stristr (sstate.envelope.ctype, "message") != NULL || |
2841 | FP_stristr (sstate.envelope.ctype, "message") != NULL || |
2884 | sstate.envelope.fname != NULL)) { |
2842 | sstate.envelope.fname != NULL)) { |
2885 | |
2843 | |
2886 | if (sstate.envelope.subject) |
2844 | if (sstate.envelope.subject) |
2887 | result->subject = _FP_strdup (sstate.envelope.subject); |
2845 | result->subject = FP_strdup (sstate.envelope.subject); |
2888 | if (sstate.envelope.from) |
2846 | if (sstate.envelope.from) |
2889 | result->origin = _FP_strdup (sstate.envelope.from); |
2847 | result->origin = FP_strdup (sstate.envelope.from); |
2890 | |
2848 | |
2891 | if (sstate.envelope.ctype) |
2849 | if (sstate.envelope.ctype) |
2892 | result->mimetype = _FP_strdup (sstate.envelope.ctype); |
2850 | result->mimetype = FP_strdup (sstate.envelope.ctype); |
2893 | else |
2851 | else |
2894 | result->mimetype = _FP_strdup ("text/plain"); |
2852 | result->mimetype = FP_strdup ("text/plain"); |
2895 | |
2853 | |
2896 | if (_FP_stristr (sstate.envelope.ctenc, "quoted-printable") != NULL) |
2854 | if (FP_stristr (sstate.envelope.ctenc, "quoted-printable") != NULL) |
2897 | result->uudet = QP_ENCODED; |
2855 | result->uudet = QP_ENCODED; |
2898 | else if (_FP_stristr (sstate.envelope.ctenc, "base64") != NULL) |
2856 | else if (FP_stristr (sstate.envelope.ctenc, "base64") != NULL) |
2899 | result->uudet = B64ENCODED; |
2857 | result->uudet = B64ENCODED; |
2900 | else if (_FP_stristr (sstate.envelope.ctenc, "x-uue") != NULL) { |
2858 | else if (FP_stristr (sstate.envelope.ctenc, "x-uue") != NULL) { |
2901 | result->uudet = UU_ENCODED; |
2859 | result->uudet = UU_ENCODED; |
2902 | result->begin = result->end = 1; |
2860 | result->begin = result->end = 1; |
2903 | } |
2861 | } |
2904 | else if (_FP_stristr (sstate.envelope.ctenc, "x-yenc") != NULL) { |
2862 | else if (FP_stristr (sstate.envelope.ctenc, "x-yenc") != NULL) { |
2905 | result->uudet = YENC_ENCODED; |
2863 | result->uudet = YENC_ENCODED; |
2906 | } |
2864 | } |
2907 | else if (_FP_stristr (sstate.envelope.ctenc, "7bit") != NULL || |
2865 | else if (FP_stristr (sstate.envelope.ctenc, "7bit") != NULL || |
2908 | _FP_stristr (sstate.envelope.ctenc, "8bit") != NULL) |
2866 | FP_stristr (sstate.envelope.ctenc, "8bit") != NULL) |
2909 | result->uudet = PT_ENCODED; |
2867 | result->uudet = PT_ENCODED; |
2910 | else if (_FP_stristr (sstate.envelope.ctype, "multipart") != NULL || |
2868 | else if (FP_stristr (sstate.envelope.ctype, "multipart") != NULL || |
2911 | _FP_stristr (sstate.envelope.ctype, "message") != NULL || |
2869 | FP_stristr (sstate.envelope.ctype, "message") != NULL || |
2912 | sstate.envelope.fname != NULL) |
2870 | sstate.envelope.fname != NULL) |
2913 | result->uudet = PT_ENCODED; |
2871 | result->uudet = PT_ENCODED; |
2914 | |
2872 | |
2915 | /* |
2873 | /* |
2916 | * If we're switched to MIME-only mode, handle as text |
2874 | * If we're switched to MIME-only mode, handle as text |
… | |
… | |
2919 | if (uu_more_mime >= 2 && !result->uudet) { |
2877 | if (uu_more_mime >= 2 && !result->uudet) { |
2920 | result->uudet = PT_ENCODED; |
2878 | result->uudet = PT_ENCODED; |
2921 | } |
2879 | } |
2922 | |
2880 | |
2923 | result->startpos = prevpos = ftell (datei); |
2881 | result->startpos = prevpos = ftell (datei); |
2924 | |
2882 | |
2925 | /* |
2883 | /* |
2926 | * If this is Quoted-Printable or Plain Text, just try looking |
2884 | * If this is Quoted-Printable or Plain Text, just try looking |
2927 | * for the next message header. If uu_fast_scanning, we know |
2885 | * for the next message header. If uu_fast_scanning, we know |
2928 | * there won't be more headers. |
2886 | * there won't be more headers. |
2929 | * If it is a "trivial" (non-embedded) message/rfc822, skip over |
2887 | * If it is a "trivial" (non-embedded) message/rfc822, skip over |
… | |
… | |
2935 | } |
2893 | } |
2936 | else if (result->uudet != 0) { |
2894 | else if (result->uudet != 0) { |
2937 | hcount = lcount = 0; |
2895 | hcount = lcount = 0; |
2938 | prevpos = ftell (datei); |
2896 | prevpos = ftell (datei); |
2939 | |
2897 | |
2940 | if (_FP_stristr (sstate.envelope.ctype, "message") != NULL && |
2898 | if (FP_stristr (sstate.envelope.ctype, "message") != NULL && |
2941 | _FP_stristr (sstate.envelope.ctype, "rfc822") != NULL) { |
2899 | FP_stristr (sstate.envelope.ctype, "rfc822") != NULL) { |
2942 | /* |
2900 | /* |
2943 | * skip over empty lines and local header |
2901 | * skip over empty lines and local header |
2944 | */ |
2902 | */ |
2945 | preheaders = ftell (datei); |
2903 | preheaders = ftell (datei); |
2946 | while (!feof (datei)) { |
2904 | while (!FP_feof (datei)) { |
2947 | if (_FP_fgets (line, 255, datei) == NULL) |
2905 | if (FP_fgets (line, 1024, datei) == NULL) |
2948 | break; |
2906 | break; |
2949 | line[255] = '\0'; |
|
|
2950 | if (!IsLineEmpty (line)) { |
2907 | if (!IsLineEmpty (line)) { |
2951 | break; |
2908 | break; |
2952 | } |
2909 | } |
2953 | } |
2910 | } |
2954 | |
2911 | |
2955 | while (!feof (datei) && !IsLineEmpty (line)) { |
2912 | while (!FP_feof (datei) && !IsLineEmpty (line)) { |
2956 | if (IsKnownHeader (line)) |
2913 | if (IsKnownHeader (line)) |
2957 | hcount++; |
2914 | hcount++; |
2958 | lcount++; |
2915 | lcount++; |
2959 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2916 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2960 | break; |
2917 | break; |
2961 | |
2918 | |
2962 | if (_FP_fgets (line, 255, datei) == NULL) |
2919 | if (FP_fgets (line, 1024, datei) == NULL) |
2963 | break; |
2920 | break; |
2964 | line[255] = '\0'; |
|
|
2965 | } |
2921 | } |
2966 | if (hcount < hlcount.afternl) |
2922 | if (hcount < hlcount.afternl) |
2967 | fseek (datei, preheaders, SEEK_SET); |
2923 | fseek (datei, preheaders, SEEK_SET); |
2968 | hcount = lcount = 0; |
2924 | hcount = lcount = 0; |
2969 | } |
2925 | } |
2970 | |
2926 | |
2971 | /* |
2927 | /* |
2972 | * look for next header |
2928 | * look for next header |
2973 | */ |
2929 | */ |
2974 | |
2930 | |
2975 | while (!feof (datei)) { |
2931 | while (!FP_feof (datei)) { |
2976 | if (_FP_fgets (line, 255, datei) == NULL) |
2932 | if (FP_fgets (line, 1024, datei) == NULL) |
2977 | break; |
2933 | break; |
2978 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2934 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2979 | if (ferror (datei)) |
2935 | if (ferror (datei)) |
2980 | break; |
2936 | break; |
2981 | line[255] = '\0'; |
|
|
2982 | |
2937 | |
2983 | if (IsKnownHeader (line)) { |
2938 | if (IsKnownHeader (line)) { |
2984 | (void) ScanHeaderLine (datei, line); |
2939 | (void) ScanHeaderLine (datei, line); |
2985 | if (hcount == 0) |
2940 | if (hcount == 0) |
2986 | preheaders = prevpos; |
2941 | preheaders = prevpos; |
… | |
… | |
3027 | } |
2982 | } |
3028 | /* |
2983 | /* |
3029 | * produce result |
2984 | * produce result |
3030 | */ |
2985 | */ |
3031 | if (sstate.envelope.fname) { |
2986 | if (sstate.envelope.fname) { |
3032 | _FP_free (result->filename); |
2987 | FP_free (result->filename); |
3033 | if ((result->filename = _FP_strdup (sstate.envelope.fname)) == NULL) |
2988 | if ((result->filename = FP_strdup (sstate.envelope.fname)) == NULL) |
3034 | *errcode = UURET_NOMEM; |
2989 | *errcode = UURET_NOMEM; |
3035 | } |
2990 | } |
3036 | else if ((result->uudet==QP_ENCODED||result->uudet==PT_ENCODED) && |
2991 | else if ((result->uudet==QP_ENCODED||result->uudet==PT_ENCODED) && |
3037 | result->filename == NULL) { |
2992 | result->filename == NULL) { |
3038 | sprintf (line, "%04d.txt", ++mimseqno); |
2993 | sprintf (line, "%04d.txt", ++mimseqno); |
3039 | if ((result->filename = _FP_strdup (line)) == NULL) |
2994 | if ((result->filename = FP_strdup (line)) == NULL) |
3040 | *errcode = UURET_NOMEM; |
2995 | *errcode = UURET_NOMEM; |
3041 | } |
2996 | } |
3042 | else { |
2997 | else { |
3043 | /* assign a filename lateron */ |
2998 | /* assign a filename lateron */ |
3044 | } |
2999 | } |
3045 | if (result->subject == NULL) { |
3000 | if (result->subject == NULL) { |
3046 | if (sstate.envelope.subject) |
3001 | if (sstate.envelope.subject) |
3047 | result->subject = _FP_strdup (sstate.envelope.subject); |
3002 | result->subject = FP_strdup (sstate.envelope.subject); |
3048 | } |
3003 | } |
3049 | result->flags = ((res==1||uu_fast_scanning)?FL_PROPER:0) | |
3004 | result->flags = ((res==1||uu_fast_scanning)?FL_PROPER:0) | |
3050 | ((uu_fast_scanning) ? FL_TOEND : 0); |
3005 | ((uu_fast_scanning) ? FL_TOEND : 0); |
3051 | result->mimeid = _FP_strdup (sstate.envelope.mimeid); |
3006 | result->mimeid = FP_strdup (sstate.envelope.mimeid); |
3052 | |
3007 | |
3053 | if (uu_fast_scanning) |
3008 | if (uu_fast_scanning) |
3054 | result->length = progress.fsize - result->startpos; |
3009 | result->length = progress.fsize - result->startpos; |
3055 | else |
3010 | else |
3056 | result->length = prevpos - result->startpos; |
3011 | result->length = prevpos - result->startpos; |
3057 | |
3012 | |
3058 | if (result->sfname == NULL) |
3013 | if (result->sfname == NULL) |
3059 | result->sfname = _FP_strdup (fname); |
3014 | result->sfname = FP_strdup (fname); |
3060 | |
3015 | |
3061 | if (result->mode == 0) |
3016 | if (result->mode == 0) |
3062 | result->mode = 0644; |
3017 | result->mode = 0644; |
3063 | |
3018 | |
3064 | /* |
3019 | /* |
… | |
… | |
3097 | * and if the following line is a proper Content-Type header. BTW, |
3052 | * and if the following line is a proper Content-Type header. BTW, |
3098 | * we know that sstate.envelope.boundary is NULL, or we wouldn't |
3053 | * we know that sstate.envelope.boundary is NULL, or we wouldn't |
3099 | * be here! |
3054 | * be here! |
3100 | */ |
3055 | */ |
3101 | |
3056 | |
3102 | if ((sstate.envelope.ctype == NULL || |
3057 | if ((!sstate.envelope.ctype || FP_stristr (sstate.envelope.ctype, "multipart")) |
3103 | _FP_stristr (sstate.envelope.ctype, "multipart") != NULL) && |
|
|
3104 | !uu_more_mime) { |
3058 | && !uu_more_mime) { |
3105 | prevpos = ftell (datei); |
3059 | prevpos = ftell (datei); |
3106 | while (!feof (datei)) { |
3060 | while (!FP_feof (datei)) { |
3107 | if (_FP_fgets (line, 255, datei) == NULL) { |
3061 | if (FP_fgets (line, 1024, datei) == NULL) |
3108 | line[0] = '\0'; |
|
|
3109 | break; |
3062 | break; |
3110 | } |
|
|
3111 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
3063 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
3112 | if (!IsLineEmpty (line)) |
3064 | if (!IsLineEmpty (line)) |
3113 | break; |
3065 | break; |
3114 | } |
3066 | } |
3115 | if (line[0] == '-' && line[1] == '-' && |
3067 | if (line[0] == '-' && line[1] == '-' && |
3116 | !IsLineEmpty (line+2) && !feof (datei)) { |
3068 | !IsLineEmpty (line+2) && !FP_feof (datei)) { |
3117 | ptr1 = _FP_strrstr (line+2, "--"); |
3069 | ptr1 = FP_strrstr (line+2, "--"); |
3118 | ptr2 = ScanHeaderLine (datei, NULL); |
3070 | ptr2 = ScanHeaderLine (datei, NULL); |
3119 | if ((ptr1 == NULL || (*(ptr1+2) != '\012' && *(ptr1+2) != '\015')) && |
3071 | if ((ptr1 == NULL || ptr1[2]) && |
3120 | ptr2 && _FP_strnicmp (ptr2, "Content-", 8) == 0) { |
3072 | ptr2 && FP_strnicmp_fast (ptr2, "Content-", 8) == 0) { |
3121 | /* |
3073 | /* |
3122 | * hmm, okay, let's do it! |
3074 | * hmm, okay, let's do it! |
3123 | */ |
3075 | */ |
3124 | sstate.isfolder = 1; |
3076 | sstate.isfolder = 1; |
3125 | sstate.ismime = 1; |
3077 | sstate.ismime = 1; |
… | |
… | |
3130 | ptr1 = line+2; |
3082 | ptr1 = line+2; |
3131 | while (*ptr1 && !isspace(*ptr1)) |
3083 | while (*ptr1 && !isspace(*ptr1)) |
3132 | ptr1++; |
3084 | ptr1++; |
3133 | *ptr1 = '\0'; |
3085 | *ptr1 = '\0'; |
3134 | |
3086 | |
3135 | sstate.envelope.mimevers = _FP_strdup ("1.0"); |
3087 | sstate.envelope.mimevers = FP_strdup ("1.0"); |
3136 | sstate.envelope.boundary = _FP_strdup (line+2); |
3088 | sstate.envelope.boundary = FP_strdup (line+2); |
3137 | |
3089 | |
3138 | /* |
3090 | /* |
3139 | * need restart |
3091 | * need restart |
3140 | */ |
3092 | */ |
3141 | |
3093 | |
3142 | fseek (datei, prevpos, SEEK_SET); |
3094 | fseek (datei, prevpos, SEEK_SET); |
3143 | |
3095 | |
3144 | _FP_free (result); |
3096 | FP_free (result); |
3145 | return NULL; |
3097 | return NULL; |
3146 | } |
3098 | } |
3147 | } |
3099 | } |
3148 | fseek (datei, prevpos, SEEK_SET); |
3100 | fseek (datei, prevpos, SEEK_SET); |
3149 | } |
3101 | } |
… | |
… | |
3153 | * Freestyle time. Anyway, if this seems to be a Mime message, |
3105 | * Freestyle time. Anyway, if this seems to be a Mime message, |
3154 | * don't allow the minimal Base64 handling. |
3106 | * don't allow the minimal Base64 handling. |
3155 | */ |
3107 | */ |
3156 | |
3108 | |
3157 | if (sstate.envelope.subject) |
3109 | if (sstate.envelope.subject) |
3158 | result->subject = _FP_strdup (sstate.envelope.subject); |
3110 | result->subject = FP_strdup (sstate.envelope.subject); |
|
|
3111 | |
3159 | if (sstate.envelope.from) |
3112 | if (sstate.envelope.from) |
3160 | result->origin = _FP_strdup (sstate.envelope.from); |
3113 | result->origin = FP_strdup (sstate.envelope.from); |
3161 | |
3114 | |
3162 | if (sstate.envelope.ctype) |
3115 | if (sstate.envelope.ctype) |
3163 | result->mimetype = _FP_strdup (sstate.envelope.ctype); |
3116 | result->mimetype = FP_strdup (sstate.envelope.ctype); |
3164 | |
3117 | |
3165 | if ((res=ScanData (datei, fname, errcode, NULL, |
3118 | if ((res=ScanData (datei, fname, errcode, NULL, |
3166 | sstate.ismime, 1, result))==-1) { |
3119 | sstate.ismime, 1, result))==-1) { |
3167 | /* oops, something went wrong */ |
3120 | /* oops, something went wrong */ |
3168 | sstate.isfolder = 0; |
3121 | sstate.isfolder = 0; |
3169 | sstate.ismime = 0; |
3122 | sstate.ismime = 0; |
3170 | UUkillfread (result); |
3123 | UUkillfread (result); |
… | |
… | |
3185 | /* |
3138 | /* |
3186 | * prevent replacing the filename found on the =ybegin line |
3139 | * prevent replacing the filename found on the =ybegin line |
3187 | */ |
3140 | */ |
3188 | } |
3141 | } |
3189 | else if (sstate.envelope.fname) { |
3142 | else if (sstate.envelope.fname) { |
3190 | _FP_free (result->filename); |
3143 | FP_free (result->filename); |
3191 | if ((result->filename = _FP_strdup (sstate.envelope.fname)) == NULL) |
3144 | if ((result->filename = FP_strdup (sstate.envelope.fname)) == NULL) |
3192 | *errcode = UURET_NOMEM; |
3145 | *errcode = UURET_NOMEM; |
3193 | } |
3146 | } |
3194 | else if ((result->uudet==QP_ENCODED||result->uudet==PT_ENCODED) && |
3147 | else if ((result->uudet==QP_ENCODED||result->uudet==PT_ENCODED) && |
3195 | result->filename == NULL) { |
3148 | result->filename == NULL) { |
3196 | sprintf (line, "%04d.txt", ++mimseqno); |
3149 | sprintf (line, "%04d.txt", ++mimseqno); |
3197 | if ((result->filename = _FP_strdup (line)) == NULL) |
3150 | if ((result->filename = FP_strdup (line)) == NULL) |
3198 | *errcode = UURET_NOMEM; |
3151 | *errcode = UURET_NOMEM; |
3199 | } |
3152 | } |
3200 | else { |
3153 | else { |
3201 | /* assign a filename lateron */ |
3154 | /* assign a filename lateron */ |
3202 | } |
3155 | } |
3203 | |
3156 | |
3204 | if (result->subject == NULL) { |
3157 | if (result->subject == NULL) { |
3205 | if (sstate.envelope.subject) |
3158 | if (sstate.envelope.subject) |
3206 | result->subject = _FP_strdup (sstate.envelope.subject); |
3159 | result->subject = FP_strdup (sstate.envelope.subject); |
3207 | } |
3160 | } |
3208 | |
3161 | |
3209 | result->flags = (result->uudet==PT_ENCODED)?FL_SINGLE:0; |
3162 | result->flags = (result->uudet==PT_ENCODED)?FL_SINGLE:0; |
3210 | result->mimeid = _FP_strdup (sstate.envelope.mimeid); |
3163 | result->mimeid = FP_strdup (sstate.envelope.mimeid); |
3211 | result->length = ftell (datei) - result->startpos; |
3164 | result->length = ftell (datei) - result->startpos; |
3212 | |
3165 | |
3213 | if (result->mode == 0) |
3166 | if (result->mode == 0) |
3214 | result->mode = 0644; |
3167 | result->mode = 0644; |
3215 | |
3168 | |
3216 | if (result->sfname == NULL) |
3169 | if (result->sfname == NULL) |
3217 | result->sfname = _FP_strdup (fname); |
3170 | result->sfname = FP_strdup (fname); |
3218 | |
3171 | |
3219 | if (res == 1) { |
3172 | if (res == 1) { |
3220 | /* |
3173 | /* |
3221 | * new headers found |
3174 | * new headers found |
3222 | */ |
3175 | */ |
… | |
… | |
3245 | UUkillheaders (&localenv); |
3198 | UUkillheaders (&localenv); |
3246 | |
3199 | |
3247 | while (mssdepth) { |
3200 | while (mssdepth) { |
3248 | mssdepth--; |
3201 | mssdepth--; |
3249 | UUkillheaders (&(multistack[mssdepth].envelope)); |
3202 | UUkillheaders (&(multistack[mssdepth].envelope)); |
3250 | _FP_free (multistack[mssdepth].source); |
3203 | FP_free (multistack[mssdepth].source); |
3251 | } |
3204 | } |
3252 | |
3205 | |
3253 | return NULL; |
3206 | return NULL; |
3254 | } |
3207 | } |
3255 | |
3208 | |