summaryrefslogtreecommitdiff
path: root/ext/zip/lib/zipint.h
diff options
context:
space:
mode:
authorJerome Loyet <fat@php.net>2012-09-27 23:57:06 +0200
committerJerome Loyet <fat@php.net>2012-09-27 23:57:06 +0200
commit0bffdd723fb1acbc8b1ef62768fa2f33c2d02bbc (patch)
tree04bbcd1a5da16ea5246d39c1bcae45b9eb67c526 /ext/zip/lib/zipint.h
parent1fa8ecd082607858084994ad7081ef06e37db5f5 (diff)
parent6a50a8640c562a41d90c7ab46affa767b97d2621 (diff)
downloadphp-git-0bffdd723fb1acbc8b1ef62768fa2f33c2d02bbc.tar.gz
Merge branch 'PHP-5.4' of git.php.net:php-src into PHP-5.4
* 'PHP-5.4' of git.php.net:php-src: (367 commits) fix unix/win dir separators Fix bug #63173: Crash when invoking invalid array callback Correct the test summary Fixed bug #60723 (error_log error time has changed to UTC ignoring default timezo) Fixed bug #60723 (error_log error time has changed to UTC ignoring default timezo) Avoid calling select if maxfd returned by curl_multi_fdset is -1 Fixing NEWS file Fixed bug #63111 (is_callable() lies for abstract static method) updated lib versions Fix folding fix bug #63015 (Incorrect arginfo for DOMErrorHandler) Bug #63000: MCAST_JOIN_GROUP on OSX is broken Fixed bug #61442 (exception threw in __autoload can not be catched) Merging PR #116 Merged GitHub PR #190: Support for the HTTP PATCH method in CLI webserver updated libary versions split tests for the new zlib version on win Fixed Bug #63103 (ext\curl\tests\bug62839.phpt broken) update news Support building PHP with the native client toolchain. ...
Diffstat (limited to 'ext/zip/lib/zipint.h')
-rw-r--r--ext/zip/lib/zipint.h148
1 files changed, 116 insertions, 32 deletions
diff --git a/ext/zip/lib/zipint.h b/ext/zip/lib/zipint.h
index d72ed144d4..ea21dddcd4 100644
--- a/ext/zip/lib/zipint.h
+++ b/ext/zip/lib/zipint.h
@@ -3,7 +3,7 @@
/*
zipint.h -- internal declarations.
- Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <libzip@nih.at>
@@ -38,12 +38,37 @@
#include "zip.h"
+#ifndef HAVE_FSEEKO
+#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
+#endif
+
+#ifndef HAVE_FTELLO
+#define ftello(s) ((long)ftell((s)))
+#endif
+
+#ifndef PHP_WIN32
+#ifndef HAVE_MKSTEMP
+int _zip_mkstemp(char *);
+#define mkstemp _zip_mkstemp
+#endif
+#endif
+
#ifdef PHP_WIN32
#include <windows.h>
#include <wchar.h>
#define _zip_rename(s, t) \
(!MoveFileExA((s), (t), \
MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
+
+/* for dup(), close(), etc. */
+#include <io.h>
+
+#if !defined(HAVE_OPEN)
+#if defined(HAVE__OPEN)
+#define open(a, b, c) _open((a), (b))
+#endif
+#endif
+
#else
#define _zip_rename rename
#endif
@@ -52,12 +77,6 @@
# define strcmpi strcasecmp
#endif
-#ifndef HAVE_FSEEKO
-#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
-#endif
-#ifndef HAVE_FTELLO
-#define ftello(s) ((long)ftell((s)))
-#endif
@@ -73,22 +92,77 @@
#define LENTRYSIZE 30
#undef MAXCOMLEN /* defined as 19 on BSD for max command name */
#define MAXCOMLEN 65536
+#define MAXEXTLEN 65536
#define EOCDLEN 22
#define CDBUFSIZE (MAXCOMLEN+EOCDLEN)
#define BUFSIZE 8192
+/* This section contains API that won't materialize like this. It's
+ placed in the internal section, pending cleanup. */
+
+typedef struct zip_source *(*zip_compression_implementation)(struct zip *,
+ struct zip_source *,
+ zip_uint16_t, int);
+typedef struct zip_source *(*zip_encryption_implementation)(struct zip *,
+ struct zip_source *,
+ zip_uint16_t, int,
+ const char *);
+
+ZIP_EXTERN(zip_compression_implementation) zip_get_compression_implementation(
+ zip_uint16_t);
+ZIP_EXTERN(zip_encryption_implementation) zip_get_encryption_implementation(
+ zip_uint16_t);
+
+
+
+
+/* This section contains API that is of limited use until support for
+ user-supplied compression/encryption implementation is finished.
+ Thus we will keep it private for now. */
+
+typedef zip_int64_t (*zip_source_layered_callback)(struct zip_source *, void *,
+ void *, zip_uint64_t,
+ enum zip_source_cmd);
+
+ZIP_EXTERN(void) zip_source_close(struct zip_source *);
+ZIP_EXTERN(struct zip_source *)zip_source_crc(struct zip *, struct zip_source *,
+ int);
+ZIP_EXTERN(struct zip_source *)zip_source_deflate(struct zip *,
+ struct zip_source *,
+ zip_uint16_t, int);
+ZIP_EXTERN(void) zip_source_error(struct zip_source *, int *, int *);
+ZIP_EXTERN(struct zip_source *)zip_source_layered(struct zip *,
+ struct zip_source *,
+ zip_source_layered_callback,
+ void *);
+ZIP_EXTERN(int) zip_source_open(struct zip_source *);
+ZIP_EXTERN(struct zip_source *)zip_source_pkware(struct zip *,
+ struct zip_source *,
+ zip_uint16_t, int,
+ const char *);
+ZIP_EXTERN(zip_int64_t) zip_source_read(struct zip_source *, void *,
+ zip_uint64_t);
+ZIP_EXTERN(int) zip_source_stat(struct zip_source *, struct zip_stat *);
+
+
+/* This function will probably remain private. It is not needed to
+ implement compression/encryption routines. (We should probably
+ rename it to _zip_source_pop.) */
+
+ZIP_EXTERN(struct zip_source *)zip_source_pop(struct zip_source *);
+
+
+
/* state of change of a file in zip archive */
enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
ZIP_ST_ADDED, ZIP_ST_RENAMED };
-/* constants for struct zip_file's member flags */
+/* error source for layered sources */
-#define ZIP_ZF_EOF 1 /* EOF reached */
-#define ZIP_ZF_DECOMP 2 /* decompress data */
-#define ZIP_ZF_CRC 4 /* compute and compare CRC */
+enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL };
/* directory entry: general purpose bit flags */
@@ -114,12 +188,14 @@ struct zip {
unsigned int flags; /* archive global flags */
unsigned int ch_flags; /* changed archive global flags */
+ char *default_password; /* password used when no other supplied */
+
struct zip_cdir *cdir; /* central directory */
char *ch_comment; /* changed archive comment */
int ch_comment_len; /* length of changed zip archive
* comment, -1 if unchanged */
- int nentry; /* number of entries */
- int nentry_alloc; /* number of entries allocated */
+ 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 */
@@ -131,18 +207,8 @@ struct zip {
struct zip_file {
struct zip *za; /* zip archive containing this file */
struct zip_error error; /* error information */
- int flags; /* -1: eof, >0: error */
-
- int method; /* compression method */
- off_t fpos; /* position within zip file (fread/fwrite) */
- unsigned long bytes_left; /* number of bytes left to read */
- unsigned long cbytes_left; /* number of bytes of compressed data left */
-
- unsigned long crc; /* CRC so far */
- unsigned long crc_orig; /* CRC recorded in archive */
-
- char *buffer;
- z_stream *zstr;
+ int eof;
+ struct zip_source *src; /* data source */
};
/* zip archive directory entry (central or local) */
@@ -183,8 +249,14 @@ struct zip_cdir {
struct zip_source {
- zip_source_callback f;
+ struct zip_source *src;
+ union {
+ zip_source_callback f;
+ zip_source_layered_callback l;
+ } cb;
void *ud;
+ enum zip_les error_source;
+ int is_open;
};
/* entry in zip archive directory */
@@ -193,6 +265,8 @@ struct zip_entry {
enum zip_state state;
struct zip_source *source;
char *ch_filename;
+ char *ch_extra;
+ int ch_extra_len;
char *ch_comment;
int ch_comment_len;
};
@@ -209,6 +283,8 @@ extern const int _zip_err_type[];
((x)->state == ZIP_ST_REPLACED \
|| (x)->state == ZIP_ST_ADDED)
+#define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY)
+
int _zip_cdir_compute_crc(struct zip *, uLong *);
@@ -220,7 +296,7 @@ int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
void _zip_dirent_finalize(struct zip_dirent *);
void _zip_dirent_init(struct zip_dirent *);
int _zip_dirent_read(struct zip_dirent *, FILE *, unsigned char **,
- unsigned int *, int, struct zip_error *);
+ zip_uint32_t *, int, struct zip_error *);
void _zip_dirent_torrent_normalize(struct zip_dirent *);
int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
@@ -234,6 +310,7 @@ void _zip_error_fini(struct zip_error *);
void _zip_error_get(struct zip_error *, int *, int *);
void _zip_error_init(struct zip_error *);
void _zip_error_set(struct zip_error *, int, int);
+void _zip_error_set_from_source(struct zip_error *, struct zip_source *);
const char *_zip_error_strerror(struct zip_error *);
int _zip_file_fillbuf(void *, size_t, struct zip_file *);
@@ -241,20 +318,27 @@ unsigned int _zip_file_get_offset(struct zip *, int);
int _zip_filerange_crc(FILE *, off_t, off_t, uLong *, struct zip_error *);
+struct zip *_zip_open(const char *, FILE *, int, int, int *);
+
struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *,
- off_t, off_t);
+ zip_uint64_t, zip_int64_t, int,
+ const struct zip_stat *);
+struct zip_source *_zip_source_new(struct zip *);
+int _zip_changed(struct zip *, int *);
void _zip_free(struct zip *);
-const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
+const char *_zip_get_name(struct zip *, zip_uint64_t, int, struct zip_error *);
int _zip_local_header_read(struct zip *, int);
void *_zip_memdup(const void *, size_t, struct zip_error *);
int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
struct zip *_zip_new(struct zip_error *);
unsigned short _zip_read2(unsigned char **);
unsigned int _zip_read4(unsigned char **);
-int _zip_replace(struct zip *, int, const char *, struct zip_source *);
-int _zip_set_name(struct zip *, int, const char *);
-int _zip_unchange(struct zip *, int, int);
+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 *);
+int _zip_unchange(struct zip *, zip_uint64_t, int);
void _zip_unchange_data(struct zip_entry *);
#endif /* zipint.h */