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 by root, Mon Jun 11 20:42:37 2001 UTC vs.
Revision 1.2.2.2 by root, Sun Mar 31 19:52:07 2002 UTC

54#else 54#else
55#define SEEK_SET 0 55#define SEEK_SET 0
56#endif 56#endif
57#endif 57#endif
58 58
59char * uuencode_id = "$Id: uuencode.c,v 1.2 2001/06/11 20:42:37 root Exp $"; 59char * uuencode_id = "$Id: uuencode.c,v 1.2.2.2 2002/03/31 19:52:07 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
108 */ 108 */
109 109
110#define CTE_UUENC "x-uuencode" 110#define CTE_UUENC "x-uuencode"
111#define CTE_XXENC "x-xxencode" 111#define CTE_XXENC "x-xxencode"
112#define CTE_BINHEX "x-binhex" 112#define CTE_BINHEX "x-binhex"
113#define CTE_YENC "x-yenc"
113 114
114#define CTE_TYPE(y) (((y)==B64ENCODED) ? "Base64" : \ 115#define CTE_TYPE(y) (((y)==B64ENCODED) ? "Base64" : \
115 ((y)==UU_ENCODED) ? CTE_UUENC : \ 116 ((y)==UU_ENCODED) ? CTE_UUENC : \
116 ((y)==XX_ENCODED) ? CTE_XXENC : \ 117 ((y)==XX_ENCODED) ? CTE_XXENC : \
117 ((y)==PT_ENCODED) ? "8bit" : \ 118 ((y)==PT_ENCODED) ? "8bit" : \
118 ((y)==QP_ENCODED) ? "quoted-printable" : \ 119 ((y)==QP_ENCODED) ? "quoted-printable" : \
119 ((y)==BH_ENCODED) ? CTE_BINHEX : "x-oops") 120 ((y)==BH_ENCODED) ? CTE_BINHEX : \
121 ((y)==YENC_ENCODED) ? CTE_YENC : "x-oops")
120 122
121/* 123/*
122 * encoding tables 124 * encoding tables
123 */ 125 */
124 126
212 214
213/* 215/*
214 * encoded bytes per line 216 * encoded bytes per line
215 */ 217 */
216 218
217static int bpl[5] = { 0, 45, 57, 45, 45 }; 219static int bpl[8] = { 0, 45, 57, 45, 45, 0, 0, 128 };
218 220
219/* 221/*
220 * tables 222 * tables
221 */ 223 */
222 224
240 */ 242 */
241 243
242static int 244static int
243UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile) 245UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile)
244{ 246{
245 uchar *itemp = (uchar *) uuestr_itemp; 247 unsigned char *itemp = (char *) uuestr_itemp;
246 uchar *otemp = (uchar *) uuestr_otemp; 248 unsigned char *otemp = (char *) uuestr_otemp;
247 unsigned char *optr, *table, *tptr; 249 unsigned char *optr, *table, *tptr;
248 int index, count; 250 int index, count;
249 long line=0; 251 long line=0;
250 size_t llen; 252 size_t llen;
251 253
252 if (outfile==NULL || infile==NULL || 254 if (outfile==NULL || infile==NULL ||
253 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 255 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
254 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 256 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
255 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 257 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
256 uustring (S_PARM_CHECK), "UUEncodeStream()"); 258 uustring (S_PARM_CHECK), "UUEncodeStream()");
257 return UURET_ILLVAL; 259 return UURET_ILLVAL;
258 } 260 }
259 261
262 * read line oriented. 264 * read line oriented.
263 */ 265 */
264 266
265 if (encoding == PT_ENCODED || encoding == QP_ENCODED) { 267 if (encoding == PT_ENCODED || encoding == QP_ENCODED) {
266 while (!feof (infile) && (linperfile <= 0 || line < linperfile)) { 268 while (!feof (infile) && (linperfile <= 0 || line < linperfile)) {
267 if (FP_fgets (itemp, 255, infile) == NULL) { 269 if (_FP_fgets (itemp, 255, infile) == NULL) {
268 break; 270 break;
269 } 271 }
270 272
271 itemp[255] = '\0'; 273 itemp[255] = '\0';
272 count = strlen (itemp); 274 count = strlen (itemp);
375 * line break. 377 * line break.
376 */ 378 */
377 379
378 if (itemp[index+1] != 0 && itemp[index+1] != '\n' && 380 if (itemp[index+1] != 0 && itemp[index+1] != '\n' &&
379 (llen >= 75 || 381 (llen >= 75 ||
380 !((itemp[index+1] >= 33 && itemp[index+1] <= 60) || 382 (!((itemp[index+1] >= 33 && itemp[index+1] <= 60) ||
381 (itemp[index+1] >= 62 && itemp[index+1] <= 126)) && 383 (itemp[index+1] >= 62 && itemp[index+1] <= 126)) &&
382 llen >= 73)) { 384 llen >= 73))) {
383 385
384 *optr++ = '='; 386 *optr++ = '=';
385 llen++; 387 llen++;
386 388
387 if (fwrite (otemp, 1, llen, outfile) != llen || 389 if (fwrite (otemp, 1, llen, outfile) != llen ||
401 403
402 return UURET_OK; 404 return UURET_OK;
403 } 405 }
404 406
405 /* 407 /*
408 * Special handling for yEnc
409 */
410
411 if (encoding == YENC_ENCODED) {
412 llen = 0;
413 optr = otemp;
414
415 while (!feof (infile) && (linperfile <= 0 || line < linperfile)) {
416 if ((count = fread (itemp, 1, 128, infile)) != 128) {
417 if (count == 0) {
418 break;
419 }
420 else if (ferror (infile)) {
421 return UURET_IOERR;
422 }
423 }
424
425 line++;
426
427 /*
428 * Busy Callback
429 */
430
431 if (UUBUSYPOLL(ftell(infile)-progress.foffset,progress.fsize)) {
432 UUMessage (uuencode_id, __LINE__, UUMSG_NOTE,
433 uustring (S_ENCODE_CANCEL));
434 return UURET_CANCEL;
435 }
436
437 for (index=0; index<count; index++) {
438 if (llen > 127) {
439 if (fwrite (otemp, 1, llen, outfile) != llen ||
440 fwrite ((char *) eolstring, 1,
441 strlen(eolstring), outfile) != strlen (eolstring)) {
442 return UURET_IOERR;
443 }
444 llen = 0;
445 optr = otemp;
446 }
447
448 switch ((char) ((int) itemp[index] + 42)) {
449 case '\0':
450 case '\t':
451 case '\n':
452 case '\r':
453 case '=':
454 case '\033':
455 *optr++ = '=';
456 *optr++ = (char) ((int) itemp[index] + 42 + 64);
457 llen += 2;
458 break;
459
460 case '.':
461 if (llen == 0) {
462 *optr++ = '=';
463 *optr++ = (char) ((int) itemp[index] + 42 + 64);
464 llen += 2;
465 }
466 else {
467 *optr++ = (char) ((int) itemp[index] + 42);
468 llen++;
469 }
470 break;
471
472 default:
473 *optr++ = (char) ((int) itemp[index] + 42);
474 llen++;
475 break;
476 }
477 }
478 }
479
480 /*
481 * write last line
482 */
483
484 if (llen) {
485 if (fwrite (otemp, 1, llen, outfile) != llen ||
486 fwrite ((char *) eolstring, 1,
487 strlen(eolstring), outfile) != strlen (eolstring)) {
488 return UURET_IOERR;
489 }
490 }
491
492 return UURET_OK;
493 }
494
495 /*
406 * Handling for binary encodings 496 * Handling for binary encodings
407 */ 497 */
408 498
409 /* 499 /*
410 * select charset 500 * select charset
450 540
451 /* 541 /*
452 * Main encoding 542 * Main encoding
453 */ 543 */
454 544
455 if (encoding == UU_ENCODED || encoding == XX_ENCODED ||
456 encoding == B64ENCODED) {
457 for (index=0; index<=count-3; index+=3, llen+=4) { 545 for (index=0; index<=count-3; index+=3, llen+=4) {
458 *optr++ = table[itemp[index] >> 2]; 546 *optr++ = table[itemp[index] >> 2];
459 *optr++ = table[((itemp[index ] & 0x03) << 4)|(itemp[index+1] >> 4)]; 547 *optr++ = table[((itemp[index ] & 0x03) << 4)|(itemp[index+1] >> 4)];
460 *optr++ = table[((itemp[index+1] & 0x0f) << 2)|(itemp[index+2] >> 6)]; 548 *optr++ = table[((itemp[index+1] & 0x0f) << 2)|(itemp[index+2] >> 6)];
461 *optr++ = table[ itemp[index+2] & 0x3f]; 549 *optr++ = table[ itemp[index+2] & 0x3f];
462 }
463 } 550 }
464 551
465 /* 552 /*
466 * Special handling for incomplete lines 553 * Special handling for incomplete lines
467 */ 554 */
537 624
538 if (outfile==NULL || 625 if (outfile==NULL ||
539 (infile == NULL && infname==NULL) || 626 (infile == NULL && infname==NULL) ||
540 (outfname==NULL && infname==NULL) || 627 (outfname==NULL && infname==NULL) ||
541 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 628 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
542 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 629 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
543 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 630 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
544 uustring (S_PARM_CHECK), "UUEncodeMulti()"); 631 uustring (S_PARM_CHECK), "UUEncodeMulti()");
545 return UURET_ILLVAL; 632 return UURET_ILLVAL;
546 } 633 }
547 634
576 } 663 }
577 664
578 if (progress.fsize <= 0) 665 if (progress.fsize <= 0)
579 progress.fsize = -1; 666 progress.fsize = -1;
580 667
581 FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 668 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
582 669
583 progress.partno = 1; 670 progress.partno = 1;
584 progress.numparts = 1; 671 progress.numparts = 1;
585 progress.percent = 0; 672 progress.percent = 0;
586 progress.foffset = 0; 673 progress.foffset = 0;
591 * 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
592 * Application/Octet-Stream 679 * Application/Octet-Stream
593 */ 680 */
594 681
595 if (mimetype == NULL) { 682 if (mimetype == NULL) {
596 if ((ptr = FP_strrchr ((outfname)?outfname:infname, '.'))) { 683 if ((ptr = _FP_strrchr ((outfname)?outfname:infname, '.'))) {
597 while (miter->extension && FP_stricmp (ptr+1, miter->extension) != 0) 684 while (miter->extension && _FP_stricmp (ptr+1, miter->extension) != 0)
598 miter++; 685 miter++;
599 mimetype = miter->mimetype; 686 mimetype = miter->mimetype;
600 } 687 }
601 } 688 }
602 689
606 693
607 /* 694 /*
608 * print sub-header 695 * print sub-header
609 */ 696 */
610 697
698 if (encoding != YENC_ENCODED) {
611 fprintf (outfile, "Content-Type: %s%s", 699 fprintf (outfile, "Content-Type: %s%s",
612 (mimetype)?mimetype:"Application/Octet-Stream", 700 (mimetype)?mimetype:"Application/Octet-Stream",
613 eolstring); 701 eolstring);
614 fprintf (outfile, "Content-Transfer-Encoding: %s%s", 702 fprintf (outfile, "Content-Transfer-Encoding: %s%s",
615 CTE_TYPE(encoding), eolstring); 703 CTE_TYPE(encoding), eolstring);
616 fprintf (outfile, "Content-Disposition: attachment; filename=\"%s\"%s", 704 fprintf (outfile, "Content-Disposition: attachment; filename=\"%s\"%s",
617 UUFNameFilter ((outfname)?outfname:infname), eolstring); 705 UUFNameFilter ((outfname)?outfname:infname), eolstring);
618 fprintf (outfile, "%s", eolstring); 706 fprintf (outfile, "%s", eolstring);
707 }
619 708
620 if (encoding == UU_ENCODED || encoding == XX_ENCODED) { 709 if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
621 fprintf (outfile, "begin %o %s%s", 710 fprintf (outfile, "begin %o %s%s",
622 (themode) ? themode : 0644, 711 (themode) ? themode : 0644,
623 UUFNameFilter ((outfname)?outfname:infname), 712 UUFNameFilter ((outfname)?outfname:infname),
624 eolstring); 713 eolstring);
625 } 714 }
715 else if (encoding == YENC_ENCODED) {
716 if (progress.fsize == -1) {
717 fprintf (outfile, "=ybegin line=128 name=%s%s",
718 UUFNameFilter ((outfname)?outfname:infname),
719 eolstring);
720 }
721 else {
722 fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
723 progress.fsize,
724 UUFNameFilter ((outfname)?outfname:infname),
725 eolstring);
726 }
727 }
728
626 if ((res = UUEncodeStream (outfile, theifile, encoding, 0)) != UURET_OK) { 729 if ((res = UUEncodeStream (outfile, theifile, encoding, 0)) != UURET_OK) {
627 if (res != UURET_CANCEL) { 730 if (res != UURET_CANCEL) {
628 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 731 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
629 uustring (S_ERR_ENCODING), 732 uustring (S_ERR_ENCODING),
630 UUFNameFilter ((infname)?infname:outfname), 733 UUFNameFilter ((infname)?infname:outfname),
631 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror(res)); 734 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror(res));
632 } 735 }
633 progress.action = 0; 736 progress.action = 0;
634 return res; 737 return res;
635 } 738 }
739
636 if (encoding == UU_ENCODED || encoding == XX_ENCODED) { 740 if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
637 fprintf (outfile, "%c%s", 741 fprintf (outfile, "%c%s",
638 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 742 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
639 eolstring); 743 eolstring);
640 fprintf (outfile, "end%s", eolstring); 744 fprintf (outfile, "end%s", eolstring);
641 } 745 }
746 else if (encoding == YENC_ENCODED) {
747 if (progress.fsize == -1) {
748 fprintf (outfile, "=yend%s",
749 eolstring);
750 }
751 else {
752 fprintf (outfile, "=yend size=%ld%s",
753 progress.fsize,
754 eolstring);
755 }
756 }
757
642 /* 758 /*
643 * empty line at end does no harm 759 * empty line at end does no harm
644 */ 760 */
761
645 fprintf (outfile, "%s", eolstring); 762 fprintf (outfile, "%s", eolstring);
646 763
647 if (infile==NULL) 764 if (infile==NULL)
648 fclose (theifile); 765 fclose (theifile);
649 766
670 int res; 787 int res;
671 788
672 if ((outfname==NULL&&infname==NULL) || partno<=0 || 789 if ((outfname==NULL&&infname==NULL) || partno<=0 ||
673 (infile == NULL&&infname==NULL) || outfile==NULL || 790 (infile == NULL&&infname==NULL) || outfile==NULL ||
674 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 791 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
675 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 792 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
676 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 793 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
677 uustring (S_PARM_CHECK), "UUEncodePartial()"); 794 uustring (S_PARM_CHECK), "UUEncodePartial()");
678 return UURET_ILLVAL; 795 return UURET_ILLVAL;
679 } 796 }
680 797
726 thesize = (long) finfo.st_size; 843 thesize = (long) finfo.st_size;
727 } 844 }
728 theifile = infile; 845 theifile = infile;
729 } 846 }
730 847
731 FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 848 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
732 849
733 progress.totsize = (thesize>0) ? thesize : -1; 850 progress.totsize = (thesize>0) ? thesize : -1;
734 progress.partno = 1; 851 progress.partno = 1;
735 progress.numparts = numparts; 852 progress.numparts = numparts;
736 progress.percent = 0; 853 progress.percent = 0;
741 * 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
742 * Application/Octet-Stream 859 * Application/Octet-Stream
743 */ 860 */
744 861
745 if (mimetype == NULL) { 862 if (mimetype == NULL) {
746 if ((ptr = FP_strrchr ((outfname)?outfname:infname, '.'))) { 863 if ((ptr = _FP_strrchr ((outfname)?outfname:infname, '.'))) {
747 while (miter->extension && FP_stricmp (ptr+1, miter->extension) != 0) 864 while (miter->extension && _FP_stricmp (ptr+1, miter->extension) != 0)
748 miter++; 865 miter++;
749 mimetype = miter->mimetype; 866 mimetype = miter->mimetype;
750 } 867 }
751 } 868 }
752 869
756 873
757 /* 874 /*
758 * print sub-header 875 * print sub-header
759 */ 876 */
760 877
878 if (encoding != YENC_ENCODED) {
761 fprintf (outfile, "MIME-Version: 1.0%s", eolstring); 879 fprintf (outfile, "MIME-Version: 1.0%s", eolstring);
762 fprintf (outfile, "Content-Type: %s%s", 880 fprintf (outfile, "Content-Type: %s%s",
763 (mimetype)?mimetype:"Application/Octet-Stream", 881 (mimetype)?mimetype:"Application/Octet-Stream",
764 eolstring); 882 eolstring);
765 fprintf (outfile, "Content-Transfer-Encoding: %s%s", 883 fprintf (outfile, "Content-Transfer-Encoding: %s%s",
766 CTE_TYPE(encoding), eolstring); 884 CTE_TYPE(encoding), eolstring);
767 fprintf (outfile, "Content-Disposition: attachment; filename=\"%s\"%s", 885 fprintf (outfile, "Content-Disposition: attachment; filename=\"%s\"%s",
768 UUFNameFilter ((outfname)?outfname:infname), eolstring); 886 UUFNameFilter ((outfname)?outfname:infname), eolstring);
887 }
888
769 fprintf (outfile, "%s", eolstring); 889 fprintf (outfile, "%s", eolstring);
770 890
771 /* 891 /*
772 * for the first part of UU or XX messages, print a begin line 892 * for the first part of UU or XX messages, print a begin line
773 */ 893 */
894
774 if (encoding == UU_ENCODED || encoding == XX_ENCODED) { 895 if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
775 fprintf (outfile, "begin %o %s%s", 896 fprintf (outfile, "begin %o %s%s",
776 (themode) ? themode : ((filemode)?filemode:0644), 897 (themode) ? themode : ((filemode)?filemode:0644),
777 UUFNameFilter ((outfname)?outfname:infname), eolstring); 898 UUFNameFilter ((outfname)?outfname:infname), eolstring);
899 }
900 else if (encoding == YENC_ENCODED) {
901 if (numparts != 1) {
902 if (progress.totsize == -1) {
903 fprintf (outfile, "=ybegin part=%d line=128 name=%s%s",
904 partno,
905 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);
921 }
922 else {
923 if (progress.totsize == -1) {
924 fprintf (outfile, "=ybegin line=128 name=%s%s",
925 UUFNameFilter ((outfname)?outfname:infname),
926 eolstring);
927 }
928 else {
929 fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
930 progress.totsize,
931 UUFNameFilter ((outfname)?outfname:infname),
932 eolstring);
933 }
934 }
778 } 935 }
779 } 936 }
780 937
781 /* 938 /*
782 * update progress information 939 * update progress information
807 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res)); 964 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res));
808 } 965 }
809 progress.action = 0; 966 progress.action = 0;
810 return res; 967 return res;
811 } 968 }
969
812 /* 970 /*
813 * print end line 971 * print end line
814 */ 972 */
973
815 if (feof (theifile) && 974 if (feof (theifile) &&
816 (encoding == UU_ENCODED || encoding == XX_ENCODED)) { 975 (encoding == UU_ENCODED || encoding == XX_ENCODED)) {
817 fprintf (outfile, "%c%s", 976 fprintf (outfile, "%c%s",
818 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 977 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
819 eolstring); 978 eolstring);
820 fprintf (outfile, "end%s", eolstring); 979 fprintf (outfile, "end%s", eolstring);
980 }
981 else if (encoding == YENC_ENCODED) {
982 if (numparts != 1) {
983 fprintf (outfile, "=yend size=%d part=%d%s",
984 (partno*linperfile*128) < progress.totsize ?
985 linperfile*128 : (progress.totsize-(partno-1)*linperfile*128),
986 partno,
987 eolstring);
988 }
989 else {
990 fprintf (outfile, "=yend size=%d%s",
991 progress.totsize,
992 eolstring);
993 }
821 } 994 }
822 995
823 /* 996 /*
824 * empty line at end does no harm 997 * empty line at end does no harm
825 */ 998 */
865 1038
866 if (outfile==NULL || 1039 if (outfile==NULL ||
867 (infile == NULL&&infname==NULL) || 1040 (infile == NULL&&infname==NULL) ||
868 (outfname==NULL&&infname==NULL) || 1041 (outfname==NULL&&infname==NULL) ||
869 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1042 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
870 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 1043 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
871 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1044 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
872 uustring (S_PARM_CHECK), "UUEncodeToStream()"); 1045 uustring (S_PARM_CHECK), "UUEncodeToStream()");
873 return UURET_ILLVAL; 1046 return UURET_ILLVAL;
874 } 1047 }
875 1048
905 } 1078 }
906 1079
907 if (progress.fsize <= 0) 1080 if (progress.fsize <= 0)
908 progress.fsize = -1; 1081 progress.fsize = -1;
909 1082
910 FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 1083 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
911 1084
912 progress.partno = 1; 1085 progress.partno = 1;
913 progress.numparts = 1; 1086 progress.numparts = 1;
914 progress.percent = 0; 1087 progress.percent = 0;
915 progress.foffset = 0; 1088 progress.foffset = 0;
919 fprintf (outfile, "begin %o %s%s", 1092 fprintf (outfile, "begin %o %s%s",
920 (themode) ? themode : 0644, 1093 (themode) ? themode : 0644,
921 UUFNameFilter ((outfname)?outfname:infname), 1094 UUFNameFilter ((outfname)?outfname:infname),
922 eolstring); 1095 eolstring);
923 } 1096 }
1097 else if (encoding == YENC_ENCODED) {
1098 if (progress.fsize == -1) {
1099 fprintf (outfile, "=ybegin line=128 name=%s%s",
1100 UUFNameFilter ((outfname)?outfname:infname),
1101 eolstring);
1102 }
1103 else {
1104 fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
1105 progress.fsize,
1106 UUFNameFilter ((outfname)?outfname:infname),
1107 eolstring);
1108 }
1109 }
1110
924 if ((res = UUEncodeStream (outfile, theifile, encoding, 0)) != UURET_OK) { 1111 if ((res = UUEncodeStream (outfile, theifile, encoding, 0)) != UURET_OK) {
925 if (res != UURET_CANCEL) { 1112 if (res != UURET_CANCEL) {
926 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1113 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
927 uustring (S_ERR_ENCODING), 1114 uustring (S_ERR_ENCODING),
928 UUFNameFilter ((infname)?infname:outfname), 1115 UUFNameFilter ((infname)?infname:outfname),
929 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res)); 1116 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res));
930 } 1117 }
931 progress.action = 0; 1118 progress.action = 0;
932 return res; 1119 return res;
933 } 1120 }
1121
934 if (encoding == UU_ENCODED || encoding == XX_ENCODED) { 1122 if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
935 fprintf (outfile, "%c%s", 1123 fprintf (outfile, "%c%s",
936 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 1124 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
937 eolstring); 1125 eolstring);
938 fprintf (outfile, "end%s", eolstring); 1126 fprintf (outfile, "end%s", eolstring);
939 } 1127 }
1128 else if (encoding == YENC_ENCODED) {
1129 if (progress.fsize == -1) {
1130 fprintf (outfile, "=yend%s",
1131 eolstring);
1132 }
1133 else {
1134 fprintf (outfile, "=yend size=%ld%s",
1135 progress.fsize,
1136 eolstring);
1137 }
1138 }
1139
940 /* 1140 /*
941 * empty line at end does no harm 1141 * empty line at end does no harm
942 */ 1142 */
1143
943 fprintf (outfile, "%s", eolstring); 1144 fprintf (outfile, "%s", eolstring);
944 1145
945 if (infile==NULL) fclose (theifile); 1146 if (infile==NULL) fclose (theifile);
946 progress.action = 0; 1147 progress.action = 0;
947 1148
962 struct stat finfo; 1163 struct stat finfo;
963 1164
964 if ((diskname==NULL&&infname==NULL) || 1165 if ((diskname==NULL&&infname==NULL) ||
965 (outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) || 1166 (outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) ||
966 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1167 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
967 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 1168 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
968 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1169 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
969 uustring (S_PARM_CHECK), "UUEncodeToFile()"); 1170 uustring (S_PARM_CHECK), "UUEncodeToFile()");
970 return UURET_ILLVAL; 1171 return UURET_ILLVAL;
971 } 1172 }
972 1173
1014 /* 1215 /*
1015 * 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
1016 * there. 1217 * there.
1017 */ 1218 */
1018 1219
1019 optr = FP_strrchr (oname, '.'); 1220 optr = _FP_strrchr (oname, '.');
1020 if (optr==NULL || strchr (optr, '/')!=NULL || strchr (optr, '\\')!=NULL) { 1221 if (optr==NULL || strchr (optr, '/')!=NULL || strchr (optr, '\\')!=NULL) {
1021 optr = oname + strlen (oname); 1222 optr = oname + strlen (oname);
1022 *optr++ = '.'; 1223 *optr++ = '.';
1023 } 1224 }
1024 else if (optr==oname || *(optr-1)=='/' || *(optr-1)=='\\') { 1225 else if (optr==oname || *(optr-1)=='/' || *(optr-1)=='\\') {
1033 if (infile==NULL) { 1234 if (infile==NULL) {
1034 if (stat (infname, &finfo) == -1) { 1235 if (stat (infname, &finfo) == -1) {
1035 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1236 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1036 uustring (S_NOT_STAT_FILE), 1237 uustring (S_NOT_STAT_FILE),
1037 infname, strerror (uu_errno=errno)); 1238 infname, strerror (uu_errno=errno));
1038 FP_free (oname); 1239 _FP_free (oname);
1039 return UURET_IOERR; 1240 return UURET_IOERR;
1040 } 1241 }
1041 if ((theifile = fopen (infname, "rb")) == NULL) { 1242 if ((theifile = fopen (infname, "rb")) == NULL) {
1042 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1243 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1043 uustring (S_NOT_OPEN_FILE), 1244 uustring (S_NOT_OPEN_FILE),
1044 infname, strerror (uu_errno=errno)); 1245 infname, strerror (uu_errno=errno));
1045 FP_free (oname); 1246 _FP_free (oname);
1046 return UURET_IOERR; 1247 return UURET_IOERR;
1047 } 1248 }
1048 if (linperfile <= 0) 1249 if (linperfile <= 0)
1049 numparts = 1; 1250 numparts = 1;
1050 else 1251 else
1072 progress.totsize = -1; 1273 progress.totsize = -1;
1073 } 1274 }
1074 theifile = infile; 1275 theifile = infile;
1075 } 1276 }
1076 1277
1077 FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256); 1278 _FP_strncpy (progress.curfile, (outfname)?outfname:infname, 256);
1078 1279
1079 progress.totsize = (progress.totsize<=0) ? -1 : progress.totsize; 1280 progress.totsize = (progress.totsize<=0) ? -1 : progress.totsize;
1080 progress.numparts = numparts; 1281 progress.numparts = numparts;
1081 1282
1082 for (part=1; !feof (theifile); part++) { 1283 for (part=1; !feof (theifile); part++) {
1130 if (infile==NULL) fclose (theifile); 1331 if (infile==NULL) fclose (theifile);
1131 progress.action = 0; 1332 progress.action = 0;
1132 free (oname); 1333 free (oname);
1133 return UURET_IOERR; 1334 return UURET_IOERR;
1134 } 1335 }
1336
1337 if (encoding != YENC_ENCODED) {
1135 fprintf (outfile, "%s", eolstring); 1338 fprintf (outfile, "%s", eolstring);
1136 fprintf (outfile, "_=_ %s", eolstring); 1339 fprintf (outfile, "_=_ %s", eolstring);
1137 if (numparts == -1) 1340 if (numparts == -1)
1138 fprintf (outfile, "_=_ Part %03d of file %s%s", 1341 fprintf (outfile, "_=_ Part %03d of file %s%s",
1139 part, UUFNameFilter ((outfname)?outfname:infname), 1342 part, UUFNameFilter ((outfname)?outfname:infname),
1140 eolstring); 1343 eolstring);
1141 else 1344 else
1142 fprintf (outfile, "_=_ Part %03d of %03d of file %s%s", 1345 fprintf (outfile, "_=_ Part %03d of %03d of file %s%s",
1143 part, numparts, 1346 part, numparts,
1144 UUFNameFilter ((outfname)?outfname:infname), 1347 UUFNameFilter ((outfname)?outfname:infname),
1145 eolstring); 1348 eolstring);
1146 fprintf (outfile, "_=_ %s", eolstring); 1349 fprintf (outfile, "_=_ %s", eolstring);
1147 fprintf (outfile, "%s", eolstring); 1350 fprintf (outfile, "%s", eolstring);
1351 }
1148 1352
1149 if (part==1 && (encoding == UU_ENCODED || encoding == XX_ENCODED)) { 1353 if (part==1 && (encoding == UU_ENCODED || encoding == XX_ENCODED)) {
1150 fprintf (outfile, "begin %o %s%s", 1354 fprintf (outfile, "begin %o %s%s",
1151 (filemode)?filemode : 0644, 1355 (filemode)?filemode : 0644,
1152 UUFNameFilter ((outfname)?outfname:infname), 1356 UUFNameFilter ((outfname)?outfname:infname),
1153 eolstring); 1357 eolstring);
1154 } 1358 }
1359 else if (encoding == YENC_ENCODED) {
1360 if (numparts != 1) {
1361 if (progress.totsize == -1) {
1362 fprintf (outfile, "=ybegin part=%d line=128 name=%s%s",
1363 part,
1364 UUFNameFilter ((outfname)?outfname:infname),
1365 eolstring);
1366 }
1367 else {
1368 fprintf (outfile, "=ybegin part=%d line=128 size=%ld name=%s%s",
1369 part,
1370 progress.totsize,
1371 UUFNameFilter ((outfname)?outfname:infname),
1372 eolstring);
1373 }
1374
1375 fprintf (outfile, "=ypart begin=%d end=%d%s",
1376 (part-1)*linperfile*128+1,
1377 (part*linperfile*128) < progress.totsize ?
1378 (part*linperfile*128) : progress.totsize,
1379 eolstring);
1380 }
1381 else {
1382 if (progress.totsize == -1) {
1383 fprintf (outfile, "=ybegin line=128 name=%s%s",
1384 UUFNameFilter ((outfname)?outfname:infname),
1385 eolstring);
1386 }
1387 else {
1388 fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
1389 progress.totsize,
1390 UUFNameFilter ((outfname)?outfname:infname),
1391 eolstring);
1392 }
1393 }
1394 }
1395
1155 if ((res = UUEncodeStream (outfile, theifile, 1396 if ((res = UUEncodeStream (outfile, theifile,
1156 encoding, linperfile)) != UURET_OK) { 1397 encoding, linperfile)) != UURET_OK) {
1157 if (res != UURET_CANCEL) { 1398 if (res != UURET_CANCEL) {
1158 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1399 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1159 uustring (S_ERR_ENCODING), 1400 uustring (S_ERR_ENCODING),
1162 } 1403 }
1163 if (infile==NULL) fclose (theifile); 1404 if (infile==NULL) fclose (theifile);
1164 progress.action = 0; 1405 progress.action = 0;
1165 fclose (outfile); 1406 fclose (outfile);
1166 unlink (oname); 1407 unlink (oname);
1167 FP_free (oname); 1408 _FP_free (oname);
1168 return res; 1409 return res;
1169 } 1410 }
1411
1170 if (feof (theifile) && 1412 if (feof (theifile) &&
1171 (encoding == UU_ENCODED || encoding == XX_ENCODED)) { 1413 (encoding == UU_ENCODED || encoding == XX_ENCODED)) {
1172 fprintf (outfile, "%c%s", 1414 fprintf (outfile, "%c%s",
1173 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 1415 (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
1174 eolstring); 1416 eolstring);
1175 fprintf (outfile, "end%s", eolstring); 1417 fprintf (outfile, "end%s", eolstring);
1176 } 1418 }
1419 else if (encoding == YENC_ENCODED) {
1420 if (numparts != 1) {
1421 fprintf (outfile, "=yend size=%d part=%d%s",
1422 (part*linperfile*128) < progress.totsize ?
1423 linperfile*128 : (progress.totsize-(part-1)*linperfile*128),
1424 part,
1425 eolstring);
1426 }
1427 else {
1428 fprintf (outfile, "=yend size=%d%s",
1429 progress.totsize,
1430 eolstring);
1431 }
1432 }
1433
1177 /* 1434 /*
1178 * empty line at end does no harm 1435 * empty line at end does no harm
1179 */ 1436 */
1437
1180 fprintf (outfile, "%s", eolstring); 1438 fprintf (outfile, "%s", eolstring);
1181 fclose (outfile); 1439 fclose (outfile);
1182 } 1440 }
1441
1183 if (infile==NULL) fclose (theifile); 1442 if (infile==NULL) fclose (theifile);
1184 progress.action = 0; 1443 progress.action = 0;
1185 FP_free (oname); 1444 _FP_free (oname);
1186 return UURET_OK; 1445 return UURET_OK;
1187} 1446}
1188 1447
1189/* 1448/*
1190 * 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
1220 char *mimetype, *ptr; 1479 char *mimetype, *ptr;
1221 int res, len; 1480 int res, len;
1222 1481
1223 if ((outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) || 1482 if ((outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) ||
1224 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1483 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
1225 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 1484 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
1226 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1485 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1227 uustring (S_PARM_CHECK), "UUE_PrepSingle()"); 1486 uustring (S_PARM_CHECK), "UUE_PrepSingle()");
1228 return UURET_ILLVAL; 1487 return UURET_ILLVAL;
1229 } 1488 }
1230 1489
1231 oname = UUFNameFilter ((outfname)?outfname:infname); 1490 oname = UUFNameFilter ((outfname)?outfname:infname);
1232 len = ((subject)?strlen(subject):0) + strlen(oname) + 40; 1491 len = ((subject)?strlen(subject):0) + strlen(oname) + 40;
1233 1492
1234 if ((ptr = FP_strrchr (oname, '.'))) { 1493 if ((ptr = _FP_strrchr (oname, '.'))) {
1235 while (miter->extension && FP_stricmp (ptr+1, miter->extension) != 0) 1494 while (miter->extension && _FP_stricmp (ptr+1, miter->extension) != 0)
1236 miter++; 1495 miter++;
1237 mimetype = miter->mimetype; 1496 mimetype = miter->mimetype;
1238 } 1497 }
1239 else 1498 else
1240 mimetype = NULL; 1499 mimetype = NULL;
1247 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1506 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1248 uustring (S_OUT_OF_MEMORY), len); 1507 uustring (S_OUT_OF_MEMORY), len);
1249 return UURET_NOMEM; 1508 return UURET_NOMEM;
1250 } 1509 }
1251 1510
1511 if (encoding == YENC_ENCODED) {
1252 if (subject) 1512 if (subject)
1513 sprintf (subline, "- %s - %s (001/001)", oname, subject);
1514 else
1515 sprintf (subline, "- %s - (001/001)", oname);
1516 }
1517 else {
1518 if (subject)
1253 sprintf (subline, "%s (001/001) - [ %s ]", subject, oname); 1519 sprintf (subline, "%s (001/001) - [ %s ]", subject, oname);
1254 else 1520 else
1255 sprintf (subline, "[ %s ] (001/001)", oname); 1521 sprintf (subline, "[ %s ] (001/001)", oname);
1522 }
1256 1523
1257 if (from) { 1524 if (from) {
1258 fprintf (outfile, "From: %s%s", from, eolstring); 1525 fprintf (outfile, "From: %s%s", from, eolstring);
1259 } 1526 }
1260 if (destination) { 1527 if (destination) {
1267 1534
1268 if (replyto) { 1535 if (replyto) {
1269 fprintf (outfile, "Reply-To: %s%s", replyto, eolstring); 1536 fprintf (outfile, "Reply-To: %s%s", replyto, eolstring);
1270 } 1537 }
1271 1538
1539 if (encoding != YENC_ENCODED) {
1272 fprintf (outfile, "MIME-Version: 1.0%s", eolstring); 1540 fprintf (outfile, "MIME-Version: 1.0%s", eolstring);
1273 fprintf (outfile, "Content-Type: %s; name=\"%s\"%s", 1541 fprintf (outfile, "Content-Type: %s; name=\"%s\"%s",
1274 (mimetype)?mimetype:"Application/Octet-Stream", 1542 (mimetype)?mimetype:"Application/Octet-Stream",
1275 UUFNameFilter ((outfname)?outfname:infname), 1543 UUFNameFilter ((outfname)?outfname:infname),
1276 eolstring); 1544 eolstring);
1277 fprintf (outfile, "Content-Transfer-Encoding: %s%s", 1545 fprintf (outfile, "Content-Transfer-Encoding: %s%s",
1278 CTE_TYPE(encoding), eolstring); 1546 CTE_TYPE(encoding), eolstring);
1547 }
1548
1279 fprintf (outfile, "%s", eolstring); 1549 fprintf (outfile, "%s", eolstring);
1280 1550
1281 res = UUEncodeToStream (outfile, infile, infname, encoding, 1551 res = UUEncodeToStream (outfile, infile, infname, encoding,
1282 outfname, filemode); 1552 outfname, filemode);
1283 1553
1284 FP_free (subline); 1554 _FP_free (subline);
1285 return res; 1555 return res;
1286} 1556}
1287 1557
1288int UUEXPORT 1558int UUEXPORT
1289UUE_PrepPartial (FILE *outfile, FILE *infile, 1559UUE_PrepPartial (FILE *outfile, FILE *infile,
1319 long thesize; 1589 long thesize;
1320 int res, len; 1590 int res, len;
1321 1591
1322 if ((outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) || 1592 if ((outfname==NULL&&infname==NULL) || (infile==NULL&&infname==NULL) ||
1323 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&& 1593 (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
1324 encoding!=PT_ENCODED&&encoding!=QP_ENCODED)) { 1594 encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) {
1325 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1595 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1326 uustring (S_PARM_CHECK), "UUE_PrepPartial()"); 1596 uustring (S_PARM_CHECK), "UUE_PrepPartial()");
1327 return UURET_ILLVAL; 1597 return UURET_ILLVAL;
1328 } 1598 }
1329 1599
1331 len = ((subject)?strlen(subject):0) + strlen (oname) + 40; 1601 len = ((subject)?strlen(subject):0) + strlen (oname) + 40;
1332 1602
1333 /* 1603 /*
1334 * if first part, get information about the file 1604 * if first part, get information about the file
1335 */ 1605 */
1606
1336 if (partno == 1) { 1607 if (partno == 1) {
1337 if (infile==NULL) { 1608 if (infile==NULL) {
1338 if (stat (infname, &finfo) == -1) { 1609 if (stat (infname, &finfo) == -1) {
1339 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR, 1610 UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
1340 uustring (S_NOT_STAT_FILE), 1611 uustring (S_NOT_STAT_FILE),
1386 filemode = (int) finfo.st_mode & 0777; 1657 filemode = (int) finfo.st_mode & 0777;
1387 thesize = (long) finfo.st_size; 1658 thesize = (long) finfo.st_size;
1388 } 1659 }
1389 theifile = infile; 1660 theifile = infile;
1390 } 1661 }
1662
1391 /* 1663 /*
1392 * if there's one part only, don't use Message/Partial 1664 * if there's one part only, don't use Message/Partial
1393 */ 1665 */
1394 1666
1395 if (numparts == 1) { 1667 if (numparts == 1) {
1400 } 1672 }
1401 1673
1402 /* 1674 /*
1403 * we also need a unique ID 1675 * we also need a unique ID
1404 */ 1676 */
1677
1405 sprintf (mimeid, "UUDV-%ld.%ld.%s", 1678 sprintf (mimeid, "UUDV-%ld.%ld.%s",
1406 (long) time(NULL), thesize, 1679 (long) time(NULL), thesize,
1407 (strlen(oname)>16)?"oops":oname); 1680 (strlen(oname)>16)?"oops":oname);
1408 } 1681 }
1409 1682
1412 uustring (S_OUT_OF_MEMORY), len); 1685 uustring (S_OUT_OF_MEMORY), len);
1413 if (infile==NULL) fclose (theifile); 1686 if (infile==NULL) fclose (theifile);
1414 return UURET_NOMEM; 1687 return UURET_NOMEM;
1415 } 1688 }
1416 1689
1690
1691 if (encoding == YENC_ENCODED) {
1417 if (subject) 1692 if (subject)
1693 sprintf (subline, "- %s - %s (%03d/%03d)", oname, subject,
1694 partno, numparts);
1695 else
1696 sprintf (subline, "- %s - (%03d/%03d)", oname,
1697 partno, numparts);
1698 }
1699 else {
1700 if (subject)
1418 sprintf (subline, "%s (%03d/%03d) - [ %s ]", 1701 sprintf (subline, "%s (%03d/%03d) - [ %s ]",
1419 subject, partno, numparts, oname); 1702 subject, partno, numparts, oname);
1420 else 1703 else
1421 sprintf (subline, "[ %s ] (%03d/%03d)", 1704 sprintf (subline, "[ %s ] (%03d/%03d)",
1422 oname, partno, numparts); 1705 oname, partno, numparts);
1706 }
1423 1707
1424 if (from) { 1708 if (from) {
1425 fprintf (outfile, "From: %s%s", from, eolstring); 1709 fprintf (outfile, "From: %s%s", from, eolstring);
1426 } 1710 }
1427 1711
1435 1719
1436 if (replyto) { 1720 if (replyto) {
1437 fprintf (outfile, "Reply-To: %s%s", replyto, eolstring); 1721 fprintf (outfile, "Reply-To: %s%s", replyto, eolstring);
1438 } 1722 }
1439 1723
1724 if (encoding != YENC_ENCODED) {
1440 fprintf (outfile, "MIME-Version: 1.0%s", eolstring); 1725 fprintf (outfile, "MIME-Version: 1.0%s", eolstring);
1441 fprintf (outfile, "Content-Type: Message/Partial; number=%d; total=%d;%s", 1726 fprintf (outfile, "Content-Type: Message/Partial; number=%d; total=%d;%s",
1442 partno, numparts, eolstring); 1727 partno, numparts, eolstring);
1443 fprintf (outfile, "\tid=\"%s\"%s", 1728 fprintf (outfile, "\tid=\"%s\"%s",
1444 mimeid, eolstring); 1729 mimeid, eolstring);
1730 }
1731
1445 fprintf (outfile, "%s", eolstring); 1732 fprintf (outfile, "%s", eolstring);
1446 1733
1447 res = UUEncodePartial (outfile, theifile, 1734 res = UUEncodePartial (outfile, theifile,
1448 infname, encoding, 1735 infname, encoding,
1449 (outfname)?outfname:infname, NULL, 1736 (outfname)?outfname:infname, NULL,
1450 themode, partno, linperfile); 1737 themode, partno, linperfile);
1451 1738
1452 FP_free (subline); 1739 _FP_free (subline);
1453 1740
1454 if (infile==NULL) { 1741 if (infile==NULL) {
1455 if (res != UURET_OK) { 1742 if (res != UURET_OK) {
1456 fclose (theifile); 1743 fclose (theifile);
1457 return res; 1744 return res;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines