summaryrefslogtreecommitdiff
path: root/src/include-local/db.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include-local/db.h')
-rw-r--r--src/include-local/db.h85
1 files changed, 36 insertions, 49 deletions
diff --git a/src/include-local/db.h b/src/include-local/db.h
index a937e7a..be7ef20 100644
--- a/src/include-local/db.h
+++ b/src/include-local/db.h
@@ -5,46 +5,33 @@
#include <stdint.h>
+#include <skalibs/cdb.h>
- /* Service types and db representation in memory */
-
-#define S6RC_INSTANCES_MAX 0xffffffU
-#define S6RC_INSTANCEPARAM_MAXLEN 0xffffffU
+#define S6RC_ARGV_MAX 0x00ffffffu
+#define S6RC_INSTANCES_MAX 0x00ffffffu
+#define S6RC_INSTANCEPARAM_MAXLEN 0x00ffffffu
-typedef enum s6rc_stype_e s6rc_stype_t, *s6rc_stype_t_ref ;
-enum s6rc_stype_e
-{
- S6RC_STYPE_LONGRUN,
- S6RC_STYPE_ONESHOT,
- S6RC_STYPE_EXTERNAL,
- S6RC_STYPE_BUNDLE,
- S6RC_STYPE_VIRTUAL,
- S6RC_STYPE_PHAIL
-} ;
+ /* Service types and db representation in memory */
+#define S6RC_STYPE_LONGRUN 0
+#define S6RC_STYPE_ONESHOT 1
+#define S6RC_STYPE_EXTERNAL 2
+#define S6RC_STYPE_BUNDLE 3
+#define S6RC_STYPE_VIRTUAL 4
+#define S6RC_STYPE_N 5
-typedef struct s6rc_baseid_s s6rc_baseid_t, *s6rc_baseid_t_ref ;
-struct s6rc_baseid_s
-{
- uint32_t i ;
- s6rc_stype_t stype ;
-} ;
+typedef uint32_t s6rc_id_t, *s6rc_id_t_ref ;
-typedef struct s6rc_id_s s6rc_id_t, *s6rc_id_t_ref ;
-struct s6rc_id_s
-{
- char const *param ;
- s6rc_baseid_t baseid ;
-} ;
+#define stype(sid) ((sid) >> 28)
+#define snum(sid) ((sid) & 0x0fffffffu)
typedef struct s6rc_common_s s6rc_common_t, *s6rc_common_t_ref ;
struct s6rc_common_s
{
uint32_t name ;
+ uint32_t flags ;
uint32_t deps[2] ;
uint32_t ndeps[2] ;
- uint32_t flag_essential : 1 ;
- uint32_t flags : 31 ;
} ;
typedef struct s6rc_atomic_s s6rc_atomic_t, *s6rc_atomic_t_ref ;
@@ -58,7 +45,6 @@ typedef struct s6rc_oneshot_s s6rc_oneshot_t, *s6rc_oneshot_t_ref ;
struct s6rc_oneshot_s
{
s6rc_atomic_t satomic ;
- uint32_t argc[2] ;
uint32_t argv[2] ;
} ;
@@ -66,9 +52,9 @@ typedef struct s6rc_longrun_s s6rc_longrun_t, *s6rc_longrun_t_ref ;
struct s6rc_longrun_s
{
s6rc_atomic_t satomic ;
- s6rc_sid_t consumer ;
uint32_t nproducers ;
uint32_t producers ;
+ s6rc_id_t consumer ;
} ;
typedef struct s6rc_external_s s6rc_external_t, *s6rc_external_t_ref ;
@@ -85,30 +71,31 @@ struct s6rc_bundle_s
uint32_t contents ;
} ;
-typedef struct s6rc_deptype_s s6rc_deptype_t, *s6rc_deptype_t_ref ;
-struct s6rc_deptype_s
-{
- uint8_t passive : 1 ;
- uint8_t soft : 1 ;
- uint8_t loose : 1 ;
-} ;
+#define s6rc_deptype_passive(dep) ((dep) & 0x01u)
+#define s6rc_deptype_soft(dep) ((dep) & 0x02u)
+#define s6rc_deptype_loose(dep) ((dep) & 0x04u)
typedef struct s6rc_db_s s6rc_db_t, *s6rc_db_t_ref ;
struct s6rc_db_s
{
- uint32_t n[STYPE_PHAIL << 1] ;
- s6rc_longrun_t *longruns ;
- s6rc_oneshot_t *oneshots ;
- s6rc_external_t *externals ;
- s6rc_bundle_t *bundles ;
- s6rc_bundle_t *virtuals ;
- s6rc_baseid_t *deps[2] ;
- s6rc_deptype_t *deptypes[2] ;
- s6rc_baseid_t *producers ;
- char const **argvs ;
- char *storage ;
+ char const *map ;
+ size_t size ;
+ uint32_t const *n ;
+ s6rc_longrun_t const *longruns ;
+ s6rc_oneshot_t const *oneshots ;
+ s6rc_external_t const *externals ;
+ s6rc_bundle_t const *bundles ;
+ s6rc_bundle_t const *virtuals ;
+ s6rc_id_t const *deps[2] ;
+ uint8_t const *deptypes[2] ;
+ s6rc_id_t const *producers ;
+ char const *storage ;
+ char const **argvs ; /* alloced */
} ;
+#define S6RC_DB_ZERO = { .map = 0, .len = 0 }
+
-extern s6rc_common_t const *s6rc_service_common (s6rc_db_t const *, s6rc_sid_t const *) ;
+extern int s6rc_service_resolve (cdb_t *, char const *, s6rc_id_t *, char const **) ;
+extern s6rc_common_t const *s6rc_service_common (s6rc_db_t const *, s6rc_id_t const *) ;
#endif