… | |
… | |
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.26 2020/12/10 22:49:15 root Exp $"; |
58 | char * uunconc_id = "$Id: uunconc.c,v 1.27 2020/12/11 20:09:23 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 |
… | |
… | |
194 | int len; |
194 | int len; |
195 | |
195 | |
196 | if (string==NULL || (len=strlen(string))<3) |
196 | if (string==NULL || (len=strlen(string))<3) |
197 | return 0; |
197 | return 0; |
198 | |
198 | |
199 | if ((ptr = _FP_stristr (string, "<a href=")) != NULL) { |
199 | if ((ptr = FP_stristr (string, "<a href=")) != NULL) { |
200 | if (_FP_stristr (string, "</a>") > ptr) |
200 | if (FP_stristr (string, "</a>") > ptr) |
201 | return 2; |
201 | return 2; |
202 | } |
202 | } |
203 | |
203 | |
204 | ptr = string + len; |
204 | ptr = string + len; |
205 | |
205 | |
206 | if (len<3) return 0; |
206 | if (len<3) return 0; |
207 | if (*--ptr == ' ') ptr--; |
207 | if (*--ptr == ' ') ptr--; |
208 | ptr--; |
208 | ptr--; |
209 | |
209 | |
210 | if (_FP_strnicmp (ptr, "<a", 2) == 0) |
210 | if (FP_strnicmp (ptr, "<a", 2) == 0) |
211 | return 1; |
211 | return 1; |
212 | |
212 | |
213 | return 0; |
213 | return 0; |
214 | } |
214 | } |
215 | |
215 | |
… | |
… | |
239 | /* |
239 | /* |
240 | * First pass |
240 | * First pass |
241 | */ |
241 | */ |
242 | while (*p1) { |
242 | while (*p1) { |
243 | if (*p1 == '&') { |
243 | if (*p1 == '&') { |
244 | if (_FP_strnicmp (p1, "&", 5) == 0) { p1+=5; *p2++='&'; res=1; } |
244 | if (FP_strnicmp (p1, "&", 5) == 0) { p1+=5; *p2++='&'; res=1; } |
245 | else if (_FP_strnicmp (p1, "<", 4) == 0) { p1+=4; *p2++='<'; res=1; } |
245 | else if (FP_strnicmp (p1, "<", 4) == 0) { p1+=4; *p2++='<'; res=1; } |
246 | else if (_FP_strnicmp (p1, ">", 4) == 0) { p1+=4; *p2++='>'; res=1; } |
246 | else if (FP_strnicmp (p1, ">", 4) == 0) { p1+=4; *p2++='>'; res=1; } |
247 | else *p2++ = *p1++; |
247 | else *p2++ = *p1++; |
248 | res = 1; |
248 | res = 1; |
249 | } |
249 | } |
250 | else *p2++ = *p1++; |
250 | else *p2++ = *p1++; |
251 | } |
251 | } |
… | |
… | |
255 | */ |
255 | */ |
256 | p1 = p2 = string; |
256 | p1 = p2 = string; |
257 | |
257 | |
258 | while (*p1) { |
258 | while (*p1) { |
259 | if (*p1 == '<') { |
259 | if (*p1 == '<') { |
260 | if ((_FP_strnicmp (p1, "<ahref=", 7) == 0 || |
260 | if ((FP_strnicmp (p1, "<ahref=", 7) == 0 || |
261 | _FP_strnicmp (p1, "<a href=",8) == 0) && |
261 | FP_strnicmp (p1, "<a href=",8) == 0) && |
262 | (_FP_strstr (p1, "</a>") != 0 || _FP_strstr (p1, "</A>") != 0)) { |
262 | (FP_strstr (p1, "</a>") != 0 || FP_strstr (p1, "</A>") != 0)) { |
263 | while (*p1 && *p1!='>') p1++; |
263 | while (*p1 && *p1!='>') p1++; |
264 | if (*p1=='\0' || *(p1+1)!='<') return 0; |
264 | if (*p1=='\0' || *(p1+1)!='<') return 0; |
265 | p1++; |
265 | p1++; |
266 | while (*p1 && (*p1!='<' || _FP_strnicmp(p1,"</a>",4)!=0)) { |
266 | while (*p1 && (*p1!='<' || FP_strnicmp(p1,"</a>",4)!=0)) { |
267 | *p2++ = *p1++; |
267 | *p2++ = *p1++; |
268 | } |
268 | } |
269 | if (_FP_strnicmp(p1,"</a>",4) != 0) |
269 | if (FP_strnicmp(p1,"</a>",4) != 0) |
270 | return 0; |
270 | return 0; |
271 | p1+=4; |
271 | p1+=4; |
272 | res=1; |
272 | res=1; |
273 | } |
273 | } |
274 | else |
274 | else |
… | |
… | |
534 | while (vflag == 0 && nflag && safety--) { |
534 | while (vflag == 0 && nflag && safety--) { |
535 | if (nflag == 1) { /* need next line to repair */ |
535 | if (nflag == 1) { /* need next line to repair */ |
536 | if (strlen (line) > 250) |
536 | if (strlen (line) > 250) |
537 | break; |
537 | break; |
538 | ptr = line + strlen (line); |
538 | ptr = line + strlen (line); |
539 | if (_FP_fgets (ptr, 299-(ptr-line), datei) == NULL) |
539 | if (FP_fgets (ptr, 299-(ptr-line), datei) == NULL) |
540 | break; |
540 | break; |
541 | } |
541 | } |
542 | else { /* don't need next line to repair */ |
542 | else { /* don't need next line to repair */ |
543 | } |
543 | } |
544 | if (UUNetscapeCollapse (line)) { |
544 | if (UUNetscapeCollapse (line)) { |
… | |
… | |
732 | char *line=uugen_inbuffer, *p1, *p2; |
732 | char *line=uugen_inbuffer, *p1, *p2; |
733 | int val; |
733 | int val; |
734 | |
734 | |
735 | uulboundary = -1; |
735 | uulboundary = -1; |
736 | |
736 | |
737 | while (!feof (datain) && |
737 | while (!FP_feof (datain) && |
738 | (ftell(datain)<maxpos || flags&FL_TOEND || |
738 | (ftell(datain)<maxpos || flags&FL_TOEND || |
739 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
739 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
740 | if (_FP_fgets (line, 1023, datain) == NULL) |
740 | if (FP_fgets (line, 1023, datain) == NULL) |
741 | break; |
741 | break; |
742 | if (ferror (datain)) { |
742 | if (ferror (datain)) { |
743 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
743 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
744 | uustring (S_SOURCE_READ_ERR), |
744 | uustring (S_SOURCE_READ_ERR), |
745 | strerror (uu_errno = errno)); |
745 | strerror (uu_errno = errno)); |
… | |
… | |
807 | * with a linebreak. Or, as the docs put it, "the CRLF preceding the |
807 | * with a linebreak. Or, as the docs put it, "the CRLF preceding the |
808 | * encapsulation line is conceptually attached to the boundary. |
808 | * encapsulation line is conceptually attached to the boundary. |
809 | * So if the part ends here, don't print a line break" |
809 | * So if the part ends here, don't print a line break" |
810 | */ |
810 | */ |
811 | /* something is broken here now, but it was broken before */ |
811 | /* something is broken here now, but it was broken before */ |
812 | if (!feof (datain) && |
812 | if (!FP_feof (datain) && |
813 | (ftell(datain)<maxpos || flags&FL_TOEND || |
813 | (ftell(datain)<maxpos || flags&FL_TOEND || |
814 | (!(flags&FL_PROPER) && uu_fast_scanning))) |
814 | (!(flags&FL_PROPER) && uu_fast_scanning))) |
815 | fprintf (dataout, "%s\n", p1); |
815 | fprintf (dataout, "%s\n", p1); |
816 | else |
816 | else |
817 | fprintf (dataout, "%s", p1); |
817 | fprintf (dataout, "%s", p1); |
… | |
… | |
832 | { |
832 | { |
833 | char *line=uugen_inbuffer, *ptr; |
833 | char *line=uugen_inbuffer, *ptr; |
834 | |
834 | |
835 | uulboundary = -1; |
835 | uulboundary = -1; |
836 | |
836 | |
837 | while (!feof (datain) && |
837 | while (!FP_feof (datain) && |
838 | (ftell(datain)<maxpos || flags&FL_TOEND || |
838 | (ftell(datain)<maxpos || flags&FL_TOEND || |
839 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
839 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
840 | if (_FP_fgets (line, 1023, datain) == NULL) |
840 | if (FP_fgets (line, 1023, datain) == NULL) |
841 | break; |
841 | break; |
842 | if (ferror (datain)) { |
842 | if (ferror (datain)) { |
843 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
843 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
844 | uustring (S_SOURCE_READ_ERR), |
844 | uustring (S_SOURCE_READ_ERR), |
845 | strerror (uu_errno = errno)); |
845 | strerror (uu_errno = errno)); |
… | |
… | |
986 | |
986 | |
987 | if (method == YENC_ENCODED) { |
987 | if (method == YENC_ENCODED) { |
988 | *state = BEGIN; |
988 | *state = BEGIN; |
989 | } |
989 | } |
990 | |
990 | |
991 | while (!feof (datain) && *state != DONE && |
991 | while (!FP_feof (datain) && *state != DONE && |
992 | (ftell(datain)<maxpos || flags&FL_TOEND || maxpos==-1 || |
992 | (ftell(datain)<maxpos || flags&FL_TOEND || maxpos==-1 || |
993 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
993 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
994 | if (_FP_fgets ((line = uugen_fnbuffer), 1200 - 5, datain) == NULL) |
994 | if (FP_fgets ((line = uugen_fnbuffer), 1200 - 5, datain) == NULL) |
995 | break; |
995 | break; |
996 | |
996 | |
997 | /* optionally skip .. */ |
997 | /* optionally skip .. */ |
998 | if (*line == '.' && uu_dotdot) |
998 | if (*line == '.' && uu_dotdot) |
999 | line++; |
999 | line++; |
… | |
… | |
1053 | * Use this pseudo-handling only if !FL_PROPER |
1053 | * Use this pseudo-handling only if !FL_PROPER |
1054 | */ |
1054 | */ |
1055 | |
1055 | |
1056 | if ((flags&FL_PROPER) == 0) { |
1056 | if ((flags&FL_PROPER) == 0) { |
1057 | if (strncmp (line, "BEGIN", 5) == 0 && |
1057 | if (strncmp (line, "BEGIN", 5) == 0 && |
1058 | _FP_strstr (line, "CUT HERE") && !tf) { /* I hate these lines */ |
1058 | FP_strstr (line, "CUT HERE") && !tf) { /* I hate these lines */ |
1059 | tc = tf = vlc = 0; |
1059 | tc = tf = vlc = 0; |
1060 | continue; |
1060 | continue; |
1061 | } |
1061 | } |
1062 | /* MIME body boundary */ |
1062 | /* MIME body boundary */ |
1063 | if (line[0] == '-' && line[1] == '-' && method == B64ENCODED) { |
1063 | if (line[0] == '-' && line[1] == '-' && method == B64ENCODED) { |
… | |
… | |
1069 | } |
1069 | } |
1070 | hadct = 0; |
1070 | hadct = 0; |
1071 | haddh = 1; |
1071 | haddh = 1; |
1072 | continue; |
1072 | continue; |
1073 | } |
1073 | } |
1074 | if (_FP_strnicmp (line, "Content-Type", 12) == 0) |
1074 | if (FP_strnicmp (line, "Content-Type", 12) == 0) |
1075 | hadct = 1; |
1075 | hadct = 1; |
1076 | } |
1076 | } |
1077 | |
1077 | |
1078 | if (*state == BEGIN) { |
1078 | if (*state == BEGIN) { |
1079 | if ((method == UU_ENCODED || method == XX_ENCODED) && |
1079 | if ((method == UU_ENCODED || method == XX_ENCODED) && |
1080 | (strncmp (line, "begin ", 6) == 0 || |
1080 | (strncmp (line, "begin ", 6) == 0 || |
1081 | _FP_strnicmp (line, "<pre>begin ", 11) == 0)) { /* for LYNX */ |
1081 | FP_strnicmp (line, "<pre>begin ", 11) == 0)) { /* for LYNX */ |
1082 | *state = DATA; |
1082 | *state = DATA; |
1083 | continue; |
1083 | continue; |
1084 | } |
1084 | } |
1085 | else if (method == BH_ENCODED && line[0] == ':') { |
1085 | else if (method == BH_ENCODED && line[0] == ':') { |
1086 | if (UUValidData (line, BH_ENCODED, &bhflag) == BH_ENCODED) { |
1086 | if (UUValidData (line, BH_ENCODED, &bhflag) == BH_ENCODED) { |
… | |
… | |
1090 | else |
1090 | else |
1091 | continue; |
1091 | continue; |
1092 | } |
1092 | } |
1093 | else if (method == YENC_ENCODED && |
1093 | else if (method == YENC_ENCODED && |
1094 | strncmp (line, "=ybegin ", 8) == 0 && |
1094 | strncmp (line, "=ybegin ", 8) == 0 && |
1095 | _FP_strstr (line, " name=") != NULL) { |
1095 | FP_strstr (line, " name=") != NULL) { |
1096 | *state = DATA; |
1096 | *state = DATA; |
1097 | |
1097 | |
1098 | if ((ptr = _FP_strstr (line, " size=")) != NULL) { |
1098 | if ((ptr = FP_strstr (line, " size=")) != NULL) { |
1099 | ptr += 6; |
1099 | ptr += 6; |
1100 | yefilesize = atoi (ptr); |
1100 | yefilesize = atoi (ptr); |
1101 | } |
1101 | } |
1102 | else { |
1102 | else { |
1103 | yefilesize = -1; |
1103 | yefilesize = -1; |
1104 | } |
1104 | } |
1105 | |
1105 | |
1106 | if ((ptr =_FP_strstr (line, " part="))) { |
1106 | if ((ptr =FP_strstr (line, " part="))) { |
1107 | int partno = atoi (ptr + 6); |
1107 | int partno = atoi (ptr + 6); |
1108 | |
1108 | |
1109 | if ((ptr = _FP_strstr (line, " total="))) |
1109 | if ((ptr = FP_strstr (line, " total="))) |
1110 | yenotlastpart = atoi (ptr + 7) != partno; |
1110 | yenotlastpart = atoi (ptr + 7) != partno; |
1111 | |
1111 | |
1112 | if (_FP_fgets (line, 1200 - 5, datain) == NULL) { |
1112 | if (FP_fgets (line, 1200 - 5, datain) == NULL) { |
1113 | break; |
1113 | break; |
1114 | } |
1114 | } |
1115 | |
1115 | |
1116 | if ((ptr = _FP_strstr (line, " end=")) == NULL) { |
1116 | if ((ptr = FP_strstr (line, " end=")) == NULL) { |
1117 | break; |
1117 | break; |
1118 | } |
1118 | } |
1119 | |
1119 | |
1120 | yepartends = atoi (ptr + 5); |
1120 | yepartends = atoi (ptr + 5); |
1121 | } |
1121 | } |
… | |
… | |
1139 | |
1139 | |
1140 | if (*state == DATA && method == YENC_ENCODED && |
1140 | if (*state == DATA && method == YENC_ENCODED && |
1141 | strncmp (line, "=yend ", 6) == 0) { |
1141 | strncmp (line, "=yend ", 6) == 0) { |
1142 | int lastpart = !yenotlastpart && (yepartends == 0 || yepartends >= yefilesize); |
1142 | int lastpart = !yenotlastpart && (yepartends == 0 || yepartends >= yefilesize); |
1143 | yefilecrc = uu_crc32_combine(yefilecrc, yepartcrc, yepartsize); |
1143 | yefilecrc = uu_crc32_combine(yefilecrc, yepartcrc, yepartsize); |
1144 | if ((ptr = _FP_strstr (line, " pcrc32=")) != NULL) { |
1144 | if ((ptr = FP_strstr (line, " pcrc32=")) != NULL) { |
1145 | crc32_t pcrc32 = strtoul (ptr + 8, NULL, 16); |
1145 | crc32_t pcrc32 = strtoul (ptr + 8, NULL, 16); |
1146 | if (pcrc32 != yepartcrc) { |
1146 | if (pcrc32 != yepartcrc) { |
1147 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1147 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1148 | uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno); |
1148 | uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno); |
1149 | } |
1149 | } |
1150 | } else if ((ptr = _FP_strstr (line, " pcrc=")) != NULL) { |
1150 | } else if ((ptr = FP_strstr (line, " pcrc=")) != NULL) { |
1151 | crc32_t pcrc32 = strtoul (ptr + 6, NULL, 16); |
1151 | crc32_t pcrc32 = strtoul (ptr + 6, NULL, 16); |
1152 | if (pcrc32 != yepartcrc) { |
1152 | if (pcrc32 != yepartcrc) { |
1153 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1153 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1154 | uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno); |
1154 | uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno); |
1155 | } |
1155 | } |
1156 | } |
1156 | } |
1157 | if (lastpart && (ptr = _FP_strstr (line, " crc32=")) != NULL) |
1157 | if (lastpart && (ptr = FP_strstr (line, " crc32=")) != NULL) |
1158 | { |
1158 | { |
1159 | crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16); |
1159 | crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16); |
1160 | if (fcrc32 != yefilecrc) { |
1160 | if (fcrc32 != yefilecrc) { |
1161 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1161 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1162 | uustring (S_CRC_MISMATCH), progress.curfile); |
1162 | uustring (S_CRC_MISMATCH), progress.curfile); |
1163 | } |
1163 | } |
1164 | } |
1164 | } |
1165 | if ((ptr = _FP_strstr (line, " size=")) != NULL) |
1165 | if ((ptr = FP_strstr (line, " size=")) != NULL) |
1166 | { |
1166 | { |
1167 | size_t size = atol(ptr + 6); |
1167 | size_t size = atol(ptr + 6); |
1168 | if (size != yepartsize && yefilesize != -1) { |
1168 | if (size != yepartsize && yefilesize != -1) { |
1169 | if (size != yefilesize) |
1169 | if (size != yefilesize) |
1170 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
1170 | UUMessage (uunconc_id, __LINE__, UUMSG_WARNING, |
… | |
… | |
1230 | } |
1230 | } |
1231 | lc[0] = 0; |
1231 | lc[0] = 0; |
1232 | lc[1] = 3; |
1232 | lc[1] = 3; |
1233 | } |
1233 | } |
1234 | else { |
1234 | else { |
1235 | _FP_strncpy (save[tc++], line, 1200); |
1235 | FP_strncpy (save[tc++], line, 1200); |
1236 | } |
1236 | } |
1237 | |
1237 | |
1238 | if (method == UU_ENCODED) |
1238 | if (method == UU_ENCODED) |
1239 | *state = (line[0] == 'M') ? DATA : END; |
1239 | *state = (line[0] == 'M') ? DATA : END; |
1240 | else if (method == XX_ENCODED) |
1240 | else if (method == XX_ENCODED) |
… | |
… | |
1377 | if (tmpfd != -1) { |
1377 | if (tmpfd != -1) { |
1378 | unlink(data->binfile); |
1378 | unlink(data->binfile); |
1379 | close(tmpfd); |
1379 | close(tmpfd); |
1380 | } |
1380 | } |
1381 | #endif /* HAVE_MKSTEMP */ |
1381 | #endif /* HAVE_MKSTEMP */ |
1382 | _FP_free (data->binfile); |
1382 | FP_free (data->binfile); |
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); |
… | |
… | |
1408 | /* |
1408 | /* |
1409 | * initialize progress information |
1409 | * initialize progress information |
1410 | */ |
1410 | */ |
1411 | progress.action = 0; |
1411 | progress.action = 0; |
1412 | if (data->filename != NULL) { |
1412 | if (data->filename != NULL) { |
1413 | _FP_strncpy (progress.curfile, |
1413 | FP_strncpy (progress.curfile, |
1414 | (strlen(data->filename)>255)? |
1414 | (strlen(data->filename)>255)? |
1415 | (data->filename+strlen(data->filename)-255):data->filename, |
1415 | (data->filename+strlen(data->filename)-255):data->filename, |
1416 | 256); |
1416 | 256); |
1417 | } |
1417 | } |
1418 | else { |
1418 | else { |
1419 | _FP_strncpy (progress.curfile, |
1419 | FP_strncpy (progress.curfile, |
1420 | (strlen(data->binfile)>255)? |
1420 | (strlen(data->binfile)>255)? |
1421 | (data->binfile+strlen(data->binfile)-255):data->binfile, |
1421 | (data->binfile+strlen(data->binfile)-255):data->binfile, |
1422 | 256); |
1422 | 256); |
1423 | } |
1423 | } |
1424 | progress.partno = 0; |
1424 | progress.partno = 0; |
… | |
… | |
1473 | uustring (S_NOT_OPEN_FILE), |
1473 | uustring (S_NOT_OPEN_FILE), |
1474 | iter->data->sfname, strerror (uu_errno = errno)); |
1474 | iter->data->sfname, strerror (uu_errno = errno)); |
1475 | res = UURET_IOERR; |
1475 | res = UURET_IOERR; |
1476 | break; |
1476 | break; |
1477 | } |
1477 | } |
1478 | _FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024); |
1478 | FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024); |
1479 | } |
1479 | } |
1480 | UUSETBUF (datain, datain_buf, uu_rbuf); |
1480 | UUSETBUF (datain, datain_buf, uu_rbuf); |
1481 | |
1481 | |
1482 | progress.partno = part; |
1482 | progress.partno = part; |
1483 | progress.fsize = (iter->data->length)?iter->data->length:-1; |
1483 | progress.fsize = (iter->data->length)?iter->data->length:-1; |
… | |
… | |
1513 | } |
1513 | } |
1514 | UUCLRBUF (uu_wbuf, dataout_buf); |
1514 | UUCLRBUF (uu_wbuf, dataout_buf); |
1515 | |
1515 | |
1516 | if (res != UURET_OK || (state != DONE && !uu_desperate)) { |
1516 | if (res != UURET_OK || (state != DONE && !uu_desperate)) { |
1517 | unlink (data->binfile); |
1517 | unlink (data->binfile); |
1518 | _FP_free (data->binfile); |
1518 | FP_free (data->binfile); |
1519 | data->binfile = NULL; |
1519 | data->binfile = NULL; |
1520 | data->state &= ~UUFILE_TMPFILE; |
1520 | data->state &= ~UUFILE_TMPFILE; |
1521 | data->state |= UUFILE_ERROR; |
1521 | data->state |= UUFILE_ERROR; |
1522 | |
1522 | |
1523 | if (res == UURET_OK && state != DONE) |
1523 | if (res == UURET_OK && state != DONE) |
… | |
… | |
1586 | UUSETBUF (dataout, dataout_buf, uu_wbuf); |
1586 | UUSETBUF (dataout, dataout_buf, uu_wbuf); |
1587 | |
1587 | |
1588 | /* |
1588 | /* |
1589 | * read fork lengths. remember they're in Motorola format |
1589 | * read fork lengths. remember they're in Motorola format |
1590 | */ |
1590 | */ |
1591 | r[0] = _FP_fgetc (datain); |
1591 | r[0] = FP_getc (datain); |
1592 | hb = (int) r[0] + 22; |
1592 | hb = (int) r[0] + 22; |
1593 | fseek (datain, (int) r[0] + 12, SEEK_SET); |
1593 | fseek (datain, (int) r[0] + 12, SEEK_SET); |
1594 | fread (r, 1, 8, datain); |
1594 | fread (r, 1, 8, datain); |
1595 | |
1595 | |
1596 | dsize = (((long) 1 << 24) * (long) r[0]) + |
1596 | dsize = (((long) 1 << 24) * (long) r[0]) + |
… | |
… | |
1632 | |
1632 | |
1633 | /* |
1633 | /* |
1634 | * copy the chosen fork |
1634 | * copy the chosen fork |
1635 | */ |
1635 | */ |
1636 | |
1636 | |
1637 | while (!feof (datain) && numbytes) { |
1637 | while (!FP_feof (datain) && numbytes) { |
1638 | if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) { |
1638 | if (UUBUSYPOLL(ftell(datain)-progress.foffset,progress.fsize)) { |
1639 | UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, |
1639 | UUMessage (uunconc_id, __LINE__, UUMSG_NOTE, |
1640 | uustring (S_DECODE_CANCEL)); |
1640 | uustring (S_DECODE_CANCEL)); |
1641 | fclose (datain); |
1641 | fclose (datain); |
1642 | UUCLRBUF (uu_rbuf, datain_buf); |
1642 | UUCLRBUF (uu_rbuf, datain_buf); |
… | |
… | |
1648 | } |
1648 | } |
1649 | |
1649 | |
1650 | bytes = fread (uugen_inbuffer, 1, |
1650 | bytes = fread (uugen_inbuffer, 1, |
1651 | (size_t) ((numbytes>1024)?1024:numbytes), datain); |
1651 | (size_t) ((numbytes>1024)?1024:numbytes), datain); |
1652 | |
1652 | |
1653 | if (ferror (datain) || (bytes == 0 && !feof (datain))) { |
1653 | if (ferror (datain) || (bytes == 0 && !FP_feof (datain))) { |
1654 | progress.action = 0; |
1654 | progress.action = 0; |
1655 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1655 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
1656 | uustring (S_SOURCE_READ_ERR), |
1656 | uustring (S_SOURCE_READ_ERR), |
1657 | data->binfile, strerror (uu_errno = errno)); |
1657 | data->binfile, strerror (uu_errno = errno)); |
1658 | fclose (datain); |
1658 | fclose (datain); |
… | |
… | |
1734 | */ |
1734 | */ |
1735 | |
1735 | |
1736 | memset (&myenv, 0, sizeof (headers)); |
1736 | memset (&myenv, 0, sizeof (headers)); |
1737 | UUScanHeader (datain, &myenv); |
1737 | UUScanHeader (datain, &myenv); |
1738 | |
1738 | |
1739 | if (_FP_stristr (myenv.ctenc, "uu") != NULL) |
1739 | if (FP_stristr (myenv.ctenc, "uu") != NULL) |
1740 | encoding = UU_ENCODED; |
1740 | encoding = UU_ENCODED; |
1741 | else if (_FP_stristr (myenv.ctenc, "xx") != NULL) |
1741 | else if (FP_stristr (myenv.ctenc, "xx") != NULL) |
1742 | encoding = XX_ENCODED; |
1742 | encoding = XX_ENCODED; |
1743 | else if (_FP_stricmp (myenv.ctenc, "base64") == 0) |
1743 | else if (FP_stricmp (myenv.ctenc, "base64") == 0) |
1744 | encoding = B64ENCODED; |
1744 | encoding = B64ENCODED; |
1745 | else if (_FP_stricmp (myenv.ctenc, "quoted-printable") == 0) |
1745 | else if (FP_stricmp (myenv.ctenc, "quoted-printable") == 0) |
1746 | encoding = QP_ENCODED; |
1746 | encoding = QP_ENCODED; |
1747 | else |
1747 | else |
1748 | encoding = PT_ENCODED; |
1748 | encoding = PT_ENCODED; |
1749 | |
1749 | |
1750 | UUkillheaders (&myenv); |
1750 | UUkillheaders (&myenv); |