+static int config_parse_timer(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ Timer *t = data;
+ usec_t u;
+ int r;
+ TimerValue *v;
+ TimerBase b;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if ((b = timer_base_from_string(lvalue)) < 0) {
+ log_error("[%s:%u] Failed to parse timer base: %s", filename, line, lvalue);
+ return -EINVAL;
+ }
+
+ if ((r = parse_usec(rvalue, &u)) < 0) {
+ log_error("[%s:%u] Failed to parse timer value: %s", filename, line, rvalue);
+ return r;
+ }
+
+ if (!(v = new0(TimerValue, 1)))
+ return -ENOMEM;
+
+ v->base = b;
+ v->value = u;
+
+ LIST_PREPEND(TimerValue, value, t->values, v);
+
+ return 0;
+}
+
+static int config_parse_timer_unit(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ Timer *t = data;
+ int r;
+ DBusError error;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ dbus_error_init(&error);
+
+ if (endswith(rvalue, ".timer")) {
+ log_error("[%s:%u] Unit cannot be of type timer: %s", filename, line, rvalue);
+ return -EINVAL;
+ }
+
+ if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, NULL, &t->unit)) < 0) {
+ log_error("[%s:%u] Failed to load unit %s: %s", filename, line, rvalue, bus_error(&error, r));
+ dbus_error_free(&error);
+ return r;
+ }
+
+ return 0;
+}
+
+static int config_parse_path_spec(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ Path *p = data;
+ PathSpec *s;
+ PathType b;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if ((b = path_type_from_string(lvalue)) < 0) {
+ log_error("[%s:%u] Failed to parse path type: %s", filename, line, lvalue);
+ return -EINVAL;
+ }
+
+ if (!path_is_absolute(rvalue)) {
+ log_error("[%s:%u] Path is not absolute: %s", filename, line, rvalue);
+ return -EINVAL;
+ }
+
+ if (!(s = new0(PathSpec, 1)))
+ return -ENOMEM;
+
+ if (!(s->path = strdup(rvalue))) {
+ free(s);
+ return -ENOMEM;
+ }
+
+ path_kill_slashes(s->path);
+
+ s->type = b;
+ s->inotify_fd = -1;
+
+ LIST_PREPEND(PathSpec, spec, p->specs, s);
+
+ return 0;
+}
+
+static int config_parse_path_unit(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ Path *t = data;
+ int r;
+ DBusError error;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ dbus_error_init(&error);
+
+ if (endswith(rvalue, ".path")) {
+ log_error("[%s:%u] Unit cannot be of type path: %s", filename, line, rvalue);
+ return -EINVAL;
+ }
+
+ if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &error, &t->unit)) < 0) {
+ log_error("[%s:%u] Failed to load unit %s: %s", filename, line, rvalue, bus_error(&error, r));
+ dbus_error_free(&error);
+ return r;
+ }
+
+ return 0;
+}
+
+static int config_parse_env_file(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ FILE *f;
+ int r;
+ char ***env = data;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if (!(f = fopen(rvalue, "re"))) {
+ log_error("[%s:%u] Failed to open environment file '%s': %m", filename, line, rvalue);
+ return -errno;
+ }
+
+ while (!feof(f)) {
+ char l[LINE_MAX], *p;
+ char **t;
+
+ if (!fgets(l, sizeof(l), f)) {
+ if (feof(f))
+ break;
+
+ r = -errno;
+ log_error("[%s:%u] Failed to read environment file '%s': %m", filename, line, rvalue);
+ goto finish;
+ }
+
+ p = strstrip(l);
+
+ if (!*p)
+ continue;
+
+ if (strchr(COMMENTS, *p))
+ continue;
+
+ t = strv_env_set(*env, p);
+ strv_free(*env);
+ *env = t;
+ }
+
+ r = 0;
+
+finish:
+ if (f)
+ fclose(f);
+
+ return r;
+}
+
+static int config_parse_ip_tos(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ int *ip_tos = data, x;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ if ((x = ip_tos_from_string(rvalue)) < 0)
+ if ((r = safe_atoi(rvalue, &x)) < 0) {
+ log_error("[%s:%u] Failed to parse IP TOS value: %s", filename, line, rvalue);
+ return r;
+ }
+
+ *ip_tos = x;
+ return 0;
+}
+
+static DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier");
+