chiark / gitweb /
use more _cleanup_ macro
[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_MAKING,
32         BUSNAME_REGISTERED,
33         BUSNAME_LISTENING,
34         BUSNAME_RUNNING,
35         BUSNAME_SIGTERM,
36         BUSNAME_SIGKILL,
37         BUSNAME_FAILED,
38         _BUSNAME_STATE_MAX,
39         _BUSNAME_STATE_INVALID = -1
40 } BusNameState;
41
42 typedef enum BusNameResult {
43         BUSNAME_SUCCESS,
44         BUSNAME_FAILURE_RESOURCES,
45         BUSNAME_FAILURE_TIMEOUT,
46         BUSNAME_FAILURE_EXIT_CODE,
47         BUSNAME_FAILURE_SIGNAL,
48         BUSNAME_FAILURE_CORE_DUMP,
49         BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT,
50         _BUSNAME_RESULT_MAX,
51         _BUSNAME_RESULT_INVALID = -1
52 } BusNameResult;
53
54 typedef enum BusNamePolicyType {
55         BUSNAME_POLICY_TYPE_USER,
56         BUSNAME_POLICY_TYPE_GROUP,
57         _BUSNAME_POLICY_TYPE_MAX,
58         _BUSNAME_POLICY_TYPE_INVALID = -1
59 } BusNamePolicyType;
60
61 typedef enum BusNamePolicyAccess {
62         BUSNAME_POLICY_ACCESS_SEE,
63         BUSNAME_POLICY_ACCESS_TALK,
64         BUSNAME_POLICY_ACCESS_OWN,
65         _BUSNAME_POLICY_ACCESS_MAX,
66         _BUSNAME_POLICY_ACCESS_INVALID = -1
67 } BusNamePolicyAccess;
68
69 struct BusNamePolicy {
70         BusNamePolicyType type;
71         BusNamePolicyAccess access;
72
73         char *name;
74
75         LIST_FIELDS(BusNamePolicy, policy);
76 };
77
78 struct BusName {
79         Unit meta;
80
81         char *name;
82         int starter_fd;
83
84         bool activating;
85         bool accept_fd;
86
87         UnitRef service;
88
89         BusNameState state, deserialized_state;
90         BusNameResult result;
91
92         usec_t timeout_usec;
93
94         sd_event_source *starter_event_source;
95         sd_event_source *timer_event_source;
96
97         pid_t control_pid;
98
99         LIST_HEAD(BusNamePolicy, policy);
100         BusNamePolicyAccess policy_world;
101 };
102
103 extern const UnitVTable busname_vtable;
104
105 const char* busname_state_to_string(BusNameState i) _const_;
106 BusNameState busname_state_from_string(const char *s) _pure_;
107
108 const char* busname_result_to_string(BusNameResult i) _const_;
109 BusNameResult busname_result_from_string(const char *s) _pure_;
110
111 const char* busname_policy_access_to_string(BusNamePolicyAccess i) _const_;
112 BusNamePolicyAccess busname_policy_access_from_string(const char *s) _pure_;