Annotation of embedaddon/php/ext/zip/lib/zip.h, revision 1.1.1.2

1.1       misho       1: #ifndef _HAD_ZIP_H
                      2: #define _HAD_ZIP_H
                      3: 
                      4: /*
                      5:   zip.h -- exported declarations.
1.1.1.2 ! misho       6:   Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner
1.1       misho       7: 
                      8:   This file is part of libzip, a library to manipulate ZIP archives.
                      9:   The authors can be contacted at <libzip@nih.at>
                     10: 
                     11:   Redistribution and use in source and binary forms, with or without
                     12:   modification, are permitted provided that the following conditions
                     13:   are met:
                     14:   1. Redistributions of source code must retain the above copyright
                     15:      notice, this list of conditions and the following disclaimer.
                     16:   2. Redistributions in binary form must reproduce the above copyright
                     17:      notice, this list of conditions and the following disclaimer in
                     18:      the documentation and/or other materials provided with the
                     19:      distribution.
                     20:   3. The names of the authors may not be used to endorse or promote
                     21:      products derived from this software without specific prior
                     22:      written permission.
                     23: 
                     24:   THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
                     25:   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     26:   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
                     28:   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
                     30:   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     31:   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
                     32:   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     33:   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
                     34:   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     35: */
                     36: 
                     37: 
                     38: #include "main/php.h"
                     39: 
                     40: #ifdef PHP_WIN32
                     41: #      include "zip_win32.h"
                     42: #      ifdef PHP_ZIP_EXPORTS
                     43: #              define ZIP_EXTERN(rt) __declspec(dllexport)rt _stdcall
                     44: #      else
                     45: #              define ZIP_EXTERN(rt) rt
                     46: #      endif
                     47: #elif defined(__GNUC__) && __GNUC__ >= 4
                     48: #      define ZIP_EXTERN(rt) __attribute__ ((visibility("default"))) rt
                     49: #else
                     50: #      define ZIP_EXTERN(rt) rt
                     51: #endif
                     52: 
                     53: BEGIN_EXTERN_C()
                     54: 
1.1.1.2 ! misho      55: #include "zipconf.h"
        !            56: 
1.1       misho      57: #include <sys/types.h>
                     58: #include <stdio.h>
                     59: #include <time.h>
                     60: 
                     61: /* flags for zip_open */
                     62: 
                     63: #define ZIP_CREATE           1
                     64: #define ZIP_EXCL             2
                     65: #define ZIP_CHECKCONS        4
                     66: #define ZIP_OVERWRITE        8
                     67: 
                     68: 
                     69: /* flags for zip_name_locate, zip_fopen, zip_stat, ... */
                     70: 
                     71: #define ZIP_FL_NOCASE          1 /* ignore case on name lookup */
                     72: #define ZIP_FL_NODIR           2 /* ignore directory component */
                     73: #define ZIP_FL_COMPRESSED      4 /* read compressed data */
                     74: #define ZIP_FL_UNCHANGED       8 /* use original data, ignoring changes */
                     75: #define ZIP_FL_RECOMPRESS      16 /* force recompression of data */
1.1.1.2 ! misho      76: #define ZIP_FL_ENCRYPTED       32 /* read encrypted data
        !            77:                                     (implies ZIP_FL_COMPRESSED) */
1.1       misho      78: 
                     79: /* archive global flags flags */
                     80: 
                     81: #define ZIP_AFL_TORRENT                1 /* torrent zipped */
1.1.1.2 ! misho      82: #define ZIP_AFL_RDONLY         2 /* read only -- cannot be cleared */
        !            83: 
        !            84: 
        !            85: /* flags for compression and encryption sources */
        !            86: 
        !            87: #define ZIP_CODEC_ENCODE       1 /* compress/encrypt */
        !            88: 
