… | |
… | |
55 | #include <uudeview.h> |
55 | #include <uudeview.h> |
56 | #include <uuint.h> |
56 | #include <uuint.h> |
57 | #include <fptools.h> |
57 | #include <fptools.h> |
58 | #include <uustring.h> |
58 | #include <uustring.h> |
59 | |
59 | |
60 | char * uuscan_id = "$Id: uuscan.c,v 1.14 2008/10/10 16:54:45 root Exp $"; |
60 | char * uuscan_id = "$Id: uuscan.c,v 1.15 2009/08/24 04:38:23 root Exp $"; |
61 | |
61 | |
62 | /* |
62 | /* |
63 | * Header fields we recognize as such. See RFC822. We add "From ", |
63 | * 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 |
64 | * the usual marker for a beginning of a new message, and a couple |
65 | * of usual MDA, News and MIME headers. |
65 | * of usual MDA, News and MIME headers. |
… | |
… | |
177 | long curpos; |
177 | long curpos; |
178 | int hadcr; |
178 | int hadcr; |
179 | |
179 | |
180 | if (initial) { |
180 | if (initial) { |
181 | _FP_strncpy (uuscan_shlline, initial, 1024); |
181 | _FP_strncpy (uuscan_shlline, initial, 1024); |
182 | } |
|
|
183 | else { |
182 | } else { |
184 | /* read first line */ |
183 | /* read first line */ |
185 | if (feof (datei) || ferror (datei)) |
184 | if (feof (datei) || ferror (datei)) |
186 | return NULL; |
185 | return NULL; |
187 | if (_FP_fgets (uuscan_shlline, 1023, datei) == NULL) |
186 | if (_FP_fgets (uuscan_shlline, 1024, datei) == NULL) |
188 | return NULL; |
187 | return NULL; |
189 | uuscan_shlline[1023] = '\0'; |
188 | uuscan_shlline[1023] = '\0'; |
190 | } |
189 | } |
191 | |
190 | |
192 | llength = strlen (uuscan_shlline); |
191 | llength = strlen (uuscan_shlline); |
… | |
… | |
235 | if (feof (datei)) |
234 | if (feof (datei)) |
236 | break; |
235 | break; |
237 | |
236 | |
238 | /* read next line */ |
237 | /* read next line */ |
239 | curpos = ftell (datei); |
238 | curpos = ftell (datei); |
240 | if (_FP_fgets (uugen_inbuffer, 255, datei) == NULL) |
239 | if (_FP_fgets (uugen_inbuffer, 1024, datei) == NULL) |
241 | break; |
240 | break; |
242 | uugen_inbuffer[255] = '\0'; |
241 | uugen_inbuffer[1023] = '\0'; |
243 | |
242 | |
244 | if (IsLineEmpty (uugen_inbuffer)) { /* oops */ |
243 | if (IsLineEmpty (uugen_inbuffer)) { /* oops */ |
245 | fseek (datei, curpos, SEEK_SET); |
244 | fseek (datei, curpos, SEEK_SET); |
246 | break; |
245 | break; |
247 | } |
246 | } |
… | |
… | |
554 | static int |
553 | static int |
555 | IsKnownHeader (char *line) |
554 | IsKnownHeader (char *line) |
556 | { |
555 | { |
557 | char **iter = knownmsgheaders; |
556 | char **iter = knownmsgheaders; |
558 | |
557 | |
|
|
558 | /* fast reject, the majority of calls are simple rejects */ |
|
|
559 | if (!strchr (line, ':')) |
|
|
560 | return 0; |
|
|
561 | |
559 | while (iter && *iter) { |
562 | while (iter && *iter) { |
560 | if (_FP_strnicmp (line, *iter, strlen (*iter)) == 0) |
563 | if (_FP_strnicmp (line, *iter, strlen (*iter)) == 0) |
561 | return 1; |
564 | return 1; |
562 | iter++; |
565 | iter++; |
563 | } |
566 | } |
… | |
… | |
642 | if (boundary) |
645 | if (boundary) |
643 | blen = strlen (boundary); |
646 | blen = strlen (boundary); |
644 | |
647 | |
645 | while (!feof (datei)) { |
648 | while (!feof (datei)) { |
646 | oldposition = ftell (datei); |
649 | oldposition = ftell (datei); |
647 | if (_FP_fgets (line, 255, datei) == NULL) |
650 | if (_FP_fgets (line, 1024, datei) == NULL) |
648 | break; |
651 | break; |
649 | if (ferror (datei)) |
652 | if (ferror (datei)) |
650 | break; |
653 | break; |
651 | |
|
|
652 | line[255] = '\0'; /* For Safety of string functions */ |
|
|
653 | |
654 | |
654 | /* |
655 | /* |
655 | * Make Busy Polls |
656 | * Make Busy Polls |
656 | */ |
657 | */ |
657 | |
658 | |
… | |
… | |
934 | (*(ptr+2) != '\012' && *(ptr+2) != '\015')) && |
935 | (*(ptr+2) != '\012' && *(ptr+2) != '\015')) && |
935 | _FP_strstr (line+2, "_=_") != NULL) { |
936 | _FP_strstr (line+2, "_=_") != NULL) { |
936 | |
937 | |
937 | long oldposition = ftell (datei); /* refresh oldpositition so the comment below becomes true */ |
938 | long oldposition = ftell (datei); /* refresh oldpositition so the comment below becomes true */ |
938 | |
939 | |
939 | if (_FP_fgets (line, 255, datei) == NULL) { |
940 | if (_FP_fgets (line, 1024, datei) == NULL) { |
940 | break; |
941 | break; |
941 | } |
942 | } |
942 | if (_FP_strnicmp (line, "Content-", 8) == 0) { |
943 | if (_FP_strnicmp (line, "Content-", 8) == 0) { |
943 | /* |
944 | /* |
944 | * Okay, let's do it. This breaks out of ScanData. ScanPart will |
945 | * Okay, let's do it. This breaks out of ScanData. ScanPart will |
… | |
… | |
998 | |
999 | |
999 | if (result->partno == 1) { |
1000 | if (result->partno == 1) { |
1000 | result->begin = 1; |
1001 | result->begin = 1; |
1001 | } |
1002 | } |
1002 | |
1003 | |
1003 | if (_FP_fgets (line, 255, datei) == NULL) { |
1004 | if (_FP_fgets (line, 1024, datei) == NULL) { |
1004 | break; |
1005 | break; |
1005 | } |
1006 | } |
1006 | |
|
|
1007 | line[255] = '\0'; |
|
|
1008 | |
1007 | |
1009 | if (strncmp (line, "=ypart ", 7) != 0) { |
1008 | if (strncmp (line, "=ypart ", 7) != 0) { |
1010 | break; |
1009 | break; |
1011 | } |
1010 | } |
1012 | |
1011 | |
… | |
… | |
1218 | *errcode = UURET_CANCEL; |
1217 | *errcode = UURET_CANCEL; |
1219 | break; |
1218 | break; |
1220 | } |
1219 | } |
1221 | |
1220 | |
1222 | oldposition = ftell (datei); |
1221 | oldposition = ftell (datei); |
1223 | if (_FP_fgets (line, 255, datei) == NULL) |
1222 | if (_FP_fgets (line, 1024, datei) == NULL) |
1224 | break; |
1223 | break; |
1225 | if (ferror (datei)) |
1224 | if (ferror (datei)) |
1226 | break; |
1225 | break; |
1227 | |
|
|
1228 | line[255] = '\0'; |
|
|
1229 | |
1226 | |
1230 | /* |
1227 | /* |
1231 | * Stop scanning at an empty line or a MIME-boundary. |
1228 | * Stop scanning at an empty line or a MIME-boundary. |
1232 | */ |
1229 | */ |
1233 | if (IsLineEmpty (line)) |
1230 | if (IsLineEmpty (line)) |
… | |
… | |
1524 | |
1521 | |
1525 | /* ignore empty lines at the beginning of a file */ |
1522 | /* ignore empty lines at the beginning of a file */ |
1526 | preheaders = ftell (datei); |
1523 | preheaders = ftell (datei); |
1527 | while (!feof (datei)) { |
1524 | while (!feof (datei)) { |
1528 | if (UUBUSYPOLL(preheaders,progress.fsize)) SPCANCEL(); |
1525 | if (UUBUSYPOLL(preheaders,progress.fsize)) SPCANCEL(); |
1529 | if (_FP_fgets (line, 255, datei) == NULL) |
1526 | if (_FP_fgets (line, 1024, datei) == NULL) |
1530 | break; |
1527 | break; |
1531 | line[255] = '\0'; |
|
|
1532 | if (!IsLineEmpty (line)) { |
1528 | if (!IsLineEmpty (line)) { |
1533 | fseek (datei, preheaders, SEEK_SET); |
1529 | fseek (datei, preheaders, SEEK_SET); |
1534 | break; |
1530 | break; |
1535 | } |
1531 | } |
1536 | preheaders = ftell (datei); |
1532 | preheaders = ftell (datei); |
… | |
… | |
1562 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1558 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1563 | _FP_free (multistack[mssdepth].source); |
1559 | _FP_free (multistack[mssdepth].source); |
1564 | } |
1560 | } |
1565 | |
1561 | |
1566 | prevpos = ftell (datei); |
1562 | prevpos = ftell (datei); |
1567 | if (_FP_fgets (line, 255, datei) == NULL) { |
1563 | if (_FP_fgets (line, 1024, datei) == NULL) { |
1568 | _FP_free (result); |
1564 | _FP_free (result); |
1569 | return NULL; |
1565 | return NULL; |
1570 | } |
1566 | } |
1571 | line[255] = '\0'; |
|
|
1572 | |
1567 | |
1573 | /* |
1568 | /* |
1574 | * Special handling for AOL folder files, which start off with a boundary. |
1569 | * Special handling for AOL folder files, which start off with a boundary. |
1575 | * We recognize them by a valid boundary line as the first line of a file. |
1570 | * We recognize them by a valid boundary line as the first line of a file. |
1576 | * Note that the rest of the scanning code becomes suspicious if a boun- |
1571 | * Note that the rest of the scanning code becomes suspicious if a boun- |
1577 | * dary does never appear in a file -- this should save us from grave |
1572 | * dary does never appear in a file -- this should save us from grave |
1578 | * false detection errors |
1573 | * false detection errors |
1579 | */ |
1574 | */ |
1580 | |
1575 | |
1581 | if (!feof (datei) && line[0] == '-' && line[1] == '-' && line[2]) { |
1576 | if (!feof (datei) && line[0] == '-' && line[1] == '-' && line[2]) { |
1582 | while (line[strlen(line)-1] == '\012' || |
|
|
1583 | line[strlen(line)-1] == '\015') { |
|
|
1584 | line[strlen(line)-1] = '\0'; |
|
|
1585 | } |
|
|
1586 | |
|
|
1587 | sstate.ismime = 1; |
1577 | sstate.ismime = 1; |
1588 | sstate.envelope.mimevers = _FP_strdup ("1.0"); |
1578 | sstate.envelope.mimevers = _FP_strdup ("1.0"); |
1589 | sstate.envelope.boundary = _FP_strdup (line+2); |
1579 | sstate.envelope.boundary = _FP_strdup (line+2); |
1590 | sstate.envelope.ctype = _FP_strdup ("multipart/mixed"); |
1580 | sstate.envelope.ctype = _FP_strdup ("multipart/mixed"); |
1591 | sstate.mimestate = MS_SUBPART; |
1581 | sstate.mimestate = MS_SUBPART; |
… | |
… | |
1620 | fseek (datei, prevpos, SEEK_SET); |
1610 | fseek (datei, prevpos, SEEK_SET); |
1621 | line[0] = '\0'; |
1611 | line[0] = '\0'; |
1622 | break; |
1612 | break; |
1623 | } |
1613 | } |
1624 | |
1614 | |
1625 | if (_FP_fgets (line, 255, datei) == NULL) { |
1615 | if (_FP_fgets (line, 1024, datei) == NULL) { |
1626 | /* If we are at eof without finding headers, there probably isn't */ |
1616 | /* If we are at eof without finding headers, there probably isn't */ |
1627 | if (hcount < hlcount.afternl) { |
1617 | if (hcount < hlcount.afternl) |
1628 | fseek (datei, prevpos, SEEK_SET); |
1618 | fseek (datei, prevpos, SEEK_SET); |
1629 | line[0] = '\0'; |
|
|
1630 | } |
|
|
1631 | break; |
1619 | break; |
1632 | } |
1620 | } |
1633 | line[255] = '\0'; |
|
|
1634 | } |
1621 | } |
1635 | |
1622 | |
1636 | /* skip empty lines */ |
1623 | /* skip empty lines */ |
1637 | prevpos = ftell (datei); |
1624 | prevpos = ftell (datei); |
1638 | if (IsLineEmpty (line)) { |
1625 | if (IsLineEmpty (line)) { |
1639 | while (!feof (datei)) { |
1626 | while (!feof (datei)) { |
1640 | if (_FP_fgets (line, 255, datei) == NULL) |
1627 | if (_FP_fgets (line, 1024, datei) == NULL) |
1641 | break; |
1628 | break; |
1642 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1629 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1643 | if (!IsLineEmpty (line)) { |
1630 | if (!IsLineEmpty (line)) { |
1644 | fseek (datei, prevpos, SEEK_SET); |
1631 | fseek (datei, prevpos, SEEK_SET); |
1645 | line[255] = '\0'; |
|
|
1646 | break; |
1632 | break; |
1647 | } |
1633 | } |
1648 | prevpos = ftell (datei); |
1634 | prevpos = ftell (datei); |
1649 | } |
1635 | } |
1650 | } |
1636 | } |
… | |
… | |
1660 | sstate.envelope.ctenc == NULL && |
1646 | sstate.envelope.ctenc == NULL && |
1661 | IsKnownHeader (line)) { |
1647 | IsKnownHeader (line)) { |
1662 | /* |
1648 | /* |
1663 | * see above |
1649 | * see above |
1664 | */ |
1650 | */ |
1665 | if (_FP_fgets (line, 255, datei) == NULL) { |
1651 | _FP_fgets (line, 1024, datei); |
1666 | line[0] = '\012'; |
|
|
1667 | line[1] = '\0'; |
|
|
1668 | } |
|
|
1669 | line[255] = '\0'; |
|
|
1670 | |
1652 | |
1671 | while (!feof (datei) && !IsLineEmpty (line)) { |
1653 | while (!feof (datei) && !IsLineEmpty (line)) { |
1672 | if (IsKnownHeader (line)) |
1654 | if (IsKnownHeader (line)) |
1673 | hcount++; |
1655 | hcount++; |
1674 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1656 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
… | |
… | |
1677 | *errcode = UURET_NOMEM; |
1659 | *errcode = UURET_NOMEM; |
1678 | _FP_free (result); |
1660 | _FP_free (result); |
1679 | return NULL; |
1661 | return NULL; |
1680 | } |
1662 | } |
1681 | |
1663 | |
1682 | if (_FP_fgets (line, 255, datei) == NULL) |
1664 | if (_FP_fgets (line, 1024, datei) == NULL) |
1683 | break; |
1665 | break; |
1684 | line[255] = '\0'; |
|
|
1685 | } |
1666 | } |
1686 | /* skip empty lines */ |
1667 | /* skip empty lines */ |
1687 | prevpos = ftell (datei); |
1668 | prevpos = ftell (datei); |
1688 | while (!feof (datei)) { |
1669 | while (!feof (datei)) { |
1689 | if (_FP_fgets (line, 255, datei) == NULL) |
1670 | if (_FP_fgets (line, 1024, datei) == NULL) |
1690 | break; |
1671 | break; |
1691 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1672 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1692 | if (!IsLineEmpty (line)) { |
1673 | if (!IsLineEmpty (line)) { |
1693 | fseek (datei, prevpos, SEEK_SET); |
1674 | fseek (datei, prevpos, SEEK_SET); |
1694 | line[255] = '\0'; |
|
|
1695 | break; |
1675 | break; |
1696 | } |
1676 | } |
1697 | prevpos = ftell (datei); |
1677 | prevpos = ftell (datei); |
1698 | } |
1678 | } |
1699 | } |
1679 | } |
… | |
… | |
1765 | |
1745 | |
1766 | blen = strlen (sstate.envelope.boundary); |
1746 | blen = strlen (sstate.envelope.boundary); |
1767 | lcount = 0; |
1747 | lcount = 0; |
1768 | |
1748 | |
1769 | while (!feof (datei)) { |
1749 | while (!feof (datei)) { |
1770 | if (_FP_fgets (line, 255, datei) == NULL) { |
1750 | if (_FP_fgets (line, 1024, datei) == NULL) |
1771 | line[0] = '\0'; |
|
|
1772 | break; |
1751 | break; |
1773 | } |
|
|
1774 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1752 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1775 | if (line[0] == '-' && line[1] == '-' && |
1753 | if (line[0] == '-' && line[1] == '-' && |
1776 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
1754 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
1777 | break; |
1755 | break; |
1778 | if (!IsLineEmpty (line)) |
1756 | if (!IsLineEmpty (line)) |
… | |
… | |
1891 | if (uu_fast_scanning && mssdepth == 0) { |
1869 | if (uu_fast_scanning && mssdepth == 0) { |
1892 | /* |
1870 | /* |
1893 | * check if the epilogue is empty |
1871 | * check if the epilogue is empty |
1894 | */ |
1872 | */ |
1895 | while (!feof (datei) && !ferror (datei) && lcount<10 && res==0) { |
1873 | while (!feof (datei) && !ferror (datei) && lcount<10 && res==0) { |
1896 | if (_FP_fgets (line, 255, datei) == NULL) |
1874 | if (_FP_fgets (line, 1024, datei) == NULL) |
1897 | break; |
1875 | break; |
1898 | if (!IsLineEmpty (line)) |
1876 | if (!IsLineEmpty (line)) |
1899 | res++; |
1877 | res++; |
1900 | lcount++; |
1878 | lcount++; |
1901 | } |
1879 | } |
… | |
… | |
1927 | |
1905 | |
1928 | if (mssdepth > 0) |
1906 | if (mssdepth > 0) |
1929 | blen = strlen (multistack[mssdepth-1].envelope.boundary); |
1907 | blen = strlen (multistack[mssdepth-1].envelope.boundary); |
1930 | |
1908 | |
1931 | while (!feof (datei)) { |
1909 | while (!feof (datei)) { |
1932 | if (_FP_fgets (line, 255, datei) == NULL) { |
1910 | if (_FP_fgets (line, 1024, datei) == NULL) |
1933 | line[0] = '\0'; |
|
|
1934 | break; |
1911 | break; |
1935 | } |
|
|
1936 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1912 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
1937 | line[255] = '\0'; |
|
|
1938 | /* check for parent boundary */ |
1913 | /* check for parent boundary */ |
1939 | if (mssdepth > 0 && line[0] == '-' && line[1] == '-' && |
1914 | if (mssdepth > 0 && line[0] == '-' && line[1] == '-' && |
1940 | strncmp (line+2, |
1915 | strncmp (line+2, |
1941 | multistack[mssdepth-1].envelope.boundary, blen) == 0) |
1916 | multistack[mssdepth-1].envelope.boundary, blen) == 0) |
1942 | break; |
1917 | break; |
… | |
… | |
2143 | /* Scan subheader. But what if there is no subheader? */ |
2118 | /* Scan subheader. But what if there is no subheader? */ |
2144 | hcount = 0; |
2119 | hcount = 0; |
2145 | lcount = 0; |
2120 | lcount = 0; |
2146 | preheaders = prevpos; |
2121 | preheaders = prevpos; |
2147 | |
2122 | |
2148 | if (_FP_fgets (line, 255, datei) == NULL) { |
2123 | if (_FP_fgets (line, 1024, datei) == NULL) { |
2149 | sstate.isfolder = 0; |
2124 | sstate.isfolder = 0; |
2150 | sstate.ismime = 0; |
2125 | sstate.ismime = 0; |
2151 | while (mssdepth) { |
2126 | while (mssdepth) { |
2152 | mssdepth--; |
2127 | mssdepth--; |
2153 | UUkillheaders (&(multistack[mssdepth].envelope)); |
2128 | UUkillheaders (&(multistack[mssdepth].envelope)); |
… | |
… | |
2155 | } |
2130 | } |
2156 | UUkillheaders (&localenv); |
2131 | UUkillheaders (&localenv); |
2157 | _FP_free (result); |
2132 | _FP_free (result); |
2158 | return NULL; |
2133 | return NULL; |
2159 | } |
2134 | } |
2160 | line[255] = '\0'; |
|
|
2161 | |
2135 | |
2162 | while (!feof (datei) && !IsLineEmpty (line)) { |
2136 | while (!feof (datei) && !IsLineEmpty (line)) { |
2163 | if (IsKnownHeader (line)) |
2137 | if (IsKnownHeader (line)) |
2164 | hcount++; |
2138 | hcount++; |
2165 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2139 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
… | |
… | |
2175 | if (line[0] == '-' && line[1] == '-') |
2149 | if (line[0] == '-' && line[1] == '-') |
2176 | break; |
2150 | break; |
2177 | |
2151 | |
2178 | prevpos = ftell (datei); |
2152 | prevpos = ftell (datei); |
2179 | |
2153 | |
2180 | if (_FP_fgets (line, 255, datei) == NULL) |
2154 | if (_FP_fgets (line, 1024, datei) == NULL) |
2181 | break; |
2155 | break; |
2182 | line[255] = '\0'; |
|
|
2183 | lcount++; |
2156 | lcount++; |
2184 | } |
2157 | } |
2185 | if (line[0] == '-' && line[1] == '-') { |
2158 | if (line[0] == '-' && line[1] == '-') { |
2186 | /* |
2159 | /* |
2187 | * this shouldn't happen, there must always be an empty line, |
2160 | * this shouldn't happen, there must always be an empty line, |
… | |
… | |
2268 | prevpos = ftell (datei); |
2241 | prevpos = ftell (datei); |
2269 | blen = strlen (sstate.envelope.boundary); |
2242 | blen = strlen (sstate.envelope.boundary); |
2270 | lcount = 0; |
2243 | lcount = 0; |
2271 | |
2244 | |
2272 | while (!feof (datei)) { |
2245 | while (!feof (datei)) { |
2273 | if (_FP_fgets (line, 255, datei) == NULL) { |
2246 | if (_FP_fgets (line, 1024, datei) == NULL) |
2274 | line[0] = '\0'; |
|
|
2275 | break; |
2247 | break; |
2276 | } |
|
|
2277 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2248 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2278 | line[255] = '\0'; |
2249 | line[255] = '\0'; |
2279 | if (line[0] == '-' && line[1] == '-' && |
2250 | if (line[0] == '-' && line[1] == '-' && |
2280 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2251 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2281 | break; |
2252 | break; |
… | |
… | |
2437 | */ |
2408 | */ |
2438 | blen = strlen (sstate.envelope.boundary); |
2409 | blen = strlen (sstate.envelope.boundary); |
2439 | prevpos = ftell (datei); |
2410 | prevpos = ftell (datei); |
2440 | |
2411 | |
2441 | while (!feof (datei)) { |
2412 | while (!feof (datei)) { |
2442 | if (_FP_fgets (line, 255, datei) == NULL) { |
2413 | if (_FP_fgets (line, 1024, datei) == NULL) |
2443 | line[0] = '\0'; |
|
|
2444 | break; |
2414 | break; |
2445 | } |
|
|
2446 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2415 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2447 | line[255] = '\0'; |
|
|
2448 | if (line[0] == '-' && line[1] == '-' && |
2416 | if (line[0] == '-' && line[1] == '-' && |
2449 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2417 | strncmp (line+2, sstate.envelope.boundary, blen) == 0) |
2450 | break; |
2418 | break; |
2451 | if (line[0] == 'C' && line[1] == 'o' && |
2419 | if (line[0] == 'C' && line[1] == 'o' && |
2452 | _FP_strnicmp (line, "Content-Type:", 13) == 0) { |
2420 | _FP_strnicmp (line, "Content-Type:", 13) == 0) { |
… | |
… | |
2620 | memset (&localenv, 0, sizeof (headers)); |
2588 | memset (&localenv, 0, sizeof (headers)); |
2621 | |
2589 | |
2622 | /* skip over blank lines first */ |
2590 | /* skip over blank lines first */ |
2623 | prevpos = ftell (datei); |
2591 | prevpos = ftell (datei); |
2624 | while (!feof (datei)) { |
2592 | while (!feof (datei)) { |
2625 | if (_FP_fgets (line, 255, datei) == NULL) |
2593 | if (_FP_fgets (line, 1024, datei) == NULL) |
2626 | break; |
2594 | break; |
2627 | line[255] = '\0'; |
|
|
2628 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2595 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2629 | if (!IsLineEmpty (line)) |
2596 | if (!IsLineEmpty (line)) |
2630 | break; |
2597 | break; |
2631 | prevpos = ftell (datei); |
2598 | prevpos = ftell (datei); |
2632 | } |
2599 | } |
… | |
… | |
2645 | } |
2612 | } |
2646 | ptr1 = ScanHeaderLine (datei, line); |
2613 | ptr1 = ScanHeaderLine (datei, line); |
2647 | if (ParseHeader (&localenv, ptr1) == NULL) |
2614 | if (ParseHeader (&localenv, ptr1) == NULL) |
2648 | *errcode = UURET_NOMEM; |
2615 | *errcode = UURET_NOMEM; |
2649 | |
2616 | |
2650 | if (_FP_fgets (line, 255, datei) == NULL) |
2617 | if (_FP_fgets (line, 1024, datei) == NULL) |
2651 | break; |
2618 | break; |
2652 | line[255] = '\0'; |
|
|
2653 | lcount++; |
2619 | lcount++; |
2654 | } |
2620 | } |
2655 | prevpos = ftell (datei); |
2621 | prevpos = ftell (datei); |
2656 | /* |
2622 | /* |
2657 | * Examine local header. We're mostly interested in the Content-Type |
2623 | * Examine local header. We're mostly interested in the Content-Type |
… | |
… | |
2734 | /* |
2700 | /* |
2735 | * skip over empty lines and local header |
2701 | * skip over empty lines and local header |
2736 | */ |
2702 | */ |
2737 | preheaders = ftell (datei); |
2703 | preheaders = ftell (datei); |
2738 | while (!feof (datei)) { |
2704 | while (!feof (datei)) { |
2739 | if (_FP_fgets (line, 255, datei) == NULL) |
2705 | if (_FP_fgets (line, 1024, datei) == NULL) |
2740 | break; |
2706 | break; |
2741 | line[255] = '\0'; |
|
|
2742 | if (!IsLineEmpty (line)) { |
2707 | if (!IsLineEmpty (line)) { |
2743 | break; |
2708 | break; |
2744 | } |
2709 | } |
2745 | } |
2710 | } |
2746 | |
2711 | |
… | |
… | |
2749 | hcount++; |
2714 | hcount++; |
2750 | lcount++; |
2715 | lcount++; |
2751 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2716 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2752 | break; |
2717 | break; |
2753 | |
2718 | |
2754 | if (_FP_fgets (line, 255, datei) == NULL) |
2719 | if (_FP_fgets (line, 1024, datei) == NULL) |
2755 | break; |
2720 | break; |
2756 | line[255] = '\0'; |
|
|
2757 | } |
2721 | } |
2758 | if (hcount < hlcount.afternl) |
2722 | if (hcount < hlcount.afternl) |
2759 | fseek (datei, preheaders, SEEK_SET); |
2723 | fseek (datei, preheaders, SEEK_SET); |
2760 | hcount = lcount = 0; |
2724 | hcount = lcount = 0; |
2761 | } |
2725 | } |
… | |
… | |
2763 | /* |
2727 | /* |
2764 | * look for next header |
2728 | * look for next header |
2765 | */ |
2729 | */ |
2766 | |
2730 | |
2767 | while (!feof (datei)) { |
2731 | while (!feof (datei)) { |
2768 | if (_FP_fgets (line, 255, datei) == NULL) |
2732 | if (_FP_fgets (line, 1024, datei) == NULL) |
2769 | break; |
2733 | break; |
2770 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2734 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2771 | if (ferror (datei)) |
2735 | if (ferror (datei)) |
2772 | break; |
2736 | break; |
2773 | line[255] = '\0'; |
|
|
2774 | |
2737 | |
2775 | if ((vflag = IsKnownHeader (line))) { |
2738 | if ((vflag = IsKnownHeader (line))) { |
2776 | (void) ScanHeaderLine (datei, line); |
2739 | (void) ScanHeaderLine (datei, line); |
2777 | |
2740 | |
2778 | if (result->uudet != PT_ENCODED || vflag == 1) { |
2741 | if (result->uudet != PT_ENCODED || vflag == 1) { |
… | |
… | |
2970 | /* |
2933 | /* |
2971 | * skip over empty lines and local header |
2934 | * skip over empty lines and local header |
2972 | */ |
2935 | */ |
2973 | preheaders = ftell (datei); |
2936 | preheaders = ftell (datei); |
2974 | while (!feof (datei)) { |
2937 | while (!feof (datei)) { |
2975 | if (_FP_fgets (line, 255, datei) == NULL) |
2938 | if (_FP_fgets (line, 1024, datei) == NULL) |
2976 | break; |
2939 | break; |
2977 | line[255] = '\0'; |
|
|
2978 | if (!IsLineEmpty (line)) { |
2940 | if (!IsLineEmpty (line)) { |
2979 | break; |
2941 | break; |
2980 | } |
2942 | } |
2981 | } |
2943 | } |
2982 | |
2944 | |
… | |
… | |
2985 | hcount++; |
2947 | hcount++; |
2986 | lcount++; |
2948 | lcount++; |
2987 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2949 | if (lcount > WAITHEADER && hcount < hlcount.afternl) |
2988 | break; |
2950 | break; |
2989 | |
2951 | |
2990 | if (_FP_fgets (line, 255, datei) == NULL) |
2952 | if (_FP_fgets (line, 1024, datei) == NULL) |
2991 | break; |
2953 | break; |
2992 | line[255] = '\0'; |
|
|
2993 | } |
2954 | } |
2994 | if (hcount < hlcount.afternl) |
2955 | if (hcount < hlcount.afternl) |
2995 | fseek (datei, preheaders, SEEK_SET); |
2956 | fseek (datei, preheaders, SEEK_SET); |
2996 | hcount = lcount = 0; |
2957 | hcount = lcount = 0; |
2997 | } |
2958 | } |
… | |
… | |
2999 | /* |
2960 | /* |
3000 | * look for next header |
2961 | * look for next header |
3001 | */ |
2962 | */ |
3002 | |
2963 | |
3003 | while (!feof (datei)) { |
2964 | while (!feof (datei)) { |
3004 | if (_FP_fgets (line, 255, datei) == NULL) |
2965 | if (_FP_fgets (line, 1024, datei) == NULL) |
3005 | break; |
2966 | break; |
3006 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
2967 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
3007 | if (ferror (datei)) |
2968 | if (ferror (datei)) |
3008 | break; |
2969 | break; |
3009 | line[255] = '\0'; |
|
|
3010 | |
2970 | |
3011 | if (IsKnownHeader (line)) { |
2971 | if (IsKnownHeader (line)) { |
3012 | (void) ScanHeaderLine (datei, line); |
2972 | (void) ScanHeaderLine (datei, line); |
3013 | if (hcount == 0) |
2973 | if (hcount == 0) |
3014 | preheaders = prevpos; |
2974 | preheaders = prevpos; |
… | |
… | |
3129 | |
3089 | |
3130 | if ((!sstate.envelope.ctype || _FP_stristr (sstate.envelope.ctype, "multipart")) |
3090 | if ((!sstate.envelope.ctype || _FP_stristr (sstate.envelope.ctype, "multipart")) |
3131 | && !uu_more_mime) { |
3091 | && !uu_more_mime) { |
3132 | prevpos = ftell (datei); |
3092 | prevpos = ftell (datei); |
3133 | while (!feof (datei)) { |
3093 | while (!feof (datei)) { |
3134 | if (_FP_fgets (line, 255, datei) == NULL) { |
3094 | if (_FP_fgets (line, 1024, datei) == NULL) |
3135 | line[0] = '\0'; |
|
|
3136 | break; |
3095 | break; |
3137 | } |
|
|
3138 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
3096 | if (UUBUSYPOLL(ftell(datei),progress.fsize)) SPCANCEL(); |
3139 | if (!IsLineEmpty (line)) |
3097 | if (!IsLineEmpty (line)) |
3140 | break; |
3098 | break; |
3141 | } |
3099 | } |
3142 | if (line[0] == '-' && line[1] == '-' && |
3100 | if (line[0] == '-' && line[1] == '-' && |