diff options
Diffstat (limited to 'src/tls/s6tls_exec_tlscio.c')
-rw-r--r-- | src/tls/s6tls_exec_tlscio.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tls/s6tls_exec_tlscio.c b/src/tls/s6tls_exec_tlscio.c new file mode 100644 index 0000000..ad00ecd --- /dev/null +++ b/src/tls/s6tls_exec_tlscio.c @@ -0,0 +1,53 @@ +/* ISC license. */ + +#include <skalibs/posixplz.h> +#include <skalibs/types.h> +#include <skalibs/djbunix.h> + +#include <s6-networking/config.h> +#include "s6tls-internal.h" + +void s6tls_exec_tlscio (int const *fds, uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername) +{ + char const *newargv[15] ; + unsigned int m = 0 ; + char fmtv[UINT_FMT] ; + char fmtd[UINT_FMT] ; + char fmtk[UINT_FMT] ; + char fmtr[UINT_FMT] ; + char fmtw[UINT_FMT] ; + + newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsc-io" ; + if (verbosity != 1) + { + newargv[m++] = "-v" ; + newargv[m++] = fmtv ; + fmtv[uint_fmt(fmtv, verbosity)] = 0 ; + } + if (fds[2]) + { + newargv[m++] = "-d" ; + newargv[m++] = fmtd ; + fmtd[uint_fmt(fmtd, fds[2])] = 0 ; + } + newargv[m++] = options & 4 ? "-S" : "-s" ; + newargv[m++] = options & 1 ? "-y" : "-Y" ; + if (kimeout) + { + newargv[m++] = "-K" ; + newargv[m++] = fmtk ; + fmtk[uint_fmt(fmtk, kimeout)] = 0 ; + } + if (servername) + { + newargv[m++] = "-k" ; + newargv[m++] = servername ; + } + newargv[m++] = "--" ; + newargv[m++] = fmtr ; + fmtr[uint_fmt(fmtr, fds[0])] = 0 ; + newargv[m++] = fmtw ; + fmtw[uint_fmt(fmtw, fds[1])] = 0 ; + newargv[m++] = 0 ; + xpathexec_run(newargv[0], newargv, (char const *const *)environ) ; +} |