📄 process.c
字号:
---------------------------------------------------------------------------*/fail: if (!found) { if (uO.qflag || uO.zipinfo_mode) Info(slide, 0x401, ((char *)slide, "[%s]\n", G.zipfn)); Info(slide, 0x401, ((char *)slide, LoadFarString(CentDirEndSigNotFound))); return PK_ERR; /* failed */ }/*--------------------------------------------------------------------------- Found the signature, so get the end-central data before returning. Do any necessary machine-type conversions (byte ordering, structure padding compensation) by reading data into character array and copying to struct. ---------------------------------------------------------------------------*/ G.real_ecrec_offset = G.cur_zipfile_bufstart + (G.inptr-G.inbuf);#ifdef TEST printf("\n found end-of-central-dir signature at offset %ld (%.8lXh)\n", G.real_ecrec_offset, G.real_ecrec_offset); printf(" from beginning of file; offset %d (%.4Xh) within block\n", G.inptr-G.inbuf, G.inptr-G.inbuf);#endif if (readbuf(__G__ (char *)byterec, ECREC_SIZE+4) == 0) return PK_EOF; G.ecrec.number_this_disk = makeword(&byterec[NUMBER_THIS_DISK]); G.ecrec.num_disk_start_cdir = makeword(&byterec[NUM_DISK_WITH_START_CENTRAL_DIR]); G.ecrec.num_entries_centrl_dir_ths_disk = makeword(&byterec[NUM_ENTRIES_CENTRL_DIR_THS_DISK]); G.ecrec.total_entries_central_dir = makeword(&byterec[TOTAL_ENTRIES_CENTRAL_DIR]); G.ecrec.size_central_directory = makelong(&byterec[SIZE_CENTRAL_DIRECTORY]); G.ecrec.offset_start_central_directory = makelong(&byterec[OFFSET_START_CENTRAL_DIRECTORY]); G.ecrec.zipfile_comment_length = makeword(&byterec[ZIPFILE_COMMENT_LENGTH]); G.expect_ecrec_offset = G.ecrec.offset_start_central_directory + G.ecrec.size_central_directory; return PK_COOL;} /* end function find_ecrec() *//*****************************//* Function uz_end_central() *//*****************************/int uz_end_central(__G) /* return PK-type error code */ __GDEF{ int error = PK_COOL;/*--------------------------------------------------------------------------- Get the zipfile comment (up to 64KB long), if any, and print it out. Then position the file pointer to the beginning of the central directory and fill buffer. ---------------------------------------------------------------------------*/#ifdef WINDLL /* for comment button: */ if ((!G.fValidate) && (G.lpUserFunctions != NULL)) G.lpUserFunctions->cchComment = G.ecrec.zipfile_comment_length; if (G.ecrec.zipfile_comment_length && (uO.zflag > 0))#else /* !WINDLL */ if (G.ecrec.zipfile_comment_length && (uO.zflag > 0 || (uO.zflag == 0 &&#ifdef TIMESTAMP !uO.T_flag &&#endif !uO.qflag)))#endif /* ?WINDLL */ {#if (defined(SFX) && defined(CHEAP_SFX_AUTORUN)) if (do_string(__G__ G.ecrec.zipfile_comment_length, CHECK_AUTORUN)) {#else if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY)) {#endif Info(slide, 0x401, ((char *)slide, LoadFarString(ZipfileCommTrunc1))); error = PK_WARN; } }#if (defined(SFX) && defined(CHEAP_SFX_AUTORUN)) else if (G.ecrec.zipfile_comment_length) { if (do_string(__G__ G.ecrec.zipfile_comment_length, CHECK_AUTORUN_Q)) { Info(slide, 0x401, ((char *)slide, LoadFarString(ZipfileCommTrunc1))); error = PK_WARN; } }#endif return error;} /* end function uz_end_central() *//************************************//* Function process_cdir_file_hdr() *//************************************/int process_cdir_file_hdr(__G) /* return PK-type error code */ __GDEF{ int error;/*--------------------------------------------------------------------------- Get central directory info, save host and method numbers, and set flag for lowercase conversion of filename, depending on the OS from which the file is coming. ---------------------------------------------------------------------------*/ if ((error = get_cdir_ent(__G)) != 0) return error; G.pInfo->hostver = G.crec.version_made_by[0]; G.pInfo->hostnum = MIN(G.crec.version_made_by[1], NUM_HOSTS);/* extnum = MIN(crec.version_needed_to_extract[1], NUM_HOSTS); */ G.pInfo->lcflag = 0; if (uO.L_flag == 1) /* name conversion for monocase systems */ switch (G.pInfo->hostnum) { case FS_FAT_: /* PKZIP and zip -k store in uppercase */ case CPM_: /* like MS-DOS, right? */ case VM_CMS_: /* all caps? */ case MVS_: /* all caps? */ case TANDEM_: case TOPS20_: case VMS_: /* our Zip uses lowercase, but ASi's doesn't */ /* case Z_SYSTEM_: ? */ /* case QDOS_: ? */ G.pInfo->lcflag = 1; /* convert filename to lowercase */ break; default: /* AMIGA_, FS_HPFS_, FS_NTFS_, MAC_, UNIX_, ATARI_, */ break; /* FS_VFAT_, ATHEOS_, BEOS_ (Z_SYSTEM_), THEOS_: */ /* no conversion */ } else if (uO.L_flag > 1) /* let -LL force lower case for all names */ G.pInfo->lcflag = 1; /* do Amigas (AMIGA_) also have volume labels? */ if (IS_VOLID(G.crec.external_file_attributes) && (G.pInfo->hostnum == FS_FAT_ || G.pInfo->hostnum == FS_HPFS_ || G.pInfo->hostnum == FS_NTFS_ || G.pInfo->hostnum == ATARI_)) { G.pInfo->vollabel = TRUE; G.pInfo->lcflag = 0; /* preserve case of volume labels */ } else G.pInfo->vollabel = FALSE; /* this flag is needed to detect archives made by "PKZIP for Unix" when deciding which kind of codepage conversion has to be applied to strings (see do_string() function in fileio.c) */ G.pInfo->HasUxAtt = (G.crec.external_file_attributes & 0xffff0000L) != 0L; return PK_COOL;} /* end function process_cdir_file_hdr() *//***************************//* Function get_cdir_ent() *//***************************/int get_cdir_ent(__G) /* return PK-type error code */ __GDEF{ cdir_byte_hdr byterec;/*--------------------------------------------------------------------------- Read the next central directory entry and do any necessary machine-type conversions (byte ordering, structure padding compensation--do so by copying the data from the array into which it was read (byterec) to the usable struct (crec)). ---------------------------------------------------------------------------*/ if (readbuf(__G__ (char *)byterec, CREC_SIZE) == 0) return PK_EOF; G.crec.version_made_by[0] = byterec[C_VERSION_MADE_BY_0]; G.crec.version_made_by[1] = byterec[C_VERSION_MADE_BY_1]; G.crec.version_needed_to_extract[0] = byterec[C_VERSION_NEEDED_TO_EXTRACT_0]; G.crec.version_needed_to_extract[1] = byterec[C_VERSION_NEEDED_TO_EXTRACT_1]; G.crec.general_purpose_bit_flag = makeword(&byterec[C_GENERAL_PURPOSE_BIT_FLAG]); G.crec.compression_method = makeword(&byterec[C_COMPRESSION_METHOD]); G.crec.last_mod_dos_datetime = makelong(&byterec[C_LAST_MOD_DOS_DATETIME]); G.crec.crc32 = makelong(&byterec[C_CRC32]); G.crec.csize = makelong(&byterec[C_COMPRESSED_SIZE]); G.crec.ucsize = makelong(&byterec[C_UNCOMPRESSED_SIZE]); G.crec.filename_length = makeword(&byterec[C_FILENAME_LENGTH]); G.crec.extra_field_length = makeword(&byterec[C_EXTRA_FIELD_LENGTH]); G.crec.file_comment_length = makeword(&byterec[C_FILE_COMMENT_LENGTH]); G.crec.disk_number_start = makeword(&byterec[C_DISK_NUMBER_START]); G.crec.internal_file_attributes = makeword(&byterec[C_INTERNAL_FILE_ATTRIBUTES]); G.crec.external_file_attributes = makelong(&byterec[C_EXTERNAL_FILE_ATTRIBUTES]); /* LONG, not word! */ G.crec.relative_offset_local_header = makelong(&byterec[C_RELATIVE_OFFSET_LOCAL_HEADER]); return PK_COOL;} /* end function get_cdir_ent() *//*************************************//* Function process_local_file_hdr() *//*************************************/int process_local_file_hdr(__G) /* return PK-type error code */ __GDEF{ local_byte_hdr byterec;/*--------------------------------------------------------------------------- Read the next local file header and do any necessary machine-type con- versions (byte ordering, structure padding compensation--do so by copy- ing the data from the array into which it was read (byterec) to the usable struct (lrec)). ---------------------------------------------------------------------------*/ if (readbuf(__G__ (char *)byterec, LREC_SIZE) == 0) return PK_EOF; G.lrec.version_needed_to_extract[0] = byterec[L_VERSION_NEEDED_TO_EXTRACT_0]; G.lrec.version_needed_to_extract[1] = byterec[L_VERSION_NEEDED_TO_EXTRACT_1]; G.lrec.general_purpose_bit_flag = makeword(&byterec[L_GENERAL_PURPOSE_BIT_FLAG]); G.lrec.compression_method = makeword(&byterec[L_COMPRESSION_METHOD]); G.lrec.last_mod_dos_datetime = makelong(&byterec[L_LAST_MOD_DOS_DATETIME]); G.lrec.crc32 = makelong(&byterec[L_CRC32]); G.lrec.csize = makelong(&byterec[L_COMPRESSED_SIZE]); G.lrec.ucsize = makelong(&byterec[L_UNCOMPRESSED_SIZE]); G.lrec.filename_length = makeword(&byterec[L_FILENAME_LENGTH]); G.lrec.extra_field_length = makeword(&byterec[L_EXTRA_FIELD_LENGTH]); if ((G.lrec.general_purpose_bit_flag & 8) != 0) { /* can't trust local header, use central directory: */ G.lrec.crc32 = G.pInfo->crc; G.lrec.csize = G.pInfo->compr_size; G.lrec.ucsize = G.pInfo->uncompr_size; } G.csize = (long)G.lrec.csize; return PK_COOL;} /* end function process_local_file_hdr() */#ifdef USE_EF_UT_TIME/*******************************//* Function ef_scan_for_izux() *//*******************************/unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime, z_utim, z_uidgid) ZCONST uch *ef_buf; /* buffer containing extra field */ unsigned ef_len; /* total length of extra field */ int ef_is_c; /* flag indicating "is central extra field" */ ulg dos_mdatetime; /* last_mod_file_date_time in DOS format */ iztimes *z_utim; /* return storage: atime, mtime, ctime */ ush *z_uidgid; /* return storage: uid and gid */{ unsigned flags = 0; unsigned eb_id; unsigned eb_len; int have_new_type_eb = FALSE; long i_time; /* buffer for Unix style 32-bit integer time value */#ifdef TIME_T_TYPE_DOUBLE int ut_in_archive_sgn = 0;#else int ut_zip_unzip_compatible = FALSE;#endif/*--------------------------------------------------------------------------- This function scans the extra field for EF_TIME, EF_IZUNIX2, EF_IZUNIX, or EF_PKUNIX blocks containing Unix-style time_t (GMT) values for the entry's access, creation, and modification time. If a valid block is found, the time stamps are copied to the iztimes structure (provided the z_utim pointer is not NULL). If a IZUNIX2 block is found or the IZUNIX block contains UID/GID fields, and the z_uidgid array pointer is valid (!= NULL), the owner info is transfered as well. The presence of an EF_TIME or EF_IZUNIX2 block results in ignoring all data from probably present obsolete EF_IZUNIX blocks. If multiple blocks of the same type are found, only the information from the last block is used. The return value is a combination of the EF_TIME Flags field with an additional flag bit indicating the presence of valid UID/GID info, or 0 in case of failure. ---------------------------------------------------------------------------*/ if (ef_len == 0 || ef_buf == NULL || (z_utim == 0 && z_uidgid == NULL)) return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -