summaryrefslogtreecommitdiffstats
path: root/maildrop/pipefds.h
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /maildrop/pipefds.h
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'maildrop/pipefds.h')
-rw-r--r--maildrop/pipefds.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/maildrop/pipefds.h b/maildrop/pipefds.h
new file mode 100644
index 0000000..1077114
--- /dev/null
+++ b/maildrop/pipefds.h
@@ -0,0 +1,35 @@
+#ifndef pipefds_h
+#define pipefds_h
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Convenience class - automatically destroy pair of pipe handles.
+//
+/////////////////////////////////////////////////////////////////////////
+
+#include "config.h"
+#include <stdlib.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+class PipeFds {
+public:
+ int fds[2];
+
+ PipeFds() { fds[0]= -1; fds[1]= -1; }
+ int Pipe();
+ void close0()
+ {
+ if (fds[0] >= 0) close(fds[0]);
+ fds[0]= -1;
+ }
+ void close1()
+ {
+ if (fds[1] >= 0) close(fds[1]);
+ fds[1]= -1;
+ }
+ ~PipeFds();
+} ;
+#endif