OSDN Git Service

* be.po, ca.po, da.po, de.po, el.po, es.po, fr.po, ja.po, nl.po,
[pf3gnuchains/gcc-fork.git] / fastjar / jartool.c
index b4b6674..09f5dbc 100644 (file)
@@ -1,6 +1,6 @@
 /*
   jartool.c - main functions for fastjar utility
-  Copyright (C) 2002, 2004  Free Software Foundation
+  Copyright (C) 2002, 2004, 2005  Free Software Foundation
   Copyright (C) 1999, 2000, 2001  Bryan Burns
   
   This program is free software; you can redistribute it and/or
@@ -284,8 +284,8 @@ static void init_args(char **, int);
 static char *get_next_arg (void);
 static char *jt_strdup (char*);
 static void expand_options (int *argcp, char ***argvp);
-static inline struct zipentry *find_entry (const char *);
-static inline int looks_like_dir (const char *);
+static struct zipentry *find_entry (const char *);
+static int looks_like_dir (const char *);
 
 /* global variables */
 ub1 file_header[30];
@@ -335,7 +335,8 @@ static const struct option options[] =
   { NULL, no_argument, NULL, 0 }
 };
 
-int main(int argc, char **argv){
+int main(int argc, char **argv)
+{
 
   char *mfile = NULL;
   
@@ -573,9 +574,16 @@ int main(int argc, char **argv){
     
     create_central_header(jarfd);
 
+#if ! (HAVE_FTRUNCATE || HAVE__CHSIZE)
+  #error neither ftruncate() or _chsize() available
+#endif
     /* Check if the file shrunk when we updated it. */
     if (action == ACTION_UPDATE)
+#if HAVE_FTRUNCATE
       ftruncate (jarfd, lseek (jarfd, 0, SEEK_CUR));
+#else
+      _chsize (jarfd, lseek (jarfd, 0, SEEK_CUR));
+#endif
 
     if (jarfd != STDIN_FILENO && close(jarfd) != 0) {
       fprintf(stderr, "%s: error closing jar archive: %s\n",
@@ -595,9 +603,7 @@ static int args_current_g;
 static char **args_g;
 
 static void 
-init_args(args, current)
-     char **args;
-     int current;
+init_args(char **args, int current)
 {
   if(!read_names_from_stdin)
     {
@@ -607,7 +613,7 @@ init_args(args, current)
 }
 
 static char *
-get_next_arg ()
+get_next_arg (void)
 {
   static int reached_end = 0;
 
@@ -667,7 +673,8 @@ get_next_arg ()
     }
 }
 
-void init_headers(){
+void init_headers(void)
+{
   /* packing file header */
   /* magic number */
   file_header[0] = 0x50;
@@ -718,7 +725,8 @@ void init_headers(){
   
 }
 
-void add_entry(struct zipentry *ze){
+void add_entry(struct zipentry *ze)
+{
 
   if(ziplist == NULL){
     ziplist = ze;
@@ -731,7 +739,7 @@ void add_entry(struct zipentry *ze){
   number_of_entries++;
 }
 
-static inline struct zipentry *
+static struct zipentry *
 find_entry (const char *fname)
 {
   struct zipentry *ze;
@@ -745,7 +753,7 @@ find_entry (const char *fname)
 }
 
 
-static inline int
+static int
 looks_like_dir (const char *fname)
 {
   struct zipentry *ze;
@@ -899,7 +907,8 @@ int read_entries (int fd)
   return 0;
 }
 
-int make_manifest(int jfd, const char *mf_name, int updating){
+int make_manifest(int jfd, const char *mf_name, int updating)
+{
   time_t current_time;
   int nlen;   /* length of file name */
   int mod_time; /* file modification time */
@@ -1798,8 +1807,10 @@ int extract_jar(int fd, char **files, int file_num){
       exit(1);
     }
 
+    if (eflen > 0)
+      consume(&pbf, eflen);
+
     if(method == 8 || flags & 0x0008){
-        consume(&pbf, eflen);
       
       inflate_file(&pbf, f_fd, &ze);
     } else {
@@ -1832,8 +1843,6 @@ int extract_jar(int fd, char **files, int file_num){
         printf("%d bytes written\n", out_a);
 #endif
       }
-
-        consume(&pbf, eflen);
     }
 
     /* if there is a data descriptor left, compare the CRC */
@@ -2205,7 +2214,7 @@ void usage(const char *filename){
   exit (1);
 }
 
-void version ()
+void version (void)
 {
   printf("jar (%s) %s\n\n", PACKAGE, VERSION);
   printf("Copyright 1999, 2000, 2001  Bryan Burns\n");
@@ -2257,8 +2266,7 @@ Example 2: use an existing manifest file 'mymanifest' and archive all the\n\
 }
 
 static char *
-jt_strdup(s)
-     char *s;
+jt_strdup(char *s)
 {
   char *result = (char*)malloc(strlen(s) + 1);
   if (result == (char*)0)