ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uunconc.c
(Generate patch)

Comparing Convert-UUlib/uulib/uunconc.c (file contents):
Revision 1.31 by root, Sat Sep 24 06:05:03 2022 UTC vs.
Revision 1.32 by root, Sat Sep 24 06:22:47 2022 UTC

37 37
38#include <stdio.h> 38#include <stdio.h>
39#include <ctype.h> 39#include <ctype.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h> 41#include <string.h>
42#include <errno.h>
42 43
43#ifdef HAVE_UNISTD_H 44#ifdef HAVE_UNISTD_H
44#include <unistd.h> 45#include <unistd.h>
45#endif
46#ifdef HAVE_ERRNO_H
47#include <errno.h>
48#endif 46#endif
49 47
50#include <crc32.h> 48#include <crc32.h>
51#include <uudeview.h> 49#include <uudeview.h>
52#include <uuint.h> 50#include <uuint.h>
736 (ftell(datain)<maxpos || flags&FL_TOEND || 734 (ftell(datain)<maxpos || flags&FL_TOEND ||
737 (!(flags&FL_PROPER) && uu_fast_scanning))) { 735 (!(flags&FL_PROPER) && uu_fast_scanning))) {
738 if (FP_fgets (line, 1023, datain) == NULL) 736 if (FP_fgets (line, 1023, datain) == NULL)
739 break; 737 break;
740 if (ferror (datain)) { 738 if (ferror (datain)) {
741 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 739 UUMessage (UUMSG_ERROR, uustring (S_SOURCE_READ_ERR), strerror (uu_errno = errno));
742 uustring (S_SOURCE_READ_ERR),
743 strerror (uu_errno = errno));
744 return UURET_IOERR; 740 return UURET_IOERR;
745 } 741 }
746 line[255] = '\0'; 742 line[255] = '\0';
747 743
748 if (boundary && line[0]=='-' && line[1]=='-' && 744 if (boundary && line[0]=='-' && line[1]=='-' &&
753 uulboundary = 0; 749 uulboundary = 0;
754 return UURET_OK; 750 return UURET_OK;
755 } 751 }
756 752
757 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) { 753 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) {
758 UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, 754 UUMessage (UUMSG_NOTE, uustring (S_DECODE_CANCEL));
759 uustring (S_DECODE_CANCEL));
760 return UURET_CANCEL; 755 return UURET_CANCEL;
761 } 756 }
762 757
763 p1 = p2 = line; 758 p1 = p2 = line;
764 759
836 (ftell(datain)<maxpos || flags&FL_TOEND || 831 (ftell(datain)<maxpos || flags&FL_TOEND ||
837 (!(flags&FL_PROPER) && uu_fast_scanning))) { 832 (!(flags&FL_PROPER) && uu_fast_scanning))) {
838 if (FP_fgets (line, 1023, datain) == NULL) 833 if (FP_fgets (line, 1023, datain) == NULL)
839 break; 834 break;
840 if (ferror (datain)) { 835 if (ferror (datain)) {
841 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 836 UUMessage (UUMSG_ERROR, uustring (S_SOURCE_READ_ERR), strerror (uu_errno = errno));
842 uustring (S_SOURCE_READ_ERR),
843 strerror (uu_errno = errno));
844 return UURET_IOERR; 837 return UURET_IOERR;
845 } 838 }
846 line[255] = '\0'; 839 line[255] = '\0';
847 840
848 if (boundary && line[0]=='-' && line[1]=='-' && 841 if (boundary && line[0]=='-' && line[1]=='-' &&
853 uulboundary = 0; 846 uulboundary = 0;
854 return UURET_OK; 847 return UURET_OK;
855 } 848 }
856 849
857 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) { 850 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) {
858 UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, 851 UUMessage (UUMSG_NOTE, uustring (S_DECODE_CANCEL));
859 uustring (S_DECODE_CANCEL));
860 return UURET_CANCEL; 852 return UURET_CANCEL;
861 } 853 }
862 854
863 ptr = line + strlen (line); 855 ptr = line + strlen (line);
864 856
995 /* optionally skip .. */ 987 /* optionally skip .. */
996 if (*line == '.' && uu_dotdot) 988 if (*line == '.' && uu_dotdot)
997 line++; 989 line++;
998 990
999 if (ferror (datain)) { 991 if (ferror (datain)) {
1000 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 992 UUMessage (UUMSG_ERROR, uustring (S_SOURCE_READ_ERR), strerror (uu_errno = errno));
1001 uustring (S_SOURCE_READ_ERR),
1002 strerror (uu_errno = errno));
1003 return UURET_IOERR; 993 return UURET_IOERR;
1004 } 994 }
1005 995
1006 if (!*line) { /* Empty line? */ 996 if (!*line) { /* Empty line? */
1007 if (*state == DATA && 997 if (*state == DATA &&
1024 /* 1014 /*
1025 * Busy Polls 1015 * Busy Polls
1026 */ 1016 */
1027 1017
1028 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) { 1018 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) {
1029 UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, 1019 UUMessage (UUMSG_NOTE, uustring (S_DECODE_CANCEL));
1030 uustring (S_DECODE_CANCEL));
1031 return UURET_CANCEL; 1020 return UURET_CANCEL;
1032 } 1021 }
1033 1022
1034 /* 1023 /*
1035 * try to make sense of data 1024 * try to make sense of data
1140 int lastpart = !yenotlastpart && (yepartends == 0 || yepartends >= yefilesize); 1129 int lastpart = !yenotlastpart && (yepartends == 0 || yepartends >= yefilesize);
1141 yefilecrc = uu_crc32_combine(yefilecrc, yepartcrc, yepartsize); 1130 yefilecrc = uu_crc32_combine(yefilecrc, yepartcrc, yepartsize);
1142 if ((ptr = FP_strstr (line, " pcrc32=")) != NULL) { 1131 if ((ptr = FP_strstr (line, " pcrc32=")) != NULL) {
1143 crc32_t pcrc32 = strtoul (ptr + 8, NULL, 16); 1132 crc32_t pcrc32 = strtoul (ptr + 8, NULL, 16);
1144 if (pcrc32 != yepartcrc) { 1133 if (pcrc32 != yepartcrc) {
1145 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1146 uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno); 1134 UUMessage (UUMSG_WARNING, uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno);
1147 } 1135 }
1148 } else if ((ptr = FP_strstr (line, " pcrc=")) != NULL) { 1136 } else if ((ptr = FP_strstr (line, " pcrc=")) != NULL) {
1149 crc32_t pcrc32 = strtoul (ptr + 6, NULL, 16); 1137 crc32_t pcrc32 = strtoul (ptr + 6, NULL, 16);
1150 if (pcrc32 != yepartcrc) { 1138 if (pcrc32 != yepartcrc) {
1151 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1152 uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno); 1139 UUMessage (UUMSG_WARNING, uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno);
1153 } 1140 }
1154 } 1141 }
1155 if (lastpart && (ptr = FP_strstr (line, " crc32=")) != NULL) 1142 if (lastpart && (ptr = FP_strstr (line, " crc32=")) != NULL)
1156 { 1143 {
1157 crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16); 1144 crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16);
1158 if (fcrc32 != yefilecrc) { 1145 if (fcrc32 != yefilecrc) {
1159 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, 1146 UUMessage (UUMSG_WARNING, uustring (S_CRC_MISMATCH), progress.curfile);
1160 uustring (S_CRC_MISMATCH), progress.curfile);
1161 } 1147 }
1162 } 1148 }
1163 if ((ptr = FP_strstr (line, " size=")) != NULL) 1149 if ((ptr = FP_strstr (line, " size=")) != NULL)
1164 { 1150 {
1165 size_t size = atol(ptr + 6); 1151 size_t size = atol(ptr + 6);
1166 if (size != yepartsize && yefilesize != -1) { 1152 if (size != yepartsize && yefilesize != -1) {
1167 if (size != yefilesize) 1153 if (size != yefilesize)
1168 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, 1154 UUMessage (UUMSG_WARNING,
1169 uustring (S_PSIZE_MISMATCH), progress.curfile, 1155 uustring (S_PSIZE_MISMATCH), progress.curfile,
1170 progress.partno, yepartsize, size); 1156 progress.partno, yepartsize, size);
1171 else 1157 else
1172 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, 1158 UUMessage (UUMSG_WARNING,
1173 uustring (S_SIZE_MISMATCH), progress.curfile, 1159 uustring (S_SIZE_MISMATCH), progress.curfile,
1174 yepartsize, size); 1160 yepartsize, size);
1175 } 1161 }
1176 } 1162 }
1177 if (lastpart) { 1163 if (lastpart) {
1220 * correctly encoded data. This usually means that the 1206 * correctly encoded data. This usually means that the
1221 * file is in error 1207 * file is in error
1222 */ 1208 */
1223 1209
1224 if (lc[1] > 10 && (lc[0] >= 1 && lc[0] <= 2) && !warning) { 1210 if (lc[1] > 10 && (lc[0] >= 1 && lc[0] <= 2) && !warning) {
1225 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, 1211 UUMessage (UUMSG_WARNING, uustring (S_DATA_SUSPICIOUS));
1226 uustring (S_DATA_SUSPICIOUS));
1227 warning=1; 1212 warning=1;
1228 } 1213 }
1229 lc[0] = 0; 1214 lc[0] = 0;
1230 lc[1] = 3; 1215 lc[1] = 3;
1231 } 1216 }
1253 } 1238 }
1254 1239
1255 if (count) { 1240 if (count) {
1256 if (method == BH_ENCODED) { 1241 if (method == BH_ENCODED) {
1257 if (UUbhwrite (oline, 1, count, dataout) != count) { 1242 if (UUbhwrite (oline, 1, count, dataout) != count) {
1258 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1243 UUMessage (UUMSG_ERROR, uustring (S_WR_ERR_TEMP), strerror (uu_errno = errno));
1259 uustring (S_WR_ERR_TEMP),
1260 strerror (uu_errno = errno));
1261 return UURET_IOERR; 1244 return UURET_IOERR;
1262 } 1245 }
1263 } 1246 }
1264 else if (fwrite (oline, 1, count, dataout) != count) { 1247 else if (fwrite (oline, 1, count, dataout) != count) {
1265 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1248 UUMessage (UUMSG_ERROR, uustring (S_WR_ERR_TEMP), strerror (uu_errno = errno));
1266 uustring (S_WR_ERR_TEMP),
1267 strerror (uu_errno = errno));
1268 return UURET_IOERR; 1249 return UURET_IOERR;
1269 } 1250 }
1270 haddata++; 1251 haddata++;
1271 count = 0; 1252 count = 0;
1272 } 1253 }
1278 for (tf=0; tf<tc; tf++) 1259 for (tf=0; tf<tc; tf++)
1279 count += UUDecodeLine (save[tf], oline + count, method); 1260 count += UUDecodeLine (save[tf], oline + count, method);
1280 if (count) { 1261 if (count) {
1281 if (method == BH_ENCODED) { 1262 if (method == BH_ENCODED) {
1282 if (UUbhwrite (oline, 1, count, dataout) != count) { 1263 if (UUbhwrite (oline, 1, count, dataout) != count) {
1283 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1264 UUMessage (UUMSG_ERROR, uustring (S_WR_ERR_TEMP), strerror (uu_errno = errno));
1284 uustring (S_WR_ERR_TEMP),
1285 strerror (uu_errno = errno));
1286 return UURET_IOERR; 1265 return UURET_IOERR;
1287 } 1266 }
1288 } 1267 }
1289 else if (fwrite (oline, 1, count, dataout) != count) { 1268 else if (fwrite (oline, 1, count, dataout) != count) {
1290 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1269 UUMessage (UUMSG_ERROR, uustring (S_WR_ERR_TEMP), strerror (uu_errno = errno));
1291 uustring (S_WR_ERR_TEMP),
1292 strerror (uu_errno = errno));
1293 return UURET_IOERR; 1270 return UURET_IOERR;
1294 } 1271 }
1295 } 1272 }
1296 } 1273 }
1297 return UURET_OK; 1274 return UURET_OK;
1347 1324
1348 if (!data->binfile) { 1325 if (!data->binfile) {
1349#else 1326#else
1350 if ((data->binfile = tmpnam (NULL)) == NULL) { 1327 if ((data->binfile = tmpnam (NULL)) == NULL) {
1351#endif /* HAVE_MKSTEMP */ 1328#endif /* HAVE_MKSTEMP */
1352 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1329 UUMessage (UUMSG_ERROR, uustring (S_NO_TEMP_NAME));
1353 uustring (S_NO_TEMP_NAME));
1354 return UURET_NOMEM; 1330 return UURET_NOMEM;
1355 } 1331 }
1356 1332
1357#ifdef HAVE_MKSTEMP 1333#ifdef HAVE_MKSTEMP
1358 strcpy(data->binfile, tmpdir); 1334 strcpy(data->binfile, tmpdir);
1366#endif /* HAVE_MKSTEMP */ 1342#endif /* HAVE_MKSTEMP */
1367 /* 1343 /*
1368 * we couldn't create a temporary file. Usually this means that TMP 1344 * we couldn't create a temporary file. Usually this means that TMP
1369 * and TEMP aren't set 1345 * and TEMP aren't set
1370 */ 1346 */
1371 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1347 UUMessage (UUMSG_ERROR, uustring (S_WR_ERR_TARGET), data->binfile, strerror (uu_errno = errno));
1372 uustring (S_WR_ERR_TARGET),
1373 data->binfile, strerror (uu_errno = errno));
1374#ifdef HAVE_MKSTEMP 1348#ifdef HAVE_MKSTEMP
1375 if (tmpfd != -1) { 1349 if (tmpfd != -1) {
1376 unlink(data->binfile); 1350 unlink(data->binfile);
1377 close(tmpfd); 1351 close(tmpfd);
1378 } 1352 }
1457 uugen_fnbuffer, 1)) != UURET_OK) 1431 uugen_fnbuffer, 1)) != UURET_OK)
1458 break; 1432 break;
1459 if ((datain = fopen (uugen_fnbuffer, "rb")) == NULL) { 1433 if ((datain = fopen (uugen_fnbuffer, "rb")) == NULL) {
1460 (*uu_FileCallback) (uu_FileCBArg, iter->data->sfname, 1434 (*uu_FileCallback) (uu_FileCBArg, iter->data->sfname,
1461 uugen_fnbuffer, 0); 1435 uugen_fnbuffer, 0);
1462 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1436 UUMessage (UUMSG_ERROR,
1463 uustring (S_NOT_OPEN_FILE), 1437 uustring (S_NOT_OPEN_FILE),
1464 uugen_fnbuffer, strerror (uu_errno = errno)); 1438 uugen_fnbuffer, strerror (uu_errno = errno));
1465 res = UURET_IOERR; 1439 res = UURET_IOERR;
1466 break; 1440 break;
1467 } 1441 }
1468 } 1442 }
1469 else { 1443 else {
1470 if ((datain = fopen (iter->data->sfname, "rb")) == NULL) { 1444 if ((datain = fopen (iter->data->sfname, "rb")) == NULL) {
1471 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1445 UUMessage (UUMSG_ERROR,
1472 uustring (S_NOT_OPEN_FILE), 1446 uustring (S_NOT_OPEN_FILE),
1473 iter->data->sfname, strerror (uu_errno = errno)); 1447 iter->data->sfname, strerror (uu_errno = errno));
1474 res = UURET_IOERR; 1448 res = UURET_IOERR;
1475 break; 1449 break;
1476 } 1450 }
1504 (data->uudet == B64ENCODED || data->uudet == QP_ENCODED || 1478 (data->uudet == B64ENCODED || data->uudet == QP_ENCODED ||
1505 data->uudet == PT_ENCODED)) 1479 data->uudet == PT_ENCODED))
1506 state = DONE; /* assume we're done */ 1480 state = DONE; /* assume we're done */
1507 1481
1508 if (fclose (dataout)) { 1482 if (fclose (dataout)) {
1509 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1483 UUMessage (UUMSG_ERROR, uustring (S_WR_ERR_TEMP), strerror (uu_errno = errno));
1510 uustring (S_WR_ERR_TEMP),
1511 strerror (uu_errno = errno));
1512 res = UURET_IOERR; 1484 res = UURET_IOERR;
1513 } 1485 }
1514 UUCLRBUF (uu_wbuf, dataout_buf); 1486 UUCLRBUF (uu_wbuf, dataout_buf);
1515 1487
1516 if (res != UURET_OK || (state != DONE && !uu_desperate)) { 1488 if (res != UURET_OK || (state != DONE && !uu_desperate)) {
1541 ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); 1513 ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2);
1542#else 1514#else
1543 ntmp = tempnam (NULL); 1515 ntmp = tempnam (NULL);
1544#endif /* HAVE_MKSTEMP */ 1516#endif /* HAVE_MKSTEMP */
1545 if (ntmp == NULL) { 1517 if (ntmp == NULL) {
1546 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1518 UUMessage (UUMSG_ERROR, uustring (S_NO_TEMP_NAME));
1547 uustring (S_NO_TEMP_NAME));
1548 progress.action = 0; 1519 progress.action = 0;
1549 return UURET_NOMEM; 1520 return UURET_NOMEM;
1550 } 1521 }
1551 if ((datain = fopen (data->binfile, "rb")) == NULL) { 1522 if ((datain = fopen (data->binfile, "rb")) == NULL) {
1552 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1523 UUMessage (UUMSG_ERROR, uustring (S_NOT_OPEN_FILE),
1553 uustring (S_NOT_OPEN_FILE),
1554 data->binfile, strerror (uu_errno = errno)); 1524 data->binfile, strerror (uu_errno = errno));
1555 progress.action = 0; 1525 progress.action = 0;
1556 free (ntmp); 1526 free (ntmp);
1557 return UURET_IOERR; 1527 return UURET_IOERR;
1558 } 1528 }
1566 if ((tmpfd = mkstemp(ntmp)) == -1 || 1536 if ((tmpfd = mkstemp(ntmp)) == -1 ||
1567 (dataout = fdopen(tmpfd, "wb")) == NULL) { 1537 (dataout = fdopen(tmpfd, "wb")) == NULL) {
1568#else 1538#else
1569 if ((dataout = fopen (ntmp, "wb")) == NULL) { 1539 if ((dataout = fopen (ntmp, "wb")) == NULL) {
1570#endif /* HAVE_MKSTEMP */ 1540#endif /* HAVE_MKSTEMP */
1571 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1541 UUMessage (UUMSG_ERROR,
1572 uustring (S_NOT_OPEN_TARGET), 1542 uustring (S_NOT_OPEN_TARGET),
1573 ntmp, strerror (uu_errno = errno)); 1543 ntmp, strerror (uu_errno = errno));
1574 progress.action = 0; 1544 progress.action = 0;
1575 fclose (datain); 1545 fclose (datain);
1576 UUCLRBUF (uu_rbuf, datain_buf); 1546 UUCLRBUF (uu_rbuf, datain_buf);
1601 rsize = (((long) 1 << 24) * (long) r[4]) + 1571 rsize = (((long) 1 << 24) * (long) r[4]) +
1602 (((long) 1 << 16) * (long) r[5]) + 1572 (((long) 1 << 16) * (long) r[5]) +
1603 (((long) 1 << 8) * (long) r[6]) + 1573 (((long) 1 << 8) * (long) r[6]) +
1604 ( (long) r[7]); 1574 ( (long) r[7]);
1605 1575
1606 UUMessage (uunconc_id, __LINE__, UUMSG_MESSAGE, 1576 UUMessage (UUMSG_MESSAGE, uustring (S_BINHEX_SIZES), dsize, rsize);
1607 uustring (S_BINHEX_SIZES),
1608 dsize, rsize);
1609 1577
1610 if (dsize == 0) { 1578 if (dsize == 0) {
1611 fseek (datain, dsize + hb + 2, SEEK_SET); 1579 fseek (datain, dsize + hb + 2, SEEK_SET);
1612 numbytes = rsize; 1580 numbytes = rsize;
1613 } 1581 }
1615 fseek (datain, hb, SEEK_SET); 1583 fseek (datain, hb, SEEK_SET);
1616 numbytes = dsize; 1584 numbytes = dsize;
1617 } 1585 }
1618 else { 1586 else {
1619 /* we should let the user have the choice here */ 1587 /* we should let the user have the choice here */
1620 UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, 1588 UUMessage (UUMSG_NOTE, uustring (S_BINHEX_BOTH));
1621 uustring (S_BINHEX_BOTH));
1622 fseek (datain, hb, SEEK_SET); 1589 fseek (datain, hb, SEEK_SET);
1623 numbytes = dsize; 1590 numbytes = dsize;
1624 } 1591 }
1625 1592
1626 progress.action = 0; 1593 progress.action = 0;
1635 * copy the chosen fork 1602 * copy the chosen fork
1636 */ 1603 */
1637 1604
1638 while (!FP_feof (datain) && numbytes) { 1605 while (!FP_feof (datain) && numbytes) {
1639 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) { 1606 if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) {
1640 UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, 1607 UUMessage (UUMSG_NOTE, uustring (S_DECODE_CANCEL));
1641 uustring (S_DECODE_CANCEL));
1642 fclose (datain); 1608 fclose (datain);
1643 UUCLRBUF (uu_rbuf, datain_buf); 1609 UUCLRBUF (uu_rbuf, datain_buf);
1644 fclose (dataout); 1610 fclose (dataout);
1645 UUCLRBUF (uu_wbuf, dataout_buf); 1611 UUCLRBUF (uu_wbuf, dataout_buf);
1646 unlink (ntmp); 1612 unlink (ntmp);
1651 bytes = fread (uugen_inbuffer, 1, 1617 bytes = fread (uugen_inbuffer, 1,
1652 (size_t) ((numbytes>1024)?1024:numbytes), datain); 1618 (size_t) ((numbytes>1024)?1024:numbytes), datain);
1653 1619
1654 if (ferror (datain) || (bytes == 0 && !FP_feof (datain))) { 1620 if (ferror (datain) || (bytes == 0 && !FP_feof (datain))) {
1655 progress.action = 0; 1621 progress.action = 0;
1656 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1622 UUMessage (UUMSG_ERROR,
1657 uustring (S_SOURCE_READ_ERR), 1623 uustring (S_SOURCE_READ_ERR),
1658 data->binfile, strerror (uu_errno = errno)); 1624 data->binfile, strerror (uu_errno = errno));
1659 fclose (datain); 1625 fclose (datain);
1660 UUCLRBUF (uu_rbuf, datain_buf); 1626 UUCLRBUF (uu_rbuf, datain_buf);
1661 fclose (dataout); 1627 fclose (dataout);
1664 free (ntmp); 1630 free (ntmp);
1665 return UURET_IOERR; 1631 return UURET_IOERR;
1666 } 1632 }
1667 if (fwrite (uugen_inbuffer, 1, bytes, dataout) != bytes) { 1633 if (fwrite (uugen_inbuffer, 1, bytes, dataout) != bytes) {
1668 progress.action = 0; 1634 progress.action = 0;
1669 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1635 UUMessage (UUMSG_ERROR,
1670 uustring (S_WR_ERR_TARGET), 1636 uustring (S_WR_ERR_TARGET),
1671 ntmp, strerror (uu_errno = errno)); 1637 ntmp, strerror (uu_errno = errno));
1672 fclose (datain); 1638 fclose (datain);
1673 UUCLRBUF (uu_rbuf, datain_buf); 1639 UUCLRBUF (uu_rbuf, datain_buf);
1674 fclose (dataout); 1640 fclose (dataout);
1679 } 1645 }
1680 numbytes -= bytes; 1646 numbytes -= bytes;
1681 } 1647 }
1682 1648
1683 if (numbytes) { 1649 if (numbytes) {
1684 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, 1650 UUMessage (UUMSG_WARNING,
1685 uustring (S_SHORT_BINHEX), 1651 uustring (S_SHORT_BINHEX),
1686 (data->filename)?data->filename: 1652 (data->filename)?data->filename:
1687 (data->subfname)?data->subfname:"???", 1653 (data->subfname)?data->subfname:"???",
1688 numbytes); 1654 numbytes);
1689 } 1655 }
1694 1660
1695 fclose (datain); 1661 fclose (datain);
1696 UUCLRBUF (uu_rbuf, datain_buf); 1662 UUCLRBUF (uu_rbuf, datain_buf);
1697 if (fclose (dataout)) { 1663 if (fclose (dataout)) {
1698 UUCLRBUF (uu_wbuf, dataout_buf); 1664 UUCLRBUF (uu_wbuf, dataout_buf);
1699 UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, 1665 UUMessage (UUMSG_ERROR,
1700 uustring (S_WR_ERR_TARGET), 1666 uustring (S_WR_ERR_TARGET),
1701 ntmp, strerror (uu_errno = errno)); 1667 ntmp, strerror (uu_errno = errno));
1702 unlink (ntmp); 1668 unlink (ntmp);
1703 free (ntmp); 1669 free (ntmp);
1704 return UURET_IOERR; 1670 return UURET_IOERR;
1705 } 1671 }
1706 UUCLRBUF (uu_wbuf, dataout_buf); 1672 UUCLRBUF (uu_wbuf, dataout_buf);
1707 1673
1708 if (unlink (data->binfile)) { 1674 if (unlink (data->binfile)) {
1709 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, 1675 UUMessage (UUMSG_WARNING,
1710 uustring (S_TMP_NOT_REMOVED), 1676 uustring (S_TMP_NOT_REMOVED),
1711 data->binfile, strerror (uu_errno = errno)); 1677 data->binfile, strerror (uu_errno = errno));
1712 } 1678 }
1713 1679
1714 free (data->binfile); 1680 free (data->binfile);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines