X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fxheader.c;h=5eabdfb4318ecaae63b034cfb6138cc2b4868abf;hb=63e092548a9b87c0be0f0b286c883e1f3d52294c;hp=e8fd6a207171bf7111c9f19821aa745c3c7849fa;hpb=7cb84c25ee51f443c69443e217efe194d12678ea;p=chaz%2Ftar diff --git a/src/xheader.c b/src/xheader.c index e8fd6a2..5eabdfb 100644 --- a/src/xheader.c +++ b/src/xheader.c @@ -96,9 +96,15 @@ static struct keyword_list *global_header_override_list; /* Template for the name field of an 'x' type header */ static char *exthdr_name; +static char *exthdr_mtime_option; +static time_t exthdr_mtime; + /* Template for the name field of a 'g' type header */ static char *globexthdr_name; +static char *globexthdr_mtime_option; +static time_t globexthdr_mtime; + bool xheader_keyword_deleted_p (const char *kw) { @@ -156,6 +162,21 @@ xheader_set_single_keyword (char *kw) USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet implemented"), kw)); } +static void +assign_time_option (char **sval, time_t *tval, const char *input) +{ + uintmax_t u; + char *p; + time_t t = u = strtoumax (input, &p, 10); + if (t != u || *p || errno == ERANGE) + ERROR ((0, 0, _("Time stamp is out of allowed range"))); + else + { + *tval = t; + assign_string (sval, input); + } +} + static void xheader_set_keyword_equal (char *kw, char *eq) { @@ -186,6 +207,10 @@ xheader_set_keyword_equal (char *kw, char *eq) assign_string (&exthdr_name, p); else if (strcmp (kw, "globexthdr.name") == 0) assign_string (&globexthdr_name, p); + else if (strcmp (kw, "exthdr.mtime") == 0) + assign_time_option (&exthdr_mtime_option, &exthdr_mtime, p); + else if (strcmp (kw, "globexthdr.mtime") == 0) + assign_time_option (&globexthdr_mtime_option, &globexthdr_mtime, p); else { if (xheader_protected_keyword_p (kw)) @@ -371,6 +396,18 @@ xheader_write (char type, char *name, time_t t, struct xheader *xhdr) char *p; size = xhdr->size; + switch (type) + { + case XGLTYPE: + if (globexthdr_mtime_option) + t = globexthdr_mtime; + break; + + case XHDTYPE: + if (exthdr_mtime_option) + t = exthdr_mtime; + break; + } header = start_private_header (name, size, t); header->header.typeflag = type;