Type cleanup. --HG-- branch : HEAD
diff --git a/lib/zip_file_get_offset.c b/lib/zip_file_get_offset.c index 17a47b8..9f161a4 100644 --- a/lib/zip_file_get_offset.c +++ b/lib/zip_file_get_offset.c
@@ -50,7 +50,7 @@ On error, fills in za->error and returns 0. */ -unsigned int +zip_uint64_t _zip_file_get_offset(struct zip *za, int idx, struct zip_error *ze) { struct zip_dirent de;
diff --git a/lib/zip_fopen_index_encrypted.c b/lib/zip_fopen_index_encrypted.c index 657ed01..56697a5 100644 --- a/lib/zip_fopen_index_encrypted.c +++ b/lib/zip_fopen_index_encrypted.c
@@ -82,7 +82,7 @@ return NULL; } - if (za->nfile >= za->nfile_alloc-1) { + if (za->nfile+1 >= za->nfile_alloc) { n = za->nfile_alloc + 10; file = (struct zip_file **)realloc(za->file, n*sizeof(struct zip_file *));
diff --git a/lib/zip_get_archive_comment.c b/lib/zip_get_archive_comment.c index a82d7f2..730062d 100644 --- a/lib/zip_get_archive_comment.c +++ b/lib/zip_get_archive_comment.c
@@ -55,12 +55,12 @@ /* start guessing */ if (za->cdir->comment_type == ZIP_ENCODING_UNKNOWN) - za->cdir->comment_type = _zip_guess_encoding((const zip_uint8_t *)ret, za->cdir->comment_len); + za->cdir->comment_type = _zip_guess_encoding(ret, za->cdir->comment_len); if (((flags & ZIP_FL_NAME_STRICT) && (za->cdir->comment_type != ZIP_ENCODING_ASCII)) || (za->cdir->comment_type == ZIP_ENCODING_CP437)) { if (za->cdir->comment_converted == NULL) - za->cdir->comment_converted = (char *)_zip_cp437_to_utf8((const zip_uint8_t *)ret, za->cdir->comment_len, + za->cdir->comment_converted = _zip_cp437_to_utf8(ret, za->cdir->comment_len, &za->cdir->comment_converted_len, &za->error); ret = za->cdir->comment_converted; if (lenp != NULL)
diff --git a/lib/zip_replace.c b/lib/zip_replace.c index e8249f9..53524e6 100644 --- a/lib/zip_replace.c +++ b/lib/zip_replace.c
@@ -68,6 +68,7 @@ za_nentry_prev = za->nentry; if (idx == ZIP_UINT64_MAX) { + /* create and use new entry, used by zip_add */ if (_zip_entry_new(za) == NULL) return -1;
diff --git a/lib/zip_utf-8.c b/lib/zip_utf-8.c index ab49169..d184b17 100644 --- a/lib/zip_utf-8.c +++ b/lib/zip_utf-8.c
@@ -118,8 +118,9 @@ enum zip_encoding_type -_zip_guess_encoding(const zip_uint8_t * const name, zip_uint32_t len) +_zip_guess_encoding(const char * const _name, zip_uint32_t len) { + zip_uint8_t *name = (zip_uint8_t *)_name; zip_uint32_t i; int ret; int j, ulen; @@ -195,10 +196,11 @@ -zip_uint8_t * -_zip_cp437_to_utf8(const zip_uint8_t * const cp437buf, zip_uint32_t len, +char * +_zip_cp437_to_utf8(const char * const _cp437buf, zip_uint32_t len, zip_uint32_t *utf8_lenp, struct zip_error *error) { + zip_uint8_t *cp437buf = (zip_uint8_t *)_cp437buf; zip_uint8_t *utf8buf; zip_uint32_t buflen, i, offset; @@ -225,5 +227,5 @@ utf8buf[buflen-1] = 0; if (utf8_lenp) *utf8_lenp = buflen-1; - return utf8buf; + return (char *)utf8buf; }
diff --git a/lib/zipint.h b/lib/zipint.h index 5d8a9af..da0d2c5 100644 --- a/lib/zipint.h +++ b/lib/zipint.h
@@ -213,7 +213,7 @@ struct zip { char *zn; /* file name */ FILE *zp; /* file */ - int open_flags; /* flags passed to zip_open */ + unsigned int open_flags; /* flags passed to zip_open */ struct zip_error error; /* error information */ unsigned int flags; /* archive global flags */ @@ -223,13 +223,13 @@ struct zip_cdir *cdir; /* central directory */ char *ch_comment; /* changed archive comment */ - int ch_comment_len; /* length of changed zip archive + zip_int32_t ch_comment_len; /* length of changed zip archive * comment, -1 if unchanged */ zip_uint64_t nentry; /* number of entries */ zip_uint64_t nentry_alloc; /* number of entries allocated */ struct zip_entry *entry; /* entries */ - int nfile; /* number of opened files within archive */ - int nfile_alloc; /* number of files allocated */ + unsigned int nfile; /* number of opened files within archive */ + unsigned int nfile_alloc; /* number of files allocated */ struct zip_file **file; /* opened files within archive */ }; @@ -256,25 +256,32 @@ char *filename; /* (cl) file name (NUL-terminated) */ char *comment; /* (c) file comment */ zip_uint16_t comment_len; /* (c) length of file comment */ - char *extrafield; /* (cl) extra field */ - zip_uint16_t extrafield_len; /* (cl) length of extra field */ + char *extrafield; /* (l) extra field local header */ + zip_uint16_t extrafield_len; /* (l) length of extra field from local header*/ +#if 0 + char *cdir_extrafield; /* (c) extra field from cdir */ + zip_uint16_t cdir_extrafield_len; /* (c) length of extra field from cdir*/ + struct zip_extrafield *extra_parsed; /* parsed extra fields */ + zip_uint16_t nextra_parsed; /* number of parsed extra fields */ + zip_uint16_t nextra_parsed_alloc; /* number of parsed extra fields allocated */ +#endif }; struct zip_dirent { - unsigned short version_madeby; /* (c) version of creator */ - unsigned short version_needed; /* (cl) version needed to extract */ - unsigned short bitflags; /* (cl) general purpose bit flag */ + zip_uint16_t version_madeby; /* (c) version of creator */ + zip_uint16_t version_needed; /* (cl) version needed to extract */ + zip_uint16_t bitflags; /* (cl) general purpose bit flag */ time_t last_mod; /* (cl) time of last modification */ - unsigned int crc; /* (cl) CRC-32 of uncompressed data */ - unsigned int comp_size; /* (cl) size of compressed data */ - unsigned int uncomp_size; /* (cl) size of uncompressed data */ - unsigned short disk_number; /* (c) disk number start */ - unsigned short int_attrib; /* (c) internal file attributes */ - unsigned int ext_attrib; /* (c) external file attributes */ - unsigned int offset; /* (c) offset of local header */ - unsigned short fn_type; /* file name encoding (autorecognition) */ + zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */ + zip_uint64_t comp_size; /* (cl) size of compressed data */ + zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */ + zip_uint32_t disk_number; /* (c) disk number start */ + zip_uint16_t int_attrib; /* (c) internal file attributes */ + zip_uint32_t ext_attrib; /* (c) external file attributes */ + zip_uint64_t offset; /* (c) offset of local header */ + enum zip_encoding_type fn_type; /* file name encoding (autorecognition) */ char *filename_converted; /* file name (autoconverted) */ - unsigned short fc_type; /* file comment encoding (autorecognition) */ + enum zip_encoding_type fc_type; /* file comment encoding (autorecognition) */ char *comment_converted; /* file comment (autoconverted) */ zip_uint32_t comment_converted_len; /* file comment length (autoconverted) */ struct zip_dirent_settable settable; @@ -283,16 +290,16 @@ /* zip archive central directory */ struct zip_cdir { - struct zip_dirent *entry; /* directory entries */ - int nentry; /* number of entries */ + struct zip_dirent *entry; /* directory entries */ + unsigned int nentry; /* number of entries */ - unsigned int size; /* size of central direcotry */ - unsigned int offset; /* offset of central directory in file */ - char *comment; /* zip archive comment */ - unsigned short comment_len; /* length of zip archive comment */ - unsigned short comment_type; /* archive comment encoding (autorecognition) */ - char *comment_converted; /* archive comment (autoconverted) */ - zip_uint32_t comment_converted_len; /* archive comment length (autoconverted) */ + zip_uint64_t size; /* size of central direcotry */ + zip_uint64_t offset; /* offset of central directory in file */ + char *comment; /* zip archive comment */ + zip_uint16_t comment_len; /* length of zip archive comment */ + enum zip_encoding_type comment_type; /* archive comment encoding (autorecognition) */ + char *comment_converted; /* archive comment (autoconverted) */ + zip_uint32_t comment_converted_len; /* archive comment length (autoconverted) */ }; @@ -359,13 +366,12 @@ const char *_zip_error_strerror(struct zip_error *); int _zip_file_fillbuf(void *, size_t, struct zip_file *); -unsigned int _zip_file_get_offset(struct zip *, int, struct zip_error *); +zip_uint64_t _zip_file_get_offset(struct zip *, int, struct zip_error *); int _zip_filerange_crc(FILE *, off_t, off_t, uLong *, struct zip_error *); -enum zip_encoding_type _zip_guess_encoding(const zip_uint8_t * const, - zip_uint32_t); -zip_uint8_t *_zip_cp437_to_utf8(const zip_uint8_t * const, zip_uint32_t, +enum zip_encoding_type _zip_guess_encoding(const char * const, zip_uint32_t); +char *_zip_cp437_to_utf8(const char * const, zip_uint32_t, zip_uint32_t *, struct zip_error *error); struct zip *_zip_open(const char *, FILE *, int, int, int *); @@ -389,7 +395,7 @@ zip_int64_t _zip_replace(struct zip *, zip_uint64_t, const char *, struct zip_source *); int _zip_set_name(struct zip *, zip_uint64_t, const char *); -void _zip_u2d_time(time_t, unsigned short *, unsigned short *); +void _zip_u2d_time(time_t, zip_uint16_t *, zip_uint16_t *); int _zip_unchange(struct zip *, zip_uint64_t, int); void _zip_unchange_data(struct zip_entry *);