… | |
… | |
34 | #include <stdio.h> |
34 | #include <stdio.h> |
35 | #include <ctype.h> |
35 | #include <ctype.h> |
36 | #include <stdlib.h> |
36 | #include <stdlib.h> |
37 | #include <string.h> |
37 | #include <string.h> |
38 | |
38 | |
39 | #ifdef HAVE_MALLOC_H |
|
|
40 | #include <malloc.h> |
|
|
41 | #endif |
|
|
42 | #ifdef HAVE_UNISTD_H |
39 | #ifdef HAVE_UNISTD_H |
43 | #include <unistd.h> |
40 | #include <unistd.h> |
44 | #endif |
|
|
45 | #ifdef HAVE_MEMORY_H |
|
|
46 | #include <memory.h> |
|
|
47 | #endif |
41 | #endif |
48 | |
42 | |
49 | #include <uudeview.h> |
43 | #include <uudeview.h> |
50 | #include <uuint.h> |
44 | #include <uuint.h> |
51 | #include <fptools.h> |
45 | #include <fptools.h> |
… | |
… | |
353 | ptr = nofname; |
347 | ptr = nofname; |
354 | length = strlen (nofname); |
348 | length = strlen (nofname); |
355 | } |
349 | } |
356 | |
350 | |
357 | if ((result = (char *) malloc (length + 1)) == NULL) { |
351 | if ((result = (char *) malloc (length + 1)) == NULL) { |
358 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
352 | UUMessage (UUMSG_ERROR, uustring (S_OUT_OF_MEMORY), length+1); |
359 | uustring (S_OUT_OF_MEMORY), length+1); |
|
|
360 | return NULL; |
353 | return NULL; |
361 | } |
354 | } |
362 | |
355 | |
363 | memcpy (result, ptr, length); |
356 | memcpy (result, ptr, length); |
364 | result[length] = '\0'; |
357 | result[length] = '\0'; |
… | |
… | |
708 | { |
701 | { |
709 | char *where, *whend, temp[80], *ptr, *p2; |
702 | char *where, *whend, temp[80], *ptr, *p2; |
710 | uufile *result; |
703 | uufile *result; |
711 | |
704 | |
712 | if ((result = (uufile *) malloc (sizeof (uufile))) == NULL) { |
705 | if ((result = (uufile *) malloc (sizeof (uufile))) == NULL) { |
713 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
706 | UUMessage (UUMSG_ERROR, uustring (S_OUT_OF_MEMORY), sizeof (uufile)); |
714 | uustring (S_OUT_OF_MEMORY), sizeof (uufile)); |
|
|
715 | *ret = UURET_NOMEM; |
707 | *ret = UURET_NOMEM; |
716 | return NULL; |
708 | return NULL; |
717 | } |
709 | } |
718 | memset (result, 0, sizeof (uufile)); |
710 | memset (result, 0, sizeof (uufile)); |
719 | |
711 | |
… | |
… | |
731 | return NULL; |
723 | return NULL; |
732 | } |
724 | } |
733 | |
725 | |
734 | if (data->filename != NULL) { |
726 | if (data->filename != NULL) { |
735 | if ((result->filename = FP_strdup (data->filename)) == NULL) { |
727 | if ((result->filename = FP_strdup (data->filename)) == NULL) { |
736 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
728 | UUMessage (UUMSG_ERROR, uustring (S_OUT_OF_MEMORY), strlen (data->filename)+1); |
737 | uustring (S_OUT_OF_MEMORY), |
|
|
738 | strlen (data->filename)+1); |
|
|
739 | *ret = UURET_NOMEM; |
729 | *ret = UURET_NOMEM; |
740 | UUkillfile (result); |
730 | UUkillfile (result); |
741 | return NULL; |
731 | return NULL; |
742 | } |
732 | } |
743 | } |
733 | } |
… | |
… | |
770 | if (result->subfname == NULL) |
760 | if (result->subfname == NULL) |
771 | result->subfname = FP_strdup (result->filename); |
761 | result->subfname = FP_strdup (result->filename); |
772 | |
762 | |
773 | if (result->filename == NULL || |
763 | if (result->filename == NULL || |
774 | result->subfname == NULL) { |
764 | result->subfname == NULL) { |
775 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
765 | UUMessage (UUMSG_ERROR, |
776 | uustring (S_OUT_OF_MEMORY), |
766 | uustring (S_OUT_OF_MEMORY), |
777 | (result->filename==NULL)? |
767 | (result->filename==NULL)? |
778 | (strlen(temp)+1):(strlen(result->filename)+1)); |
768 | (strlen(temp)+1):(strlen(result->filename)+1)); |
779 | *ret = UURET_NOMEM; |
769 | *ret = UURET_NOMEM; |
780 | UUkillfile(result); |
770 | UUkillfile(result); |
… | |
… | |
802 | } |
792 | } |
803 | /* |
793 | /* |
804 | * in case the strdup failed |
794 | * in case the strdup failed |
805 | */ |
795 | */ |
806 | if (result->subfname == NULL) { |
796 | if (result->subfname == NULL) { |
807 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
797 | UUMessage (UUMSG_ERROR, |
808 | uustring (S_OUT_OF_MEMORY), |
798 | uustring (S_OUT_OF_MEMORY), |
809 | (result->filename)? |
799 | (result->filename)? |
810 | (strlen(result->filename)+1):(strlen(temp)+1)); |
800 | (strlen(result->filename)+1):(strlen(temp)+1)); |
811 | *ret = UURET_NOMEM; |
801 | *ret = UURET_NOMEM; |
812 | UUkillfile (result); |
802 | UUkillfile (result); |
… | |
… | |
853 | else { /* if not, escape to UNKNOWN. We need to fill subfname */ |
843 | else { /* if not, escape to UNKNOWN. We need to fill subfname */ |
854 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
844 | sprintf (temp, "%s.%03d", nofname, ++nofnum); |
855 | result->subfname = FP_strdup (temp); |
845 | result->subfname = FP_strdup (temp); |
856 | } |
846 | } |
857 | if (result->subfname == NULL) { |
847 | if (result->subfname == NULL) { |
858 | UUMessage (uucheck_id, __LINE__, UUMSG_ERROR, |
848 | UUMessage (UUMSG_ERROR, |
859 | uustring (S_OUT_OF_MEMORY), |
849 | uustring (S_OUT_OF_MEMORY), |
860 | (result->filename)? |
850 | (result->filename)? |
861 | (strlen(result->filename)+1):(strlen(temp)+1)); |
851 | (strlen(result->filename)+1):(strlen(temp)+1)); |
862 | *ret = UURET_NOMEM; |
852 | *ret = UURET_NOMEM; |
863 | UUkillfile (result); |
853 | UUkillfile (result); |