nightmaremail

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

trigger.c (636B)


      1 #include "trigger.h"
      2 
      3 #include <unistd.h>
      4 #include "select.h"
      5 #include "open.h"
      6 #include "hasnpbg1.h"
      7 
      8 static int fd = -1;
      9 #ifdef HASNAMEDPIPEBUG1
     10 static int fdw = -1;
     11 #endif
     12 
     13 void trigger_set()
     14 {
     15  if (fd != -1)
     16    close(fd);
     17 #ifdef HASNAMEDPIPEBUG1
     18  if (fdw != -1)
     19    close(fdw);
     20 #endif
     21  fd = open_read("lock/trigger");
     22 #ifdef HASNAMEDPIPEBUG1
     23  fdw = open_write("lock/trigger");
     24 #endif
     25 }
     26 
     27 void trigger_selprep(nfds,rfds)
     28 int *nfds;
     29 fd_set *rfds;
     30 {
     31  if (fd != -1)
     32   {
     33    FD_SET(fd,rfds);
     34    if (*nfds < fd + 1) *nfds = fd + 1;
     35   }
     36 }
     37 
     38 int trigger_pulled(rfds)
     39 fd_set *rfds;
     40 {
     41  if (fd != -1) if (FD_ISSET(fd,rfds)) return 1;
     42  return 0;
     43 }