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/spfquery.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/spfquery.c')
-rw-r--r-- | src/spfquery.c | 99 |
1 files changed, 57 insertions, 42 deletions
diff --git a/src/spfquery.c b/src/spfquery.c index 8c642ee..68a5158 100644 --- a/src/spfquery.c +++ b/src/spfquery.c @@ -1,26 +1,36 @@ -#include <string.h> #include <unistd.h> -#include "buffer.h" -#include "stralloc.h" + +#include <string.h> + #include "alloc.h" -#include "spf.h" -#include "exit.h" -#include "dns.h" -#include "str.h" +#include "buffer.h" #include "byte.h" +#include "exit.h" #include "logmsg.h" +#include "str.h" +#include "stralloc.h" + +#include "dns.h" +#include "spf.h" #define WHO "spfquery" -void die(int e,char *s) { buffer_putsflush(buffer_2,s); _exit(e); } -void die_nomem() { die(111,"fatal: out of memory\n"); } +void die(int e, char *s) +{ + buffer_putsflush(buffer_2, s); + _exit(e); +} +void die_nomem() +{ + die(111, "fatal: out of memory\n"); +} static stralloc heloin = {0}; static stralloc mfin = {0}; static stralloc spflocal = {0}; static stralloc spfbounce = {0}; -int main(int argc,char **argv) +int main(int argc, char **argv) { stralloc spfip = {0}; int flag = 0; @@ -28,70 +38,75 @@ int main(int argc,char **argv) int verbose = 0; flagip6 = 1; - if (argc < 4) - logmsg(WHO,100,USAGE,"spfquery <sender-ip> <sender-helo/ehlo> <envelope-from> [<local rules>] [-v(erbose) ]\n"); + if (argc < 4) + logmsg( + WHO, + 100, + USAGE, + "spfquery <sender-ip> <sender-helo/ehlo> <envelope-from> [<local rules>] [-v(erbose) ]\n"); - if (!stralloc_copys(&spfip,argv[1])) die_nomem(); + if (!stralloc_copys(&spfip, argv[1])) die_nomem(); if (!stralloc_0(&spfip)) die_nomem(); - r = byte_chr(spfip.s,spfip.len,':'); + r = byte_chr(spfip.s, spfip.len, ':'); if (r < spfip.len) flag = 1; - if (!stralloc_copys(&heloin,argv[2])) die_nomem(); + if (!stralloc_copys(&heloin, argv[2])) die_nomem(); if (!stralloc_0(&heloin)) die_nomem(); - if (!stralloc_copys(&mfin,argv[3])) die_nomem(); + if (!stralloc_copys(&mfin, argv[3])) die_nomem(); if (!stralloc_0(&mfin)) die_nomem(); if (argc > 4) { - if (!byte_diff(argv[4],2,"-v")) verbose = 1; + if (!byte_diff(argv[4], 2, "-v")) + verbose = 1; else { - if (!stralloc_copys(&spflocal,argv[4])) die_nomem(); + if (!stralloc_copys(&spflocal, argv[4])) die_nomem(); if (spflocal.len && !stralloc_0(&spflocal)) die_nomem(); } } if (argc > 5) { - if (!byte_diff(argv[5],2,"-v")) verbose = 1; + if (!byte_diff(argv[5], 2, "-v")) verbose = 1; } - if (!stralloc_copys(&spfexplain,SPF_DEFEXP)) die_nomem(); + if (!stralloc_copys(&spfexplain, SPF_DEFEXP)) die_nomem(); if (!stralloc_0(&spfexplain)) die_nomem(); DNS_INIT - r = spf_query(spfip.s,heloin.s,mfin.s,"localhost",flag); + r = spf_query(spfip.s, heloin.s, mfin.s, "localhost", flag); if (r == SPF_NOMEM) die_nomem(); - buffer_puts(buffer_1,"result="); + buffer_puts(buffer_1, "result="); switch (r) { - case SPF_ME: buffer_puts(buffer_1,"loopback"); break; - case SPF_OK: buffer_puts(buffer_1,"pass"); break; - case SPF_NONE: buffer_puts(buffer_1,"none"); break; - case SPF_UNKNOWN: buffer_puts(buffer_1,"unknown"); break; - case SPF_NEUTRAL: buffer_puts(buffer_1,"neutral"); break; - case SPF_SOFTFAIL: buffer_puts(buffer_1,"softfail"); break; - case SPF_FAIL: buffer_puts(buffer_1,"fail"); break; - case SPF_ERROR: buffer_puts(buffer_1,"error"); break; - case SPF_SYNTAX: buffer_puts(buffer_1,"IP address syntax error"); break; - default: buffer_puts(buffer_1,"undefined"); break; + case SPF_ME: buffer_puts(buffer_1, "loopback"); break; + case SPF_OK: buffer_puts(buffer_1, "pass"); break; + case SPF_NONE: buffer_puts(buffer_1, "none"); break; + case SPF_UNKNOWN: buffer_puts(buffer_1, "unknown"); break; + case SPF_NEUTRAL: buffer_puts(buffer_1, "neutral"); break; + case SPF_SOFTFAIL: buffer_puts(buffer_1, "softfail"); break; + case SPF_FAIL: buffer_puts(buffer_1, "fail"); break; + case SPF_ERROR: buffer_puts(buffer_1, "error"); break; + case SPF_SYNTAX: buffer_puts(buffer_1, "IP address syntax error"); break; + default: buffer_puts(buffer_1, "undefined"); break; } - buffer_putsflush(buffer_1,"\n"); + buffer_putsflush(buffer_1, "\n"); if (r == SPF_SYNTAX) _exit(1); if (verbose) { - buffer_puts(buffer_1,"SPF records read: \n"); - buffer_put(buffer_1,spfrecord.s,spfrecord.len); + buffer_puts(buffer_1, "SPF records read: \n"); + buffer_put(buffer_1, spfrecord.s, spfrecord.len); } - buffer_puts(buffer_1,"SPF information evaluated: "); - buffer_put(buffer_1,spfinfo.s,spfinfo.len); - buffer_putsflush(buffer_1,"\n"); + buffer_puts(buffer_1, "SPF information evaluated: "); + buffer_put(buffer_1, spfinfo.s, spfinfo.len); + buffer_putsflush(buffer_1, "\n"); if (r == SPF_FAIL) { - buffer_puts(buffer_1,"SPF results returned: "); - if (!spf_parse(&spfbounce,spfexpmsg.s,expdomain.s)) die_nomem(); - buffer_put(buffer_1,spfbounce.s,spfbounce.len); - buffer_putsflush(buffer_1,"\n"); + buffer_puts(buffer_1, "SPF results returned: "); + if (!spf_parse(&spfbounce, spfexpmsg.s, expdomain.s)) die_nomem(); + buffer_put(buffer_1, spfbounce.s, spfbounce.len); + buffer_putsflush(buffer_1, "\n"); } _exit(0); |