]> Dogcows Code - chaz/tar/blobdiff - src/xheader.c
(write_extended): Change type and meaning of the first argument. All callers updated
[chaz/tar] / src / xheader.c
index 029bebf3b5eb55b53eb10e3836dcc777be472b1d..37bcdc1d7c1b9ed84049b324897074a62eb5c373 100644 (file)
@@ -424,7 +424,7 @@ struct xhdr_tab
 {
   char const *keyword;
   void (*coder) (struct tar_stat_info const *, char const *,
-                struct xheader *, void *data);
+                struct xheader *, void const *data);
   void (*decoder) (struct tar_stat_info *, char const *, size_t);
   bool protect;
 };
@@ -615,7 +615,8 @@ extended_header_init (void)
 }
 
 void
-xheader_store (char const *keyword, struct tar_stat_info const *st, void *data)
+xheader_store (char const *keyword, struct tar_stat_info const *st,
+              void const *data)
 {
   struct xhdr_tab const *t;
 
@@ -742,7 +743,7 @@ xheader_string_add (char const *s)
 
 void
 xheader_string_end (char const *keyword)
-{  
+{
   size_t len;
   size_t p;
   size_t n = 0;
@@ -753,9 +754,9 @@ xheader_string_end (char const *keyword)
   if (extended_header.buffer)
     return;
   extended_header_init ();
-  
+
   len = strlen (keyword) + string_length + 3; /* ' ' + '=' + '\n' */
-  
+
   do
     {
       p = n;
@@ -950,7 +951,7 @@ static void
 dummy_coder (struct tar_stat_info const *st __attribute__ ((unused)),
             char const *keyword __attribute__ ((unused)),
             struct xheader *xhdr __attribute__ ((unused)),
-            void *data __attribute__ ((unused)))
+            void const *data __attribute__ ((unused)))
 {
 }
 
@@ -963,7 +964,7 @@ dummy_decoder (struct tar_stat_info *st __attribute__ ((unused)),
 
 static void
 atime_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_time (st->atime, keyword, xhdr);
 }
@@ -979,7 +980,7 @@ atime_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 gid_coder (struct tar_stat_info const *st, char const *keyword,
-          struct xheader *xhdr, void *data __attribute__ ((unused)))
+          struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_num (st->stat.st_gid, keyword, xhdr);
 }
@@ -995,7 +996,7 @@ gid_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 gname_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->gname, keyword, xhdr);
 }
@@ -1009,7 +1010,7 @@ gname_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 linkpath_coder (struct tar_stat_info const *st, char const *keyword,
-               struct xheader *xhdr, void *data __attribute__ ((unused)))
+               struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->link_name, keyword, xhdr);
 }
@@ -1023,7 +1024,7 @@ linkpath_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 ctime_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_time (st->ctime, keyword, xhdr);
 }
@@ -1039,7 +1040,7 @@ ctime_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 mtime_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_time (st->mtime, keyword, xhdr);
 }
@@ -1055,7 +1056,7 @@ mtime_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 path_coder (struct tar_stat_info const *st, char const *keyword,
-           struct xheader *xhdr, void *data __attribute__ ((unused)))
+           struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->file_name, keyword, xhdr);
 }
@@ -1071,7 +1072,7 @@ path_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 size_coder (struct tar_stat_info const *st, char const *keyword,
-           struct xheader *xhdr, void *data __attribute__ ((unused)))
+           struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_num (st->stat.st_size, keyword, xhdr);
 }
@@ -1087,7 +1088,7 @@ size_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 uid_coder (struct tar_stat_info const *st, char const *keyword,
-          struct xheader *xhdr, void *data __attribute__ ((unused)))
+          struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_num (st->stat.st_uid, keyword, xhdr);
 }
@@ -1103,7 +1104,7 @@ uid_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 uname_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->uname, keyword, xhdr);
 }
@@ -1117,7 +1118,7 @@ uname_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 sparse_size_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data)
+            struct xheader *xhdr, void const *data)
 {
   size_coder (st, keyword, xhdr, data);
 }
@@ -1134,7 +1135,7 @@ sparse_size_decoder (struct tar_stat_info *st, char const *arg,
 static void
 sparse_numblocks_coder (struct tar_stat_info const *st, char const *keyword,
                        struct xheader *xhdr,
-                       void *data __attribute__ ((unused)))
+                       void const *data __attribute__ ((unused)))
 {
   code_num (st->sparse_map_avail, keyword, xhdr);
 }
@@ -1154,9 +1155,9 @@ sparse_numblocks_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 sparse_offset_coder (struct tar_stat_info const *st, char const *keyword,
-                    struct xheader *xhdr, void *data)
+                    struct xheader *xhdr, void const *data)
 {
-  size_t *pi = data;
+  size_t const *pi = data;
   code_num (st->sparse_map[*pi].offset, keyword, xhdr);
 }
 
