diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-24 16:44:56 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-24 16:53:05 +0100 |
commit | 901992209e3c87a4cf06b530d7b26ae2d35680ef (patch) | |
tree | bed037327826be870021502f5e72d1b1652d68d0 /src/import/curl-util.c | |
parent | 0c7bf33a989a58922b3eb9aaa96abd773c8754c4 (diff) |
import: add a new "pull-gpt" verb for downloading GPT disk images from the internet
Diffstat (limited to 'src/import/curl-util.c')
-rw-r--r-- | src/import/curl-util.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/import/curl-util.c b/src/import/curl-util.c index eaaebaef42..78a58a8a6d 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -413,3 +413,34 @@ int curl_header_strdup(const void *contents, size_t sz, const char *field, char *value = s; return 1; } + +int curl_parse_http_time(const char *t, time_t *ret) { + struct tm tm; + time_t v; + + assert(t); + assert(ret); + + RUN_WITH_LOCALE(LC_TIME, "C") { + const char *e; + + /* RFC822 */ + e = strptime(t, "%a, %d %b %Y %H:%M:%S %Z", &tm); + if (!e || *e != 0) + /* RFC 850 */ + e = strptime(t, "%A, %d-%b-%y %H:%M:%S %Z", &tm); + if (!e || *e != 0) + /* ANSI C */ + e = strptime(t, "%a %b %d %H:%M:%S %Y", &tm); + if (!e || *e != 0) + return -EINVAL; + + v = timegm(&tm); + } + + if (v == (time_t) -1) + return -EINVAL; + + *ret = v; + return 0; +} |