… | |
… | |
54 | #else |
54 | #else |
55 | #define SEEK_SET 0 |
55 | #define SEEK_SET 0 |
56 | #endif |
56 | #endif |
57 | #endif |
57 | #endif |
58 | |
58 | |
59 | char * uuencode_id = "$Id: uuencode.c,v 1.3 2002/03/31 20:04:30 root Exp $"; |
59 | char * uuencode_id = "$Id: uuencode.c,v 1.4 2002/03/31 20:08:42 root Exp $"; |
60 | |
60 | |
61 | #if 0 |
61 | #if 0 |
62 | /* |
62 | /* |
63 | * the End-Of-Line string. MIME enforces CRLF, so that's what we use. Some |
63 | * the End-Of-Line string. MIME enforces CRLF, so that's what we use. Some |
64 | * implementations of uudecode will complain about a missing end line, since |
64 | * implementations of uudecode will complain about a missing end line, since |
… | |
… | |
264 | * read line oriented. |
264 | * read line oriented. |
265 | */ |
265 | */ |
266 | |
266 | |
267 | if (encoding == PT_ENCODED || encoding == QP_ENCODED) { |
267 | if (encoding == PT_ENCODED || encoding == QP_ENCODED) { |
268 | while (!feof (infile) && (linperfile <= 0 || line < linperfile)) { |
268 | while (!feof (infile) && (linperfile <= 0 || line < linperfile)) { |
269 | if (FP_fgets (itemp, 255, infile) == NULL) { |
269 | if (_FP_fgets (itemp, 255, infile) == NULL) { |
270 | break; |
270 | break; |
271 | } |
271 | } |
272 | |
272 | |
273 | itemp[255] = '\0'; |
273 | itemp[255] = '\0'; |
274 | count = strlen (itemp); |
274 | count = strlen (itemp); |
… | |
… | |
663 | } |
663 | } |
664 | |
664 | |
665 | if (progress.fsize <= 0) |
665 | if (progress.fsize <= 0) |
666 | progress.fsize = -1; |
666 | progress.fsize = -1; |
667 | |
667 | |
668 | FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
668 | _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
669 | |
669 | |
670 | progress.partno = 1; |
670 | progress.partno = 1; |
671 | progress.numparts = 1; |
671 | progress.numparts = 1; |
672 | progress.percent = 0; |
672 | progress.percent = 0; |
673 | progress.foffset = 0; |
673 | progress.foffset = 0; |
… | |
… | |
678 | * looking at the file's extension. If it is unknown, default to |
678 | * looking at the file's extension. If it is unknown, default to |
679 | * Application/Octet-Stream |
679 | * Application/Octet-Stream |
680 | */ |
680 | */ |
681 | |
681 | |
682 | if (mimetype == NULL) { |
682 | if (mimetype == NULL) { |
683 | if ((ptr = FP_strrchr ((outfname)?outfname:infname, '.'))) { |
683 | if ((ptr = _FP_strrchr ((outfname)?outfname:infname, '.'))) { |
684 | while (miter->extension && FP_stricmp (ptr+1, miter->extension) != 0) |
684 | while (miter->extension && _FP_stricmp (ptr+1, miter->extension) != 0) |
685 | miter++; |
685 | miter++; |
686 | mimetype = miter->mimetype; |
686 | mimetype = miter->mimetype; |
687 | } |
687 | } |
688 | } |
688 | } |
689 | |
689 | |
… | |
… | |
843 | thesize = (long) finfo.st_size; |
843 | thesize = (long) finfo.st_size; |
844 | } |
844 | } |
845 | theifile = infile; |
845 | theifile = infile; |
846 | } |
846 | } |
847 | |
847 | |
848 | FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
848 | _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
849 | |
849 | |
850 | progress.totsize = (thesize>0) ? thesize : -1; |
850 | progress.totsize = (thesize>0) ? thesize : -1; |
851 | progress.partno = 1; |
851 | progress.partno = 1; |
852 | progress.numparts = numparts; |
852 | progress.numparts = numparts; |
853 | progress.percent = 0; |
853 | progress.percent = 0; |
… | |
… | |
858 | * looking at the file's extension. If it is unknown, default to |
858 | * looking at the file's extension. If it is unknown, default to |
859 | * Application/Octet-Stream |
859 | * Application/Octet-Stream |
860 | */ |
860 | */ |
861 | |
861 | |
862 | if (mimetype == NULL) { |
862 | if (mimetype == NULL) { |
863 | if ((ptr = FP_strrchr ((outfname)?outfname:infname, '.'))) { |
863 | if ((ptr = _FP_strrchr ((outfname)?outfname:infname, '.'))) { |
864 | while (miter->extension && FP_stricmp (ptr+1, miter->extension) != 0) |
864 | while (miter->extension && _FP_stricmp (ptr+1, miter->extension) != 0) |
865 | miter++; |
865 | miter++; |
866 | mimetype = miter->mimetype; |
866 | mimetype = miter->mimetype; |
867 | } |
867 | } |
868 | } |
868 | } |
869 | |
869 | |
… | |
… | |
1078 | } |
1078 | } |
1079 | |
1079 | |
1080 | if (progress.fsize <= 0) |
1080 | if (progress.fsize <= 0) |
1081 | progress.fsize = -1; |
1081 | progress.fsize = -1; |
1082 | |
1082 | |
1083 | FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
1083 | _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
1084 | |
1084 | |
1085 | progress.partno = 1; |
1085 | progress.partno = 1; |
1086 | progress.numparts = 1; |
1086 | progress.numparts = 1; |
1087 | progress.percent = 0; |
1087 | progress.percent = 0; |
1088 | progress.foffset = 0; |
1088 | progress.foffset = 0; |
… | |
… | |
1215 | /* |
1215 | /* |
1216 | * optr points after the last dot, so that we can print the part number |
1216 | * optr points after the last dot, so that we can print the part number |
1217 | * there. |
1217 | * there. |
1218 | */ |
1218 | */ |
1219 | |
1219 | |
1220 | optr = FP_strrchr (oname, '.'); |
1220 | optr = _FP_strrchr (oname, '.'); |
1221 | if (optr==NULL || strchr (optr, '/')!=NULL || strchr (optr, '\\')!=NULL) { |
1221 | if (optr==NULL || strchr (optr, '/')!=NULL || strchr (optr, '\\')!=NULL) { |
1222 | optr = oname + strlen (oname); |
1222 | optr = oname + strlen (oname); |
1223 | *optr++ = '.'; |
1223 | *optr++ = '.'; |
1224 | } |
1224 | } |
1225 | else if (optr==oname || *(optr-1)=='/' || *(optr-1)=='\\') { |
1225 | else if (optr==oname || *(optr-1)=='/' || *(optr-1)=='\\') { |
… | |
… | |
1234 | if (infile==NULL) { |
1234 | if (infile==NULL) { |
1235 | if (stat (infname, &finfo) == -1) { |
1235 | if (stat (infname, &finfo) == -1) { |
1236 | UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, |
1236 | UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, |
1237 | uustring (S_NOT_STAT_FILE), |
1237 | uustring (S_NOT_STAT_FILE), |
1238 | infname, strerror (uu_errno=errno)); |
1238 | infname, strerror (uu_errno=errno)); |
1239 | FP_free (oname); |
1239 | _FP_free (oname); |
1240 | return UURET_IOERR; |
1240 | return UURET_IOERR; |
1241 | } |
1241 | } |
1242 | if ((theifile = fopen (infname, "rb")) == NULL) { |
1242 | if ((theifile = fopen (infname, "rb")) == NULL) { |
1243 | UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, |
1243 | UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, |
1244 | uustring (S_NOT_OPEN_FILE), |
1244 | uustring (S_NOT_OPEN_FILE), |
1245 | infname, strerror (uu_errno=errno)); |
1245 | infname, strerror (uu_errno=errno)); |
1246 | FP_free (oname); |
1246 | _FP_free (oname); |
1247 | return UURET_IOERR; |
1247 | return UURET_IOERR; |
1248 | } |
1248 | } |
1249 | if (linperfile <= 0) |
1249 | if (linperfile <= 0) |
1250 | numparts = 1; |
1250 | numparts = 1; |
1251 | else |
1251 | else |
… | |
… | |
1273 | progress.totsize = -1; |
1273 | progress.totsize = -1; |
1274 | } |
1274 | } |
1275 | theifile = infile; |
1275 | theifile = infile; |
1276 | } |
1276 | } |
1277 | |
1277 | |
1278 | FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
1278 | _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); |
1279 | |
1279 | |
1280 | progress.totsize = (progress.totsize<=0) ? -1 : progress.totsize; |
1280 | progress.totsize = (progress.totsize<=0) ? -1 : progress.totsize; |
1281 | progress.numparts = numparts; |
1281 | progress.numparts = numparts; |
1282 | |
1282 | |
1283 | for (part=1; !feof (theifile); part++) { |
1283 | for (part=1; !feof (theifile); part++) { |
… | |
… | |
1403 | } |
1403 | } |
1404 | if (infile==NULL) fclose (theifile); |
1404 | if (infile==NULL) fclose (theifile); |
1405 | progress.action = 0; |
1405 | progress.action = 0; |
1406 | fclose (outfile); |
1406 | fclose (outfile); |
1407 | unlink (oname); |
1407 | unlink (oname); |
1408 | FP_free (oname); |
1408 | _FP_free (oname); |
1409 | return res; |
1409 | return res; |
1410 | } |
1410 | } |
1411 | |
1411 | |
1412 | if (feof (theifile) && |
1412 | if (feof (theifile) && |
1413 | (encoding == UU_ENCODED || encoding == XX_ENCODED)) { |
1413 | (encoding == UU_ENCODED || encoding == XX_ENCODED)) { |
… | |
… | |
1439 | fclose (outfile); |
1439 | fclose (outfile); |
1440 | } |
1440 | } |
1441 | |
1441 | |
1442 | if (infile==NULL) fclose (theifile); |
1442 | if (infile==NULL) fclose (theifile); |
1443 | progress.action = 0; |
1443 | progress.action = 0; |
1444 | FP_free (oname); |
1444 | _FP_free (oname); |
1445 | return UURET_OK; |
1445 | return UURET_OK; |
1446 | } |
1446 | } |
1447 | |
1447 | |
1448 | /* |
1448 | /* |
1449 | * Encode a MIME Mail message or Newsgroup posting and send to a |
1449 | * Encode a MIME Mail message or Newsgroup posting and send to a |
… | |
… | |
1488 | } |
1488 | } |
1489 | |
1489 | |
1490 | oname = UUFNameFilter ((outfname)?outfname:infname); |
1490 | oname = UUFNameFilter ((outfname)?outfname:infname); |
1491 | len = ((subject)?strlen(subject):0) + strlen(oname) + 40; |
1491 | len = ((subject)?strlen(subject):0) + strlen(oname) + 40; |
1492 | |
1492 | |
1493 | if ((ptr = FP_strrchr (oname, '.'))) { |
1493 | if ((ptr = _FP_strrchr (oname, '.'))) { |
1494 | while (miter->extension && FP_stricmp (ptr+1, miter->extension) != 0) |
1494 | while (miter->extension && _FP_stricmp (ptr+1, miter->extension) != 0) |
1495 | miter++; |
1495 | miter++; |
1496 | mimetype = miter->mimetype; |
1496 | mimetype = miter->mimetype; |
1497 | } |
1497 | } |
1498 | else |
1498 | else |
1499 | mimetype = NULL; |
1499 | mimetype = NULL; |
… | |
… | |
1549 | fprintf (outfile, "%s", eolstring); |
1549 | fprintf (outfile, "%s", eolstring); |
1550 | |
1550 | |
1551 | res = UUEncodeToStream (outfile, infile, infname, encoding, |
1551 | res = UUEncodeToStream (outfile, infile, infname, encoding, |
1552 | outfname, filemode); |
1552 | outfname, filemode); |
1553 | |
1553 | |
1554 | FP_free (subline); |
1554 | _FP_free (subline); |
1555 | return res; |
1555 | return res; |
1556 | } |
1556 | } |
1557 | |
1557 | |
1558 | int UUEXPORT |
1558 | int UUEXPORT |
1559 | UUE_PrepPartial (FILE *outfile, FILE *infile, |
1559 | UUE_PrepPartial (FILE *outfile, FILE *infile, |
… | |
… | |
1734 | res = UUEncodePartial (outfile, theifile, |
1734 | res = UUEncodePartial (outfile, theifile, |
1735 | infname, encoding, |
1735 | infname, encoding, |
1736 | (outfname)?outfname:infname, NULL, |
1736 | (outfname)?outfname:infname, NULL, |
1737 | themode, partno, linperfile); |
1737 | themode, partno, linperfile); |
1738 | |
1738 | |
1739 | FP_free (subline); |
1739 | _FP_free (subline); |
1740 | |
1740 | |
1741 | if (infile==NULL) { |
1741 | if (infile==NULL) { |
1742 | if (res != UURET_OK) { |
1742 | if (res != UURET_OK) { |
1743 | fclose (theifile); |
1743 | fclose (theifile); |
1744 | return res; |
1744 | return res; |