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

Comparing Convert-UUlib/uulib/uuencode.c (file contents):
Revision 1.2.2.2 by root, Sun Mar 31 19:52:07 2002 UTC vs.
Revision 1.2.2.3 by root, Sun Oct 13 13:03:08 2002 UTC

44 44
45#include <uudeview.h> 45#include <uudeview.h>
46#include <uuint.h> 46#include <uuint.h>
47#include <fptools.h> 47#include <fptools.h>
48#include <uustring.h> 48#include <uustring.h>
49#include <crc32.h>
49 50
50/* for braindead systems */ 51/* for braindead systems */
51#ifndef SEEK_SET 52#ifndef SEEK_SET
52#ifdef L_BEGIN 53#ifdef L_BEGIN
53#define SEEK_SET L_BEGIN 54#define SEEK_SET L_BEGIN
54#else 55#else
55#define SEEK_SET 0 56#define SEEK_SET 0
56#endif 57#endif
57#endif 58#endif
58 59
59char * uuencode_id = "$Id: uuencode.c,v 1.2.2.2 2002/03/31 19:52:07 root Exp $"; 60char * uuencode_id = "$Id: uuencode.c,v 1.2.2.3 2002/10/13 13:03:08 root Exp $";
60 61
61#if 0 62#if 0
62/* 63/*
63 * the End-Of-Line string. MIME enforces CRLF, so that's what we use. Some 64 * 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 65 * implementations of uudecode will complain about a missing end line, since
240/* 241/*
241 * Encode one part of the data stream 242 * Encode one part of the data stream
242 */ 243 */
243 244
244static int 245static int
245UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile) 246UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc32_t *crc, crc32_t *pcrc)
246{ 247{
247 unsigned char *itemp = (char *) uuestr_itemp; 248 unsigned char *itemp = (char *) uuestr_itemp;
248 unsigned char *otemp = (char *) uuestr_otemp; 249 unsigned char *otemp = (char *) uuestr_otemp;
249 unsigned char *optr, *table, *tptr; 250 unsigned char *optr, *table, *tptr;
250 int index, count; 251 int index, count;
420 else if (ferror (infile)) { 421 else if (ferror (infile)) {
421 return UURET_IOERR; 422 return UURET_IOERR;
422 } 423 }
423 } 424 }
424 425
426 if (pcrc)
427 *pcrc = crc32(*pcrc, itemp, count);
428 if (crc)
429 *crc = crc32(*crc, itemp, count);
430
425 line++; 431 line++;
426 432
427 /* 433 /*
428 * Busy Callback 434 * Busy Callback
429 */ 435 */
619 mimemap *miter=mimetable; 625 mimemap *miter=mimetable;
620 struct stat finfo; 626 struct stat finfo;
621 int res, themode; 627 int res, themode;
622 FILE *theifile; 628 FILE *theifile;
623 char *ptr; 629 char *ptr;
630 crc32_t crc;
631 crc32_t *crcptr=NULL;
624 632
625 if (outfile==NULL || 633 if (outfile==NULL ||
626 (infile == NULL && infname==NULL) || 634 (infile == NULL && infname==NULL) ||
627 (outfname==NULL && infname==NULL) || 635 (outfname==NULL && infname==NULL) ||
628 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 636 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
660 progress.fsize = (long) finfo.st_size; 668 progress.fsize = (long) finfo.st_size;
661 } 669 }
662 theifile = infile; 670 theifile = infile;
663 } 671 }
664 672
665 if (progress.fsize <= 0) 673 if (progress.fsize < 0)
666 progress.fsize = -1; 674 progress.fsize = -1;
667 675
668 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 676 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
669 677
670 progress.partno = 1; 678 progress.partno = 1;
711 (themode) ? themode : 0644, 719 (themode) ? themode : 0644,
712 UUFNameFilter ((outfname)?outfname:infname), 720 UUFNameFilter ((outfname)?outfname:infname),
713 eolstring); 721 eolstring);
714 } 722 }
715 else if (encoding == YENC_ENCODED) { 723 else if (encoding == YENC_ENCODED) {
724 crc = crc32(0L, Z_NULL, 0);
725 crcptr = &crc;
716 if (progress.fsize == -1) { 726 if (progress.fsize == -1) {
717 fprintf (outfile, "=ybegin line=128 name=%s%s", 727 fprintf (outfile, "=ybegin line=128 name=%s%s",
718 UUFNameFilter ((outfname)?outfname:infname), 728 UUFNameFilter ((outfname)?outfname:infname),
719 eolstring); 729 eolstring);
720 } 730 }
724 UUFNameFilter ((outfname)?outfname:infname), 734 UUFNameFilter ((outfname)?outfname:infname),
725 eolstring); 735 eolstring);
726 } 736 }
727 } 737 }
728 738
729 if ((res = UUEncodeStream (outfile, theifile, encoding, 0)) != UURET_OK) { 739 if ((res = UUEncodeStream (outfile, theifile, encoding, 0, crcptr, NULL)) != UURET_OK) {
730 if (res != UURET_CANCEL) { 740 if (res != UURET_CANCEL) {
731 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 741 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
732 uustring (S_ERR_ENCODING), 742 uustring (S_ERR_ENCODING),
733 UUFNameFilter ((infname)?infname:outfname), 743 UUFNameFilter ((infname)?infname:outfname),
734 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror(res)); 744 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror(res));
743 eolstring); 753 eolstring);
744 fprintf (outfile, "end%s", eolstring); 754 fprintf (outfile, "end%s", eolstring);
745 } 755 }
746 else if (encoding == YENC_ENCODED) { 756 else if (encoding == YENC_ENCODED) {
747 if (progress.fsize == -1) { 757 if (progress.fsize == -1) {
748 fprintf (outfile, "=yend%s", 758 fprintf (outfile, "=yend crc32=%08lx%s",
759 crc,
749 eolstring); 760 eolstring);
750 } 761 }
751 else { 762 else {
752 fprintf (outfile, "=yend size=%ld%s", 763 fprintf (outfile, "=yend size=%ld crc32=%08lx%s",
753 progress.fsize, 764 progress.fsize,
765 crc,
754 eolstring); 766 eolstring);
755 } 767 }
756 } 768 }
757 769
758 /* 770 /*
774 786
775int UUEXPORT 787int UUEXPORT
776UUEncodePartial (FILE *outfile, FILE *infile, 788UUEncodePartial (FILE *outfile, FILE *infile,
777 char *infname, int encoding, 789 char *infname, int encoding,
778 char *outfname, char *mimetype, 790 char *outfname, char *mimetype,
779 int filemode, int partno, long linperfile) 791 int filemode, int partno, long linperfile,
792 crc32_t *crcptr)
780{ 793{
781 mimemap *miter=mimetable; 794 mimemap *miter=mimetable;
782 static FILE *theifile; 795 static FILE *theifile;
783 int themode, numparts; 796 int themode, numparts;
784 struct stat finfo; 797 struct stat finfo;
785 long thesize; 798 long thesize;
786 char *ptr; 799 char *ptr;
787 int res; 800 int res;
801 crc32_t pcrc;
802 crc32_t *pcrcptr=NULL;
788 803
789 if ((outfname==NULL&&infname==NULL) || partno<=0 || 804 if ((outfname==NULL&&infname==NULL) || partno<=0 ||
790 (infile == NULL&&infname==NULL) || outfile==NULL || 805 (infile == NULL&&infname==NULL) || outfile==NULL ||
791 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 806 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
792 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) { 807 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
828 if (fstat (fileno (infile), &finfo) != 0) { 843 if (fstat (fileno (infile), &finfo) != 0) {
829 UUMessage (uuencode_id, __LINE__, UUMSG_WARNING, 844 UUMessage (uuencode_id, __LINE__, UUMSG_WARNING,
830 uustring (S_STAT_ONE_PART)); 845 uustring (S_STAT_ONE_PART));
831 numparts = 1; 846 numparts = 1;
832 themode = (filemode)?filemode:0644; 847 themode = (filemode)?filemode:0644;
833 thesize = 0; 848 thesize = -1;
834 } 849 }
835 else { 850 else {
836 if (linperfile <= 0) 851 if (linperfile <= 0)
837 numparts = 1; 852 numparts = 1;
838 else 853 else
845 theifile = infile; 860 theifile = infile;
846 } 861 }
847 862
848 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 863 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
849 864
850 progress.totsize = (thesize>0) ? thesize : -1; 865 progress.totsize = (thesize>=0) ? thesize : -1;
851 progress.partno = 1; 866 progress.partno = 1;
852 progress.numparts = numparts; 867 progress.numparts = numparts;
853 progress.percent = 0; 868 progress.percent = 0;
854 progress.foffset = 0; 869 progress.foffset = 0;
855 870
895 if (encoding == UU_ENCODED || encoding == XX_ENCODED) { 910 if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
896 fprintf (outfile, "begin %o %s%s", 911 fprintf (outfile, "begin %o %s%s",
897 (themode) ? themode : ((filemode)?filemode:0644), 912 (themode) ? themode : ((filemode)?filemode:0644),
898 UUFNameFilter ((outfname)?outfname:infname), eolstring); 913 UUFNameFilter ((outfname)?outfname:infname), eolstring);
899 } 914 }
915 }
900 else if (encoding == YENC_ENCODED) { 916 if (encoding == YENC_ENCODED) {
917 pcrc = crc32(0L, Z_NULL, 0);
918 pcrcptr = &pcrc;
901 if (numparts != 1) { 919 if (numparts != 1) {
902 if (progress.totsize == -1) { 920 if (progress.totsize == -1) {
903 fprintf (outfile, "=ybegin part=%d line=128 name=%s%s", 921 fprintf (outfile, "=ybegin part=%d line=128 name=%s%s",
904 partno, 922 partno,
905 UUFNameFilter ((outfname)?outfname:infname), 923 UUFNameFilter ((outfname)?outfname:infname),
906 eolstring);
907 }
908 else {
909 fprintf (outfile, "=ybegin part=%d line=128 size=%ld name=%s%s",
910 partno,
911 progress.totsize,
912 UUFNameFilter ((outfname)?outfname:infname),
913 eolstring);
914 }
915
916 fprintf (outfile, "=ypart begin=%d end=%d%s",
917 (partno-1)*linperfile*128+1,
918 (partno*linperfile*128) < progress.totsize ?
919 (partno*linperfile*128) : progress.totsize,
920 eolstring); 924 eolstring);
921 } 925 }
922 else { 926 else {
923 if (progress.totsize == -1) {
924 fprintf (outfile, "=ybegin line=128 name=%s%s", 927 fprintf (outfile, "=ybegin part=%d line=128 size=%ld name=%s%s",
928 partno,
929 progress.totsize,
925 UUFNameFilter ((outfname)?outfname:infname), 930 UUFNameFilter ((outfname)?outfname:infname),
926 eolstring); 931 eolstring);
927 } 932 }
928 else { 933
934 fprintf (outfile, "=ypart begin=%d end=%d%s",
935 (partno-1)*linperfile*128+1,
936 (partno*linperfile*128) < progress.totsize ?
937 (partno*linperfile*128) : progress.totsize,
938 eolstring);
939 }
940 else {
941 if (progress.totsize == -1) {
942 fprintf (outfile, "=ybegin line=128 name=%s%s",
943 UUFNameFilter ((outfname)?outfname:infname),
944 eolstring);
945 }
946 else {
929 fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s", 947 fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
930 progress.totsize, 948 progress.totsize,
931 UUFNameFilter ((outfname)?outfname:infname), 949 UUFNameFilter ((outfname)?outfname:infname),
932 eolstring); 950 eolstring);
933 }
934 } 951 }
935 } 952 }
936 } 953 }
937 954
938 /* 955 /*
952 else 969 else
953 progress.fsize = linperfile*bpl[encoding]; 970 progress.fsize = linperfile*bpl[encoding];
954 971
955 progress.action = UUACT_ENCODING; 972 progress.action = UUACT_ENCODING;
956 973
957 if ((res = UUEncodeStream (outfile, theifile, 974 if ((res = UUEncodeStream (outfile, theifile, encoding, linperfile,
958 encoding, linperfile)) != UURET_OK) { 975 crcptr, pcrcptr)) != UURET_OK) {
959 if (infile==NULL) fclose (theifile); 976 if (infile==NULL) fclose (theifile);
960 if (res != UURET_CANCEL) { 977 if (res != UURET_CANCEL) {
961 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 978 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
962 uustring (S_ERR_ENCODING), 979 uustring (S_ERR_ENCODING),
963 UUFNameFilter ((outfname)?outfname:infname), 980 UUFNameFilter ((outfname)?outfname:infname),
978 eolstring); 995 eolstring);
979 fprintf (outfile, "end%s", eolstring); 996 fprintf (outfile, "end%s", eolstring);
980 } 997 }
981 else if (encoding == YENC_ENCODED) { 998 else if (encoding == YENC_ENCODED) {
982 if (numparts != 1) { 999 if (numparts != 1) {
983 fprintf (outfile, "=yend size=%d part=%d%s", 1000 fprintf (outfile, "=yend size=%d part=%d pcrc32=%08lx",
984 (partno*linperfile*128) < progress.totsize ? 1001 (partno*linperfile*128) < progress.totsize ?
985 linperfile*128 : (progress.totsize-(partno-1)*linperfile*128), 1002 linperfile*128 : (progress.totsize-(partno-1)*linperfile*128),
986 partno, 1003 partno,
987 eolstring); 1004 pcrc);
988 } 1005 }
989 else { 1006 else {
990 fprintf (outfile, "=yend size=%d%s", 1007 fprintf (outfile, "=yend size=%d",
991 progress.totsize, 1008 progress.totsize);
992 eolstring);
993 } 1009 }
1010 if (feof (theifile))
1011 fprintf (outfile, " crc32=%08lx", *crcptr);
1012 fprintf (outfile, "%s", eolstring);
994 } 1013 }
995 1014
996 /* 1015 /*
997 * empty line at end does no harm 1016 * empty line at end does no harm
998 */ 1017 */
1033{ 1052{
1034 struct stat finfo; 1053 struct stat finfo;
1035 FILE *theifile; 1054 FILE *theifile;
1036 int themode; 1055 int themode;
1037 int res; 1056 int res;
1057 crc32_t crc;
1058 crc32_t *crcptr=NULL;
1038 1059
1039 if (outfile==NULL || 1060 if (outfile==NULL ||
1040 (infile == NULL&&infname==NULL) || 1061 (infile == NULL&&infname==NULL) ||
1041 (outfname==NULL&&infname==NULL) || 1062 (outfname==NULL&&infname==NULL) ||
1042 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1063 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
1075 progress.fsize = (long) finfo.st_size; 1096 progress.fsize = (long) finfo.st_size;
1076 } 1097 }
1077 theifile = infile; 1098 theifile = infile;
1078 } 1099 }
1079 1100
1080 if (progress.fsize <= 0) 1101 if (progress.fsize < 0)
1081 progress.fsize = -1; 1102 progress.fsize = -1;
1082 1103
1083 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 1104 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
1084 1105
1085 progress.partno = 1; 1106 progress.partno = 1;
1093 (themode) ? themode : 0644, 1114 (themode) ? themode : 0644,
1094 UUFNameFilter ((outfname)?outfname:infname), 1115 UUFNameFilter ((outfname)?outfname:infname),
1095 eolstring); 1116 eolstring);
1096 } 1117 }
1097 else if (encoding == YENC_ENCODED) { 1118 else if (encoding == YENC_ENCODED) {
1119 crc = crc32(0L, Z_NULL, 0);
1120 crcptr = &crc;
1098 if (progress.fsize == -1) { 1121 if (progress.fsize == -1) {
1099 fprintf (outfile, "=ybegin line=128 name=%s%s", 1122 fprintf (outfile, "=ybegin line=128 name=%s%s",
1100 UUFNameFilter ((outfname)?outfname:infname), 1123 UUFNameFilter ((outfname)?outfname:infname),
1101 eolstring); 1124 eolstring);
1102 } 1125 }
1106 UUFNameFilter ((outfname)?outfname:infname), 1129 UUFNameFilter ((outfname)?outfname:infname),
1107 eolstring); 1130 eolstring);
1108 } 1131 }
1109 } 1132 }
1110 1133
1111 if ((res = UUEncodeStream (outfile, theifile, encoding, 0)) != UURET_OK) { 1134 if ((res = UUEncodeStream (outfile, theifile, encoding, 0, crcptr, NULL)) != UURET_OK) {
1112 if (res != UURET_CANCEL) { 1135 if (res != UURET_CANCEL) {
1113 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1136 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1114 uustring (S_ERR_ENCODING), 1137 uustring (S_ERR_ENCODING),
1115 UUFNameFilter ((infname)?infname:outfname), 1138 UUFNameFilter ((infname)?infname:outfname),
1116 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res)); 1139 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res));
1125 eolstring); 1148 eolstring);
1126 fprintf (outfile, "end%s", eolstring); 1149 fprintf (outfile, "end%s", eolstring);
1127 } 1150 }
1128 else if (encoding == YENC_ENCODED) { 1151 else if (encoding == YENC_ENCODED) {
1129 if (progress.fsize == -1) { 1152 if (progress.fsize == -1) {
1130 fprintf (outfile, "=yend%s", 1153 fprintf (outfile, "=yend crc32=%08lx%s",
1154 crc,
1131 eolstring); 1155 eolstring);
1132 } 1156 }
1133 else { 1157 else {
1134 fprintf (outfile, "=yend size=%ld%s", 1158 fprintf (outfile, "=yend size=%ld crc32=%08lx%s",
1135 progress.fsize, 1159 progress.fsize,
1160 crc,
1136 eolstring); 1161 eolstring);
1137 } 1162 }
1138 } 1163 }
1139 1164
1140 /* 1165 /*
1159{ 1184{
1160 int part, numparts, len, filemode, res; 1185 int part, numparts, len, filemode, res;
1161 char *oname=NULL, *optr, *ptr; 1186 char *oname=NULL, *optr, *ptr;
1162 FILE *theifile, *outfile; 1187 FILE *theifile, *outfile;
1163 struct stat finfo; 1188 struct stat finfo;
1189 crc32_t pcrc, crc;
1190 crc32_t *pcrcptr=NULL, *crcptr=NULL;
1164 1191
1165 if ((diskname==NULL&&infname==NULL) || 1192 if ((diskname==NULL&&infname==NULL) ||
1166 (outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) || 1193 (outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) ||
1167 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1194 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
1168 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) { 1195 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
1275 theifile = infile; 1302 theifile = infile;
1276 } 1303 }
1277 1304
1278 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 1305 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
1279 1306
1280 progress.totsize = (progress.totsize<=0) ? -1 : progress.totsize; 1307 progress.totsize = (progress.totsize<0) ? -1 : progress.totsize;
1281 progress.numparts = numparts; 1308 progress.numparts = numparts;
1282 1309
1283 for (part=1; !feof (theifile); part++) { 1310 for (part=1; !feof (theifile); part++) {
1284 /* 1311 /*
1285 * Attach extension 1312 * Attach extension
1355 (filemode)?filemode : 0644, 1382 (filemode)?filemode : 0644,
1356 UUFNameFilter ((outfname)?outfname:infname), 1383 UUFNameFilter ((outfname)?outfname:infname),
1357 eolstring); 1384 eolstring);
1358 } 1385 }
1359 else if (encoding == YENC_ENCODED) { 1386 else if (encoding == YENC_ENCODED) {
1387 if (!crcptr) {
1388 crc = crc32(0L, Z_NULL, 0);
1389 crcptr = &crc;
1390 }
1391 pcrc = crc32(0L, Z_NULL, 0);
1392 pcrcptr = &pcrc;
1360 if (numparts != 1) { 1393 if (numparts != 1) {
1361 if (progress.totsize == -1) { 1394 if (progress.totsize == -1) {
1362 fprintf (outfile, "=ybegin part=%d line=128 name=%s%s", 1395 fprintf (outfile, "=ybegin part=%d line=128 name=%s%s",
1363 part, 1396 part,
1364 UUFNameFilter ((outfname)?outfname:infname), 1397 UUFNameFilter ((outfname)?outfname:infname),
1392 } 1425 }
1393 } 1426 }
1394 } 1427 }
1395 1428
1396 if ((res = UUEncodeStream (outfile, theifile, 1429 if ((res = UUEncodeStream (outfile, theifile,
1397 encoding, linperfile)) != UURET_OK) { 1430 encoding, linperfile, crcptr, pcrcptr)) != UURET_OK) {
1398 if (res != UURET_CANCEL) { 1431 if (res != UURET_CANCEL) {
1399 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1432 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1400 uustring (S_ERR_ENCODING), 1433 uustring (S_ERR_ENCODING),
1401 UUFNameFilter ((infname)?infname:outfname), 1434 UUFNameFilter ((infname)?infname:outfname),
1402 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res)); 1435 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res));
1416 eolstring); 1449 eolstring);
1417 fprintf (outfile, "end%s", eolstring); 1450 fprintf (outfile, "end%s", eolstring);
1418 } 1451 }
1419 else if (encoding == YENC_ENCODED) { 1452 else if (encoding == YENC_ENCODED) {
1420 if (numparts != 1) { 1453 if (numparts != 1) {
1421 fprintf (outfile, "=yend size=%d part=%d%s", 1454 fprintf (outfile, "=yend size=%d part=%d pcrc32=%08lx",
1422 (part*linperfile*128) < progress.totsize ? 1455 (part*linperfile*128) < progress.totsize ?
1423 linperfile*128 : (progress.totsize-(part-1)*linperfile*128), 1456 linperfile*128 : (progress.totsize-(part-1)*linperfile*128),
1424 part, 1457 part,
1425 eolstring); 1458 pcrc);
1426 } 1459 }
1427 else { 1460 else {
1428 fprintf (outfile, "=yend size=%d%s", 1461 fprintf (outfile, "=yend size=%d",
1429 progress.totsize, 1462 progress.totsize);
1430 eolstring);
1431 } 1463 }
1464 if (feof (theifile))
1465 fprintf (outfile, " crc32=%08lx", crc);
1466 fprintf (outfile, "%s", eolstring);
1432 } 1467 }
1433 1468
1434 /* 1469 /*
1435 * empty line at end does no harm 1470 * empty line at end does no harm
1436 */ 1471 */
1586 static FILE *theifile; 1621 static FILE *theifile;
1587 struct stat finfo; 1622 struct stat finfo;
1588 char *subline, *oname; 1623 char *subline, *oname;
1589 long thesize; 1624 long thesize;
1590 int res, len; 1625 int res, len;
1626 static crc32_t crc;
1627 crc32_t *crcptr=NULL;
1591 1628
1592 if ((outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) || 1629 if ((outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) ||
1593 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1630 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
1594 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) { 1631 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
1595 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1632 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1632 if (filesize <= 0) { 1669 if (filesize <= 0) {
1633 UUMessage (uuencode_id, __LINE__, UUMSG_WARNING, 1670 UUMessage (uuencode_id, __LINE__, UUMSG_WARNING,
1634 uustring (S_STAT_ONE_PART)); 1671 uustring (S_STAT_ONE_PART));
1635 numparts = 1; 1672 numparts = 1;
1636 themode = (filemode)?filemode:0644; 1673 themode = (filemode)?filemode:0644;
1637 thesize = 0; 1674 thesize = -1;
1638 } 1675 }
1639 else { 1676 else {
1640 if (linperfile <= 0) 1677 if (linperfile <= 0)
1641 numparts = 1; 1678 numparts = 1;
1642 else 1679 else
1687 return UURET_NOMEM; 1724 return UURET_NOMEM;
1688 } 1725 }
1689 1726
1690 1727
1691 if (encoding == YENC_ENCODED) { 1728 if (encoding == YENC_ENCODED) {
1729 if (partno == 1)
1730 crc = crc32(0L, Z_NULL, 0);
1731 crcptr = &crc;
1692 if (subject) 1732 if (subject)
1693 sprintf (subline, "- %s - %s (%03d/%03d)", oname, subject, 1733 sprintf (subline, "- %s - %s (%03d/%03d)", oname, subject,
1694 partno, numparts); 1734 partno, numparts);
1695 else 1735 else
1696 sprintf (subline, "- %s - (%03d/%03d)", oname, 1736 sprintf (subline, "- %s - (%03d/%03d)", oname,
1732 fprintf (outfile, "%s", eolstring); 1772 fprintf (outfile, "%s", eolstring);
1733 1773
1734 res = UUEncodePartial (outfile, theifile, 1774 res = UUEncodePartial (outfile, theifile,
1735 infname, encoding, 1775 infname, encoding,
1736 (outfname)?outfname:infname, NULL, 1776 (outfname)?outfname:infname, NULL,
1737 themode, partno, linperfile); 1777 themode, partno, linperfile, crcptr);
1738 1778
1739 _FP_free (subline); 1779 _FP_free (subline);
1740 1780
1741 if (infile==NULL) { 1781 if (infile==NULL) {
1742 if (res != UURET_OK) { 1782 if (res != UURET_OK) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines