]> Dogcows Code - chaz/tar/blobdiff - scripts/xsparse.c
tar: change interdir_made from int to bool
[chaz/tar] / scripts / xsparse.c
index 99bb82a05ae805355d583b8d17270a534daac20d..fd91b48726c2b75a71367c3271d6742610f89ae3 100644 (file)
@@ -4,10 +4,10 @@
    Copyright (C) 2006, 2007 Free Software Foundation, Inc.
 
    Written by Sergey Poznyakoff
    Copyright (C) 2006, 2007 Free Software Foundation, Inc.
 
    Written by Sergey Poznyakoff
-   
+
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    This program 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
+   Free Software Foundation; either version 3, or (at your option) any later
    version.
 
    This program is distributed in the hope that it will be useful, but
    version.
 
    This program is distributed in the hope that it will be useful, but
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -128,12 +129,12 @@ get_var (FILE *fp, char **name, char **value)
   static char *buffer;
   static size_t bufsize = OFF_T_STRSIZE_BOUND;
   char *p, *q;
   static char *buffer;
   static size_t bufsize = OFF_T_STRSIZE_BOUND;
   char *p, *q;
-  
+
   buffer = emalloc (bufsize);
   do
     {
       size_t len, s;
   buffer = emalloc (bufsize);
   do
     {
       size_t len, s;
-      
+
       if (!fgets (buffer, bufsize, fp))
        return 0;
       len = strlen (buffer);
       if (!fgets (buffer, bufsize, fp))
        return 0;
       len = strlen (buffer);
@@ -185,12 +186,12 @@ read_xheader (char *name)
 
   if (verbose)
     printf ("Reading extended header file\n");
 
   if (verbose)
     printf ("Reading extended header file\n");
-  
+
   while (get_var (fp, &kw, &val))
     {
       if (verbose)
        printf ("Found variable GNU.sparse.%s = %s\n", kw, val);
   while (get_var (fp, &kw, &val))
     {
       if (verbose)
        printf ("Found variable GNU.sparse.%s = %s\n", kw, val);
-      
+
       if (expect && strcmp (kw, expect))
        die (1, "bad keyword sequence: expected `%s' but found `%s'",
             expect, kw);
       if (expect && strcmp (kw, expect))
        die (1, "bad keyword sequence: expected `%s' but found `%s'",
             expect, kw);
@@ -266,7 +267,7 @@ read_map (FILE *ifp)
 
   if (verbose)
     printf ("Reading v.1.0 sparse map\n");
 
   if (verbose)
     printf ("Reading v.1.0 sparse map\n");
-  
+
   get_line (nbuf, sizeof nbuf, ifp);
   sparse_map_size = string_to_size (nbuf, NULL);
   sparse_map = emalloc (sparse_map_size * sizeof *sparse_map);
   get_line (nbuf, sizeof nbuf, ifp);
   sparse_map_size = string_to_size (nbuf, NULL);
   sparse_map = emalloc (sparse_map_size * sizeof *sparse_map);
@@ -279,9 +280,9 @@ read_map (FILE *ifp)
       sparse_map[i].numbytes = string_to_size (nbuf, NULL);
     }
 
       sparse_map[i].numbytes = string_to_size (nbuf, NULL);
     }
 
-  fseek (ifp, ((ftell (ifp) + BLOCKSIZE - 1) / BLOCKSIZE) * BLOCKSIZE,
-        SEEK_SET);
-}  
+  fseeko (ifp, ((ftell (ifp) + BLOCKSIZE - 1) / BLOCKSIZE) * BLOCKSIZE,
+         SEEK_SET);
+}
 
 void
 expand_sparse (FILE *sfp, int ofd)
 
 void
 expand_sparse (FILE *sfp, int ofd)
@@ -293,11 +294,11 @@ expand_sparse (FILE *sfp, int ofd)
   for (i = 0; i < sparse_map_size; i++)
     if (maxbytes < sparse_map[i].numbytes)
       maxbytes = sparse_map[i].numbytes;
   for (i = 0; i < sparse_map_size; i++)
     if (maxbytes < sparse_map[i].numbytes)
       maxbytes = sparse_map[i].numbytes;