@@ -1177,9 +1178,9 @@ sparse_offset_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 sparse_numbytes_coder (struct tar_stat_info const *st, char const *keyword,
-                      struct xheader *xhdr, void *data)
+                      struct xheader *xhdr, void const *data)
 {
-  size_t *pi = data;
+  size_t const *pi = data;
   code_num (st->sparse_map[*pi].numbytes, keyword, xhdr);
 }
 
@@ -1204,14 +1205,14 @@ sparse_map_decoder (struct tar_stat_info *st, char const *arg,
 {
   int offset = 1;
   static char *keyword = "GNU.sparse.map";
-  
+
   st->sparse_map_avail = 0;
   while (1)
     {
       uintmax_t u;
       char *delim;
       struct sp_array e;
-      
+
       if (!ISDIGIT (*arg))
        {
          ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
@@ -1247,7 +1248,7 @@ sparse_map_decoder (struct tar_stat_info *st, char const *arg,
              return;
            }
        }
-           
+
       offset = !offset;
 
       if (*delim == 0)
@@ -1271,7 +1272,7 @@ sparse_map_decoder (struct tar_stat_info *st, char const *arg,
 
 static void
 dumpdir_coder (struct tar_stat_info const *st, char const *keyword,
-              struct xheader *xhdr, void *data)
+              struct xheader *xhdr, void const *data)
 {
   xheader_print_n (xhdr, keyword, data, dumpdir_size (data));
 }
@@ -1284,6 +1285,60 @@ dumpdir_decoder (struct tar_stat_info *st, char const *arg,
   memcpy (st->dumpdir, arg, size);
 }
 
+static void
+volume_label_coder (struct tar_stat_info const *st, char const *keyword,
+                   struct xheader *xhdr, void const *data)
+{
+  code_string (data, keyword, xhdr);
+}
+
+static void
+volume_label_decoder (struct tar_stat_info *st, char const *arg, size_t size)
+{
+  decode_string (&volume_label, arg);
+}
+
+static void
+volume_size_coder (struct tar_stat_info const *st, char const *keyword,
+                  struct xheader *xhdr, void const *data)
+{
+  off_t v = *(off_t*)data;
+  code_num (v, keyword, xhdr);
+}
+
+static void
+volume_size_decoder (struct tar_stat_info *st, char const *arg, size_t size)
+{
+  uintmax_t u;
+  if (decode_num (&u, arg, TYPE_MAXIMUM (uintmax_t), "GNU.volume.size"))
+    continued_file_size = u;
+}
+
+/* FIXME: Merge with volume_size_coder */
+static void
+volume_offset_coder (struct tar_stat_info const *st, char const *keyword,
+                    struct xheader *xhdr, void const *data)
+{
+  off_t v = *(off_t*)data;
+  code_num (v, keyword, xhdr);
+}
+
+static void
+volume_offset_decoder (struct tar_stat_info *st, char const *arg, size_t size)
+{
+  uintmax_t u;
+  if (decode_num (&u, arg, TYPE_MAXIMUM (uintmax_t), "GNU.volume.offset"))
+    continued_file_offset = u;
+}
+
+static void
+volume_filename_decoder (struct tar_stat_info *st, char const *arg,
+                        size_t size)
+{
+  decode_string (&continued_file_name, arg);
+}
+  
+
 struct xhdr_tab const xhdr_tab[] = {
   { "atime",   atime_coder,    atime_decoder,    false },
   { "comment", dummy_coder,    dummy_decoder,    false },
@@ -1316,12 +1371,10 @@ struct xhdr_tab const xhdr_tab[] = {
 
   { "GNU.dumpdir",           dumpdir_coder, dumpdir_decoder,
     true },
-  
-#if 0 /* GNU private keywords (not yet implemented) */
 
-  /* Keeps the tape/volume header. May be present only in the global headers.
+  /* Keeps the tape/volume label. May be present only in the global headers.
      Equivalent to GNUTYPE_VOLHDR.  */
-  { "GNU.volume.header", volume_header_coder, volume_header_decoder, false },
+  { "GNU.volume.label", volume_label_coder, volume_label_decoder, true },
 
   /* These may be present in a first global header of the archive.
      They provide the same functionality as GNUTYPE_MULTIVOL header.
@@ -1329,9 +1382,10 @@ struct xhdr_tab const xhdr_tab[] = {
      otherwise kept in the size field of a multivolume header.  The
      GNU.volume.offset keeps the offset of the start of this volume,
      otherwise kept in oldgnu_header.offset.  */
-  { "GNU.volume.size", volume_size_coder, volume_size_decoder, false },
-  { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, false },
-#endif
+  { "GNU.volume.filename", volume_label_coder, volume_filename_decoder,
+    true },
+  { "GNU.volume.size", volume_size_coder, volume_size_decoder, true },
+  { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, true },
 
   { NULL, NULL, NULL, false }
 };
This page took 0.027802 seconds and 4 git commands to generate.