libassa
3.5.0
|
00001 // -*- c++ -*- 00002 //------------------------------------------------------------------------------ 00003 // $Id: Pipe.h,v 1.3 2005/10/08 02:42:00 vlg Exp $ 00004 //------------------------------------------------------------------------------ 00005 // Pipe.h 00006 //------------------------------------------------------------------------------ 00007 // Copyright (C) 1997-2002 Vladislav Grinchenko 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Library General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2 of the License, or (at your option) any later version. 00013 //------------------------------------------------------------------------------ 00014 #ifndef PIPE_H 00015 #define PIPE_H 00016 00017 #include <stdio.h> 00018 #include <string> 00019 00020 #include "assa/Logger.h" 00021 00022 namespace ASSA { 00023 00028 class Pipe 00029 { 00030 public: 00034 Pipe (); 00035 00039 ~Pipe (); 00040 00056 FILE* open (const string& cmd_, const string& type_); 00057 00065 int close (); 00066 00074 int kill (); 00075 00077 pid_t pid () const; 00078 00080 FILE* fp () const; 00081 00083 int fd () const; 00084 00085 private: 00086 Pipe (const Pipe&); 00087 Pipe& operator= (const Pipe&); 00088 00089 private: 00093 FILE* m_fp; 00094 00098 pid_t m_child_pid; 00099 }; 00100 00101 inline pid_t 00102 Pipe::pid () const { return m_child_pid; } 00103 00104 inline int 00105 Pipe::fd () const { return fileno (m_fp); } 00106 00107 inline FILE* 00108 Pipe::fp () const { return m_fp; } 00109 00110 } // end namespace ASSA 00111 00112 #endif // PIPE_H 00113