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.5 by root, Sun Mar 31 20:04:30 2002 UTC vs.
Revision 1.6 by root, Sun Mar 31 20:08:42 2002 UTC

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
84char * uulib_id = "$Id: uulib.c,v 1.5 2002/03/31 20:04:30 root Exp $"; 84char * uulib_id = "$Id: uulib.c,v 1.6 2002/03/31 20:08:42 root Exp $";
85 85
86#ifdef SYSTEM_WINDLL 86#ifdef SYSTEM_WINDLL
87BOOL _export WINAPI 87BOOL _export WINAPI
88DllEntryPoint (HINSTANCE hInstance, DWORD seginfo, 88DllEntryPoint (HINSTANCE hInstance, DWORD seginfo,
89 LPVOID lpCmdLine) 89 LPVOID lpCmdLine)
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:
690 if (delflag && fileid==NULL) { 690 if (delflag && fileid==NULL) {
691 if ((killem = (itbd *) malloc (sizeof (itbd))) == NULL) { 691 if ((killem = (itbd *) malloc (sizeof (itbd))) == NULL) {
692 UUMessage (uulib_id, __LINE__, UUMSG_WARNING, 692 UUMessage (uulib_id, __LINE__, UUMSG_WARNING,
693 uustring (S_OUT_OF_MEMORY), sizeof (itbd)); 693 uustring (S_OUT_OF_MEMORY), sizeof (itbd));
694 } 694 }
695 else if ((killem->fname = FP_strdup (filename)) == NULL) { 695 else if ((killem->fname = _FP_strdup (filename)) == NULL) {
696 UUMessage (uulib_id, __LINE__, UUMSG_WARNING, 696 UUMessage (uulib_id, __LINE__, UUMSG_WARNING,
697 uustring (S_OUT_OF_MEMORY), strlen(filename)+1); 697 uustring (S_OUT_OF_MEMORY), strlen(filename)+1);
698 FP_free (killem); 698 _FP_free (killem);
699 } 699 }
700 else { 700 else {
701 killem->NEXT = ftodel; 701 killem->NEXT = ftodel;
702 ftodel = killem; 702 ftodel = killem;
703 } 703 }
707 progress.partno = 0; 707 progress.partno = 0;
708 progress.numparts = 1; 708 progress.numparts = 1;
709 progress.fsize = (long) ((finfo.st_size>0)?finfo.st_size:-1); 709 progress.fsize = (long) ((finfo.st_size>0)?finfo.st_size:-1);
710 progress.percent = 0; 710 progress.percent = 0;
711 progress.foffset = 0; 711 progress.foffset = 0;
712 FP_strncpy (progress.curfile, 712 _FP_strncpy (progress.curfile,
713 (strlen(filename)>255)? 713 (strlen(filename)>255)?
714 (filename+strlen(filename)-255):filename, 714 (filename+strlen(filename)-255):filename,
715 256); 715 256);
716 progress.action = UUACT_SCANNING; 716 progress.action = UUACT_SCANNING;
717 717
954#endif 954#endif
955 goto skip_copy; 955 goto skip_copy;
956 } 956 }
957 957
958 progress.action = 0; 958 progress.action = 0;
959 FP_strncpy (progress.curfile, 959 _FP_strncpy (progress.curfile,
960 (strlen(uugen_fnbuffer)>255)? 960 (strlen(uugen_fnbuffer)>255)?
961 (uugen_fnbuffer+strlen(uugen_fnbuffer)-255):uugen_fnbuffer, 961 (uugen_fnbuffer+strlen(uugen_fnbuffer)-255):uugen_fnbuffer,
962 256); 962 256);
963 progress.partno = 0; 963 progress.partno = 0;
964 progress.numparts = 1; 964 progress.numparts = 1;
1036 thefile->binfile, 1036 thefile->binfile,
1037 strerror (uu_errno = errno)); 1037 strerror (uu_errno = errno));
1038 } 1038 }
1039 1039
1040skip_copy: 1040skip_copy:
1041 FP_free (thefile->binfile); 1041 _FP_free (thefile->binfile);
1042 thefile->binfile = NULL; 1042 thefile->binfile = NULL;
1043 thefile->state &= ~UUFILE_TMPFILE; 1043 thefile->state &= ~UUFILE_TMPFILE;
1044 thefile->state |= UUFILE_DECODED; 1044 thefile->state |= UUFILE_DECODED;
1045 progress.action = 0; 1045 progress.action = 0;
1046 1046
1085 uustring (S_NOT_OPEN_FILE), 1085 uustring (S_NOT_OPEN_FILE),
1086 thefile->thisfile->data->sfname, 1086 thefile->thisfile->data->sfname,
1087 strerror (uu_errno=errno)); 1087 strerror (uu_errno=errno));
1088 return UURET_IOERR; 1088 return UURET_IOERR;
1089 } 1089 }
1090 FP_strncpy (uugen_fnbuffer, thefile->thisfile->data->sfname, 1024); 1090 _FP_strncpy (uugen_fnbuffer, thefile->thisfile->data->sfname, 1024);
1091 } 1091 }
1092 1092
1093 /* 1093 /*
1094 * seek to beginning of info 1094 * seek to beginning of info
1095 */ 1095 */
1097 fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET); 1097 fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET);
1098 maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length; 1098 maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length;
1099 1099
1100 while (!feof (inpfile) && 1100 while (!feof (inpfile) &&
1101 (uu_fast_scanning || ftell(inpfile) < maxpos)) { 1101 (uu_fast_scanning || ftell(inpfile) < maxpos)) {
1102 if (FP_fgets (uugen_inbuffer, 511, inpfile) == NULL) 1102 if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL)
1103 break; 1103 break;
1104 uugen_inbuffer[511] = '\0'; 1104 uugen_inbuffer[511] = '\0';
1105 1105
1106 if (ferror (inpfile)) 1106 if (ferror (inpfile))
1107 break; 1107 break;
1148 if (thefile == NULL) 1148 if (thefile == NULL)
1149 return UURET_ILLVAL; 1149 return UURET_ILLVAL;
1150 1150
1151 oldname = thefile->filename; 1151 oldname = thefile->filename;
1152 1152
1153 if ((thefile->filename = FP_strdup (newname)) == NULL) { 1153 if ((thefile->filename = _FP_strdup (newname)) == NULL) {
1154 UUMessage (uulib_id, __LINE__, UUMSG_ERROR, 1154 UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
1155 uustring (S_NOT_RENAME), 1155 uustring (S_NOT_RENAME),
1156 oldname, newname); 1156 oldname, newname);
1157 thefile->filename = oldname; 1157 thefile->filename = oldname;
1158 return UURET_NOMEM; 1158 return UURET_NOMEM;
1159 } 1159 }
1160 FP_free (oldname); 1160 _FP_free (oldname);
1161 return UURET_OK; 1161 return UURET_OK;
1162} 1162}
1163 1163
1164int UUEXPORT 1164int UUEXPORT
1165UURemoveTemp (uulist *thefile) 1165UURemoveTemp (uulist *thefile)
1172 UUMessage (uulib_id, __LINE__, UUMSG_WARNING, 1172 UUMessage (uulib_id, __LINE__, UUMSG_WARNING,
1173 uustring (S_TMP_NOT_REMOVED), 1173 uustring (S_TMP_NOT_REMOVED),
1174 thefile->binfile, 1174 thefile->binfile,
1175 strerror (uu_errno = errno)); 1175 strerror (uu_errno = errno));
1176 } 1176 }
1177 FP_free (thefile->binfile); 1177 _FP_free (thefile->binfile);
1178 thefile->binfile = NULL; 1178 thefile->binfile = NULL;
1179 thefile->state &= ~UUFILE_TMPFILE; 1179 thefile->state &= ~UUFILE_TMPFILE;
1180 } 1180 }
1181 return UURET_OK; 1181 return UURET_OK;
1182} 1182}
1197 if (unlink (iter->fname)) { 1197 if (unlink (iter->fname)) {
1198 UUMessage (uulib_id, __LINE__, UUMSG_WARNING, 1198 UUMessage (uulib_id, __LINE__, UUMSG_WARNING,
1199 uustring (S_TMP_NOT_REMOVED), 1199 uustring (S_TMP_NOT_REMOVED),
1200 iter->fname, strerror (uu_errno = errno)); 1200 iter->fname, strerror (uu_errno = errno));
1201 } 1201 }
1202 FP_free (iter->fname); 1202 _FP_free (iter->fname);
1203 ptr = iter; 1203 ptr = iter;
1204 iter = iter->NEXT; 1204 iter = iter->NEXT;
1205 FP_free (ptr); 1205 _FP_free (ptr);
1206 } 1206 }
1207 1207
1208 ftodel = NULL; 1208 ftodel = NULL;
1209 1209
1210 /* 1210 /*
1232 } 1232 }
1233 1233
1234 UUkilllist (UUGlobalFileList); 1234 UUkilllist (UUGlobalFileList);
1235 UUGlobalFileList = NULL; 1235 UUGlobalFileList = NULL;
1236 1236
1237 FP_free (uusavepath); 1237 _FP_free (uusavepath);
1238 FP_free (uuencodeext); 1238 _FP_free (uuencodeext);
1239 FP_free (sstate.source); 1239 _FP_free (sstate.source);
1240 1240
1241 uusavepath = NULL; 1241 uusavepath = NULL;
1242 uuencodeext = NULL; 1242 uuencodeext = NULL;
1243 1243
1244 UUkillheaders (&localenv); 1244 UUkillheaders (&localenv);
1247 memset (&sstate, 0, sizeof (scanstate)); 1247 memset (&sstate, 0, sizeof (scanstate));
1248 1248
1249 while (mssdepth) { 1249 while (mssdepth) {
1250 mssdepth--; 1250 mssdepth--;
1251 UUkillheaders (&(multistack[mssdepth].envelope)); 1251 UUkillheaders (&(multistack[mssdepth].envelope));
1252 FP_free (multistack[mssdepth].source); 1252 _FP_free (multistack[mssdepth].source);
1253 } 1253 }
1254 1254
1255 /* 1255 /*
1256 * clean up the malloc'ed stuff 1256 * clean up the malloc'ed stuff
1257 */ 1257 */
1258 1258
1259 for (aiter=toallocate; aiter->ptr; aiter++) { 1259 for (aiter=toallocate; aiter->ptr; aiter++) {
1260 FP_free (*(aiter->ptr)); 1260 _FP_free (*(aiter->ptr));
1261 *(aiter->ptr) = NULL; 1261 *(aiter->ptr) = NULL;
1262 } 1262 }
1263 1263
1264 return UURET_OK; 1264 return UURET_OK;
1265} 1265}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines