unzip.c (libextractor-1.10) | : | unzip.c (libextractor-1.11) | ||
---|---|---|---|---|
skipping to change at line 327 | skipping to change at line 327 | |||
/** | /** | |||
* Is the file encrypted? | * Is the file encrypted? | |||
*/ | */ | |||
int encrypted; | int encrypted; | |||
}; | }; | |||
/** | /** | |||
* Read a byte from a gz_stream; update next_in and avail_in. Return EOF | * Read a byte from a gz_stream; update next_in and avail_in. Return EOF | |||
* for end of file. | * for end of file. | |||
* IN assertion: the stream s has been sucessfully opened for reading. | * IN assertion: the stream s has been successfully opened for reading. | |||
* | * | |||
* @param ffd functions for performing IO operations | * @param ffd functions for performing IO operations | |||
* @param pi where to store the byte that was read | * @param pi where to store the byte that was read | |||
* @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF | * @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF | |||
*/ | */ | |||
static int | static int | |||
read_byte_from_ffd (const struct FileFuncDefs *ffd, | read_byte_from_ffd (const struct FileFuncDefs *ffd, | |||
int *pi) | int *pi) | |||
{ | { | |||
unsigned char c; | unsigned char c; | |||
if (1 != ZREAD (*ffd, &c, 1)) | if (1 != ZREAD (*ffd, &c, 1)) | |||
return EXTRACTOR_UNZIP_EOF; | return EXTRACTOR_UNZIP_EOF; | |||
*pi = (int) c; | *pi = (int) c; | |||
return EXTRACTOR_UNZIP_OK; | return EXTRACTOR_UNZIP_OK; | |||
} | } | |||
/** | /** | |||
* Read a short (2 bytes) from a gz_stream; update next_in and avail_in. Return EOF | * Read a short (2 bytes) from a gz_stream; update next_in and avail_in. Return EOF | |||
* for end of file. | * for end of file. | |||
* IN assertion: the stream s has been sucessfully opened for reading. | * IN assertion: the stream s has been successfully opened for reading. | |||
* | * | |||
* @param ffd functions for performing IO operations | * @param ffd functions for performing IO operations | |||
* @param pi where to store the short that was read | * @param pi where to store the short that was read | |||
* @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF | * @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF | |||
*/ | */ | |||
static int | static int | |||
read_short_from_ffd (const struct FileFuncDefs *ffd, | read_short_from_ffd (const struct FileFuncDefs *ffd, | |||
uLong *pX) | uLong *pX) | |||
{ | { | |||
uLong x; | uLong x; | |||
skipping to change at line 376 | skipping to change at line 376 | |||
if (EXTRACTOR_UNZIP_OK != (err = read_byte_from_ffd (ffd, &i))) | if (EXTRACTOR_UNZIP_OK != (err = read_byte_from_ffd (ffd, &i))) | |||
return err; | return err; | |||
x += ((uLong) i) << 8; | x += ((uLong) i) << 8; | |||
*pX = x; | *pX = x; | |||
return err; | return err; | |||
} | } | |||
/** | /** | |||
* Read a 'long' (4 bytes) from a gz_stream; update next_in and avail_in. Return EOF | * Read a 'long' (4 bytes) from a gz_stream; update next_in and avail_in. Return EOF | |||
* for end of file. | * for end of file. | |||
* IN assertion: the stream s has been sucessfully opened for reading. | * IN assertion: the stream s has been successfully opened for reading. | |||
* | * | |||
* @param ffd functions for performing IO operations | * @param ffd functions for performing IO operations | |||
* @param pi where to store the long that was read | * @param pi where to store the long that was read | |||
* @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF | * @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF | |||
*/ | */ | |||
static int | static int | |||
read_long_from_ffd (const struct FileFuncDefs *ffd, | read_long_from_ffd (const struct FileFuncDefs *ffd, | |||
uLong *pX) | uLong *pX) | |||
{ | { | |||
uLong x; | uLong x; | |||
skipping to change at line 426 | skipping to change at line 426 | |||
#define CASESENSITIVITYDEFAULTVALUE 1 | #define CASESENSITIVITYDEFAULTVALUE 1 | |||
#endif | #endif | |||
/** | /** | |||
* Compare two filenames (fileName1, fileName2). | * Compare two filenames (fileName1, fileName2). | |||
* | * | |||
* @param filename1 name of first file | * @param filename1 name of first file | |||
* @param filename2 name of second file | * @param filename2 name of second file | |||
* @param iCaseSensitivity, use 1 for case sensitivity (like strcmp); | * @param iCaseSensitivity, use 1 for case sensitivity (like strcmp); | |||
* 2 for no case sensitivity (like strcmpi or strcasecmp); or | * 2 for no case sensitivity (like strcmpi or strcasecmp); or | |||
* 0 for defaut of your operating system (like 1 on Unix, 2 on Windows) | * 0 for default of your operating system (like 1 on Unix, 2 on Windows) | |||
* @return 0 if names are equal | * @return 0 if names are equal | |||
*/ | */ | |||
static int | static int | |||
EXTRACTOR_common_unzip_string_file_name_compare (const char*fileName1, | EXTRACTOR_common_unzip_string_file_name_compare (const char*fileName1, | |||
const char*fileName2, | const char*fileName2, | |||
int iCaseSensitivity) | int iCaseSensitivity) | |||
{ | { | |||
if (0 == iCaseSensitivity) | if (0 == iCaseSensitivity) | |||
iCaseSensitivity = CASESENSITIVITYDEFAULTVALUE; | iCaseSensitivity = CASESENSITIVITYDEFAULTVALUE; | |||
if (1 == iCaseSensitivity) | if (1 == iCaseSensitivity) | |||
skipping to change at line 721 | skipping to change at line 721 | |||
* @return NULL on error | * @return NULL on error | |||
*/ | */ | |||
static struct EXTRACTOR_UnzipFile * | static struct EXTRACTOR_UnzipFile * | |||
unzip_open_using_ffd (struct FileFuncDefs *ffd) | unzip_open_using_ffd (struct FileFuncDefs *ffd) | |||
{ | { | |||
struct EXTRACTOR_UnzipFile us; | struct EXTRACTOR_UnzipFile us; | |||
struct EXTRACTOR_UnzipFile *file; | struct EXTRACTOR_UnzipFile *file; | |||
uLong central_pos; | uLong central_pos; | |||
uLong uL; | uLong uL; | |||
uLong number_disk; /* number of the current dist, used for | uLong number_disk; /* number of the current dist, used for | |||
spaning ZIP, unsupported, always 0*/ | spanning ZIP, unsupported, always 0*/ | |||
uLong number_disk_with_CD; /* number of the disk with central dir, used | uLong number_disk_with_CD; /* number of the disk with central dir, used | |||
for spaning ZIP, unsupported, always 0*/ | for spanning ZIP, unsupported, always 0*/ | |||
uLong number_entry_CD; /* total number of entries in | uLong number_entry_CD; /* total number of entries in | |||
the central dir | the central dir | |||
(same than number_entry on nospan) */ | (same than number_entry on nospan) */ | |||
memset (&us, 0, sizeof(us)); | memset (&us, 0, sizeof(us)); | |||
us.z_filefunc = *ffd; | us.z_filefunc = *ffd; | |||
central_pos = locate_central_directory (&us.z_filefunc); | central_pos = locate_central_directory (&us.z_filefunc); | |||
if (0 == central_pos) | if (0 == central_pos) | |||
return NULL; | return NULL; | |||
if (0 != ZSEEK (us.z_filefunc, | if (0 != ZSEEK (us.z_filefunc, | |||
skipping to change at line 941 | skipping to change at line 941 | |||
return err; | return err; | |||
} | } | |||
/** | /** | |||
* Try locate the file szFileName in the zipfile. | * Try locate the file szFileName in the zipfile. | |||
* | * | |||
* @param file zipfile to manipulate | * @param file zipfile to manipulate | |||
* @param szFileName name to find | * @param szFileName name to find | |||
* @param iCaseSensitivity, use 1 for case sensitivity (like strcmp); | * @param iCaseSensitivity, use 1 for case sensitivity (like strcmp); | |||
* 2 for no case sensitivity (like strcmpi or strcasecmp); or | * 2 for no case sensitivity (like strcmpi or strcasecmp); or | |||
* 0 for defaut of your operating system (like 1 on Unix, 2 on Windows) | * 0 for default of your operating system (like 1 on Unix, 2 on Windows) | |||
* @return #EXTRACTOR_UNZIP_OK if the file is found. It becomes the current file . | * @return #EXTRACTOR_UNZIP_OK if the file is found. It becomes the current file . | |||
* #EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the file is not found | * #EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the file is not found | |||
*/ | */ | |||
int | int | |||
EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file, | EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file, | |||
const char *szFileName, | const char *szFileName, | |||
int iCaseSensitivity) | int iCaseSensitivity) | |||
{ | { | |||
int err; | int err; | |||
/* We remember the 'current' position in the file so that we can jump | /* We remember the 'current' position in the file so that we can jump | |||
skipping to change at line 1008 | skipping to change at line 1008 | |||
file->cur_file_info = cur_file_infoSaved; | file->cur_file_info = cur_file_infoSaved; | |||
file->cur_file_info_internal = cur_file_info_internalSaved; | file->cur_file_info_internal = cur_file_info_internalSaved; | |||
return err; | return err; | |||
} | } | |||
/** | /** | |||
* Read bytes from the current file (must have been opened). | * Read bytes from the current file (must have been opened). | |||
* | * | |||
* @param buf contain buffer where data must be copied | * @param buf contain buffer where data must be copied | |||
* @param len the size of buf. | * @param len the size of buf. | |||
* @return the number of byte copied if somes bytes are copied | * @return the number of byte copied if some bytes are copied | |||
* 0 if the end of file was reached | * 0 if the end of file was reached | |||
* <0 with error code if there is an error | * <0 with error code if there is an error | |||
* (#EXTRACTOR_UNZIP_ERRNO for IO error, or zLib error for uncompress err or) | * (#EXTRACTOR_UNZIP_ERRNO for IO error, or zLib error for uncompress err or) | |||
*/ | */ | |||
ssize_t | ssize_t | |||
EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file, | EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file, | |||
void *buf, | void *buf, | |||
size_t len) | size_t len) | |||
{ | { | |||
int err = EXTRACTOR_UNZIP_OK; | int err = EXTRACTOR_UNZIP_OK; | |||
End of changes. 8 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added |