nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

qmail-tcpok.c (969B)


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