diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/qmail-qmqpd.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/qmail-qmqpd.c')
-rw-r--r-- | src/qmail-qmqpd.c | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/src/qmail-qmqpd.c b/src/qmail-qmqpd.c index 86404a9..b949338 100644 --- a/src/qmail-qmqpd.c +++ b/src/qmail-qmqpd.c @@ -1,49 +1,54 @@ #include <unistd.h> -#include "auto_qmail.h" -#include "qmail.h" -#include "received.h" -#include "sig.h" + #include "buffer.h" +#include "byte.h" +#include "case.h" +#include "env.h" #include "exit.h" -#include "now.h" #include "fmt.h" -#include "env.h" -#include "case.h" -#include "byte.h" #include "ip.h" +#include "sig.h" #include "str.h" +#include "auto_qmail.h" +#include "now.h" +#include "qmail.h" +#include "received.h" + #define PORT_QMQP "628" -void resources() { _exit(111); } +void resources() +{ + _exit(111); +} -ssize_t safewrite(int fd,char *buf,int len) +ssize_t safewrite(int fd, char *buf, int len) { int r; - r = write(fd,buf,len); + r = write(fd, buf, len); if (r <= 0) _exit(0); return r; } -ssize_t saferead(int fd,char *buf,int len) +ssize_t saferead(int fd, char *buf, int len) { int r; - r = read(fd,buf,len); + r = read(fd, buf, len); if (r <= 0) _exit(0); return r; } char inbuf[512]; -buffer bi = BUFFER_INIT(saferead,0,inbuf,sizeof(inbuf)); +buffer bi = BUFFER_INIT(saferead, 0, inbuf, sizeof(inbuf)); char outbuf[256]; -buffer bo = BUFFER_INIT(safewrite,1,outbuf,sizeof(outbuf)); +buffer bo = BUFFER_INIT(safewrite, 1, outbuf, sizeof(outbuf)); unsigned long bytesleft = 100; void getbyte(char *ch) { if (!bytesleft--) _exit(100); - buffer_get(&bi,ch,1); + buffer_get(&bi, ch, 1); } unsigned long getlen() @@ -82,7 +87,7 @@ void identify() remoteinfo = env_get("TCP6REMOTEINFO"); if (!remoteinfo) remoteinfo = env_get("TCPREMOTEINFO"); remoteip = env_get("TCP6REMOTEIP"); - if (remoteip && byte_equal(remoteip,7,V4MAPPREFIX)) remoteip=remoteip+7; + if (remoteip && byte_equal(remoteip, 7, V4MAPPREFIX)) remoteip = remoteip + 7; if (!remoteip) remoteip = env_get("TCPREMOTEIP"); if (!remoteip) remoteip = "unknown"; local = env_get("TCP6LOCALHOST"); @@ -91,10 +96,10 @@ void identify() if (!local) local = env_get("TCPLOCALIP"); if (!local) local = "unknown"; localport = env_get("TCP6LOCALPORT"); - if (!localport) localport = env_get("TCPLOCALPORT"); + if (!localport) localport = env_get("TCPLOCALPORT"); if (!localport) localport = "0"; - received(&qq,"QMQP",local,remoteip,remotehost,remoteinfo,(char *) 0,(char *) 0,(char *) 0); + received(&qq, "QMQP", local, remoteip, remotehost, remoteinfo, (char *)0, (char *)0, (char *)0); } char buf[1000]; @@ -116,7 +121,7 @@ int getbuf() for (i = 0; i < len; ++i) getbyte(buf + i); getcomma(); buf[len] = 0; - return byte_chr(buf,len,'\0') == len; + return byte_chr(buf, len, '\0') == len; } int flagok = 1; @@ -144,21 +149,21 @@ int main() while (len > 0) { /* XXX: could speed this up */ getbyte(&ch); --len; - qmail_put(&qq,&ch,1); + qmail_put(&qq, &ch, 1); } getcomma(); if (getbuf()) - qmail_from(&qq,buf); + qmail_from(&qq, buf); else { - qmail_from(&qq,""); + qmail_from(&qq, ""); qmail_fail(&qq); flagok = 0; } while (bytesleft) if (getbuf()) - qmail_to(&qq,buf); + qmail_to(&qq, buf); else { qmail_fail(&qq); flagok = 0; @@ -170,21 +175,20 @@ int main() result = qmail_close(&qq); if (!*result) { - len = fmt_str(buf,"Kok "); - len += fmt_ulong(buf + len,(unsigned long) now()); - len += fmt_str(buf + len," qp "); - len += fmt_ulong(buf + len,qp); + len = fmt_str(buf, "Kok "); + len += fmt_ulong(buf + len, (unsigned long)now()); + len += fmt_str(buf + len, " qp "); + len += fmt_ulong(buf + len, qp); buf[len] = 0; result = buf; } - if (!flagok) - result = "Dsorry, I can't accept addresses like that (#5.1.3)"; + if (!flagok) result = "Dsorry, I can't accept addresses like that (#5.1.3)"; - buffer_put(&bo,strnum,fmt_ulong(strnum,(unsigned long) str_len(result))); - buffer_puts(&bo,":"); - buffer_puts(&bo,result); - buffer_puts(&bo,","); + buffer_put(&bo, strnum, fmt_ulong(strnum, (unsigned long)str_len(result))); + buffer_puts(&bo, ":"); + buffer_puts(&bo, result); + buffer_puts(&bo, ","); buffer_flush(&bo); _exit(0); } |