… | |
… | |
79 | #include <uudeview.h> |
79 | #include <uudeview.h> |
80 | #include <uuint.h> |
80 | #include <uuint.h> |
81 | #include <fptools.h> |
81 | #include <fptools.h> |
82 | #include <uustring.h> |
82 | #include <uustring.h> |
83 | |
83 | |
84 | char * uulib_id = "$Id: uulib.c,v 1.4 2001/06/12 09:56:11 root Exp $"; |
84 | char * uulib_id = "$Id: uulib.c,v 1.4.2.2 2002/03/31 19:52:07 root Exp $"; |
85 | |
85 | |
86 | #ifdef SYSTEM_WINDLL |
86 | #ifdef SYSTEM_WINDLL |
87 | BOOL _export WINAPI |
87 | BOOL _export WINAPI |
88 | DllEntryPoint (HINSTANCE hInstance, DWORD seginfo, |
88 | DllEntryPoint (HINSTANCE hInstance, DWORD seginfo, |
89 | LPVOID lpCmdLine) |
89 | LPVOID lpCmdLine) |
… | |
… | |
112 | |
112 | |
113 | /* |
113 | /* |
114 | * Callback functions and their opaque arguments |
114 | * Callback functions and their opaque arguments |
115 | */ |
115 | */ |
116 | |
116 | |
117 | void (*uu_MsgCallback) (void *, char *, int) = NULL; |
117 | void (*uu_MsgCallback) _ANSI_ARGS_((void *, char *, int)) = NULL; |
118 | int (*uu_BusyCallback) (void *, uuprogress *) = NULL; |
118 | int (*uu_BusyCallback) _ANSI_ARGS_((void *, uuprogress *)) = NULL; |
119 | int (*uu_FileCallback) (void *, char *, char *, int) = NULL; |
119 | int (*uu_FileCallback) _ANSI_ARGS_((void *, char *, char *, int)) = NULL; |
120 | char * (*uu_FNameFilter) (void *, char *) = NULL; |
120 | char * (*uu_FNameFilter) _ANSI_ARGS_((void *, char *)) = NULL; |
121 | |
121 | |
122 | void *uu_MsgCBArg = NULL; |
122 | void *uu_MsgCBArg = NULL; |
123 | void *uu_BusyCBArg = NULL; |
123 | void *uu_BusyCBArg = NULL; |
124 | void *uu_FileCBArg = NULL; |
124 | void *uu_FileCBArg = NULL; |
125 | void *uu_FFCBArg = NULL; |
125 | void *uu_FFCBArg = NULL; |
… | |
… | |
231 | { &uucheck_lastname, 256 }, /* from uucheck.c */ |
231 | { &uucheck_lastname, 256 }, /* from uucheck.c */ |
232 | { &uucheck_tempname, 256 }, |
232 | { &uucheck_tempname, 256 }, |
233 | { &uuestr_itemp, 256 }, /* from uuencode.c:UUEncodeStream() */ |
233 | { &uuestr_itemp, 256 }, /* from uuencode.c:UUEncodeStream() */ |
234 | { &uuestr_otemp, 1024 }, |
234 | { &uuestr_otemp, 1024 }, |
235 | { &uulib_msgstring, 1024 }, /* from uulib.c:UUMessage() */ |
235 | { &uulib_msgstring, 1024 }, /* from uulib.c:UUMessage() */ |
236 | { &uuncdl_fulline, 256+4 }, /* from uunconc.c:UUDecodeLine(). +4 is for leftover parts */ |
236 | { &uuncdl_fulline, 300 }, /* from uunconc.c:UUDecodeLine() */ |
237 | { &uuncdp_oline, 4*257 }, /* from uunconc.c:UUDecodePart() */ |
237 | { &uuncdp_oline, 1200 }, /* from uunconc.c:UUDecodePart() */ |
238 | { &uunconc_UUxlat, 256 * sizeof (int) }, /* from uunconc.c:toplevel */ |
238 | { &uunconc_UUxlat, 256 * sizeof (int) }, /* from uunconc.c:toplevel */ |
239 | { &uunconc_UUxlen, 64 * sizeof (int) }, |
239 | { &uunconc_UUxlen, 64 * sizeof (int) }, |
240 | { &uunconc_B64xlat, 256 * sizeof (int) }, |
240 | { &uunconc_B64xlat, 256 * sizeof (int) }, |
241 | { &uunconc_XXxlat, 256 * sizeof (int) }, |
241 | { &uunconc_XXxlat, 256 * sizeof (int) }, |
242 | { &uunconc_BHxlat, 256 * sizeof (int) }, |
242 | { &uunconc_BHxlat, 256 * sizeof (int) }, |
243 | { &uunconc_save, 3*256 }, /* from uunconc.c:decoding buffer */ |
243 | { &uunconc_save, 3*300 }, /* from uunconc.c:decoding buffer */ |
244 | { &uuscan_shlline, 1024 }, /* from uuscan.c:ScanHeaderLine() */ |
244 | { &uuscan_shlline, 1024 }, /* from uuscan.c:ScanHeaderLine() */ |
245 | { &uuscan_pvvalue, 256 }, /* from uuscan.c:ParseValue() */ |
245 | { &uuscan_pvvalue, 300 }, /* from uuscan.c:ParseValue() */ |
246 | { &uuscan_phtext, 256 }, /* from uuscan.c:ParseHeader() */ |
246 | { &uuscan_phtext, 300 }, /* from uuscan.c:ParseHeader() */ |
247 | { &uuscan_sdline, 256 }, /* from uuscan.c:ScanData() */ |
247 | { &uuscan_sdline, 300 }, /* from uuscan.c:ScanData() */ |
248 | { &uuscan_sdbhds1, 256 }, |
248 | { &uuscan_sdbhds1, 300 }, |
249 | { &uuscan_sdbhds2, 256 }, |
249 | { &uuscan_sdbhds2, 300 }, |
250 | { &uuscan_spline, 256 }, /* from uuscan.c:ScanPart() */ |
250 | { &uuscan_spline, 300 }, /* from uuscan.c:ScanPart() */ |
251 | { &uuutil_bhwtmp, 256 }, /* from uuutil.c:UUbhwrite() */ |
251 | { &uuutil_bhwtmp, 300 }, /* from uuutil.c:UUbhwrite() */ |
252 | { NULL, 0 } |
252 | { NULL, 0 } |
253 | }; |
253 | }; |
254 | |
254 | |
255 | /* |
255 | /* |
256 | * Handle the printing of messages. Works like printf. |
256 | * Handle the printing of messages. Works like printf. |
… | |
… | |
390 | /* |
390 | /* |
391 | * oops. we may not print a message here, because we need these |
391 | * oops. we may not print a message here, because we need these |
392 | * areas (uulib_msgstring) in UUMessage() |
392 | * areas (uulib_msgstring) in UUMessage() |
393 | */ |
393 | */ |
394 | for (aiter=toallocate; aiter->ptr; aiter++) { |
394 | for (aiter=toallocate; aiter->ptr; aiter++) { |
395 | FP_free (*(aiter->ptr)); |
395 | _FP_free (*(aiter->ptr)); |
396 | } |
396 | } |
397 | return UURET_NOMEM; |
397 | return UURET_NOMEM; |
398 | } |
398 | } |
399 | } |
399 | } |
400 | |
400 | |
… | |
… | |
416 | { |
416 | { |
417 | int result; |
417 | int result; |
418 | |
418 | |
419 | switch (option) { |
419 | switch (option) { |
420 | case UUOPT_VERSION: |
420 | case UUOPT_VERSION: |
421 | FP_strncpy (cvalue, uulibversion, clength); |
421 | _FP_strncpy (cvalue, uulibversion, clength); |
422 | result = 0; |
422 | result = 0; |
423 | break; |
423 | break; |
424 | case UUOPT_FAST: |
424 | case UUOPT_FAST: |
425 | if (ivalue) *ivalue = uu_fast_scanning; |
425 | if (ivalue) *ivalue = uu_fast_scanning; |
426 | result = uu_fast_scanning; |
426 | result = uu_fast_scanning; |
… | |
… | |
456 | case UUOPT_OVERWRITE: |
456 | case UUOPT_OVERWRITE: |
457 | if (ivalue) *ivalue = uu_overwrite; |
457 | if (ivalue) *ivalue = uu_overwrite; |
458 | result = uu_overwrite; |
458 | result = uu_overwrite; |
459 | break; |
459 | break; |
460 | case UUOPT_SAVEPATH: |
460 | case UUOPT_SAVEPATH: |
461 | FP_strncpy (cvalue, uusavepath, clength); |
461 | _FP_strncpy (cvalue, uusavepath, clength); |
462 | result = 0; |
462 | result = 0; |
463 | break; |
463 | break; |
464 | case UUOPT_PROGRESS: |
464 | case UUOPT_PROGRESS: |
465 | if (clength==sizeof(uuprogress)) { |
465 | if (clength==sizeof(uuprogress)) { |
466 | memcpy (cvalue, &progress, sizeof (uuprogress)); |
466 | memcpy (cvalue, &progress, sizeof (uuprogress)); |
… | |
… | |
484 | case UUOPT_TINYB64: |
484 | case UUOPT_TINYB64: |
485 | if (ivalue) *ivalue = uu_tinyb64; |
485 | if (ivalue) *ivalue = uu_tinyb64; |
486 | result = uu_tinyb64; |
486 | result = uu_tinyb64; |
487 | break; |
487 | break; |
488 | case UUOPT_ENCEXT: |
488 | case UUOPT_ENCEXT: |
489 | FP_strncpy (cvalue, uuencodeext, clength); |
489 | _FP_strncpy (cvalue, uuencodeext, clength); |
490 | result = 0; |
490 | result = 0; |
491 | break; |
491 | break; |
492 | case UUOPT_REMOVE: |
492 | case UUOPT_REMOVE: |
493 | if (ivalue) *ivalue = uu_remove_input; |
493 | if (ivalue) *ivalue = uu_remove_input; |
494 | result = uu_remove_input; |
494 | result = uu_remove_input; |
… | |
… | |
530 | break; |
530 | break; |
531 | case UUOPT_OVERWRITE: |
531 | case UUOPT_OVERWRITE: |
532 | uu_overwrite = ivalue; |
532 | uu_overwrite = ivalue; |
533 | break; |
533 | break; |
534 | case UUOPT_SAVEPATH: |
534 | case UUOPT_SAVEPATH: |
535 | FP_free (uusavepath); |
535 | _FP_free (uusavepath); |
536 | uusavepath = FP_strdup (cvalue); |
536 | uusavepath = _FP_strdup (cvalue); |
537 | break; |
537 | break; |
538 | case UUOPT_IGNMODE: |
538 | case UUOPT_IGNMODE: |
539 | uu_ignmode = ivalue; |
539 | uu_ignmode = ivalue; |
540 | break; |
540 | break; |
541 | case UUOPT_USETEXT: |
541 | case UUOPT_USETEXT: |
… | |
… | |
546 | break; |
546 | break; |
547 | case UUOPT_TINYB64: |
547 | case UUOPT_TINYB64: |
548 | uu_tinyb64 = ivalue; |
548 | uu_tinyb64 = ivalue; |
549 | break; |
549 | break; |
550 | case UUOPT_ENCEXT: |
550 | case UUOPT_ENCEXT: |
551 | FP_free (uuencodeext); |
551 | _FP_free (uuencodeext); |
552 | uuencodeext = FP_strdup (cvalue); |
552 | uuencodeext = _FP_strdup (cvalue); |
553 | break; |
553 | break; |
554 | case UUOPT_REMOVE: |
554 | case UUOPT_REMOVE: |
555 | uu_remove_input = ivalue; |
555 | uu_remove_input = ivalue; |
556 | break; |
556 | break; |
557 | case UUOPT_MOREMIME: |
557 | case UUOPT_MOREMIME: |
… | |
… | |
573 | * Set the various Callback functions |
573 | * Set the various Callback functions |
574 | */ |
574 | */ |
575 | |
575 | |
576 | int UUEXPORT |
576 | int UUEXPORT |
577 | UUSetMsgCallback (void *opaque, |
577 | UUSetMsgCallback (void *opaque, |
578 | void (*func) (void *, char *, int)) |
578 | void (*func) _ANSI_ARGS_((void *, char *, int))) |
579 | { |
579 | { |
580 | uu_MsgCallback = func; |
580 | uu_MsgCallback = func; |
581 | uu_MsgCBArg = opaque; |
581 | uu_MsgCBArg = opaque; |
582 | |
582 | |
583 | return UURET_OK; |
583 | return UURET_OK; |
584 | } |
584 | } |
585 | |
585 | |
586 | int UUEXPORT |
586 | int UUEXPORT |
587 | UUSetBusyCallback (void *opaque, |
587 | UUSetBusyCallback (void *opaque, |
588 | int (*func) (void *, uuprogress *), |
588 | int (*func) _ANSI_ARGS_((void *, uuprogress *)), |
589 | long msecs) |
589 | long msecs) |
590 | { |
590 | { |
591 | uu_BusyCallback = func; |
591 | uu_BusyCallback = func; |
592 | uu_BusyCBArg = opaque; |
592 | uu_BusyCBArg = opaque; |
593 | uu_busy_msecs = msecs; |
593 | uu_busy_msecs = msecs; |
… | |
… | |
595 | return UURET_OK; |
595 | return UURET_OK; |
596 | } |
596 | } |
597 | |
597 | |
598 | int UUEXPORT |
598 | int UUEXPORT |
599 | UUSetFileCallback (void *opaque, |
599 | UUSetFileCallback (void *opaque, |
600 | int (*func) (void *, char *, char *, int)) |
600 | int (*func) _ANSI_ARGS_((void *, char *, char *, int))) |
601 | { |
601 | { |
602 | uu_FileCallback = func; |
602 | uu_FileCallback = func; |
603 | uu_FileCBArg = opaque; |
603 | uu_FileCBArg = opaque; |
604 | |
604 | |
605 | return UURET_OK; |
605 | return UURET_OK; |
606 | } |
606 | } |
607 | |
607 | |
608 | int UUEXPORT |
608 | int UUEXPORT |
609 | UUSetFNameFilter (void *opaque, |
609 | UUSetFNameFilter (void *opaque, |
610 | char * (*func) (void *, char *)) |
610 | char * (*func) _ANSI_ARGS_((void *, char *))) |
611 | { |
611 | { |
612 | uu_FNameFilter = func; |
612 | uu_FNameFilter = func; |
613 | uu_FFCBArg = opaque; |
613 | uu_FFCBArg = opaque; |
614 | |
614 | |
615 | return UURET_OK; |
615 | return UURET_OK; |
… | |
… | |
651 | * Load a File. We call ScanPart repeatedly until at EOF and |
651 | * Load a File. We call ScanPart repeatedly until at EOF and |
652 | * add the parts to UUGlobalFileList |
652 | * add the parts to UUGlobalFileList |
653 | */ |
653 | */ |
654 | |
654 | |
655 | int UUEXPORT |
655 | int UUEXPORT |
656 | UULoadFile (char *filename, char *fileid, int delflag, int *partcount) |
656 | UULoadFile (char *filename, char *fileid, int delflag) |
657 | { |
657 | { |
658 | int res, sr; |
658 | int res, sr, count=0; |
659 | struct stat finfo; |
659 | struct stat finfo; |
660 | fileread *loaded; |
660 | fileread *loaded; |
661 | uufile *fload; |
661 | uufile *fload; |
662 | itbd *killem; |
662 | itbd *killem; |
663 | FILE *datei; |
663 | FILE *datei; |
664 | |
|
|
665 | int _count; |
|
|
666 | if (!partcount) |
|
|
667 | partcount = &_count; |
|
|
668 | |
|
|
669 | *partcount = 0; |
|
|
670 | |
664 | |
671 | if ((datei = fopen (filename, "rb")) == NULL) { |
665 | if ((datei = fopen (filename, "rb")) == NULL) { |
672 | UUMessage (uulib_id, __LINE__, UUMSG_ERROR, |
666 | UUMessage (uulib_id, __LINE__, UUMSG_ERROR, |
673 | uustring (S_NOT_OPEN_SOURCE), |
667 | uustring (S_NOT_OPEN_SOURCE), |
674 | filename, strerror (uu_errno = errno)); |
668 | filename, strerror (uu_errno = errno)); |
… | |
… | |
690 | if (delflag && fileid==NULL) { |
684 | if (delflag && fileid==NULL) { |
691 | if ((killem = (itbd *) malloc (sizeof (itbd))) == NULL) { |
685 | if ((killem = (itbd *) malloc (sizeof (itbd))) == NULL) { |
692 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
686 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
693 | uustring (S_OUT_OF_MEMORY), sizeof (itbd)); |
687 | uustring (S_OUT_OF_MEMORY), sizeof (itbd)); |
694 | } |
688 | } |
695 | else if ((killem->fname = FP_strdup (filename)) == NULL) { |
689 | else if ((killem->fname = _FP_strdup (filename)) == NULL) { |
696 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
690 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
697 | uustring (S_OUT_OF_MEMORY), strlen(filename)+1); |
691 | uustring (S_OUT_OF_MEMORY), strlen(filename)+1); |
698 | FP_free (killem); |
692 | _FP_free (killem); |
699 | } |
693 | } |
700 | else { |
694 | else { |
701 | killem->NEXT = ftodel; |
695 | killem->NEXT = ftodel; |
702 | ftodel = killem; |
696 | ftodel = killem; |
703 | } |
697 | } |
… | |
… | |
707 | progress.partno = 0; |
701 | progress.partno = 0; |
708 | progress.numparts = 1; |
702 | progress.numparts = 1; |
709 | progress.fsize = (long) ((finfo.st_size>0)?finfo.st_size:-1); |
703 | progress.fsize = (long) ((finfo.st_size>0)?finfo.st_size:-1); |
710 | progress.percent = 0; |
704 | progress.percent = 0; |
711 | progress.foffset = 0; |
705 | progress.foffset = 0; |
712 | FP_strncpy (progress.curfile, |
706 | _FP_strncpy (progress.curfile, |
713 | (strlen(filename)>255)? |
707 | (strlen(filename)>255)? |
714 | (filename+strlen(filename)-255):filename, |
708 | (filename+strlen(filename)-255):filename, |
715 | 256); |
709 | 256); |
716 | progress.action = UUACT_SCANNING; |
710 | progress.action = UUACT_SCANNING; |
717 | |
711 | |
… | |
… | |
729 | ungetc (res, datei); |
723 | ungetc (res, datei); |
730 | |
724 | |
731 | if ((loaded = ScanPart (datei, fileid, &sr)) == NULL) { |
725 | if ((loaded = ScanPart (datei, fileid, &sr)) == NULL) { |
732 | if (sr != UURET_NODATA && sr != UURET_OK && sr != UURET_CONT) { |
726 | if (sr != UURET_NODATA && sr != UURET_OK && sr != UURET_CONT) { |
733 | UUkillfread (loaded); |
727 | UUkillfread (loaded); |
734 | if (sr != UURET_CANCEL) |
728 | if (sr != UURET_CANCEL) { |
735 | UUMessage (uulib_id, __LINE__, UUMSG_ERROR, |
729 | UUMessage (uulib_id, __LINE__, UUMSG_ERROR, |
736 | uustring (S_READ_ERROR), filename, |
730 | uustring (S_READ_ERROR), filename, |
737 | strerror (uu_errno)); |
731 | strerror (uu_errno)); |
738 | |
732 | } |
739 | UUCheckGlobalList (); |
733 | UUCheckGlobalList (); |
740 | progress.action = 0; |
734 | progress.action = 0; |
741 | fclose (datei); |
735 | fclose (datei); |
742 | return sr; |
736 | return sr; |
743 | } |
737 | } |
… | |
… | |
827 | /* |
821 | /* |
828 | * if in fast mode, we don't look any further, because we're told |
822 | * if in fast mode, we don't look any further, because we're told |
829 | * that each source file holds at most one encoded part |
823 | * that each source file holds at most one encoded part |
830 | */ |
824 | */ |
831 | |
825 | |
832 | if (loaded->uudet) |
|
|
833 | (*partcount)++; |
|
|
834 | |
|
|
835 | if (uu_fast_scanning && sr != UURET_CONT) |
826 | if (uu_fast_scanning && sr != UURET_CONT) |
836 | break; |
827 | break; |
|
|
828 | |
|
|
829 | if (loaded->uudet) |
|
|
830 | count++; |
837 | } |
831 | } |
838 | fclose (datei); |
832 | fclose (datei); |
839 | |
833 | |
840 | if (!uu_fast_scanning && *partcount == 0) |
834 | if (!uu_fast_scanning && count==0) { |
841 | UUMessage (uulib_id, __LINE__, UUMSG_NOTE, |
835 | UUMessage (uulib_id, __LINE__, UUMSG_NOTE, |
842 | uustring (S_NO_DATA_FOUND), filename); |
836 | uustring (S_NO_DATA_FOUND), filename); |
|
|
837 | } |
843 | |
838 | |
844 | progress.action = 0; |
839 | progress.action = 0; |
845 | UUCheckGlobalList (); |
840 | UUCheckGlobalList (); |
846 | |
841 | |
847 | return UURET_OK; |
842 | return UURET_OK; |
… | |
… | |
939 | thefile->binfile, strerror (uu_errno = errno)); |
934 | thefile->binfile, strerror (uu_errno = errno)); |
940 | fclose (source); |
935 | fclose (source); |
941 | return UURET_IOERR; |
936 | return UURET_IOERR; |
942 | } |
937 | } |
943 | |
938 | |
944 | /* try rename() shortcut first */ |
|
|
945 | if (!rename (thefile->binfile, uugen_fnbuffer)) |
|
|
946 | { |
|
|
947 | mode_t mask = 0000; /* there is a slight window here anyway */ |
|
|
948 | #if HAVE_UMASK |
|
|
949 | mask = umask (0022); umask (mask); |
|
|
950 | #endif |
|
|
951 | fclose (source); |
|
|
952 | #if HAVE_CHMOD |
|
|
953 | chmod (uugen_fnbuffer, thefile->mode & ~mask); |
|
|
954 | #endif |
|
|
955 | goto skip_copy; |
|
|
956 | } |
|
|
957 | |
|
|
958 | progress.action = 0; |
939 | progress.action = 0; |
959 | FP_strncpy (progress.curfile, |
940 | _FP_strncpy (progress.curfile, |
960 | (strlen(uugen_fnbuffer)>255)? |
941 | (strlen(uugen_fnbuffer)>255)? |
961 | (uugen_fnbuffer+strlen(uugen_fnbuffer)-255):uugen_fnbuffer, |
942 | (uugen_fnbuffer+strlen(uugen_fnbuffer)-255):uugen_fnbuffer, |
962 | 256); |
943 | 256); |
963 | progress.partno = 0; |
944 | progress.partno = 0; |
964 | progress.numparts = 1; |
945 | progress.numparts = 1; |
… | |
… | |
1034 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
1015 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
1035 | uustring (S_TMP_NOT_REMOVED), |
1016 | uustring (S_TMP_NOT_REMOVED), |
1036 | thefile->binfile, |
1017 | thefile->binfile, |
1037 | strerror (uu_errno = errno)); |
1018 | strerror (uu_errno = errno)); |
1038 | } |
1019 | } |
1039 | |
|
|
1040 | skip_copy: |
|
|
1041 | FP_free (thefile->binfile); |
1020 | _FP_free (thefile->binfile); |
1042 | thefile->binfile = NULL; |
1021 | thefile->binfile = NULL; |
1043 | thefile->state &= ~UUFILE_TMPFILE; |
1022 | thefile->state &= ~UUFILE_TMPFILE; |
1044 | thefile->state |= UUFILE_DECODED; |
1023 | thefile->state |= UUFILE_DECODED; |
1045 | progress.action = 0; |
1024 | progress.action = 0; |
1046 | |
1025 | |
… | |
… | |
1052 | * If the function returns non-zero, we break and don't send any more |
1031 | * If the function returns non-zero, we break and don't send any more |
1053 | */ |
1032 | */ |
1054 | |
1033 | |
1055 | int UUEXPORT |
1034 | int UUEXPORT |
1056 | UUInfoFile (uulist *thefile, void *opaque, |
1035 | UUInfoFile (uulist *thefile, void *opaque, |
1057 | int (*func) (void *, char *)) |
1036 | int (*func) _ANSI_ARGS_((void *, char *))) |
1058 | { |
1037 | { |
1059 | int errflag=0, res, bhflag=0, dd; |
1038 | int errflag=0, res, bhflag=0, dd; |
1060 | long maxpos; |
1039 | long maxpos; |
1061 | FILE *inpfile; |
1040 | FILE *inpfile; |
1062 | |
1041 | |
… | |
… | |
1085 | uustring (S_NOT_OPEN_FILE), |
1064 | uustring (S_NOT_OPEN_FILE), |
1086 | thefile->thisfile->data->sfname, |
1065 | thefile->thisfile->data->sfname, |
1087 | strerror (uu_errno=errno)); |
1066 | strerror (uu_errno=errno)); |
1088 | return UURET_IOERR; |
1067 | return UURET_IOERR; |
1089 | } |
1068 | } |
1090 | FP_strncpy (uugen_fnbuffer, thefile->thisfile->data->sfname, 1024); |
1069 | _FP_strncpy (uugen_fnbuffer, thefile->thisfile->data->sfname, 1024); |
1091 | } |
1070 | } |
1092 | |
1071 | |
1093 | /* |
1072 | /* |
1094 | * seek to beginning of info |
1073 | * seek to beginning of info |
1095 | */ |
1074 | */ |
… | |
… | |
1097 | fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET); |
1076 | fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET); |
1098 | maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length; |
1077 | maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length; |
1099 | |
1078 | |
1100 | while (!feof (inpfile) && |
1079 | while (!feof (inpfile) && |
1101 | (uu_fast_scanning || ftell(inpfile) < maxpos)) { |
1080 | (uu_fast_scanning || ftell(inpfile) < maxpos)) { |
1102 | if (FP_fgets (uugen_inbuffer, 511, inpfile) == NULL) |
1081 | if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL) |
1103 | break; |
1082 | break; |
1104 | uugen_inbuffer[511] = '\0'; |
1083 | uugen_inbuffer[511] = '\0'; |
1105 | |
1084 | |
1106 | if (ferror (inpfile)) |
1085 | if (ferror (inpfile)) |
1107 | break; |
1086 | break; |
… | |
… | |
1148 | if (thefile == NULL) |
1127 | if (thefile == NULL) |
1149 | return UURET_ILLVAL; |
1128 | return UURET_ILLVAL; |
1150 | |
1129 | |
1151 | oldname = thefile->filename; |
1130 | oldname = thefile->filename; |
1152 | |
1131 | |
1153 | if ((thefile->filename = FP_strdup (newname)) == NULL) { |
1132 | if ((thefile->filename = _FP_strdup (newname)) == NULL) { |
1154 | UUMessage (uulib_id, __LINE__, UUMSG_ERROR, |
1133 | UUMessage (uulib_id, __LINE__, UUMSG_ERROR, |
1155 | uustring (S_NOT_RENAME), |
1134 | uustring (S_NOT_RENAME), |
1156 | oldname, newname); |
1135 | oldname, newname); |
1157 | thefile->filename = oldname; |
1136 | thefile->filename = oldname; |
1158 | return UURET_NOMEM; |
1137 | return UURET_NOMEM; |
1159 | } |
1138 | } |
1160 | FP_free (oldname); |
1139 | _FP_free (oldname); |
1161 | return UURET_OK; |
1140 | return UURET_OK; |
1162 | } |
1141 | } |
1163 | |
1142 | |
1164 | int UUEXPORT |
1143 | int UUEXPORT |
1165 | UURemoveTemp (uulist *thefile) |
1144 | UURemoveTemp (uulist *thefile) |
… | |
… | |
1172 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
1151 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
1173 | uustring (S_TMP_NOT_REMOVED), |
1152 | uustring (S_TMP_NOT_REMOVED), |
1174 | thefile->binfile, |
1153 | thefile->binfile, |
1175 | strerror (uu_errno = errno)); |
1154 | strerror (uu_errno = errno)); |
1176 | } |
1155 | } |
1177 | FP_free (thefile->binfile); |
1156 | _FP_free (thefile->binfile); |
1178 | thefile->binfile = NULL; |
1157 | thefile->binfile = NULL; |
1179 | thefile->state &= ~UUFILE_TMPFILE; |
1158 | thefile->state &= ~UUFILE_TMPFILE; |
1180 | } |
1159 | } |
1181 | return UURET_OK; |
1160 | return UURET_OK; |
1182 | } |
1161 | } |
… | |
… | |
1197 | if (unlink (iter->fname)) { |
1176 | if (unlink (iter->fname)) { |
1198 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
1177 | UUMessage (uulib_id, __LINE__, UUMSG_WARNING, |
1199 | uustring (S_TMP_NOT_REMOVED), |
1178 | uustring (S_TMP_NOT_REMOVED), |
1200 | iter->fname, strerror (uu_errno = errno)); |
1179 | iter->fname, strerror (uu_errno = errno)); |
1201 | } |
1180 | } |
1202 | FP_free (iter->fname); |
1181 | _FP_free (iter->fname); |
1203 | ptr = iter; |
1182 | ptr = iter; |
1204 | iter = iter->NEXT; |
1183 | iter = iter->NEXT; |
1205 | FP_free (ptr); |
1184 | _FP_free (ptr); |
1206 | } |
1185 | } |
1207 | |
1186 | |
1208 | ftodel = NULL; |
1187 | ftodel = NULL; |
1209 | |
1188 | |
1210 | /* |
1189 | /* |
… | |
… | |
1232 | } |
1211 | } |
1233 | |
1212 | |
1234 | UUkilllist (UUGlobalFileList); |
1213 | UUkilllist (UUGlobalFileList); |
1235 | UUGlobalFileList = NULL; |
1214 | UUGlobalFileList = NULL; |
1236 | |
1215 | |
1237 | FP_free (uusavepath); |
1216 | _FP_free (uusavepath); |
1238 | FP_free (uuencodeext); |
1217 | _FP_free (uuencodeext); |
1239 | FP_free (sstate.source); |
1218 | _FP_free (sstate.source); |
1240 | |
1219 | |
1241 | uusavepath = NULL; |
1220 | uusavepath = NULL; |
1242 | uuencodeext = NULL; |
1221 | uuencodeext = NULL; |
1243 | |
1222 | |
1244 | UUkillheaders (&localenv); |
1223 | UUkillheaders (&localenv); |
… | |
… | |
1247 | memset (&sstate, 0, sizeof (scanstate)); |
1226 | memset (&sstate, 0, sizeof (scanstate)); |
1248 | |
1227 | |
1249 | while (mssdepth) { |
1228 | while (mssdepth) { |
1250 | mssdepth--; |
1229 | mssdepth--; |
1251 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1230 | UUkillheaders (&(multistack[mssdepth].envelope)); |
1252 | FP_free (multistack[mssdepth].source); |
1231 | _FP_free (multistack[mssdepth].source); |
1253 | } |
1232 | } |
1254 | |
1233 | |
1255 | /* |
1234 | /* |
1256 | * clean up the malloc'ed stuff |
1235 | * clean up the malloc'ed stuff |
1257 | */ |
1236 | */ |
1258 | |
1237 | |
1259 | for (aiter=toallocate; aiter->ptr; aiter++) { |
1238 | for (aiter=toallocate; aiter->ptr; aiter++) { |
1260 | FP_free (*(aiter->ptr)); |
1239 | _FP_free (*(aiter->ptr)); |
1261 | *(aiter->ptr) = NULL; |
1240 | *(aiter->ptr) = NULL; |
1262 | } |
1241 | } |
1263 | |
1242 | |
1264 | return UURET_OK; |
1243 | return UURET_OK; |
1265 | } |
1244 | } |