… | |
… | |
51 | #include <uudeview.h> |
51 | #include <uudeview.h> |
52 | #include <uuint.h> |
52 | #include <uuint.h> |
53 | #include <fptools.h> |
53 | #include <fptools.h> |
54 | #include <uustring.h> |
54 | #include <uustring.h> |
55 | |
55 | |
56 | char * uucheck_id = "$Id: uucheck.c,v 1.21 2020/12/11 06:22:26 root Exp $"; |
56 | char * uucheck_id = "$Id: uucheck.c,v 1.22 2020/12/11 20:09:23 root Exp $"; |
57 | |
57 | |
58 | /* |
58 | /* |
59 | * Arbitrary number. This is the maximum number of part numbers we |
59 | * Arbitrary number. This is the maximum number of part numbers we |
60 | * store for our have-parts and missing-parts lists |
60 | * store for our have-parts and missing-parts lists |
61 | */ |
61 | */ |
… | |
… | |
131 | /* |
131 | /* |
132 | * Ignore a "Repost" prefix of the subject line. We don't want to get |
132 | * Ignore a "Repost" prefix of the subject line. We don't want to get |
133 | * a file named "Repost" :-) |
133 | * a file named "Repost" :-) |
134 | **/ |
134 | **/ |
135 | |
135 | |
136 | if (_FP_strnicmp (subject, "repost", 6) == 0) |
136 | if (FP_strnicmp (subject, "repost", 6) == 0) |
137 | subject += 6; |
137 | subject += 6; |
138 | if (_FP_strnicmp (subject, "re:", 3) == 0) |
138 | if (FP_strnicmp (subject, "re:", 3) == 0) |
139 | subject += 3; |
139 | subject += 3; |
140 | |
140 | |
141 | while (*subject == ' ' || *subject == ':') subject++; |
141 | while (*subject == ' ' || *subject == ':') subject++; |
142 | |
142 | |
143 | part = _FP_stristr (subject, "part"); |
143 | part = FP_stristr (subject, "part"); |
144 | if (part == subject) { |
144 | if (part == subject) { |
145 | subject += 4; |
145 | subject += 4; |
146 | while (*subject == ' ') subject++; |
146 | while (*subject == ' ') subject++; |
147 | } |
147 | } |
148 | |
148 | |
… | |
… | |
221 | /*while (*ptr && *ptr != 0x0a && *ptr != 0x0d && ptr != part) {*/ |
221 | /*while (*ptr && *ptr != 0x0a && *ptr != 0x0d && ptr != part) {*/ |
222 | while (*ptr && *ptr != 0x0a && *ptr != 0x0d) { |
222 | while (*ptr && *ptr != 0x0a && *ptr != 0x0d) { |
223 | iter = ptr; |
223 | iter = ptr; |
224 | count = length = alflag = 0; |
224 | count = length = alflag = 0; |
225 | |
225 | |
226 | if (_FP_strnicmp (ptr, "ftp", 3) == 0) { |
226 | if (FP_strnicmp (ptr, "ftp", 3) == 0) { |
227 | /* hey, that's an ftp address */ |
227 | /* hey, that's an ftp address */ |
228 | while (isalpha (*ptr) || isdigit (*ptr) || *ptr == '.') |
228 | while (isalpha (*ptr) || isdigit (*ptr) || *ptr == '.') |
229 | ptr++; |
229 | ptr++; |
230 | continue; |
230 | continue; |
231 | } |
231 | } |
… | |
… | |
260 | ptr = iter + 1; |
260 | ptr = iter + 1; |
261 | length = 0; |
261 | length = 0; |
262 | continue; |
262 | continue; |
263 | } |
263 | } |
264 | |
264 | |
265 | if (_FP_strnicmp (iter, "edu", 3) == 0 || |
265 | if (FP_strnicmp (iter, "edu", 3) == 0 || |
266 | _FP_strnicmp (iter, "gov", 3) == 0) { |
266 | FP_strnicmp (iter, "gov", 3) == 0) { |
267 | /* hey, that's an ftp address */ |
267 | /* hey, that's an ftp address */ |
268 | while (isalpha (*iter) || isdigit (*iter) || *iter == '.') |
268 | while (isalpha (*iter) || isdigit (*iter) || *iter == '.') |
269 | iter++; |
269 | iter++; |
270 | ptr = iter; |
270 | ptr = iter; |
271 | length = 0; |
271 | length = 0; |
… | |
… | |
443 | } |
443 | } |
444 | |
444 | |
445 | while (iter[count] == ' ' || iter[count] == '#' || |
445 | while (iter[count] == ' ' || iter[count] == '#' || |
446 | iter[count] == '/' || iter[count] == '\\') count++; |
446 | iter[count] == '/' || iter[count] == '\\') count++; |
447 | |
447 | |
448 | if (_FP_strnicmp (iter + count, "of", 2) == 0) |
448 | if (FP_strnicmp (iter + count, "of", 2) == 0) |
449 | count += 2; |
449 | count += 2; |
450 | |
450 | |
451 | while (iter[count] == ' ') count++; |
451 | while (iter[count] == ' ') count++; |
452 | while (isdigit (iter[count])) count++; |
452 | while (isdigit (iter[count])) count++; |
453 | while (iter[count] == ' ') count++; |
453 | while (iter[count] == ' ') count++; |
… | |
… | |
470 | /* |
470 | /* |
471 | * look for the string "part " followed by a number |
471 | * look for the string "part " followed by a number |
472 | */ |
472 | */ |
473 | |
473 | |
474 | if (length == 0) { |
474 | if (length == 0) { |
475 | if ((iter = _FP_stristr (subject, "part ")) != NULL) { |
475 | if ((iter = FP_stristr (subject, "part ")) != NULL) { |
476 | iter += 5; |
476 | iter += 5; |
477 | |
477 | |
478 | while (isspace (*iter) || *iter == '.' || *iter == '-') |
478 | while (isspace (*iter) || *iter == '.' || *iter == '-') |
479 | iter++; |
479 | iter++; |
480 | |
480 | |
481 | while (isdigit (iter[length])) |
481 | while (isdigit (iter[length])) |
482 | length++; |
482 | length++; |
483 | |
483 | |
484 | if (length == 0) { |
484 | if (length == 0) { |
485 | if (_FP_strnicmp (iter, "one", 3) == 0) length = 1; |
485 | if (FP_strnicmp (iter, "one", 3) == 0) length = 1; |
486 | else if (_FP_strnicmp (iter, "two", 3) == 0) length = 2; |
486 | else if (FP_strnicmp (iter, "two", 3) == 0) length = 2; |
487 | else if (_FP_strnicmp (iter, "three", 5) == 0) length = 3; |
487 | else if (FP_strnicmp (iter, "three", 5) == 0) length = 3; |
488 | else if (_FP_strnicmp (iter, "four", 4) == 0) length = 4; |
488 | else if (FP_strnicmp (iter, "four", 4) == 0) length = 4; |
489 | else if (_FP_strnicmp (iter, "five", 4) == 0) length = 5; |
489 | else if (FP_strnicmp (iter, "five", 4) == 0) length = 5; |
490 | else if (_FP_strnicmp (iter, "six", 3) == 0) length = 6; |
490 | else if (FP_strnicmp (iter, "six", 3) == 0) length = 6; |
491 | else if (_FP_strnicmp (iter, "seven", 5) == 0) length = 7; |
491 | else if (FP_strnicmp (iter, "seven", 5) == 0) length = 7; |
492 | else if (_FP_strnicmp (iter, "eight", 5) == 0) length = 8; |
492 | else if (FP_strnicmp (iter, "eight", 5) == 0) length = 8; |
493 | else if (_FP_strnicmp (iter, "nine", 4) == 0) length = 9; |
493 | else if (FP_strnicmp (iter, "nine", 4) == 0) length = 9; |
494 | else if (_FP_strnicmp (iter, "ten", 3) == 0) length = 10; |
494 | else if (FP_strnicmp (iter, "ten", 3) == 0) length = 10; |
495 | |
495 | |
496 | if (length && (*whend = strchr (iter, ' '))) { |
496 | if (length && (*whend = strchr (iter, ' '))) { |
497 | *where = iter; |
497 | *where = iter; |
498 | return length; |
498 | return length; |
499 | } |
499 | } |
… | |
… | |
510 | /* |
510 | /* |
511 | * look for the string "part" followed by a number |
511 | * look for the string "part" followed by a number |
512 | */ |
512 | */ |
513 | |
513 | |
514 | if (length == 0) { |
514 | if (length == 0) { |
515 | if ((iter = _FP_stristr (subject, "part")) != NULL) { |
515 | if ((iter = FP_stristr (subject, "part")) != NULL) { |
516 | iter += 4; |
516 | iter += 4; |
517 | |
517 | |
518 | while (isspace (*iter) || *iter == '.' || *iter == '-') |
518 | while (isspace (*iter) || *iter == '.' || *iter == '-') |
519 | iter++; |
519 | iter++; |
520 | |
520 | |
521 | while (isdigit (iter[length])) |
521 | while (isdigit (iter[length])) |
522 | length++; |
522 | length++; |
523 | |
523 | |
524 | if (length == 0) { |
524 | if (length == 0) { |
525 | if (_FP_strnicmp (iter, "one", 3) == 0) length = 1; |
525 | if (FP_strnicmp (iter, "one", 3) == 0) length = 1; |
526 | else if (_FP_strnicmp (iter, "two", 3) == 0) length = 2; |
526 | else if (FP_strnicmp (iter, "two", 3) == 0) length = 2; |
527 | else if (_FP_strnicmp (iter, "three", 5) == 0) length = 3; |
527 | else if (FP_strnicmp (iter, "three", 5) == 0) length = 3; |
528 | else if (_FP_strnicmp (iter, "four", 4) == 0) length = 4; |
528 | else if (FP_strnicmp (iter, "four", 4) == 0) length = 4; |
529 | else if (_FP_strnicmp (iter, "five", 4) == 0) length = 5; |
529 | else if (FP_strnicmp (iter, "five", 4) == 0) length = 5; |
530 | else if (_FP_strnicmp (iter, "six", 3) == 0) length = 6; |
530 | else if (FP_strnicmp (iter, "six", 3) == 0) length = 6; |
531 | else if (_FP_strnicmp (iter, "seven", 5) == 0) length = 7; |
531 | else if (FP_strnicmp (iter, "seven", 5) == 0) length = 7; |
532 | else if (_FP_strnicmp (iter, "eight", 5) == 0) length = 8; |
532 | else if (FP_strnicmp (iter, "eight", 5) == 0) length = 8; |
533 | else if (_FP_strnicmp (iter, "nine", 4) == 0) length = 9; |
533 | else if (FP_strnicmp (iter, "nine", 4) == 0) length = 9; |
534 | else if (_FP_strnicmp (iter, "ten", 3) == 0) length = 10; |
534 | else if (FP_strnicmp (iter, "ten", 3) == 0) length = 10; |
535 | |
535 | |
536 | if (length && (*whend = strchr (iter, ' '))) { |
536 | if (length && (*whend = strchr (iter, ' '))) { |
537 | *where = iter; |
537 | *where = iter; |
538 | return length; |
538 | return length; |
539 | } |
539 | } |
… | |
… | |
550 | /* |
550 | /* |
551 | * look for [0-9]* "of" [0-9]* |
551 | * look for [0-9]* "of" [0-9]* |
552 | */ |
552 | */ |
553 | |
553 | |
554 | if (length == 0) { |
554 | if (length == 0) { |
555 | if ((iter = _FP_strirstr (subject, "of")) != NULL) { |
555 | if ((iter = FP_strirstr (subject, "of")) != NULL) { |
556 | while (iter>subject && isspace (*(iter-1))) |
556 | while (iter>subject && isspace (*(iter-1))) |
557 | iter--; |
557 | iter--; |
558 | if (isdigit(*(iter-1))) { |
558 | if (isdigit(*(iter-1))) { |
559 | while (iter>subject && isdigit (*(iter-1))) |
559 | while (iter>subject && isdigit (*(iter-1))) |
560 | iter--; |
560 | iter--; |
… | |
… | |
649 | |
649 | |
650 | if (length == 0) { |
650 | if (length == 0) { |
651 | /* |
651 | /* |
652 | * some people use the strangest things, including spelling mistakes :-) |
652 | * some people use the strangest things, including spelling mistakes :-) |
653 | */ |
653 | */ |
654 | if ((iter = _FP_stristr (subject, "first")) != NULL) length = 1; |
654 | if ((iter = FP_stristr (subject, "first")) != NULL) length = 1; |
655 | else if ((iter = _FP_stristr (subject, "second")) != NULL) length = 2; |
655 | else if ((iter = FP_stristr (subject, "second")) != NULL) length = 2; |
656 | else if ((iter = _FP_stristr (subject, "third")) != NULL) length = 3; |
656 | else if ((iter = FP_stristr (subject, "third")) != NULL) length = 3; |
657 | else if ((iter = _FP_stristr (subject, "forth")) != NULL) length = 4; |
657 | else if ((iter = FP_stristr (subject, "forth")) != NULL) length = 4; |
658 | else if ((iter = _FP_stristr (subject, "fourth")) != NULL) length = 4; |
658 | else if ((iter = FP_stristr (subject, "fourth")) != NULL) length = 4; |
659 | else if ((iter = _FP_stristr (subject, "fifth")) != NULL) length = 5; |
659 | else if ((iter = FP_stristr (subject, "fifth")) != NULL) length = 5; |
660 | else if ((iter = _FP_stristr (subject, "sixth")) != NULL) length = 6; |
660 | else if ((iter = FP_stristr (subject, "sixth")) != NULL) length = 6; |
661 | else if ((iter = _FP_stristr (subject, "seventh")) != NULL) length = 7; |
661 | else if ((iter = FP_stristr (subject, "seventh")) != NULL) length = 7; |
662 | else if ((iter = _FP_stristr (subject, "eigth")) != NULL) length = 8; |
662 | else if ((iter = FP_stristr (subject, "eigth")) != NULL) length = 8; |
663 | else if ((iter = _FP_stristr (subject, "eighth")) != NULL) length = 8; |
663 | else if ((iter = FP_stristr (subject, "eighth")) != NULL) length = 8; |
664 | else if ((iter = _FP_stristr (subject, "nineth")) != NULL) length = 9; |
664 | else if ((iter = FP_stristr (subject, "nineth")) != NULL) length = 9; |
665 | else if ((iter = _FP_stristr (subject, "ninth")) != NULL) length = 9; |
665 | else if ((iter = FP_stristr (subject, "ninth")) != NULL) length = 9; |
666 | else if ((iter = _FP_stristr (subject, "tenth")) != NULL) length = 10; |
666 | else if ((iter = FP_stristr (subject, "tenth")) != NULL) length = 10; |
667 | else iter = NULL; |
667 | else iter = NULL; |
668 | |
668 | |
669 | if (length && iter && (*whend = strchr (iter, ' '))) { |
669 | if (length && iter && (*whend = strchr (iter, ' '))) { |
670 | *where = iter; |
670 | *where = iter; |
671 | return length; |
671 | return length; |
… | |
… | |
678 | return -1; |
678 | return -1; |
679 | |
679 | |
680 | *where = iter; |
680 | *where = iter; |
681 | |
681 | |
682 | if (delim && delim[0]) { |
682 | if (delim && delim[0]) { |
683 | if ((*whend=_FP_stristr (iter, delim)) != NULL && (*whend - *where) < 12) { |
683 | if ((*whend=FP_stristr (iter, delim)) != NULL && (*whend - *where) < 12) { |
684 | ptr = (*whend += strlen (delim)); |
684 | ptr = (*whend += strlen (delim)); |
685 | |
685 | |
686 | while (*ptr == ' ') |
686 | while (*ptr == ' ') |
687 | ptr++; |
687 | ptr++; |
688 | |
688 | |
… | |
… | |
734 | UUkillfile (result); |
734 | UUkillfile (result); |
735 | return NULL; |
735 | return NULL; |
736 | } |
736 | } |
737 | |
737 | |
738 | if (data->filename != NULL) { |
738 | if (data->filename != NULL) { |
739 | if ((result->filename = _FP_strdup (data->filename)) == NULL) { |
739 | if ((result->filename = FP_strdup (data->filename)) == NULL) { |
740 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
740 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
741 | uustring (S_OUT_OF_MEMORY), |
741 | uustring (S_OUT_OF_MEMORY), |
742 | strlen (data->filename)+1); |
742 | strlen (data->filename)+1); |
743 | *ret = UURET_NOMEM; |
743 | *ret = UURET_NOMEM; |
744 | UUkillfile (result); |
744 | UUkillfile (result); |
… | |
… | |
752 | result->subfname = UUGetFileName (data->subject, where, whend); |
752 | result->subfname = UUGetFileName (data->subject, where, whend); |
753 | else |
753 | else |
754 | result->subfname = NULL; |
754 | result->subfname = NULL; |
755 | |
755 | |
756 | result->yefilesize = data->yefilesize; |
756 | result->yefilesize = data->yefilesize; |
757 | result->mimeid = _FP_strdup (data->mimeid); |
757 | result->mimeid = FP_strdup (data->mimeid); |
758 | result->mimetype = _FP_strdup (data->mimetype); |
758 | result->mimetype = FP_strdup (data->mimetype); |
759 | |
759 | |
760 | if (result->partno == -1 && |
760 | if (result->partno == -1 && |
761 | (data->uudet == PT_ENCODED || data->uudet == QP_ENCODED)) |
761 | (data->uudet == PT_ENCODED || data->uudet == QP_ENCODED)) |
762 | result->partno = 1; |
762 | result->partno = 1; |
763 | |
763 | |
… | |
… | |
765 | /* |
765 | /* |
766 | * Don't touch this part. But it should really have a filename |
766 | * Don't touch this part. But it should really have a filename |
767 | */ |
767 | */ |
768 | if (result->filename == NULL) { |
768 | if (result->filename == NULL) { |
769 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
769 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
770 | result->filename = _FP_strdup (temp); |
770 | result->filename = FP_strdup (temp); |
771 | } |
771 | } |
772 | if (result->subfname == NULL) |
772 | if (result->subfname == NULL) |
773 | result->subfname = _FP_strdup (result->filename); |
773 | result->subfname = FP_strdup (result->filename); |
774 | |
774 | |
775 | if (result->filename == NULL || |
775 | if (result->filename == NULL || |
776 | result->subfname == NULL) { |
776 | result->subfname == NULL) { |
777 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
777 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
778 | uustring (S_OUT_OF_MEMORY), |
778 | uustring (S_OUT_OF_MEMORY), |
… | |
… | |
795 | */ |
795 | */ |
796 | /* |
796 | /* |
797 | * in this case, it really _should_ have a filename somewhere |
797 | * in this case, it really _should_ have a filename somewhere |
798 | */ |
798 | */ |
799 | if (result->filename != NULL && *result->filename) |
799 | if (result->filename != NULL && *result->filename) |
800 | result->subfname = _FP_strdup (result->filename); |
800 | result->subfname = FP_strdup (result->filename); |
801 | else { /* if not, escape to UNKNOWN. We need to fill subfname */ |
801 | else { /* if not, escape to UNKNOWN. We need to fill subfname */ |
802 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
802 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
803 | result->subfname = _FP_strdup (temp); |
803 | result->subfname = FP_strdup (temp); |
804 | } |
804 | } |
805 | /* |
805 | /* |
806 | * in case the strdup failed |
806 | * in case the strdup failed |
807 | */ |
807 | */ |
808 | if (result->subfname == NULL) { |
808 | if (result->subfname == NULL) { |
… | |
… | |
823 | * initialize lastvalid |
823 | * initialize lastvalid |
824 | */ |
824 | */ |
825 | lastvalid = 1; |
825 | lastvalid = 1; |
826 | lastenc = data->uudet; |
826 | lastenc = data->uudet; |
827 | lastpart = result->partno = 1; |
827 | lastpart = result->partno = 1; |
828 | _FP_strncpy (uucheck_lastname, result->subfname, 256); |
828 | FP_strncpy (uucheck_lastname, result->subfname, 256); |
829 | } |
829 | } |
830 | else |
830 | else |
831 | result->partno = 1; |
831 | result->partno = 1; |
832 | } |
832 | } |
833 | else if (result->subfname == NULL && data->uudet && data->mimeid) { |
833 | else if (result->subfname == NULL && data->uudet && data->mimeid) { |
… | |
… | |
835 | * if it's got a file name, use it. Else use the mime-id for identifying |
835 | * if it's got a file name, use it. Else use the mime-id for identifying |
836 | * this part, and hope there's no other files encoded in the same message |
836 | * this part, and hope there's no other files encoded in the same message |
837 | * under the same id. |
837 | * under the same id. |
838 | */ |
838 | */ |
839 | if (result->filename) |
839 | if (result->filename) |
840 | result->subfname = _FP_strdup (result->filename); |
840 | result->subfname = FP_strdup (result->filename); |
841 | else |
841 | else |
842 | result->subfname = _FP_strdup (result->mimeid); |
842 | result->subfname = FP_strdup (result->mimeid); |
843 | } |
843 | } |
844 | else if (result->subfname == NULL && data->uudet) { |
844 | else if (result->subfname == NULL && data->uudet) { |
845 | /* |
845 | /* |
846 | * ff we have lastvalid, use it. Make an exception for |
846 | * ff we have lastvalid, use it. Make an exception for |
847 | * Base64-encoded files. |
847 | * Base64-encoded files. |
… | |
… | |
849 | if (data->uudet == B64ENCODED) { |
849 | if (data->uudet == B64ENCODED) { |
850 | /* |
850 | /* |
851 | * Assume it's the first part. I wonder why it's got no part number? |
851 | * Assume it's the first part. I wonder why it's got no part number? |
852 | */ |
852 | */ |
853 | if (result->filename != NULL && *result->filename) |
853 | if (result->filename != NULL && *result->filename) |
854 | result->subfname = _FP_strdup (result->filename); |
854 | result->subfname = FP_strdup (result->filename); |
855 | else { /* if not, escape to UNKNOWN. We need to fill subfname */ |
855 | else { /* if not, escape to UNKNOWN. We need to fill subfname */ |
856 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
856 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
857 | result->subfname = _FP_strdup (temp); |
857 | result->subfname = FP_strdup (temp); |
858 | } |
858 | } |
859 | if (result->subfname == NULL) { |
859 | if (result->subfname == NULL) { |
860 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
860 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
861 | uustring (S_OUT_OF_MEMORY), |
861 | uustring (S_OUT_OF_MEMORY), |
862 | (result->filename)? |
862 | (result->filename)? |
… | |
… | |
866 | return NULL; |
866 | return NULL; |
867 | } |
867 | } |
868 | lastvalid = 0; |
868 | lastvalid = 0; |
869 | } |
869 | } |
870 | else if (lastvalid && data->uudet == lastenc && result->partno == -1) { |
870 | else if (lastvalid && data->uudet == lastenc && result->partno == -1) { |
871 | result->subfname = _FP_strdup (uucheck_lastname); |
871 | result->subfname = FP_strdup (uucheck_lastname); |
872 | result->partno = ++lastpart; |
872 | result->partno = ++lastpart; |
873 | |
873 | |
874 | /* |
874 | /* |
875 | * if it's the last part, invalidate lastvalid |
875 | * if it's the last part, invalidate lastvalid |
876 | */ |
876 | */ |
877 | if (data->end || (data->partno && data->partno == data->maxpno)) |
877 | if (data->end || (data->partno && data->partno == data->maxpno)) |
878 | lastvalid = 0; |
878 | lastvalid = 0; |
879 | } |
879 | } |
880 | else if (data->partno != -1 && result->filename) { |
880 | else if (data->partno != -1 && result->filename) { |
881 | result->subfname = _FP_strdup (result->filename); |
881 | result->subfname = FP_strdup (result->filename); |
882 | } |
882 | } |
883 | else { |
883 | else { |
884 | /* |
884 | /* |
885 | * it's got no info, it's got no begin, and we don't know anything |
885 | * it's got no info, it's got no begin, and we don't know anything |
886 | * about this part. Let's forget all about it. |
886 | * about this part. Let's forget all about it. |
… | |
… | |
919 | /* |
919 | /* |
920 | * hmm, this is reason enough to initialize lastvalid, at least |
920 | * hmm, this is reason enough to initialize lastvalid, at least |
921 | * if we have no end |
921 | * if we have no end |
922 | */ |
922 | */ |
923 | if (!data->end) { |
923 | if (!data->end) { |
924 | _FP_strncpy (uucheck_lastname, result->subfname, 256); |
924 | FP_strncpy (uucheck_lastname, result->subfname, 256); |
925 | result->partno = lastpart = 1; |
925 | result->partno = lastpart = 1; |
926 | lastenc = data->uudet; |
926 | lastenc = data->uudet; |
927 | lastvalid = 1; |
927 | lastvalid = 1; |
928 | } |
928 | } |
929 | else |
929 | else |
930 | result->partno = 1; |
930 | result->partno = 1; |
931 | } |
931 | } |
932 | else if (result->partno == -1 && data->uudet) { |
932 | else if (result->partno == -1 && data->uudet) { |
933 | if (lastvalid && _FP_stricmp (uucheck_lastname, result->subfname) == 0) { |
933 | if (lastvalid && FP_stricmp (uucheck_lastname, result->subfname) == 0) { |
934 | /* |
934 | /* |
935 | * if the subject filename is the same as last time, use part no |
935 | * if the subject filename is the same as last time, use part no |
936 | * of lastvalid. If at end, invalidate lastvalid |
936 | * of lastvalid. If at end, invalidate lastvalid |
937 | */ |
937 | */ |
938 | result->partno = ++lastpart; |
938 | result->partno = ++lastpart; |
… | |
… | |
968 | } |
968 | } |
969 | |
969 | |
970 | skipcheck: |
970 | skipcheck: |
971 | |
971 | |
972 | if (result->filename) { |
972 | if (result->filename) { |
973 | if (*(ptr = _FP_cutdir (result->filename))) { |
973 | if (*(ptr = FP_cutdir (result->filename))) { |
974 | p2 = _FP_strdup (ptr); |
974 | p2 = FP_strdup (ptr); |
975 | _FP_free (result->filename); |
975 | FP_free (result->filename); |
976 | result->filename = p2; |
976 | result->filename = p2; |
977 | } |
977 | } |
978 | } |
978 | } |
979 | |
979 | |
980 | result->data = data; |
980 | result->data = data; |
… | |
… | |
1023 | && !(iter->thisfile && iter->thisfile->yefilesize != data->yefilesize) |
1023 | && !(iter->thisfile && iter->thisfile->yefilesize != data->yefilesize) |
1024 | && !(iter->begin && data->data->begin) |
1024 | && !(iter->begin && data->data->begin) |
1025 | && !(iter->end && data->data->end) |
1025 | && !(iter->end && data->data->end) |
1026 | && !(iter->flags & FL_SINGLE) |
1026 | && !(iter->flags & FL_SINGLE) |
1027 | && !(data->filename && iter->filename && strcmp (data->filename, iter->filename) != 0) |
1027 | && !(data->filename && iter->filename && strcmp (data->filename, iter->filename) != 0) |
1028 | && _FP_stricmp (data->subfname, iter->subfname) == 0 |
1028 | && FP_stricmp (data->subfname, iter->subfname) == 0 |
1029 | && !(data->mimeid && iter->mimeid && strcmp (data->mimeid, iter->mimeid) != 0) |
1029 | && !(data->mimeid && iter->mimeid && strcmp (data->mimeid, iter->mimeid) != 0) |
1030 | ) |
1030 | ) |
1031 | ) { |
1031 | ) { |
1032 | |
1032 | |
1033 | /* |
1033 | /* |
… | |
… | |
1046 | } |
1046 | } |
1047 | } |
1047 | } |
1048 | } |
1048 | } |
1049 | |
1049 | |
1050 | if (iter->filename == NULL && data->filename != NULL) { |
1050 | if (iter->filename == NULL && data->filename != NULL) { |
1051 | if ((iter->filename = _FP_strdup (data->filename)) == NULL) |
1051 | if ((iter->filename = FP_strdup (data->filename)) == NULL) |
1052 | return UURET_NOMEM; |
1052 | return UURET_NOMEM; |
1053 | } |
1053 | } |
1054 | |
1054 | |
1055 | /* |
1055 | /* |
1056 | * special case when we might have tagged a part as Base64 when the |
1056 | * special case when we might have tagged a part as Base64 when the |
… | |
… | |
1091 | iter->mode = data->data->mode; |
1091 | iter->mode = data->data->mode; |
1092 | if (data->data->begin) iter->begin = (data->partno)?data->partno:1; |
1092 | if (data->data->begin) iter->begin = (data->partno)?data->partno:1; |
1093 | if (data->data->end) iter->end = (data->partno)?data->partno:1; |
1093 | if (data->data->end) iter->end = (data->partno)?data->partno:1; |
1094 | |
1094 | |
1095 | if (data->mimetype) { |
1095 | if (data->mimetype) { |
1096 | _FP_free (iter->mimetype); |
1096 | FP_free (iter->mimetype); |
1097 | iter->mimetype = _FP_strdup (data->mimetype); |
1097 | iter->mimetype = FP_strdup (data->mimetype); |
1098 | } |
1098 | } |
1099 | |
1099 | |
1100 | /* |
1100 | /* |
1101 | * insert part at the beginning |
1101 | * insert part at the beginning |
1102 | */ |
1102 | */ |
… | |
… | |
1121 | * if we find the same part no again, check which one looks better |
1121 | * if we find the same part no again, check which one looks better |
1122 | */ |
1122 | */ |
1123 | if (data->partno == fiter->partno) { |
1123 | if (data->partno == fiter->partno) { |
1124 | if (fiter->data->subject == NULL) |
1124 | if (fiter->data->subject == NULL) |
1125 | return UURET_NODATA; |
1125 | return UURET_NODATA; |
1126 | else if (_FP_stristr (fiter->data->subject, "repost") != NULL && |
1126 | else if (FP_stristr (fiter->data->subject, "repost") != NULL && |
1127 | _FP_stristr (data->data->subject, "repost") == NULL) |
1127 | FP_stristr (data->data->subject, "repost") == NULL) |
1128 | return UURET_NODATA; |
1128 | return UURET_NODATA; |
1129 | else if (fiter->data->uudet && !data->data->uudet) |
1129 | else if (fiter->data->uudet && !data->data->uudet) |
1130 | return UURET_NODATA; |
1130 | return UURET_NODATA; |
1131 | else { |
1131 | else { |
1132 | /* |
1132 | /* |
… | |
… | |
1198 | { |
1198 | { |
1199 | const uulist uulist_new = { 0 }; |
1199 | const uulist uulist_new = { 0 }; |
1200 | *unew = uulist_new; /* zero-initialise the structure */ |
1200 | *unew = uulist_new; /* zero-initialise the structure */ |
1201 | } |
1201 | } |
1202 | |
1202 | |
1203 | if ((unew->subfname = _FP_strdup (data->subfname)) == NULL) { |
1203 | if ((unew->subfname = FP_strdup (data->subfname)) == NULL) { |
1204 | _FP_free (unew); |
1204 | FP_free (unew); |
1205 | return UURET_NOMEM; |
1205 | return UURET_NOMEM; |
1206 | } |
1206 | } |
1207 | |
1207 | |
1208 | if (data->filename != NULL) { |
1208 | if (data->filename != NULL) { |
1209 | if ((unew->filename = _FP_strdup (data->filename)) == NULL) { |
1209 | if ((unew->filename = FP_strdup (data->filename)) == NULL) { |
1210 | _FP_free (unew->subfname); |
1210 | FP_free (unew->subfname); |
1211 | _FP_free (unew); |
1211 | FP_free (unew); |
1212 | return UURET_NOMEM; |
1212 | return UURET_NOMEM; |
1213 | } |
1213 | } |
1214 | } |
1214 | } |
1215 | else |
1215 | else |
1216 | unew->filename = NULL; |
1216 | unew->filename = NULL; |
1217 | |
1217 | |
1218 | if (data->mimeid != NULL) { |
1218 | if (data->mimeid != NULL) { |
1219 | if ((unew->mimeid = _FP_strdup (data->mimeid)) == NULL) { |
1219 | if ((unew->mimeid = FP_strdup (data->mimeid)) == NULL) { |
1220 | _FP_free (unew->subfname); |
1220 | FP_free (unew->subfname); |
1221 | _FP_free (unew->filename); |
1221 | FP_free (unew->filename); |
1222 | _FP_free (unew); |
1222 | FP_free (unew); |
1223 | return UURET_NOMEM; |
1223 | return UURET_NOMEM; |
1224 | } |
1224 | } |
1225 | } |
1225 | } |
1226 | else |
1226 | else |
1227 | unew->mimeid = NULL; |
1227 | unew->mimeid = NULL; |
1228 | |
1228 | |
1229 | if (data->mimetype != NULL) { |
1229 | if (data->mimetype != NULL) { |
1230 | if ((unew->mimetype = _FP_strdup (data->mimetype)) == NULL) { |
1230 | if ((unew->mimetype = FP_strdup (data->mimetype)) == NULL) { |
1231 | _FP_free (unew->mimeid); |
1231 | FP_free (unew->mimeid); |
1232 | _FP_free (unew->subfname); |
1232 | FP_free (unew->subfname); |
1233 | _FP_free (unew->filename); |
1233 | FP_free (unew->filename); |
1234 | _FP_free (unew); |
1234 | FP_free (unew); |
1235 | return UURET_NOMEM; |
1235 | return UURET_NOMEM; |
1236 | } |
1236 | } |
1237 | } |
1237 | } |
1238 | else |
1238 | else |
1239 | unew->mimetype = NULL; |
1239 | unew->mimetype = NULL; |
… | |
… | |
1419 | |
1419 | |
1420 | /* |
1420 | /* |
1421 | * Set the parts we have and/or missing |
1421 | * Set the parts we have and/or missing |
1422 | */ |
1422 | */ |
1423 | |
1423 | |
1424 | _FP_free (liter->haveparts); |
1424 | FP_free (liter->haveparts); |
1425 | _FP_free (liter->misparts); |
1425 | FP_free (liter->misparts); |
1426 | |
1426 | |
1427 | liter->haveparts = NULL; |
1427 | liter->haveparts = NULL; |
1428 | liter->misparts = NULL; |
1428 | liter->misparts = NULL; |
1429 | |
1429 | |
1430 | if (havecount) { |
1430 | if (havecount) { |
… | |
… | |
1462 | if (liter->state==UUFILE_OK && |
1462 | if (liter->state==UUFILE_OK && |
1463 | (liter->filename==NULL || liter->filename[0]=='\0')) { |
1463 | (liter->filename==NULL || liter->filename[0]=='\0')) { |
1464 | /* |
1464 | /* |
1465 | * Emergency backup if the file does not have a filename |
1465 | * Emergency backup if the file does not have a filename |
1466 | */ |
1466 | */ |
1467 | _FP_free (liter->filename); |
1467 | FP_free (liter->filename); |
1468 | if (liter->subfname && liter->subfname[0] && |
1468 | if (liter->subfname && liter->subfname[0] && |
1469 | _FP_strpbrk (liter->subfname, "()[];: ") == NULL) |
1469 | FP_strpbrk (liter->subfname, "()[];: ") == NULL) |
1470 | liter->filename = _FP_strdup (liter->subfname); |
1470 | liter->filename = FP_strdup (liter->subfname); |
1471 | else { |
1471 | else { |
1472 | sprintf (uucheck_tempname, "%s.%03d", nofname, ++nofnum); |
1472 | sprintf (uucheck_tempname, "%s.%03d", nofname, ++nofnum); |
1473 | liter->filename = _FP_strdup (uucheck_tempname); |
1473 | liter->filename = FP_strdup (uucheck_tempname); |
1474 | } |
1474 | } |
1475 | } |
1475 | } |
1476 | liter = liter->NEXT; |
1476 | liter = liter->NEXT; |
1477 | } |
1477 | } |
1478 | |
1478 | |