1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Kay Sievers, Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "in-addr-util.h"
24 #include "timesyncd-manager.h"
25 #include "timesyncd-server.h"
26 #include "timesyncd-conf.h"
28 int manager_parse_server_string(Manager *m, ServerType type, const char *string) {
29 const char *word, *state;
37 first = type == SERVER_FALLBACK ? m->fallback_servers : m->system_servers;
39 FOREACH_WORD_QUOTED(word, length, string, state) {
40 char buffer[length+1];
44 memcpy(buffer, word, length);
47 /* Filter out duplicates */
48 LIST_FOREACH(names, n, first)
49 if (streq_ptr(n->string, buffer)) {
57 r = server_name_new(m, NULL, type, buffer);
65 int config_parse_servers(
70 unsigned section_line,
77 Manager *m = userdata;
85 manager_flush_server_names(m, ltype);
87 r = manager_parse_server_string(m, ltype, rvalue);
89 log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to parse NTP server string '%s'. Ignoring.", rvalue);
97 int manager_parse_config_file(Manager *m) {
100 return config_parse(NULL, "/etc/systemd/timesyncd.conf", NULL,
102 config_item_perf_lookup, timesyncd_gperf_lookup,
103 false, false, true, m);