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

📄 extract.c

📁 汇编源码大全 有各种汇编源码 希望对你有所帮助
💻 C
📖 第 1 页 / 共 3 页
字号:
#endif /* S_IFLNK */    memset(outbuf, 0, OUTBUFSIZ);#ifndef DOS_OS2    if (aflag)                  /* if we have a scratchpad, clear it out */        memset(outout, 0, OUTBUFSIZ);#endif /* !DOS_OS2 */    if (tflag) {        if (!quietflg) {            fprintf(stdout, "  Testing: %-22s ", filename);            fflush(stdout);        }    } else {        if (cflag) {            /* output to stdout (copy of it) */#if defined(MACOS) || defined(AMIGA)            outfd = 1;#else /* !(MACOS || AMIGA) */            outfd = dup(1);     /* GRR: change this to #define for Mac/Amiga */#endif /* ?(MACOS || AMIGA) */#ifdef DOS_OS2            if (!aflag)                setmode(outfd, O_BINARY);#endif /* DOS_OS2 */#ifdef VMS            if (create_output_file())   /* VMS version required for stdout! */                return 50;      /* 50:  disk full (?) */#endif        } else#ifdef S_IFLNK        if (!symlnk)    /* symlink() takes care of file creation */#endif /* !S_IFLNK */        {            if (create_output_file())                return 50;      /* 50:  disk full (?) */        }    } /* endif (!tflag) *//*---------------------------------------------------------------------------    Unpack the file.  ---------------------------------------------------------------------------*/    switch (lrec.compression_method) {    case STORED:        if (!tflag && QCOND) {            fprintf(stdout, " Extracting: %-22s ", filename);            if (cflag)                fprintf(stdout, "\n");            fflush(stdout);        }#ifdef S_IFLNK        /*         * If file came from Unix and is a symbolic link and we are extracting         * to disk, allocate a storage area, put the data in it, and create the         * link.  Since we know it's a symbolic link to start with, shouldn't         * have to worry about overflowing unsigned ints with unsigned longs.         * (This doesn't do anything for compressed symlinks, but that can be         * added later...it also doesn't set the time or permissions of the         * link, but does anyone really care?)         */        if (symlnk) {#if defined(MTS) || defined(MACOS)            fprintf(stdout, "\n  warning:  symbolic link ignored\n");            error = 1;          /* 1:  warning error */#else /* !(MTS || MACOS) */            char *orig = (char *)malloc((unsigned)lrec.uncompressed_size+1);            char *p = orig;            while (ReadByte(&b))                *p++ = b;            *p = 0;   /* terminate string */            UpdateCRC((unsigned char *)orig, p-orig);            if (symlink(orig, filename))                if ((errno == EEXIST) && overwrite_all) {  /* OK to overwrite */                    unlink(filename);                    if (symlink(orig, filename))                        perror("symlink error");                } else                    perror("symlink error");            free(orig);#endif /* ?(MTS || MACOS) */        } else#endif /* S_IFLNK */        while (ReadByte(&b) && !disk_full)            OUTB(b)        break;    case SHRUNK:        if (!tflag && QCOND) {            fprintf(stdout, "UnShrinking: %-22s ", filename);            if (cflag)                fprintf(stdout, "\n");            fflush(stdout);        }#ifdef S_IFLNK   /* !!! This code needs to be added to unShrink, etc. !!! */        if (symlnk) {            fprintf(stdout, "\n  warning:  symbolic link ignored\n");            error = 1;          /* 1:  warning error */        }#endif /* S_IFLNK */        unShrink();        break;    case REDUCED1:    case REDUCED2:    case REDUCED3:    case REDUCED4:        if (!tflag && QCOND) {            fprintf(stdout, "  Expanding: %-22s ", filename);            if (cflag)                fprintf(stdout, "\n");            fflush(stdout);        }#ifdef S_IFLNK   /* !!! This code needs to be added to unShrink, etc. !!! */        if (symlnk) {            fprintf(stdout, "\n  warning:  symbolic link ignored\n");            error = 1;          /* 1:  warning error */        }#endif /* S_IFLNK */        unReduce();        break;    case IMPLODED:        if (!tflag && QCOND) {            fprintf(stdout, "  Exploding: %-22s ", filename);            if (cflag)                fprintf(stdout, "\n");            fflush(stdout);        }#ifdef S_IFLNK   /* !!! This code needs to be added to unShrink, etc. !!! */        if (symlnk) {            fprintf(stdout, "\n  warning:  symbolic link ignored\n");            error = 1;          /* 1:  warning error */        }#endif /* S_IFLNK */        unImplode();        break;#ifdef INFLATE    case DEFLATED:        if (!tflag && QCOND) {            fprintf(stdout, "  Deflating: %-22s ", filename);            if (cflag)                fprintf(stdout, "\n");            fflush(stdout);        }#ifdef S_IFLNK   /* !!! This code needs to be added to unShrink, etc. !!! */        if (symlnk) {            fprintf(stdout, "\n  warning:  symbolic link ignored\n");            error = 1;          /* 1:  warning error */        }#endif /* S_IFLNK */        inflate();        break;#endif /* INFLATE */    default:   /* should never get to this point */        fprintf(stderr, "%s:  unknown compression method\n", filename);        /* close and delete file before return? */        return 1;               /* 1:  warning error */    } /* end switch (compression method) */    if (disk_full) {            /* set by FlushOutput()/OUTB() macro */        if (disk_full > 1)            return 50;          /* 50:  disk full */        error = 1;              /* 1:  warning error */    }/*---------------------------------------------------------------------------    Write the last partial buffer, if any; set the file date and time; and    close the file (not necessarily in that order).  Then make sure CRC came    out OK and print result.  [Note:  crc32val must be logical-ANDed with    32 bits of 1's, or else machines whose longs are bigger than 32 bits will    report bad CRCs (because of the upper bits being filled with 1's instead    of 0's).]  ---------------------------------------------------------------------------*/#ifdef S_IFLNK    if (!symlnk) {#endif /* S_IFLNK */    if (!disk_full && FlushOutput())        if (disk_full > 1)            return 50;          /* 50:  disk full */        else {                  /* disk_full == 1 */            fprintf(stderr, "%s:  probably corrupt\n", filename);            error = 1;          /* 1:  warning error */        }    if (!tflag)#ifdef VMS        CloseOutputFile();#else /* !VMS */#ifdef MTS                      /* MTS can't set file time */        close(outfd);#else /* !MTS */        set_file_time_and_close();#endif /* ?MTS */#endif /* ?VMS */#ifdef S_IFLNK    } /* endif (!symlnk) */#endif /* S_IFLNK */    if ((crc32val = ((~crc32val) & 0xFFFFFFFFL)) != lrec.crc32) {        /* if quietflg is set, we haven't output the filename yet:  do it */        if (quietflg)            printf("%-22s: ", filename);        fprintf(stdout, " Bad CRC %08lx  (should be %08lx)\n", crc32val,                lrec.crc32);        error = 1;              /* 1:  warning error */    } else if (tflag) {        if (!quietflg)            fprintf(stdout, " OK\n");    } else {        if (QCOND && !error)            fprintf(stdout, "\n");    }    return error;}       /* end function extract_or_test_member() */#ifdef CRYPT/*******************************//*  Function decrypt_member()  *//*******************************/static int decrypt_member()   /* return 10 if out of memory or can't get */{                             /*  tty; -1 if bad password; 0 if checks out */    UWORD b, c;    byte *p;    int n, t;    /* set keys */    if (key == NULL && ((key = malloc(PWLEN+1)) == NULL ||         getp("Enter password: ", key, PWLEN+1) == NULL))        return 10;        /* what to return here? */    init_keys(key);    /* decrypt current buffer contents, set flag to re-read if necessary */    for (n = incnt > csize ? (int)csize : incnt, p = inptr; n--; p++)        *p = DECRYPT(*p);    /* decrypt header */    for (c = 0; c < 10; c++)        ReadByte(&b);    ReadByte(&c);    ReadByte(&b);#ifdef CRYPT_DEBUG    printf("   lrec.crc = %08lx   crec.crc = [ ? ]   pInfo->ExtLocHdr = %s\n",      lrec.crc32, /* pInfo->crc, */ pInfo->ExtLocHdr? "true":"false");    printf("   incnt = %d   unzip offset into zipfile = %ld\n", incnt,      cur_zipfile_bufstart+(inptr-inbuf));    printf("   (c | (b<<8)) = %04x   (crc >> 16) = %04x   lrec.time = %04x\n",      (UWORD)(c | (b<<8)), (UWORD)(lrec.crc32 >> 16), lrec.last_mod_file_time);#endif /* CRYPT_DEBUG */    /* same test as in zipbare() in crypt.c */    if ((UWORD)(c | (b<<8)) != (pInfo->ExtLocHdr? lrec.last_mod_file_time :        (UWORD)(lrec.crc32 >> 16)))        return -1;    return 0;}#endif /* CRYPT */

⌨️ 快捷键说明

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