* src/native/vm/java_lang_Class.c: Removed.
[cacao.git] / src / vmcore / zip.c
index 6aa5eec29029cbe5fa785bd4264fcbfc695fbd20..c3644e22cc543e3ba6aa5e5ef0f05606437efc9a 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vmcore/zip.c - ZIP file handling for bootstrap classloader
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-            Edwin Steiner
-
-   $Id: zip.c 7246 2007-01-29 18:49:05Z twisti $
-
 */
 
 
 #include "config.h"
 
 #include <assert.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
 #include "vm/types.h"
 
 #include "toolbox/hashtable.h"
+
 #include "mm/memory.h"
+
 #include "vm/global.h"
+#include "vm/vm.h"
+
 #include "vmcore/suck.h"
 #include "vmcore/utf8.h"
 #include "vmcore/zip.h"
 
 #define SIGNATURE_LENGTH    4
 
-
-/* Local file header ***********************************************************
-
-   local file header signature     4 bytes  (0x04034b50)
-   version needed to extract       2 bytes
-   general purpose bit flag        2 bytes
-   compression method              2 bytes
-   last mod file time              2 bytes
-   last mod file date              2 bytes
-   crc-32                          4 bytes
-   compressed size                 4 bytes
-   uncompressed size               4 bytes
-   file name length                2 bytes
-   extra field length              2 bytes
-
-   file name (variable size)
-   extra field (variable size)
-
-*******************************************************************************/
-
-#define LFH_HEADER_SIZE              30
-
-#define LFH_SIGNATURE                0x04034b50
-#define LFH_FILE_NAME_LENGTH         26
-#define LFH_EXTRA_FIELD_LENGTH       28
-
-typedef struct lfh lfh;
-
-struct lfh {
-       u2 compressionmethod;
-       u4 compressedsize;
-       u4 uncompressedsize;
-       u2 filenamelength;
-       u2 extrafieldlength;
-};
-
-
 /* Central directory structure *************************************************
 
    [file header 1]
@@ -408,7 +367,9 @@ classbuffer *zip_get(list_classpath_entry *lce, classinfo *c)
 
        /* try to find the class in the current archive */
 
-       if ((htzfe = zip_find(lce, c->name)) == NULL)
+       htzfe = zip_find(lce, c->name);
+
+       if (htzfe == NULL)
                return NULL;
 
        /* read stuff from local file header */
@@ -443,19 +404,19 @@ classbuffer *zip_get(list_classpath_entry *lce, classinfo *c)
                /* initialize this inflate run */
 
                if (inflateInit2(&zs, -MAX_WBITS) != Z_OK)
-                       assert(0);
+                       vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno));
 
                /* decompress the file into buffer */
 
                err = inflate(&zs, Z_SYNC_FLUSH);
 
                if ((err != Z_STREAM_END) && (err != Z_OK))
-                       assert(0);
+                       vm_abort("zip_get: inflate failed: %s", strerror(errno));
 
                /* finish this inflate run */
 
                if (inflateEnd(&zs) != Z_OK)
-                       assert(0);
+                       vm_abort("zip_get: inflateEnd failed: %s", strerror(errno));
                break;
 
        case 0:
@@ -464,14 +425,15 @@ classbuffer *zip_get(list_classpath_entry *lce, classinfo *c)
                break;
 
        default:
-               assert(0);
+               vm_abort("zip_get: unknown compression method %d",
+                                htzfe->compressionmethod);
        }
        
        /* allocate classbuffer */
 
        cb = NEW(classbuffer);
 
-       cb->class = c;
+       cb->clazz = c;
        cb->size  = htzfe->uncompressedsize;
        cb->data  = outdata;
        cb->pos   = outdata;