1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
9 typedef union Name Name
;
10 typedef struct Meta Meta
;
11 typedef struct NameVTable NameVTable
;
12 typedef enum NameType NameType
;
13 typedef enum NameLoadState NameLoadState
;
14 typedef enum NameActiveState NameActiveState
;
15 typedef enum NameDependency NameDependency
;
22 #include "socket-util.h"
37 _NAME_TYPE_INVALID
= -1,
47 enum NameActiveState
{
49 NAME_ACTIVE_RELOADING
,
53 _NAME_ACTIVE_STATE_MAX
56 static inline bool NAME_IS_ACTIVE_OR_RELOADING(NameActiveState t
) {
57 return t
== NAME_ACTIVE
|| t
== NAME_ACTIVE_RELOADING
;
60 static inline bool NAME_IS_ACTIVE_OR_ACTIVATING(NameActiveState t
) {
61 return t
== NAME_ACTIVE
|| t
== NAME_ACTIVATING
|| t
== NAME_ACTIVE_RELOADING
;
64 static inline bool NAME_IS_INACTIVE_OR_DEACTIVATING(NameActiveState t
) {
65 return t
== NAME_INACTIVE
|| t
== NAME_DEACTIVATING
;
69 /* Positive dependencies */
75 NAME_REQUIRED_BY
, /* inverse of 'requires' and 'requisite' is 'required_by' */
76 NAME_SOFT_REQUIRED_BY
, /* inverse of 'soft_requires' and 'soft_requisite' is 'soft_required_by' */
77 NAME_WANTED_BY
, /* inverse of 'wants' */
79 /* Negative dependencies */
80 NAME_CONFLICTS
, /* inverse of 'conflicts' is 'conflicts' */
83 NAME_BEFORE
, /* inverse of before is after and vice versa */
91 NameLoadState load_state
;
94 Set
*dependencies
[_NAME_DEPENDENCY_MAX
];
98 /* If there is something to do with this name, then this is
111 #include "milestone.h"
114 #include "automount.h"
115 #include "snapshot.h"
132 int (*load
)(Name
*n
);
133 void (*dump
)(Name
*n
, FILE *f
, const char *prefix
);
135 int (*start
)(Name
*n
);
136 int (*stop
)(Name
*n
);
137 int (*reload
)(Name
*n
);
139 /* Boils down the more complex internal state of this name to
140 * a simpler one that the engine can understand */
141 NameActiveState (*active_state
)(Name
*n
);
143 void (*free_hook
)(Name
*n
);
146 /* For casting a name into the various name types */
147 #define DEFINE_CAST(UPPERCASE, MixedCase) \
148 static inline MixedCase* UPPERCASE(Name *name) { \
149 if (!name || name->meta.type != NAME_##UPPERCASE) \
152 return (MixedCase*) name; \
155 /* For casting the various name types into a name */
156 #define NAME(o) ((Name*) (o))
158 DEFINE_CAST(SOCKET
, Socket
);
159 DEFINE_CAST(TIMER
, Timer
);
160 DEFINE_CAST(SERVICE
, Service
);
161 DEFINE_CAST(MILESTONE
, Milestone
);
162 DEFINE_CAST(DEVICE
, Device
);
163 DEFINE_CAST(MOUNT
, Mount
);
164 DEFINE_CAST(AUTOMOUNT
, Automount
);
165 DEFINE_CAST(SNAPSHOT
, Snapshot
);
167 NameActiveState
name_active_state(Name
*name
);
169 bool name_type_can_start(NameType t
);
170 bool name_type_can_reload(NameType t
);
172 NameType
name_type_from_string(const char *n
);
173 bool name_is_valid(const char *n
);
175 Name
*name_new(Manager
*m
);
176 void name_free(Name
*name
);
177 int name_link(Name
*name
);
178 int name_link_names(Name
*name
, bool replace
);
179 int name_merge(Name
*name
, Name
*other
);
180 int name_sanitize(Name
*n
);
181 int name_load_fragment_and_dropin(Name
*n
);
182 int name_load(Name
*name
);
183 const char* name_id(Name
*n
);
184 const char *name_description(Name
*n
);
186 void name_dump(Name
*n
, FILE *f
, const char *prefix
);
188 int name_start(Name
*n
);
189 int name_stop(Name
*n
);
190 int name_reload(Name
*n
);
192 int name_notify(Name
*n
, NameActiveState old
, NameActiveState
new);