|
1 #include "strerr.h" |
|
2 #include "substdio.h" |
|
3 #include "lock.h" |
|
4 #include "open.h" |
|
5 #include "readwrite.h" |
|
6 #include "auto_qmail.h" |
|
7 #include "exit.h" |
|
8 |
|
9 #define FATAL "qmail-tcpok: fatal: " |
|
10 |
|
11 char buf[1024]; /* XXX: must match size in tcpto_clean.c, tcpto.c */ |
|
12 substdio ss; |
|
13 |
|
14 void main() |
|
15 { |
|
16 int fd; |
|
17 int i; |
|
18 |
|
19 if (chdir(auto_qmail) == -1) |
|
20 strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,": "); |
|
21 if (chdir("queue/lock") == -1) |
|
22 strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,"/queue/lock: "); |
|
23 |
|
24 fd = open_write("tcpto"); |
|
25 if (fd == -1) |
|
26 strerr_die4sys(111,FATAL,"unable to write ",auto_qmail,"/queue/lock/tcpto: "); |
|
27 if (lock_ex(fd) == -1) |
|
28 strerr_die4sys(111,FATAL,"unable to lock ",auto_qmail,"/queue/lock/tcpto: "); |
|
29 |
|
30 substdio_fdbuf(&ss,write,fd,buf,sizeof buf); |
|
31 for (i = 0;i < sizeof buf;++i) substdio_put(&ss,"",1); |
|
32 if (substdio_flush(&ss) == -1) |
|
33 strerr_die4sys(111,FATAL,"unable to clear ",auto_qmail,"/queue/lock/tcpto: "); |
|
34 _exit(0); |
|
35 } |