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

Comparing Convert-UUlib/uulib/uulib.c (file contents):
Revision 1.22 by root, Fri Jul 10 01:17:08 2015 UTC vs.
Revision 1.23 by root, Thu Dec 10 22:49:15 2020 UTC

81#include <fptools.h> 81#include <fptools.h>
82#include <uustring.h> 82#include <uustring.h>
83 83
84#include "safealloc.c" 84#include "safealloc.c"
85 85
86char * uulib_id = "$Id: uulib.c,v 1.22 2015/07/10 01:17:08 root Exp $"; 86char * uulib_id = "$Id: uulib.c,v 1.23 2020/12/10 22:49:15 root Exp $";
87 87
88#ifdef SYSTEM_WINDLL 88#ifdef SYSTEM_WINDLL
89BOOL _export WINAPI 89BOOL _export WINAPI
90DllEntryPoint (HINSTANCE hInstance, DWORD seginfo, 90DllEntryPoint (HINSTANCE hInstance, DWORD seginfo,
91 LPVOID lpCmdLine) 91 LPVOID lpCmdLine)
92{ 92{
93 /* Don't do anything, so just return true */ 93 /* Don't do anything, so just return true */
94 return TRUE; 94 return TRUE;
612/* 612/*
613 * Set the various Callback functions 613 * Set the various Callback functions
614 */ 614 */
615 615
616int UUEXPORT 616int UUEXPORT
617UUSetMsgCallback (void *opaque, 617UUSetMsgCallback (void *opaque,
618 void (*func) (void *, char *, int)) 618 void (*func) (void *, char *, int))
619{ 619{
620 uu_MsgCallback = func; 620 uu_MsgCallback = func;
621 uu_MsgCBArg = opaque; 621 uu_MsgCBArg = opaque;
622 622
720 void *datei_buf; 720 void *datei_buf;
721 721
722 int _count; 722 int _count;
723 if (!partcount) 723 if (!partcount)
724 partcount = &_count; 724 partcount = &_count;
725 725
726 *partcount = 0; 726 *partcount = 0;
727 727
728 if ((datei = fopen (filename, "rb")) == NULL) { 728 if ((datei = fopen (filename, "rb")) == NULL) {
729 UUMessage (uulib_id, __LINE__, UUMSG_ERROR, 729 UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
730 uustring (S_NOT_OPEN_SOURCE), 730 uustring (S_NOT_OPEN_SOURCE),
776 776
777 if (fileid == NULL) 777 if (fileid == NULL)
778 fileid = filename; 778 fileid = filename;
779 779
780 while (!feof (datei) && !ferror (datei)) { 780 while (!feof (datei) && !ferror (datei)) {
781 /* 781 /*
782 * Peek file, or some systems won't detect EOF 782 * Peek file, or some systems won't detect EOF
783 */ 783 */
784 res = _FP_fgetc (datei); 784 res = _FP_fgetc (datei);
785 if (feof (datei) || ferror (datei)) 785 if (feof (datei) || ferror (datei))
786 break; 786 break;
787 else 787 else
788 ungetc (res, datei); 788 ungetc (res, datei);
789 789
790 if ((loaded = ScanPart (datei, fileid, &sr)) == NULL) { 790 if ((loaded = ScanPart (datei, fileid, &sr)) == NULL) {
791 if (sr != UURET_NODATA && sr != UURET_OK && sr != UURET_CONT) { 791 if (sr != UURET_NODATA && sr != UURET_OK && sr != UURET_CONT) {
792 UUkillfread (loaded); 792 UUkillfread (loaded);
793 if (sr != UURET_CANCEL) 793 if (sr != UURET_CANCEL)
794 UUMessage (uulib_id, __LINE__, UUMSG_ERROR, 794 UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
837 */ 837 */
838 UUkillfread (loaded); 838 UUkillfread (loaded);
839 if (uu_fast_scanning && sr != UURET_CONT) break; 839 if (uu_fast_scanning && sr != UURET_CONT) break;
840 continue; 840 continue;
841 } 841 }
842 842
843 if ((fload = UUPreProcessPart (loaded, &res)) == NULL) { 843 if ((fload = UUPreProcessPart (loaded, &res)) == NULL) {
844 /* 844 /*
845 * no useful data found 845 * no useful data found
846 */ 846 */
847 if (res != UURET_NODATA) { 847 if (res != UURET_NODATA) {
867 fload->partno, 867 fload->partno,
868 (loaded->begin) ? "begin" : "", 868 (loaded->begin) ? "begin" : "",
869 (loaded->end) ? "end" : "", 869 (loaded->end) ? "end" : "",
870 codenames[loaded->uudet]); 870 codenames[loaded->uudet]);
871 } 871 }
872 872
873 if ((res = UUInsertPartToList (fload))) { 873 if ((res = UUInsertPartToList (fload))) {
874 /* 874 /*
875 * couldn't use the data 875 * couldn't use the data
876 */ 876 */
877 UUkillfile (fload); 877 UUkillfile (fload);
980 thefile->mode &= 0777; 980 thefile->mode &= 0777;
981 } 981 }
982 982
983 /* 983 /*
984 * Determine the name of the target file according to the rules: 984 * Determine the name of the target file according to the rules:
985 * 985 *
986 * IF (destname!=NULL) THEN filename=destname; 986 * IF (destname!=NULL) THEN filename=destname;
987 * ELSE 987 * ELSE
988 * filename = thefile->filename 988 * filename = thefile->filename
989 * IF (FilenameFilter!=NULL) THEN filename=FilenameFilter(filename); 989 * IF (FilenameFilter!=NULL) THEN filename=FilenameFilter(filename);
990 * filename = SaveFilePath + filename 990 * filename = SaveFilePath + filename
1164 /* 1164 /*
1165 * We might need to ask our callback function to download the file 1165 * We might need to ask our callback function to download the file
1166 */ 1166 */
1167 1167
1168 if (uu_FileCallback) { 1168 if (uu_FileCallback) {
1169 if ((res = (*uu_FileCallback) (uu_FileCBArg, 1169 if ((res = (*uu_FileCallback) (uu_FileCBArg,
1170 thefile->thisfile->data->sfname, 1170 thefile->thisfile->data->sfname,
1171 uugen_fnbuffer, 1171 uugen_fnbuffer,
1172 1)) != UURET_OK) 1172 1)) != UURET_OK)
1173 return res; 1173 return res;
1174 if ((inpfile = fopen (uugen_fnbuffer, "rb")) == NULL) { 1174 if ((inpfile = fopen (uugen_fnbuffer, "rb")) == NULL) {
1181 } 1181 }
1182 } 1182 }
1183 else { 1183 else {
1184 if ((inpfile = fopen (thefile->thisfile->data->sfname, "rb")) == NULL) { 1184 if ((inpfile = fopen (thefile->thisfile->data->sfname, "rb")) == NULL) {
1185 UUMessage (uulib_id, __LINE__, UUMSG_ERROR, 1185 UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
1186 uustring (S_NOT_OPEN_FILE), 1186 uustring (S_NOT_OPEN_FILE),
1187 thefile->thisfile->data->sfname, 1187 thefile->thisfile->data->sfname,
1188 strerror (uu_errno=errno)); 1188 strerror (uu_errno=errno));
1189 return UURET_IOERR; 1189 return UURET_IOERR;
1190 } 1190 }
1191 _FP_strncpy (uugen_fnbuffer, thefile->thisfile->data->sfname, 1024); 1191 _FP_strncpy (uugen_fnbuffer, thefile->thisfile->data->sfname, 1024);
1196 */ 1196 */
1197 1197
1198 fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET); 1198 fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET);
1199 maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length; 1199 maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length;
1200 1200
1201 while (!feof (inpfile) && 1201 while (!feof (inpfile) &&
1202 (uu_fast_scanning || ftell(inpfile) < maxpos)) { 1202 (uu_fast_scanning || ftell(inpfile) < maxpos)) {
1203 if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL) 1203 if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL)
1204 break; 1204 break;
1205 uugen_inbuffer[511] = '\0'; 1205 uugen_inbuffer[511] = '\0';
1206 1206
1232 } 1232 }
1233 1233
1234 fclose (inpfile); 1234 fclose (inpfile);
1235 1235
1236 if (uu_FileCallback) 1236 if (uu_FileCallback)
1237 (*uu_FileCallback) (uu_FileCBArg, 1237 (*uu_FileCallback) (uu_FileCBArg,
1238 thefile->thisfile->data->sfname, 1238 thefile->thisfile->data->sfname,
1239 uugen_fnbuffer, 0); 1239 uugen_fnbuffer, 0);
1240 1240
1241 if (errflag) 1241 if (errflag)
1242 return UURET_IOERR; 1242 return UURET_IOERR;
1243 1243
1244 return UURET_OK; 1244 return UURET_OK;
1245} 1245}
1246 1246
1247int UUEXPORT 1247int UUEXPORT
1248UURenameFile (uulist *thefile, char *newname) 1248UURenameFile (uulist *thefile, char *newname)
1249{ 1249{
1250 char *oldname; 1250 char *oldname;
1251 1251

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines