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

📄 vmmvs.c

📁 完整的解压zip文件的源码。包含密码功能
💻 C
📖 第 1 页 / 共 2 页
字号:
/*---------------------------------------------------------------------------  vmmvs.c (for both VM/CMS and MVS)  Contains:  vmmvs_open_infile()             open_outfile()             close_outfile()             close_infile()             getVMMVSexfield()             do_wild()             mapattr()             mapname()             checkdir()             check_for_newer()             stat()             version()  ---------------------------------------------------------------------------*/#define UNZIP_INTERNAL#include "unzip.h"/********************************//* Function vmmvs_open_infile() *//********************************/FILE *vmmvs_open_infile(__G)   __GDEF{   FILE *fzip;   G.tempfn = NULL;   fzip = fopen(G.zipfn, FOPR);#if 0   /* Let's try it without the convert for a while -- RG Hartwig */   if ((fzip = fopen(G.zipfn,"rb,recfm=fb")) == NULL) {      size_t cnt;      char *buf;      FILE *in, *out;      if ((buf = (char *)malloc(32768)) == NULL) return NULL;      if ((G.tempfn = tmpnam(NULL)) == NULL) return NULL;      if ((in = fopen(G.zipfn,"rb")) != NULL &&          (out = fopen(G.tempfn,"wb,recfm=fb,lrecl=1")) != NULL) {         Trace((stdout,"Converting ZIP file to fixed record format...\n"));         while (!feof(in)) {            cnt = fread(buf,1,32768,in);            if (cnt) fwrite(buf,1,cnt,out);         }      }      else {         free(buf);         fclose(out);         fclose(in);         return NULL;      }      free(buf);      fclose(out);      fclose(in);      fzip = fopen(G.tempfn,"rb,recfm=fb");      if (fzip == NULL) return NULL;      /* Update the G.ziplen value since it might have changed after         the reformatting copy. */      fseek(fzip,0L,SEEK_SET);      fseek(fzip,0L,SEEK_END);      G.ziplen = ftell(fzip);   }#endif   return fzip;}/***************************//* Function open_outfile() *//***************************/int open_outfile(__G)           /* return 1 if fail */    __GDEF{    char type[100];    char *mode = NULL;    if (G.pInfo->textmode)        mode = FOPWT;    else if (G.lrec.extra_field_length > 0 && G.extra_field != NULL) {        unsigned lef_len = (unsigned)(G.lrec.extra_field_length);        uch *lef_buf = G.extra_field;        while (lef_len > EB_HEADSIZE) {            unsigned eb_id = makeword(&lef_buf[EB_ID]);            unsigned eb_dlen = makeword(&lef_buf[EB_LEN]);            if (eb_dlen > (lef_len - EB_HEADSIZE)) {                /* Discovered some extra field inconsistency! */                TTrace((stderr,                        "open_outfile: block length %u > rest lef_size %u\n",                        eb_dlen, lef_len - EB_HEADSIZE));                break;            }            if ((eb_id == EF_VMCMS || eb_id == EF_MVS) &&                (getVMMVSexfield(type, lef_buf, eb_dlen) > 0)) {                mode = type;                break;            }            /* Skip this extra field block */            lef_buf += (eb_dlen + EB_HEADSIZE);            lef_len -= (eb_dlen + EB_HEADSIZE);        }    }    if (mode == NULL) mode = FOPW;    Trace((stderr, "Output file='%s' opening with '%s'\n", G.filename, mode));    if ((G.outfile = fopen(G.filename, mode)) == NULL) {        Info(slide, 0x401, ((char *)slide, "\nerror:  cannot create %s\n",             G.filename));        Trace((stderr, "error %d: '%s'\n", errno, strerror(errno)));        return 1;    }    return 0;} /* end function open_outfile() *//****************************//* Function close_outfile() *//****************************/void close_outfile(__G)   __GDEF{   fclose(G.outfile);} /* end function close_outfile() *//***************************//* Function close_infile() *//***************************/void close_infile(__G)   __GDEF{   fclose(G.zipfd);   /* If we're working from a temp file, erase it now */   if (G.tempfn)      remove(G.tempfn);} /* end function close_infile() *//******************************//* Function getVMMVSexfield() *//******************************/extent getVMMVSexfield(type, ef_block, datalen)    char *type;    uch *ef_block;    unsigned datalen;{    fldata_t *fdata = (fldata_t *) &ef_block[4];    if (datalen < sizeof(fldata_t))        return 0;    strcpy(type, "w");    strcat(type,  fdata->__openmode == __TEXT   ? ""                 :fdata->__openmode == __BINARY ? "b"                 :fdata->__openmode == __RECORD ? "b,type=record"                 :                                "");    strcat(type, ",recfm=");    strcat(type,  fdata->__recfmF? "F"                 :fdata->__recfmV? "V"                 :fdata->__recfmU? "U"                 :                 "?");    if (fdata->__recfmBlk) strcat(type, "B");    if (fdata->__recfmS)   strcat(type, "S");    if (fdata->__recfmASA) strcat(type, "A");    if (fdata->__recfmM)   strcat(type, "M");    sprintf(type+strlen(type), ",lrecl=%ld", fdata->__recfmV                                              ? fdata->__maxreclen+4                                              : fdata->__maxreclen);#ifdef VM_CMS    /* For CMS, use blocksize for FB files only */    if (fdata->__recfmBlk)       sprintf(type+strlen(type), ",blksize=%ld", fdata->__blksize);#else    /* For MVS, always use blocksize */    sprintf(type+strlen(type), ",blksize=%ld", fdata->__blksize);#endif    return strlen(type);} /* end function getVMMVSexfield() */#ifndef SFX/**********************//* Function do_wild() */   /* for porting:  dir separator; match(ignore_case) *//**********************/char *do_wild(__G__ wld)    __GDEF    char *wld;             /* only used first time on a given dir */{    static int First = 0;    static char filename[256];    if (First == 0) {       First = 1;       strcpy( filename, wld );       return filename;    }    else       return (char *)NULL;} /* end function do_wild() */#endif /* !SFX *//************************//*  Function mapattr()  *//************************/int mapattr(__G)     __GDEF{    return 0;}/************************//*  Function mapname()  *//************************/int mapname(__G__ renamed)            /* returns: */            /* 0 (PK_COOL) if no error, */            /* 1 (PK_WARN) if caution (filename trunc), */            /* 2 (PK_ERR)  if warning (skip file because dir doesn't exist), */            /* 3 (PK_BADERR) if error (skip file), */            /* 10 if no memory (skip file) */            /* 78 (IZ_VOL_LABEL) if path was volume label (skip it) */    __GDEF    int renamed;{    char newname[FILNAMSIZ], *lbar;#ifdef MVS    char *pmember;#endif    int name_changed = 0;    if (G.pInfo->vollabel)        return IZ_VOL_LABEL;    /* can't set disk volume labels in CMS_MVS */#ifdef MVS    /* Remove bad characters for MVS from the filename */    while ((lbar = strpbrk(G.filename, "_+-")) != NULL) {       /* Must use memmove() here because data overlaps.  */       /* strcpy() gives undefined behavior in this case. */       memmove(lbar, lbar+1, strlen(lbar));       name_changed = 1;    }#endif    /* Remove bad characters for MVS/CMS from the filename */    while ((lbar = strpbrk(G.filename, "()")) != NULL) {       memmove(lbar, lbar+1, strlen(lbar));       name_changed = 1;    }#ifdef VM_CMS    if ((lbar = strrchr(G.filename, '/')) != NULL) {        strcpy(newname, lbar+1);        Trace((stderr, "File '%s' renamed to '%s'\n", G.filename, newname));        strcpy(G.filename, newname);        name_changed = 1;    }#else /* MVS */    if ((pmember = strrchr(G.filename, '/')) == NULL)        pmember = G.filename;    else        pmember++;    /* search for extension in file name */    if ((lbar = strrchr(pmember, '.')) != NULL) {        *lbar++ = '\0';        strcpy(newname, pmember);        strcpy(pmember, lbar);        strcat(pmember, "(");        strcat(pmember, newname);        strcat(pmember, ")");    }    /* Remove all 'internal' dots '.', to prevent false consideration as     * MVS path delimiters! */    while ((lbar = strrchr(G.filename, '.')) != NULL) {        memmove(lbar, lbar+1, strlen(lbar));        name_changed = 1;    }    /* Finally, convert path delimiters from internal '/' to external '.' */    while ((lbar = strchr(G.filename, '/')) != NULL)        *lbar = '.';#endif /* ?VM_CMS */

⌨️ 快捷键说明

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