You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/07/17 08:31:04 UTC
svn commit: r556825 [2/10] - in
/harmony/enhanced/classlib/branches/java6/modules:
archive/src/main/java/java/util/jar/ archive/src/main/java/java/util/zip/
archive/src/main/java/org/apache/harmony/archive/internal/nls/
archive/src/main/java/org/apache...
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Deflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Deflater.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Deflater.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Deflater.java Mon Jul 16 23:30:22 2007
@@ -26,52 +26,53 @@
*/
public class Deflater {
- public static final int BEST_COMPRESSION = 9;
+ public static final int BEST_COMPRESSION = 9;
- public static final int BEST_SPEED = 1;
+ public static final int BEST_SPEED = 1;
- public static final int DEFAULT_COMPRESSION = -1;
+ public static final int DEFAULT_COMPRESSION = -1;
- public static final int DEFAULT_STRATEGY = 0;
+ public static final int DEFAULT_STRATEGY = 0;
- public static final int DEFLATED = 8;
+ public static final int DEFLATED = 8;
- public static final int FILTERED = 1;
+ public static final int FILTERED = 1;
- public static final int HUFFMAN_ONLY = 2;
+ public static final int HUFFMAN_ONLY = 2;
- public static final int NO_COMPRESSION = 0;
+ public static final int NO_COMPRESSION = 0;
- private static final int Z_NO_FLUSH = 0;
+ private static final int Z_NO_FLUSH = 0;
+
+ private static final int Z_FINISH = 4;
- private static final int Z_FINISH = 4;
-
// Fill in the JNI id caches
private static native void oneTimeInitialization();
-
- // A stub buffer used when deflate() called while inputBuffer has not been set.
+
+ // A stub buffer used when deflate() called while inputBuffer has not been
+ // set.
private static final byte[] STUB_INPUT_BUFFER = new byte[0];
static {
oneTimeInitialization();
}
- private int flushParm = Z_NO_FLUSH;
+ private int flushParm = Z_NO_FLUSH;
- private boolean finished;
+ private boolean finished;
- private int compressLevel = DEFAULT_COMPRESSION;
+ private int compressLevel = DEFAULT_COMPRESSION;
- private int strategy = DEFAULT_STRATEGY;
+ private int strategy = DEFAULT_STRATEGY;
- private long streamHandle = -1;
+ private long streamHandle = -1;
- private byte[] inputBuffer;
+ private byte[] inputBuffer;
+
+ private int inRead;
- private int inRead;
-
private int inLength;
-
+
/**
* Constructs a new Deflater instance with default compression level and
* strategy.
@@ -79,7 +80,7 @@
public Deflater() {
this(DEFAULT_COMPRESSION, false);
}
-
+
/**
* Constructs a new Deflater instance with compression level level and
* default compression strategy. THe compression level provided must be
@@ -112,35 +113,35 @@
streamHandle = createStream(compressLevel, strategy, noHeader);
}
- /**
- * Deflates data into the supplied buffer
- *
- * @param buf
- * buffer to store compressed data
- *
- * @return number of bytes of compressed data stored
- *
- */
- public int deflate(byte[] buf) {
- return deflate(buf, 0, buf.length);
- }
-
- /**
- * Deflates data into the supplied buffer using the region from off to
- * nbytes - 1.
- *
- * @param buf
- * buffer to store compressed data
- * @param off
- * offset inf buf to start storing data
- * @param nbytes
- * number of bytes of compressed data to store in buf
- *
- * @return number of bytes of compressed data stored
- *
- */
- public synchronized int deflate(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
+ /**
+ * Deflates data into the supplied buffer
+ *
+ * @param buf
+ * buffer to store compressed data
+ *
+ * @return number of bytes of compressed data stored
+ *
+ */
+ public int deflate(byte[] buf) {
+ return deflate(buf, 0, buf.length);
+ }
+
+ /**
+ * Deflates data into the supplied buffer using the region from off to
+ * nbytes - 1.
+ *
+ * @param buf
+ * buffer to store compressed data
+ * @param off
+ * offset inf buf to start storing data
+ * @param nbytes
+ * number of bytes of compressed data to store in buf
+ *
+ * @return number of bytes of compressed data stored
+ *
+ */
+ public synchronized int deflate(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
// avoid int overflow, check null buf
@@ -152,276 +153,276 @@
}
return deflateImpl(buf, off, nbytes, streamHandle, flushParm);
}
- throw new ArrayIndexOutOfBoundsException();
- }
+ throw new ArrayIndexOutOfBoundsException();
+ }
- private synchronized native int deflateImpl(byte[] buf, int off,
- int nbytes, long handle, int flushParm1);
+ private synchronized native int deflateImpl(byte[] buf, int off,
+ int nbytes, long handle, int flushParm1);
- private synchronized native void endImpl(long handle);
+ private synchronized native void endImpl(long handle);
- /**
- * Frees all resources held onto by this Deflater. Any unused input or output
- * is discarded. This is also called from the finalize method.
- *
- * @see #finalize
- */
- public synchronized void end() {
- if (streamHandle != -1) {
- endImpl(streamHandle);
- inputBuffer = null;
- streamHandle = -1;
- }
- }
+ /**
+ * Frees all resources held onto by this Deflater. Any unused input or
+ * output is discarded. This is also called from the finalize method.
+ *
+ * @see #finalize
+ */
+ public synchronized void end() {
+ if (streamHandle != -1) {
+ endImpl(streamHandle);
+ inputBuffer = null;
+ streamHandle = -1;
+ }
+ }
- @Override
+ @Override
protected void finalize() {
- end();
- }
+ end();
+ }
- /**
- * Indicates to the Deflater that all uncompressed input has been provided
- * to it.
- *
- * @see #finished
- */
- public synchronized void finish() {
- flushParm = Z_FINISH;
- }
-
- /**
- * Returns whether or not all provided data has been successfully
- * compressed.
- *
- * @return true if all data has been compressed, false otherwise
- */
- public synchronized boolean finished() {
- return finished;
- }
-
- /**
- * Returns the Adler32 checksum of uncompressed data currently read. If a
- * preset dictionary is used getAdler() will return the Adler32 checksum of
- * the dictionary used.
- *
- * @return The Adler32 checksum of uncompressed data or preset dictionary if
- * used
- *
- * @see #setDictionary(byte[])
- * @see #setDictionary(byte[], int, int)
- */
- public synchronized int getAdler() {
- if (streamHandle == -1) {
+ /**
+ * Indicates to the Deflater that all uncompressed input has been provided
+ * to it.
+ *
+ * @see #finished
+ */
+ public synchronized void finish() {
+ flushParm = Z_FINISH;
+ }
+
+ /**
+ * Returns whether or not all provided data has been successfully
+ * compressed.
+ *
+ * @return true if all data has been compressed, false otherwise
+ */
+ public synchronized boolean finished() {
+ return finished;
+ }
+
+ /**
+ * Returns the Adler32 checksum of uncompressed data currently read. If a
+ * preset dictionary is used getAdler() will return the Adler32 checksum of
+ * the dictionary used.
+ *
+ * @return The Adler32 checksum of uncompressed data or preset dictionary if
+ * used
+ *
+ * @see #setDictionary(byte[])
+ * @see #setDictionary(byte[], int, int)
+ */
+ public synchronized int getAdler() {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- return getAdlerImpl(streamHandle);
- }
+ return getAdlerImpl(streamHandle);
+ }
- private synchronized native int getAdlerImpl(long handle);
+ private synchronized native int getAdlerImpl(long handle);
- /**
- * Returns the total number of bytes of input consumed by the deflater.
- *
- * @return number of bytes of input read.
- */
- public synchronized int getTotalIn() {
- if (streamHandle == -1) {
+ /**
+ * Returns the total number of bytes of input consumed by the deflater.
+ *
+ * @return number of bytes of input read.
+ */
+ public synchronized int getTotalIn() {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- return (int)getTotalInImpl(streamHandle);
- }
+ return (int) getTotalInImpl(streamHandle);
+ }
- private synchronized native long getTotalInImpl(long handle);
+ private synchronized native long getTotalInImpl(long handle);
- /**
- * Returns the total number of compressed bytes output by this Deflater.
- *
- * @return number of compressed bytes output.
- */
- public synchronized int getTotalOut() {
- if (streamHandle == -1) {
+ /**
+ * Returns the total number of compressed bytes output by this Deflater.
+ *
+ * @return number of compressed bytes output.
+ */
+ public synchronized int getTotalOut() {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- return (int)getTotalOutImpl(streamHandle);
- }
+ return (int) getTotalOutImpl(streamHandle);
+ }
- private synchronized native long getTotalOutImpl(long handle);
+ private synchronized native long getTotalOutImpl(long handle);
- /**
- * Indicates whether or not all bytes of uncompressed input have been
- * consumed by the Deflater. If needsInput() answers true setInput() must be
- * called before deflation can continue. If all bytes of uncompressed data
- * have been provided to the Deflater finish() must be called to ensure the
- * compressed data is output.
- *
- * @return True if input is required for deflation to continue, false
- * otherwise
- * @see #finished()
- * @see #setInput(byte[])
- * @see #setInput(byte[], int, int)
- */
- public synchronized boolean needsInput() {
- if (inputBuffer == null) {
+ /**
+ * Indicates whether or not all bytes of uncompressed input have been
+ * consumed by the Deflater. If needsInput() answers true setInput() must be
+ * called before deflation can continue. If all bytes of uncompressed data
+ * have been provided to the Deflater finish() must be called to ensure the
+ * compressed data is output.
+ *
+ * @return True if input is required for deflation to continue, false
+ * otherwise
+ * @see #finished()
+ * @see #setInput(byte[])
+ * @see #setInput(byte[], int, int)
+ */
+ public synchronized boolean needsInput() {
+ if (inputBuffer == null) {
return true;
}
- return inRead == inLength;
- }
+ return inRead == inLength;
+ }
- /**
- * Resets the <code>Deflater</code> to accept new input without affecting
- * any previously made settings for the compression strategy or level. This
- * operation <i>must</i> be called after <code>finished()</code> returns
- * <code>true</code> if the <code>Deflater</code> is to be reused.
- *
- * @see #finished
- */
- public synchronized void reset() {
- if (streamHandle == -1) {
+ /**
+ * Resets the <code>Deflater</code> to accept new input without affecting
+ * any previously made settings for the compression strategy or level. This
+ * operation <i>must</i> be called after <code>finished()</code> returns
+ * <code>true</code> if the <code>Deflater</code> is to be reused.
+ *
+ * @see #finished
+ */
+ public synchronized void reset() {
+ if (streamHandle == -1) {
throw new NullPointerException();
}
- flushParm = Z_NO_FLUSH;
- finished = false;
- resetImpl(streamHandle);
- inputBuffer = null;
- }
-
- private synchronized native void resetImpl(long handle);
-
- public void setDictionary(byte[] buf) {
- setDictionary(buf, 0, buf.length);
- }
-
- /**
- * Sets the dictionary to be used for compression by this Deflater.
- * setDictionary() can only be called if this Deflater supports the writing
- * of ZLIB headers. This is the default behaviour but can be overridden
- * using Deflater(int, boolean).
- *
- * @see Deflater#Deflater(int, boolean)
- */
- public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
+ flushParm = Z_NO_FLUSH;
+ finished = false;
+ resetImpl(streamHandle);
+ inputBuffer = null;
+ }
+
+ private synchronized native void resetImpl(long handle);
+
+ public void setDictionary(byte[] buf) {
+ setDictionary(buf, 0, buf.length);
+ }
+
+ /**
+ * Sets the dictionary to be used for compression by this Deflater.
+ * setDictionary() can only be called if this Deflater supports the writing
+ * of ZLIB headers. This is the default behaviour but can be overridden
+ * using Deflater(int, boolean).
+ *
+ * @see Deflater#Deflater(int, boolean)
+ */
+ public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
setDictionaryImpl(buf, off, nbytes, streamHandle);
} else {
throw new ArrayIndexOutOfBoundsException();
}
- }
+ }
- private synchronized native void setDictionaryImpl(byte[] buf, int off,
- int nbytes, long handle);
+ private synchronized native void setDictionaryImpl(byte[] buf, int off,
+ int nbytes, long handle);
- /**
- * Sets the input buffer the Deflater will use to extract uncompressed bytes
- * for later compression.
- */
- public void setInput(byte[] buf) {
- setInput(buf, 0, buf.length);
- }
-
- /**
- * Sets the input buffer the Deflater will use to extract uncompressed bytes
- * for later compression. Input will be taken from the buffer region
- * starting at off and ending at nbytes - 1.
- */
- public synchronized void setInput(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
+ /**
+ * Sets the input buffer the Deflater will use to extract uncompressed bytes
+ * for later compression.
+ */
+ public void setInput(byte[] buf) {
+ setInput(buf, 0, buf.length);
+ }
+
+ /**
+ * Sets the input buffer the Deflater will use to extract uncompressed bytes
+ * for later compression. Input will be taken from the buffer region
+ * starting at off and ending at nbytes - 1.
+ */
+ public synchronized void setInput(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
- inLength = nbytes;
- inRead = 0;
- if (inputBuffer == null) {
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
+ inLength = nbytes;
+ inRead = 0;
+ if (inputBuffer == null) {
setLevelsImpl(compressLevel, strategy, streamHandle);
}
- inputBuffer = buf;
- setInputImpl(buf, off, nbytes, streamHandle);
- } else {
+ inputBuffer = buf;
+ setInputImpl(buf, off, nbytes, streamHandle);
+ } else {
throw new ArrayIndexOutOfBoundsException();
}
- }
+ }
- private synchronized native void setLevelsImpl(int level, int strategy,
- long handle);
+ private synchronized native void setLevelsImpl(int level, int strategy,
+ long handle);
- private synchronized native void setInputImpl(byte[] buf, int off,
- int nbytes, long handle);
+ private synchronized native void setInputImpl(byte[] buf, int off,
+ int nbytes, long handle);
- /**
- * Sets the compression level to be used when compressing data. The
- * compression level must be a value between 0 and 9. This value must be set
- * prior to calling setInput().
- *
- * @param level
- * compression level to use
- * @exception IllegalArgumentException
- * If the compression level is invalid.
- */
- public synchronized void setLevel(int level) {
- if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
+ /**
+ * Sets the compression level to be used when compressing data. The
+ * compression level must be a value between 0 and 9. This value must be set
+ * prior to calling setInput().
+ *
+ * @param level
+ * compression level to use
+ * @exception IllegalArgumentException
+ * If the compression level is invalid.
+ */
+ public synchronized void setLevel(int level) {
+ if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
throw new IllegalArgumentException();
}
- if (inputBuffer != null) {
+ if (inputBuffer != null) {
throw new IllegalStateException();
}
- compressLevel = level;
- }
+ compressLevel = level;
+ }
- /**
- * Sets the compression strategy to be used. The strategy must be one of
- * FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior
- * to calling setInput().
- *
- * @param strategy
- * compression strategy to use
- * @exception IllegalArgumentException
- * If the strategy specified is not one of FILTERED,
- * HUFFMAN_ONLY or DEFAULT_STRATEGY.
- */
- public synchronized void setStrategy(int strategy) {
- if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) {
+ /**
+ * Sets the compression strategy to be used. The strategy must be one of
+ * FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior
+ * to calling setInput().
+ *
+ * @param strategy
+ * compression strategy to use
+ * @exception IllegalArgumentException
+ * If the strategy specified is not one of FILTERED,
+ * HUFFMAN_ONLY or DEFAULT_STRATEGY.
+ */
+ public synchronized void setStrategy(int strategy) {
+ if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) {
throw new IllegalArgumentException();
}
- if (inputBuffer != null) {
+ if (inputBuffer != null) {
throw new IllegalStateException();
}
- this.strategy = strategy;
- }
-
- /**
- * Returns a long int of total number of bytes read by the Deflater. This
- * method performs the same as getTotalIn except it returns a long value
- * instead of an integer
- *
- * @see getTotalIn
- * @return bytes exactly read by deflater
- */
- public synchronized long getBytesRead() {
- // Throw NPE here
- if (streamHandle == -1) {
+ this.strategy = strategy;
+ }
+
+ /**
+ * Returns a long int of total number of bytes read by the Deflater. This
+ * method performs the same as getTotalIn except it returns a long value
+ * instead of an integer
+ *
+ * @see getTotalIn
+ * @return bytes exactly read by deflater
+ */
+ public synchronized long getBytesRead() {
+ // Throw NPE here
+ if (streamHandle == -1) {
throw new NullPointerException();
}
- return getTotalInImpl(streamHandle);
- }
+ return getTotalInImpl(streamHandle);
+ }
- /**
- * Returns a long int of total number of bytes of read by the Deflater. This
- * method performs the same as getTotalOut except it returns a long value
- * instead of an integer
- *
- * @see getTotalOut
- * @return bytes exactly write by deflater
- */
+ /**
+ * Returns a long int of total number of bytes of read by the Deflater. This
+ * method performs the same as getTotalOut except it returns a long value
+ * instead of an integer
+ *
+ * @see getTotalOut
+ * @return bytes exactly write by deflater
+ */
public synchronized long getBytesWritten() {
// Throw NPE here
if (streamHandle == -1) {
@@ -430,5 +431,5 @@
return getTotalOutImpl(streamHandle);
}
- private native long createStream(int level, int strategy1, boolean noHeader1);
+ private native long createStream(int level, int strategy1, boolean noHeader1);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java Mon Jul 16 23:30:22 2007
@@ -17,7 +17,6 @@
package java.util.zip;
-
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -30,154 +29,154 @@
* Deflater.
*/
public class DeflaterOutputStream extends FilterOutputStream {
- static final int BUF_SIZE = 512;
+ static final int BUF_SIZE = 512;
- protected byte[] buf;
+ protected byte[] buf;
- protected Deflater def;
+ protected Deflater def;
- boolean done = false;
+ boolean done = false;
- /**
- * Constructs a new DeflaterOutputStream instance using os as the underlying
- * stream. The provided Deflater instance will be used to compress data.
- *
- * @param os
- * OutputStream to receive compressed data
- * @param def
- * Deflater to perform compression
- */
- public DeflaterOutputStream(OutputStream os, Deflater def) {
- this(os, def, BUF_SIZE);
- }
-
- /**
- * Constructs a new DeflaterOutputStream instance using os as the underlying
- * stream.
- *
- * @param os
- * OutputStream to receive compressed data
- */
- public DeflaterOutputStream(OutputStream os) {
- this(os, new Deflater());
- }
-
- /**
- * Constructs a new DeflaterOutputStream instance using os as the underlying
- * stream. The provided Deflater instance will be used to compress data. The
- * internal buffer for storing compressed data will be of size bsize.
- *
- * @param os
- * OutputStream to receive compressed data
- * @param def
- * Deflater to perform compression
- * @param bsize
- * size of internal compression buffer
- */
- public DeflaterOutputStream(OutputStream os, Deflater def, int bsize) {
- super(os);
- if (os == null || def == null) {
+ /**
+ * Constructs a new DeflaterOutputStream instance using os as the underlying
+ * stream. The provided Deflater instance will be used to compress data.
+ *
+ * @param os
+ * OutputStream to receive compressed data
+ * @param def
+ * Deflater to perform compression
+ */
+ public DeflaterOutputStream(OutputStream os, Deflater def) {
+ this(os, def, BUF_SIZE);
+ }
+
+ /**
+ * Constructs a new DeflaterOutputStream instance using os as the underlying
+ * stream.
+ *
+ * @param os
+ * OutputStream to receive compressed data
+ */
+ public DeflaterOutputStream(OutputStream os) {
+ this(os, new Deflater());
+ }
+
+ /**
+ * Constructs a new DeflaterOutputStream instance using os as the underlying
+ * stream. The provided Deflater instance will be used to compress data. The
+ * internal buffer for storing compressed data will be of size bsize.
+ *
+ * @param os
+ * OutputStream to receive compressed data
+ * @param def
+ * Deflater to perform compression
+ * @param bsize
+ * size of internal compression buffer
+ */
+ public DeflaterOutputStream(OutputStream os, Deflater def, int bsize) {
+ super(os);
+ if (os == null || def == null) {
throw new NullPointerException();
}
- if (bsize <= 0) {
+ if (bsize <= 0) {
throw new IllegalArgumentException();
}
- this.def = def;
- buf = new byte[bsize];
- }
-
- /**
- * Compress the data in the input buffer and write it to the underlying
- * stream.
- *
- * @exception java.io.IOException
- * If an error occurs during deflation.
- */
- protected void deflate() throws IOException {
- int x = 0;
- do {
- x = def.deflate(buf);
- out.write(buf, 0, x);
- } while (!def.needsInput());
- }
-
- /**
- * Writes any unwritten compressed data to the underlying stream, the closes
- * all underlying streams. This stream can no longer be used after close()
- * has been called.
- *
- * @exception java.io.IOException
- * If an error occurs during close.
- */
- @Override
+ this.def = def;
+ buf = new byte[bsize];
+ }
+
+ /**
+ * Compress the data in the input buffer and write it to the underlying
+ * stream.
+ *
+ * @exception java.io.IOException
+ * If an error occurs during deflation.
+ */
+ protected void deflate() throws IOException {
+ int x = 0;
+ do {
+ x = def.deflate(buf);
+ out.write(buf, 0, x);
+ } while (!def.needsInput());
+ }
+
+ /**
+ * Writes any unwritten compressed data to the underlying stream, the closes
+ * all underlying streams. This stream can no longer be used after close()
+ * has been called.
+ *
+ * @exception java.io.IOException
+ * If an error occurs during close.
+ */
+ @Override
public void close() throws IOException {
- if (!def.finished()) {
+ if (!def.finished()) {
finish();
}
- def.end();
- out.close();
- }
-
- /**
- * Write any unwritten data to the underlying stream. Do not close the
- * stream. This allows subsequent Deflater's to write to the same stream.
- * This Deflater cannot be used again.
- *
- * @exception java.io.IOException
- * If an error occurs.
- */
- public void finish() throws IOException {
- if (done) {
+ def.end();
+ out.close();
+ }
+
+ /**
+ * Write any unwritten data to the underlying stream. Do not close the
+ * stream. This allows subsequent Deflater's to write to the same stream.
+ * This Deflater cannot be used again.
+ *
+ * @exception java.io.IOException
+ * If an error occurs.
+ */
+ public void finish() throws IOException {
+ if (done) {
return;
}
- def.finish();
- int x = 0;
- while (!def.finished()) {
- if (def.needsInput()) {
+ def.finish();
+ int x = 0;
+ while (!def.finished()) {
+ if (def.needsInput()) {
def.setInput(buf, 0, 0);
}
- x = def.deflate(buf);
- out.write(buf, 0, x);
- }
- done = true;
- }
+ x = def.deflate(buf);
+ out.write(buf, 0, x);
+ }
+ done = true;
+ }
- @Override
+ @Override
public void write(int i) throws IOException {
- byte[] b = new byte[1];
- b[0] = (byte) i;
- write(b, 0, 1);
- }
-
- /**
- * Compress nbytes of data from buf starting at off and write it to the
- * underlying stream.
- *
- * @param buf
- * Buffer of data to compress
- * @param off
- * offset in buffer to extract data from
- * @param nbytes
- * Number of bytes of data to compress and write
- *
- * @exception java.io.IOException
- * If an error occurs during writing.
- */
- @Override
+ byte[] b = new byte[1];
+ b[0] = (byte) i;
+ write(b, 0, 1);
+ }
+
+ /**
+ * Compress nbytes of data from buf starting at off and write it to the
+ * underlying stream.
+ *
+ * @param buf
+ * Buffer of data to compress
+ * @param off
+ * offset in buffer to extract data from
+ * @param nbytes
+ * Number of bytes of data to compress and write
+ *
+ * @exception java.io.IOException
+ * If an error occurs during writing.
+ */
+ @Override
public void write(byte[] buffer, int off, int nbytes) throws IOException {
- if (done) {
+ if (done) {
throw new IOException(Messages.getString("archive.26")); //$NON-NLS-1$
}
- // avoid int overflow, check null buf
- if (off <= buffer.length && nbytes >= 0 && off >= 0
- && buffer.length - off >= nbytes) {
- if (!def.needsInput()) {
+ // avoid int overflow, check null buf
+ if (off <= buffer.length && nbytes >= 0 && off >= 0
+ && buffer.length - off >= nbytes) {
+ if (!def.needsInput()) {
throw new IOException();
}
- def.setInput(buffer, off, nbytes);
- deflate();
- } else {
+ def.setInput(buffer, off, nbytes);
+ deflate();
+ } else {
throw new ArrayIndexOutOfBoundsException();
}
- }
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPInputStream.java Mon Jul 16 23:30:22 2007
@@ -17,7 +17,6 @@
package java.util.zip;
-
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
@@ -28,181 +27,182 @@
* The GZIPInputStream class is used to read data stored in the GZIP format.
*/
public class GZIPInputStream extends java.util.zip.InflaterInputStream {
- protected CRC32 crc = new CRC32();
+ protected CRC32 crc = new CRC32();
- protected boolean eos = false;
+ protected boolean eos = false;
- public final static int GZIP_MAGIC = 0x8b1f;
+ public final static int GZIP_MAGIC = 0x8b1f;
- private static final int FHCRC = 2;
+ private static final int FHCRC = 2;
- private static final int FEXTRA = 4;
-
- private static final int FNAME = 8;
-
- private static final int FCOMMENT = 16;
-
- /**
- * Construct a GZIPInputStream to read from GZIP data from the underlying
- * stream
- *
- * @param is
- * InputStream to read data from
- */
- public GZIPInputStream(InputStream is) throws IOException {
- this(is, BUF_SIZE);
- }
-
- /**
- * Construct a GZIPInputStream to read from GZIP data from the underlying
- * stream. Set the internal buffer size to size
- *
- * @param is
- * InputStream to read data from
- * @param size
- * Internal read buffer size
- */
- public GZIPInputStream(InputStream is, int size) throws IOException {
- super(is, new Inflater(true), size);
- byte[] header = new byte[10];
- readFully(header, 0, header.length);
- if (getShort(header, 0) != GZIP_MAGIC) {
+ private static final int FEXTRA = 4;
+
+ private static final int FNAME = 8;
+
+ private static final int FCOMMENT = 16;
+
+ /**
+ * Construct a GZIPInputStream to read from GZIP data from the underlying
+ * stream
+ *
+ * @param is
+ * InputStream to read data from
+ */
+ public GZIPInputStream(InputStream is) throws IOException {
+ this(is, BUF_SIZE);
+ }
+
+ /**
+ * Construct a GZIPInputStream to read from GZIP data from the underlying
+ * stream. Set the internal buffer size to size
+ *
+ * @param is
+ * InputStream to read data from
+ * @param size
+ * Internal read buffer size
+ */
+ public GZIPInputStream(InputStream is, int size) throws IOException {
+ super(is, new Inflater(true), size);
+ byte[] header = new byte[10];
+ readFully(header, 0, header.length);
+ if (getShort(header, 0) != GZIP_MAGIC) {
throw new IOException(Messages.getString("archive.1F")); //$NON-NLS-1$;
}
- int flags = header[3];
- boolean hcrc = (flags & FHCRC) != 0;
- if (hcrc) {
+ int flags = header[3];
+ boolean hcrc = (flags & FHCRC) != 0;
+ if (hcrc) {
crc.update(header, 0, header.length);
}
- if ((flags & FEXTRA) != 0) {
- readFully(header, 0, 2);
- if (hcrc) {
+ if ((flags & FEXTRA) != 0) {
+ readFully(header, 0, 2);
+ if (hcrc) {
crc.update(header, 0, 2);
}
- int length = getShort(header, 0);
- while (length > 0) {
- int max = length > buf.length ? buf.length : length;
- int result = in.read(buf, 0, max);
- if (result == -1) {
+ int length = getShort(header, 0);
+ while (length > 0) {
+ int max = length > buf.length ? buf.length : length;
+ int result = in.read(buf, 0, max);
+ if (result == -1) {
throw new EOFException();
}
- if (hcrc) {
+ if (hcrc) {
crc.update(buf, 0, result);
}
- length -= result;
- }
- }
- if ((flags & FNAME) != 0) {
+ length -= result;
+ }
+ }
+ if ((flags & FNAME) != 0) {
readZeroTerminated(hcrc);
}
- if ((flags & FCOMMENT) != 0) {
+ if ((flags & FCOMMENT) != 0) {
readZeroTerminated(hcrc);
}
- if (hcrc) {
- readFully(header, 0, 2);
- int crc16 = getShort(header, 0);
- if ((crc.getValue() & 0xffff) != crc16) {
+ if (hcrc) {
+ readFully(header, 0, 2);
+ int crc16 = getShort(header, 0);
+ if ((crc.getValue() & 0xffff) != crc16) {
throw new IOException(Messages.getString("archive.20")); //$NON-NLS-1$
}
- crc.reset();
- }
- }
-
- private long getLong(byte[] buffer, int off) {
- long l = 0;
- l |= (buffer[off] & 0xFF);
- l |= (buffer[off + 1] & 0xFF) << 8;
- l |= (buffer[off + 2] & 0xFF) << 16;
- l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
- return l;
- }
-
- private int getShort(byte[] buffer, int off) {
- return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
- }
-
- /**
- * Reads and decompresses GZIP data from the underlying stream into buf.
- *
- * @param buffer
- * Buffer to receive data
- * @param off
- * Offset in buffer to store data
- * @param nbytes
- * Number of bytes to read
- */
- @Override
+ crc.reset();
+ }
+ }
+
+ private long getLong(byte[] buffer, int off) {
+ long l = 0;
+ l |= (buffer[off] & 0xFF);
+ l |= (buffer[off + 1] & 0xFF) << 8;
+ l |= (buffer[off + 2] & 0xFF) << 16;
+ l |= ((long) (buffer[off + 3] & 0xFF)) << 24;
+ return l;
+ }
+
+ private int getShort(byte[] buffer, int off) {
+ return (buffer[off] & 0xFF) | ((buffer[off + 1] & 0xFF) << 8);
+ }
+
+ /**
+ * Reads and decompresses GZIP data from the underlying stream into buf.
+ *
+ * @param buffer
+ * Buffer to receive data
+ * @param off
+ * Offset in buffer to store data
+ * @param nbytes
+ * Number of bytes to read
+ */
+ @Override
public int read(byte[] buffer, int off, int nbytes) throws IOException {
if (closed) {
throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
}
- if(eof){
+ if (eof) {
return -1;
}
- // avoid int overflow, check null buffer
- if (off <= buffer.length && nbytes >= 0 && off >= 0
- && buffer.length - off >= nbytes) {
- int val = super.read(buffer, off, nbytes);
- if (val != -1) {
+ // avoid int overflow, check null buffer
+ if (off <= buffer.length && nbytes >= 0 && off >= 0
+ && buffer.length - off >= nbytes) {
+ int val = super.read(buffer, off, nbytes);
+ if (val != -1) {
crc.update(buffer, off, val);
} else if (!eos) {
- eos = true;
- // Get non-compressed bytes read by fill
- int size = inf.getRemaining();
- final int trailerSize = 8; // crc (4 bytes) + total out (4 bytes)
- byte[] b = new byte[trailerSize];
- int copySize = (size > trailerSize) ? trailerSize : size;
+ eos = true;
+ // Get non-compressed bytes read by fill
+ int size = inf.getRemaining();
+ final int trailerSize = 8; // crc (4 bytes) + total out (4
+ // bytes)
+ byte[] b = new byte[trailerSize];
+ int copySize = (size > trailerSize) ? trailerSize : size;
System.arraycopy(buf, len - size, b, 0, copySize);
- readFully(b, copySize, trailerSize - copySize);
+ readFully(b, copySize, trailerSize - copySize);
- if (getLong(b, 0) != crc.getValue()) {
+ if (getLong(b, 0) != crc.getValue()) {
throw new IOException(Messages.getString("archive.20")); //$NON-NLS-1$
}
- if ((int) getLong(b, 4) != inf.getTotalOut()) {
+ if ((int) getLong(b, 4) != inf.getTotalOut()) {
throw new IOException(Messages.getString("archive.21")); //$NON-NLS-1$
}
- }
- return val;
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
- /**
- * Closes this stream and any underlying streams.
- */
- @Override
+ }
+ return val;
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ /**
+ * Closes this stream and any underlying streams.
+ */
+ @Override
public void close() throws IOException {
- eos = true;
- super.close();
- }
-
- private void readFully(byte[] buffer, int offset, int length)
- throws IOException {
- int result;
- while (length > 0) {
- result = in.read(buffer, offset, length);
- if (result == -1) {
+ eos = true;
+ super.close();
+ }
+
+ private void readFully(byte[] buffer, int offset, int length)
+ throws IOException {
+ int result;
+ while (length > 0) {
+ result = in.read(buffer, offset, length);
+ if (result == -1) {
throw new EOFException();
}
- offset += result;
- length -= result;
- }
- }
-
- private void readZeroTerminated(boolean hcrc) throws IOException {
- int result;
- while ((result = in.read()) > 0) {
- if (hcrc) {
+ offset += result;
+ length -= result;
+ }
+ }
+
+ private void readZeroTerminated(boolean hcrc) throws IOException {
+ int result;
+ while ((result = in.read()) > 0) {
+ if (hcrc) {
crc.update(result);
}
- }
- if (result == -1) {
+ }
+ if (result == -1) {
throw new EOFException();
}
- // Add the zero
- if (hcrc) {
+ // Add the zero
+ if (hcrc) {
crc.update(result);
}
- }
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/GZIPOutputStream.java Mon Jul 16 23:30:22 2007
@@ -17,7 +17,6 @@
package java.util.zip;
-
import java.io.IOException;
import java.io.OutputStream;
@@ -27,71 +26,71 @@
*/
public class GZIPOutputStream extends DeflaterOutputStream {
- protected CRC32 crc = new CRC32();
+ protected CRC32 crc = new CRC32();
- /**
- * Construct a new GZIPOutputStream to write data in GZIP format to the
- * underlying stream.
- *
- * @param os
- * OutputStream to write to
- */
- public GZIPOutputStream(OutputStream os) throws IOException {
- this(os, BUF_SIZE);
- }
-
- /**
- * Construct a new GZIPOutputStream to write data in GZIP format to the
- * underlying stream. Set the internal compression buffer to sise size.
- *
- * @param os
- * OutputStream to write to
- * @param size
- * Internal buffer size
- */
- public GZIPOutputStream(OutputStream os, int size) throws IOException {
- super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
- writeShort(GZIPInputStream.GZIP_MAGIC);
- out.write(Deflater.DEFLATED);
- out.write(0); // flags
- writeLong(0); // mod time
- out.write(0); // extra flags
- out.write(0); // operating system
- }
-
- /**
- * Indicates to the stream that all data has been written out, and any GZIP
- * terminal data can now be output.
- */
- @Override
+ /**
+ * Construct a new GZIPOutputStream to write data in GZIP format to the
+ * underlying stream.
+ *
+ * @param os
+ * OutputStream to write to
+ */
+ public GZIPOutputStream(OutputStream os) throws IOException {
+ this(os, BUF_SIZE);
+ }
+
+ /**
+ * Construct a new GZIPOutputStream to write data in GZIP format to the
+ * underlying stream. Set the internal compression buffer to sise size.
+ *
+ * @param os
+ * OutputStream to write to
+ * @param size
+ * Internal buffer size
+ */
+ public GZIPOutputStream(OutputStream os, int size) throws IOException {
+ super(os, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
+ writeShort(GZIPInputStream.GZIP_MAGIC);
+ out.write(Deflater.DEFLATED);
+ out.write(0); // flags
+ writeLong(0); // mod time
+ out.write(0); // extra flags
+ out.write(0); // operating system
+ }
+
+ /**
+ * Indicates to the stream that all data has been written out, and any GZIP
+ * terminal data can now be output.
+ */
+ @Override
public void finish() throws IOException {
- super.finish();
- writeLong(crc.getValue());
- writeLong(crc.tbytes);
- }
-
- /**
- * Write up to nbytes of data from buf, starting at offset off, to the
- * underlying stream in GZIP format.
- */
- @Override
+ super.finish();
+ writeLong(crc.getValue());
+ writeLong(crc.tbytes);
+ }
+
+ /**
+ * Write up to nbytes of data from buf, starting at offset off, to the
+ * underlying stream in GZIP format.
+ */
+ @Override
public void write(byte[] buffer, int off, int nbytes) throws IOException {
- super.write(buffer, off, nbytes);
- crc.update(buffer, off, nbytes);
- }
-
- private int writeShort(int i) throws IOException {
- out.write(i & 0xFF);
- out.write((i >> 8) & 0xFF);
- return i;
- }
-
- private long writeLong(long i) throws IOException {
- // Write out the long value as an unsigned int
- out.write((int) (i & 0xFF));
- out.write((int) (i >> 8) & 0xFF);
- out.write((int) (i >> 16) & 0xFF);
- out.write((int) (i >> 24) & 0xFF);
- return i;
- }
+ super.write(buffer, off, nbytes);
+ crc.update(buffer, off, nbytes);
+ }
+
+ private int writeShort(int i) throws IOException {
+ out.write(i & 0xFF);
+ out.write((i >> 8) & 0xFF);
+ return i;
+ }
+
+ private long writeLong(long i) throws IOException {
+ // Write out the long value as an unsigned int
+ out.write((int) (i & 0xFF));
+ out.write((int) (i >> 8) & 0xFF);
+ out.write((int) (i >> 16) & 0xFF);
+ out.write((int) (i >> 24) & 0xFF);
+ return i;
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/Inflater.java Mon Jul 16 23:30:22 2007
@@ -19,7 +19,6 @@
import org.apache.harmony.archive.internal.nls.Messages;
-
/**
* The Inflater class is used to decompress bytes using the DEFLATE compression
* algorithm. Inflation is performed by the ZLIB compression library.
@@ -29,156 +28,158 @@
*/
public class Inflater {
- private boolean finished; // Set by the inflateImpl native
+ private boolean finished; // Set by the inflateImpl native
+
+ private boolean needsDictionary; // Set by the inflateImpl native
- private boolean needsDictionary; // Set by the inflateImpl native
+ private long streamHandle = -1;
- private long streamHandle = -1;
+ int inRead;
- int inRead;
-
int inLength;
- // Fill in the JNI id caches
- private static native void oneTimeInitialization();
+ // Fill in the JNI id caches
+ private static native void oneTimeInitialization();
+
+ static {
+ oneTimeInitialization();
+ }
- static {
- oneTimeInitialization();
- }
-
private static final byte MAGIC_NUMBER = 120;
+
private boolean gotFirstByte = false;
+
private boolean pass_magic_number_check = true;
-
- /**
- * Release any resources associated with this Inflater. Any unused
- * input/output is discarded. This is also called by the finalize method.
- */
- public synchronized void end() {
- if (streamHandle != -1) {
- endImpl(streamHandle);
- inRead = 0;
- inLength = 0;
- streamHandle = -1;
- }
- }
- private native synchronized void endImpl(long handle);
+ /**
+ * Release any resources associated with this Inflater. Any unused
+ * input/output is discarded. This is also called by the finalize method.
+ */
+ public synchronized void end() {
+ if (streamHandle != -1) {
+ endImpl(streamHandle);
+ inRead = 0;
+ inLength = 0;
+ streamHandle = -1;
+ }
+ }
+
+ private native synchronized void endImpl(long handle);
- @Override
+ @Override
protected void finalize() {
- end();
- }
+ end();
+ }
- /**
- * Indicates if the Inflater has inflated the entire deflated stream. If
- * deflated bytes remain and needsInput returns true this method will return
- * false. This method should be called after all deflated input is supplied
- * to the Inflater.
- *
- * @return True if all input has been inflated, false otherwise
- */
- public synchronized boolean finished() {
- return finished;
- }
-
- /**
- * Returns the Adler32 checksum of either all bytes inflated, or the
- * checksum of the preset dictionary if one has been supplied.
- *
- * @return The Adler32 checksum associated with this Inflater.
- */
- public synchronized int getAdler() {
- if (streamHandle == -1) {
+ /**
+ * Indicates if the Inflater has inflated the entire deflated stream. If
+ * deflated bytes remain and needsInput returns true this method will return
+ * false. This method should be called after all deflated input is supplied
+ * to the Inflater.
+ *
+ * @return True if all input has been inflated, false otherwise
+ */
+ public synchronized boolean finished() {
+ return finished;
+ }
+
+ /**
+ * Returns the Adler32 checksum of either all bytes inflated, or the
+ * checksum of the preset dictionary if one has been supplied.
+ *
+ * @return The Adler32 checksum associated with this Inflater.
+ */
+ public synchronized int getAdler() {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- return getAdlerImpl(streamHandle);
- }
+ return getAdlerImpl(streamHandle);
+ }
- private native synchronized int getAdlerImpl(long handle);
+ private native synchronized int getAdlerImpl(long handle);
- /**
- * Returns the number of bytes of current input remaining to be read by the
- * inflater
- *
- * @return Number of bytes of unread input.
- */
- public synchronized int getRemaining() {
- return inLength - inRead;
- }
-
- /**
- * Returns total number of bytes of input read by the Inflater.
- *
- * @return Total bytes read
- */
- public synchronized int getTotalIn() {
- if (streamHandle == -1) {
+ /**
+ * Returns the number of bytes of current input remaining to be read by the
+ * inflater
+ *
+ * @return Number of bytes of unread input.
+ */
+ public synchronized int getRemaining() {
+ return inLength - inRead;
+ }
+
+ /**
+ * Returns total number of bytes of input read by the Inflater.
+ *
+ * @return Total bytes read
+ */
+ public synchronized int getTotalIn() {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- long totalIn = getTotalInImpl(streamHandle);
- return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
- : Integer.MAX_VALUE);
- }
-
- private synchronized native long getTotalInImpl(long handle);
-
- /**
- * Returns total number of bytes of input output by the Inflater.
- *
- * @return Total bytes output
- */
- public synchronized int getTotalOut() {
- if (streamHandle == -1) {
+ long totalIn = getTotalInImpl(streamHandle);
+ return (totalIn <= Integer.MAX_VALUE ? (int) totalIn
+ : Integer.MAX_VALUE);
+ }
+
+ private synchronized native long getTotalInImpl(long handle);
+
+ /**
+ * Returns total number of bytes of input output by the Inflater.
+ *
+ * @return Total bytes output
+ */
+ public synchronized int getTotalOut() {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- long totalOut = getTotalOutImpl(streamHandle);
- return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
- : Integer.MAX_VALUE);
- }
-
- private native synchronized long getTotalOutImpl(long handle);
-
- /**
- * Inflates bytes from current input and stores them in buf.
- *
- * @param buf
- * Buffer to output inflated bytes
- * @return Number of bytes inflated
- * @exception DataFormatException
- * If the underlying stream is corrupted or was not DEFLATED
- *
- */
- public int inflate(byte[] buf) throws DataFormatException {
- return inflate(buf, 0, buf.length);
- }
-
- /**
- * Inflates up to nbytes bytes from current input and stores them in buf
- * starting at off.
- *
- * @param buf
- * Buffer to output inflated bytes
- * @param off
- * Offset in buffer into which to store inflated bytes
- * @param nbytes
- * Number of inflated bytes to store
- * @exception DataFormatException
- * If the underlying stream is corrupted or was not DEFLATED
- * @return Number of bytes inflated
- */
- public synchronized int inflate(byte[] buf, int off, int nbytes)
- throws DataFormatException {
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
+ long totalOut = getTotalOutImpl(streamHandle);
+ return (totalOut <= Integer.MAX_VALUE ? (int) totalOut
+ : Integer.MAX_VALUE);
+ }
+
+ private native synchronized long getTotalOutImpl(long handle);
+
+ /**
+ * Inflates bytes from current input and stores them in buf.
+ *
+ * @param buf
+ * Buffer to output inflated bytes
+ * @return Number of bytes inflated
+ * @exception DataFormatException
+ * If the underlying stream is corrupted or was not DEFLATED
+ *
+ */
+ public int inflate(byte[] buf) throws DataFormatException {
+ return inflate(buf, 0, buf.length);
+ }
+
+ /**
+ * Inflates up to nbytes bytes from current input and stores them in buf
+ * starting at off.
+ *
+ * @param buf
+ * Buffer to output inflated bytes
+ * @param off
+ * Offset in buffer into which to store inflated bytes
+ * @param nbytes
+ * Number of inflated bytes to store
+ * @exception DataFormatException
+ * If the underlying stream is corrupted or was not DEFLATED
+ * @return Number of bytes inflated
+ */
+ public synchronized int inflate(byte[] buf, int off, int nbytes)
+ throws DataFormatException {
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
if (nbytes == 0)
return 0;
- if (streamHandle == -1) {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
-
+
if (!pass_magic_number_check) {
throw new DataFormatException();
}
@@ -186,183 +187,180 @@
if (needsInput()) {
return 0;
}
-
- boolean neededDict = needsDictionary;
- needsDictionary = false;
- int result = inflateImpl(buf, off, nbytes, streamHandle);
- if (needsDictionary && neededDict) {
+
+ boolean neededDict = needsDictionary;
+ needsDictionary = false;
+ int result = inflateImpl(buf, off, nbytes, streamHandle);
+ if (needsDictionary && neededDict) {
throw new DataFormatException(Messages.getString("archive.27")); //$NON-NLS-1$
}
- return result;
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
- private native synchronized int inflateImpl(byte[] buf, int off,
- int nbytes, long handle);
-
- /**
- * Constructs a new Inflater instance.
- */
- public Inflater() {
- this(false);
- }
-
- /**
- * Constructs a new Inflater instance. If noHeader is true the Inflater will
- * not attempt to read a ZLIB header.
- *
- * @param noHeader
- * If true, read a ZLIB header from input.
- */
- public Inflater(boolean noHeader) {
- streamHandle = createStream(noHeader);
- }
-
- /**
- * Indicates whether the input bytes were compressed with a preset
- * dictionary. This method should be called prior to inflate() to determine
- * if a dictionary is required. If so setDictionary() should be called with
- * the appropriate dictionary prior to calling inflate().
- *
- * @return true if a preset dictionary is required for inflation.
- * @see #setDictionary(byte[])
- * @see #setDictionary(byte[], int, int)
- */
- public synchronized boolean needsDictionary() {
- return needsDictionary;
- }
-
- public synchronized boolean needsInput() {
- return inRead == inLength;
- }
-
- /**
- * Resets the Inflater.
- */
- public synchronized void reset() {
- if (streamHandle == -1) {
+ return result;
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ private native synchronized int inflateImpl(byte[] buf, int off,
+ int nbytes, long handle);
+
+ /**
+ * Constructs a new Inflater instance.
+ */
+ public Inflater() {
+ this(false);
+ }
+
+ /**
+ * Constructs a new Inflater instance. If noHeader is true the Inflater will
+ * not attempt to read a ZLIB header.
+ *
+ * @param noHeader
+ * If true, read a ZLIB header from input.
+ */
+ public Inflater(boolean noHeader) {
+ streamHandle = createStream(noHeader);
+ }
+
+ /**
+ * Indicates whether the input bytes were compressed with a preset
+ * dictionary. This method should be called prior to inflate() to determine
+ * if a dictionary is required. If so setDictionary() should be called with
+ * the appropriate dictionary prior to calling inflate().
+ *
+ * @return true if a preset dictionary is required for inflation.
+ * @see #setDictionary(byte[])
+ * @see #setDictionary(byte[], int, int)
+ */
+ public synchronized boolean needsDictionary() {
+ return needsDictionary;
+ }
+
+ public synchronized boolean needsInput() {
+ return inRead == inLength;
+ }
+
+ /**
+ * Resets the Inflater.
+ */
+ public synchronized void reset() {
+ if (streamHandle == -1) {
throw new NullPointerException();
}
- finished = false;
- needsDictionary = false;
- inLength = inRead = 0;
- resetImpl(streamHandle);
- }
-
- private native synchronized void resetImpl(long handle);
-
- /**
- * Sets the preset dictionary to be used for inflation to buf.
- * needsDictionary() can be called to determine whether the current input
- * was deflated using a preset dictionary.
- *
- * @param buf
- * The buffer containing the dictionary bytes
- * @see #needsDictionary
- */
- public synchronized void setDictionary(byte[] buf) {
- setDictionary(buf, 0, buf.length);
- }
+ finished = false;
+ needsDictionary = false;
+ inLength = inRead = 0;
+ resetImpl(streamHandle);
+ }
+
+ private native synchronized void resetImpl(long handle);
+
+ /**
+ * Sets the preset dictionary to be used for inflation to buf.
+ * needsDictionary() can be called to determine whether the current input
+ * was deflated using a preset dictionary.
+ *
+ * @param buf
+ * The buffer containing the dictionary bytes
+ * @see #needsDictionary
+ */
+ public synchronized void setDictionary(byte[] buf) {
+ setDictionary(buf, 0, buf.length);
+ }
- public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
+ public synchronized void setDictionary(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
setDictionaryImpl(buf, off, nbytes, streamHandle);
} else {
throw new ArrayIndexOutOfBoundsException();
}
- }
+ }
- private native synchronized void setDictionaryImpl(byte[] buf, int off,
- int nbytes, long handle);
+ private native synchronized void setDictionaryImpl(byte[] buf, int off,
+ int nbytes, long handle);
- /**
- * Sets the current input to buf. This method should only be called if
- * needsInput() returns true.
- *
- * @param buf
- * input buffer
- * @see #needsInput
- */
- public synchronized void setInput(byte[] buf) {
- setInput(buf, 0, buf.length);
- }
-
- /**
- * Sets the current input to the region of buf starting at off and ending at
- * nbytes - 1. This method should only be called if needsInput() returns
- * true.
- *
- * @param buf
- * input buffer
- * @param off
- * offset to read from in buffer
- * @param nbytes
- * number of bytes to read
- * @see #needsInput
- */
- public synchronized void setInput(byte[] buf, int off, int nbytes) {
- if (streamHandle == -1) {
+ /**
+ * Sets the current input to buf. This method should only be called if
+ * needsInput() returns true.
+ *
+ * @param buf
+ * input buffer
+ * @see #needsInput
+ */
+ public synchronized void setInput(byte[] buf) {
+ setInput(buf, 0, buf.length);
+ }
+
+ /**
+ * Sets the current input to the region of buf starting at off and ending at
+ * nbytes - 1. This method should only be called if needsInput() returns
+ * true.
+ *
+ * @param buf
+ * input buffer
+ * @param off
+ * offset to read from in buffer
+ * @param nbytes
+ * number of bytes to read
+ * @see #needsInput
+ */
+ public synchronized void setInput(byte[] buf, int off, int nbytes) {
+ if (streamHandle == -1) {
throw new IllegalStateException();
}
- // avoid int overflow, check null buf
- if (off <= buf.length && nbytes >= 0 && off >= 0
- && buf.length - off >= nbytes) {
- inRead = 0;
- inLength = nbytes;
- setInputImpl(buf, off, nbytes, streamHandle);
- } else {
+ // avoid int overflow, check null buf
+ if (off <= buf.length && nbytes >= 0 && off >= 0
+ && buf.length - off >= nbytes) {
+ inRead = 0;
+ inLength = nbytes;
+ setInputImpl(buf, off, nbytes, streamHandle);
+ } else {
throw new ArrayIndexOutOfBoundsException();
}
-
- if(!gotFirstByte && nbytes>0)
- {
- pass_magic_number_check = (buf[off] == MAGIC_NUMBER || nbytes > 1);
- gotFirstByte = true;
- }
- }
-
- /**
- * Returns a long int of total number of bytes of input read by the
- * Inflater.
- * This method performs the same as getTotalIn except it returns a
- * long value instead of an integer
- *
- * @see getTotalIn
- * @return Total bytes read
- */
- public synchronized long getBytesRead() {
- // Throw NPE here
- if (streamHandle == -1) {
+
+ if (!gotFirstByte && nbytes > 0) {
+ pass_magic_number_check = (buf[off] == MAGIC_NUMBER || nbytes > 1);
+ gotFirstByte = true;
+ }
+ }
+
+ /**
+ * Returns a long int of total number of bytes of input read by the
+ * Inflater. This method performs the same as getTotalIn except it returns a
+ * long value instead of an integer
+ *
+ * @see getTotalIn
+ * @return Total bytes read
+ */
+ public synchronized long getBytesRead() {
+ // Throw NPE here
+ if (streamHandle == -1) {
throw new NullPointerException();
}
- return getTotalInImpl(streamHandle);
- }
+ return getTotalInImpl(streamHandle);
+ }
- /**
- * Returns a long int of total number of bytes of input output by the
- * Inflater.
- * This method performs the same as getTotalOut except it returns a
- * long value instead of an integer
- *
- * @see getTotalOut
- * @return Total bytes output
- */
- public synchronized long getBytesWritten() {
- // Throw NPE here
- if (streamHandle == -1) {
+ /**
+ * Returns a long int of total number of bytes of input output by the
+ * Inflater. This method performs the same as getTotalOut except it returns
+ * a long value instead of an integer
+ *
+ * @see getTotalOut
+ * @return Total bytes output
+ */
+ public synchronized long getBytesWritten() {
+ // Throw NPE here
+ if (streamHandle == -1) {
throw new NullPointerException();
}
- return getTotalOutImpl(streamHandle);
- }
+ return getTotalOutImpl(streamHandle);
+ }
- private native synchronized void setInputImpl(byte[] buf, int off,
- int nbytes, long handle);
+ private native synchronized void setInputImpl(byte[] buf, int off,
+ int nbytes, long handle);
- private native long createStream(boolean noHeader1);
+ private native long createStream(boolean noHeader1);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/InflaterInputStream.java Mon Jul 16 23:30:22 2007
@@ -17,7 +17,6 @@
package java.util.zip;
-
import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
@@ -34,257 +33,259 @@
*/
public class InflaterInputStream extends FilterInputStream {
- protected Inflater inf;
+ protected Inflater inf;
+
+ protected byte[] buf;
+
+ protected int len;
- protected byte[] buf;
+ boolean closed;
- protected int len;
+ boolean eof;
+
+ static final int BUF_SIZE = 512;
+
+ /**
+ * Constructs a new InflaterOutputStream on is
+ *
+ * @param is
+ * The InputStream to read data from
+ */
+ public InflaterInputStream(InputStream is) {
+ this(is, new Inflater(), BUF_SIZE);
+ }
- boolean closed;
+ /**
+ * Constructs a new InflaterOutputStream on is, using the Inflater provided
+ * in inf.
+ *
+ * @param is
+ * The InputStream to read data from
+ * @param inf
+ * The Inflater to use for decompression
+ */
+ public InflaterInputStream(InputStream is, Inflater inf) {
+ this(is, inf, BUF_SIZE);
+ }
- boolean eof;
-
- static final int BUF_SIZE = 512;
-
- /**
- * Constructs a new InflaterOutputStream on is
- *
- * @param is The InputStream to read data from
- */
- public InflaterInputStream(InputStream is) {
- this(is, new Inflater(), BUF_SIZE);
- }
-
- /**
- * Constructs a new InflaterOutputStream on is, using the Inflater provided
- * in inf.
- *
- * @param is
- * The InputStream to read data from
- * @param inf
- * The Inflater to use for decompression
- */
- public InflaterInputStream(InputStream is, Inflater inf) {
- this(is, inf, BUF_SIZE);
- }
-
- /**
- * Constructs a new InflaterOutputStream on is, using the Inflater provided
- * in inf. The size of the inflation buffer is determined by bsize.
- *
- * @param is
- * The InputStream to read data from
- * @param inf
- * The Inflater to use for decompression
- * @param bsize
- * size of the inflation buffer
- */
- public InflaterInputStream(InputStream is, Inflater inf, int bsize) {
- super(is);
- if (is == null || inf == null) {
+ /**
+ * Constructs a new InflaterOutputStream on is, using the Inflater provided
+ * in inf. The size of the inflation buffer is determined by bsize.
+ *
+ * @param is
+ * The InputStream to read data from
+ * @param inf
+ * The Inflater to use for decompression
+ * @param bsize
+ * size of the inflation buffer
+ */
+ public InflaterInputStream(InputStream is, Inflater inf, int bsize) {
+ super(is);
+ if (is == null || inf == null) {
throw new NullPointerException();
}
- if (bsize <= 0) {
+ if (bsize <= 0) {
throw new IllegalArgumentException();
}
- this.inf = inf;
- buf = new byte[bsize];
- }
-
- /**
- * Reads a single byte of decompressed data.
- *
- * @return byte read
- * @throws IOException
- * If an error occurs reading
- */
- @Override
+ this.inf = inf;
+ buf = new byte[bsize];
+ }
+
+ /**
+ * Reads a single byte of decompressed data.
+ *
+ * @return byte read
+ * @throws IOException
+ * If an error occurs reading
+ */
+ @Override
public int read() throws IOException {
- byte[] b = new byte[1];
- if (read(b, 0, 1) == -1) {
+ byte[] b = new byte[1];
+ if (read(b, 0, 1) == -1) {
return -1;
}
- return b[0] & 0xff;
- }
+ return b[0] & 0xff;
+ }
- /**
- * Reads up to nbytes of decompressed data and stores it in buf starting at
- * off.
- *
- * @param buffer
- * Buffer to store into
- * @param off
- * offset in buffer to store at
- * @param nbytes
- * number of bytes to store
- * @return Number of uncompressed bytes read
- * @throws IOException
- * If an error occurs reading
- */
- @Override
+ /**
+ * Reads up to nbytes of decompressed data and stores it in buf starting at
+ * off.
+ *
+ * @param buffer
+ * Buffer to store into
+ * @param off
+ * offset in buffer to store at
+ * @param nbytes
+ * number of bytes to store
+ * @return Number of uncompressed bytes read
+ * @throws IOException
+ * If an error occurs reading
+ */
+ @Override
public int read(byte[] buffer, int off, int nbytes) throws IOException {
- /* archive.1E=Stream is closed */
- if (closed) {
+ /* archive.1E=Stream is closed */
+ if (closed) {
throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
}
- if (null == buffer) {
+ if (null == buffer) {
throw new NullPointerException();
}
- if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) {
+ if (off < 0 || nbytes < 0 || off + nbytes > buffer.length) {
throw new IndexOutOfBoundsException();
}
- if (nbytes == 0) {
+ if (nbytes == 0) {
return 0;
}
- if (inf.finished()) {
- eof = true;
- return -1;
- }
-
- // avoid int overflow, check null buffer
- if (off <= buffer.length && nbytes >= 0 && off >= 0
- && buffer.length - off >= nbytes) {
- do {
- if (inf.needsInput()) {
+ if (inf.finished()) {
+ eof = true;
+ return -1;
+ }
+
+ // avoid int overflow, check null buffer
+ if (off <= buffer.length && nbytes >= 0 && off >= 0
+ && buffer.length - off >= nbytes) {
+ do {
+ if (inf.needsInput()) {
fill();
}
- int result;
- try {
- result = inf.inflate(buffer, off, nbytes);
- } catch (DataFormatException e) {
- if (len == -1) {
+ int result;
+ try {
+ result = inf.inflate(buffer, off, nbytes);
+ } catch (DataFormatException e) {
+ if (len == -1) {
throw new EOFException();
}
- throw (IOException)(new IOException().initCause(e));
- }
- if (result > 0) {
+ throw (IOException) (new IOException().initCause(e));
+ }
+ if (result > 0) {
return result;
} else if (inf.finished()) {
- eof = true;
- return -1;
- } else if (inf.needsDictionary()) {
+ eof = true;
+ return -1;
+ } else if (inf.needsDictionary()) {
return -1;
} else if (len == -1) {
throw new EOFException();
- // If result == 0, fill() and try again
+ // If result == 0, fill() and try again
}
- } while (true);
- }
- throw new ArrayIndexOutOfBoundsException();
- }
+ } while (true);
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
- protected void fill() throws IOException {
- if (closed) {
+ protected void fill() throws IOException {
+ if (closed) {
throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
}
- if ((len = in.read(buf)) > 0) {
+ if ((len = in.read(buf)) > 0) {
inf.setInput(buf, 0, len);
}
- }
+ }
- /**
- * Skips up to nbytes of uncompressed data.
- *
- * @param nbytes
- * Number of bytes to skip
- * @return Number of uncompressed bytes skipped
- * @throws IOException
- * If an error occurs skipping
- */
- @Override
+ /**
+ * Skips up to nbytes of uncompressed data.
+ *
+ * @param nbytes
+ * Number of bytes to skip
+ * @return Number of uncompressed bytes skipped
+ * @throws IOException
+ * If an error occurs skipping
+ */
+ @Override
public long skip(long nbytes) throws IOException {
- if (nbytes >= 0) {
- long count = 0, rem = 0;
- while (count < nbytes) {
- int x = read(buf, 0,
- (rem = nbytes - count) > buf.length ? buf.length
- : (int) rem);
- if (x == -1) {
- eof = true;
- return count;
- }
- count += x;
- }
- return count;
- }
- throw new IllegalArgumentException();
- }
-
- /**
- * Returns 0 if this stream has been closed, 1 otherwise.
- *
- * @throws IOException
- * If an error occurs
- */
- @Override
+ if (nbytes >= 0) {
+ long count = 0, rem = 0;
+ while (count < nbytes) {
+ int x = read(buf, 0,
+ (rem = nbytes - count) > buf.length ? buf.length
+ : (int) rem);
+ if (x == -1) {
+ eof = true;
+ return count;
+ }
+ count += x;
+ }
+ return count;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * Returns 0 if this stream has been closed, 1 otherwise.
+ *
+ * @throws IOException
+ * If an error occurs
+ */
+ @Override
public int available() throws IOException {
- if (closed) {
+ if (closed) {
// archive.1E=Stream is closed
throw new IOException(Messages.getString("archive.1E")); //$NON-NLS-1$
}
- if (eof) {
+ if (eof) {
return 0;
}
- return 1;
- }
+ return 1;
+ }
- /**
- * Closes the stream
- *
- * @throws IOException
- * If an error occurs closing the stream
- */
- @Override
+ /**
+ * Closes the stream
+ *
+ * @throws IOException
+ * If an error occurs closing the stream
+ */
+ @Override
public void close() throws IOException {
- if (!closed) {
- inf.end();
- closed = true;
- eof = true;
- super.close();
- }
- }
-
- /**
- * Marks the current position in the stream.
- *
- * This implementation overrides the supertype implementation to do nothing
- * at all.
- *
- * @param readlimit
- * of no use
- */
- @Override
+ if (!closed) {
+ inf.end();
+ closed = true;
+ eof = true;
+ super.close();
+ }
+ }
+
+ /**
+ * Marks the current position in the stream.
+ *
+ * This implementation overrides the supertype implementation to do nothing
+ * at all.
+ *
+ * @param readlimit
+ * of no use
+ */
+ @Override
@SuppressWarnings("unused")
public void mark(int readlimit) {
- // do nothing
- }
+ // do nothing
+ }
/**
- * Reset the position of the stream to the last mark position.
- *
- * This implementation overrides the supertype implementation and always
- * throws an {@link IOException IOException} when called.
- *
- * @throws IOException
- * if the method is called
- */
+ * Reset the position of the stream to the last mark position.
+ *
+ * This implementation overrides the supertype implementation and always
+ * throws an {@link IOException IOException} when called.
+ *
+ * @throws IOException
+ * if the method is called
+ */
@Override
- public void reset() throws IOException{
+ public void reset() throws IOException {
throw new IOException();
}
-
+
/**
- * Answers whether the receiver implements mark semantics. This type
- * does not support mark, so always responds <code>false</code>.
- * @return false
- */
- @Override
+ * Answers whether the receiver implements mark semantics. This type does
+ * not support mark, so always responds <code>false</code>.
+ *
+ * @return false
+ */
+ @Override
public boolean markSupported() {
- return false;
- }
+ return false;
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipConstants.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipConstants.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipConstants.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/zip/ZipConstants.java Mon Jul 16 23:30:22 2007
@@ -17,18 +17,17 @@
package java.util.zip;
-
interface ZipConstants {
- public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
- CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
+ public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
+ CENSIG = 0x2014b50, ENDSIG = 0x6054b50;
- public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
- LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
- LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
- EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
- CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
- CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
- CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
- ENDOFF = 16, ENDCOM = 20;
+ public static final int LOCHDR = 30, EXTHDR = 16, CENHDR = 46, ENDHDR = 22,
+ LOCVER = 4, LOCFLG = 6, LOCHOW = 8, LOCTIM = 10, LOCCRC = 14,
+ LOCSIZ = 18, LOCLEN = 22, LOCNAM = 26, LOCEXT = 28, EXTCRC = 4,
+ EXTSIZ = 8, EXTLEN = 12, CENVEM = 4, CENVER = 6, CENFLG = 8,
+ CENHOW = 10, CENTIM = 12, CENCRC = 16, CENSIZ = 20, CENLEN = 24,
+ CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
+ CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
+ ENDOFF = 16, ENDCOM = 20;
}