ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uucheck.c
(Generate patch)

Comparing Convert-UUlib/uulib/uucheck.c (file contents):
Revision 1.3 by root, Sun Feb 10 22:47:18 2002 UTC vs.
Revision 1.3.2.3 by root, Sun Oct 13 13:03:07 2002 UTC

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
56char * uucheck_id = "$Id: uucheck.c,v 1.3 2002/02/10 22:47:18 root Exp $"; 56char * uucheck_id = "$Id: uucheck.c,v 1.3.2.3 2002/10/13 13:03:07 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 */
65 65
66/* 66/*
67 * forward declarations of local functions 67 * forward declarations of local functions
68 */ 68 */
69 69
70static char * UUGetFileName (char *, char *, char *); 70static char * UUGetFileName _ANSI_ARGS_((char *, char *, char *));
71static int UUGetPartNo (char *, char **, char **); 71static int UUGetPartNo _ANSI_ARGS_((char *, char **, char **));
72 72
73/* 73/*
74 * State of Scanner function and PreProcessPart 74 * State of Scanner function and PreProcessPart
75 */ 75 */
76 76
132/* 132/*
133 * Ignore a "Repost" prefix of the subject line. We don't want to get 133 * Ignore a "Repost" prefix of the subject line. We don't want to get
134 * a file named "Repost" :-) 134 * a file named "Repost" :-)
135 **/ 135 **/
136 136
137 if (FP_strnicmp (subject, "repost", 6) == 0) 137 if (_FP_strnicmp (subject, "repost", 6) == 0)
138 subject += 6; 138 subject += 6;
139 if (FP_strnicmp (subject, "re:", 3) == 0) 139 if (_FP_strnicmp (subject, "re:", 3) == 0)
140 subject += 3; 140 subject += 3;
141 141
142 while (*subject == ' ' || *subject == ':') subject++; 142 while (*subject == ' ' || *subject == ':') subject++;
143 143
144 part = FP_stristr (subject, "part"); 144 part = _FP_stristr (subject, "part");
145 if (part == subject) { 145 if (part == subject) {
146 subject += 4; 146 subject += 4;
147 while (*subject == ' ') subject++; 147 while (*subject == ' ') subject++;
148 } 148 }
149 149
216 * (That's most likely a filename) 216 * (That's most likely a filename)
217 **/ 217 **/
218 218
219 if (length == 0) { 219 if (length == 0) {
220 ptr = subject; 220 ptr = subject;
221 /* #warning another experimental change */
222 /*while (*ptr && *ptr != 0x0a && *ptr != 0x0d && ptr != part) {*/ 221 while (*ptr && *ptr != 0x0a && *ptr != 0x0d && ptr != part) {
223 while (*ptr && *ptr != 0x0a && *ptr != 0x0d) {
224 iter = ptr; 222 iter = ptr;
225 count = length = alflag = 0; 223 count = length = alflag = 0;
226 224
227 if (FP_strnicmp (ptr, "ftp", 3) == 0) { 225 if (_FP_strnicmp (ptr, "ftp", 3) == 0) {
228 /* hey, that's an ftp address */ 226 /* hey, that's an ftp address */
229 while (isalpha (*ptr) || isdigit (*ptr) || *ptr == '.') 227 while (isalpha (*ptr) || isdigit (*ptr) || *ptr == '.')
230 ptr++; 228 ptr++;
231 continue; 229 continue;
232 } 230 }
245 ptr = iter; 243 ptr = iter;
246 244
247 length = 0; 245 length = 0;
248 continue; 246 continue;
249 } 247 }
250
251 /* #warning multi-part change experimental, make pluggable */
252 /* if (*iter++ != '.' || count > 32 || alflag == 0) { */ 248 if (*iter++ != '.' || count > 32 || alflag == 0) {
253 if (*iter++ != '.' || count > 32) {
254 ptr = iter; 249 ptr = iter;
255 length = 0; 250 length = 0;
256 continue; 251 continue;
257 } 252 }
258
259 /* two consecutive dots don't look correct */
260 if (*iter == '.') {
261 ptr = iter + 1;
262 length = 0;
263 continue;
264 }
265
266 if (FP_strnicmp (iter, "edu", 3) == 0 || 253 if (_FP_strnicmp (iter, "edu", 3) == 0 ||
267 FP_strnicmp (iter, "gov", 3) == 0) { 254 _FP_strnicmp (iter, "gov", 3) == 0) {
268 /* hey, that's an ftp address */ 255 /* hey, that's an ftp address */
269 while (isalpha (*iter) || isdigit (*iter) || *iter == '.') 256 while (isalpha (*iter) || isdigit (*iter) || *iter == '.')
270 iter++; 257 iter++;
271 ptr = iter; 258 ptr = iter;
272 length = 0; 259 length = 0;
438 } 425 }
439 426
440 while (iter[count] == ' ' || iter[count] == '#' || 427 while (iter[count] == ' ' || iter[count] == '#' ||
441 iter[count] == '/' || iter[count] == '\\') count++; 428 iter[count] == '/' || iter[count] == '\\') count++;
442 429
443 if (FP_strnicmp (iter + count, "of", 2) == 0) 430 if (_FP_strnicmp (iter + count, "of", 2) == 0)
444 count += 2; 431 count += 2;
445 432
446 while (iter[count] == ' ') count++; 433 while (iter[count] == ' ') count++;
447 while (isdigit (iter[count])) count++; 434 while (isdigit (iter[count])) count++;
448 while (iter[count] == ' ') count++; 435 while (iter[count] == ' ') count++;
464 /* 451 /*
465 * look for the string "part " followed by a number 452 * look for the string "part " followed by a number
466 */ 453 */
467 454
468 if (length == 0) { 455 if (length == 0) {
469 if ((iter = FP_stristr (subject, "part ")) != NULL) { 456 if ((iter = _FP_stristr (subject, "part ")) != NULL) {
470 iter += 5; 457 iter += 5;
471 458
472 while (isspace (*iter) || *iter == '.' || *iter == '-') 459 while (isspace (*iter) || *iter == '.' || *iter == '-')
473 iter++; 460 iter++;
474 461
475 while (isdigit (iter[length])) 462 while (isdigit (iter[length]))
476 length++; 463 length++;
477 464
478 if (length == 0) { 465 if (length == 0) {
479 if (FP_strnicmp (iter, "one", 3) == 0) length = 1; 466 if (_FP_strnicmp (iter, "one", 3) == 0) length = 1;
480 else if (FP_strnicmp (iter, "two", 3) == 0) length = 2; 467 else if (_FP_strnicmp (iter, "two", 3) == 0) length = 2;
481 else if (FP_strnicmp (iter, "three", 5) == 0) length = 3; 468 else if (_FP_strnicmp (iter, "three", 5) == 0) length = 3;
482 else if (FP_strnicmp (iter, "four", 4) == 0) length = 4; 469 else if (_FP_strnicmp (iter, "four", 4) == 0) length = 4;
483 else if (FP_strnicmp (iter, "five", 4) == 0) length = 5; 470 else if (_FP_strnicmp (iter, "five", 4) == 0) length = 5;
484 else if (FP_strnicmp (iter, "six", 3) == 0) length = 6; 471 else if (_FP_strnicmp (iter, "six", 3) == 0) length = 6;
485 else if (FP_strnicmp (iter, "seven", 5) == 0) length = 7; 472 else if (_FP_strnicmp (iter, "seven", 5) == 0) length = 7;
486 else if (FP_strnicmp (iter, "eight", 5) == 0) length = 8; 473 else if (_FP_strnicmp (iter, "eight", 5) == 0) length = 8;
487 else if (FP_strnicmp (iter, "nine", 4) == 0) length = 9; 474 else if (_FP_strnicmp (iter, "nine", 4) == 0) length = 9;
488 else if (FP_strnicmp (iter, "ten", 3) == 0) length = 10; 475 else if (_FP_strnicmp (iter, "ten", 3) == 0) length = 10;
489 476
490 if (length && (*whend = strchr (iter, ' '))) { 477 if (length && (*whend = strchr (iter, ' '))) {
491 *where = iter; 478 *where = iter;
492 return length; 479 return length;
493 } 480 }
504 /* 491 /*
505 * look for the string "part" followed by a number 492 * look for the string "part" followed by a number
506 */ 493 */
507 494
508 if (length == 0) { 495 if (length == 0) {
509 if ((iter = FP_stristr (subject, "part")) != NULL) { 496 if ((iter = _FP_stristr (subject, "part")) != NULL) {
510 iter += 4; 497 iter += 4;
511 498
512 while (isspace (*iter) || *iter == '.' || *iter == '-') 499 while (isspace (*iter) || *iter == '.' || *iter == '-')
513 iter++; 500 iter++;
514 501
515 while (isdigit (iter[length])) 502 while (isdigit (iter[length]))
516 length++; 503 length++;
517 504
518 if (length == 0) { 505 if (length == 0) {
519 if (FP_strnicmp (iter, "one", 3) == 0) length = 1; 506 if (_FP_strnicmp (iter, "one", 3) == 0) length = 1;
520 else if (FP_strnicmp (iter, "two", 3) == 0) length = 2; 507 else if (_FP_strnicmp (iter, "two", 3) == 0) length = 2;
521 else if (FP_strnicmp (iter, "three", 5) == 0) length = 3; 508 else if (_FP_strnicmp (iter, "three", 5) == 0) length = 3;
522 else if (FP_strnicmp (iter, "four", 4) == 0) length = 4; 509 else if (_FP_strnicmp (iter, "four", 4) == 0) length = 4;
523 else if (FP_strnicmp (iter, "five", 4) == 0) length = 5; 510 else if (_FP_strnicmp (iter, "five", 4) == 0) length = 5;
524 else if (FP_strnicmp (iter, "six", 3) == 0) length = 6; 511 else if (_FP_strnicmp (iter, "six", 3) == 0) length = 6;
525 else if (FP_strnicmp (iter, "seven", 5) == 0) length = 7; 512 else if (_FP_strnicmp (iter, "seven", 5) == 0) length = 7;
526 else if (FP_strnicmp (iter, "eight", 5) == 0) length = 8; 513 else if (_FP_strnicmp (iter, "eight", 5) == 0) length = 8;
527 else if (FP_strnicmp (iter, "nine", 4) == 0) length = 9; 514 else if (_FP_strnicmp (iter, "nine", 4) == 0) length = 9;
528 else if (FP_strnicmp (iter, "ten", 3) == 0) length = 10; 515 else if (_FP_strnicmp (iter, "ten", 3) == 0) length = 10;
529 516
530 if (length && (*whend = strchr (iter, ' '))) { 517 if (length && (*whend = strchr (iter, ' '))) {
531 *where = iter; 518 *where = iter;
532 return length; 519 return length;
533 } 520 }
544 /* 531 /*
545 * look for [0-9]* "of" [0-9]* 532 * look for [0-9]* "of" [0-9]*
546 */ 533 */
547 534
548 if (length == 0) { 535 if (length == 0) {
549 if ((iter = FP_strirstr (subject, "of")) != NULL) { 536 if ((iter = _FP_strirstr (subject, "of")) != NULL) {
550 while (iter>subject && isspace (*(iter-1))) 537 while (iter>subject && isspace (*(iter-1)))
551 iter--; 538 iter--;
552 if (isdigit(*(iter-1))) { 539 if (isdigit(*(iter-1))) {
553 while (iter>subject && isdigit (*(iter-1))) 540 while (iter>subject && isdigit (*(iter-1)))
554 iter--; 541 iter--;
643 630
644 if (length == 0) { 631 if (length == 0) {
645 /* 632 /*
646 * some people use the strangest things, including spelling mistakes :-) 633 * some people use the strangest things, including spelling mistakes :-)
647 */ 634 */
648 if ((iter = FP_stristr (subject, "first")) != NULL) length = 1; 635 if ((iter = _FP_stristr (subject, "first")) != NULL) length = 1;
649 else if ((iter = FP_stristr (subject, "second")) != NULL) length = 2; 636 else if ((iter = _FP_stristr (subject, "second")) != NULL) length = 2;
650 else if ((iter = FP_stristr (subject, "third")) != NULL) length = 3; 637 else if ((iter = _FP_stristr (subject, "third")) != NULL) length = 3;
651 else if ((iter = FP_stristr (subject, "forth")) != NULL) length = 4; 638 else if ((iter = _FP_stristr (subject, "forth")) != NULL) length = 4;
652 else if ((iter = FP_stristr (subject, "fourth")) != NULL) length = 4; 639 else if ((iter = _FP_stristr (subject, "fourth")) != NULL) length = 4;
653 else if ((iter = FP_stristr (subject, "fifth")) != NULL) length = 5; 640 else if ((iter = _FP_stristr (subject, "fifth")) != NULL) length = 5;
654 else if ((iter = FP_stristr (subject, "sixth")) != NULL) length = 6; 641 else if ((iter = _FP_stristr (subject, "sixth")) != NULL) length = 6;
655 else if ((iter = FP_stristr (subject, "seventh")) != NULL) length = 7; 642 else if ((iter = _FP_stristr (subject, "seventh")) != NULL) length = 7;
656 else if ((iter = FP_stristr (subject, "eigth")) != NULL) length = 8; 643 else if ((iter = _FP_stristr (subject, "eigth")) != NULL) length = 8;
657 else if ((iter = FP_stristr (subject, "eighth")) != NULL) length = 8;
658 else if ((iter = FP_stristr (subject, "nineth")) != NULL) length = 9; 644 else if ((iter = _FP_stristr (subject, "nineth")) != NULL) length = 9;
659 else if ((iter = FP_stristr (subject, "ninth")) != NULL) length = 9; 645 else if ((iter = _FP_stristr (subject, "ninth")) != NULL) length = 9;
660 else if ((iter = FP_stristr (subject, "tenth")) != NULL) length = 10; 646 else if ((iter = _FP_stristr (subject, "tenth")) != NULL) length = 10;
661 else iter = NULL; 647 else iter = NULL;
662 648
663 if (length && iter && (*whend = strchr (iter, ' '))) { 649 if (length && iter && (*whend = strchr (iter, ' '))) {
664 *where = iter; 650 *where = iter;
665 return length; 651 return length;
672 return -1; 658 return -1;
673 659
674 *where = iter; 660 *where = iter;
675 661
676 if (delim && delim[0]) { 662 if (delim && delim[0]) {
677 if ((*whend=FP_stristr (iter, delim)) != NULL && (*whend - *where) < 12) { 663 if ((*whend=_FP_stristr (iter, delim)) != NULL && (*whend - *where) < 12) {
678 ptr = (*whend += strlen (delim)); 664 ptr = (*whend += strlen (delim));
679 665
680 while (*ptr == ' ') 666 while (*ptr == ' ')
681 ptr++; 667 ptr++;
682 668
728 UUkillfile (result); 714 UUkillfile (result);
729 return NULL; 715 return NULL;
730 } 716 }
731 717
732 if (data->filename != NULL) { 718 if (data->filename != NULL) {
733 if ((result->filename = FP_strdup (data->filename)) == NULL) { 719 if ((result->filename = _FP_strdup (data->filename)) == NULL) {
734 UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, 720 UUMessage (uucheck_id, __LINE__, UUMSG_ERROR,
735 uustring (S_OUT_OF_MEMORY), 721 uustring (S_OUT_OF_MEMORY),
736 strlen (data->filename)+1); 722 strlen (data->filename)+1);
737 *ret = UURET_NOMEM; 723 *ret = UURET_NOMEM;
738 UUkillfile (result); 724 UUkillfile (result);
745 if (uu_dumbness <= 1) 731 if (uu_dumbness <= 1)
746 result->subfname = UUGetFileName (data->subject, where, whend); 732 result->subfname = UUGetFileName (data->subject, where, whend);
747 else 733 else
748 result->subfname = NULL; 734 result->subfname = NULL;
749 735
750 result->mimeid = FP_strdup (data->mimeid); 736 result->mimeid = _FP_strdup (data->mimeid);
751 result->mimetype = FP_strdup (data->mimetype); 737 result->mimetype = _FP_strdup (data->mimetype);
752 738
753 if (result->partno == -1 && 739 if (result->partno == -1 &&
754 (data->uudet == PT_ENCODED || data->uudet == QP_ENCODED)) 740 (data->uudet == PT_ENCODED || data->uudet == QP_ENCODED))
755 result->partno = 1; 741 result->partno = 1;
756 742
758 /* 744 /*
759 * Don't touch this part. But it should really have a filename 745 * Don't touch this part. But it should really have a filename
760 */ 746 */
761 if (result->filename == NULL) { 747 if (result->filename == NULL) {
762 sprintf (temp, "%s.%03d", nofname, ++nofnum); 748 sprintf (temp, "%s.%03d", nofname, ++nofnum);
763 result->filename = FP_strdup (temp); 749 result->filename = _FP_strdup (temp);
764 } 750 }
765 if (result->subfname == NULL) 751 if (result->subfname == NULL)
766 result->subfname = FP_strdup (result->filename); 752 result->subfname = _FP_strdup (result->filename);
767 753
768 if (result->filename == NULL || 754 if (result->filename == NULL ||
769 result->subfname == NULL) { 755 result->subfname == NULL) {
770 UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, 756 UUMessage (uucheck_id, __LINE__, UUMSG_ERROR,
771 uustring (S_OUT_OF_MEMORY), 757 uustring (S_OUT_OF_MEMORY),
788 */ 774 */
789 /* 775 /*
790 * in this case, it really _should_ have a filename somewhere 776 * in this case, it really _should_ have a filename somewhere
791 */ 777 */
792 if (result->filename != NULL) 778 if (result->filename != NULL)
793 result->subfname = FP_strdup (result->filename); 779 result->subfname = _FP_strdup (result->filename);
794 else { /* if not, escape to UNKNOWN. We need to fill subfname */ 780 else { /* if not, escape to UNKNOWN. We need to fill subfname */
795 sprintf (temp, "%s.%03d", nofname, ++nofnum); 781 sprintf (temp, "%s.%03d", nofname, ++nofnum);
796 result->subfname = FP_strdup (temp); 782 result->subfname = _FP_strdup (temp);
797 } 783 }
798 /* 784 /*
799 * in case the strdup failed 785 * in case the strdup failed
800 */ 786 */
801 if (result->subfname == NULL) { 787 if (result->subfname == NULL) {
816 * initialize lastvalid 802 * initialize lastvalid
817 */ 803 */
818 lastvalid = 1; 804 lastvalid = 1;
819 lastenc = data->uudet; 805 lastenc = data->uudet;
820 lastpart = result->partno = 1; 806 lastpart = result->partno = 1;
821 FP_strncpy (uucheck_lastname, result->subfname, 256); 807 _FP_strncpy (uucheck_lastname, result->subfname, 256);
822 } 808 }
823 else 809 else
824 result->partno = 1; 810 result->partno = 1;
825 } 811 }
826 else if (result->subfname == NULL && data->uudet && data->mimeid) { 812 else if (result->subfname == NULL && data->uudet && data->mimeid) {
828 * if it's got a file name, use it. Else use the mime-id for identifying 814 * if it's got a file name, use it. Else use the mime-id for identifying
829 * this part, and hope there's no other files encoded in the same message 815 * this part, and hope there's no other files encoded in the same message
830 * under the same id. 816 * under the same id.
831 */ 817 */
832 if (result->filename) 818 if (result->filename)
833 result->subfname = FP_strdup (result->filename); 819 result->subfname = _FP_strdup (result->filename);
834 else 820 else
835 result->subfname = FP_strdup (result->mimeid); 821 result->subfname = _FP_strdup (result->mimeid);
836 } 822 }
837 else if (result->subfname == NULL && data->uudet) { 823 else if (result->subfname == NULL && data->uudet) {
838 /* 824 /*
839 * ff we have lastvalid, use it. Make an exception for 825 * ff we have lastvalid, use it. Make an exception for
840 * Base64-encoded files. 826 * Base64-encoded files.
842 if (data->uudet == B64ENCODED) { 828 if (data->uudet == B64ENCODED) {
843 /* 829 /*
844 * Assume it's the first part. I wonder why it's got no part number? 830 * Assume it's the first part. I wonder why it's got no part number?
845 */ 831 */
846 if (result->filename != NULL) 832 if (result->filename != NULL)
847 result->subfname = FP_strdup (result->filename); 833 result->subfname = _FP_strdup (result->filename);
848 else { /* if not, escape to UNKNOWN. We need to fill subfname */ 834 else { /* if not, escape to UNKNOWN. We need to fill subfname */
849 sprintf (temp, "%s.%03d", nofname, ++nofnum); 835 sprintf (temp, "%s.%03d", nofname, ++nofnum);
850 result->subfname = FP_strdup (temp); 836 result->subfname = _FP_strdup (temp);
851 } 837 }
852 if (result->subfname == NULL) { 838 if (result->subfname == NULL) {
853 UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, 839 UUMessage (uucheck_id, __LINE__, UUMSG_ERROR,
854 uustring (S_OUT_OF_MEMORY), 840 uustring (S_OUT_OF_MEMORY),
855 (result->filename)? 841 (result->filename)?
858 UUkillfile (result); 844 UUkillfile (result);
859 return NULL; 845 return NULL;
860 } 846 }
861 lastvalid = 0; 847 lastvalid = 0;
862 } 848 }
863 else if (lastvalid && data->uudet == lastenc) { 849 else if (lastvalid && data->uudet == lastenc && result->partno == -1) {
864 result->subfname = FP_strdup (uucheck_lastname); 850 result->subfname = _FP_strdup (uucheck_lastname);
865 result->partno = ++lastpart; 851 result->partno = ++lastpart;
866 852
867 /* 853 /*
868 * if it's the last part, invalidate lastvalid 854 * if it's the last part, invalidate lastvalid
869 */ 855 */
870 if (data->end || (data->partno && data->partno == data->maxpno)) 856 if (data->end || (data->partno && data->partno == data->maxpno))
871 lastvalid = 0; 857 lastvalid = 0;
858 }
859 else if (data->partno != -1 && result->filename) {
860 result->subfname = _FP_strdup (result->filename);
872 } 861 }
873 else { 862 else {
874 /* 863 /*
875 * it's got no info, it's got no begin, and we don't know anything 864 * it's got no info, it's got no begin, and we don't know anything
876 * about this part. Let's forget all about it. 865 * about this part. Let's forget all about it.
909 /* 898 /*
910 * hmm, this is reason enough to initialize lastvalid, at least 899 * hmm, this is reason enough to initialize lastvalid, at least
911 * if we have no end 900 * if we have no end
912 */ 901 */
913 if (!data->end) { 902 if (!data->end) {
914 FP_strncpy (uucheck_lastname, result->subfname, 256); 903 _FP_strncpy (uucheck_lastname, result->subfname, 256);
915 result->partno = lastpart = 1; 904 result->partno = lastpart = 1;
916 lastenc = data->uudet; 905 lastenc = data->uudet;
917 lastvalid = 1; 906 lastvalid = 1;
918 } 907 }
919 else 908 else
920 result->partno = 1; 909 result->partno = 1;
921 } 910 }
922 else if (result->partno == -1 && data->uudet) { 911 else if (result->partno == -1 && data->uudet) {
923 if (lastvalid && FP_stricmp (uucheck_lastname, result->subfname) == 0) { 912 if (lastvalid && _FP_stricmp (uucheck_lastname, result->subfname) == 0) {
924 /* 913 /*
925 * if the subject filename is the same as last time, use part no 914 * if the subject filename is the same as last time, use part no
926 * of lastvalid. If at end, invalidate lastvalid 915 * of lastvalid. If at end, invalidate lastvalid
927 */ 916 */
928 result->partno = ++lastpart; 917 result->partno = ++lastpart;
958 } 947 }
959 948
960 skipcheck: 949 skipcheck:
961 950
962 if (result->filename) { 951 if (result->filename) {
963 if (*(ptr = FP_cutdir (result->filename))) { 952 if (*(ptr = _FP_cutdir (result->filename))) {
964 p2 = FP_strdup (ptr); 953 p2 = _FP_strdup (ptr);
965 FP_free (result->filename); 954 _FP_free (result->filename);
966 result->filename = p2; 955 result->filename = p2;
967 } 956 }
968 } 957 }
969 958
970 result->data = data; 959 result->data = data;
1003 992
1004 while (iter) { 993 while (iter) {
1005 if (data->data->flags & FL_SINGLE) { 994 if (data->data->flags & FL_SINGLE) {
1006 /* this space intentionally left blank */ 995 /* this space intentionally left blank */
1007 } 996 }
1008 else if ((FP_stricmp (data->subfname, iter->subfname) == 0 || 997 else if ((_FP_stricmp (data->subfname, iter->subfname) == 0 ||
1009 (data->mimeid && iter->mimeid && 998 (data->mimeid && iter->mimeid &&
1010 strcmp (data->mimeid, iter->mimeid) == 0)) && 999 strcmp (data->mimeid, iter->mimeid) == 0)) &&
1011 !(iter->begin && data->data->begin) && 1000 !(iter->begin && data->data->begin) &&
1012 !(iter->end && data->data->end) && 1001 !(iter->end && data->data->end) &&
1013 !(data->mimeid && iter->mimeid && 1002 !(data->mimeid && iter->mimeid &&
1028 (data->partno==fiter->partno || 1017 (data->partno==fiter->partno ||
1029 (data->partno > fiter->partno && fiter->data->end))) 1018 (data->partno > fiter->partno && fiter->data->end)))
1030 goto goahead; 1019 goto goahead;
1031 1020
1032 if (iter->filename == NULL && data->filename != NULL) { 1021 if (iter->filename == NULL && data->filename != NULL) {
1033 if ((iter->filename = FP_strdup (data->filename)) == NULL) 1022 if ((iter->filename = _FP_strdup (data->filename)) == NULL)
1034 return UURET_NOMEM; 1023 return UURET_NOMEM;
1035 } 1024 }
1036 1025
1037 /* 1026 /*
1038 * special case when we might have tagged a part as Base64 when the 1027 * special case when we might have tagged a part as Base64 when the
1073 iter->mode = data->data->mode; 1062 iter->mode = data->data->mode;
1074 if (data->data->begin) iter->begin = (data->partno)?data->partno:1; 1063 if (data->data->begin) iter->begin = (data->partno)?data->partno:1;
1075 if (data->data->end) iter->end = (data->partno)?data->partno:1; 1064 if (data->data->end) iter->end = (data->partno)?data->partno:1;
1076 1065
1077 if (data->mimetype) { 1066 if (data->mimetype) {
1078 FP_free (iter->mimetype); 1067 _FP_free (iter->mimetype);
1079 iter->mimetype = FP_strdup (data->mimetype); 1068 iter->mimetype = _FP_strdup (data->mimetype);
1080 } 1069 }
1081 1070
1082 /* 1071 /*
1083 * insert part at the beginning 1072 * insert part at the beginning
1084 */ 1073 */
1103 * if we find the same part no again, check which one looks better 1092 * if we find the same part no again, check which one looks better
1104 */ 1093 */
1105 if (data->partno == fiter->partno) { 1094 if (data->partno == fiter->partno) {
1106 if (fiter->data->subject == NULL) 1095 if (fiter->data->subject == NULL)
1107 return UURET_NODATA; 1096 return UURET_NODATA;
1108 else if (FP_stristr (fiter->data->subject, "repost") != NULL && 1097 else if (_FP_stristr (fiter->data->subject, "repost") != NULL &&
1109 FP_stristr (data->data->subject, "repost") == NULL) 1098 _FP_stristr (data->data->subject, "repost") == NULL)
1110 return UURET_NODATA; 1099 return UURET_NODATA;
1111 else if (fiter->data->uudet && !data->data->uudet) 1100 else if (fiter->data->uudet && !data->data->uudet)
1112 return UURET_NODATA; 1101 return UURET_NODATA;
1113 else { 1102 else {
1114 /* 1103 /*
1175 1164
1176 if ((unew = (uulist *) malloc (sizeof (uulist))) == NULL) { 1165 if ((unew = (uulist *) malloc (sizeof (uulist))) == NULL) {
1177 return UURET_NOMEM; 1166 return UURET_NOMEM;
1178 } 1167 }
1179 1168
1180 if ((unew->subfname = FP_strdup (data->subfname)) == NULL) { 1169 if ((unew->subfname = _FP_strdup (data->subfname)) == NULL) {
1181 FP_free (unew); 1170 _FP_free (unew);
1182 return UURET_NOMEM; 1171 return UURET_NOMEM;
1183 } 1172 }
1184 1173
1185 if (data->filename != NULL) { 1174 if (data->filename != NULL) {
1186 if ((unew->filename = FP_strdup (data->filename)) == NULL) { 1175 if ((unew->filename = _FP_strdup (data->filename)) == NULL) {
1187 FP_free (unew->subfname); 1176 _FP_free (unew->subfname);
1188 FP_free (unew); 1177 _FP_free (unew);
1189 return UURET_NOMEM; 1178 return UURET_NOMEM;
1190 } 1179 }
1191 } 1180 }
1192 else 1181 else
1193 unew->filename = NULL; 1182 unew->filename = NULL;
1194 1183
1195 if (data->mimeid != NULL) { 1184 if (data->mimeid != NULL) {
1196 if ((unew->mimeid = FP_strdup (data->mimeid)) == NULL) { 1185 if ((unew->mimeid = _FP_strdup (data->mimeid)) == NULL) {
1197 FP_free (unew->subfname); 1186 _FP_free (unew->subfname);
1198 FP_free (unew->filename); 1187 _FP_free (unew->filename);
1199 FP_free (unew); 1188 _FP_free (unew);
1200 return UURET_NOMEM; 1189 return UURET_NOMEM;
1201 } 1190 }
1202 } 1191 }
1203 else 1192 else
1204 unew->mimeid = NULL; 1193 unew->mimeid = NULL;
1205 1194
1206 if (data->mimetype != NULL) { 1195 if (data->mimetype != NULL) {
1207 if ((unew->mimetype = FP_strdup (data->mimetype)) == NULL) { 1196 if ((unew->mimetype = _FP_strdup (data->mimetype)) == NULL) {
1208 FP_free (unew->mimeid); 1197 _FP_free (unew->mimeid);
1209 FP_free (unew->subfname); 1198 _FP_free (unew->subfname);
1210 FP_free (unew->filename); 1199 _FP_free (unew->filename);
1211 FP_free (unew); 1200 _FP_free (unew);
1212 return UURET_NOMEM; 1201 return UURET_NOMEM;
1213 } 1202 }
1214 } 1203 }
1215 else 1204 else
1216 unew->mimetype = NULL; 1205 unew->mimetype = NULL;
1400 1389
1401 /* 1390 /*
1402 * Set the parts we have and/or missing 1391 * Set the parts we have and/or missing
1403 */ 1392 */
1404 1393
1405 FP_free (liter->haveparts); 1394 _FP_free (liter->haveparts);
1406 FP_free (liter->misparts); 1395 _FP_free (liter->misparts);
1407 1396
1408 liter->haveparts = NULL; 1397 liter->haveparts = NULL;
1409 liter->misparts = NULL; 1398 liter->misparts = NULL;
1410 1399
1411 if (havecount) { 1400 if (havecount) {
1443 if (liter->state==UUFILE_OK && 1432 if (liter->state==UUFILE_OK &&
1444 (liter->filename==NULL || liter->filename[0]=='\0')) { 1433 (liter->filename==NULL || liter->filename[0]=='\0')) {
1445 /* 1434 /*
1446 * Emergency backup if the file does not have a filename 1435 * Emergency backup if the file does not have a filename
1447 */ 1436 */
1448 FP_free (liter->filename); 1437 _FP_free (liter->filename);
1449 if (liter->subfname && liter->subfname[0] && 1438 if (liter->subfname && liter->subfname[0] &&
1450 FP_strpbrk (liter->subfname, "()[];: ") == NULL) 1439 _FP_strpbrk (liter->subfname, "()[];: ") == NULL)
1451 liter->filename = FP_strdup (liter->subfname); 1440 liter->filename = _FP_strdup (liter->subfname);
1452 else { 1441 else {
1453 sprintf (uucheck_tempname, "%s.%03d", nofname, ++nofnum); 1442 sprintf (uucheck_tempname, "%s.%03d", nofname, ++nofnum);
1454 liter->filename = FP_strdup (uucheck_tempname); 1443 liter->filename = _FP_strdup (uucheck_tempname);
1455 } 1444 }
1456 } 1445 }
1457 liter = liter->NEXT; 1446 liter = liter->NEXT;
1458 } 1447 }
1459 1448

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines