📄 human68k.c
字号:
} } Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath))); /* could check for existence here, prompt for new name... */ return MPN_OK; }/*--------------------------------------------------------------------------- INIT: allocate and initialize buffer space for the file currently being extracted. If file was renamed with an absolute path, don't prepend the extract-to path. ---------------------------------------------------------------------------*/ if (FUNCTION == INIT) { Trace((stderr, "initializing buildpath to ")); /* allocate space for full filename, root path, and maybe "./" */ if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+3)) == (char *)NULL) return MPN_NOMEM; if ((rootlen > 0) && !renamed_fullpath) { strcpy(buildpath, rootpath); end = buildpath + rootlen; } else { *buildpath = '\0'; end = buildpath; } Trace((stderr, "[%s]\n", FnFilter1(buildpath))); return MPN_OK; }/*--------------------------------------------------------------------------- ROOT: if appropriate, store the path in rootpath and create it if neces- sary; else assume it's a zipfile member and return. This path segment gets used in extracting all members from every zipfile specified on the command line. ---------------------------------------------------------------------------*/#if (!defined(SFX) || defined(SFX_EXDIR)) if (FUNCTION == ROOT) { Trace((stderr, "initializing root path to [%s]\n", FnFilter1(pathcomp))); if (pathcomp == (char *)NULL) { rootlen = 0; return MPN_OK; } if (rootlen > 0) /* rootpath was already set, nothing to do */ return MPN_OK; if ((rootlen = strlen(pathcomp)) > 0) { int had_trailing_pathsep=FALSE, has_drive=FALSE, add_dot=FALSE; char *tmproot; if ((tmproot = (char *)malloc(rootlen+3)) == (char *)NULL) { rootlen = 0; return MPN_NOMEM; } strcpy(tmproot, pathcomp); if (isalpha((uch)tmproot[0]) && tmproot[1] == ':') has_drive = TRUE; /* drive designator */ if (tmproot[rootlen-1] == '/' || tmproot[rootlen-1] == '\\') { tmproot[--rootlen] = '\0'; had_trailing_pathsep = TRUE; } if (has_drive && (rootlen == 2)) { if (!had_trailing_pathsep) /* i.e., original wasn't "x:/" */ add_dot = TRUE; /* relative path: add '.' before '/' */ } else if (rootlen > 0 && (SSTAT(tmproot, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode))) /* path does not exist */ { if (!G.create_dirs /* || iswild(tmproot) */ ) { free(tmproot); rootlen = 0; /* skip (or treat as stored file) */ return MPN_INF_SKIP; } /* create the directory (could add loop here scanning tmproot * to create more than one level, but why really necessary?) */ if (mkdir(tmproot, 0777) == -1) { Info(slide, 1, ((char *)slide, "checkdir: cannot create extraction directory: %s\n", FnFilter1(tmproot))); free(tmproot); rootlen = 0; /* path didn't exist, tried to create, and failed: */ /* file exists, or 2+ subdir levels required */ return MPN_ERR_SKIP; } } if (add_dot) /* had just "x:", make "x:." */ tmproot[rootlen++] = '.'; tmproot[rootlen++] = '/'; tmproot[rootlen] = '\0'; if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) { free(tmproot); rootlen = 0; return MPN_NOMEM; } Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath))); } return MPN_OK; }#endif /* !SFX || SFX_EXDIR *//*--------------------------------------------------------------------------- END: free rootpath, immediately prior to program exit. ---------------------------------------------------------------------------*/ if (FUNCTION == END) { Trace((stderr, "freeing rootpath\n")); if (rootlen > 0) { free(rootpath); rootlen = 0; } return MPN_OK; } return MPN_INVALID; /* should never reach */} /* end function checkdir() */#if (defined(USE_EF_UT_TIME) || defined(TIMESTAMP))/* The following DOS date/time structure is machine-dependent as it * assumes "little-endian" byte order. For MSDOS-specific code, which * is run on ix86 CPUs (or emulators), this assumption is valid; but * care should be taken when using this code as template for other ports. */typedef union { ulg z_dostime; struct { /* date and time words */ ush ztime; /* DOS file modification time word */ ush zdate; /* DOS file modification date word */ } zft; struct { /* DOS date/time components bitfield */ unsigned zt_se : 5; unsigned zt_mi : 6; unsigned zt_hr : 5; unsigned zd_dy : 5; unsigned zd_mo : 4; unsigned zd_yr : 7; } z_dtf;} dos_fdatetime;#endif /* USE_EF_UT_TIME || TIMESTAMP *//****************************//* Function close_outfile() *//****************************/void close_outfile(__G) __GDEF{#ifdef USE_EF_UT_TIME dos_fdatetime dos_dt; iztimes z_utime; struct tm *t;#endif /* USE_EF_UT_TIME */#ifdef USE_EF_UT_TIME if (G.extra_field &&#ifdef IZ_CHECK_TZ G.tz_is_valid &&#endif (ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime, &z_utime, NULL) & EB_UT_FL_MTIME)) { TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n", z_utime.mtime)); /* round up (down if "up" overflows) to even seconds */ if (z_utime.mtime & 1) z_utime.mtime = (z_utime.mtime + 1 > z_utime.mtime) ? z_utime.mtime + 1 : z_utime.mtime - 1; TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7.0 or Macintosh */ t = localtime(&(z_utime.mtime)); } else t = (struct tm *)NULL; if (t != (struct tm *)NULL) { if (t->tm_year < 80) { dos_dt.z_dtf.zt_se = 0; dos_dt.z_dtf.zt_mi = 0; dos_dt.z_dtf.zt_hr = 0; dos_dt.z_dtf.zd_dy = 1; dos_dt.z_dtf.zd_mo = 1; dos_dt.z_dtf.zd_yr = 0; } else { dos_dt.z_dtf.zt_se = t->tm_sec >> 1; dos_dt.z_dtf.zt_mi = t->tm_min; dos_dt.z_dtf.zt_hr = t->tm_hour; dos_dt.z_dtf.zd_dy = t->tm_mday; dos_dt.z_dtf.zd_mo = t->tm_mon + 1; dos_dt.z_dtf.zd_yr = t->tm_year - 80; } } else { dos_dt.z_dostime = G.lrec.last_mod_dos_datetime; } _dos_filedate(fileno(G.outfile), dos_dt.z_dostime);#else /* !USE_EF_UT_TIME */ _dos_filedate(fileno(G.outfile), G.lrec.last_mod_dos_datetime);#endif /* ?USE_EF_UT_TIME */ fclose(G.outfile); _dos_chmod(G.filename, G.pInfo->file_attr);} /* end function close_outfile() */#ifdef TIMESTAMP/*************************//* Function stamp_file() *//*************************/int stamp_file(fname, modtime) ZCONST char *fname; time_t modtime;{ dos_fdatetime dos_dt; time_t t_even; struct tm *t; int fd; /* file handle */ /* round up (down if "up" overflows) to even seconds */ t_even = ((modtime + 1 > modtime) ? modtime + 1 : modtime) & (~1); TIMET_TO_NATIVE(t_even) /* NOP unless MSC 7.0 or Macintosh */ t = localtime(&t_even); if (t == (struct tm *)NULL) return -1; /* time conversion error */ if (t->tm_year < 80) { dos_dt.z_dtf.zt_se = 0; dos_dt.z_dtf.zt_mi = 0; dos_dt.z_dtf.zt_hr = 0; dos_dt.z_dtf.zd_dy = 1; dos_dt.z_dtf.zd_mo = 1; dos_dt.z_dtf.zd_yr = 0; } else { dos_dt.z_dtf.zt_se = t->tm_sec >> 1; dos_dt.z_dtf.zt_mi = t->tm_min; dos_dt.z_dtf.zt_hr = t->tm_hour; dos_dt.z_dtf.zd_dy = t->tm_mday; dos_dt.z_dtf.zd_mo = t->tm_mon + 1; dos_dt.z_dtf.zd_yr = t->tm_year - 80; } if (((fd = open((char *)fname, 0)) == -1) || (_dos_filedate(fd, dos_dt.z_dostime))) { if (fd != -1) close(fd); return -1; } close(fd); return 0;} /* end function stamp_file() */#endif /* TIMESTAMP */#ifndef SFX/************************//* Function version() *//************************/void version(__G) __GDEF{ int len;#if 0 char buf[40];#endif len = sprintf((char *)slide, LoadFarString(CompiledWith),#ifdef __GNUC__ "gcc ", __VERSION__,#else# if 0 "cc ", (sprintf(buf, " version %d", _RELEASE), buf),# else "unknown compiler", "",# endif#endif "Human68k",#ifdef __MC68020__ " (X68030)",#else " (X680x0)",#endif#ifdef __DATE__ " on ", __DATE__#else "", ""#endif ); (*G.message)((zvoid *)&G, slide, (ulg)len, 0);} /* end function version() */#endif /* !SFX */#if defined (SFX) && defined (MAIN)int main(int argc, char *argv[]){ char argv0[92]; /* make true argv[0] (startup routine makes it inaccuracy) */ argv[0] = strcat (strcpy (argv0, _procp->exe_path), _procp->exe_name); return MAIN(argc, argv);}#endif /* SFX && MAIN */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -