From a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Wed, 3 Jul 2024 15:52:39 +0200 Subject: format files --- src/tls_start.c | 77 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 34 deletions(-) (limited to 'src/tls_start.c') diff --git a/src/tls_start.c b/src/tls_start.c index 77c5155..12c8e75 100644 --- a/src/tls_start.c +++ b/src/tls_start.c @@ -1,35 +1,42 @@ #include -#include "scan.h" + #include "env.h" -#include "open.h" -#include "stralloc.h" #include "fd.h" #include "logmsg.h" +#include "open.h" +#include "scan.h" +#include "stralloc.h" #define WHO "tls_start" #define BUFSIZE 8192 -static void die_nomem() { logmsg(WHO,111,FATAL,"out of memory"); } -static void die_tlsenv() { logmsg(WHO,111,FATAL,"no UCSPITLS environment to read"); } +static void die_nomem() +{ + logmsg(WHO, 111, FATAL, "out of memory"); +} +static void die_tlsenv() +{ + logmsg(WHO, 111, FATAL, "no UCSPITLS environment to read"); +} int starttls_init(void) { unsigned long fd; char *fdstr; - + if (!(fdstr = env_get("SSLCTLFD"))) return 0; - if (!scan_ulong(fdstr,&fd)) return 0; - if (write((int)fd,"Y",1) < 1) return 0; - + if (!scan_ulong(fdstr, &fd)) return 0; + if (write((int)fd, "Y", 1) < 1) return 0; + if (!(fdstr = env_get("SSLREADFD"))) return 0; - if (!scan_ulong(fdstr,&fd)) return 0; - if (fd_move(0,(int)fd) == -1) return 0; - - if (!(fdstr = env_get("SSLWRITEFD"))) return 0; - if (!scan_ulong(fdstr,&fd)) return 0; - if (fd_move(1,(int)fd) == -1) return 0; - + if (!scan_ulong(fdstr, &fd)) return 0; + if (fd_move(0, (int)fd) == -1) return 0; + + if (!(fdstr = env_get("SSLWRITEFD"))) return 0; + if (!scan_ulong(fdstr, &fd)) return 0; + if (fd_move(1, (int)fd) == -1) return 0; + return 1; } @@ -41,41 +48,43 @@ int starttls_info(void) char *x; int j; - stralloc ssl_env = {0}; - stralloc ssl_parm = {0}; + stralloc ssl_env = {0}; + stralloc ssl_parm = {0}; stralloc ssl_value = {0}; if (!(fdstr = env_get("SSLCTLFD"))) return 0; - if (!scan_ulong(fdstr,&fd)) return 0; + if (!scan_ulong(fdstr, &fd)) return 0; - while ((j = read(fd,envbuf,BUFSIZE)) > 0 ) { - if (!stralloc_catb(&ssl_env,envbuf,j)) die_nomem(); - if (ssl_env.len >= 2 && ssl_env.s[ssl_env.len - 2] == 0 && ssl_env.s[ssl_env.len - 1] == 0) - break; + while ((j = read(fd, envbuf, BUFSIZE)) > 0) { + if (!stralloc_catb(&ssl_env, envbuf, j)) die_nomem(); + if (ssl_env.len >= 2 && ssl_env.s[ssl_env.len - 2] == 0 && ssl_env.s[ssl_env.len - 1] == 0) break; } - if (j <= 0) { die_tlsenv(); return 0; } // nothing to read + if (j <= 0) { + die_tlsenv(); + return 0; + } // nothing to read - x = ssl_env.s; + x = ssl_env.s; for (j = 0; j < ssl_env.len - 1; ++j) { - if ( *x != '=' ) { - if (!stralloc_catb(&ssl_parm,x,1)) die_nomem(); - x++; + if (*x != '=') { + if (!stralloc_catb(&ssl_parm, x, 1)) die_nomem(); + x++; } else { if (!stralloc_0(&ssl_parm)) die_nomem(); x++; for (; j < ssl_env.len - j - 1; ++j) { - if ( *x != '\0' ) { - if (!stralloc_catb(&ssl_value,x,1)) die_nomem(); - x++; + if (*x != '\0') { + if (!stralloc_catb(&ssl_value, x, 1)) die_nomem(); + x++; } else { if (!stralloc_0(&ssl_value)) die_nomem(); x++; - if (!env_put(ssl_parm.s,ssl_value.s)) die_nomem(); - ssl_parm.len = 0; + if (!env_put(ssl_parm.s, ssl_value.s)) die_nomem(); + ssl_parm.len = 0; ssl_value.len = 0; - break; + break; } } } -- cgit v1.2.3