1.1       misho      89: 
                     90: /* libzip error codes */
                     91: 
                     92: #define ZIP_ER_OK             0  /* N No error */
                     93: #define ZIP_ER_MULTIDISK      1  /* N Multi-disk zip archives not supported */
                     94: #define ZIP_ER_RENAME         2  /* S Renaming temporary file failed */
                     95: #define ZIP_ER_CLOSE          3  /* S Closing zip archive failed */
                     96: #define ZIP_ER_SEEK           4  /* S Seek error */
                     97: #define ZIP_ER_READ           5  /* S Read error */
                     98: #define ZIP_ER_WRITE          6  /* S Write error */
                     99: #define ZIP_ER_CRC            7  /* N CRC error */
                    100: #define ZIP_ER_ZIPCLOSED      8  /* N Containing zip archive was closed */
                    101: #define ZIP_ER_NOENT          9  /* N No such file */
                    102: #define ZIP_ER_EXISTS        10  /* N File already exists */
                    103: #define ZIP_ER_OPEN          11  /* S Can't open file */
                    104: #define ZIP_ER_TMPOPEN       12  /* S Failure to create temporary file */
                    105: #define ZIP_ER_ZLIB          13  /* Z Zlib error */
                    106: #define ZIP_ER_MEMORY        14  /* N Malloc failure */
                    107: #define ZIP_ER_CHANGED       15  /* N Entry has been changed */
                    108: #define ZIP_ER_COMPNOTSUPP   16  /* N Compression method not supported */
                    109: #define ZIP_ER_EOF           17  /* N Premature EOF */
                    110: #define ZIP_ER_INVAL         18  /* N Invalid argument */
                    111: #define ZIP_ER_NOZIP         19  /* N Not a zip archive */
                    112: #define ZIP_ER_INTERNAL      20  /* N Internal error */
                    113: #define ZIP_ER_INCONS        21  /* N Zip archive inconsistent */
                    114: #define ZIP_ER_REMOVE        22  /* S Can't remove file */
                    115: #define ZIP_ER_DELETED       23  /* N Entry has been deleted */
1.1.1.2 ! misho     116: #define ZIP_ER_ENCRNOTSUPP   24  /* N Encryption method not supported */
        !           117: #define ZIP_ER_RDONLY        25  /* N Read-only archive */ 
        !           118: #define ZIP_ER_NOPASSWD      26  /* N No password provided */
        !           119: #define ZIP_ER_WRONGPASSWD   27  /* N Wrong password provided */
1.1       misho     120: 
                    121: /* type of system error value */
                    122: 
                    123: #define ZIP_ET_NONE          0  /* sys_err unused */
                    124: #define ZIP_ET_SYS           1  /* sys_err is errno */
                    125: #define ZIP_ET_ZLIB          2  /* sys_err is zlib error code */
                    126: 
                    127: /* compression methods */
                    128: 
                    129: #define ZIP_CM_DEFAULT       -1  /* better of deflate or store */
                    130: #define ZIP_CM_STORE          0  /* stored (uncompressed) */
                    131: #define ZIP_CM_SHRINK         1  /* shrunk */
                    132: #define ZIP_CM_REDUCE_1               2  /* reduced with factor 1 */
                    133: #define ZIP_CM_REDUCE_2               3  /* reduced with factor 2 */
                    134: #define ZIP_CM_REDUCE_3               4  /* reduced with factor 3 */
                    135: #define ZIP_CM_REDUCE_4               5  /* reduced with factor 4 */
                    136: #define ZIP_CM_IMPLODE        6  /* imploded */
                    137: /* 7 - Reserved for Tokenizing compression algorithm */
                    138: #define ZIP_CM_DEFLATE        8  /* deflated */
                    139: #define ZIP_CM_DEFLATE64       9  /* deflate64 */
                    140: #define ZIP_CM_PKWARE_IMPLODE 10  /* PKWARE imploding */
                    141: /* 11 - Reserved by PKWARE */
                    142: #define ZIP_CM_BZIP2          12  /* compressed using BZIP2 algorithm */
                    143: /* 13 - Reserved by PKWARE */
                    144: #define ZIP_CM_LZMA          14  /* LZMA (EFS) */
                    145: /* 15-17 - Reserved by PKWARE */
                    146: #define ZIP_CM_TERSE         18  /* compressed using IBM TERSE (new) */
                    147: #define ZIP_CM_LZ77           19  /* IBM LZ77 z Architecture (PFS) */
                    148: #define ZIP_CM_WAVPACK       97  /* WavPack compressed data */
                    149: #define ZIP_CM_PPMD          98  /* PPMd version I, Rev 1 */
                    150: 
                    151: /* encryption methods */
                    152: 
                    153: #define ZIP_EM_NONE           0  /* not encrypted */
                    154: #define ZIP_EM_TRAD_PKWARE     1  /* traditional PKWARE encryption */
                    155: #if 0 /* Strong Encryption Header not parsed yet */
                    156: #define ZIP_EM_DES        0x6601  /* strong encryption: DES */
                    157: #define ZIP_EM_RC2_OLD    0x6602  /* strong encryption: RC2, version < 5.2 */
                    158: #define ZIP_EM_3DES_168   0x6603
                    159: #define ZIP_EM_3DES_112   0x6609
                    160: #define ZIP_EM_AES_128    0x660e
                    161: #define ZIP_EM_AES_192    0x660f
                    162: #define ZIP_EM_AES_256    0x6610
                    163: #define ZIP_EM_RC2        0x6702  /* strong encryption: RC2, version >= 5.2 */
                    164: #define ZIP_EM_RC4        0x6801
                    165: #endif
                    166: #define ZIP_EM_UNKNOWN    0xffff  /* unknown algorithm */
                    167: 
                    168: 
                    169: 
                    170: enum zip_source_cmd {
                    171:     ZIP_SOURCE_OPEN,   /* prepare for reading */
                    172:     ZIP_SOURCE_READ,   /* read data */
                    173:     ZIP_SOURCE_CLOSE,  /* reading is done */
                    174:     ZIP_SOURCE_STAT,   /* get meta information */
                    175:     ZIP_SOURCE_ERROR,  /* get error information */
                    176:     ZIP_SOURCE_FREE    /* cleanup and free resources */
                    177: };
                    178: 
