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

📄 unzip.c

📁 WINDOWS下的ZIP解压软件,我是个学生,请让我加入这个网站学习
💻 C
📖 第 1 页 / 共 5 页
字号:
void TakeDownFromProcessZipFile(void)
{
    if (inbuf) {
        LocalUnlock(hInBuf);
        inbuf = NULL;
    }
    if (hInBuf)
        hInBuf = LocalFree(hInBuf);

    if (outbuf) {
        LocalUnlock(hOutBuf);
        outbuf = NULL;
    }
    if (hOutBuf)
        hOutBuf = LocalFree(hOutBuf);

    if (zipfn) {
        LocalUnlock(hZipFN);
        zipfn = NULL;
    }
    if (hZipFN)
        hZipFN = LocalFree(hZipFN);

    if (filename) {
        LocalUnlock(hFileName);
        filename = NULL;
    }
    if (hFileName)
        hFileName = LocalFree(hFileName);
}

#else /* !MSWIN */

/******************/
/*  Main program  */
/******************/

int main(argc, argv)   /* return PK-type error code (except under VMS) */
    int argc;
    char *argv[];
{
    char *s;
    int c, error=FALSE, negative=0;


/*---------------------------------------------------------------------------
    Macintosh initialization code.
  ---------------------------------------------------------------------------*/

#ifdef MACOS
#ifdef THINK_C
#   include <console.h>
    static char *argstr[30], args[30*64];
    Point p;
    SFTypeList sfT;
    EventRecord theEvent;
    short eMask;
    SFReply fileRep;
#endif /* THINK_C */
    int a;

    for (a = 0;  a < 4;  ++a)
        rghCursor[a] = GetCursor(a+128);
    giCursor = 0;

    area.Slide = (byte *)calloc(8193, sizeof(short)+sizeof(char)+sizeof(char));
    area.shrink.Prefix_of = (short *)area.Slide;
    area.shrink.Suffix_of = area.Slide + (sizeof(short)*(HSIZE+1));
    area.shrink.Stack = area.Slide + (sizeof(short) + sizeof(char))*(HSIZE+1);

#ifdef THINK_C   
    for (a = 0;  a < 30;  ++a)
        argstr[a] = &args[a*64];
start:
    tflag=vflag=cflag=aflag=jflag=U_flag=quietflg=fflag=uflag=zflag = 0;
    local_hdr_sig[1] = central_hdr_sig[1] = end_central_sig[1] = '\0';
/*  extd_local_sig[1] = '\0';  */
    error = FALSE;

    argc = ccommand(&argv);
    SetPt(&p, 40, 40);

    SFGetFile(p, "\pSpecify ZIP file:", 0L, -1, sfT, 0L, &fileRep);
    if (fileRep.good) {
        macfstest(fileRep.vRefNum);
        ResolveMacVol(fileRep.vRefNum, &gnVRefNum, &glDirID, NULL);
        for (a = 1;  a < argc;  ++a)
            if (argv[a][0] == '-')
                BlockMove(argv[a], argstr[a], (strlen(argv[a]) > 63) ? 64 :
                   strlen(argv[a])+1);
            else
                break;
        PtoCstr((char *)fileRep.fName);
        strcpy(argstr[a], (char *)fileRep.fName);
        for (;  a < argc;  ++a)
            BlockMove(argv[a], argstr[a+1], (strlen(argv[a]) > 63) ? 64 :
               strlen(argv[a])+1);
        ++argc;
        argv = argstr;

        if (hfsflag == FALSE)  /* can't support directories:  junk pathnames */
            jflag = 1;
    }
#endif /* THINK_C */
#endif /* MACOS */

/*---------------------------------------------------------------------------
    Set signal handler for restoring echo, warn of zipfile corruption, etc.
  ---------------------------------------------------------------------------*/

    signal(SIGINT, handler);
    signal(SIGTERM, handler);
#ifdef SIGBUS
    signal(SIGBUS, handler);
#endif
#ifdef SIGSEGV
    signal(SIGSEGV, handler);
#endif

/*---------------------------------------------------------------------------
    Debugging info for checking on structure padding:
  ---------------------------------------------------------------------------*/

#ifdef DEBUG_STRUC
    printf("local_file_hdr size: %X\n",
           sizeof(local_file_hdr));
    printf("local_byte_hdr size: %X\n",
           sizeof(local_byte_hdr));
    printf("actual size of local headers: %X\n", LREC_SIZE);

    printf("central directory header size: %X\n",
           sizeof(cdir_file_hdr));
    printf("central directory byte header size: %X\n",
           sizeof(cdir_byte_hdr));
    printf("actual size of central dir headers: %X\n", CREC_SIZE);

    printf("end central dir record size: %X\n",
           sizeof(ecdir_rec));
    printf("end central dir byte record size: %X\n",
           sizeof(ec_byte_rec));
    printf("actual size of end-central-dir record: %X\n", ECREC_SIZE);
#endif /* DEBUG_STRUC */

/*---------------------------------------------------------------------------
    Put environment-variable options into the queue, then rip through any
    command-line options lurking about...
  ---------------------------------------------------------------------------*/

    envargs(&argc, &argv, ENV_UNZIP);

    while (--argc > 0 && (*++argv)[0] == '-') {
        s = argv[0] + 1;
        while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
            switch (c) {
                case ('-'):
                    ++negative;
                    break;
                case ('a'):
                    if (negative)
                        aflag = FALSE, negative = 0;
                    else
                        aflag = TRUE;
                    break;
#if 0
                case ('b'):    /* force binary mode */
                    if (negative)
                        bflag = FALSE, negative = 0;
                    else
                        bflag = TRUE;
                    break;
#endif
                case ('c'):
                    if (negative) {
                        cflag = FALSE, negative = 0;
#ifdef NATIVE
                        aflag = FALSE;
#endif
                    } else {
                        cflag = TRUE;
#ifdef NATIVE
                        aflag = TRUE;  /* so you can read it on the screen */
#endif
                    }
                    break;
                case ('d'):    /* re-create directory structure (default) */
                    if (negative)
                        jflag = TRUE, negative = 0;
                    break;
                case ('e'):    /* just ignore -e, -x options (extract) */
                    break;
                case ('f'):    /* "freshen" (extract only newer files) */
                    if (negative)
                        fflag = uflag = FALSE, negative = 0;
                    else
                        fflag = uflag = TRUE;
                    break;
                case ('j'):    /* junk pathnames/directory structure */
                    if (negative)
                        jflag = FALSE, negative = 0;
                    else
                        jflag = TRUE;
                    break;
                case ('l'):
                    if (negative) {
                        vflag = MAX(vflag-negative,0);
                        negative = 0;
                    } else
                        ++vflag;
                    break;
                case ('n'):    /* don't overwrite any files */
                    if (negative)
                        overwrite_none = FALSE, negative = 0;
                    else
                        overwrite_none = TRUE;
                    break;
                case ('o'):    /* OK to overwrite files without prompting */
                    if (negative) {
                        overwrite_all = MAX(overwrite_all-negative,0);
                        force_flag = MAX(force_flag-negative,0);
                        negative = 0;
                    } else {
                        ++overwrite_all;
                        ++force_flag;  /* (share -o for now) force to cont. */
                    }
                    break;
                case ('p'):    /* pipes:  stdout, no tranlation, no messages */
                    if (negative) {
                        cflag = FALSE;
                        quietflg = MAX(quietflg-999,0);
                        negative = 0;
                    } else {
                        cflag = TRUE;
                        quietflg += 999;
                    }
                    break;
                case ('q'):    /* quiet:  fewer comments/messages */
                    if (negative) {
                        quietflg = MAX(quietflg-negative,0);
                        negative = 0;
                    } else
                        ++quietflg;
                    break;
#ifdef DOS_OS2
                case ('s'):    /* spaces in filenames:  allow by default */
                    if (negative)
                        sflag = TRUE, negative = 0;
                    else
                        sflag = FALSE;
                    break;
#endif
                case ('t'):
                    if (negative)
                        tflag = FALSE, negative = 0;
                    else
                        tflag = TRUE;
                    break;
                case ('U'):    /* Uppercase (don't convert to all-lower) */
                    if (negative)
                        U_flag = FALSE, negative = 0;
                    else
                        U_flag = TRUE;
                    break;
                case ('u'):    /* update (extract only new and newer files) */
                    if (negative)
                        uflag = FALSE, negative = 0;
                    else
                        uflag = TRUE;
                    break;
                case ('V'):    /* Version (retain VMS/DEC-20 file versions) */
                    if (negative)
                        V_flag = FALSE, negative = 0;
                    else
                        V_flag = TRUE;
                    break;
                case ('v'):    /* verbose */
                    if (negative) {
                        vflag = MAX(vflag-negative,0);
                        negative = 0;
                    } else if (vflag)
                        ++vflag;
                    else
                        vflag = 2;
                    break;
#ifdef VMS
                case ('X'):   /* restore owner/protection info (need privs?) */
                    if (negative)
                        secinf = FALSE, negative = 0;
                    else
                        secinf = TRUE;
                    break;
#endif /* VMS */
                case ('x'):    /* extract:  default */
                    break;
                case ('z'):    /* display only the archive comment */
                    if (negative) {
                        zflag = MAX(zflag-negative,0);
                        negative = 0;
                    } else
                        ++zflag;
                    break;
                default:
                    error = TRUE;
                    break;

            } /* end switch */
        } /* end while (not end of argument string) */
    } /* end while (not done with switches) */

/*---------------------------------------------------------------------------
    Make sure we aren't trying to do too many things here.  [This seems like

⌨️ 快捷键说明

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