#ifndef _HAD_ZIPINT_H
#define _HAD_ZIPINT_H
#include <zlib.h>
#include "zip.h"
#include "zipint_alias.h"
BEGIN_EXTERN_C()
#ifndef HAVE_FSEEKO
#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
#endif
#define CENTRAL_MAGIC "PK\1\2"
#define LOCAL_MAGIC "PK\3\4"
#define EOCD_MAGIC "PK\5\6"
#define DATADES_MAGIC "PK\7\8"
#define CDENTRYSIZE 46u
#define LENTRYSIZE 30
#define MAXCOMLEN 65536
#define EOCDLEN 22
#define CDBUFSIZE (MAXCOMLEN+EOCDLEN)
#define BUFSIZE 8192
enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
ZIP_ST_ADDED, ZIP_ST_RENAMED };
#define ZIP_ZF_EOF 1
#define ZIP_ZF_DECOMP 2
#define ZIP_ZF_CRC 4
#define ZIP_GPBF_ENCRYPTED 0x0001
#define ZIP_GPBF_STRONG_ENCRYPTION 0x0040
#define ZIP_GPBF_USE_DATA_DESCRIPTOR 0x0008
struct zip_error {
int zip_err;
int sys_err;
char *str;
};
struct zip {
char *zn;
FILE *zp;
struct zip_error error;
struct zip_cdir *cdir;
char *ch_comment;
int ch_comment_len;
int nentry;
int nentry_alloc;
struct zip_entry *entry;
int nfile;
int nfile_alloc;
struct zip_file **file;
};
struct zip_file {
struct zip *za;
struct zip_error error;
int flags;
int method;
long fpos;
unsigned long bytes_left;
unsigned long cbytes_left;
unsigned long crc;
unsigned long crc_orig;
char *buffer;
z_stream *zstr;
};
struct zip_dirent {
unsigned short version_madeby;
unsigned short version_needed;
unsigned short bitflags;
unsigned short comp_method;
time_t last_mod;
unsigned int crc;
unsigned int comp_size;
unsigned int uncomp_size;
char *filename;
unsigned short filename_len;
char *extrafield;
unsigned short extrafield_len;
char *comment;
unsigned short comment_len;
unsigned short disk_number;
unsigned short int_attrib;
unsigned int ext_attrib;
unsigned int offset;
};
struct zip_cdir {
struct zip_dirent *entry;
int nentry;
unsigned int size;
unsigned int offset;
char *comment;
unsigned short comment_len;
};
struct zip_source {
zip_source_callback f;
void *ud;
};
struct zip_entry {
enum zip_state state;
struct zip_source *source;
char *ch_filename;
char *ch_comment;
int ch_comment_len;
};
extern const char * const _zip_err_str[];
extern const int _zip_nerr_str;
extern const int _zip_err_type[];
#define ZIP_ENTRY_DATA_CHANGED(x) \
((x)->state == ZIP_ST_REPLACED \
|| (x)->state == ZIP_ST_ADDED)
PHPZIPAPI void _zip_cdir_free(struct zip_cdir *);
PHPZIPAPI struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
PHPZIPAPI int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
PHPZIPAPI void _zip_dirent_finalize(struct zip_dirent *);
PHPZIPAPI void _zip_dirent_init(struct zip_dirent *);
PHPZIPAPI int _zip_dirent_read(struct zip_dirent *, FILE *,
unsigned char **, unsigned int, int, struct zip_error *);
PHPZIPAPI int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
PHPZIPAPI void _zip_entry_free(struct zip_entry *);
PHPZIPAPI void _zip_entry_init(struct zip *, int);
PHPZIPAPI struct zip_entry *_zip_entry_new(struct zip *);
PHPZIPAPI void _zip_error_clear(struct zip_error *);
PHPZIPAPI void _zip_error_copy(struct zip_error *, struct zip_error *);
PHPZIPAPI void _zip_error_fini(struct zip_error *);
PHPZIPAPI void _zip_error_get(struct zip_error *, int *, int *);
PHPZIPAPI void _zip_error_init(struct zip_error *);
PHPZIPAPI void _zip_error_set(struct zip_error *, int, int);
PHPZIPAPI const char *_zip_error_strerror(struct zip_error *);
PHPZIPAPI int _zip_file_fillbuf(void *, size_t, struct zip_file *);
PHPZIPAPI unsigned int _zip_file_get_offset(struct zip *, int);
PHPZIPAPI void _zip_free(struct zip *);
PHPZIPAPI const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
PHPZIPAPI int _zip_local_header_read(struct zip *, int);
PHPZIPAPI void *_zip_memdup(const void *, size_t, struct zip_error *);
PHPZIPAPI int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
PHPZIPAPI struct zip *_zip_new(struct zip_error *);
PHPZIPAPI unsigned short _zip_read2(unsigned char **);
PHPZIPAPI unsigned int _zip_read4(unsigned char **);
PHPZIPAPI int _zip_replace(struct zip *, int, const char *, struct zip_source *);
PHPZIPAPI int _zip_set_name(struct zip *, int, const char *);
PHPZIPAPI int _zip_unchange(struct zip *, int, int);
PHPZIPAPI void _zip_unchange_data(struct zip_entry *);
END_EXTERN_C();
#endif