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

1.1     ! misho       1: #ifndef _HAD_ZIPINT_H
        !             2: #define _HAD_ZIPINT_H
        !             3: 
        !             4: /*
        !             5:   zipint.h -- internal declarations.
        !             6:   Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
        !             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: #include <zlib.h>
        !            38: 
        !            39: #include "zip.h"
        !            40: 
        !            41: #ifdef PHP_WIN32
        !            42: #include <windows.h>
        !            43: #include <wchar.h>
        !            44: #define _zip_rename(s, t)                                              \
        !            45:        (!MoveFileExA((s), (t),                                         \
        !            46:                     MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
        !            47: #else
        !            48: #define _zip_rename    rename
        !            49: #endif
        !            50: 
        !            51: #ifndef strcasecmp
        !            52: # define strcmpi strcasecmp 
        !            53: #endif
        !            54: 
        !            55: #ifndef HAVE_FSEEKO
        !            56: #define fseeko(s, o, w)        (fseek((s), (long int)(o), (w)))
        !            57: #endif
        !            58: #ifndef HAVE_FTELLO
        !            59: #define ftello(s)      ((long)ftell((s)))
        !            60: #endif
        !            61: 
        !            62: 
        !            63: 
        !            64: #define CENTRAL_MAGIC "PK\1\2"
        !            65: #define LOCAL_MAGIC   "PK\3\4"
        !            66: #define EOCD_MAGIC    "PK\5\6"
        !            67: #define DATADES_MAGIC "PK\7\8"
        !            68: #define TORRENT_SIG    "TORRENTZIPPED-"
        !            69: #define TORRENT_SIG_LEN        14
        !            70: #define TORRENT_CRC_LEN 8
        !            71: #define TORRENT_MEM_LEVEL      8
        !            72: #define CDENTRYSIZE         46u
        !            73: #define LENTRYSIZE          30
        !            74: #undef MAXCOMLEN /* defined as 19 on BSD for max command name */
        !            75: #define MAXCOMLEN        65536
        !            76: #define EOCDLEN             22
        !            77: #define CDBUFSIZE       (MAXCOMLEN+EOCDLEN)
        !            78: #define BUFSIZE                8192
        !            79: 
        !            80: 
        !            81: 
        !            82: /* state of change of a file in zip archive */
        !            83: 
        !            84: enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
        !            85:                 ZIP_ST_ADDED, ZIP_ST_RENAMED };
        !            86: 
        !            87: /* constants for struct zip_file's member flags */
        !            88: 
        !            89: #define ZIP_ZF_EOF     1 /* EOF reached */
        !            90: #define ZIP_ZF_DECOMP  2 /* decompress data */
        !            91: #define ZIP_ZF_CRC     4 /* compute and compare CRC */
        !            92: 
        !            93: /* directory entry: general purpose bit flags */
        !            94: 
        !            95: #define ZIP_GPBF_ENCRYPTED             0x0001  /* is encrypted */
        !            96: #define ZIP_GPBF_DATA_DESCRIPTOR       0x0008  /* crc/size after file data */
        !            97: #define ZIP_GPBF_STRONG_ENCRYPTION     0x0040  /* uses strong encryption */
        !            98: 
        !            99: /* error information */
        !           100: 
        !           101: struct zip_error {
        !           102:     int zip_err;       /* libzip error code (ZIP_ER_*) */
        !           103:     int sys_err;       /* copy of errno (E*) or zlib error code */
        !           104:     char *str;         /* string representation or NULL */
        !           105: };
        !           106: 
        !           107: /* zip archive, part of API */
        !           108: 
        !           109: struct zip {
        !           110:     char *zn;                  /* file name */
        !           111:     FILE *zp;                  /* file */
        !           112:     struct zip_error error;    /* error information */
        !           113: 
        !           114:     unsigned int flags;                /* archive global flags */
        !           115:     unsigned int ch_flags;     /* changed archive global flags */
        !           116: 
        !           117:     struct zip_cdir *cdir;     /* central directory */
        !           118:     char *ch_comment;          /* changed archive comment */
        !           119:     int ch_comment_len;                /* length of changed zip archive
        !           120:                                 * comment, -1 if unchanged */
        !           121:     int nentry;                        /* number of entries */
        !           122:     int nentry_alloc;          /* number of entries allocated */
        !           123:     struct zip_entry *entry;   /* entries */
        !           124:     int nfile;                 /* number of opened files within archive */
        !           125:     int nfile_alloc;           /* number of files allocated */
        !           126:     struct zip_file **file;    /* opened files within archive */
        !           127: };
        !           128: 
        !           129: /* file in zip archive, part of API */
        !           130: 
        !           131: struct zip_file {
        !           132:     struct zip *za;            /* zip archive containing this file */
        !           133:     struct zip_error error;    /* error information */
        !           134:     int flags;                 /* -1: eof, >0: error */
        !           135: 
        !           136:     int method;                        /* compression method */
        !           137:     off_t fpos;                        /* position within zip file (fread/fwrite) */
        !           138:     unsigned long bytes_left;  /* number of bytes left to read */
        !           139:     unsigned long cbytes_left;  /* number of bytes of compressed data left */
        !           140: 
        !           141:     unsigned long crc;         /* CRC so far */
        !           142:     unsigned long crc_orig;    /* CRC recorded in archive */
        !           143: 
        !           144:     char *buffer;
        !           145:     z_stream *zstr;
        !           146: };
        !           147: 
        !           148: /* zip archive directory entry (central or local) */
        !           149: 
        !           150: struct zip_dirent {
        !           151:     unsigned short version_madeby;     /* (c)  version of creator */
        !           152:     unsigned short version_needed;     /* (cl) version needed to extract */
        !           153:     unsigned short bitflags;           /* (cl) general purpose bit flag */
        !           154:     unsigned short comp_method;                /* (cl) compression method used */
        !           155:     time_t last_mod;                   /* (cl) time of last modification */
        !           156:     unsigned int crc;                  /* (cl) CRC-32 of uncompressed data */
        !           157:     unsigned int comp_size;            /* (cl) size of commpressed data */
        !           158:     unsigned int uncomp_size;          /* (cl) size of uncommpressed data */
        !           159:     char *filename;                    /* (cl) file name (NUL-terminated) */
        !           160:     unsigned short filename_len;       /* (cl) length of filename (w/o NUL) */
        !           161:     char *extrafield;                  /* (cl) extra field */
        !           162:     unsigned short extrafield_len;     /* (cl) length of extra field */
        !           163:     char *comment;                     /* (c)  file comment */
        !           164:     unsigned short comment_len;                /* (c)  length of file comment */
        !           165:     unsigned short disk_number;                /* (c)  disk number start */
        !           166:     unsigned short int_attrib;         /* (c)  internal file attributes */
        !           167:     unsigned int ext_attrib;           /* (c)  external file attributes */
        !           168:     unsigned int offset;               /* (c)  offset of local header  */
        !           169: };
        !           170: 
        !           171: /* zip archive central directory */
        !           172: 
        !           173: struct zip_cdir {
        !           174:     struct zip_dirent *entry;  /* directory entries */
        !           175:     int nentry;                        /* number of entries */
        !           176: 
        !           177:     unsigned int size;         /* size of central direcotry */
        !           178:     unsigned int offset;       /* offset of central directory in file */
        !           179:     char *comment;             /* zip archive comment */
        !           180:     unsigned short comment_len;        /* length of zip archive comment */
        !           181: };
        !           182: 
        !           183: 
        !           184: 
        !           185: struct zip_source {
        !           186:     zip_source_callback f;
        !           187:     void *ud;
        !           188: };
        !           189: 
        !           190: /* entry in zip archive directory */
        !           191: 
        !           192: struct zip_entry {
        !           193:     enum zip_state state;
        !           194:     struct zip_source *source;
        !           195:     char *ch_filename;
        !           196:     char *ch_comment;
        !           197:     int ch_comment_len;
        !           198: };
        !           199: 
        !           200: 
        !           201: 
        !           202: extern const char * const _zip_err_str[];
        !           203: extern const int _zip_nerr_str;
        !           204: extern const int _zip_err_type[];
        !           205: 
        !           206: 
        !           207: 
        !           208: #define ZIP_ENTRY_DATA_CHANGED(x)      \
        !           209:                        ((x)->state == ZIP_ST_REPLACED  \
        !           210:                         || (x)->state == ZIP_ST_ADDED)
        !           211: 
        !           212: 
        !           213: 
        !           214: int _zip_cdir_compute_crc(struct zip *, uLong *);
        !           215: void _zip_cdir_free(struct zip_cdir *);
        !           216: int _zip_cdir_grow(struct zip_cdir *, int, struct zip_error *);
        !           217: struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
        !           218: int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
        !           219: 
        !           220: void _zip_dirent_finalize(struct zip_dirent *);
        !           221: void _zip_dirent_init(struct zip_dirent *);
        !           222: int _zip_dirent_read(struct zip_dirent *, FILE *, unsigned char **,
        !           223:                     unsigned int *, int, struct zip_error *);
        !           224: void _zip_dirent_torrent_normalize(struct zip_dirent *);
        !           225: int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
        !           226: 
        !           227: void _zip_entry_free(struct zip_entry *);
        !           228: void _zip_entry_init(struct zip *, int);
        !           229: struct zip_entry *_zip_entry_new(struct zip *);
        !           230: 
        !           231: void _zip_error_clear(struct zip_error *);
        !           232: void _zip_error_copy(struct zip_error *, struct zip_error *);
        !           233: void _zip_error_fini(struct zip_error *);
        !           234: void _zip_error_get(struct zip_error *, int *, int *);
        !           235: void _zip_error_init(struct zip_error *);
        !           236: void _zip_error_set(struct zip_error *, int, int);
        !           237: const char *_zip_error_strerror(struct zip_error *);
        !           238: 
        !           239: int _zip_file_fillbuf(void *, size_t, struct zip_file *);
        !           240: unsigned int _zip_file_get_offset(struct zip *, int);
        !           241: 
        !           242: int _zip_filerange_crc(FILE *, off_t, off_t, uLong *, struct zip_error *);
        !           243: 
        !           244: struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *,
        !           245:                                         off_t, off_t);
        !           246: 
        !           247: void _zip_free(struct zip *);
        !           248: const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
        !           249: int _zip_local_header_read(struct zip *, int);
        !           250: void *_zip_memdup(const void *, size_t, struct zip_error *);
        !           251: int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
        !           252: struct zip *_zip_new(struct zip_error *);
        !           253: unsigned short _zip_read2(unsigned char **);
        !           254: unsigned int _zip_read4(unsigned char **);
        !           255: int _zip_replace(struct zip *, int, const char *, struct zip_source *);
        !           256: int _zip_set_name(struct zip *, int, const char *);
        !           257: int _zip_unchange(struct zip *, int, int);
        !           258: void _zip_unchange_data(struct zip_entry *);
        !           259: 
        !           260: #endif /* zipint.h */

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