-  
+
   for (buffer = malloc (maxbytes); !buffer; maxbytes /= 2)
     if (maxbytes == 0)
       die (1, "not enough memory");
   for (buffer = malloc (maxbytes); !buffer; maxbytes /= 2)
     if (maxbytes == 0)
       die (1, "not enough memory");
-  
+
   for (i = 0; i < sparse_map_size; i++)
     {
       size_t size = sparse_map[i].numbytes;
   for (i = 0; i < sparse_map_size; i++)
     {
       size_t size = sparse_map[i].numbytes;
@@ -341,13 +342,13 @@ guess_outname (char *name)
 {
   char *p;
   char *s;
 {
   char *p;
   char *s;
-  
+
   if (name[0] == '.' && name[1] == '/')
     name += 2;
 
   p = name + strlen (name) - 1;
   s = NULL;
   if (name[0] == '.' && name[1] == '/')
     name += 2;
 
   p = name + strlen (name) - 1;
   s = NULL;
-      
+
   for (; p > name && *p != '/'; p--)
     ;
   if (*p == '/')
   for (; p > name && *p != '/'; p--)
     ;
   if (*p == '/')
@@ -357,7 +358,7 @@ guess_outname (char *name)
       for (p--; p > name && *p != '/'; p--)
        ;
     }
       for (p--; p > name && *p != '/'; p--)
        ;
     }
-  
+
   if (*p != '/')
     {
       if (s)
   if (*p != '/')
     {
       if (s)
@@ -388,7 +389,7 @@ main (int argc, char **argv)
   FILE *ifp;
   struct stat st;
   int ofd;
   FILE *ifp;
   struct stat st;
   int ofd;
-  
+
   progname = argv[0];
   while ((c = getopt (argc, argv, "hnvx:")) != EOF)
     {
   progname = argv[0];
   while ((c = getopt (argc, argv, "hnvx:")) != EOF)
     {
@@ -407,7 +408,7 @@ main (int argc, char **argv)
        case 'v':
          verbose++;
          break;
        case 'v':
          verbose++;
          break;
-         
+
        default:
          exit (1);
        }
        default:
          exit (1);
        }
@@ -428,17 +429,17 @@ main (int argc, char **argv)
 
   if (stat (inname, &st))
     die (1, "cannot stat %s (%d)", inname, errno);
 
   if (stat (inname, &st))
     die (1, "cannot stat %s (%d)", inname, errno);
-  
+
   ifp = fopen (inname, "r");
   if (ifp == NULL)
     die (1, "cannot open file %s (%d)", inname, errno);
   ifp = fopen (inname, "r");
   if (ifp == NULL)
     die (1, "cannot open file %s (%d)", inname, errno);
-  
+
   if (!xheader_file || version_major == 1)
     read_map (ifp);
 
   if (!outname)
     guess_outname (inname);
   if (!xheader_file || version_major == 1)
     read_map (ifp);
 
   if (!outname)
     guess_outname (inname);
-  
+
   ofd = open (outname, O_RDWR|O_CREAT|O_TRUNC, st.st_mode);
   if (ofd == -1)
     die (1, "cannot open file %s (%d)", outname, errno);
   ofd = open (outname, O_RDWR|O_CREAT|O_TRUNC, st.st_mode);
   if (ofd == -1)
     die (1, "cannot open file %s (%d)", outname, errno);
@@ -451,7 +452,7 @@ main (int argc, char **argv)
       printf ("Finished dry run\n");
       return 0;
     }
       printf ("Finished dry run\n");
       return 0;
     }
-  
+
   expand_sparse (ifp, ofd);
 
   fclose (ifp);
   expand_sparse (ifp, ofd);
 
   fclose (ifp);
@@ -459,7 +460,7 @@ main (int argc, char **argv)
 
   if (verbose)
     printf ("Done\n");
 
   if (verbose)
     printf ("Done\n");
-  
+
   if (outsize)
     {
       if (stat (outname, &st))
   if (outsize)
     {
       if (stat (outname, &st))
@@ -467,7 +468,6 @@ main (int argc, char **argv)
       if (st.st_size != outsize)
        die (1, "expanded file has wrong size");
     }
       if (st.st_size != outsize)
        die (1, "expanded file has wrong size");
     }
-  
+
   return 0;
 }
   return 0;
 }
-
This page took 0.025665 seconds and 4 git commands to generate.