From dbe89195b258c1101b5dd37dfbf5f0d71c25e0fa Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 13 May 2020 19:13:04 +0200 Subject: initd: split configuration handling into "config.c" This commit splits off only the handling of the service configuration and handling of the run time state and adds an abstraction layer in the form of functions that have to be called to access the data. Signed-off-by: David Oberhollenzer --- initd/init.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'initd/init.h') diff --git a/initd/init.h b/initd/init.h index 2c2adb1..813dedb 100644 --- a/initd/init.h +++ b/initd/init.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -54,4 +55,43 @@ typedef struct { */ pid_t runsvc(service_t *svc); +/********** config.c **********/ + +/* load persistent configuration from disk */ +int config_load(void); + +svc_run_data_t *config_rt_data_by_pid(pid_t pid); + +/* + Get the next service that is waiting to be launched. Returns NULL if + the queue is empty. + */ +svc_run_data_t *config_dequeue(void); + +/* + Transition to a different target, if possible in the current state. + + The transition may be ignored, e.g. if we are currently in the reboot + or shutdown target. + */ +void config_set_target(int tgt); + +/* get the current run time target from the configuration manager */ +int config_get_current_target(void); + +/* + Find out if the current target is completed, i.e. there are no more services + left in the queue and no active single shot services. + */ +bool config_is_current_target_complete(void); + +/* Ask whether we should respawn services in the current target */ +bool config_should_respawn(void); + +/* notify the configuration manager that a single shot service started */ +void config_singleshot_started(void); + +/* notify the configuration manager that a single shot service terminated */ +void config_singleshot_terminated(void); + #endif /* INIT_H */ -- cgit v1.2.3