⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 human68k.c

📁 完整的解压zip文件的源码。包含密码功能
💻 C
📖 第 1 页 / 共 2 页
字号:
  ---------------------------------------------------------------------------*/    if (FUNCTION == GETPATH) {        strcpy(pathcomp, buildpath);        Trace((stderr, "getting and freeing path [%s]\n", pathcomp));        free(buildpath);        buildpath = end = (char *)NULL;        return 0;    }/*---------------------------------------------------------------------------    APPEND_NAME:  assume the path component is the filename; append it and    return without checking for existence.  ---------------------------------------------------------------------------*/    if (FUNCTION == APPEND_NAME) {        char *old_end = end;        Trace((stderr, "appending filename [%s]\n", pathcomp));        while ((*end = *pathcomp++) != '\0') {            ++end;            normalize_name(old_end);            if ((end-buildpath) >= FILNAMSIZ) {                *--end = '\0';                Info(slide, 1, ((char *)slide,                  "checkdir warning:  path too long; truncating\n\                   %s\n                -> %s\n",                  G.filename, buildpath));                return 1;   /* filename truncated */            }        }        Trace((stderr, "buildpath now = [%s]\n", buildpath));        return 0;  /* could check for existence here, prompt for new name... */    }/*---------------------------------------------------------------------------    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.  ---------------------------------------------------------------------------*//* GRR:  for VMS and TOPS-20, add up to 13 to strlen */    if (FUNCTION == INIT) {        Trace((stderr, "initializing buildpath to "));        if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1)) ==            (char *)NULL)            return 10;        if ((rootlen > 0) && !renamed_fullpath) {            strcpy(buildpath, rootpath);            end = buildpath + rootlen;        } else {            *buildpath = '\0';            end = buildpath;        }        Trace((stderr, "[%s]\n", buildpath));        return 0;    }/*---------------------------------------------------------------------------    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", pathcomp));        if (pathcomp == (char *)NULL) {            rootlen = 0;            return 0;        }        if ((rootlen = strlen(pathcomp)) > 0) {            int had_trailing_pathsep=FALSE;            if (pathcomp[rootlen-1] == '/') {                pathcomp[--rootlen] = '\0';                had_trailing_pathsep = TRUE;            }            if (rootlen > 0 && (SSTAT(pathcomp, &G.statbuf) ||                !S_ISDIR(G.statbuf.st_mode)))          /* path does not exist */            {                if (!G.create_dirs /* || iswild(pathcomp) */ ) {                    rootlen = 0;                    return 2;   /* skip (or treat as stored file) */                }                /* create the directory (could add loop here to scan pathcomp                 * and create more than one level, but why really necessary?) */                if (MKDIR(pathcomp, 0777) == -1) {                    Info(slide, 1, ((char *)slide,                      "checkdir:  cannot create extraction directory: %s\n",                      pathcomp));                    rootlen = 0;   /* path didn't exist, tried to create, and */                    return 3;  /* failed:  file exists, or 2+ levels required */                }            }            if ((rootpath = (char *)malloc(rootlen+2)) == NULL) {                rootlen = 0;                return 10;            }            strcpy(rootpath, pathcomp);            rootpath[rootlen++] = '/';            rootpath[rootlen] = '\0';            Trace((stderr, "rootpath now = [%s]\n", rootpath));        }        return 0;    }#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 0;    }    return 99;  /* should never reach */} /* end function checkdir() *//****************************//* Function close_outfile() *//****************************/void close_outfile(__G)    __GDEF{#ifdef USE_EF_UT_TIME    iztimes z_utime;    struct tm *t;    /* 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.     */    union {        ulg z_dostime;        struct {                /* date and time words */            union {             /* DOS file modification time word */                ush ztime;                struct {                    unsigned zt_se : 5;                    unsigned zt_mi : 6;                    unsigned zt_hr : 5;                } _tf;            } _t;            union {             /* DOS file modification date word */                ush zdate;                struct {                    unsigned zd_dy : 5;                    unsigned zd_mo : 4;                    unsigned zd_yr : 7;                } _df;            } _d;        } zt;    } dos_dt;#endif /* USE_EF_UT_TIME */    if (uO.cflag) {        fclose(G.outfile);        return;    }#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.zt._t._tf.zt_se = 0;            dos_dt.zt._t._tf.zt_mi = 0;            dos_dt.zt._t._tf.zt_hr = 0;            dos_dt.zt._d._df.zd_dy = 1;            dos_dt.zt._d._df.zd_mo = 1;            dos_dt.zt._d._df.zd_yr = 0;        } else {            dos_dt.zt._t._tf.zt_se = t->tm_sec >> 1;            dos_dt.zt._t._tf.zt_mi = t->tm_min;            dos_dt.zt._t._tf.zt_hr = t->tm_hour;            dos_dt.zt._d._df.zd_dy = t->tm_mday;            dos_dt.zt._d._df.zd_mo = t->tm_mon + 1;            dos_dt.zt._d._df.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;{    union {        ulg z_dostime;        struct {                /* date and time words */            union {             /* DOS file modification time word */                ush ztime;                struct {                    unsigned zt_se : 5;                    unsigned zt_mi : 6;                    unsigned zt_hr : 5;                } _tf;            } _t;            union {             /* DOS file modification date word */                ush zdate;                struct {                    unsigned zd_dy : 5;                    unsigned zd_mo : 4;                    unsigned zd_yr : 7;                } _df;            } _d;        } zt;    } 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.zt._t._tf.zt_se = 0;        dos_dt.zt._t._tf.zt_mi = 0;        dos_dt.zt._t._tf.zt_hr = 0;        dos_dt.zt._d._df.zd_dy = 1;        dos_dt.zt._d._df.zd_mo = 1;        dos_dt.zt._d._df.zd_yr = 0;    } else {        dos_dt.zt._t._tf.zt_se = t->tm_sec >> 1;        dos_dt.zt._t._tf.zt_mi = t->tm_min;        dos_dt.zt._t._tf.zt_hr = t->tm_hour;        dos_dt.zt._d._df.zd_dy = t->tm_mday;        dos_dt.zt._d._df.zd_mo = t->tm_mon + 1;        dos_dt.zt._d._df.zd_yr = t->tm_year - 80;    }    if (((fd = open((char *)fname, 0)) == -1) ||        (_dos_filedate(fileno(G.outfile), 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", " (X68000)",#ifdef __DATE__      " on ", __DATE__#else      "", ""#endif      );    (*G.message)((zvoid *)&G, slide, (ulg)len, 0);} /* end function version() */#endif /* !SFX *//* Human68K-specific routines */#define VALID_CHAR "&#()@_^{}!"extern ulg TwentyOneOptions(void);static int multi_period = 0;static int special_char = 0;voidInitTwentyOne(void){    ulg stat;    stat = TwentyOneOptions();    if (stat == 0 || stat == (unsigned long) -1) {        special_char = 0;        multi_period = 0;        return;    }    if (stat & (1UL << 29))        special_char = 1;    if (stat & (1UL << 28))        multi_period = 1;}static voidnormalize_name(char *name){    char *dot;    char *p;    if (strlen(name) > 18) {    /* too long */        char base[18 + 1];        char ext[4 + 1];        if ((dot = jstrrchr(name, '.')) != NULL)            *dot = '\0';        strncpy(base, name, 18);        base[18] = '\0';        if (dot) {            *dot = '.';            strncpy(ext, dot, 4);            ext[4] = '\0';        } else            *ext = '\0';        strcpy(name, base);        strcat(name, ext);    }    dot = NULL;    for (p = name; *p; p++) {        if (iskanji((unsigned char)*p) && p[1] != '\0')            p++;        else if (*p == '.') {            if (!multi_period) {                dot = p;                *p = '_';            }        } else if (!special_char && !isalnum (*p)                   && strchr(VALID_CHAR, *p) == NULL)            *p = '_';    }    if (dot != NULL) {        *dot = '.';        if (strlen(dot) > 4)            dot[4] = '\0';    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -