summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-03-28 01:50:36 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-03-28 01:50:36 +0000
commite2959c22c7309836d6f5dba2f0db7b293b860ad8 (patch)
treea26cefd2a36f6682e302bed8840642da0c6c64a8 /src/include
parentba3bcbb86ea0177349bcd021559347248d6ab10a (diff)
downloads6-rc-e2959c22c7309836d6f5dba2f0db7b293b860ad8.tar.xz
A few pieces of the future s6-rcd server
Diffstat (limited to 'src/include')
-rw-r--r--src/include/s6-rc/connection.h13
-rw-r--r--src/include/s6-rc/event.h31
-rw-r--r--src/include/s6-rc/s6rc-constants.h14
-rw-r--r--src/include/s6-rc/s6rc-db.h76
-rw-r--r--src/include/s6-rc/s6rc-servicedir.h18
-rw-r--r--src/include/s6-rc/s6rc-utils.h19
-rw-r--r--src/include/s6-rc/s6rc.h11
7 files changed, 43 insertions, 139 deletions
diff --git a/src/include/s6-rc/connection.h b/src/include/s6-rc/connection.h
index f6d5eda..b02c96f 100644
--- a/src/include/s6-rc/connection.h
+++ b/src/include/s6-rc/connection.h
@@ -8,9 +8,20 @@
#include <s6-rc/connection-common.h>
+#define S6RC_MONITOR_BUFSIZE S6RC_CONNECTION_BUFSIZE
+
+typedef struct s6rc_monitor_s s6rc_monitor_t, *s6rc_monitor_t_ref ;
+struct s6rc_monitor_s
+{
+ textmessage_receiver_t in ;
+ char inbuf[S6RC_MONITOR_BUFSIZE] ;
+}
+#define S6RC_MONITOR_ZERO { .in = TEXTMESSAGE_RECEIVER_ZERO, .inbuf = "" }
+
+extern void s6rc_connection_end (s6rc_connection_t *) ;
extern int s6rc_connection_start (s6rc_connection_t *, char const *, tain_t const *, tain_t *) ;
#define s6rc_connection_start_g(path, deadline) s6rc_connection_start(path, (deadline), &STAMP)
-extern void s6rc_connection_end (s6rc_connection_t *) ;
+extern int s6rc_monitor (s6rc_connection_t *, s6rc_monitor_t *, tain_t const *, tain_t *) ;
#endif
diff --git a/src/include/s6-rc/event.h b/src/include/s6-rc/event.h
new file mode 100644
index 0000000..fe944e7
--- /dev/null
+++ b/src/include/s6-rc/event.h
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+#ifndef S6RC_EVENT_H
+#define S6RC_EVENT_H
+
+#include <stdint.h>
+
+typedef enum s6rc_eventtype_e s6rc_eventtype_t, *s6rc_eventtype_t_ref ;
+enum s6rc_eventtype_e
+{
+ S6RC_EVENTTYPE_WANTED_STATE_DOWN,
+ S6RC_EVENTTYPE_WANTED_STATE_UP,
+ S6RC_EVENTTYPE_CURRENT_STATE_DOWN,
+ S6RC_EVENTTYPE_CURRENT_STATE_UP,
+ S6RC_EVENTTYPE_TRANSITION_STOP,
+ S6RC_EVENTTYPE_TRANSITION_START,
+ S6RC_EVENTTYPE_CUSTOM, /* for misc events from other processes */
+ S6RC_EVENTTYPE_PHAIL
+} ;
+
+typedef struct s6rc_event_s s6rc_event_t, *s6rc_event_t_ref ;
+struct s6rc_event_s
+{
+ char const *name ;
+ uint32_t value ;
+ uint8_t type : 3 ;
+ uint8_t extra : 5 ;
+} ;
+#define S6RC_EVENT_ZERO { .name = 0, .value = 0, .type = S6RC_EVENTTYPE_PHAIL, .extra = 0 }
+
+#endif
diff --git a/src/include/s6-rc/s6rc-constants.h b/src/include/s6-rc/s6rc-constants.h
deleted file mode 100644
index 168dac8..0000000
--- a/src/include/s6-rc/s6rc-constants.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ISC license. */
-
-#ifndef S6RC_CONSTANTS_H
-#define S6RC_CONSTANTS_H
-
-#define S6RC_COMPILED_BASE "/etc/s6-rc/compiled"
-
-#define S6RC_ONESHOT_RUNNER "s6rc-oneshot-runner"
-#define S6RC_ONESHOT_RUNNER_LEN (sizeof S6RC_ONESHOT_RUNNER - 1)
-
-#define S6RC_FDHOLDER "s6rc-fdholder"
-#define S6RC_FDHOLDER_LEN (sizeof S6RC_FDHOLDER - 1)
-
-#endif
diff --git a/src/include/s6-rc/s6rc-db.h b/src/include/s6-rc/s6rc-db.h
deleted file mode 100644
index 0f03967..0000000
--- a/src/include/s6-rc/s6rc-db.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ISC license. */
-
-#ifndef S6RC_DB_H
-#define S6RC_DB_H
-
-#include <stdint.h>
-#include <skalibs/diuint32.h>
-#include <skalibs/buffer.h>
-
-#define S6RC_DB_BANNER_START "s6rc-db: start\n"
-#define S6RC_DB_BANNER_START_LEN (sizeof(S6RC_DB_BANNER_START) - 1)
-#define S6RC_DB_BANNER_END "\ns6rc-db: end\n"
-#define S6RC_DB_BANNER_END_LEN (sizeof(S6RC_DB_BANNER_END) - 1)
-
-#define S6RC_DB_FLAG_ESSENTIAL 0x00000001U
-
-
-typedef struct s6rc_oneshot_s s6rc_oneshot_t, *s6rc_oneshot_t_ref ;
-struct s6rc_oneshot_s
-{
- uint32_t argc[2] ;
- uint32_t argv[2] ;
-} ;
-
-typedef struct s6rc_longrun_s s6rc_longrun_t, *s6rc_longrun_t_ref ;
-struct s6rc_longrun_s
-{
- uint32_t consumer ;
- uint32_t nproducers ;
- uint32_t producers ;
-} ;
-
-typedef union s6rc_longshot_u s6rc_longshot_t, *s6rc_longshot_t_ref ;
-union s6rc_longshot_u
-{
- s6rc_oneshot_t oneshot ;
- s6rc_longrun_t longrun ;
-} ;
-
-typedef struct s6rc_service_s s6rc_service_t, *s6rc_service_t_ref ;
-struct s6rc_service_s
-{
- uint32_t name ;
- uint32_t flags ;
- uint32_t deps[2] ;
- uint32_t ndeps[2] ;
- uint32_t timeout[2] ;
- s6rc_longshot_t x ;
-} ;
-
-typedef struct s6rc_db_s s6rc_db_t, *s6rc_db_t_ref ;
-struct s6rc_db_s
-{
- s6rc_service_t *services ;
- unsigned int nshort ;
- unsigned int nlong ;
- unsigned int stringlen ;
- unsigned int nargvs ;
- unsigned int ndeps ;
- unsigned int nproducers ;
- char *string ;
- char const **argvs ;
- uint32_t *deps ;
- uint32_t *producers ;
-} ;
-
-extern int s6rc_db_read_uint32 (buffer *, uint32_t *) ;
-
-extern int s6rc_db_read_sizes (int, s6rc_db_t *) ;
-extern int s6rc_db_read (int, s6rc_db_t *) ;
-
-extern int s6rc_db_check_pipelines (s6rc_db_t const *, diuint32 *) ;
-extern int s6rc_db_check_depcycles (s6rc_db_t const *, int, diuint32 *) ;
-extern int s6rc_db_check_revdeps (s6rc_db_t const *) ;
-
-#endif
diff --git a/src/include/s6-rc/s6rc-servicedir.h b/src/include/s6-rc/s6rc-servicedir.h
deleted file mode 100644
index 1648975..0000000
--- a/src/include/s6-rc/s6rc-servicedir.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* ISC license. */
-
-#ifndef S6RC_SERVICEDIR_H
-#define S6RC_SERVICEDIR_H
-
-#include <skalibs/tai.h>
-
-extern int s6rc_servicedir_block (char const *) ;
-extern int s6rc_servicedir_unblock (char const *, int) ;
-extern int s6rc_servicedir_copy_offline (char const *, char const *) ;
-extern int s6rc_servicedir_copy_online (char const *, char const *) ;
-#define s6rc_servicedir_copy(src, dst, h) ((h) ? s6rc_servicedir_copy_online(src, dst) : s6rc_servicedir_copy_offline(src, dst))
-extern void s6rc_servicedir_unsupervise (char const *, char const *, char const *, int) ;
-
-extern int s6rc_servicedir_manage (char const *, char const *, tain_t const *, tain_t *) ;
-#define s6rc_servicedir_manage_g(live, suffix, deadline) s6rc_servicedir_manage(live, suffix, (deadline), &STAMP)
-
-#endif
diff --git a/src/include/s6-rc/s6rc-utils.h b/src/include/s6-rc/s6rc-utils.h
deleted file mode 100644
index 8f67920..0000000
--- a/src/include/s6-rc/s6rc-utils.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* ISC license. */
-
-#ifndef S6RC_UTILS_H
-#define S6RC_UTILS_H
-
-#include <sys/types.h>
-#include <skalibs/stralloc.h>
-#include <s6-rc/s6rc-db.h>
-
-extern void s6rc_graph_closure (s6rc_db_t const *, unsigned char *, unsigned int, int) ;
-extern int s6rc_lock (char const *, int, int *, char const *, int, int *, int) ;
-extern int s6rc_read_uint (char const *, unsigned int *) ;
-extern int s6rc_sanitize_dir (stralloc *, char const *, size_t *) ;
-
-extern int s6rc_livedir_prefixsize (char const *, size_t *) ;
-extern ssize_t s6rc_livedir_prefix (char const *, char *, size_t) ;
-extern int s6rc_livedir_create (stralloc *, char const *, char const *, char const *, char const *, char const *, unsigned char const *, unsigned int, size_t *) ;
-
-#endif
diff --git a/src/include/s6-rc/s6rc.h b/src/include/s6-rc/s6rc.h
deleted file mode 100644
index 87a87ef..0000000
--- a/src/include/s6-rc/s6rc.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* ISC license. */
-
-#ifndef S6RC_H
-#define S6RC_H
-
-#include <s6-rc/s6rc-constants.h>
-#include <s6-rc/s6rc-db.h>
-#include <s6-rc/s6rc-utils.h>
-#include <s6-rc/s6rc-servicedir.h>
-
-#endif