… | |
… | |
34 | |
34 | |
35 | #include <stdio.h> |
35 | #include <stdio.h> |
36 | #include <ctype.h> |
36 | #include <ctype.h> |
37 | #include <stdlib.h> |
37 | #include <stdlib.h> |
38 | #include <string.h> |
38 | #include <string.h> |
39 | |
|
|
40 | #ifdef HAVE_MALLOC_H |
|
|
41 | #include <malloc.h> |
39 | #include <errno.h> |
42 | #endif |
40 | |
43 | #ifdef HAVE_UNISTD_H |
41 | #ifdef HAVE_UNISTD_H |
44 | #include <unistd.h> |
42 | #include <unistd.h> |
45 | #endif |
|
|
46 | #ifdef HAVE_MEMORY_H |
|
|
47 | #include <memory.h> |
|
|
48 | #endif |
|
|
49 | #ifdef HAVE_ERRNO_H |
|
|
50 | #include <errno.h> |
|
|
51 | #endif |
43 | #endif |
52 | |
44 | |
53 | #include <uudeview.h> |
45 | #include <uudeview.h> |
54 | #include <uuint.h> |
46 | #include <uuint.h> |
55 | #include <fptools.h> |
47 | #include <fptools.h> |
… | |
… | |
134 | |
126 | |
135 | /* |
127 | /* |
136 | * Macro: print cancellation message in UUScanPart |
128 | * Macro: print cancellation message in UUScanPart |
137 | */ |
129 | */ |
138 | |
130 | |
139 | #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; } |
140 | |
132 | |
141 | /* |
133 | /* |
142 | * 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. |
143 | */ |
135 | */ |
144 | |
136 | |
… | |
… | |
635 | /* |
627 | /* |
636 | * Make Busy Polls |
628 | * Make Busy Polls |
637 | */ |
629 | */ |
638 | |
630 | |
639 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
631 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
640 | UUMessage (uuscan_id, __LINE__, UUMSG_NOTE, |
632 | UUMessage (UUMSG_NOTE, uustring (S_SCAN_CANCEL)); |
641 | uustring (S_SCAN_CANCEL)); |
|
|
642 | *errcode = UURET_CANCEL; |
633 | *errcode = UURET_CANCEL; |
643 | break; |
634 | break; |
644 | } |
635 | } |
645 | |
636 | |
646 | if (IsLineEmpty (line)) { /* line empty? */ |
637 | if (IsLineEmpty (line)) { /* line empty? */ |
… | |
… | |
1197 | while (!FP_feof (datei)) { |
1188 | while (!FP_feof (datei)) { |
1198 | /* |
1189 | /* |
1199 | * Make Busy Polls |
1190 | * Make Busy Polls |
1200 | */ |
1191 | */ |
1201 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
1192 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) { |
1202 | UUMessage (uuscan_id, __LINE__, UUMSG_NOTE, |
1193 | UUMessage (UUMSG_NOTE, uustring (S_SCAN_CANCEL)); |
1203 | uustring (S_SCAN_CANCEL)); |
|
|
1204 | *errcode = UURET_CANCEL; |
1194 | *errcode = UURET_CANCEL; |
1205 | break; |
1195 | break; |
1206 | } |
1196 | } |
1207 | |
1197 | |
1208 | oldposition = ftell (datei); |
1198 | oldposition = ftell (datei); |
… | |
… | |
1687 | if (sstate.envelope.mimevers != NULL) { |
1677 | if (sstate.envelope.mimevers != NULL) { |
1688 | /* this is a MIME file. check the Content-Type */ |
1678 | /* this is a MIME file. check the Content-Type */ |
1689 | sstate.ismime = 1; |
1679 | sstate.ismime = 1; |
1690 | if (FP_stristr (sstate.envelope.ctype, "multipart") != NULL) { |
1680 | if (FP_stristr (sstate.envelope.ctype, "multipart") != NULL) { |
1691 | if (sstate.envelope.boundary == NULL) { |
1681 | if (sstate.envelope.boundary == NULL) { |
1692 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1682 | UUMessage (UUMSG_WARNING, uustring (S_MIME_NO_BOUNDARY)); |
1693 | uustring (S_MIME_NO_BOUNDARY)); |
|
|
1694 | sstate.mimestate = MS_BODY; |
1683 | sstate.mimestate = MS_BODY; |
1695 | FP_free (sstate.envelope.ctype); |
1684 | FP_free (sstate.envelope.ctype); |
1696 | sstate.envelope.ctype = FP_strdup ("text/plain"); |
1685 | sstate.envelope.ctype = FP_strdup ("text/plain"); |
1697 | } |
1686 | } |
1698 | else { |
1687 | else { |
… | |
… | |
1744 | lcount++; |
1733 | lcount++; |
1745 | |
1734 | |
1746 | prevpos = ftell (datei); |
1735 | prevpos = ftell (datei); |
1747 | } |
1736 | } |
1748 | if (FP_feof (datei) || ferror (datei)) { |
1737 | if (FP_feof (datei) || ferror (datei)) { |
1749 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1738 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
1750 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
1751 | /* |
1739 | /* |
1752 | * restart and try again; don't restart if uu_fast_scanning |
1740 | * restart and try again; don't restart if uu_fast_scanning |
1753 | */ |
1741 | */ |
1754 | sstate.isfolder = 0; |
1742 | sstate.isfolder = 0; |
1755 | sstate.ismime = 0; |
1743 | sstate.ismime = 0; |
… | |
… | |
1772 | else { |
1760 | else { |
1773 | sstate.mimestate = MS_SUBPART; |
1761 | sstate.mimestate = MS_SUBPART; |
1774 | } |
1762 | } |
1775 | } |
1763 | } |
1776 | else { /* shouldn't happen */ |
1764 | else { /* shouldn't happen */ |
1777 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1765 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
1778 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
1779 | /* |
1766 | /* |
1780 | * restart and try again; don't restart if uu_fast_scanning |
1767 | * restart and try again; don't restart if uu_fast_scanning |
1781 | */ |
1768 | */ |
1782 | sstate.isfolder = 0; |
1769 | sstate.isfolder = 0; |
1783 | sstate.ismime = 0; |
1770 | sstate.ismime = 0; |
… | |
… | |
1987 | } |
1974 | } |
1988 | result->length = prevpos - result->startpos; |
1975 | result->length = prevpos - result->startpos; |
1989 | *errcode = UURET_CONT; |
1976 | *errcode = UURET_CONT; |
1990 | } |
1977 | } |
1991 | else if (mssdepth > 0) { |
1978 | else if (mssdepth > 0) { |
1992 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
1979 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
1993 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
1994 | /* |
1980 | /* |
1995 | * restart and try again; don't restart if uu_fast_scanning |
1981 | * restart and try again; don't restart if uu_fast_scanning |
1996 | */ |
1982 | */ |
1997 | sstate.isfolder = 0; |
1983 | sstate.isfolder = 0; |
1998 | sstate.ismime = 0; |
1984 | sstate.ismime = 0; |
… | |
… | |
2153 | |
2139 | |
2154 | if (FP_stristr (localenv.ctype, "multipart") != NULL) { |
2140 | if (FP_stristr (localenv.ctype, "multipart") != NULL) { |
2155 | /* oh no, not again */ |
2141 | /* oh no, not again */ |
2156 | if (mssdepth >= MSMAXDEPTH) { |
2142 | if (mssdepth >= MSMAXDEPTH) { |
2157 | /* Argh, what an isane message. Treat as plain text */ |
2143 | /* Argh, what an isane message. Treat as plain text */ |
2158 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2144 | UUMessage (UUMSG_WARNING, uustring (S_MIME_MULTI_DEPTH)); |
2159 | uustring (S_MIME_MULTI_DEPTH)); |
|
|
2160 | } |
2145 | } |
2161 | else if (localenv.boundary == NULL) { |
2146 | else if (localenv.boundary == NULL) { |
2162 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2147 | UUMessage (UUMSG_WARNING, uustring (S_MIME_NO_BOUNDARY)); |
2163 | uustring (S_MIME_NO_BOUNDARY)); |
|
|
2164 | } |
2148 | } |
2165 | else { |
2149 | else { |
2166 | memcpy (&multistack[mssdepth], &sstate, sizeof (scanstate)); |
2150 | memcpy (&multistack[mssdepth], &sstate, sizeof (scanstate)); |
2167 | memcpy (&sstate.envelope, &localenv, sizeof (headers)); |
2151 | memcpy (&sstate.envelope, &localenv, sizeof (headers)); |
2168 | memset (&localenv, 0, sizeof (headers)); |
2152 | memset (&localenv, 0, sizeof (headers)); |
… | |
… | |
2270 | sstate.mimestate = MS_EPILOGUE; |
2254 | sstate.mimestate = MS_EPILOGUE; |
2271 | else |
2255 | else |
2272 | sstate.mimestate = MS_SUBPART; |
2256 | sstate.mimestate = MS_SUBPART; |
2273 | } |
2257 | } |
2274 | else { |
2258 | else { |
2275 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2259 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
2276 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
2277 | |
2260 | |
2278 | while (mssdepth) { |
2261 | while (mssdepth) { |
2279 | mssdepth--; |
2262 | mssdepth--; |
2280 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2263 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2281 | FP_free (multistack[mssdepth].source); |
2264 | FP_free (multistack[mssdepth].source); |
… | |
… | |
2423 | sstate.mimestate = MS_EPILOGUE; |
2406 | sstate.mimestate = MS_EPILOGUE; |
2424 | else |
2407 | else |
2425 | sstate.mimestate = MS_SUBPART; |
2408 | sstate.mimestate = MS_SUBPART; |
2426 | } |
2409 | } |
2427 | else { |
2410 | else { |
2428 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2411 | UUMessage (UUMSG_WARNING, uustring (S_MIME_B_NOT_FOUND)); |
2429 | uustring (S_MIME_B_NOT_FOUND)); |
|
|
2430 | |
2412 | |
2431 | while (mssdepth) { |
2413 | while (mssdepth) { |
2432 | mssdepth--; |
2414 | mssdepth--; |
2433 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2415 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2434 | FP_free (multistack[mssdepth].source); |
2416 | FP_free (multistack[mssdepth].source); |
… | |
… | |
2609 | /* |
2591 | /* |
2610 | * Examine local header. We're mostly interested in the Content-Type |
2592 | * Examine local header. We're mostly interested in the Content-Type |
2611 | * and the Content-Transfer-Encoding. |
2593 | * and the Content-Transfer-Encoding. |
2612 | */ |
2594 | */ |
2613 | if (FP_stristr (localenv.ctype, "multipart") != NULL) { |
2595 | if (FP_stristr (localenv.ctype, "multipart") != NULL) { |
2614 | UUMessage (uuscan_id, __LINE__, UUMSG_WARNING, |
2596 | UUMessage (UUMSG_WARNING, uustring (S_MIME_PART_MULTI)); |
2615 | uustring (S_MIME_PART_MULTI)); |
|
|
2616 | } |
2597 | } |
2617 | if (localenv.subject) |
2598 | if (localenv.subject) |
2618 | result->subject = FP_strdup (localenv.subject); |
2599 | result->subject = FP_strdup (localenv.subject); |
2619 | else |
2600 | else |
2620 | result->subject = FP_strdup (sstate.envelope.subject); |
2601 | result->subject = FP_strdup (sstate.envelope.subject); |