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;
26 typedef enum NameType {
36 _NAME_TYPE_INVALID = -1,
39 typedef enum NameState {
45 typedef enum NameDependency {
46 /* Positive dependencies */
52 NAME_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */
53 NAME_WANTED_BY, /* inverse of 'wants', 'soft_requires' and 'soft_requisite' is 'wanted_by' */
55 /* Negative dependencies */
56 NAME_CONFLICTS, /* inverse of 'conflicts' is 'conflicts' */
59 NAME_BEFORE, /* inverse of before is after and vice versa */
70 Set *dependencies[_NAME_DEPENDENCY_MAX];
74 /* If there is something to do with this name, then this is
84 typedef enum ServiceState {
103 typedef enum ServiceMode {
115 typedef enum TimerState {
139 typedef enum SocketState {
163 typedef enum MilestoneState {
172 MilestoneState state;
175 typedef enum DeviceState {
188 typedef enum MountState {
201 typedef enum AutomountState {
206 AUTOMOUNT_START_POST,
212 AUTOMOUNT_MAINTAINANCE
218 AutomountState state;
223 typedef enum SnapshotState {
248 /* For casting a name into the various name types */
250 #define DEFINE_CAST(UPPERCASE, MixedCase, lowercase) \
251 static inline MixedCase* UPPERCASE(Name *name) { \
252 if (name->meta.type != NAME_##UPPERCASE) \
255 return &name->lowercase; \
258 DEFINE_CAST(SERVICE, Service, service);
259 DEFINE_CAST(TIMER, Timer, timer);
260 DEFINE_CAST(SOCKET, Socket, socket);
261 DEFINE_CAST(MILESTONE, Milestone, milestone);
262 DEFINE_CAST(DEVICE, Device, device);
263 DEFINE_CAST(MOUNT, Mount, mount);
264 DEFINE_CAST(AUTOMOUNT, Automount, automount);
265 DEFINE_CAST(SNAPSHOT, Snapshot, snapshot);
267 /* For casting the various name types into a name */
268 #define NAME(o) ((Name*) (o))
270 bool name_is_ready(Name *name);
271 NameType name_type_from_string(const char *n);
272 bool name_is_valid(const char *n);
274 Name *name_new(Manager *m);
275 void name_free(Name *name);
276 int name_link(Name *name);
277 int name_merge(Name *name, Name *other);
278 int name_augment(Name *n);