OSDN Git Service

* boehm.c (set_bit): Improve type safety wrt unsignedness.
[pf3gnuchains/gcc-fork.git] / gcc / java / zextract.c
index 3985cd9..eeea944 100644 (file)
@@ -1,21 +1,23 @@
 /* Handle a .class file embedded in a .zip archive.
    This extracts a member from a .zip file, but does not handle
    uncompression (since that is not needed for classes.zip).
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
+   Free Software Foundation, Inc.
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000  Free Software Foundation, Inc.
+This file is part of GCC.
 
-This program is free software; you can redistribute it and/or modify
+GCC 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.
 
-This program is distributed in the hope that it will be useful,
+GCC 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 CC; see the file COPYING.  If not, write to
+along with GCC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  
 
@@ -27,6 +29,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "zipfile.h"
 
 /* This stuff is partly based on the 28 August 1994 public release of the
@@ -210,16 +214,15 @@ typedef unsigned long     ulg;  /*  predefined on some systems) & match zip  */
 /* Prototypes          */
 /***********************/
 
-static ush makeword PARAMS ((const uch *));
-static ulg makelong PARAMS ((const uch *));
-static long find_zip_file_start PARAMS ((int fd, long offset));
+static ush makeword (const uch *);
+static ulg makelong (const uch *);
+static long find_zip_file_start (int fd, long offset);
 
 /***********************/
 /* Function makeword() */
 /***********************/
 
-static ush makeword(b)
-    const uch *b;
+static ush makeword(const uch *b)
 {
     /*
      * Convert Intel style 'short' integer to non-Intel non-16-bit
@@ -233,8 +236,8 @@ static ush makeword(b)
 /* Function makelong() */
 /***********************/
 
-static ulg makelong(sig)
-    const uch *sig;
+static ulg
+makelong (const uch *sig)
 {
     /*
      * Convert intel style 'long' variable to non-Intel non-16-bit
@@ -250,9 +253,7 @@ static ulg makelong(sig)
    start of the actual data.  Return -1 on error.  OFFSET is the
    offset from the beginning of the zip file of the file's header.  */
 static long
-find_zip_file_start (fd, offset)
-     int fd;
-     long offset;
+find_zip_file_start (int fd, long offset)
 {
   int filename_length, extra_field_length;
   unsigned char buffer[LREC_SIZE + 4];
@@ -263,7 +264,7 @@ find_zip_file_start (fd, offset)
   if (read (fd, buffer, LREC_SIZE + 4) != LREC_SIZE + 4)
     return -1;
 
-  if (buffer[0] != 'P' || strncmp (&buffer[1], LOCAL_HDR_SIG, 3))
+  if (buffer[0] != 'P' || strncmp ((const char *) &buffer[1], LOCAL_HDR_SIG, 3))
     return -1;
 
   filename_length = makeword (&buffer[4 + L_FILENAME_LENGTH]);
@@ -273,8 +274,7 @@ find_zip_file_start (fd, offset)
 }
 
 int
-read_zip_archive (zipf)
-     register ZipFile *zipf;
+read_zip_archive (ZipFile *zipf)
 {
   int i;
   int dir_last_pad;
@@ -287,8 +287,8 @@ read_zip_archive (zipf)
     return -1;
   if (read (zipf->fd, buffer, ECREC_SIZE+4) != ECREC_SIZE+4)
     return -2;
-  zipf->count = makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR]);
-  zipf->dir_size = makelong(&buffer[SIZE_CENTRAL_DIRECTORY]);
+  zipf->count = makeword((const uch *) &buffer[TOTAL_ENTRIES_CENTRAL_DIR]);
+  zipf->dir_size = makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY]);
 #define ALLOC xmalloc
   /* Allocate 1 more to allow appending '\0' to last filename. */
   zipf->central_directory = ALLOC (zipf->dir_size+1);
@@ -306,9 +306,9 @@ read_zip_archive (zipf)
   printf ("total_entries_central_dir = %d\n",
         makeword(&buffer[TOTAL_ENTRIES_CENTRAL_DIR]));
   printf ("size_central_directory = %d\n",
-        makelong(&buffer[SIZE_CENTRAL_DIRECTORY]));
+        makelong((const uch *) &buffer[SIZE_CENTRAL_DIRECTORY]));
   printf ("offset_start_central_directory = %d\n",
-        makelong(&buffer[OFFSET_START_CENTRAL_DIRECTORY]));
+        makelong((const uch *) &buffer[OFFSET_START_CENTRAL_DIRECTORY]));
   printf ("zipfile_comment_length = %d\n",
         makeword(&buffer[ZIPFILE_COMMENT_LENGTH]));
 #endif
@@ -319,11 +319,11 @@ read_zip_archive (zipf)
     {
       ZipDirectory *zipd = (ZipDirectory*)(dir_ptr + dir_last_pad);
       int compression_method = (int) dir_ptr[4+C_COMPRESSION_METHOD];
-      long size = makelong (&dir_ptr[4+C_COMPRESSED_SIZE]);
-      long uncompressed_size = makelong (&dir_ptr[4+C_UNCOMPRESSED_SIZE]);
-      long filename_length = makeword (&dir_ptr[4+C_FILENAME_LENGTH]);
-      long extra_field_length = makeword (&dir_ptr[4+C_EXTRA_FIELD_LENGTH]);
-      long file_offset = makelong (&dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]);
+      long size = makelong ((const uch *) &dir_ptr[4+C_COMPRESSED_SIZE]);
+      long uncompressed_size = makelong ((const uch *) &dir_ptr[4+C_UNCOMPRESSED_SIZE]);
+      long filename_length = makeword ((const uch *) &dir_ptr[4+C_FILENAME_LENGTH]);
+      long extra_field_length = makeword ((const uch *) &dir_ptr[4+C_EXTRA_FIELD_LENGTH]);
+      long file_offset = makelong ((const uch *) &dir_ptr[4+C_RELATIVE_OFFSET_LOCAL_HEADER]);
       int unpadded_direntry_length;
       if ((dir_ptr-zipf->central_directory)+filename_length+CREC_SIZE+4>zipf->dir_size)
        return -1;
@@ -352,7 +352,7 @@ read_zip_archive (zipf)
 }
 
 #ifdef TEST
-main ()
+main (void)
 {
   ZipFile zipf[1];
   ZipDirectory *zipd;