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 {
141 typedef enum SocketState {
168 typedef enum MilestoneState {
177 MilestoneState state;
180 typedef enum DeviceState {
193 typedef enum MountState {
206 typedef enum AutomountState {
211 AUTOMOUNT_START_POST,
217 AUTOMOUNT_MAINTAINANCE
223 AutomountState state;
228 typedef enum SnapshotState {
253 /* For casting a name into the various name types */
255 #define DEFINE_CAST(UPPERCASE, MixedCase, lowercase) \
256 static inline MixedCase* UPPERCASE(Name *name) { \
257 if (name->meta.type != NAME_##UPPERCASE) \
260 return &name->lowercase; \
263 DEFINE_CAST(SERVICE, Service, service);
264 DEFINE_CAST(TIMER, Timer, timer);
265 DEFINE_CAST(SOCKET, Socket, socket);
266 DEFINE_CAST(MILESTONE, Milestone, milestone);
267 DEFINE_CAST(DEVICE, Device, device);
268 DEFINE_CAST(MOUNT, Mount, mount);
269 DEFINE_CAST(AUTOMOUNT, Automount, automount);
270 DEFINE_CAST(SNAPSHOT, Snapshot, snapshot);
272 /* For casting the various name types into a name */
273 #define NAME(o) ((Name*) (o))
275 bool name_is_ready(Name *name);
276 NameType name_type_from_string(const char *n);
277 bool name_is_valid(const char *n);
279 Name *name_new(Manager *m);
280 void name_free(Name *name);
281 int name_link(Name *name);
282 int name_link_names(Name *name, bool replace);
283 int name_merge(Name *name, Name *other);
284 int name_sanitize(Name *n);
285 int name_load(Name *name);
286 const char* name_id(Name *n);
288 void name_dump(Name *n, FILE *f, const char *prefix);