… | |
… | |
53 | #include <uudeview.h> |
53 | #include <uudeview.h> |
54 | #include <uuint.h> |
54 | #include <uuint.h> |
55 | #include <fptools.h> |
55 | #include <fptools.h> |
56 | #include <uustring.h> |
56 | #include <uustring.h> |
57 | |
57 | |
58 | char * uunconc_id = "$Id: uunconc.c,v 1.27 2020/12/11 20:09:23 root Exp $"; |
58 | char * uunconc_id = "$Id: uunconc.c,v 1.28 2020/12/12 03:55:00 root Exp $"; |
59 | |
59 | |
60 | /* for braindead systems */ |
60 | /* for braindead systems */ |
61 | #ifndef SEEK_SET |
61 | #ifndef SEEK_SET |
62 | #ifdef L_BEGIN |
62 | #ifdef L_BEGIN |
63 | #define SEEK_SET L_BEGIN |
63 | #define SEEK_SET L_BEGIN |
… | |
… | |
1347 | } |
1347 | } |
1348 | data->binfile = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
1348 | data->binfile = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
1349 | |
1349 | |
1350 | if (!data->binfile) { |
1350 | if (!data->binfile) { |
1351 | #else |
1351 | #else |
1352 | if ((data->binfile = tempnam (NULL, "uu")) == NULL) { |
1352 | if ((data->binfile = tmpnam (NULL)) == NULL) { |
1353 | #endif /* HAVE_MKSTEMP */ |
1353 | #endif /* HAVE_MKSTEMP */ |
1354 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1354 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1355 | uustring (S_NO_TEMP_NAME)); |
1355 | uustring (S_NO_TEMP_NAME)); |
1356 | return UURET_NOMEM; |
1356 | return UURET_NOMEM; |
1357 | } |
1357 | } |
… | |
… | |
1383 | data->binfile = NULL; |
1383 | data->binfile = NULL; |
1384 | uu_errno = errno; |
1384 | uu_errno = errno; |
1385 | return UURET_IOERR; |
1385 | return UURET_IOERR; |
1386 | } |
1386 | } |
1387 | UUSETBUF (dataout, dataout_buf, uu_wbuf); |
1387 | UUSETBUF (dataout, dataout_buf, uu_wbuf); |
|
|
1388 | FP_flockfile (dataout); |
1388 | |
1389 | |
1389 | /* |
1390 | /* |
1390 | * we don't have begin lines in Base64 or plain text files. |
1391 | * we don't have begin lines in Base64 or plain text files. |
1391 | */ |
1392 | */ |
1392 | if (data->uudet == B64ENCODED || data->uudet == QP_ENCODED || |
1393 | if (data->uudet == B64ENCODED || data->uudet == QP_ENCODED || |
… | |
… | |
1476 | break; |
1477 | break; |
1477 | } |
1478 | } |
1478 | FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024); |
1479 | FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024); |
1479 | } |
1480 | } |
1480 | UUSETBUF (datain, datain_buf, uu_rbuf); |
1481 | UUSETBUF (datain, datain_buf, uu_rbuf); |
|
|
1482 | FP_flockfile (datain); |
1481 | |
1483 | |
1482 | progress.partno = part; |
1484 | progress.partno = part; |
1483 | progress.fsize = (iter->data->length)?iter->data->length:-1; |
1485 | progress.fsize = (iter->data->length)?iter->data->length:-1; |
1484 | progress.percent = 0; |
1486 | progress.percent = 0; |
1485 | progress.foffset = iter->data->startpos; |
1487 | progress.foffset = iter->data->startpos; |
… | |
… | |
1536 | * If this was a BinHex file, we must extract its data or resource fork |
1538 | * If this was a BinHex file, we must extract its data or resource fork |
1537 | */ |
1539 | */ |
1538 | |
1540 | |
1539 | if (data->uudet == BH_ENCODED && data->binfile) { |
1541 | if (data->uudet == BH_ENCODED && data->binfile) { |
1540 | #ifdef HAVE_MKSTEMP |
1542 | #ifdef HAVE_MKSTEMP |
1541 | ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
1543 | ntmp = malloc(strlen(tmpdir)+strlen(tmpprefix)+2); |
1542 | |
|
|
1543 | if (ntmp == NULL) { |
|
|
1544 | #else |
1544 | #else |
1545 | if ((ntmp = tempnam (NULL, "uu")) == NULL) { |
1545 | ntmp = tempnam (NULL); |
1546 | #endif /* HAVE_MKSTEMP */ |
1546 | #endif /* HAVE_MKSTEMP */ |
|
|
1547 | if (ntmp == NULL) { |
1547 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1548 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1548 | uustring (S_NO_TEMP_NAME)); |
1549 | uustring (S_NO_TEMP_NAME)); |
1549 | progress.action = 0; |
1550 | progress.action = 0; |
1550 | return UURET_NOMEM; |
1551 | return UURET_NOMEM; |
1551 | } |
1552 | } |
… | |
… | |
1556 | progress.action = 0; |
1557 | progress.action = 0; |
1557 | free (ntmp); |
1558 | free (ntmp); |
1558 | return UURET_IOERR; |
1559 | return UURET_IOERR; |
1559 | } |
1560 | } |
1560 | UUSETBUF (datain, datain_buf, uu_rbuf); |
1561 | UUSETBUF (datain, datain_buf, uu_rbuf); |
|
|
1562 | FP_flockfile (datain); |
1561 | |
1563 | |
1562 | #ifdef HAVE_MKSTEMP |
1564 | #ifdef HAVE_MKSTEMP |
1563 | strcpy(ntmp, tmpdir); |
1565 | strcpy(ntmp, tmpdir); |
1564 | strcat(ntmp, "/"); |
1566 | strcat(ntmp, "/"); |
1565 | strcat(ntmp, tmpprefix); |
1567 | strcat(ntmp, tmpprefix); |
… | |
… | |
1582 | #endif /* HAVE_MKSTEMP */ |
1584 | #endif /* HAVE_MKSTEMP */ |
1583 | free (ntmp); |
1585 | free (ntmp); |
1584 | return UURET_IOERR; |
1586 | return UURET_IOERR; |
1585 | } |
1587 | } |
1586 | UUSETBUF (dataout, dataout_buf, uu_wbuf); |
1588 | UUSETBUF (dataout, dataout_buf, uu_wbuf); |
|
|
1589 | FP_flockfile (dataout); |
1587 | |
1590 | |
1588 | /* |
1591 | /* |
1589 | * read fork lengths. remember they're in Motorola format |
1592 | * read fork lengths. remember they're in Motorola format |
1590 | */ |
1593 | */ |
1591 | r[0] = FP_getc (datain); |
1594 | r[0] = FP_getc (datain); |