diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/bus-common.c | 35 | ||||
-rw-r--r-- | src/core/bus-common.h | 35 | ||||
-rw-r--r-- | src/core/busname.c | 8 | ||||
-rw-r--r-- | src/core/busname.h | 16 | ||||
-rw-r--r-- | src/core/load-fragment.c | 4 |
5 files changed, 75 insertions, 23 deletions
diff --git a/src/core/bus-common.c b/src/core/bus-common.c new file mode 100644 index 0000000000..4a61cb9a3a --- /dev/null +++ b/src/core/bus-common.c @@ -0,0 +1,35 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2014 Daniel Mack + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +#include "special.h" +#include "bus-kernel.h" +#include "bus-internal.h" +#include "bus-util.h" +#include "service.h" +#include "bus-common.h" + +static const char* const bus_policy_access_table[_BUS_POLICY_ACCESS_MAX] = { + [BUS_POLICY_ACCESS_SEE] = "see", + [BUS_POLICY_ACCESS_TALK] = "talk", + [BUS_POLICY_ACCESS_OWN] = "own", +}; + +DEFINE_STRING_TABLE_LOOKUP(bus_policy_access, BusPolicyAccess); diff --git a/src/core/bus-common.h b/src/core/bus-common.h new file mode 100644 index 0000000000..209f870c72 --- /dev/null +++ b/src/core/bus-common.h @@ -0,0 +1,35 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +#include "macro.h" + +/*** + This file is part of systemd. + + Copyright 2014 Daniel Mack + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +typedef enum BusPolicyAccess { + BUS_POLICY_ACCESS_SEE, + BUS_POLICY_ACCESS_TALK, + BUS_POLICY_ACCESS_OWN, + _BUS_POLICY_ACCESS_MAX, + _BUS_POLICY_ACCESS_INVALID = -1 +} BusPolicyAccess; + +const char* bus_policy_access_to_string(BusPolicyAccess i) _const_; +BusPolicyAccess bus_policy_access_from_string(const char *s) _pure_; diff --git a/src/core/busname.c b/src/core/busname.c index 39ea6a0d93..22d2a6d24b 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -911,14 +911,6 @@ static const char* const busname_result_table[_BUSNAME_RESULT_MAX] = { DEFINE_STRING_TABLE_LOOKUP(busname_result, BusNameResult); -static const char* const busname_policy_access_table[_BUSNAME_POLICY_ACCESS_MAX] = { - [BUSNAME_POLICY_ACCESS_SEE] = "see", - [BUSNAME_POLICY_ACCESS_TALK] = "talk", - [BUSNAME_POLICY_ACCESS_OWN] = "own", -}; - -DEFINE_STRING_TABLE_LOOKUP(busname_policy_access, BusNamePolicyAccess); - const UnitVTable busname_vtable = { .object_size = sizeof(BusName), diff --git a/src/core/busname.h b/src/core/busname.h index 65d57f710a..c9b653d82e 100644 --- a/src/core/busname.h +++ b/src/core/busname.h @@ -25,6 +25,7 @@ typedef struct BusName BusName; typedef struct BusNamePolicy BusNamePolicy; #include "unit.h" +#include "bus-common.h" typedef enum BusNameState { BUSNAME_DEAD, @@ -58,17 +59,9 @@ typedef enum BusNamePolicyType { _BUSNAME_POLICY_TYPE_INVALID = -1 } BusNamePolicyType; -typedef enum BusNamePolicyAccess { - BUSNAME_POLICY_ACCESS_SEE, - BUSNAME_POLICY_ACCESS_TALK, - BUSNAME_POLICY_ACCESS_OWN, - _BUSNAME_POLICY_ACCESS_MAX, - _BUSNAME_POLICY_ACCESS_INVALID = -1 -} BusNamePolicyAccess; - struct BusNamePolicy { BusNamePolicyType type; - BusNamePolicyAccess access; + BusPolicyAccess access; char *name; @@ -97,7 +90,7 @@ struct BusName { pid_t control_pid; LIST_HEAD(BusNamePolicy, policy); - BusNamePolicyAccess policy_world; + BusPolicyAccess policy_world; }; extern const UnitVTable busname_vtable; @@ -107,6 +100,3 @@ BusNameState busname_state_from_string(const char *s) _pure_; const char* busname_result_to_string(BusNameResult i) _const_; BusNameResult busname_result_from_string(const char *s) _pure_; - -const char* busname_policy_access_to_string(BusNamePolicyAccess i) _const_; -BusNamePolicyAccess busname_policy_access_from_string(const char *s) _pure_; diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index fda27becb5..b4da6a550e 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -1686,7 +1686,7 @@ int config_parse_busname_service( return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_bus_policy_world, busname_policy_access, BusNamePolicyAccess, "Failed to parse bus name policy access"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bus_policy_world, bus_policy_access, BusPolicyAccess, "Failed to parse bus name policy access"); int config_parse_bus_policy( const char *unit, @@ -1736,7 +1736,7 @@ int config_parse_bus_policy( access_str++; access_str += strspn(access_str, WHITESPACE); - p->access = busname_policy_access_from_string(access_str); + p->access = bus_policy_access_from_string(access_str); if (p->access < 0) { log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid busname policy access type '%s'", access_str); |