]> Dogcows Code - chaz/tar/blobdiff - src/xheader.c
(tar_sparse_major,tar_sparse_minor): New globals.
[chaz/tar] / src / xheader.c
index 8399df81fd41faa1a55d8961f564cd231c561185..3eb1505890f68b207c5c1a66d2f3b306521239af 100644 (file)
@@ -1,6 +1,6 @@
 /* POSIX extended headers for tar.
 
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
    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
@@ -157,7 +157,7 @@ xheader_list_destroy (struct keyword_list **root)
 static void
 xheader_set_single_keyword (char *kw)
 {
-  USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet imlemented"), kw));
+  USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet implemented"), kw));
 }
 
 static void
@@ -836,8 +836,15 @@ code_time (struct timespec t, char const *keyword, struct xheader *xhdr)
   xheader_print (xhdr, keyword, code_timespec (t, buf));
 }
 
-static bool
-decode_time (struct timespec *ts, char const *arg, char const *keyword)
+enum decode_time_status
+  {
+    decode_time_success,
+    decode_time_range,
+    decode_time_bad_header
+  };
+
+static enum decode_time_status
+_decode_time (struct timespec *ts, char const *arg, char const *keyword)
 {
   time_t s;
   unsigned long int ns = 0;
@@ -853,21 +860,21 @@ decode_time (struct timespec *ts, char const *arg, char const *keyword)
        {
          intmax_t i = strtoimax (arg, &arg_lim, 10);
          if (TYPE_SIGNED (time_t) ? i < TYPE_MINIMUM (time_t) : i < 0)
-           goto out_of_range;
+           return decode_time_range;
          s = i;
        }
       else
        {
          uintmax_t i = strtoumax (arg, &arg_lim, 10);
          if (TYPE_MAXIMUM (time_t) < i)
-           goto out_of_range;
+           return decode_time_range;
          s = i;
        }
 
       p = arg_lim;
 
       if (errno == ERANGE)
-       goto out_of_range;
+       return decode_time_range;
 
       if (*p == '.')
        {
@@ -895,7 +902,7 @@ decode_time (struct timespec *ts, char const *arg, char const *keyword)
              if (ns != 0)
                {
                  if (s == TYPE_MINIMUM (time_t))
-                   goto out_of_range;
+                   return decode_time_range;
                  s--;
                  ns = BILLION - ns;
                }
@@ -906,20 +913,34 @@ decode_time (struct timespec *ts, char const *arg, char const *keyword)
        {
          ts->tv_sec = s;
          ts->tv_nsec = ns;
-         return true;
+         return decode_time_success;
        }
     }
 
-  ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
-         keyword, arg));
-  return false;
+  return decode_time_bad_header;
+}
 
- out_of_range:
-  out_of_range_header (keyword, arg, - (uintmax_t) TYPE_MINIMUM (time_t),
-                      TYPE_MAXIMUM (time_t));
-  return false;
+static bool
+decode_time (struct timespec *ts, char const *arg, char const *keyword)
+{
+  switch (_decode_time (ts, arg, keyword))
+    {
+    case decode_time_success:
+      return true;
+    case decode_time_bad_header:
+      ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
+             keyword, arg));
+      return false;
+    case decode_time_range:
+      out_of_range_header (keyword, arg, - (uintmax_t) TYPE_MINIMUM (time_t),
+                          TYPE_MAXIMUM (time_t));
+      return false;
+    }
+  return true;
 }
 
+  
+
 static void
 code_num (uintmax_t value, char const *keyword, struct xheader *xhdr)
 {
@@ -1362,7 +1383,9 @@ struct xhdr_tab const xhdr_tab[] = {
   { "GNU.sparse.size",       sparse_size_coder, sparse_size_decoder, true },
   { "GNU.sparse.numblocks",  sparse_numblocks_coder, sparse_numblocks_decoder,
     true },
-  /* tar 1.14 - 1.15.1 keywords. Multiplse instances of these appeared in 'x'
+  { "GNU.sparse.name",       path_coder, path_decoder,
+    true },
+  /* tar 1.14 - 1.15.1 keywords. Multiple instances of these appeared in 'x'
      headers, and each of them was meaningful. It confilcted with POSIX specs,
      which requires that "when extended header records conflict, the last one
      given in the header shall take precedence." */
This page took 0.026717 seconds and 4 git commands to generate.