mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 00:51:24 +03:00
time: split get_timezone() into main function and zone1970.tab function
This allows for adding another function to read from a different timezone source, which is added in the next commit.
This commit is contained in:
parent
31097e2b99
commit
09a54a862b
@ -1262,7 +1262,7 @@ int parse_nsec(const char *t, nsec_t *nsec) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_timezones(char ***ret) {
|
||||
static int get_timezones_from_zone1970_tab(char ***ret) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_strv_free_ char **zones = NULL;
|
||||
int r;
|
||||
@ -1270,7 +1270,9 @@ int get_timezones(char ***ret) {
|
||||
assert(ret);
|
||||
|
||||
f = fopen("/usr/share/zoneinfo/zone1970.tab", "re");
|
||||
if (f) {
|
||||
if (!f)
|
||||
return -errno;
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *line = NULL, *cc = NULL, *co = NULL, *tz = NULL;
|
||||
|
||||
@ -1296,8 +1298,20 @@ int get_timezones(char ***ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
} else if (errno != ENOENT)
|
||||
return -errno;
|
||||
|
||||
*ret = TAKE_PTR(zones);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_timezones(char ***ret) {
|
||||
_cleanup_strv_free_ char **zones = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = get_timezones_from_zone1970_tab(&zones);
|
||||
if (r < 0 && r != -ENOENT)
|
||||
return r;
|
||||
|
||||
/* Always include UTC */
|
||||
r = strv_extend(&zones, "UTC");
|
||||
|
Loading…
Reference in New Issue
Block a user