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 {
46 typedef enum NameDependency {
47 /* Positive dependencies */
53 NAME_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */
54 NAME_WANTED_BY, /* inverse of 'wants', 'soft_requires' and 'soft_requisite' is 'wanted_by' */
56 /* Negative dependencies */
57 NAME_CONFLICTS, /* inverse of 'conflicts' is 'conflicts' */
60 NAME_BEFORE, /* inverse of before is after and vice versa */
71 Set *dependencies[_NAME_DEPENDENCY_MAX];
75 /* If there is something to do with this name, then this is
85 typedef enum ServiceState {
104 typedef enum ServiceMode {
116 typedef enum TimerState {
140 typedef enum SocketState {
164 typedef enum MilestoneState {
173 MilestoneState state;
176 typedef enum DeviceState {
189 typedef enum MountState {
202 typedef enum AutomountState {
207 AUTOMOUNT_START_POST,
213 AUTOMOUNT_MAINTAINANCE
219 AutomountState state;
224 typedef enum SnapshotState {
249 /* For casting a name into the various name types */
251 #define DEFINE_CAST(UPPERCASE, MixedCase, lowercase) \
252 static inline MixedCase* UPPERCASE(Name *name) { \
253 if (name->meta.type != NAME_##UPPERCASE) \
256 return &name->lowercase; \
259 DEFINE_CAST(SERVICE, Service, service);
260 DEFINE_CAST(TIMER, Timer, timer);
261 DEFINE_CAST(SOCKET, Socket, socket);
262 DEFINE_CAST(MILESTONE, Milestone, milestone);
263 DEFINE_CAST(DEVICE, Device, device);
264 DEFINE_CAST(MOUNT, Mount, mount);
265 DEFINE_CAST(AUTOMOUNT, Automount, automount);
266 DEFINE_CAST(SNAPSHOT, Snapshot, snapshot);
268 /* For casting the various name types into a name */
269 #define NAME(o) ((Name*) (o))
271 bool name_is_ready(Name *name);
272 NameType name_type_from_string(const char *n);
273 bool name_is_valid(const char *n);
275 Name *name_new(Manager *m);
276 void name_free(Name *name);
277 int name_link(Name *name);
278 int name_merge(Name *name, Name *other);
279 int name_augment(Name *n);
280 const char* name_id(Name *n);
282 void name_dump(Name *n, FILE *f);