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-clean.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/qmail-clean.c')
-rw-r--r-- | src/qmail-clean.c | 107 |
1 files changed, 66 insertions, 41 deletions
diff --git a/src/qmail-clean.c b/src/qmail-clean.c index df149a5..2a9d706 100644 --- a/src/qmail-clean.c +++ b/src/qmail-clean.c @@ -1,20 +1,22 @@ -#include <unistd.h> -#include <sys/types.h> #include <sys/stat.h> -#include "sig.h" -#include "now.h" -#include "str.h" -#include "direntry.h" -#include "getln.h" -#include "stralloc.h" +#include <sys/types.h> +#include <unistd.h> + #include "buffer.h" #include "byte.h" -#include "scan.h" -#include "fmt.h" -#include "exit.h" +#include "direntry.h" #include "error.h" -#include "fmtqfn.h" +#include "exit.h" +#include "fmt.h" +#include "getln.h" +#include "scan.h" +#include "sig.h" +#include "str.h" +#include "stralloc.h" + #include "auto_qmail.h" +#include "fmtqfn.h" +#include "now.h" #define OSSIFIED 129600 /* see qmail-send.c */ @@ -30,14 +32,14 @@ void cleanuppid() time = now(); dir = opendir("pid"); if (!dir) return; - + while ((d = readdir(dir))) { - if (str_equal(d->d_name,".")) continue; - if (str_equal(d->d_name,"..")) continue; - if (!stralloc_copys(&line,"pid/")) continue; - if (!stralloc_cats(&line,d->d_name)) continue; + if (str_equal(d->d_name, ".")) continue; + if (str_equal(d->d_name, "..")) continue; + if (!stralloc_copys(&line, "pid/")) continue; + if (!stralloc_cats(&line, d->d_name)) continue; if (!stralloc_0(&line)) continue; - if (stat(line.s,&st) == -1) continue; + if (stat(line.s, &st) == -1) continue; if (time < st.st_atime + OSSIFIED) continue; unlink(line.s); } @@ -46,9 +48,9 @@ void cleanuppid() char fnbuf[FMTQFN]; -void respond(char *s) -{ - if (buffer_putflush(buffer_1small,s,1) == -1) _exit(100); +void respond(char *s) +{ + if (buffer_putflush(buffer_1small, s, 1) == -1) _exit(100); } int main() @@ -63,37 +65,60 @@ int main() sig_pipeignore(); - if (!stralloc_ready(&line,200)) _exit(111); + if (!stralloc_ready(&line, 200)) _exit(111); cleanuploop = 0; for (;;) { - if (cleanuploop) --cleanuploop; else { cleanuppid(); cleanuploop = 30; } - if (getln(buffer_0small,&line,&match,'\0') == -1) break; + if (cleanuploop) + --cleanuploop; + else { + cleanuppid(); + cleanuploop = 30; + } + if (getln(buffer_0small, &line, &match, '\0') == -1) break; if (!match) break; - if (line.len < 7) { respond("x"); continue; } - if (line.len > 100) { respond("x"); continue; } - if (line.s[line.len - 1]) { respond("x"); continue; } /* impossible */ + if (line.len < 7) { + respond("x"); + continue; + } + if (line.len > 100) { + respond("x"); + continue; + } + if (line.s[line.len - 1]) { + respond("x"); + continue; + } /* impossible */ for (i = line.len - 2; i > 4; --i) { if (line.s[i] == '/') break; - if ((unsigned char) (line.s[i] - '0') > 9) - { respond("x"); continue; } + if ((unsigned char)(line.s[i] - '0') > 9) { + respond("x"); + continue; + } } - if (line.s[i] == '/') - if (!scan_ulong(line.s + i + 1,&id)) { respond("x"); continue; } - if (byte_equal(line.s,5,"foop/")) { -#define U(prefix,flag) fmtqfn(fnbuf,prefix,id,flag); \ - if (unlink(fnbuf) == -1) if (errno != ENOENT) { respond("!"); continue; } - U("intd/",1) - U("mess/",1) + if (line.s[i] == '/') + if (!scan_ulong(line.s + i + 1, &id)) { + respond("x"); + continue; + } + if (byte_equal(line.s, 5, "foop/")) { +#define U(prefix, flag) \ + fmtqfn(fnbuf, prefix, id, flag); \ + if (unlink(fnbuf) == -1) \ + if (errno != ENOENT) { \ + respond("!"); \ + continue; \ + } + U("intd/", 1) + U("mess/", 1) respond("+"); - } else if (byte_equal(line.s,4,"todo/")) { - U("intd/",1) - U("todo/",1) + } else if (byte_equal(line.s, 4, "todo/")) { + U("intd/", 1) + U("todo/", 1) respond("+"); - } - else + } else respond("x"); } _exit(0); |