[kaffe] CVS kaffe (dalibor): Merged in java/util/zip/ZipConstants from Classpath

Kaffe CVS cvs-commits at kaffe.org
Sun Sep 28 17:41:02 PDT 2003


PatchSet 4075 
Date: 2003/09/29 00:38:57
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Merged in java/util/zip/ZipConstants from Classpath

Members: 
	ChangeLog:1.1670->1.1671 
	libraries/javalib/java/util/zip/ZipConstants.java:1.7->1.8 
	libraries/javalib/java/util/zip/ZipInputStream.java:1.14->1.15 
	libraries/javalib/java/util/zip/ZipOutputStream.java:1.12->1.13 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1670 kaffe/ChangeLog:1.1671
--- kaffe/ChangeLog:1.1670	Sun Sep 28 22:30:18 2003
+++ kaffe/ChangeLog	Mon Sep 29 00:38:57 2003
@@ -1,3 +1,12 @@
+2003-09-29  Dalibor Topic <robilad at kaffe.org>
+
+	* libraries/javalib/java/util/zip/ZipConstants.java:
+	Merged in from GNU Classpath to get the right constant names.
+	
+	* libraries/javalib/java/util/zip/ZipOutputStream.java,
+	libraries/javalib/java/util/zip/ZipInputStream.java:
+	Modified to use the right zip constant names.
+
 2003-09-28  Dalibor Topic <robilad at kaffe.org>
 
 	* kaffe/kaffevm/exception.h:
Index: kaffe/libraries/javalib/java/util/zip/ZipConstants.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipConstants.java:1.7 kaffe/libraries/javalib/java/util/zip/ZipConstants.java:1.8
--- kaffe/libraries/javalib/java/util/zip/ZipConstants.java:1.7	Sat Nov 24 01:52:55 2001
+++ kaffe/libraries/javalib/java/util/zip/ZipConstants.java	Mon Sep 29 00:38:59 2003
@@ -1,78 +1,97 @@
-/*
- * Java core library component.
- *
- * Copyright (c) 1997, 1998
- *      Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- */
+/* java.util.zip.ZipConstants
+   Copyright (C) 2001 Free Software Foundation, Inc.
 
-package java.util.zip;
-
-// This isn't documented so I don't know what it contains .... !!!
-
-interface ZipConstants {
+This file is part of GNU Classpath.
 
-  int CEN_SIGNATURE = 0;
-  int CEN_VERSIONMADE = 4;
-  int CEN_VERSIONEXTRACT = 6;
-  int CEN_FLAGS = 8;
-  int CEN_METHOD = 10;
-  int CEN_TIME = 12;
-  int CEN_DATE = 14;
-  int CEN_CRC = 16;
-  int CEN_COMPRESSEDSIZE = 20;
-  int CEN_UNCOMPRESSEDSIZE = 24;
-  int CEN_FILENAMELEN = 28;
-  int CEN_EXTRAFIELDLEN = 30;
-  int CEN_FILECOMMENTLEN = 32;
-  int CEN_DISKNUMBER = 34;
-  int CEN_INTERNALATTR = 36;
-  int CEN_EXTERNALATTR = 38;
-  int CEN_LCLOFFSET = 42;
-
-  int CEN_RECSZ = 46;
-
-  long CEN_HEADSIG = 0x02014b50;
-
-  int END_SIGNATURE = 0;
-  int END_DISKNUMBER = 4;
-  int END_CENDISKNUMBER = 6;
-  int END_TOTALCENONDISK = 8;
-  int END_TOTALCEN = 10;
-  int END_CENSIZE = 12;
-  int END_CENOFFSET = 16;
-  int END_COMMENTLEN = 20;
-
-  int END_RECSZ = 22;
-
-  long END_ENDSIG = 0x06054b50;
-
-  int LOC_SIGNATURE = 0;
-  int LOC_VERSIONEXTRACT = 4;
-  int LOC_FLAGS = 6;
-  int LOC_METHOD = 8;
-  int LOC_TIME = 10;
-  int LOC_DATE = 12;
-  int LOC_CRC = 14;
-  int LOC_COMPRESSEDSIZE = 18;
-  int LOC_UNCOMPRESSEDSIZE = 22;
-  int LOC_FILENAMELEN = 26;
-  int LOC_EXTRAFIELDLEN = 28;
-
-  int LOC_RECSZ = 30;
-
-  long LOC_HEADSIG = 0x04034b50;
-
-  long DATA_HEADSIG = 0x08074b50;
-  int DATA_SIGNATURE = 0;
-  int DATA_CRC = 4;
-  int DATA_COMPRESSEDSIZE = 8;
-  int DATA_UNCOMPRESSEDSIZE = 12;
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
 
-  int DATA_RECSZ = 16;
+package java.util.zip;
 
-  int DEFLATED = 8;
-  int STORED = 0;
+interface ZipConstants
+{
+    /* The local file header */
+    public final static int LOCHDR = 30;
+    public final static int LOCSIG = 'P'|('K'<<8)|(3<<16)|(4<<24);
+
+    public final static int LOCVER =  4;
+    public final static int LOCFLG =  6;
+    public final static int LOCHOW =  8;
+    public final static int LOCTIM = 10;
+    public final static int LOCCRC = 14;
+    public final static int LOCSIZ = 18;
+    public final static int LOCLEN = 22;
+    public final static int LOCNAM = 26;
+    public final static int LOCEXT = 28;
+
+    /* The Data descriptor */
+    public final static int EXTSIG = 'P'|('K'<<8)|(7<<16)|(8<<24);
+    public final static int EXTHDR = 16;
+
+    public final static int EXTCRC =  4;
+    public final static int EXTSIZ =  8;
+    public final static int EXTLEN = 12;
+
+    /* The central directory file header */
+    public final static int CENSIG = 'P'|('K'<<8)|(1<<16)|(2<<24);
+    public final static int CENHDR = 46;
+
+    public final static int CENVEM =  4;
+    public final static int CENVER =  6;
+    public final static int CENFLG =  8;
+    public final static int CENHOW = 10;
+    public final static int CENTIM = 12;
+    public final static int CENCRC = 16;
+    public final static int CENSIZ = 20;
+    public final static int CENLEN = 24;
+    public final static int CENNAM = 28;
+    public final static int CENEXT = 30;
+    public final static int CENCOM = 32;
+    public final static int CENDSK = 34;
+    public final static int CENATT = 36;
+    public final static int CENATX = 38;
+    public final static int CENOFF = 42;
+
+    /* The entries in the end of central directory */
+    public final static int ENDSIG = 'P'|('K'<<8)|(5<<16)|(6<<24);
+    public final static int ENDHDR = 22;
+
+    /* The following two fields are missing in SUN JDK */
+    final static int ENDNRD =  4;
+    final static int ENDDCD =  6;
+    public final static int ENDSUB =  8;
+    public final static int ENDTOT = 10;
+    public final static int ENDSIZ = 12;
+    public final static int ENDOFF = 16;
+    public final static int ENDCOM = 20;
 }
