aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/s6tls_prep_tlsdio.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-09-08 08:38:06 +0000
committerLaurent Bercot <ska@appnovation.com>2023-09-08 08:38:06 +0000
commit7113c4cf792ec44ec04a54e9723fa31a97bee5a7 (patch)
treecb13b4316f0a164e83ffba5ca603dcf11c26045c /src/tls/s6tls_prep_tlsdio.c
parent9efa646c7fb520747804acdc829b3cccea0dce63 (diff)
downloads6-networking-7113c4cf792ec44ec04a54e9723fa31a97bee5a7.tar.gz
Refactor s6-tls[cd] so they're ready to port to posix_spawn
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tls/s6tls_prep_tlsdio.c')
-rw-r--r--src/tls/s6tls_prep_tlsdio.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tls/s6tls_prep_tlsdio.c b/src/tls/s6tls_prep_tlsdio.c
new file mode 100644
index 0000000..942425b
--- /dev/null
+++ b/src/tls/s6tls_prep_tlsdio.c
@@ -0,0 +1,53 @@
+/* ISC license. */
+
+#include <skalibs/types.h>
+
+#include <s6-networking/config.h>
+#include "s6tls-internal.h"
+
+void s6tls_prep_tlsdio (char const **argv, char *buf, int fdr, int fdw, int fdnotif, uint32_t options, unsigned int verbosity, unsigned int kimeout, unsigned int snilevel)
+{
+ size_t m = 0 ;
+ size_t n = 0 ;
+
+ argv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsd-io" ;
+ if (verbosity != 1)
+ {
+ argv[m++] = "-v" ;
+ argv[m++] = buf + n ;
+ n += uint_fmt(buf + n, verbosity) ;
+ buf[n++] = 0 ;
+ }
+ if (fdnotif)
+ {
+ argv[m++] = "-d" ;
+ argv[m++] = buf + n ;
+ n += uint_fmt(buf + n, fdnotif) ;
+ buf[n++] = 0 ;
+ }
+ argv[m++] = options & 4 ? "-S" : "-s" ;
+ if (options & 1)
+ argv[m++] = options & 2 ? "-y" : "-Y" ;
+ if (kimeout)
+ {
+ argv[m++] = "-K" ;
+ argv[m++] = buf + n ;
+ n += uint_fmt(buf + n, kimeout) ;
+ buf[n++] = 0 ;
+ }
+ if (snilevel)
+ {
+ argv[m++] = "-k" ;
+ argv[m++] = buf + n ;
+ n += uint_fmt(buf + n, snilevel) ;
+ buf[n++] = 0 ;
+ }
+ argv[m++] = "--" ;
+ argv[m++] = buf + n ;
+ n += uint_fmt(buf + n, fdr) ;
+ buf[n++] = 0 ;
+ argv[m++] = buf + n ;
+ n += uint_fmt(buf + n, fdw) ;
+ buf[n++] = 0 ;
+ argv[m++] = 0 ;
+}