harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r446478 [6/11] - in /incubator/harmony/enhanced/classlib/trunk/modules/archive: ./ .settings/ META-INF/ make/ src/main/java/java/util/jar/ src/main/java/java/util/zip/ src/main/java/org/apache/harmony/archive/internal/pack200/ src/main/nati...
Date Fri, 15 Sep 2006 02:40:36 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java Thu Sep 14 19:40:33 2006
@@ -1,176 +1,176 @@
-/*
- *  Copyright 2006 The Apache Software Foundation or its licensors, 
- *  as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.harmony.archive.internal.pack200;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class CodecEncoding {
-	/**
-	 * The canonical encodings are defined to allow a single byte to represent
-	 * one of the standard encodings. The following values are defined in the
-	 * Pack200 specification, and this array cannot be changed.
-	 */
-	private static Codec[] canonicalCodec = { null, new BHSDCodec(1, 256),
-			new BHSDCodec(1, 256, 1), new BHSDCodec(1, 256, 0, 1),
-			new BHSDCodec(1, 256, 1, 1), new BHSDCodec(2, 256),
-			new BHSDCodec(2, 256, 1), new BHSDCodec(2, 256, 0, 1),
-			new BHSDCodec(2, 256, 1, 1), new BHSDCodec(3, 256),
-			new BHSDCodec(3, 256, 1), new BHSDCodec(3, 256, 0, 1),
-			new BHSDCodec(3, 256, 1, 1), new BHSDCodec(4, 256),
-			new BHSDCodec(4, 256, 1), new BHSDCodec(4, 256, 0, 1),
-			new BHSDCodec(4, 256, 1, 1), new BHSDCodec(5, 4), new BHSDCodec(5, 4, 1),
-			new BHSDCodec(5, 4, 2), new BHSDCodec(5, 16), new BHSDCodec(5, 16, 1),
-			new BHSDCodec(5, 16, 2), new BHSDCodec(5, 32), new BHSDCodec(5, 32, 1),
-			new BHSDCodec(5, 32, 2), new BHSDCodec(5, 64), new BHSDCodec(5, 64, 1),
-			new BHSDCodec(5, 64, 2), new BHSDCodec(5, 128), new BHSDCodec(5, 128, 1),
-			new BHSDCodec(5, 128, 2), new BHSDCodec(5, 4, 0, 1), 
-			new BHSDCodec(5, 4, 1, 1), new BHSDCodec(5, 4, 2, 1),
-			new BHSDCodec(5, 16, 0, 1), new BHSDCodec(5, 16, 1, 1),
-			new BHSDCodec(5, 16, 2, 1), new BHSDCodec(5, 32, 0, 1),
-			new BHSDCodec(5, 32, 1, 1), new BHSDCodec(5, 32, 2, 1),
-			new BHSDCodec(5, 64, 0, 1), new BHSDCodec(5, 64, 1, 1),new BHSDCodec(5, 64, 2, 1),
-			new BHSDCodec(5, 128, 0, 1), new BHSDCodec(5, 128, 1, 1),
-			new BHSDCodec(5, 128, 2, 1), new BHSDCodec(2, 192),
-			new BHSDCodec(2, 224), new BHSDCodec(2, 240), new BHSDCodec(2, 248),
-			new BHSDCodec(2, 252), new BHSDCodec(2, 8, 0, 1), new BHSDCodec(2, 8, 1, 1),
-			new BHSDCodec(2, 16, 0, 1), new BHSDCodec(2, 16, 1, 1),
-			new BHSDCodec(2, 32, 0, 1), new BHSDCodec(2, 32, 1, 1),
-			new BHSDCodec(2, 64, 0, 1), new BHSDCodec(2, 64, 1, 1),
-			new BHSDCodec(2, 128, 0, 1), new BHSDCodec(2, 128, 1, 1),
-			new BHSDCodec(2, 192, 0, 1), new BHSDCodec(2, 192, 1, 1),
-			new BHSDCodec(2, 224, 0, 1), new BHSDCodec(2, 224, 1, 1),
-			new BHSDCodec(2, 240, 0, 1), new BHSDCodec(2, 240, 1, 1),
-			new BHSDCodec(2, 248, 0, 1), new BHSDCodec(2, 248, 1, 1),
-			new BHSDCodec(3, 192), new BHSDCodec(3, 224), new BHSDCodec(3, 240),
-			new BHSDCodec(3, 248), new BHSDCodec(3, 252), new BHSDCodec(3, 8, 0, 1),
-			new BHSDCodec(3, 8, 1, 1), new BHSDCodec(3, 16, 0, 1),
-			new BHSDCodec(3, 16, 1, 1), new BHSDCodec(3, 32, 0, 1),
-			new BHSDCodec(3, 32, 1, 1), new BHSDCodec(3, 64, 0, 1),
-			new BHSDCodec(3, 64, 1, 1), new BHSDCodec(3, 128, 0, 1),
-			new BHSDCodec(3, 128, 1, 1), new BHSDCodec(3, 192, 0, 1),
-			new BHSDCodec(3, 192, 1, 1), new BHSDCodec(3, 224, 0, 1),
-			new BHSDCodec(3, 224, 1, 1), new BHSDCodec(3, 240, 0, 1),
-			new BHSDCodec(3, 240, 1, 1), new BHSDCodec(3, 248, 0, 1),
-			new BHSDCodec(3, 248, 1, 1), new BHSDCodec(4, 192),
-			new BHSDCodec(4, 224), new BHSDCodec(4, 240), new BHSDCodec(4, 248),
-			new BHSDCodec(4, 252), new BHSDCodec(4, 8, 0, 1), new BHSDCodec(4, 8, 1, 1),
-			new BHSDCodec(4, 16, 0, 1), new BHSDCodec(4, 16, 1, 1),
-			new BHSDCodec(4, 32, 0, 1), new BHSDCodec(4, 32, 1, 1),
-			new BHSDCodec(4, 64, 0, 1), new BHSDCodec(4, 64, 1, 1),
-			new BHSDCodec(4, 128, 0, 1), new BHSDCodec(4, 128, 1, 1),
-			new BHSDCodec(4, 192, 0, 1), new BHSDCodec(4, 192, 1, 1),
-			new BHSDCodec(4, 224, 0, 1), new BHSDCodec(4, 224, 1, 1),
-			new BHSDCodec(4, 240, 0, 1), new BHSDCodec(4, 240, 1, 1),
-			new BHSDCodec(4, 248, 0, 1), new BHSDCodec(4, 248, 1, 1) };
-
-	/** 
-	 * Returns the codec specified by the given value byte and optional byte header.
-	 * If the value is >=116, then bytes may be consumed from the secondary input
-	 * stream, which is taken to be the contents of the band_headers byte array.
-	 * Since the values from this are consumed and not repeated, the input stream
-	 * should be reused for subsequent encodings. This does not therefore close
-	 * the input stream.
-	 * @param value the canonical encoding value
-	 * @param in the input stream to read additional byte headers from
-	 * @param defaultCodec TODO
-	 * @return the corresponding codec, or <code>null</code> if the default should be used
-	 * @throws IOException 
-	 * @throws IOException if there is a problem reading from the input stream (which
-	 * in reality, is never, since the band_headers are likely stored in a byte array
-	 * and accessed via a ByteArrayInputStream. However, an EOFException could occur
-	 * if things go titsup.com.
-	 * @throws Pack200Exception 
-	 */
-	public static Codec getCodec(int value, InputStream in, Codec defaultCodec) throws IOException, Pack200Exception {
-		// Sanity check to make sure that no-one's been buggering with
-		// the canonical codecs, which would really cause havoc
-		if (canonicalCodec.length != 116) 
-			throw new Error("Canonical encodings have been incorrectly modified");
-		if (value < 0) {
-			throw new IllegalArgumentException(
-					"Encoding cannot be less than zero");
-		} else if (value == 0) {
-			return defaultCodec;
-		} else if (value <= 115) {
-			return canonicalCodec[value];
-		} else if (value == 116) {
-			int code = in.read();
-			if (code == -1)
-				throw new EOFException("End of buffer read whilst trying to decode codec");
-			int d = (code & 0x01);
-			int s = (code >> 1 & 0x03);
-			int b = (code >> 3 & 0x07) + 1; // this might result in an invalid number, but it's checked in the Codec constructor
-			code = in.read();
-			if (code == -1)
-				throw new EOFException("End of buffer read whilst trying to decode codec");
-			int h = code + 1;
-			// This handles the special cases for invalid combinations of data.
-			return new BHSDCodec(b,h,s,d);			
-		} else if (value >= 117 && value <= 140) {
-			int offset = value - 117;
-			int kx = offset & 3;
-			boolean kbflag = (offset >> 2 & 1) == 1;
-			boolean adef = (offset >> 3 & 1) == 1;
-			boolean bdef = (offset >> 4 & 1) == 1;
-			// If both A and B use the default encoding, what's the point of having a run of default values followed by default values
-			if (adef && bdef)
-				throw new Pack200Exception("ADef and BDef should never both be true");
-			int kb = (kbflag ? in.read() : 3);
-			int k = (kb+1) * (int)Math.pow(16, kx);
-			Codec aCodec, bCodec;
-			if (adef) {
-				aCodec = defaultCodec;
-			} else {
-				aCodec = getCodec(in.read(),in,defaultCodec); 
-			}
-			if (bdef) {
-				bCodec = defaultCodec;
-			} else {
-				bCodec = getCodec(in.read(),in,defaultCodec); 
-			}
-			return new RunCodec(k,aCodec,bCodec);
-		} else if (value >= 141 && value <= 188) {
-			int offset = value - 141;
-			boolean fdef = (offset & 1) == 1; 
-			boolean udef = (offset >> 1 & 1) == 1;
-			int tdefl = offset >> 2;
-			boolean tdef = tdefl == 0;
-			// From section 6.7.3 of spec
-			final int[] tdefToL= {0,4,8,16,32,64,128,192,224,240,248,252 };
-			int l = tdefToL[tdefl];
-			// NOTE: Do not re-factor this to bring out uCodec; the order in which
-			// they are read from the stream is important
-			if (tdef) {
-				Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
-				Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
-				// Unfortunately, if tdef, then tCodec depends both on l and also on k, the
-				// number of items read from the fCodec. So we don't know in advance what
-				// the codec will be.
-				return new PopulationCodec(fCodec,l,uCodec);
-			} else {
-				Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
-				Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
-				Codec tCodec = getCodec(in.read(),in,defaultCodec);
-				return new PopulationCodec(fCodec,uCodec,tCodec);
-			}
-		} else {
-			throw new Pack200Exception("Invalid codec encoding byte (" + value + ") found" );
-		}
-	}
-}
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, 
+ *  as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.archive.internal.pack200;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class CodecEncoding {
+	/**
+	 * The canonical encodings are defined to allow a single byte to represent
+	 * one of the standard encodings. The following values are defined in the
+	 * Pack200 specification, and this array cannot be changed.
+	 */
+	private static Codec[] canonicalCodec = { null, new BHSDCodec(1, 256),
+			new BHSDCodec(1, 256, 1), new BHSDCodec(1, 256, 0, 1),
+			new BHSDCodec(1, 256, 1, 1), new BHSDCodec(2, 256),
+			new BHSDCodec(2, 256, 1), new BHSDCodec(2, 256, 0, 1),
+			new BHSDCodec(2, 256, 1, 1), new BHSDCodec(3, 256),
+			new BHSDCodec(3, 256, 1), new BHSDCodec(3, 256, 0, 1),
+			new BHSDCodec(3, 256, 1, 1), new BHSDCodec(4, 256),
+			new BHSDCodec(4, 256, 1), new BHSDCodec(4, 256, 0, 1),
+			new BHSDCodec(4, 256, 1, 1), new BHSDCodec(5, 4), new BHSDCodec(5, 4, 1),
+			new BHSDCodec(5, 4, 2), new BHSDCodec(5, 16), new BHSDCodec(5, 16, 1),
+			new BHSDCodec(5, 16, 2), new BHSDCodec(5, 32), new BHSDCodec(5, 32, 1),
+			new BHSDCodec(5, 32, 2), new BHSDCodec(5, 64), new BHSDCodec(5, 64, 1),
+			new BHSDCodec(5, 64, 2), new BHSDCodec(5, 128), new BHSDCodec(5, 128, 1),
+			new BHSDCodec(5, 128, 2), new BHSDCodec(5, 4, 0, 1), 
+			new BHSDCodec(5, 4, 1, 1), new BHSDCodec(5, 4, 2, 1),
+			new BHSDCodec(5, 16, 0, 1), new BHSDCodec(5, 16, 1, 1),
+			new BHSDCodec(5, 16, 2, 1), new BHSDCodec(5, 32, 0, 1),
+			new BHSDCodec(5, 32, 1, 1), new BHSDCodec(5, 32, 2, 1),
+			new BHSDCodec(5, 64, 0, 1), new BHSDCodec(5, 64, 1, 1),new BHSDCodec(5, 64, 2, 1),
+			new BHSDCodec(5, 128, 0, 1), new BHSDCodec(5, 128, 1, 1),
+			new BHSDCodec(5, 128, 2, 1), new BHSDCodec(2, 192),
+			new BHSDCodec(2, 224), new BHSDCodec(2, 240), new BHSDCodec(2, 248),
+			new BHSDCodec(2, 252), new BHSDCodec(2, 8, 0, 1), new BHSDCodec(2, 8, 1, 1),
+			new BHSDCodec(2, 16, 0, 1), new BHSDCodec(2, 16, 1, 1),
+			new BHSDCodec(2, 32, 0, 1), new BHSDCodec(2, 32, 1, 1),
+			new BHSDCodec(2, 64, 0, 1), new BHSDCodec(2, 64, 1, 1),
+			new BHSDCodec(2, 128, 0, 1), new BHSDCodec(2, 128, 1, 1),
+			new BHSDCodec(2, 192, 0, 1), new BHSDCodec(2, 192, 1, 1),
+			new BHSDCodec(2, 224, 0, 1), new BHSDCodec(2, 224, 1, 1),
+			new BHSDCodec(2, 240, 0, 1), new BHSDCodec(2, 240, 1, 1),
+			new BHSDCodec(2, 248, 0, 1), new BHSDCodec(2, 248, 1, 1),
+			new BHSDCodec(3, 192), new BHSDCodec(3, 224), new BHSDCodec(3, 240),
+			new BHSDCodec(3, 248), new BHSDCodec(3, 252), new BHSDCodec(3, 8, 0, 1),
+			new BHSDCodec(3, 8, 1, 1), new BHSDCodec(3, 16, 0, 1),
+			new BHSDCodec(3, 16, 1, 1), new BHSDCodec(3, 32, 0, 1),
+			new BHSDCodec(3, 32, 1, 1), new BHSDCodec(3, 64, 0, 1),
+			new BHSDCodec(3, 64, 1, 1), new BHSDCodec(3, 128, 0, 1),
+			new BHSDCodec(3, 128, 1, 1), new BHSDCodec(3, 192, 0, 1),
+			new BHSDCodec(3, 192, 1, 1), new BHSDCodec(3, 224, 0, 1),
+			new BHSDCodec(3, 224, 1, 1), new BHSDCodec(3, 240, 0, 1),
+			new BHSDCodec(3, 240, 1, 1), new BHSDCodec(3, 248, 0, 1),
+			new BHSDCodec(3, 248, 1, 1), new BHSDCodec(4, 192),
+			new BHSDCodec(4, 224), new BHSDCodec(4, 240), new BHSDCodec(4, 248),
+			new BHSDCodec(4, 252), new BHSDCodec(4, 8, 0, 1), new BHSDCodec(4, 8, 1, 1),
+			new BHSDCodec(4, 16, 0, 1), new BHSDCodec(4, 16, 1, 1),
+			new BHSDCodec(4, 32, 0, 1), new BHSDCodec(4, 32, 1, 1),
+			new BHSDCodec(4, 64, 0, 1), new BHSDCodec(4, 64, 1, 1),
+			new BHSDCodec(4, 128, 0, 1), new BHSDCodec(4, 128, 1, 1),
+			new BHSDCodec(4, 192, 0, 1), new BHSDCodec(4, 192, 1, 1),
+			new BHSDCodec(4, 224, 0, 1), new BHSDCodec(4, 224, 1, 1),
+			new BHSDCodec(4, 240, 0, 1), new BHSDCodec(4, 240, 1, 1),
+			new BHSDCodec(4, 248, 0, 1), new BHSDCodec(4, 248, 1, 1) };
+
+	/** 
+	 * Returns the codec specified by the given value byte and optional byte header.
+	 * If the value is >=116, then bytes may be consumed from the secondary input
+	 * stream, which is taken to be the contents of the band_headers byte array.
+	 * Since the values from this are consumed and not repeated, the input stream
+	 * should be reused for subsequent encodings. This does not therefore close
+	 * the input stream.
+	 * @param value the canonical encoding value
+	 * @param in the input stream to read additional byte headers from
+	 * @param defaultCodec TODO
+	 * @return the corresponding codec, or <code>null</code> if the default should be used
+	 * @throws IOException 
+	 * @throws IOException if there is a problem reading from the input stream (which
+	 * in reality, is never, since the band_headers are likely stored in a byte array
+	 * and accessed via a ByteArrayInputStream. However, an EOFException could occur
+	 * if things go titsup.com.
+	 * @throws Pack200Exception 
+	 */
+	public static Codec getCodec(int value, InputStream in, Codec defaultCodec) throws IOException, Pack200Exception {
+		// Sanity check to make sure that no-one's been buggering with
+		// the canonical codecs, which would really cause havoc
+		if (canonicalCodec.length != 116) 
+			throw new Error("Canonical encodings have been incorrectly modified");
+		if (value < 0) {
+			throw new IllegalArgumentException(
+					"Encoding cannot be less than zero");
+		} else if (value == 0) {
+			return defaultCodec;
+		} else if (value <= 115) {
+			return canonicalCodec[value];
+		} else if (value == 116) {
+			int code = in.read();
+			if (code == -1)
+				throw new EOFException("End of buffer read whilst trying to decode codec");
+			int d = (code & 0x01);
+			int s = (code >> 1 & 0x03);
+			int b = (code >> 3 & 0x07) + 1; // this might result in an invalid number, but it's checked in the Codec constructor
+			code = in.read();
+			if (code == -1)
+				throw new EOFException("End of buffer read whilst trying to decode codec");
+			int h = code + 1;
+			// This handles the special cases for invalid combinations of data.
+			return new BHSDCodec(b,h,s,d);			
+		} else if (value >= 117 && value <= 140) {
+			int offset = value - 117;
+			int kx = offset & 3;
+			boolean kbflag = (offset >> 2 & 1) == 1;
+			boolean adef = (offset >> 3 & 1) == 1;
+			boolean bdef = (offset >> 4 & 1) == 1;
+			// If both A and B use the default encoding, what's the point of having a run of default values followed by default values
+			if (adef && bdef)
+				throw new Pack200Exception("ADef and BDef should never both be true");
+			int kb = (kbflag ? in.read() : 3);
+			int k = (kb+1) * (int)Math.pow(16, kx);
+			Codec aCodec, bCodec;
+			if (adef) {
+				aCodec = defaultCodec;
+			} else {
+				aCodec = getCodec(in.read(),in,defaultCodec); 
+			}
+			if (bdef) {
+				bCodec = defaultCodec;
+			} else {
+				bCodec = getCodec(in.read(),in,defaultCodec); 
+			}
+			return new RunCodec(k,aCodec,bCodec);
+		} else if (value >= 141 && value <= 188) {
+			int offset = value - 141;
+			boolean fdef = (offset & 1) == 1; 
+			boolean udef = (offset >> 1 & 1) == 1;
+			int tdefl = offset >> 2;
+			boolean tdef = tdefl == 0;
+			// From section 6.7.3 of spec
+			final int[] tdefToL= {0,4,8,16,32,64,128,192,224,240,248,252 };
+			int l = tdefToL[tdefl];
+			// NOTE: Do not re-factor this to bring out uCodec; the order in which
+			// they are read from the stream is important
+			if (tdef) {
+				Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+				Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+				// Unfortunately, if tdef, then tCodec depends both on l and also on k, the
+				// number of items read from the fCodec. So we don't know in advance what
+				// the codec will be.
+				return new PopulationCodec(fCodec,l,uCodec);
+			} else {
+				Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+				Codec uCodec = (udef ? defaultCodec : getCodec(in.read(),in,defaultCodec) );
+				Codec tCodec = getCodec(in.read(),in,defaultCodec);
+				return new PopulationCodec(fCodec,uCodec,tCodec);
+			}
+		} else {
+			throw new Pack200Exception("Invalid codec encoding byte (" + value + ") found" );
+		}
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/CodecEncoding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/PopulationCodec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/PopulationCodec.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/PopulationCodec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/PopulationCodec.java Thu Sep 14 19:40:33 2006
@@ -1,106 +1,106 @@
-/*
- *  Copyright 2006 The Apache Software Foundation or its licensors, 
- *  as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.harmony.archive.internal.pack200;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class PopulationCodec extends Codec {
-	private Codec favouredCodec;
-	private Codec tokenCodec;
-	private Codec unvafouredCodec;
-	private int l;
-	
-	public PopulationCodec(Codec favouredCodec, Codec tableCodec, Codec unvafouredCodec) {
-		this.favouredCodec = favouredCodec;
-		this.tokenCodec = tableCodec;
-		this.unvafouredCodec = unvafouredCodec;
-	}
-
-	public PopulationCodec(Codec favouredCodec, int l, Codec unvafouredCodec) {
-		if (l >= 256 || l <=0)
-			throw new IllegalArgumentException("L must be between 1..255");
-		this.favouredCodec = favouredCodec;
-		this.l = l;
-		this.unvafouredCodec = unvafouredCodec;
-	}
-
-	@Override
-	public long decode(InputStream in) throws IOException, Pack200Exception {
-		throw new Pack200Exception("Population encoding does not work unless the number of elements are known");
-	}
-
-	@Override
-	public long decode(InputStream in, long last) throws IOException,
-			Pack200Exception {
-		throw new Pack200Exception("Population encoding does not work unless the number of elements are known");
-	}
-
-	@Override
-	public long[] decode(int n, InputStream in) throws IOException, Pack200Exception {
-		long favoured[] =new long[n]; // there must be <= n  values, but probably a lot less
-		long result[];
-		// read table of favourites first
-		long smallest = Long.MAX_VALUE;
-		long last = 0;
-		long value = 0; // TODO Are these sensible starting points?
-		int k = -1;
-		while( true ) {
-			last = value;
-			value = favouredCodec.decode(in,last);
-			if ( value == smallest || value == last)
-				break;
-			favoured[++k] = value;
-			if (Math.abs(smallest) > Math.abs(value)) {
-				smallest = value;
-			} else if (Math.abs(smallest) == Math.abs(value) ) {
-				// ensure that -X and +X -> +X
-				smallest = Math.abs(smallest);
-			}
-		} 
-		// if tokenCodec needs to be derived from the T, L and K values
-		if (tokenCodec == null) {
-			if (k < 256) {
-				tokenCodec = Codec.BYTE1;
-			} else {
-				// if k >= 256, b >= 2
-				int b = 1;
-				while(++b < 5 && tokenCodec == null) {
-					BHSDCodec codec = new BHSDCodec(b,256-l,0);
-					if (codec.encodes(k))
-						tokenCodec = codec;
-				}
-				if (tokenCodec == null)
-					throw new Pack200Exception("Cannot calculate token codec from " + k + " and " + l);
-			}
-		}
-		// read favourites
-		result = tokenCodec.decode(n, in);
-		// read unfavourites
-		last = 0;
-		for(int i=0;i<n;i++) {
-			int index = (int) result[i];
-			if (index == 0) {
-				result[i] = unvafouredCodec.decode(in, last);
-			} else {
-				result[i] = favoured[index-1];
-			}
-		}
-		return result;
-	}	
-}
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, 
+ *  as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.archive.internal.pack200;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class PopulationCodec extends Codec {
+	private Codec favouredCodec;
+	private Codec tokenCodec;
+	private Codec unvafouredCodec;
+	private int l;
+	
+	public PopulationCodec(Codec favouredCodec, Codec tableCodec, Codec unvafouredCodec) {
+		this.favouredCodec = favouredCodec;
+		this.tokenCodec = tableCodec;
+		this.unvafouredCodec = unvafouredCodec;
+	}
+
+	public PopulationCodec(Codec favouredCodec, int l, Codec unvafouredCodec) {
+		if (l >= 256 || l <=0)
+			throw new IllegalArgumentException("L must be between 1..255");
+		this.favouredCodec = favouredCodec;
+		this.l = l;
+		this.unvafouredCodec = unvafouredCodec;
+	}
+
+	@Override
+	public long decode(InputStream in) throws IOException, Pack200Exception {
+		throw new Pack200Exception("Population encoding does not work unless the number of elements are known");
+	}
+
+	@Override
+	public long decode(InputStream in, long last) throws IOException,
+			Pack200Exception {
+		throw new Pack200Exception("Population encoding does not work unless the number of elements are known");
+	}
+
+	@Override
+	public long[] decode(int n, InputStream in) throws IOException, Pack200Exception {
+		long favoured[] =new long[n]; // there must be <= n  values, but probably a lot less
+		long result[];
+		// read table of favourites first
+		long smallest = Long.MAX_VALUE;
+		long last = 0;
+		long value = 0; // TODO Are these sensible starting points?
+		int k = -1;
+		while( true ) {
+			last = value;
+			value = favouredCodec.decode(in,last);
+			if ( value == smallest || value == last)
+				break;
+			favoured[++k] = value;
+			if (Math.abs(smallest) > Math.abs(value)) {
+				smallest = value;
+			} else if (Math.abs(smallest) == Math.abs(value) ) {
+				// ensure that -X and +X -> +X
+				smallest = Math.abs(smallest);
+			}
+		} 
+		// if tokenCodec needs to be derived from the T, L and K values
+		if (tokenCodec == null) {
+			if (k < 256) {
+				tokenCodec = Codec.BYTE1;
+			} else {
+				// if k >= 256, b >= 2
+				int b = 1;
+				while(++b < 5 && tokenCodec == null) {
+					BHSDCodec codec = new BHSDCodec(b,256-l,0);
+					if (codec.encodes(k))
+						tokenCodec = codec;
+				}
+				if (tokenCodec == null)
+					throw new Pack200Exception("Cannot calculate token codec from " + k + " and " + l);
+			}
+		}
+		// read favourites
+		result = tokenCodec.decode(n, in);
+		// read unfavourites
+		last = 0;
+		for(int i=0;i<n;i++) {
+			int index = (int) result[i];
+			if (index == 0) {
+				result[i] = unvafouredCodec.decode(in, last);
+			} else {
+				result[i] = favoured[index-1];
+			}
+		}
+		return result;
+	}	
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/PopulationCodec.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java Thu Sep 14 19:40:33 2006
@@ -1,63 +1,63 @@
-/*
- *  Copyright 2006 The Apache Software Foundation or its licensors, 
- *  as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.harmony.archive.internal.pack200;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * A run codec is a grouping of two nested codecs; K values are decoded from
- * the first codec, and the remaining codes are decoded from the remaining
- * codec. Note that since this codec maintains state, the instances are
- * not reusable.
- *
- * @author Alex Blewitt
- * @version $Revision: $
- */
-public class RunCodec extends Codec {
-	private int k;
-	private Codec aCodec;
-	private Codec bCodec;
-	private long last;
-
-	public RunCodec(int k, Codec aCodec, Codec bCodec) throws Pack200Exception {
-		if (k <= 0)
-			throw new Pack200Exception("Cannot have a RunCodec for a negative number of numbers");
-		if (aCodec == null || bCodec == null)
-			throw new Pack200Exception("Must supply both codecs for a RunCodec");
-		this.k = k;
-		this.aCodec = aCodec;
-		this.bCodec = bCodec;
-	}
-	public long decode(InputStream in) throws IOException, Pack200Exception {
-		return decode(in,this.last);
-	}
-
-	public long decode(InputStream in, long last) throws IOException, Pack200Exception {
-		if(--k>=0) {
-			long value = aCodec.decode(in,last);
-			this.last = (k == 0 ? 0 : value);
-			return value;
-		} else {
-			this.last = bCodec.decode(in,last);
-			return this.last;			
-		}
-	}
-	public String toString() {
-		return "RunCodec[k="+k+";aCodec="+aCodec+"bCodec="+bCodec+"]";
-	}
-}
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, 
+ *  as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.archive.internal.pack200;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A run codec is a grouping of two nested codecs; K values are decoded from
+ * the first codec, and the remaining codes are decoded from the remaining
+ * codec. Note that since this codec maintains state, the instances are
+ * not reusable.
+ *
+ * @author Alex Blewitt
+ * @version $Revision: $
+ */
+public class RunCodec extends Codec {
+	private int k;
+	private Codec aCodec;
+	private Codec bCodec;
+	private long last;
+
+	public RunCodec(int k, Codec aCodec, Codec bCodec) throws Pack200Exception {
+		if (k <= 0)
+			throw new Pack200Exception("Cannot have a RunCodec for a negative number of numbers");
+		if (aCodec == null || bCodec == null)
+			throw new Pack200Exception("Must supply both codecs for a RunCodec");
+		this.k = k;
+		this.aCodec = aCodec;
+		this.bCodec = bCodec;
+	}
+	public long decode(InputStream in) throws IOException, Pack200Exception {
+		return decode(in,this.last);
+	}
+
+	public long decode(InputStream in, long last) throws IOException, Pack200Exception {
+		if(--k>=0) {
+			long value = aCodec.decode(in,last);
+			this.last = (k == 0 ? 0 : value);
+			return value;
+		} else {
+			this.last = bCodec.decode(in,last);
+			return this.last;			
+		}
+	}
+	public String toString() {
+		return "RunCodec[k="+k+";aCodec="+aCodec+"bCodec="+bCodec+"]";
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/RunCodec.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/linux/DoxygenSupport.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/linux/DoxygenSupport.txt?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/linux/DoxygenSupport.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/linux/DoxygenSupport.txt Thu Sep 14 19:40:33 2006
@@ -1,24 +1,24 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * This file provides the group definitions required to create the Doxygen generated
- * output for compounds.  
- */
- 
-/**
- * @defgroup HarmonyNatives Harmony JCL Natives
- * @brief Native support for the Harmony JCL
- */
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This file provides the group definitions required to create the Doxygen generated
+ * output for compounds.  
+ */
+ 
+/**
+ * @defgroup HarmonyNatives Harmony JCL Natives
+ * @brief Native support for the Harmony JCL
+ */

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/linux/DoxygenSupport.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/adler32.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/adler32.c?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/adler32.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/adler32.c Thu Sep 14 19:40:33 2006
@@ -1,45 +1,45 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "vmi.h"
-#include "zconf.h"
-uLong adler32 PROTOTYPE ((uLong crc, const Bytef * buf, uInt size));
-
-jlong JNICALL
-Java_java_util_zip_Adler32_updateImpl (JNIEnv * env, jobject recv,
-                                       jbyteArray buf, int off, int len,
-                                       jlong crc)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  jbyte *b;
-  jboolean isCopy;
-  jlong result;
-
-  b = (*env)->GetPrimitiveArrayCritical (env, buf, &isCopy);
-  result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len);
-  (*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT);
-
-  return result;
-}
-
-jlong JNICALL
-Java_java_util_zip_Adler32_updateByteImpl (JNIEnv * env, jobject recv,
-                                           jint val, jlong crc)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  return adler32 ((uLong) crc, (Bytef *) (&val), 1);
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vmi.h"
+#include "zconf.h"
+uLong adler32 PROTOTYPE ((uLong crc, const Bytef * buf, uInt size));
+
+jlong JNICALL
+Java_java_util_zip_Adler32_updateImpl (JNIEnv * env, jobject recv,
+                                       jbyteArray buf, int off, int len,
+                                       jlong crc)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *b;
+  jboolean isCopy;
+  jlong result;
+
+  b = (*env)->GetPrimitiveArrayCritical (env, buf, &isCopy);
+  result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len);
+  (*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT);
+
+  return result;
+}
+
+jlong JNICALL
+Java_java_util_zip_Adler32_updateByteImpl (JNIEnv * env, jobject recv,
+                                           jint val, jlong crc)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  return adler32 ((uLong) crc, (Bytef *) (&val), 1);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/adler32.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archive_copyright.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archive_copyright.c?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archive_copyright.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archive_copyright.c Thu Sep 14 19:40:33 2006
@@ -1,20 +1,20 @@
-/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* A copyright string included in each DLL and executable */
-
-const char hyCopyright[] =
-  "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";
-
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archive_copyright.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c Thu Sep 14 19:40:33 2006
@@ -1,143 +1,143 @@
-/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* HarmonyDoxygen */
-/**
- * @file
- * @ingroup HarmonyNatives
- * @brief Harmony Archive natives initialization API.
- */
-
-#include "vmi.h"
-#include "jclglob.h"
-#include "zip.h"
-#include <string.h>
-
-static UDATA keyInitCount = 0;
-
-void *JCL_ID_CACHE = NULL;
-
-static void freeReferences (JNIEnv * env);
-
-/**
- * This DLL is being loaded, do any initialization required.
- * This may be called more than once.
- */
-jint JNICALL
-JNI_OnLoad (JavaVM * vm, void *reserved)
-{
-  JniIDCache *idCache;
-  JNIEnv *env;
-  void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
-  void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
-
-  if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
-    {
-      PORT_ACCESS_FROM_ENV (env);
-
-      if (HY_VMLS_FNTBL (env)->
-          HYVMLSAllocKeys (env, keyInitCountPtr, jclIdCache, NULL))
-        {
-          goto fail;
-        }
-
-      /* This allocate must actually be done by hymem_allocate_memory. */
-      idCache = (JniIDCache *) hymem_allocate_memory (sizeof (JniIDCache));
-      if (!idCache)
-        goto fail2;
-
-      memset (idCache, 0, sizeof (JniIDCache));
-      HY_VMLS_SET (env, *jclIdCache, idCache);
-
-      /* Attach to the common library */
-      if (JNI_OK != ClearLibAttach (env))
-        {
-          goto fail2;
-        }
-
-      return JNI_VERSION_1_2;
-    }
-
-fail2:
-  HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr, jclIdCache, NULL);
-fail:
-  return 0;
-}
-
-/**
- * This DLL is being unloaded, do any clean up required.
- * This may be called more than once!!
- */
-void JNICALL
-JNI_OnUnload (JavaVM * vm, void *reserved)
-{
-  JNIEnv *env;
-  void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
-  void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
-
-  if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
-    {
-      JniIDCache *idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
-
-      if (idCache)
-        {
-          JCLZipFileLink *zipfileHandles;
-          JCLZipFile *jclZipFile;
-
-          PORT_ACCESS_FROM_ENV (env);
-
-          /* Detach from the common library */
-          ClearLibDetach (env);
-
-          /* Close and free the HyZipFile handles */
-          zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
-          if (zipfileHandles != NULL)
-            {
-              jclZipFile = zipfileHandles->next;
-              while (jclZipFile != NULL)
-                {
-                  JCLZipFile *next = jclZipFile->next;
-                  zip_closeZipFile (PORTLIB, &jclZipFile->hyZipFile);
-                  jclmem_free_memory (env, jclZipFile);
-                  jclZipFile = next;
-                }
-              jclmem_free_memory (env, zipfileHandles);
-            }
-
-          /* Free any global references */
-          freeReferences (env);
-
-          /* Free VMLS keys */
-          idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
-          HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr,
-                                              jclIdCache, NULL);
-          hymem_free_memory (idCache);
-        }
-    }
-}
-
-/**
- * @internal
- */
-static void
-freeReferences (JNIEnv * env)
-{
-  jclass classRef;
-
-  /* clean up class references */
-  classRef = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
-  if (classRef)
-    (*env)->DeleteWeakGlobalRef (env, (jweak) classRef);
-}
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* HarmonyDoxygen */
+/**
+ * @file
+ * @ingroup HarmonyNatives
+ * @brief Harmony Archive natives initialization API.
+ */
+
+#include "vmi.h"
+#include "jclglob.h"
+#include "zip.h"
+#include <string.h>
+
+static UDATA keyInitCount = 0;
+
+void *JCL_ID_CACHE = NULL;
+
+static void freeReferences (JNIEnv * env);
+
+/**
+ * This DLL is being loaded, do any initialization required.
+ * This may be called more than once.
+ */
+jint JNICALL
+JNI_OnLoad (JavaVM * vm, void *reserved)
+{
+  JniIDCache *idCache;
+  JNIEnv *env;
+  void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
+  void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
+
+  if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
+    {
+      PORT_ACCESS_FROM_ENV (env);
+
+      if (HY_VMLS_FNTBL (env)->
+          HYVMLSAllocKeys (env, keyInitCountPtr, jclIdCache, NULL))
+        {
+          goto fail;
+        }
+
+      /* This allocate must actually be done by hymem_allocate_memory. */
+      idCache = (JniIDCache *) hymem_allocate_memory (sizeof (JniIDCache));
+      if (!idCache)
+        goto fail2;
+
+      memset (idCache, 0, sizeof (JniIDCache));
+      HY_VMLS_SET (env, *jclIdCache, idCache);
+
+      /* Attach to the common library */
+      if (JNI_OK != ClearLibAttach (env))
+        {
+          goto fail2;
+        }
+
+      return JNI_VERSION_1_2;
+    }
+
+fail2:
+  HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr, jclIdCache, NULL);
+fail:
+  return 0;
+}
+
+/**
+ * This DLL is being unloaded, do any clean up required.
+ * This may be called more than once!!
+ */
+void JNICALL
+JNI_OnUnload (JavaVM * vm, void *reserved)
+{
+  JNIEnv *env;
+  void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
+  void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
+
+  if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
+    {
+      JniIDCache *idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
+
+      if (idCache)
+        {
+          JCLZipFileLink *zipfileHandles;
+          JCLZipFile *jclZipFile;
+
+          PORT_ACCESS_FROM_ENV (env);
+
+          /* Detach from the common library */
+          ClearLibDetach (env);
+
+          /* Close and free the HyZipFile handles */
+          zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
+          if (zipfileHandles != NULL)
+            {
+              jclZipFile = zipfileHandles->next;
+              while (jclZipFile != NULL)
+                {
+                  JCLZipFile *next = jclZipFile->next;
+                  zip_closeZipFile (PORTLIB, &jclZipFile->hyZipFile);
+                  jclmem_free_memory (env, jclZipFile);
+                  jclZipFile = next;
+                }
+              jclmem_free_memory (env, zipfileHandles);
+            }
+
+          /* Free any global references */
+          freeReferences (env);
+
+          /* Free VMLS keys */
+          idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
+          HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr,
+                                              jclIdCache, NULL);
+          hymem_free_memory (idCache);
+        }
+    }
+}
+
+/**
+ * @internal
+ */
+static void
+freeReferences (JNIEnv * env)
+{
+  jclass classRef;
+
+  /* clean up class references */
+  classRef = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
+  if (classRef)
+    (*env)->DeleteWeakGlobalRef (env, (jweak) classRef);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/deflater.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/deflater.c?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/deflater.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/deflater.c Thu Sep 14 19:40:33 2006
@@ -1,282 +1,282 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "vmi.h"
-#include "iohelp.h"
-#include "exceptions.h"
-
-#include "zlib.h"
-#include "inflater.h"
-#include "jclglob.h"
-#include "jclprots.h"
-
-void zfree PROTOTYPE ((void *opaque, void *address));
-void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
-
-void JNICALL
-Java_java_util_zip_Deflater_setDictionaryImpl (JNIEnv * env, jobject recv,
-					       jbyteArray dict, int off,
-					       int len, jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  int err = 0;
-  char *dBytes;
-  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
-
-  dBytes = jclmem_allocate_memory (env, len);
-  if (dBytes == NULL)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return;
-    }
-  (*env)->GetByteArrayRegion (env, dict, off, len, dBytes);
-  err = deflateSetDictionary (stream->stream, (Bytef *) dBytes, len);
-  if (err != Z_OK)
-    {
-      jclmem_free_memory (env, dBytes);
-      throwNewIllegalArgumentException (env, "");
-      return;
-    }
-  stream->dict = dBytes;
-}
-
-jlong JNICALL
-Java_java_util_zip_Deflater_getTotalInImpl (JNIEnv * env, jobject recv,
-					    jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  return stream->stream->total_in;
-}
-
-jlong JNICALL
-Java_java_util_zip_Deflater_getTotalOutImpl (JNIEnv * env, jobject recv,
-					     jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  return stream->stream->total_out;
-}
-
-jint JNICALL
-Java_java_util_zip_Deflater_getAdlerImpl (JNIEnv * env, jobject recv,
-					  jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-
-  return stream->stream->adler;
-}
-
-/* Create a new stream . This stream cannot be used until it has been properly initialized. */
-jlong JNICALL
-Java_java_util_zip_Deflater_createStream (JNIEnv * env, jobject recv,
-					  jint level, jint strategy,
-					  jboolean noHeader)
-{  
-  PORT_ACCESS_FROM_ENV (env);
-
-  JCLZipStream *jstream;
-  z_stream *stream;
-  int err = 0;
-  int wbits = 15;		/*Use MAX for fastest */
-
-  /*Allocate mem for wrapped struct */
-  jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
-  if (jstream == NULL)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return -1;
-    }
-  /*Allocate the z_stream */
-  stream = jclmem_allocate_memory (env, sizeof (z_stream));
-  if (stream == NULL)
-    {
-      jclmem_free_memory (env, jstream);
-      throwNewOutOfMemoryError (env, "");
-      return -1;
-    }
-  stream->opaque = (void *) privatePortLibrary;
-  stream->zalloc = zalloc;
-  stream->zfree = zfree;
-  jstream->stream = stream;
-  jstream->dict = NULL;
-  jstream->inaddr = NULL;
-
-  /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so */
-  if (noHeader)
-    wbits = wbits / -1;
-  err = deflateInit2 (stream, level, Z_DEFLATED,	/*Only supported ZLIB method */
-		      wbits,	/*Window bits to use. 15 is fastest but consumes the most memory */
-		      9,	/*Memory allocation for internal compression state. 9 uses the most. */
-		      strategy);
-  if (err != Z_OK)
-    {
-      throwNewIllegalArgumentException (env, "");
-      return -1;
-    }
-
-  return (jlong) ((IDATA) jstream);
-}
-
-void JNICALL
-Java_java_util_zip_Deflater_setInputImpl (JNIEnv * env, jobject recv,
-					  jbyteArray buf, jint off, jint len,
-					  jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  jbyte *in;
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  if (stream->inaddr != NULL)	/*Input has already been provided, free the old buffer */
-    jclmem_free_memory (env, stream->inaddr);
-  stream->inaddr = jclmem_allocate_memory (env, len);
-  if (stream->inaddr == NULL)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return;
-    }
-  in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
-  if (in == NULL)
-    return;
-  memcpy (stream->inaddr, (in + off), len);
-  ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT));
-  stream->stream->next_in = (Bytef *) stream->inaddr;
-  stream->stream->avail_in = len;
-
-  return;
-}
-
-jint JNICALL
-Java_java_util_zip_Deflater_deflateImpl (JNIEnv * env, jobject recv,
-					 jbyteArray buf, int off, int len,
-					 jlong handle, int flushParm)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  jbyte *out;
-  JCLZipStream *stream;
-  jint err = 0;
-  jint sin, sout, inBytes = 0;
-
-  /* We need to get the number of bytes already read */
-  inBytes =
-    ((*env)->
-     GetIntField (env, recv,
-		  JCL_CACHE_GET (env, FID_java_util_zip_Deflater_inRead)));
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  stream->stream->avail_out = len;
-  sin = stream->stream->total_in;
-  sout = stream->stream->total_out;
-  out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
-  if (out == NULL)
-    return -1;
-  stream->stream->next_out = (Bytef *) out + off;
-  err = deflate (stream->stream, flushParm);
-  ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0));
-  if (err != Z_OK)
-    {
-      if (err == Z_STREAM_END)
-	{
-	  ((*env)->
-	   SetBooleanField (env, recv,
-			    JCL_CACHE_GET (env,
-					   FID_java_util_zip_Deflater_finished),
-			    JNI_TRUE));
-	  return stream->stream->total_out - sout;
-	}
-    }
-  if (flushParm != Z_FINISH)
-    {
-      /* Need to update the number of input bytes read. */
-      ((*env)->
-       SetIntField (env, recv,
-		    JCL_CACHE_GET (env, FID_java_util_zip_Deflater_inRead),
-		    (jint) stream->stream->total_in - sin + inBytes));
-    }
-  return stream->stream->total_out - sout;
-}
-
-void JNICALL
-Java_java_util_zip_Deflater_endImpl (JNIEnv * env, jobject recv, jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-
-  deflateEnd (stream->stream);
-  if (stream->inaddr != NULL)
-    jclmem_free_memory (env, stream->inaddr);
-  if (stream->dict != NULL)
-    jclmem_free_memory (env, stream->dict);
-  jclmem_free_memory (env, stream->stream);
-  jclmem_free_memory (env, stream);
-}
-
-void JNICALL
-Java_java_util_zip_Deflater_resetImpl (JNIEnv * env, jobject recv,
-				       jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  deflateReset (stream->stream);
-}
-
-void JNICALL
-Java_java_util_zip_Deflater_setLevelsImpl (JNIEnv * env, jobject recv,
-					   int level, int strategy,
-					   jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  JCLZipStream *stream;
-  jbyte b = 0;
-  int err = 0;
-
-  if (handle == -1)
-    {
-      throwNewIllegalStateException (env, "");
-      return;
-    }
-  stream = (JCLZipStream *) ((IDATA) handle);
-  stream->stream->next_out = (Bytef *) & b;
-  err = deflateParams (stream->stream, level, strategy);
-  if (err != Z_OK)
-    throwNewIllegalStateException (env, "");
-}
-
-void JNICALL
-Java_java_util_zip_Deflater_oneTimeInitialization (JNIEnv * env, jclass clazz)
-{
-  jfieldID fid;
-
-  fid = (*env)->GetFieldID (env, clazz, "inRead", "I");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_Deflater_inRead, fid);
-
-  fid = (*env)->GetFieldID (env, clazz, "finished", "Z");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_Deflater_finished, fid);
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vmi.h"
+#include "iohelp.h"
+#include "exceptions.h"
+
+#include "zlib.h"
+#include "inflater.h"
+#include "jclglob.h"
+#include "jclprots.h"
+
+void zfree PROTOTYPE ((void *opaque, void *address));
+void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
+
+void JNICALL
+Java_java_util_zip_Deflater_setDictionaryImpl (JNIEnv * env, jobject recv,
+					       jbyteArray dict, int off,
+					       int len, jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  int err = 0;
+  char *dBytes;
+  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
+
+  dBytes = jclmem_allocate_memory (env, len);
+  if (dBytes == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return;
+    }
+  (*env)->GetByteArrayRegion (env, dict, off, len, dBytes);
+  err = deflateSetDictionary (stream->stream, (Bytef *) dBytes, len);
+  if (err != Z_OK)
+    {
+      jclmem_free_memory (env, dBytes);
+      throwNewIllegalArgumentException (env, "");
+      return;
+    }
+  stream->dict = dBytes;
+}
+
+jlong JNICALL
+Java_java_util_zip_Deflater_getTotalInImpl (JNIEnv * env, jobject recv,
+					    jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  return stream->stream->total_in;
+}
+
+jlong JNICALL
+Java_java_util_zip_Deflater_getTotalOutImpl (JNIEnv * env, jobject recv,
+					     jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  return stream->stream->total_out;
+}
+
+jint JNICALL
+Java_java_util_zip_Deflater_getAdlerImpl (JNIEnv * env, jobject recv,
+					  jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+
+  return stream->stream->adler;
+}
+
+/* Create a new stream . This stream cannot be used until it has been properly initialized. */
+jlong JNICALL
+Java_java_util_zip_Deflater_createStream (JNIEnv * env, jobject recv,
+					  jint level, jint strategy,
+					  jboolean noHeader)
+{  
+  PORT_ACCESS_FROM_ENV (env);
+
+  JCLZipStream *jstream;
+  z_stream *stream;
+  int err = 0;
+  int wbits = 15;		/*Use MAX for fastest */
+
+  /*Allocate mem for wrapped struct */
+  jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
+  if (jstream == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return -1;
+    }
+  /*Allocate the z_stream */
+  stream = jclmem_allocate_memory (env, sizeof (z_stream));
+  if (stream == NULL)
+    {
+      jclmem_free_memory (env, jstream);
+      throwNewOutOfMemoryError (env, "");
+      return -1;
+    }
+  stream->opaque = (void *) privatePortLibrary;
+  stream->zalloc = zalloc;
+  stream->zfree = zfree;
+  jstream->stream = stream;
+  jstream->dict = NULL;
+  jstream->inaddr = NULL;
+
+  /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so */
+  if (noHeader)
+    wbits = wbits / -1;
+  err = deflateInit2 (stream, level, Z_DEFLATED,	/*Only supported ZLIB method */
+		      wbits,	/*Window bits to use. 15 is fastest but consumes the most memory */
+		      9,	/*Memory allocation for internal compression state. 9 uses the most. */
+		      strategy);
+  if (err != Z_OK)
+    {
+      throwNewIllegalArgumentException (env, "");
+      return -1;
+    }
+
+  return (jlong) ((IDATA) jstream);
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_setInputImpl (JNIEnv * env, jobject recv,
+					  jbyteArray buf, jint off, jint len,
+					  jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *in;
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  if (stream->inaddr != NULL)	/*Input has already been provided, free the old buffer */
+    jclmem_free_memory (env, stream->inaddr);
+  stream->inaddr = jclmem_allocate_memory (env, len);
+  if (stream->inaddr == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return;
+    }
+  in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
+  if (in == NULL)
+    return;
+  memcpy (stream->inaddr, (in + off), len);
+  ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT));
+  stream->stream->next_in = (Bytef *) stream->inaddr;
+  stream->stream->avail_in = len;
+
+  return;
+}
+
+jint JNICALL
+Java_java_util_zip_Deflater_deflateImpl (JNIEnv * env, jobject recv,
+					 jbyteArray buf, int off, int len,
+					 jlong handle, int flushParm)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *out;
+  JCLZipStream *stream;
+  jint err = 0;
+  jint sin, sout, inBytes = 0;
+
+  /* We need to get the number of bytes already read */
+  inBytes =
+    ((*env)->
+     GetIntField (env, recv,
+		  JCL_CACHE_GET (env, FID_java_util_zip_Deflater_inRead)));
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  stream->stream->avail_out = len;
+  sin = stream->stream->total_in;
+  sout = stream->stream->total_out;
+  out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
+  if (out == NULL)
+    return -1;
+  stream->stream->next_out = (Bytef *) out + off;
+  err = deflate (stream->stream, flushParm);
+  ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0));
+  if (err != Z_OK)
+    {
+      if (err == Z_STREAM_END)
+	{
+	  ((*env)->
+	   SetBooleanField (env, recv,
+			    JCL_CACHE_GET (env,
+					   FID_java_util_zip_Deflater_finished),
+			    JNI_TRUE));
+	  return stream->stream->total_out - sout;
+	}
+    }
+  if (flushParm != Z_FINISH)
+    {
+      /* Need to update the number of input bytes read. */
+      ((*env)->
+       SetIntField (env, recv,
+		    JCL_CACHE_GET (env, FID_java_util_zip_Deflater_inRead),
+		    (jint) stream->stream->total_in - sin + inBytes));
+    }
+  return stream->stream->total_out - sout;
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_endImpl (JNIEnv * env, jobject recv, jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+
+  deflateEnd (stream->stream);
+  if (stream->inaddr != NULL)
+    jclmem_free_memory (env, stream->inaddr);
+  if (stream->dict != NULL)
+    jclmem_free_memory (env, stream->dict);
+  jclmem_free_memory (env, stream->stream);
+  jclmem_free_memory (env, stream);
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_resetImpl (JNIEnv * env, jobject recv,
+				       jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  deflateReset (stream->stream);
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_setLevelsImpl (JNIEnv * env, jobject recv,
+					   int level, int strategy,
+					   jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  JCLZipStream *stream;
+  jbyte b = 0;
+  int err = 0;
+
+  if (handle == -1)
+    {
+      throwNewIllegalStateException (env, "");
+      return;
+    }
+  stream = (JCLZipStream *) ((IDATA) handle);
+  stream->stream->next_out = (Bytef *) & b;
+  err = deflateParams (stream->stream, level, strategy);
+  if (err != Z_OK)
+    throwNewIllegalStateException (env, "");
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_oneTimeInitialization (JNIEnv * env, jclass clazz)
+{
+  jfieldID fid;
+
+  fid = (*env)->GetFieldID (env, clazz, "inRead", "I");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Deflater_inRead, fid);
+
+  fid = (*env)->GetFieldID (env, clazz, "finished", "Z");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Deflater_finished, fid);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/deflater.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/inflater.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/inflater.c?view=diff&rev=446478&r1=446477&r2=446478
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/inflater.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/inflater.c Thu Sep 14 19:40:33 2006
@@ -1,288 +1,288 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "vmi.h"
-#include "iohelp.h"
-#include "exceptions.h"
-#include "jclglob.h"
-#include "jclprots.h"
-
-#include "inflater.h"
-
-void throwNewDataFormatException (JNIEnv * env, const char *message);
-
-/* Create a new stream . This stream cannot be used until it has been properly initialized. */
-jlong JNICALL
-Java_java_util_zip_Inflater_createStream (JNIEnv * env, jobject recv,
-                                          jboolean noHeader)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  JCLZipStream *jstream;
-  z_stream *stream;
-  int err = 0;
-  int wbits = 15;               /*Use MAX for fastest */
-
-  /*Allocate mem for wrapped struct */
-  jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
-  if (jstream == NULL)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return -1;
-    }
-
-  /*Allocate the z_stream */
-  stream = jclmem_allocate_memory (env, sizeof (z_stream));
-  if (stream == NULL)
-    {
-      jclmem_free_memory (env, jstream);
-      throwNewOutOfMemoryError (env, "");
-      return -1;
-    }
-  stream->opaque = (void *) privatePortLibrary;
-  stream->zalloc = zalloc;
-  stream->zfree = zfree;
-  stream->adler = 1;
-  jstream->stream = stream;
-  jstream->dict = NULL;
-  jstream->inaddr = NULL;
-
-  /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so. */
-  if (noHeader)
-    wbits = wbits / -1;
-  err = inflateInit2 (stream, wbits);   /*Window bits to use. 15 is fastest but consumes the most memory */
-
-  if (err != Z_OK)
-    {
-      jclmem_free_memory (env, stream);
-      jclmem_free_memory (env, jstream);
-      throwNewIllegalArgumentException (env, "");
-      return -1;
-    }
-
-  return (jlong) ((IDATA) jstream);
-}
-
-void JNICALL
-Java_java_util_zip_Inflater_setInputImpl (JNIEnv * env, jobject recv,
-                                          jbyteArray buf, jint off, jint len,
-                                          jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  jbyte *in;
-  U_8 *baseAddr;
-  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
-
-  if (stream->inaddr != NULL)   /*Input has already been provided, free the old buffer */
-    jclmem_free_memory (env, stream->inaddr);
-  baseAddr = jclmem_allocate_memory (env, len);
-  if (baseAddr == NULL)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return;
-    }
-  stream->inaddr = baseAddr;
-  stream->stream->next_in = (Bytef *) baseAddr;
-  stream->stream->avail_in = len;
-  in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
-  if (in == NULL)
-    return;
-  memcpy (baseAddr, (in + off), len);
-  ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT));
-  return;
-}
-
-jint JNICALL
-Java_java_util_zip_Inflater_inflateImpl (JNIEnv * env, jobject recv,
-                                         jbyteArray buf, int off, int len,
-                                         jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-
-  jbyte *out;
-  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
-  jint err = 0;
-  jfieldID fid = 0, fid2 = 0;
-  jint sin, sout, inBytes = 0;
-
-  /* We need to get the number of bytes already read */
-  fid = JCL_CACHE_GET (env, FID_java_util_zip_Inflater_inRead);
-  inBytes = ((*env)->GetIntField (env, recv, fid));
-
-  stream->stream->avail_out = len;
-  sin = stream->stream->total_in;
-  sout = stream->stream->total_out;
-  out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
-  if (out == NULL)
-    return -1;
-  stream->stream->next_out = (Bytef *) out + off;
-  err = inflate (stream->stream, Z_SYNC_FLUSH);
-  ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0));
-
-  if (err != Z_OK)
-    {
-      if(err == Z_STREAM_ERROR) {
-          return 0;
-      }
-      if (err == Z_STREAM_END || err == Z_NEED_DICT)
-        {
-          ((*env)->SetIntField (env, recv, fid, (jint) stream->stream->total_in - sin + inBytes));      /* Update inRead */
-          if (err == Z_STREAM_END)
-            fid2 = JCL_CACHE_GET (env, FID_java_util_zip_Inflater_finished);
-          else
-            fid2 =
-              JCL_CACHE_GET (env, FID_java_util_zip_Inflater_needsDictionary);
-
-          ((*env)->SetBooleanField (env, recv, fid2, JNI_TRUE));
-          return stream->stream->total_out - sout;
-        }
-      else
-        {
-          throwNewDataFormatException (env, "");
-          return -1;
-        }
-    }
-
-  /* Need to update the number of input bytes read. Is there a better way
-   * (Maybe global the fid then delete when end is called)?
-   */
-  ((*env)->
-   SetIntField (env, recv, fid,
-                (jint) stream->stream->total_in - sin + inBytes));
-
-  return stream->stream->total_out - sout;
-}
-
-jint JNICALL
-Java_java_util_zip_Inflater_getAdlerImpl (JNIEnv * env, jobject recv,
-                                          jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-
-  return stream->stream->adler;
-}
-
-void JNICALL
-Java_java_util_zip_Inflater_endImpl (JNIEnv * env, jobject recv, jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  inflateEnd (stream->stream);
-  if (stream->inaddr != NULL)   /*Input has been provided, free the buffer */
-    jclmem_free_memory (env, stream->inaddr);
-  if (stream->dict != NULL)
-    jclmem_free_memory (env, stream->dict);
-  jclmem_free_memory (env, stream->stream);
-  jclmem_free_memory (env, stream);
-}
-
-void JNICALL
-Java_java_util_zip_Inflater_setDictionaryImpl (JNIEnv * env, jobject recv,
-                                               jbyteArray dict, int off,
-                                               int len, jlong handle)
-{
-  PORT_ACCESS_FROM_ENV (env);
-  int err = 0;
-  U_8 *dBytes;
-  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
-
-  dBytes = jclmem_allocate_memory (env, len);
-  if (dBytes == NULL)
-    {
-      throwNewOutOfMemoryError (env, "");
-      return;
-    }
-  (*env)->GetByteArrayRegion (env, dict, off, len, dBytes);
-  err = inflateSetDictionary (stream->stream, (Bytef *) dBytes, len);
-  if (err != Z_OK)
-    {
-      jclmem_free_memory (env, dBytes);
-      throwNewIllegalArgumentException (env, "");
-      return;
-    }
-  stream->dict = dBytes;
-}
-
-void JNICALL
-Java_java_util_zip_Inflater_resetImpl (JNIEnv * env, jobject recv,
-                                       jlong handle)
-{
-  JCLZipStream *stream;
-  int err = 0;
-  stream = (JCLZipStream *) ((IDATA) handle);
-
-  err = inflateReset (stream->stream);
-  if (err != Z_OK)
-    {
-      throwNewIllegalArgumentException (env, "");
-      return;
-    }
-}
-
-/**
-  * Throw java.util.zip.DataFormatException
-  */
-void
-throwNewDataFormatException (JNIEnv * env, const char *message)
-{
-  throwNewExceptionByName(env, "java/util/zip/DataFormatException", message);
-}
-
-jlong JNICALL
-Java_java_util_zip_Inflater_getTotalOutImpl (JNIEnv * env, jobject recv,
-                                             jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  return stream->stream->total_out;
-
-}
-
-jlong JNICALL
-Java_java_util_zip_Inflater_getTotalInImpl (JNIEnv * env, jobject recv,
-                                            jlong handle)
-{
-  JCLZipStream *stream;
-
-  stream = (JCLZipStream *) ((IDATA) handle);
-  return stream->stream->total_in;
-}
-
-void JNICALL
-Java_java_util_zip_Inflater_oneTimeInitialization (JNIEnv * env, jclass clazz)
-{
-  jfieldID fid;
-
-  fid = (*env)->GetFieldID (env, clazz, "inRead", "I");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_Inflater_inRead, fid);
-
-  fid = (*env)->GetFieldID (env, clazz, "finished", "Z");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_Inflater_finished, fid);
-
-  fid = (*env)->GetFieldID (env, clazz, "needsDictionary", "Z");
-  if (!fid)
-    return;
-  JCL_CACHE_SET (env, FID_java_util_zip_Inflater_needsDictionary, fid);
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "vmi.h"
+#include "iohelp.h"
+#include "exceptions.h"
+#include "jclglob.h"
+#include "jclprots.h"
+
+#include "inflater.h"
+
+void throwNewDataFormatException (JNIEnv * env, const char *message);
+
+/* Create a new stream . This stream cannot be used until it has been properly initialized. */
+jlong JNICALL
+Java_java_util_zip_Inflater_createStream (JNIEnv * env, jobject recv,
+                                          jboolean noHeader)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  JCLZipStream *jstream;
+  z_stream *stream;
+  int err = 0;
+  int wbits = 15;               /*Use MAX for fastest */
+
+  /*Allocate mem for wrapped struct */
+  jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
+  if (jstream == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return -1;
+    }
+
+  /*Allocate the z_stream */
+  stream = jclmem_allocate_memory (env, sizeof (z_stream));
+  if (stream == NULL)
+    {
+      jclmem_free_memory (env, jstream);
+      throwNewOutOfMemoryError (env, "");
+      return -1;
+    }
+  stream->opaque = (void *) privatePortLibrary;
+  stream->zalloc = zalloc;
+  stream->zfree = zfree;
+  stream->adler = 1;
+  jstream->stream = stream;
+  jstream->dict = NULL;
+  jstream->inaddr = NULL;
+
+  /*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so. */
+  if (noHeader)
+    wbits = wbits / -1;
+  err = inflateInit2 (stream, wbits);   /*Window bits to use. 15 is fastest but consumes the most memory */
+
+  if (err != Z_OK)
+    {
+      jclmem_free_memory (env, stream);
+      jclmem_free_memory (env, jstream);
+      throwNewIllegalArgumentException (env, "");
+      return -1;
+    }
+
+  return (jlong) ((IDATA) jstream);
+}
+
+void JNICALL
+Java_java_util_zip_Inflater_setInputImpl (JNIEnv * env, jobject recv,
+                                          jbyteArray buf, jint off, jint len,
+                                          jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *in;
+  U_8 *baseAddr;
+  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
+
+  if (stream->inaddr != NULL)   /*Input has already been provided, free the old buffer */
+    jclmem_free_memory (env, stream->inaddr);
+  baseAddr = jclmem_allocate_memory (env, len);
+  if (baseAddr == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return;
+    }
+  stream->inaddr = baseAddr;
+  stream->stream->next_in = (Bytef *) baseAddr;
+  stream->stream->avail_in = len;
+  in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
+  if (in == NULL)
+    return;
+  memcpy (baseAddr, (in + off), len);
+  ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT));
+  return;
+}
+
+jint JNICALL
+Java_java_util_zip_Inflater_inflateImpl (JNIEnv * env, jobject recv,
+                                         jbyteArray buf, int off, int len,
+                                         jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *out;
+  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
+  jint err = 0;
+  jfieldID fid = 0, fid2 = 0;
+  jint sin, sout, inBytes = 0;
+
+  /* We need to get the number of bytes already read */
+  fid = JCL_CACHE_GET (env, FID_java_util_zip_Inflater_inRead);
+  inBytes = ((*env)->GetIntField (env, recv, fid));
+
+  stream->stream->avail_out = len;
+  sin = stream->stream->total_in;
+  sout = stream->stream->total_out;
+  out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
+  if (out == NULL)
+    return -1;
+  stream->stream->next_out = (Bytef *) out + off;
+  err = inflate (stream->stream, Z_SYNC_FLUSH);
+  ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0));
+
+  if (err != Z_OK)
+    {
+      if(err == Z_STREAM_ERROR) {
+          return 0;
+      }
+      if (err == Z_STREAM_END || err == Z_NEED_DICT)
+        {
+          ((*env)->SetIntField (env, recv, fid, (jint) stream->stream->total_in - sin + inBytes));      /* Update inRead */
+          if (err == Z_STREAM_END)
+            fid2 = JCL_CACHE_GET (env, FID_java_util_zip_Inflater_finished);
+          else
+            fid2 =
+              JCL_CACHE_GET (env, FID_java_util_zip_Inflater_needsDictionary);
+
+          ((*env)->SetBooleanField (env, recv, fid2, JNI_TRUE));
+          return stream->stream->total_out - sout;
+        }
+      else
+        {
+          throwNewDataFormatException (env, "");
+          return -1;
+        }
+    }
+
+  /* Need to update the number of input bytes read. Is there a better way
+   * (Maybe global the fid then delete when end is called)?
+   */
+  ((*env)->
+   SetIntField (env, recv, fid,
+                (jint) stream->stream->total_in - sin + inBytes));
+
+  return stream->stream->total_out - sout;
+}
+
+jint JNICALL
+Java_java_util_zip_Inflater_getAdlerImpl (JNIEnv * env, jobject recv,
+                                          jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+
+  return stream->stream->adler;
+}
+
+void JNICALL
+Java_java_util_zip_Inflater_endImpl (JNIEnv * env, jobject recv, jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  inflateEnd (stream->stream);
+  if (stream->inaddr != NULL)   /*Input has been provided, free the buffer */
+    jclmem_free_memory (env, stream->inaddr);
+  if (stream->dict != NULL)
+    jclmem_free_memory (env, stream->dict);
+  jclmem_free_memory (env, stream->stream);
+  jclmem_free_memory (env, stream);
+}
+
+void JNICALL
+Java_java_util_zip_Inflater_setDictionaryImpl (JNIEnv * env, jobject recv,
+                                               jbyteArray dict, int off,
+                                               int len, jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  int err = 0;
+  U_8 *dBytes;
+  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
+
+  dBytes = jclmem_allocate_memory (env, len);
+  if (dBytes == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return;
+    }
+  (*env)->GetByteArrayRegion (env, dict, off, len, dBytes);
+  err = inflateSetDictionary (stream->stream, (Bytef *) dBytes, len);
+  if (err != Z_OK)
+    {
+      jclmem_free_memory (env, dBytes);
+      throwNewIllegalArgumentException (env, "");
+      return;
+    }
+  stream->dict = dBytes;
+}
+
+void JNICALL
+Java_java_util_zip_Inflater_resetImpl (JNIEnv * env, jobject recv,
+                                       jlong handle)
+{
+  JCLZipStream *stream;
+  int err = 0;
+  stream = (JCLZipStream *) ((IDATA) handle);
+
+  err = inflateReset (stream->stream);
+  if (err != Z_OK)
+    {
+      throwNewIllegalArgumentException (env, "");
+      return;
+    }
+}
+
+/**
+  * Throw java.util.zip.DataFormatException
+  */
+void
+throwNewDataFormatException (JNIEnv * env, const char *message)
+{
+  throwNewExceptionByName(env, "java/util/zip/DataFormatException", message);
+}
+
+jlong JNICALL
+Java_java_util_zip_Inflater_getTotalOutImpl (JNIEnv * env, jobject recv,
+                                             jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  return stream->stream->total_out;
+
+}
+
+jlong JNICALL
+Java_java_util_zip_Inflater_getTotalInImpl (JNIEnv * env, jobject recv,
+                                            jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  return stream->stream->total_in;
+}
+
+void JNICALL
+Java_java_util_zip_Inflater_oneTimeInitialization (JNIEnv * env, jclass clazz)
+{
+  jfieldID fid;
+
+  fid = (*env)->GetFieldID (env, clazz, "inRead", "I");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Inflater_inRead, fid);
+
+  fid = (*env)->GetFieldID (env, clazz, "finished", "Z");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Inflater_finished, fid);
+
+  fid = (*env)->GetFieldID (env, clazz, "needsDictionary", "Z");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Inflater_needsDictionary, fid);
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/inflater.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message