… | |
… | |
52 | #include <uudeview.h> |
52 | #include <uudeview.h> |
53 | #include <uuint.h> |
53 | #include <uuint.h> |
54 | #include <fptools.h> |
54 | #include <fptools.h> |
55 | #include <uustring.h> |
55 | #include <uustring.h> |
56 | |
56 | |
57 | char * uunconc_id = "$Id: uunconc.c,v 1.4 2002/03/31 20:04:30 root Exp $"; |
57 | char * uunconc_id = "$Id: uunconc.c,v 1.5 2002/03/31 20:08:42 root Exp $"; |
58 | |
58 | |
59 | /* for braindead systems */ |
59 | /* for braindead systems */ |
60 | #ifndef SEEK_SET |
60 | #ifndef SEEK_SET |
61 | #ifdef L_BEGIN |
61 | #ifdef L_BEGIN |
62 | #define SEEK_SET L_BEGIN |
62 | #define SEEK_SET L_BEGIN |
… | |
… | |
193 | int len; |
193 | int len; |
194 | |
194 | |
195 | if (string==NULL || (len=strlen(string))<3) |
195 | if (string==NULL || (len=strlen(string))<3) |
196 | return 0; |
196 | return 0; |
197 | |
197 | |
198 | if ((ptr = FP_stristr (string, "<a href=")) != NULL) { |
198 | if ((ptr = _FP_stristr (string, "<a href=")) != NULL) { |
199 | if (FP_stristr (string, "</a>") > ptr) |
199 | if (_FP_stristr (string, "</a>") > ptr) |
200 | return 2; |
200 | return 2; |
201 | } |
201 | } |
202 | |
202 | |
203 | ptr = string + len; |
203 | ptr = string + len; |
204 | |
204 | |
… | |
… | |
207 | } |
207 | } |
208 | if (len<3) return 0; |
208 | if (len<3) return 0; |
209 | if (*--ptr == ' ') ptr--; |
209 | if (*--ptr == ' ') ptr--; |
210 | ptr--; |
210 | ptr--; |
211 | |
211 | |
212 | if (FP_strnicmp (ptr, "<a", 2) == 0) |
212 | if (_FP_strnicmp (ptr, "<a", 2) == 0) |
213 | return 1; |
213 | return 1; |
214 | |
214 | |
215 | return 0; |
215 | return 0; |
216 | } |
216 | } |
217 | |
217 | |
… | |
… | |
241 | /* |
241 | /* |
242 | * First pass |
242 | * First pass |
243 | */ |
243 | */ |
244 | while (*p1) { |
244 | while (*p1) { |
245 | if (*p1 == '&') { |
245 | if (*p1 == '&') { |
246 | if (FP_strnicmp (p1, "&", 5) == 0) { p1+=5; *p2++='&'; res=1; } |
246 | if (_FP_strnicmp (p1, "&", 5) == 0) { p1+=5; *p2++='&'; res=1; } |
247 | else if (FP_strnicmp (p1, "<", 4) == 0) { p1+=4; *p2++='<'; res=1; } |
247 | else if (_FP_strnicmp (p1, "<", 4) == 0) { p1+=4; *p2++='<'; res=1; } |
248 | else if (FP_strnicmp (p1, ">", 4) == 0) { p1+=4; *p2++='>'; res=1; } |
248 | else if (_FP_strnicmp (p1, ">", 4) == 0) { p1+=4; *p2++='>'; res=1; } |
249 | else *p2++ = *p1++; |
249 | else *p2++ = *p1++; |
250 | res = 1; |
250 | res = 1; |
251 | } |
251 | } |
252 | else *p2++ = *p1++; |
252 | else *p2++ = *p1++; |
253 | } |
253 | } |
… | |
… | |
257 | */ |
257 | */ |
258 | p1 = p2 = string; |
258 | p1 = p2 = string; |
259 | |
259 | |
260 | while (*p1) { |
260 | while (*p1) { |
261 | if (*p1 == '<') { |
261 | if (*p1 == '<') { |
262 | if ((FP_strnicmp (p1, "<ahref=", 7) == 0 || |
262 | if ((_FP_strnicmp (p1, "<ahref=", 7) == 0 || |
263 | FP_strnicmp (p1, "<a href=",8) == 0) && |
263 | _FP_strnicmp (p1, "<a href=",8) == 0) && |
264 | (FP_strstr (p1, "</a>") != 0 || FP_strstr (p1, "</A>") != 0)) { |
264 | (_FP_strstr (p1, "</a>") != 0 || FP_strstr (p1, "</A>") != 0)) { |
265 | while (*p1 && *p1!='>') p1++; |
265 | while (*p1 && *p1!='>') p1++; |
266 | if (*p1=='\0' || *(p1+1)!='<') return 0; |
266 | if (*p1=='\0' || *(p1+1)!='<') return 0; |
267 | p1++; |
267 | p1++; |
268 | while (*p1 && (*p1!='<' || FP_strnicmp(p1,"</a>",4)!=0)) { |
268 | while (*p1 && (*p1!='<' || _FP_strnicmp(p1,"</a>",4)!=0)) { |
269 | *p2++ = *p1++; |
269 | *p2++ = *p1++; |
270 | } |
270 | } |
271 | if (FP_strnicmp(p1,"</a>",4) != 0) |
271 | if (_FP_strnicmp(p1,"</a>",4) != 0) |
272 | return 0; |
272 | return 0; |
273 | p1+=4; |
273 | p1+=4; |
274 | res=1; |
274 | res=1; |
275 | } |
275 | } |
276 | else |
276 | else |
… | |
… | |
469 | */ |
469 | */ |
470 | if (encoding != UU_ENCODED) |
470 | if (encoding != UU_ENCODED) |
471 | if (strchr (ptr, ' ') != NULL) |
471 | if (strchr (ptr, ' ') != NULL) |
472 | goto _t_XX; |
472 | goto _t_XX; |
473 | |
473 | |
474 | /* suspicious = 1; we're careful here REMOVED 0.4.15 _FP__ */ |
474 | /* suspicious = 1; we're careful here REMOVED 0.4.15 __FP__ */ |
475 | len = j; |
475 | len = j; |
476 | } |
476 | } |
477 | |
477 | |
478 | while (len--) { |
478 | while (len--) { |
479 | if (*s < 0 || UUxlat[ACAST(*s++)] < 0) { |
479 | if (*s < 0 || UUxlat[ACAST(*s++)] < 0) { |
… | |
… | |
542 | while (vflag == 0 && nflag && safety--) { |
542 | while (vflag == 0 && nflag && safety--) { |
543 | if (nflag == 1) { /* need next line to repair */ |
543 | if (nflag == 1) { /* need next line to repair */ |
544 | ptr = line + strlen (line); |
544 | ptr = line + strlen (line); |
545 | while (ptr>line && (*(ptr-1)=='\015' || *(ptr-1)=='\012')) |
545 | while (ptr>line && (*(ptr-1)=='\015' || *(ptr-1)=='\012')) |
546 | ptr--; |
546 | ptr--; |
547 | if (FP_fgets (ptr, 255-(ptr-line), datei) == NULL) |
547 | if (_FP_fgets (ptr, 255-(ptr-line), datei) == NULL) |
548 | break; |
548 | break; |
549 | } |
549 | } |
550 | else { /* don't need next line to repair */ |
550 | else { /* don't need next line to repair */ |
551 | } |
551 | } |
552 | if (UUNetscapeCollapse (line)) { |
552 | if (UUNetscapeCollapse (line)) { |
… | |
… | |
744 | uulboundary = -1; |
744 | uulboundary = -1; |
745 | |
745 | |
746 | while (!feof (datain) && |
746 | while (!feof (datain) && |
747 | (ftell(datain)<maxpos || flags&FL_TOEND || |
747 | (ftell(datain)<maxpos || flags&FL_TOEND || |
748 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
748 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
749 | if (FP_fgets (line, 255, datain) == NULL) |
749 | if (_FP_fgets (line, 255, datain) == NULL) |
750 | break; |
750 | break; |
751 | if (ferror (datain)) { |
751 | if (ferror (datain)) { |
752 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
752 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
753 | uustring (S_SOURCE_READ_ERR), |
753 | uustring (S_SOURCE_READ_ERR), |
754 | strerror (uu_errno = errno)); |
754 | strerror (uu_errno = errno)); |
… | |
… | |
841 | uulboundary = -1; |
841 | uulboundary = -1; |
842 | |
842 | |
843 | while (!feof (datain) && |
843 | while (!feof (datain) && |
844 | (ftell(datain)<maxpos || flags&FL_TOEND || |
844 | (ftell(datain)<maxpos || flags&FL_TOEND || |
845 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
845 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
846 | if (FP_fgets (line, 255, datain) == NULL) |
846 | if (_FP_fgets (line, 255, datain) == NULL) |
847 | break; |
847 | break; |
848 | if (ferror (datain)) { |
848 | if (ferror (datain)) { |
849 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
849 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
850 | uustring (S_SOURCE_READ_ERR), |
850 | uustring (S_SOURCE_READ_ERR), |
851 | strerror (uu_errno = errno)); |
851 | strerror (uu_errno = errno)); |
… | |
… | |
933 | } |
933 | } |
934 | |
934 | |
935 | while (!feof (datain) && *state != DONE && |
935 | while (!feof (datain) && *state != DONE && |
936 | (ftell(datain)<maxpos || flags&FL_TOEND || maxpos==-1 || |
936 | (ftell(datain)<maxpos || flags&FL_TOEND || maxpos==-1 || |
937 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
937 | (!(flags&FL_PROPER) && uu_fast_scanning))) { |
938 | if (FP_fgets (line, 299, datain) == NULL) |
938 | if (_FP_fgets (line, 299, datain) == NULL) |
939 | break; |
939 | break; |
940 | |
940 | |
941 | if (ferror (datain)) { |
941 | if (ferror (datain)) { |
942 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
942 | UUMessage (uunconc_id, __LINE__, UUMSG_ERROR, |
943 | uustring (S_SOURCE_READ_ERR), |
943 | uustring (S_SOURCE_READ_ERR), |
… | |
… | |
993 | * Use this pseudo-handling only if !FL_PROPER |
993 | * Use this pseudo-handling only if !FL_PROPER |
994 | */ |
994 | */ |
995 | |
995 | |
996 | if ((flags&FL_PROPER) == 0) { |
996 | if ((flags&FL_PROPER) == 0) { |
997 | if (strncmp (line, "BEGIN", 5) == 0 && |
997 | if (strncmp (line, "BEGIN", 5) == 0 && |
998 | FP_strstr (line, "CUT HERE") && !tf) { /* I hate these lines */ |
998 | _FP_strstr (line, "CUT HERE") && !tf) { /* I hate these lines */ |
999 | tc = tf = vlc = 0; |
999 | tc = tf = vlc = 0; |
1000 | continue; |
1000 | continue; |
1001 | } |
1001 | } |
1002 | /* MIME body boundary */ |
1002 | /* MIME body boundary */ |
1003 | if (line[0] == '-' && line[1] == '-' && method == B64ENCODED) { |
1003 | if (line[0] == '-' && line[1] == '-' && method == B64ENCODED) { |
… | |
… | |
1009 | } |
1009 | } |
1010 | hadct = 0; |
1010 | hadct = 0; |
1011 | haddh = 1; |
1011 | haddh = 1; |
1012 | continue; |
1012 | continue; |
1013 | } |
1013 | } |
1014 | if (FP_strnicmp (line, "Content-Type", 12) == 0) |
1014 | if (_FP_strnicmp (line, "Content-Type", 12) == 0) |
1015 | hadct = 1; |
1015 | hadct = 1; |
1016 | } |
1016 | } |
1017 | |
1017 | |
1018 | if (*state == BEGIN) { |
1018 | if (*state == BEGIN) { |
1019 | if ((method == UU_ENCODED || method == XX_ENCODED) && |
1019 | if ((method == UU_ENCODED || method == XX_ENCODED) && |
1020 | (strncmp (line, "begin ", 6) == 0 || |
1020 | (strncmp (line, "begin ", 6) == 0 || |
1021 | FP_strnicmp (line, "<pre>begin ", 11) == 0)) { /* for LYNX */ |
1021 | _FP_strnicmp (line, "<pre>begin ", 11) == 0)) { /* for LYNX */ |
1022 | *state = DATA; |
1022 | *state = DATA; |
1023 | continue; |
1023 | continue; |
1024 | } |
1024 | } |
1025 | else if (method == BH_ENCODED && line[0] == ':') { |
1025 | else if (method == BH_ENCODED && line[0] == ':') { |
1026 | if (UUValidData (line, BH_ENCODED, &bhflag) == BH_ENCODED) { |
1026 | if (UUValidData (line, BH_ENCODED, &bhflag) == BH_ENCODED) { |
… | |
… | |
1030 | else |
1030 | else |
1031 | continue; |
1031 | continue; |
1032 | } |
1032 | } |
1033 | else if (method == YENC_ENCODED && |
1033 | else if (method == YENC_ENCODED && |
1034 | strncmp (line, "=ybegin ", 8) == 0 && |
1034 | strncmp (line, "=ybegin ", 8) == 0 && |
1035 | FP_strstr (line, " size=") != NULL && |
1035 | _FP_strstr (line, " size=") != NULL && |
1036 | FP_strstr (line, " name=") != NULL) { |
1036 | _FP_strstr (line, " name=") != NULL) { |
1037 | *state = DATA; |
1037 | *state = DATA; |
1038 | |
1038 | |
1039 | ptr = FP_strstr (line, " size=") + 6; |
1039 | ptr = _FP_strstr (line, " size=") + 6; |
1040 | yefilesize = atoi (ptr); |
1040 | yefilesize = atoi (ptr); |
1041 | |
1041 | |
1042 | if (FP_strstr (line, " part=") != NULL) { |
1042 | if (_FP_strstr (line, " part=") != NULL) { |
1043 | if (FP_fgets (line, 299, datain) == NULL) { |
1043 | if (_FP_fgets (line, 299, datain) == NULL) { |
1044 | break; |
1044 | break; |
1045 | } |
1045 | } |
1046 | |
1046 | |
1047 | if ((ptr = FP_strstr (line, " end=")) == NULL) { |
1047 | if ((ptr = _FP_strstr (line, " end=")) == NULL) { |
1048 | break; |
1048 | break; |
1049 | } |
1049 | } |
1050 | |
1050 | |
1051 | yepartends = atoi (ptr + 5); |
1051 | yepartends = atoi (ptr + 5); |
1052 | } |
1052 | } |
… | |
… | |
1120 | } |
1120 | } |
1121 | lc[0] = 0; |
1121 | lc[0] = 0; |
1122 | lc[1] = 3; |
1122 | lc[1] = 3; |
1123 | } |
1123 | } |
1124 | else { |
1124 | else { |
1125 | FP_strncpy (save[tc++], line, 256); |
1125 | _FP_strncpy (save[tc++], line, 256); |
1126 | } |
1126 | } |
1127 | |
1127 | |
1128 | if (method == UU_ENCODED) |
1128 | if (method == UU_ENCODED) |
1129 | *state = (line[0] == 'M') ? DATA : END; |
1129 | *state = (line[0] == 'M') ? DATA : END; |
1130 | else if (method == XX_ENCODED) |
1130 | else if (method == XX_ENCODED) |
… | |
… | |
1266 | if (tmpfd != -1) { |
1266 | if (tmpfd != -1) { |
1267 | unlink(data->binfile); |
1267 | unlink(data->binfile); |
1268 | close(tmpfd); |
1268 | close(tmpfd); |
1269 | } |
1269 | } |
1270 | #endif /* HAVE_MKSTEMP */ |
1270 | #endif /* HAVE_MKSTEMP */ |
1271 | FP_free (data->binfile); |
1271 | _FP_free (data->binfile); |
1272 | data->binfile = NULL; |
1272 | data->binfile = NULL; |
1273 | uu_errno = errno; |
1273 | uu_errno = errno; |
1274 | return UURET_IOERR; |
1274 | return UURET_IOERR; |
1275 | } |
1275 | } |
1276 | |
1276 | |
… | |
… | |
1296 | /* |
1296 | /* |
1297 | * initialize progress information |
1297 | * initialize progress information |
1298 | */ |
1298 | */ |
1299 | progress.action = 0; |
1299 | progress.action = 0; |
1300 | if (data->filename != NULL) { |
1300 | if (data->filename != NULL) { |
1301 | FP_strncpy (progress.curfile, |
1301 | _FP_strncpy (progress.curfile, |
1302 | (strlen(data->filename)>255)? |
1302 | (strlen(data->filename)>255)? |
1303 | (data->filename+strlen(data->filename)-255):data->filename, |
1303 | (data->filename+strlen(data->filename)-255):data->filename, |
1304 | 256); |
1304 | 256); |
1305 | } |
1305 | } |
1306 | else { |
1306 | else { |
1307 | FP_strncpy (progress.curfile, |
1307 | _FP_strncpy (progress.curfile, |
1308 | (strlen(data->binfile)>255)? |
1308 | (strlen(data->binfile)>255)? |
1309 | (data->binfile+strlen(data->binfile)-255):data->binfile, |
1309 | (data->binfile+strlen(data->binfile)-255):data->binfile, |
1310 | 256); |
1310 | 256); |
1311 | } |
1311 | } |
1312 | progress.partno = 0; |
1312 | progress.partno = 0; |
… | |
… | |
1361 | uustring (S_NOT_OPEN_FILE), |
1361 | uustring (S_NOT_OPEN_FILE), |
1362 | iter->data->sfname, strerror (uu_errno = errno)); |
1362 | iter->data->sfname, strerror (uu_errno = errno)); |
1363 | res = UURET_IOERR; |
1363 | res = UURET_IOERR; |
1364 | break; |
1364 | break; |
1365 | } |
1365 | } |
1366 | FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024); |
1366 | _FP_strncpy (uugen_fnbuffer, iter->data->sfname, 1024); |
1367 | } |
1367 | } |
1368 | |
1368 | |
1369 | progress.partno = part; |
1369 | progress.partno = part; |
1370 | progress.fsize = (iter->data->length)?iter->data->length:-1; |
1370 | progress.fsize = (iter->data->length)?iter->data->length:-1; |
1371 | progress.percent = 0; |
1371 | progress.percent = 0; |
… | |
… | |
1393 | |
1393 | |
1394 | fclose (dataout); |
1394 | fclose (dataout); |
1395 | |
1395 | |
1396 | if (res != UURET_OK || (state != DONE && !uu_desperate)) { |
1396 | if (res != UURET_OK || (state != DONE && !uu_desperate)) { |
1397 | unlink (data->binfile); |
1397 | unlink (data->binfile); |
1398 | FP_free (data->binfile); |
1398 | _FP_free (data->binfile); |
1399 | data->binfile = NULL; |
1399 | data->binfile = NULL; |
1400 | data->state &= ~UUFILE_TMPFILE; |
1400 | data->state &= ~UUFILE_TMPFILE; |
1401 | data->state |= UUFILE_ERROR; |
1401 | data->state |= UUFILE_ERROR; |
1402 | |
1402 | |
1403 | if (res == UURET_OK && state != DONE) |
1403 | if (res == UURET_OK && state != DONE) |
… | |
… | |
1594 | */ |
1594 | */ |
1595 | |
1595 | |
1596 | memset (&myenv, 0, sizeof (headers)); |
1596 | memset (&myenv, 0, sizeof (headers)); |
1597 | UUScanHeader (datain, &myenv); |
1597 | UUScanHeader (datain, &myenv); |
1598 | |
1598 | |
1599 | if (FP_stristr (myenv.ctenc, "uu") != NULL) |
1599 | if (_FP_stristr (myenv.ctenc, "uu") != NULL) |
1600 | encoding = UU_ENCODED; |
1600 | encoding = UU_ENCODED; |
1601 | else if (FP_stristr (myenv.ctenc, "xx") != NULL) |
1601 | else if (_FP_stristr (myenv.ctenc, "xx") != NULL) |
1602 | encoding = XX_ENCODED; |
1602 | encoding = XX_ENCODED; |
1603 | else if (FP_stricmp (myenv.ctenc, "base64") == 0) |
1603 | else if (_FP_stricmp (myenv.ctenc, "base64") == 0) |
1604 | encoding = B64ENCODED; |
1604 | encoding = B64ENCODED; |
1605 | else if (FP_stricmp (myenv.ctenc, "quoted-printable") == 0) |
1605 | else if (_FP_stricmp (myenv.ctenc, "quoted-printable") == 0) |
1606 | encoding = QP_ENCODED; |
1606 | encoding = QP_ENCODED; |
1607 | else |
1607 | else |
1608 | encoding = PT_ENCODED; |
1608 | encoding = PT_ENCODED; |
1609 | |
1609 | |
1610 | UUkillheaders (&myenv); |
1610 | UUkillheaders (&myenv); |