diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-03-18 12:23:41 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-03-18 12:23:41 +0000 |
| commit | e296c0405b813f4d19ae7efaf6eb1b4117b1e333 (patch) | |
| tree | f3aa5282f817b68471d93e9f7be2b40500e52c68 /src/include | |
| parent | 9e63925306dd86243c13becd93ab6d211c9b5010 (diff) | |
| parent | 6a00734ff583507e906ded535eb6ac6a01a2ecec (diff) | |
| download | s6-e296c0405b813f4d19ae7efaf6eb1b4117b1e333.tar.gz | |
Merge branch '2.15.0.0'
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/s6/ftrigr.h | 103 |
1 files changed, 28 insertions, 75 deletions
diff --git a/src/include/s6/ftrigr.h b/src/include/s6/ftrigr.h index a7b8f3d..2e0f340 100644 --- a/src/include/s6/ftrigr.h +++ b/src/include/s6/ftrigr.h @@ -1,99 +1,52 @@ /* ISC license. */ -#ifndef FTRIGR_H -#define FTRIGR_H +#ifndef S6_FTRIGR_H +#define S6_FTRIGR_H -#include <sys/types.h> #include <stdint.h> -#include <skalibs/config.h> #include <skalibs/tai.h> -#include <skalibs/stralloc.h> #include <skalibs/genalloc.h> -#include <skalibs/gensetdyn.h> -#include <skalibs/textclient.h> +#include <skalibs/sass.h> +#include <skalibs/sassclient.h> -#include <s6/config.h> +#define FTRIGR_REPEAT SASS_FLAG_KEEP - - /* Constants */ - -#define FTRIGR_IPCPATH SKALIBS_SPROOT "/run/service/ftrigrd/s" - -#define FTRIGRD_PROG S6_EXTBINPREFIX "s6-ftrigrd" -#define FTRIGR_BANNER1 "ftrigr v1.0 (b)\n" -#define FTRIGR_BANNER1_LEN (sizeof FTRIGR_BANNER1 - 1) -#define FTRIGR_BANNER2 "ftrigr v1.0 (a)\n" -#define FTRIGR_BANNER2_LEN (sizeof FTRIGR_BANNER2 - 1) - - - /* Internals of the ftrigr_t */ - -typedef enum fr1state_e fr1state_t, *fr1state_t_ref ; -enum fr1state_e -{ - FR1STATE_WAITACK, - FR1STATE_WAITACKDATA, - FR1STATE_LISTENING, - FR1STATE_ERROR -} ; - -typedef struct ftrigr1_s ftrigr1_t, *ftrigr1_t_ref ; -struct ftrigr1_s +typedef struct ftrigr_s ftrigr, *ftrigr_ref ; +struct ftrigr_s { - uint32_t options ; - fr1state_t state ; - stralloc what ; + sassclient client ; + genalloc data ; /* ftrigr_data */ } ; -#define FTRIGR1_ZERO { .options = 0, .state = FR1STATE_ERROR, .what = STRALLOC_ZERO } -extern ftrigr1_t const ftrigr1_zero ; +#define FTRIGR_ZERO { .client = SASSCLIENT_ZERO, .data = GENALLOC_ZERO } - - /* The ftrigr_t itself */ - -typedef struct ftrigr_s ftrigr, ftrigr_t, *ftrigr_ref, *ftrigr_t_ref ; -struct ftrigr_s +typedef struct ftrigr_string_s ftrigr_string, *ftrigr_string_ref ; +struct ftrigr_string_s { - textclient connection ; - genalloc list ; /* array of uint16_t */ - size_t head ; - gensetdyn data ; /* set of ftrigr1_t */ + char *s ; + uint32_t len ; } ; -#define FTRIGR_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .head = 0, .data = GENSETDYN_INIT(ftrigr1_t, 2, 0, 1) } -extern ftrigr_t const ftrigr_zero ; - - /* Starting and ending a session */ - -extern int ftrigr_start (ftrigr_t *, char const *, tain const *, tain *) ; -#define ftrigr_start_g(a, path, deadline) ftrigr_start(a, path, (deadline), &STAMP) -extern int ftrigr_startf (ftrigr_t *, tain const *, tain *) ; +extern int ftrigr_startf (ftrigr *, tain const *, tain *) ; #define ftrigr_startf_g(a, deadline) ftrigr_startf(a, (deadline), &STAMP) -extern void ftrigr_end (ftrigr_t *) ; - - - /* Instant primitives for async programming */ - -#define ftrigr_fd(a) textclient_fd(&(a)->connection) -extern int ftrigr_updateb (ftrigr_t *) ; -extern int ftrigr_update (ftrigr_t *) ; -extern int ftrigr_check (ftrigr_t *, uint16_t, char *) ; -extern int ftrigr_checksa (ftrigr_t *, uint16_t, stralloc *) ; -extern void ftrigr_ack (ftrigr_t *, size_t) ; - +extern int ftrigr_start (ftrigr *, unsigned int) ; +extern void ftrigr_end (ftrigr *) ; - /* Synchronous functions with timeouts */ +#define ftrigr_fd(a) sassclient_fd(&(a)->client) +extern int ftrigr_update (ftrigr *) ; +extern int ftrigr_peek (ftrigr *, uint32_t, ftrigr_string *) ; +extern int ftrigr_ack (ftrigr *, uint32_t) ; +extern void ftrigr_release (ftrigr *, uint32_t) ; -#define FTRIGR_REPEAT 0x0001 +extern int ftrigr_subscribe (ftrigr *, uint32_t *, uint32_t, uint32_t, char const *, char const *, tain const *, tain *) ; +#define ftrigr_subscribe_g(a, id, flags, timeout, path, re, deadline) ftrigr_subscribe(a, id, flags, timeout, path, re, (deadline), &STAMP) -extern uint16_t ftrigr_subscribe (ftrigr_t *, char const *, char const *, uint32_t, tain const *, tain *) ; -#define ftrigr_subscribe_g(a, path, re, options, deadline) ftrigr_subscribe(a, path, re, options, (deadline), &STAMP) -extern int ftrigr_unsubscribe (ftrigr_t *, uint16_t, tain const *, tain *) ; +extern int ftrigr_unsubscribe (ftrigr *, uint32_t, tain const *, tain *) ; #define ftrigr_unsubscribe_g(a, id, deadline) ftrigr_unsubscribe(a, id, (deadline), &STAMP) -extern int ftrigr_wait_and (ftrigr_t *, uint16_t const *, unsigned int, tain const *, tain *) ; +extern int ftrigr_wait_and (ftrigr *, uint32_t const *, unsigned int, tain const *, tain *) ; #define ftrigr_wait_and_g(a, list, len, deadline) ftrigr_wait_and(a, list, len, (deadline), &STAMP) -extern int ftrigr_wait_or (ftrigr_t *, uint16_t const *, unsigned int, tain const *, tain *, char *) ; -#define ftrigr_wait_or_g(a, list, len, deadline, what) ftrigr_wait_or(a, list, len, deadline, &STAMP, what) +extern int ftrigr_wait_or (ftrigr *, uint32_t const *, unsigned int, ftrigr_string *, tain const *, tain *) ; +#define ftrigr_wait_or_g(a, list, n, v, deadline) ftrigr_wait_or(a, list, n, v, (deadline), &STAMP) #endif |
