summaryrefslogtreecommitdiff
path: root/src/rcpthosts.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
commita6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch)
treeb88cc7a8457658d67e0321718556ac807f6bccf3 /src/rcpthosts.c
parent00be7622c428f279872f84569f098ce16150f8a8 (diff)
format files
Diffstat (limited to 'src/rcpthosts.c')
-rw-r--r--src/rcpthosts.c52
1 files changed, 31 insertions, 21 deletions
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);