chiark / gitweb /
7f591974de03cbe0e4c28be8d4df8c40b0f6234c
[elogind.git] / src / core / busname.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2013 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 typedef struct BusName BusName;
25 typedef struct BusNamePolicy BusNamePolicy;
26
27 #include "unit.h"
28
29 typedef enum BusNameState {
30         BUSNAME_DEAD,
31         BUSNAME_LISTENING,
32         BUSNAME_RUNNING,
33         BUSNAME_FAILED,
34         _BUSNAME_STATE_MAX,
35         _BUSNAME_STATE_INVALID = -1
36 } BusNameState;
37
38 typedef enum BusNameResult {
39         BUSNAME_SUCCESS,
40         BUSNAME_FAILURE_RESOURCES,
41         BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT,
42         _BUSNAME_RESULT_MAX,
43         _BUSNAME_RESULT_INVALID = -1
44 } BusNameResult;
45
46 struct BusName {
47         Unit meta;
48
49         char *name;
50         int starter_fd;
51
52         UnitRef service;
53
54         BusNameState state, deserialized_state;
55         BusNameResult result;
56
57         sd_event_source *event_source;
58
59         bool accept_fd;
60
61         LIST_HEAD(BusNamePolicy, policy);
62 };
63
64 typedef enum BusNamePolicyType {
65         BUSNAME_POLICY_TYPE_USER,
66         BUSNAME_POLICY_TYPE_GROUP,
67         BUSNAME_POLICY_TYPE_WORLD,
68         _BUSNAME_POLICY_TYPE_MAX,
69         _BUSNAME_POLICY_TYPE_INVALID = -1
70 } BusNamePolicyType;
71
72 typedef enum BusNamePolicyAccess {
73         BUSNAME_POLICY_ACCESS_SEE,
74         BUSNAME_POLICY_ACCESS_TALK,
75         BUSNAME_POLICY_ACCESS_OWN,
76         _BUSNAME_POLICY_ACCESS_MAX,
77         _BUSNAME_POLICY_ACCESS_INVALID = -1
78 } BusNamePolicyAccess;
79
80 struct BusNamePolicy {
81         BusNamePolicyType type;
82         BusNamePolicyAccess access;
83
84         union {
85                 uid_t uid;
86                 gid_t gid;
87         };
88
89         LIST_FIELDS(BusNamePolicy, policy);
90 };
91
92 extern const UnitVTable busname_vtable;
93
94 const char* busname_state_to_string(BusNameState i) _const_;
95 BusNameState busname_state_from_string(const char *s) _pure_;
96
97 const char* busname_result_to_string(BusNameResult i) _const_;
98 BusNameResult busname_result_from_string(const char *s) _pure_;
99
100 const char* busname_policy_access_to_string(BusNamePolicyAccess i) _const_;
101 BusNamePolicyAccess busname_policy_access_from_string(const char *s) _pure_;