+
Index: kaffe/libraries/javalib/java/util/zip/ZipInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.14 kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.15
--- kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.14	Fri Jan  4 05:12:28 2002
+++ kaffe/libraries/javalib/java/util/zip/ZipInputStream.java	Mon Sep 29 00:38:59 2003
@@ -20,8 +20,8 @@
 	implements ZipConstants {
 
   private byte sigbuf[] = new byte[4];
-  private byte zheader[] = new byte[LOC_RECSZ];
-  private byte dheader[] = new byte[DATA_RECSZ];
+  private byte zheader[] = new byte[LOCHDR];
+  private byte dheader[] = new byte[EXTHDR];
   private boolean gotSig;
   private SwitchInflater sinf;
   private ZipEntry entry;
@@ -43,9 +43,9 @@
       // Read next signature
       int sig = readSig();
       switch (sig) {
-      case (int)CEN_HEADSIG:		// central dir: no more entries
+      case (int)CENSIG:		// central dir: no more entries
 	return null;
-      case (int)LOC_HEADSIG:		// another entry
+      case (int)LOCSIG:		// another entry
 	break;
       default:				// unexpected
 	throw new IOException("Bogus signature: 0x" + Integer.toHexString(sig));
@@ -55,31 +55,31 @@
       readFully(zheader, sigbuf.length, zheader.length - sigbuf.length);
 
       // Read filename; assume UTF-8 encoding
-      byte[] nameBuf = new byte[get16(zheader, LOC_FILENAMELEN)];
+      byte[] nameBuf = new byte[get16(zheader, LOCNAM)];
       readFully(nameBuf, 0, nameBuf.length);
 
       // Read extra field
-      byte[] extra = new byte[get16(zheader, LOC_EXTRAFIELDLEN)];
+      byte[] extra = new byte[get16(zheader, LOCEXT)];
       readFully(extra, 0, extra.length);
 
       // Setup new entry
       entry = new ZipEntry(UTF8.decode(nameBuf));
-      entry.version = get16(zheader, LOC_VERSIONEXTRACT);
-      entry.flag    = get16(zheader, LOC_FLAGS);
+      entry.version = get16(zheader, LOCVER);
+      entry.flag    = get16(zheader, LOCFLG);
 
-      entry.setMethod(get16(zheader, LOC_METHOD));
-      entry.setDosTime(get32(zheader, LOC_TIME));
-      entry.setCrc(get32(zheader, LOC_CRC) & 0xffffffffL);
+      entry.setMethod(get16(zheader, LOCHOW));
+      entry.setDosTime(get32(zheader, LOCTIM));
+      entry.setCrc(get32(zheader, LOCCRC) & 0xffffffffL);
 
-      entry.setCompressedSize(get32(zheader, LOC_COMPRESSEDSIZE) & 0xffffffffL);
-      entry.setSize(get32(zheader, LOC_UNCOMPRESSEDSIZE) & 0xffffffffL);
+      entry.setCompressedSize(get32(zheader, LOCSIZ) & 0xffffffffL);
+      entry.setSize(get32(zheader, LOCLEN) & 0xffffffffL);
 
       entry.setExtra( extra );
       entry.setComment("");
       entry.offset = 0;
 
       // Select the loader, simple or inflater.
-      if (entry.method == STORED) {
+      if (entry.method == ZipEntry.STORED) {
 	sinf.setMode(true);
 	sinf.setLength((int)entry.csize);
       }
@@ -120,7 +120,7 @@
 	// from the DATA header. This is so that users can find out
 	// the compressed and uncompressed sizes of data written in
 	// a compressed entry.
-	if (entry.method == DEFLATED && peekSig() == (int)DATA_HEADSIG) {
+	if (entry.method == ZipEntry.DEFLATED && peekSig() == (int)EXTSIG) {
 
 	  // Consume signature
 	  readSig();
@@ -129,15 +129,15 @@
 	  readFully(dheader, sigbuf.length, dheader.length - sigbuf.length);
 
 	  // Read CRC
-	  int data_crc = get32(dheader, DATA_CRC);
+	  int data_crc = get32(dheader, EXTCRC);
 	  entry.setCrc(data_crc & 0xffffffffL);
 
 	  // Read compressed size
-	  int data_csize = get32(dheader, DATA_COMPRESSEDSIZE);
+	  int data_csize = get32(dheader, EXTSIZ);
 	  entry.setCompressedSize(data_csize & 0xffffffffL);
 
 	  // Read uncompressed size
-	  int data_size = get32(dheader, DATA_UNCOMPRESSEDSIZE);
+	  int data_size = get32(dheader, EXTLEN);
 	  if (data_crc == 0 && data_size != 0) {
 	      throw new IOException(
 		"CRC error: data_crc=0, data_csize=" + data_csize + ",data_size=" + data_size);
Index: kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java:1.12 kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java:1.13
--- kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java:1.12	Mon Dec  3 03:42:07 2001
+++ kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java	Mon Sep 29 00:38:59 2003
@@ -136,20 +136,20 @@
 	// We only add the data descriptor when writing a compressed entry
 
 	if (curr.flag == 0x0008) {
-	    byte[] da = new byte[DATA_RECSZ];
-	    put32(da, DATA_SIGNATURE, (int)DATA_HEADSIG);
-	    put32(da, DATA_CRC, (int)curr.crc);
-	    put32(da, DATA_COMPRESSEDSIZE, (int) curr.csize);
-	    put32(da, DATA_UNCOMPRESSEDSIZE, (int) curr.size);
+	    byte[] da = new byte[EXTHDR];
+	    put32(da, 0, (int)EXTSIG);
+	    put32(da, EXTCRC, (int)curr.crc);
+	    put32(da, EXTSIZ, (int) curr.csize);
+	    put32(da, EXTLEN, (int) curr.size);
 	    strm.write(da);
-	    dout += DATA_RECSZ;
+	    dout += EXTHDR;
 	}
 
 	curr = null;
 }
 
 public void finish() throws IOException {
-	byte[] ch = new byte[CEN_RECSZ];
+	byte[] ch = new byte[CENHDR];
 	int count = 0;
 	int size = 0;
 
@@ -168,28 +168,28 @@
 		    UTF8.encode(ze.name) : new byte[0];
 
 		// Write central directory entry
-		put32(ch, CEN_SIGNATURE, (int)CEN_HEADSIG);
+		put32(ch, 0, (int)CENSIG);
 		int zipver = (ze.method == STORED ? ZIPVER_1_0 : ZIPVER_2_0);
-		put16(ch, CEN_VERSIONMADE, zipver);
-		put16(ch, CEN_VERSIONEXTRACT, zipver);
-		put16(ch, CEN_FLAGS, ze.flag);
-		put16(ch, CEN_METHOD, ze.method);
-		put32(ch, CEN_TIME, ze.dosTime);
-		put32(ch, CEN_CRC, (int)ze.crc);
-		put32(ch, CEN_COMPRESSEDSIZE, (int)ze.csize);
-		put32(ch, CEN_UNCOMPRESSEDSIZE, (int)ze.size);
-		put16(ch, CEN_FILENAMELEN, nameBuf.length);
-		put16(ch, CEN_EXTRAFIELDLEN, ze.extra == null ?
+		put16(ch, CENVEM, zipver);
+		put16(ch, CENVER, zipver);
+		put16(ch, CENFLG, ze.flag);
+		put16(ch, CENHOW, ze.method);
+		put32(ch, CENTIM, ze.dosTime);
+		put32(ch, CENCRC, (int)ze.crc);
+		put32(ch, CENSIZ, (int)ze.csize);
+		put32(ch, CENLEN, (int)ze.size);
+		put16(ch, CENNAM, nameBuf.length);
+		put16(ch, CENEXT, ze.extra == null ?
 			0 : ze.extra.length);
-		put16(ch, CEN_FILECOMMENTLEN, ze.comment == null ?
+		put16(ch, CENCOM, ze.comment == null ?
 			0 : ze.comment.length());
-		put16(ch, CEN_DISKNUMBER, 0);
-		put16(ch, CEN_INTERNALATTR, 0);
-		put32(ch, CEN_EXTERNALATTR, 0);
-		put32(ch, CEN_LCLOFFSET, (int)ze.offset);
+		put16(ch, CENDSK, 0);
+		put16(ch, CENATT, 0);
+		put32(ch, CENATX, 0);
+		put32(ch, CENOFF, (int)ze.offset);
 
 		strm.write(ch);
-		size += CEN_RECSZ;
+		size += CENHDR;
 
 		// Write name
 		strm.write(nameBuf);
@@ -209,15 +209,15 @@
 	        throw new ZipException("ZIP file must have at least one entry");
 	}
 
-	byte[] ce = new byte[END_RECSZ];
-	put32(ce, END_SIGNATURE, (int)END_ENDSIG);
-	put16(ce, END_DISKNUMBER, 0);
-	put16(ce, END_CENDISKNUMBER, 0);
-	put16(ce, END_TOTALCENONDISK, count);
-	put16(ce, END_TOTALCEN, count);
-	put32(ce, END_CENSIZE, size);
-	put32(ce, END_CENOFFSET, dout);
-	put16(ce, END_COMMENTLEN, 0);
+	byte[] ce = new byte[ENDHDR];
+	put32(ce, 0, (int)ENDSIG);
+	put16(ce, ENDNRD, 0);
+	put16(ce, ENDDCD, 0);
+	put16(ce, ENDSUB, count);
+	put16(ce, ENDTOT, count);
+	put32(ce, ENDSIZ, size);
+	put32(ce, ENDOFF, dout);
+	put16(ce, ENDCOM, 0);
 
 	strm.write(ce);
 
@@ -257,31 +257,31 @@
 	byte[] nameBuf = (ze.name != null) ?
 	    UTF8.encode(ze.name) : new byte[0];
 
-	byte[] lh = new byte[LOC_RECSZ];
-	put32(lh, LOC_SIGNATURE, (int)LOC_HEADSIG);
-	put16(lh, LOC_VERSIONEXTRACT,
+	byte[] lh = new byte[LOCHDR];
+	put32(lh, 0, (int)LOCSIG);
+	put16(lh, LOCVER,
 		ze.method == STORED ? ZIPVER_1_0 : ZIPVER_2_0);
-	put16(lh, LOC_FLAGS, ze.flag);
-	put16(lh, LOC_METHOD, ze.method);
-	put32(lh, LOC_TIME, ze.dosTime);
+	put16(lh, LOCFLG, ze.flag);
+	put16(lh, LOCHOW, ze.method);
+	put32(lh, LOCTIM, ze.dosTime);
 
 	if (ze.method == STORED) {
-		put32(lh, LOC_CRC, (int)ze.crc);
-		put32(lh, LOC_COMPRESSEDSIZE, (int)ze.csize);
-		put32(lh, LOC_UNCOMPRESSEDSIZE, (int)ze.size);
+		put32(lh, LOCCRC, (int)ze.crc);
+		put32(lh, LOCSIZ, (int)ze.csize);
+		put32(lh, LOCLEN, (int)ze.size);
 	} else {
-		put32(lh, LOC_CRC, 0);
-		put32(lh, LOC_COMPRESSEDSIZE, 0);
-		put32(lh, LOC_UNCOMPRESSEDSIZE, 0);
+		put32(lh, LOCCRC, 0);
+		put32(lh, LOCSIZ, 0);
+		put32(lh, LOCLEN, 0);
 	}
 
-	put16(lh, LOC_FILENAMELEN, nameBuf.length);
-	put16(lh, LOC_EXTRAFIELDLEN, ze.extra == null ? 0 : ze.extra.length);
+	put16(lh, LOCNAM, nameBuf.length);
+	put16(lh, LOCEXT, ze.extra == null ? 0 : ze.extra.length);
 
 	strm.write(lh);
 
 	ze.offset = dout;
-	dout += LOC_RECSZ;
+	dout += LOCHDR;
 
 	// Write name
 	strm.write(nameBuf);




More information about the kaffe mailing list