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

📄 vms.c

📁 压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.
💻 C
📖 第 1 页 / 共 5 页
字号:
        hh = (G.lrec.last_mod_dos_datetime >> 11) & 0x1f;        mm = (G.lrec.last_mod_dos_datetime >> 5) & 0x3f;        ss = (G.lrec.last_mod_dos_datetime << 1) & 0x3e;    }#else /* !USE_EF_UT_TIME */    yr = ((G.lrec.last_mod_dos_datetime >> 25) & 0x7f) + 1980;    mo = ((G.lrec.last_mod_dos_datetime >> 21) & 0x0f) - 1;    dy = (G.lrec.last_mod_dos_datetime >> 16) & 0x1f;    hh = (G.lrec.last_mod_dos_datetime >> 11) & 0x1f;    mm = (G.lrec.last_mod_dos_datetime >> 5) & 0x3f;    ss = (G.lrec.last_mod_dos_datetime << 1) & 0x1f;#endif /* ?USE_EF_UT_TIME */    dattim = cc$rms_xabdat;     /* fill XABs with default values */    rdt = cc$rms_xabrdt;    sprintf(timbuf, "%02u-%3s-%04u %02u:%02u:%02u.00", dy, month[mo],            yr, hh, mm, ss);    sys$bintim(&date_str, &dattim.xab$q_cdt);    memcpy(&rdt.xab$q_rdt, &dattim.xab$q_cdt, sizeof(rdt.xab$q_rdt));}static int create_default_output(__GPRO)      /* return 1 (PK_WARN) if fail */{    int ierr;    int text_output, bin_fixed;    /* extract the file in text (variable-length) format, when     * a) explicitely requested by the user (through the -a option)     *  or     * b) piping to SYS$OUTPUT, unless "binary" piping was requested     *    by the user (through the -b option)     */    text_output = G.pInfo->textmode ||                  (uO.cflag &&                   (!uO.bflag || (!(uO.bflag - 1) && G.pInfo->textfile)));    /* use fixed length 512 byte record format for disk file when     * a) explicitly requested by the user (-b option)     *  and     * b) entry is not extracted in text mode     */    bin_fixed = !text_output &&                (uO.bflag != 0) && ((uO.bflag != 1) || !G.pInfo->textfile);    rfm = FAB$C_STMLF;  /* Default, stream-LF format from VMS or UNIX */    if (!uO.cflag)              /* Redirect output */    {        rab = cc$rms_rab;       /* fill RAB with default values */        fileblk = cc$rms_fab;   /* fill FAB with default values */        outfab = &fileblk;        outfab->fab$l_xab = NULL;        outrab = &rab;        rab.rab$l_fab = outfab;        if (text_output)        {   /* Default format for output `real' text file */            outfab->fab$b_rfm = FAB$C_VAR;      /* variable length records */            outfab->fab$b_rat = FAB$M_CR;       /* implied (CR) carriage ctrl */        }        else if (bin_fixed)        {   /* Default format for output `real' binary file */            outfab->fab$b_rfm = FAB$C_FIX;      /* fixed length record format */            outfab->fab$w_mrs = 512;            /* record size 512 bytes */            outfab->fab$b_rat = 0;              /* no carriage ctrl */        }        else        {   /* Default format for output misc (bin or text) file */            outfab->fab$b_rfm = FAB$C_STMLF;    /* stream-LF record format */            outfab->fab$b_rat = FAB$M_CR;       /* implied (CR) carriage ctrl */        }        outfab->fab$l_fna = G.filename;        outfab->fab$b_fns = strlen(outfab->fab$l_fna);        set_default_datetime_XABs(__G);        dattim.xab$l_nxt = outfab->fab$l_xab;        outfab->fab$l_xab = (void *) &dattim;        outfab->fab$w_ifi = 0;  /* Clear IFI. It may be nonzero after ZIP */        outfab->fab$b_fac = FAB$M_BRO | FAB$M_PUT;  /* {block|record} output */        /* 2004-11-23 SMS.         * If RMS_DEFAULT values have been determined, and have not been         * set by the user, then set some FAB/RAB parameters for faster         * output.  User-specified RMS_DEFAULT values override the         * built-in default values, so if the RMS_DEFAULT values could         * not be determined, then these (possibly unwise) values could         * not be overridden, and hence will not be set.  Honestly,         * this seems to be excessively cautious, but only old VMS         * versions will be affected.         */        /* If RMS_DEFAULT (and adjusted active) values are available,         * then set the FAB/RAB parameters.  If RMS_DEFAULT values are         * not available, then suffer with the default behavior.         */        if (rms_defaults_known > 0)        {            /* Set the FAB/RAB parameters accordingly. */            outfab-> fab$w_deq = rms_ext_active;            outrab-> rab$b_mbc = rms_mbc_active;            outrab-> rab$b_mbf = rms_mbf_active;#ifdef OLD_FABDEF            /* Truncate at EOF on close, as we may over-extend. */            outfab-> fab$l_fop |= FAB$M_TEF ;            /* If using multiple buffers, enable write-behind. */            if (rms_mbf_active > 1)            {                outrab-> rab$l_rop |= RAB$M_WBH;            }        }        /* Set the initial file allocation according to the file         * size.  Also set the "sequential access only" flag, as         * otherwise, on a file system with highwater marking         * enabled, allocating space for a large file may lock the         * disk for a long time (minutes).         */        outfab-> fab$l_alq = (unsigned) (G.lrec.ucsize+ 511)/ 512;        outfab-> fab$l_fop |= FAB$M_SQO;#else /* !OLD_FABDEF */            /* Truncate at EOF on close, as we may over-extend. */            outfab-> fab$v_tef = 1;            /* If using multiple buffers, enable write-behind. */            if (rms_mbf_active > 1)            {                outrab-> rab$v_wbh = 1;            }        }        /* Set the initial file allocation according to the file         * size.  Also set the "sequential access only" flag, as         * otherwise, on a file system with highwater marking         * enabled, allocating space for a large file may lock the         * disk for a long time (minutes).         */        outfab-> fab$l_alq = (unsigned) (G.lrec.ucsize+ 511)/ 512;        outfab-> fab$v_sqo = 1;#endif /* ?OLD_FABDEF */        ierr = sys$create(outfab);        if (ierr == RMS$_FEX)            ierr = replace(__G);        if (ierr == 0)          /* Canceled */            return (free_up(), PK_WARN);        if (ERR(ierr))        {            char buf[256];            sprintf(buf, "[ Cannot create output file %s ]\n", G.filename);            vms_msg(__G__ buf, ierr);            vms_msg(__G__ "", outfab->fab$l_stv);            free_up();            return PK_WARN;        }        if (!text_output)        {            rab.rab$l_rop |= (RAB$M_BIO | RAB$M_ASY);        }        rab.rab$b_rac = RAB$C_SEQ;        if ((ierr = sys$connect(outrab)) != RMS$_NORMAL)        {#ifdef DEBUG            vms_msg(__G__ "create_default_output: sys$connect failed.\n", ierr);            vms_msg(__G__ "", outfab->fab$l_stv);#endif            Info(slide, 1, ((char *)slide,                 "Can't create output file:  %s\n", FnFilter1(G.filename)));            free_up();            return PK_WARN;        }    }                   /* end if (!uO.cflag) */    init_buf_ring();    _flush_routine = text_output ? got_eol=0,_flush_stream : _flush_blocks;    _close_routine = _close_rms;    return PK_COOL;}static int create_rms_output(__GPRO)          /* return 1 (PK_WARN) if fail */{    int ierr;    int text_output;    /* extract the file in text (variable-length) format, when     * piping to SYS$OUTPUT, unless "binary" piping was requested     * by the user (through the -b option); the "-a" option is     * ignored when extracting zip entries with VMS attributes saved     */    text_output = uO.cflag &&                  (!uO.bflag || (!(uO.bflag - 1) && G.pInfo->textfile));    rfm = outfab->fab$b_rfm;    /* Use record format from VMS extra field */    if (uO.cflag)    {        if (text_output && !PRINTABLE_FORMAT(rfm))        {            Info(slide, 1, ((char *)slide,               "[ File %s has illegal record format to put to screen ]\n",               FnFilter1(G.filename)));            free_up();            return PK_WARN;        }    }    else                        /* Redirect output */    {        rab = cc$rms_rab;       /* fill RAB with default values */        /* The output FAB has already been initialized with the values         * found in the Zip file's "VMS attributes" extra field */        outfab->fab$l_fna = G.filename;        outfab->fab$b_fns = strlen(outfab->fab$l_fna);        /* If no XAB date/time, use attributes from non-VMS fields. */        if (!(xabdat && xabrdt))        {            set_default_datetime_XABs(__G);            if (xabdat == NULL)            {                dattim.xab$l_nxt = outfab->fab$l_xab;                outfab->fab$l_xab = (void *) &dattim;            }        }        outfab->fab$w_ifi = 0;  /* Clear IFI. It may be nonzero after ZIP */        outfab->fab$b_fac = FAB$M_BIO | FAB$M_PUT;      /* block-mode output */        /* 2004-11-23 SMS.         * Set the "sequential access only" flag, as otherwise, on a         * file system with highwater marking enabled, allocating space         * for a large file may lock the disk for a long time (minutes).         */#ifdef OLD_FABDEF        outfab-> fab$l_fop |= FAB$M_SQO;#else /* !OLD_FABDEF */        outfab-> fab$v_sqo = 1;#endif /* ?OLD_FABDEF */        ierr = sys$create(outfab);        if (ierr == RMS$_FEX)            ierr = replace(__G);        if (ierr == 0)          /* Canceled */            return (free_up(), PK_WARN);        if (ERR(ierr))        {            char buf[256];            sprintf(buf, "[ Cannot create output file %s ]\n", G.filename);            vms_msg(__G__ buf, ierr);            vms_msg(__G__ "", outfab->fab$l_stv);            free_up();            return PK_WARN;        }        if (outfab->fab$b_org & (FAB$C_REL | FAB$C_IDX)) {            /* relative and indexed files require explicit allocation */            ierr = sys$extend(outfab);            if (ERR(ierr))            {                char buf[256];                sprintf(buf, "[ Cannot allocate space for %s ]\n", G.filename);                vms_msg(__G__ buf, ierr);                vms_msg(__G__ "", outfab->fab$l_stv);                free_up();                return PK_WARN;            }        }        outrab = &rab;        rab.rab$l_fab = outfab;        {            rab.rab$l_rop |= (RAB$M_BIO | RAB$M_ASY);        }        rab.rab$b_rac = RAB$C_SEQ;        if ((ierr = sys$connect(outrab)) != RMS$_NORMAL)        {#ifdef DEBUG            vms_msg(__G__ "create_rms_output: sys$connect failed.\n", ierr);            vms_msg(__G__ "", outfab->fab$l_stv);#endif            Info(slide, 1, ((char *)slide,                 "Can't create output file:  %s\n", FnFilter1(G.filename)));            free_up();            return PK_WARN;        }    }                   /* end if (!uO.cflag) */    init_buf_ring();    if ( text_output )        switch (rfm)        {            case FAB$C_VAR:                _flush_routine = _flush_varlen;                break;            case FAB$C_STM:            case FAB$C_STMCR:            case FAB$C_STMLF:                _flush_routine = _flush_stream;                got_eol = 0;                break;            default:                _flush_routine = _flush_blocks;                break;        }    else        _flush_routine = _flush_blocks;    _close_routine = _close_rms;    return PK_COOL;}static  int pka_devchn;static  int pka_io_pending;static  unsigned pka_vbn;#if defined(__DECC) || defined(__DECCXX)#pragma __member_alignment __save#pragma __nomember_alignment#endif /* __DECC || __DECCXX */static struct{    short   status;    long    count;    short   dummy;} pka_io_sb;#if defined(__DECC) || defined(__DECCXX)#pragma __member_alignment __restore#endif /* __DECC || __DECCXX */static struct{    short   status;    short   dummy;    void    *addr;} pka_acp_sb;static struct fibdef    pka_fib;static struct atrdef    pka_atr[VMS_MAX_ATRCNT];static int              pka_idx;static ulg              pka_uchar;static struct fatdef    pka_rattr;static struct dsc$descriptor    pka_fibdsc ={   sizeof(pka_fib), DSC$K_DTYPE_Z, DSC$K_CLASS_S, (void *) &pka_fib  };static struct dsc$descriptor_s  pka_devdsc ={   0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &nam.nam$t_dvi[1]  };static struct dsc$descriptor_s  pka_fnam ={   0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL  };static char exp_nam[NAM$C_MAXRSS];static char res_nam[NAM$C_MAXRSS];#define PK_PRINTABLE_RECTYP(x)   ( (x) == FAT$C_VARIABLE \                                || (x) == FAT$C_STREAMLF \                                || (x) == FAT$C_STREAMCR \                                || (x) == FAT$C_STREAM   )static int create_qio_output(__GPRO)          /* return 1 (PK_WARN) if fail */{    int status;    int i;    int text_output;    /* extract the file in text (variable-length) format, when     * piping to SYS$OUTPUT, unless "binary" piping was requested     * by the user (through the -b option); the "-a" option is     * ignored when extracting zip entries with VMS attributes saved     */    text_output = uO.cflag &&                  (!uO.bflag || (!(uO.bflag - 1) && G.pInfo->textfile));    if ( uO.cflag )    {        int rtype;        if (text_output)        {            rtype = pka_rattr.fat$v_rtype;            if (!PK_PRINTABLE_RECTYP(rtype))            {                Info(slide, 1, ((char *)slide,                   "[ File %s has illegal record format to put to screen ]\n",                   FnFilter1(G.filename)));                return PK_WARN;            }        }        else            /* force "block I/O" for binary piping mode */            rtype = FAT$C_UNDEFINED;        init_buf_ring();        switch (rtype)        {            case FAT$C_VARIABLE:                _flush_routine = _flush_varlen;                break;            case FAT$C_STREAM:            case FAT$C_STREAMCR:            case FAT$C_STREAMLF:                _flush_routine = _flush_stream;                got_eol = 0;                break;            default:                _flush_routine = _flush_blocks;                break;        }        _close_routine = _close_rms;    }    else                        /* !(uO.cflag) : redirect output */    {        fileblk = cc$rms_fab;        fileblk.fab$l_fna = G.filename;        fileblk.fab$b_fns = strlen(G.filename);        nam = cc$rms_nam;        fileblk.fab$l_nam = &nam;        nam.nam$l_esa = exp_nam;        nam.nam$b_ess = sizeof(exp_nam);        nam.nam$l_rsa = res_nam;        nam.nam$b_rss = sizeof(res_nam);

⌨️ 快捷键说明

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