diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-06-28 17:26:47 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2021-06-28 17:26:47 +0000 |
commit | ae1a76cad535a04f0c059e8dae9c8a27a84222a4 (patch) | |
tree | 91648546a5c588a5f0e68ef530d311e594440f4e /src/server/state.h | |
parent | c26824e1f078b8de0d38cb87d3f291235ab5cf76 (diff) | |
download | s6-rc-ae1a76cad535a04f0c059e8dae9c8a27a84222a4.tar.xz |
Some more code around state
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/server/state.h')
-rw-r--r-- | src/server/state.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/server/state.h b/src/server/state.h new file mode 100644 index 0000000..f0149bc --- /dev/null +++ b/src/server/state.h @@ -0,0 +1,45 @@ +/* ISC license. */ + +#ifndef S6RCD_STATE_H +#define S6RCD_STATE_H + +#include <skalibs/genalloc.h> + +#include <s6-rc/db.h> + + + /* Service states, instances, machine state */ + +typedef struct stateatom_s stateatom_t, *stateatom_t_ref ; +struct stateatom_s +{ + uint8_t wanted : 1 ; + uint8_t current : 1 ; + uint8_t transitioning : 1 ; +} ; + +typedef struct instance_s instance_t, *instance_t_ref ; +struct instance_s +{ + char const *param ; + stateatom_t state ; +} ; + +typedef struct state_s state_t, *state_t_ref ; +struct state_s +{ + stateatom_t *sta[S6RC_STYPE_PHAIL] ; + genalloc *dyn[S6RC_STYPE_PHAIL] ; /* every genalloc is a list of instance_t */ +} ; + +extern void state_free (state_t *, uint32_t const *) ; +extern int state_ready (state_t *, uint32_t const *) ; + +extern int state_write (char const *, state_t const *, uint32_t const *) ; +extern int state_read (char const *, state_t *, uint32_t const *) ; + + +extern stateatom_t *state_atom (s6rc_db_t const *, state_t const *, s6rc_sid_t const *) ; + + +#endif |