summaryrefslogtreecommitdiff
path: root/src/qmail-tcpto.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/qmail-tcpto.c
parent00be7622c428f279872f84569f098ce16150f8a8 (diff)
format files
Diffstat (limited to 'src/qmail-tcpto.c')
-rw-r--r--src/qmail-tcpto.c84
1 files changed, 51 insertions, 33 deletions
diff --git a/src/qmail-tcpto.c b/src/qmail-tcpto.c
index e148c55..b5100ef 100644
--- a/src/qmail-tcpto.c
+++ b/src/qmail-tcpto.c
@@ -2,37 +2,55 @@
#include <sys/socket.h>
#include <unistd.h>
+
#include "buffer.h"
-#include "auto_qmail.h"
+#include "error.h"
+#include "exit.h"
#include "fmt.h"
#include "ip.h"
#include "lock.h"
-#include "error.h"
-#include "exit.h"
+#include "logmsg.h"
+#include "open.h"
+#include "stralloc.h"
+
+#include "auto_qmail.h"
#include "datetime.h"
#include "now.h"
-#include "stralloc.h"
-#include "open.h"
-#include "logmsg.h"
#define WHO "qmail-tcpto"
-void die(n) int n; { buffer_flush(buffer_1); _exit(n); }
+void die(n) int n;
+{
+ buffer_flush(buffer_1);
+ _exit(n);
+}
void warn(s) char *s;
{
char *x;
x = error_str(errno);
- buffer_puts(buffer_1,s);
- buffer_puts(buffer_1,": ");
- buffer_puts(buffer_1,x);
- buffer_puts(buffer_1,"\n");
+ buffer_puts(buffer_1, s);
+ buffer_puts(buffer_1, ": ");
+ buffer_puts(buffer_1, x);
+ buffer_puts(buffer_1, "\n");
}
-void die_chdir() { logmsg(WHO,110,FATAL,"unable to chdir"); }
-void die_open() { logmsg(WHO,112,FATAL,"unable to open tcpto"); }
-void die_lock() { logmsg(WHO,112,FATAL,"unable to lock tcpto"); }
-void die_read() { logmsg(WHO,112,FATAL,"unable to read tcpto"); }
+void die_chdir()
+{
+ logmsg(WHO, 110, FATAL, "unable to chdir");
+}
+void die_open()
+{
+ logmsg(WHO, 112, FATAL, "unable to open tcpto");
+}
+void die_lock()
+{
+ logmsg(WHO, 112, FATAL, "unable to lock tcpto");
+}
+void die_read()
+{
+ logmsg(WHO, 112, FATAL, "unable to read tcpto");
+}
char tcpto_buf[1024];
@@ -58,38 +76,38 @@ int main(void)
fd = open_read("tcpto");
if (fd == -1) die_open();
if (lock_ex(fdlock) == -1) die_lock();
- r = read(fd,tcpto_buf,sizeof(tcpto_buf));
+ r = read(fd, tcpto_buf, sizeof(tcpto_buf));
close(fd);
close(fdlock);
if (r == -1) die_read();
- r >>= 5; /* 32 bit read */
+ r >>= 5; /* 32 bit read */
start = now();
record = tcpto_buf;
for (i = 0; i < r; ++i) {
if (record[4] >= 1) {
- when = (unsigned long) (unsigned char) record[11];
- when = (when << 8) + (unsigned long) (unsigned char) record[10];
- when = (when << 8) + (unsigned long) (unsigned char) record[9];
- when = (when << 8) + (unsigned long) (unsigned char) record[8];
+ when = (unsigned long)(unsigned char)record[11];
+ when = (when << 8) + (unsigned long)(unsigned char)record[10];
+ when = (when << 8) + (unsigned long)(unsigned char)record[9];
+ when = (when << 8) + (unsigned long)(unsigned char)record[8];
if (record[0] == AF_INET) {
- byte_copy(&ip4,4,record + 16);
- buffer_put(buffer_1,tmp,ip4_fmt(tmp,ip4));
+ byte_copy(&ip4, 4, record + 16);
+ buffer_put(buffer_1, tmp, ip4_fmt(tmp, ip4));
} else {
- byte_copy(&ip6,16,record + 16);
- buffer_put(buffer_1,tmp,ip6_fmt(tmp,ip6));
+ byte_copy(&ip6, 16, record + 16);
+ buffer_put(buffer_1, tmp, ip6_fmt(tmp, ip6));
}
- buffer_puts(buffer_1," timed out ");
- buffer_put(buffer_1,tmp,fmt_ulong(tmp,(unsigned long) (start - when)));
- buffer_puts(buffer_1," seconds ago; # recent timeouts: ");
- buffer_put(buffer_1,tmp,fmt_ulong(tmp,(unsigned long) (unsigned char) record[4]));
- buffer_puts(buffer_1,"\n");
- }
- record += 32;
+ buffer_puts(buffer_1, " timed out ");
+ buffer_put(buffer_1, tmp, fmt_ulong(tmp, (unsigned long)(start - when)));
+ buffer_puts(buffer_1, " seconds ago; # recent timeouts: ");
+ buffer_put(buffer_1, tmp, fmt_ulong(tmp, (unsigned long)(unsigned char)record[4]));
+ buffer_puts(buffer_1, "\n");
+ }
+ record += 32;
}
- die(0);
+ die(0);
}