1 /* 2 * Copyright 2012 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 /* 17 Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. 18 19 Redistribution and use in source and binary forms, with or without 20 modification, are permitted provided that the following conditions are met: 21 22 1. Redistributions of source code must retain the above copyright notice, 23 this list of conditions and the following disclaimer. 24 25 2. Redistributions in binary form must reproduce the above copyright 26 notice, this list of conditions and the following disclaimer in 27 the documentation and/or other materials provided with the distribution. 28 29 3. The names of the authors may not be used to endorse or promote products 30 derived from this software without specific prior written permission. 31 32 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 33 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 34 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 35 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 36 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 37 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 38 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 39 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 40 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 41 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 */ 43 /* 44 * This program is based on zlib-1.1.3, so all credit should go authors 45 * Jean-loup Gailly([email protected]) and Mark Adler([email protected]) 46 * and contributors of zlib. 47 */ 48 package org.jboss.netty.util.internal.jzlib; 49 50 public final class JZlib { 51 52 // wrapper types 53 public static final Enum<?> W_NONE = WrapperType.NONE; 54 public static final Enum<?> W_ZLIB = WrapperType.ZLIB; 55 public static final Enum<?> W_GZIP = WrapperType.GZIP; 56 public static final Enum<?> W_ZLIB_OR_NONE = WrapperType.ZLIB_OR_NONE; 57 58 // compression levels 59 public static final int Z_NO_COMPRESSION = 0; 60 public static final int Z_BEST_SPEED = 1; 61 public static final int Z_BEST_COMPRESSION = 9; 62 public static final int Z_DEFAULT_COMPRESSION = -1; 63 64 // compression strategy 65 public static final int Z_FILTERED = 1; 66 public static final int Z_HUFFMAN_ONLY = 2; 67 public static final int Z_DEFAULT_STRATEGY = 0; 68 69 // flush method 70 public static final int Z_NO_FLUSH = 0; 71 public static final int Z_PARTIAL_FLUSH = 1; 72 public static final int Z_SYNC_FLUSH = 2; 73 public static final int Z_FULL_FLUSH = 3; 74 public static final int Z_FINISH = 4; 75 76 // return codes 77 public static final int Z_OK = 0; 78 public static final int Z_STREAM_END = 1; 79 public static final int Z_NEED_DICT = 2; 80 public static final int Z_ERRNO = -1; 81 public static final int Z_STREAM_ERROR = -2; 82 public static final int Z_DATA_ERROR = -3; 83 public static final int Z_MEM_ERROR = -4; 84 public static final int Z_BUF_ERROR = -5; 85 public static final int Z_VERSION_ERROR = -6; 86 87 // internal stuff 88 static final int Z_DEFLATED = 8; 89 static final int MAX_MEM_LEVEL = 9; 90 static final int DEF_MEM_LEVEL = 8; 91 static final int MAX_WBITS = 15; // 32K LZ77 window 92 static final int DEF_WBITS = MAX_WBITS; 93 static final int MAX_BITS = 15; 94 static final int PRESET_DICT = 0x20; // preset dictionary flag in zlib header 95 static final int MANY = 1440; 96 static final int BL_CODES = 19; 97 static final int D_CODES = 30; 98 static final int LITERALS = 256; 99 static final int LENGTH_CODES = 29; 100 static final int L_CODES = LITERALS + 1 + LENGTH_CODES; 101 static final int HEAP_SIZE = 2 * L_CODES + 1; 102 // Bit length codes must not exceed MAX_BL_BITS bits 103 static final int MAX_BL_BITS = 7; 104 105 enum WrapperType { 106 NONE, ZLIB, GZIP, ZLIB_OR_NONE 107 } 108 109 private JZlib() { 110 // Utility class 111 } 112 }