1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
9 typedef union Name Name;
10 typedef struct Meta Meta;
11 typedef struct Service Service;
12 typedef struct Timer Timer;
13 typedef struct Socket Socket;
14 typedef struct Milestone Milestone;
15 typedef struct Device Device;
16 typedef struct Mount Mount;
17 typedef struct Automount Automount;
18 typedef struct Snapshot Snapshot;
25 #include "socket-util.h"
27 typedef enum NameType {
37 _NAME_TYPE_INVALID = -1,
40 typedef enum NameState {
47 typedef enum NameDependency {
48 /* Positive dependencies */
54 NAME_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */
55 NAME_WANTED_BY, /* inverse of 'wants', 'soft_requires' and 'soft_requisite' is 'wanted_by' */
57 /* Negative dependencies */
58 NAME_CONFLICTS, /* inverse of 'conflicts' is 'conflicts' */
61 NAME_BEFORE, /* inverse of before is after and vice versa */
72 Set *dependencies[_NAME_DEPENDENCY_MAX];
76 /* If there is something to do with this name, then this is
86 typedef enum ServiceState {
105 typedef enum ServiceMode {
117 typedef enum TimerState {
140 typedef enum SocketState {
167 typedef enum MilestoneState {
176 MilestoneState state;
179 typedef enum DeviceState {
192 typedef enum MountState {
198 MOUNT_SIGTERM, /* if the mount command hangs */
210 typedef enum AutomountState {
215 AUTOMOUNT_START_POST,
221 AUTOMOUNT_MAINTAINANCE
227 AutomountState state;
232 typedef enum SnapshotState {
257 /* For casting a name into the various name types */
259 #define DEFINE_CAST(UPPERCASE, MixedCase, lowercase) \
260 static inline MixedCase* UPPERCASE(Name *name) { \
261 if (name->meta.type != NAME_##UPPERCASE) \
264 return &name->lowercase; \
267 DEFINE_CAST(SERVICE, Service, service);
268 DEFINE_CAST(TIMER, Timer, timer);
269 DEFINE_CAST(SOCKET, Socket, socket);
270 DEFINE_CAST(MILESTONE, Milestone, milestone);
271 DEFINE_CAST(DEVICE, Device, device);
272 DEFINE_CAST(MOUNT, Mount, mount);
273 DEFINE_CAST(AUTOMOUNT, Automount, automount);
274 DEFINE_CAST(SNAPSHOT, Snapshot, snapshot);
276 /* For casting the various name types into a name */
277 #define NAME(o) ((Name*) (o))
279 bool name_is_running(Name *name);
280 bool name_is_dead(Name *name);
282 NameType name_type_from_string(const char *n);
283 bool name_is_valid(const char *n);
285 Name *name_new(Manager *m);
286 void name_free(Name *name);
287 int name_link(Name *name);
288 int name_link_names(Name *name, bool replace);
289 int name_merge(Name *name, Name *other);
290 int name_sanitize(Name *n);
291 int name_load(Name *name);
292 const char* name_id(Name *n);
294 void name_dump(Name *n, FILE *f, const char *prefix);