Back to index

courier  0.68.2
pipefds.h
Go to the documentation of this file.
00001 #ifndef       pipefds_h
00002 #define       pipefds_h
00003 
00004 
00006 //
00007 //  Convenience class - automatically destroy pair of pipe handles.
00008 //
00010 
00011 #include      "config.h"
00012 #include      <stdlib.h>
00013 #if    HAVE_UNISTD_H
00014 #include      <unistd.h>
00015 #endif
00016 
00017 class PipeFds {
00018 public:
00019        int fds[2];
00020 
00021        PipeFds() { fds[0]= -1; fds[1]= -1; }
00022        int Pipe();
00023        void close0()
00024               {
00025                      if (fds[0] >= 0)     close(fds[0]);
00026                      fds[0]= -1;
00027               }
00028        void close1()
00029               {
00030                      if (fds[1] >= 0)     close(fds[1]);
00031                      fds[1]= -1;
00032               }
00033        ~PipeFds();
00034 } ;
00035 #endif