1.1.1.2 ! misho     179: #define ZIP_SOURCE_ERR_LOWER   -2
        !           180: 
        !           181: #define ZIP_STAT_NAME                  0x0001
        !           182: #define ZIP_STAT_INDEX                 0x0002
        !           183: #define ZIP_STAT_SIZE                  0x0004
        !           184: #define ZIP_STAT_COMP_SIZE             0x0008
        !           185: #define ZIP_STAT_MTIME                 0x0010
        !           186: #define ZIP_STAT_CRC                   0x0020
        !           187: #define ZIP_STAT_COMP_METHOD           0x0040
        !           188: #define ZIP_STAT_ENCRYPTION_METHOD     0x0080
        !           189: #define ZIP_STAT_FLAGS                 0x0100
1.1       misho     190: 
                    191: struct zip_stat {
1.1.1.2 ! misho     192:     zip_uint64_t valid;                        /* which fields have valid values */
1.1       misho     193:     const char *name;                  /* name of the file */
1.1.1.2 ! misho     194:     zip_uint64_t index;                        /* index within archive */
        !           195:     zip_uint64_t size;                 /* size of file (uncompressed) */
        !           196:     zip_uint64_t comp_size;            /* size of file (compressed) */
1.1       misho     197:     time_t mtime;                      /* modification time */
1.1.1.2 ! misho     198:     zip_uint32_t crc;                  /* crc of file data */
        !           199:     zip_uint16_t comp_method;          /* compression method used */
        !           200:     zip_uint16_t encryption_method;    /* encryption method used */
        !           201:     zip_uint32_t flags;                        /* reserved for future use */
1.1       misho     202: };
                    203: 
                    204: struct zip;
                    205: struct zip_file;
                    206: struct zip_source;
                    207: 
1.1.1.2 ! misho     208: typedef zip_int64_t (*zip_source_callback)(void *, void *, zip_uint64_t,
        !           209:                                           enum zip_source_cmd);
        !           210: 
1.1       misho     211: 
                    212: 
1.1.1.2 ! misho     213: ZIP_EXTERN(zip_int64_t) zip_add(struct zip *, const char *, struct zip_source *);
        !           214: ZIP_EXTERN(zip_int64_t) zip_add_dir(struct zip *, const char *);
1.1       misho     215: ZIP_EXTERN(int) zip_close(struct zip *);
1.1.1.2 ! misho     216: ZIP_EXTERN(int) zip_delete(struct zip *, zip_uint64_t);
1.1       misho     217: ZIP_EXTERN(void) zip_error_clear(struct zip *);
                    218: ZIP_EXTERN(void) zip_error_get(struct zip *, int *, int *);
                    219: ZIP_EXTERN(int) zip_error_get_sys_type(int);
1.1.1.2 ! misho     220: ZIP_EXTERN(int) zip_error_to_str(char *, zip_uint64_t, int, int);
1.1       misho     221: ZIP_EXTERN(int) zip_fclose(struct zip_file *);
1.1.1.2 ! misho     222: ZIP_EXTERN(struct zip *)zip_fdopen(int, int, int *);
1.1       misho     223: ZIP_EXTERN(void) zip_file_error_clear(struct zip_file *);
                    224: ZIP_EXTERN(void) zip_file_error_get(struct zip_file *, int *, int *);
                    225: ZIP_EXTERN(const char *)zip_file_strerror(struct zip_file *);
