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/rcpthosts.c | 52 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'src/rcpthosts.c') diff --git a/src/rcpthosts.c b/src/rcpthosts.c index 2242249..f69f4f9 100644 --- a/src/rcpthosts.c +++ b/src/rcpthosts.c @@ -1,15 +1,17 @@ -#include "cdbread.h" +#include "rcpthosts.h" + #include "byte.h" -#include "open.h" -#include "error.h" -#include "exit.h" -#include "control.h" -#include "constmap.h" -#include "stralloc.h" #include "case.h" +#include "cdbread.h" #include "close.h" +#include "constmap.h" +#include "error.h" +#include "exit.h" #include "fd.h" -#include "rcpthosts.h" +#include "open.h" +#include "stralloc.h" + +#include "control.h" static int flagrh = 0; static int flagmrh = 0; @@ -21,11 +23,12 @@ static struct cdb cdb; int rcpthosts_init() { - flagrh = control_readfile(&rh,"control/rcpthosts",0); + flagrh = control_readfile(&rh, "control/rcpthosts", 0); if (flagrh != 1) return flagrh; - if (!constmap_init(&maprh,rh.s,rh.len,0)) return flagrh = -1; + if (!constmap_init(&maprh, rh.s, rh.len, 0)) return flagrh = -1; fdmrh = open_read("control/morercpthosts.cdb"); - if (fdmrh == -1) if (errno != ENOENT) return flagmrh = -1; + if (fdmrh == -1) + if (errno != ENOENT) return flagmrh = -1; if (fdmrh > 0) flagmrh = 1; return 0; } @@ -39,28 +42,35 @@ int rcpthosts(char *buf, int len) if (flagrh != 1) return 1; - j = byte_rchr(buf,len,'@'); + j = byte_rchr(buf, len, '@'); if (j >= len) return 1; /* presumably envnoathost is acceptable */ - ++j; buf += j; len -= j; + ++j; + buf += j; + len -= j; - if (!stralloc_copyb(&host,buf,len)) return -1; + if (!stralloc_copyb(&host, buf, len)) return -1; buf = host.s; - case_lowerb(buf,len); + case_lowerb(buf, len); for (j = 0; j < len; ++j) if (!j || (buf[j] == '.')) - if (constmap(&maprh,buf + j,len - j)) return 1; + if (constmap(&maprh, buf + j, len - j)) return 1; if (flagmrh == 1) { fdmrh = open_read("control/morercpthosts.cdb"); - if (fdmrh == -1) if (errno == ENOENT) return 0; - cdb_init(&cdb,fdmrh); + if (fdmrh == -1) + if (errno == ENOENT) return 0; + cdb_init(&cdb, fdmrh); - for (j = 0; j < len ;++j) + for (j = 0; j < len; ++j) if (!j || (buf[j] == '.')) { - r = cdb_find(&cdb,buf + j,len - j); - if (r) { cdb_free(&cdb); close(fdmrh); return r; } + r = cdb_find(&cdb, buf + j, len - j); + if (r) { + cdb_free(&cdb); + close(fdmrh); + return r; + } } cdb_free(&cdb); close(fdmrh); -- cgit v1.2.3