… | |
… | |
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.16 2008/10/10 16:54:45 root Exp $"; |
58 | char * uunconc_id = "$Id: uunconc.c,v 1.17 2009/08/24 06:15: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 |
… | |
… | |
201 | return 2; |
201 | return 2; |
202 | } |
202 | } |
203 | |
203 | |
204 | ptr = string + len; |
204 | ptr = string + len; |
205 | |
205 | |
206 | while (len && (*(ptr-1)=='\015' || *(ptr-1)=='\012')) { |
|
|
207 | ptr--; len--; |
|
|
208 | } |
|
|
209 | if (len<3) return 0; |
206 | if (len<3) return 0; |
210 | if (*--ptr == ' ') ptr--; |
207 | if (*--ptr == ' ') ptr--; |
211 | ptr--; |
208 | ptr--; |
212 | |
209 | |
213 | if (_FP_strnicmp (ptr, "<a", 2) == 0) |
210 | if (_FP_strnicmp (ptr, "<a", 2) == 0) |
… | |
… | |
301 | |
298 | |
302 | if ((s == NULL) || (*s == '\0')) { |
299 | if ((s == NULL) || (*s == '\0')) { |
303 | return 0; /* bad string */ |
300 | return 0; /* bad string */ |
304 | } |
301 | } |
305 | |
302 | |
306 | while (*s && *s!='\012' && *s!='\015') { |
303 | while (*s) { |
307 | s++; |
304 | s++; |
308 | len++; |
305 | len++; |
309 | i++; |
306 | i++; |
310 | } |
307 | } |
311 | |
308 | |
… | |
… | |
543 | while (vflag == 0 && nflag && safety--) { |
540 | while (vflag == 0 && nflag && safety--) { |
544 | if (nflag == 1) { /* need next line to repair */ |
541 | if (nflag == 1) { /* need next line to repair */ |
545 | if (strlen (line) > 250) |
542 | if (strlen (line) > 250) |
546 | break; |
543 | break; |
547 | ptr = line + strlen (line); |
544 | ptr = line + strlen (line); |
548 | while (ptr>line && (*(ptr-1)=='\015' || *(ptr-1)=='\012')) |
|
|
549 | ptr--; |
|
|
550 | if (_FP_fgets (ptr, 299-(ptr-line), datei) == NULL) |
545 | if (_FP_fgets (ptr, 299-(ptr-line), datei) == NULL) |
551 | break; |
546 | break; |
552 | } |
547 | } |
553 | else { /* don't need next line to repair */ |
548 | else { /* don't need next line to repair */ |
554 | } |
549 | } |
… | |
… | |
577 | * it! |
572 | * it! |
578 | */ |
573 | */ |
579 | |
574 | |
580 | if (vflag == 0) { |
575 | if (vflag == 0) { |
581 | ptr = line + strlen(line); |
576 | ptr = line + strlen(line); |
582 | while (ptr>line && (*(ptr-1)=='\012' || *(ptr-1)=='\015')) { |
|
|
583 | ptr--; |
|
|
584 | } |
|
|
585 | *ptr++ = ' '; |
577 | *ptr++ = ' '; |
586 | *ptr-- = '\0'; |
578 | *ptr-- = '\0'; |
587 | if ((vflag = UUValidData (line, encoding, bhflag)) != UU_ENCODED) { |
579 | if ((vflag = UUValidData (line, encoding, bhflag)) != UU_ENCODED) { |
588 | *ptr = '\0'; |
580 | *ptr = '\0'; |
589 | vflag = 0; |
581 | vflag = 0; |
… | |
… | |
793 | |
785 | |
794 | fputc (val, dataout); |
786 | fputc (val, dataout); |
795 | p2 += 2; |
787 | p2 += 2; |
796 | p1 = p2; |
788 | p1 = p2; |
797 | } |
789 | } |
798 | else if (*p2 == '\012' || *(p2+1) == '\015') { |
790 | else if (!*p2) { |
799 | /* soft line break */ |
791 | /* soft line break */ |
800 | *p2 = '\0'; |
792 | *p2 = '\0'; |
801 | break; |
793 | break; |
802 | } |
794 | } |
803 | else { |
795 | else { |
804 | /* huh? */ |
796 | /* huh? */ |
805 | fputc ('=', dataout); |
797 | fputc ('=', dataout); |
806 | } |
798 | } |
807 | } |
799 | } |
808 | /* |
|
|
809 | * p2 points to a nullbyte right after the CR/LF/CRLF |
|
|
810 | */ |
|
|
811 | val = 0; |
|
|
812 | while (p2>p1 && isspace (*(p2-1))) { |
|
|
813 | if (*(p2-1) == '\012' || *(p2-1) == '\015') |
|
|
814 | val = 1; |
|
|
815 | p2--; |
|
|
816 | } |
|
|
817 | *p2 = '\0'; |
|
|
818 | |
800 | |
819 | /* |
801 | /* |
820 | * If the part ends directly after this line, the data does not end |
802 | * If the part ends directly after this line, the data does not end |
821 | * with a linebreak. Or, as the docs put it, "the CRLF preceding the |
803 | * with a linebreak. Or, as the docs put it, "the CRLF preceding the |
822 | * encapsulation line is conceptually attached to the boundary. |
804 | * encapsulation line is conceptually attached to the boundary. |
823 | * So if the part ends here, don't print a line break" |
805 | * So if the part ends here, don't print a line break" |
824 | */ |
806 | */ |
|
|
807 | /* something is broken here now, but it was broken before */ |
825 | if (val && (!feof (datain) && |
808 | if (!feof (datain) && |
826 | (ftell(datain)<maxpos || flags&FL_TOEND || |
809 | (ftell(datain)<maxpos || flags&FL_TOEND || |
827 | (!(flags&FL_PROPER) && uu_fast_scanning)))) |
810 | (!(flags&FL_PROPER) && uu_fast_scanning))) |
828 | fprintf (dataout, "%s\n", p1); |
811 | fprintf (dataout, "%s\n", p1); |
829 | else |
812 | else |
830 | fprintf (dataout, "%s", p1); |
813 | fprintf (dataout, "%s", p1); |
831 | } |
814 | } |
832 | return UURET_OK; |
815 | return UURET_OK; |
… | |
… | |
873 | return UURET_CANCEL; |
856 | return UURET_CANCEL; |
874 | } |
857 | } |
875 | |
858 | |
876 | ptr = line + strlen (line); |
859 | ptr = line + strlen (line); |
877 | |
860 | |
878 | while (ptr>line && (*(ptr-1) == '\012' || *(ptr-1) == '\015')) |
|
|
879 | ptr--; |
|
|
880 | |
|
|
881 | |
|
|
882 | /* |
861 | /* |
883 | * If the part ends directly after this line, the data does not end |
862 | * If the part ends directly after this line, the data does not end |
884 | * with a linebreak. Or, as the docs put it, "the CRLF preceding the |
863 | * with a linebreak. Or, as the docs put it, "the CRLF preceding the |
885 | * encapsulation line is conceptually attached to the boundary. |
864 | * encapsulation line is conceptually attached to the boundary. |
886 | * So if the part ends here, don't print a line break" |
865 | * So if the part ends here, don't print a line break" |
887 | */ |
866 | */ |
888 | if ((*ptr == '\012' || *ptr == '\015') && |
|
|
889 | (ftell(datain)<maxpos || flags&FL_TOEND || flags&FL_PARTIAL || |
867 | if ((ftell(datain)<maxpos || flags&FL_TOEND || flags&FL_PARTIAL || |
890 | !boundary || (!(flags&FL_PROPER) && uu_fast_scanning))) { |
868 | !boundary || (!(flags&FL_PROPER) && uu_fast_scanning))) { |
891 | *ptr = '\0'; |
869 | *ptr = '\0'; |
892 | fprintf (dataout, "%s\n", line); |
870 | fprintf (dataout, "%s\n", line); |
893 | } |
871 | } |
894 | else { |
872 | else { |
… | |
… | |
943 | d[count] = (isdigit (*(s+1)) ? (*(s+1)-'0') : (tolower (*(s+1))-'a'+10)) << 4; |
921 | d[count] = (isdigit (*(s+1)) ? (*(s+1)-'0') : (tolower (*(s+1))-'a'+10)) << 4; |
944 | d[count] |= (isdigit (*(s+2)) ? (*(s+2)-'0') : (tolower (*(s+2))-'a'+10)); |
922 | d[count] |= (isdigit (*(s+2)) ? (*(s+2)-'0') : (tolower (*(s+2))-'a'+10)); |
945 | count++; |
923 | count++; |
946 | s+=3; |
924 | s+=3; |
947 | } |
925 | } |
948 | else if (*(s+1) == '\012' || *(s+1) == '\015') { |
926 | else if (!s[1]) { |
949 | s+=2; |
927 | d[count++] = '\012'; |
950 | } |
928 | } |
951 | else { |
929 | else { |
952 | d[count++] = *s++; |
930 | d[count++] = *s++; |
953 | } |
931 | } |
954 | } |
932 | } |
… | |
… | |
1019 | uustring (S_SOURCE_READ_ERR), |
997 | uustring (S_SOURCE_READ_ERR), |
1020 | strerror (uu_errno = errno)); |
998 | strerror (uu_errno = errno)); |
1021 | return UURET_IOERR; |
999 | return UURET_IOERR; |
1022 | } |
1000 | } |
1023 | |
1001 | |
1024 | if (line[0]=='\015' || line[0]=='\012') { /* Empty line? */ |
1002 | if (!*line) { /* Empty line? */ |
1025 | if (*state == DATA && |
1003 | if (*state == DATA && |
1026 | (method == UU_ENCODED || method == XX_ENCODED)) |
1004 | (method == UU_ENCODED || method == XX_ENCODED)) |
1027 | *state = END; |
1005 | *state = END; |
1028 | |
1006 | |
1029 | /* |
1007 | /* |