1.1.1.2 ! misho     226: ZIP_EXTERN(struct) zip_file *zip_fopen(struct zip *, const char *, int);
        !           227: ZIP_EXTERN(struct) zip_file *zip_fopen_encrypted(struct zip *, const char *,
        !           228:                                                int, const char *);
        !           229: ZIP_EXTERN(struct zip_file *)zip_fopen_index(struct zip *, zip_uint64_t, int);
        !           230: ZIP_EXTERN(struct zip_file *)zip_fopen_index_encrypted(struct zip *,
        !           231:                                                      zip_uint64_t, int,
        !           232:                                                      const char *);
        !           233: ZIP_EXTERN(zip_int64_t) zip_fread(struct zip_file *, void *, zip_uint64_t);
1.1       misho     234: ZIP_EXTERN(const char *)zip_get_archive_comment(struct zip *, int *, int);
                    235: ZIP_EXTERN(int) zip_get_archive_flag(struct zip *, int, int);
1.1.1.2 ! misho     236: ZIP_EXTERN(const char *)zip_get_file_comment(struct zip *, zip_uint64_t,
        !           237:                                            int *, int);
        !           238: ZIP_EXTERN(const char *)zip_get_file_extra(struct zip *, zip_uint64_t,
        !           239:                                          int *, int);
        !           240: ZIP_EXTERN(const char *)zip_get_name(struct zip *, zip_uint64_t, int);
        !           241: ZIP_EXTERN(zip_uint64_t) zip_get_num_entries(struct zip *, int);
        !           242: ZIP_EXTERN(int) zip_get_num_files(struct zip *);  /* deprecated, use zip_get_num_entries instead */
1.1       misho     243: ZIP_EXTERN(int) zip_name_locate(struct zip *, const char *, int);
                    244: ZIP_EXTERN(struct zip *)zip_open(const char *, int, int *);
1.1.1.2 ! misho     245: ZIP_EXTERN(int) zip_rename(struct zip *, zip_uint64_t, const char *);
        !           246: ZIP_EXTERN(int) zip_replace(struct zip *, zip_uint64_t, struct zip_source *);
1.1       misho     247: ZIP_EXTERN(int) zip_set_archive_comment(struct zip *, const char *, int);
                    248: ZIP_EXTERN(int) zip_set_archive_flag(struct zip *, int, int);
1.1.1.2 ! misho     249: ZIP_EXTERN(int) zip_set_default_password(struct zip *, const char *);
        !           250: ZIP_EXTERN(int) zip_set_file_comment(struct zip *, zip_uint64_t,
        !           251:                                    const char *, int);
        !           252: ZIP_EXTERN(int) zip_set_file_extra(struct zip *, zip_uint64_t,
        !           253:                                  const char *, int);
        !           254: ZIP_EXTERN(struct) zip_source *zip_source_buffer(struct zip *, const void *,
        !           255:                                                zip_uint64_t, int);
        !           256: ZIP_EXTERN(struct) zip_source *zip_source_file(struct zip *, const char *,
        !           257:                                              zip_uint64_t, zip_int64_t);
        !           258: ZIP_EXTERN(struct) zip_source *zip_source_filep(struct zip *, FILE *,
        !           259:                                               zip_uint64_t, zip_int64_t);
1.1       misho     260: ZIP_EXTERN(void) zip_source_free(struct zip_source *);
                    261: ZIP_EXTERN(struct zip_source *)zip_source_function(struct zip *,
                    262:                                                  zip_source_callback, void *);
                    263: ZIP_EXTERN(struct zip_source *)zip_source_zip(struct zip *, struct zip *,
1.1.1.2 ! misho     264:                                             zip_uint64_t, int,
        !           265:                                             zip_uint64_t, zip_int64_t);
1.1       misho     266: ZIP_EXTERN(int) zip_stat(struct zip *, const char *, int, struct zip_stat *);
1.1.1.2 ! misho     267: ZIP_EXTERN(int) zip_stat_index(struct zip *, zip_uint64_t, int,
        !           268:                              struct zip_stat *);
1.1       misho     269: ZIP_EXTERN(void) zip_stat_init(struct zip_stat *);
                    270: ZIP_EXTERN(const char *)zip_strerror(struct zip *);
1.1.1.2 ! misho     271: ZIP_EXTERN(int) zip_unchange(struct zip *, zip_uint64_t);
1.1       misho     272: ZIP_EXTERN(int) zip_unchange_all(struct zip *);
                    273: ZIP_EXTERN(int) zip_unchange_archive(struct zip *);
                    274: 
                    275: END_EXTERN_C();
                    276: #endif /* _HAD_ZIP_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>