Annotation of src/usr.bin/gzsig/gzip.h, Revision 1.1
1.1 ! marius 1: /*
! 2: * gzip.h
! 3: *
! 4: * Copyright (c) 2001 Dug Song <dugsong@arbor.net>
! 5: * Copyright (c) 2001 Arbor Networks, Inc.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: *
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. The names of the copyright holders may not be used to endorse or
! 17: * promote products derived from this software without specific
! 18: * prior written permission.
! 19: *
! 20: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
! 21: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
! 22: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
! 23: * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
! 24: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! 25: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
! 26: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
! 27: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
! 28: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! 29: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 30: *
! 31: * $Id: gzip.h,v 1.2 2005/04/01 16:47:31 dugsong Exp $
! 32: */
! 33:
! 34: #ifndef GZIP_H
! 35: #define GZIP_H
! 36:
! 37: /* RFC 1952 is b0rked! This is from gzip-1.2.4's algorithm.doc... */
! 38:
! 39: /* Magic header */
! 40: #define GZIP_MAGIC "\037\213"
! 41:
! 42: /* Compression methods */
! 43: #define GZIP_MSTORED 0
! 44: #define GZIP_MCOMPRESS 1
! 45: #define GZIP_MPACKED 2
! 46: #define GZIP_MLZHED 3
! 47: #define GZIP_MDEFLATE 8
! 48:
! 49: /* Flags */
! 50: #define GZIP_FTEXT 0x01
! 51: #define GZIP_FCONT 0x02 /* never set by gzip-1.2.4 */
! 52: #define GZIP_FEXTRA 0x04
! 53: #define GZIP_FNAME 0x08
! 54: #define GZIP_FCOMMENT 0x10
! 55: #define GZIP_FENCRYPT 0x20
! 56: #define GZIP_FRESERVED 0xC0
! 57:
! 58: #define GZIP_FENCRYPT_LEN 12
! 59:
! 60: #define GZSIG_ID "GS"
! 61: #define GZSIG_VERSION 1
! 62:
! 63: struct gzsig_data {
! 64: u_char version;
! 65: #ifdef COMMENT_ONLY
! 66: u_char signature[];
! 67: #endif
! 68: };
! 69:
! 70: /*
! 71: * Note: all number fields below are in little-endian byte order.
! 72: */
! 73:
! 74: struct gzip_xfield {
! 75: u_short len;
! 76: struct gzip_subfield {
! 77: u_char id[2];
! 78: u_short len;
! 79: #ifdef COMMENT_ONLY
! 80: u_char data[];
! 81: #endif
! 82: } subfield;
! 83: };
! 84:
! 85: struct gzip_header {
! 86: u_char magic[2];
! 87: u_char method;
! 88: u_char flags;
! 89: u_char mtime[4];
! 90: u_char xflags;
! 91: u_char os;
! 92: #if COMMENT_ONLY
! 93: /* Optional fields */
! 94: u_char part[2]; /* flags & GZIP_FCONT */
! 95: struct gzip_xfield xfield; /* flags & GZIP_FEXTRA */
! 96: char filename[]; /* flags & GZIP_FNAME */
! 97: char comment[]; /* flags & GZIP_FCOMMENT */
! 98: u_char encrypt_hdr[12]; /* flags & GZIP_FENCRYPT */
! 99: #endif
! 100: };
! 101:
! 102: struct gzip_trailer {
! 103: u_int32_t crc32[4];
! 104: u_int32_t size[4];
! 105: };
! 106:
! 107: #endif /* GZIP_H */