pstreams-0.8.0/pstream.h0000664000076400007640000020552312125352470013653 0ustar rediredi/* PStreams - POSIX Process I/O for C++ Copyright (C) 2001-2013 Jonathan Wakely This file is part of PStreams. PStreams is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. PStreams is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ /** * @file pstream.h * @brief Declares all PStreams classes. * @author Jonathan Wakely * * Defines classes redi::ipstream, redi::opstream, redi::pstream * and redi::rpstream. */ #ifndef REDI_PSTREAM_H_SEEN #define REDI_PSTREAM_H_SEEN #include #include #include #include #include #include #include // for min() #include // for errno #include // for size_t, NULL #include // for exit() #include // for pid_t #include // for waitpid() #include // for ioctl() and FIONREAD #if defined(__sun) # include // for FIONREAD on Solaris 2.5 #endif #include // for pipe() fork() exec() and filedes functions #include // for kill() #include // for fcntl() #if REDI_EVISCERATE_PSTREAMS # include // for FILE, fdopen() #endif /// The library version. #define PSTREAMS_VERSION 0x0080 // 0.8.0 /** * @namespace redi * @brief All PStreams classes are declared in namespace redi. * * Like the standard iostreams, PStreams is a set of class templates, * taking a character type and traits type. As with the standard streams * they are most likely to be used with @c char and the default * traits type, so typedefs for this most common case are provided. * * The @c pstream_common class template is not intended to be used directly, * it is used internally to provide the common functionality for the * other stream classes. */ namespace redi { /// Common base class providing constants and typenames. struct pstreams { /// Type used to specify how to connect to the process. typedef std::ios_base::openmode pmode; /// Type used to hold the arguments for a command. typedef std::vector argv_type; /// Type used for file descriptors. typedef int fd_type; static const pmode pstdin = std::ios_base::out; ///< Write to stdin static const pmode pstdout = std::ios_base::in; ///< Read from stdout static const pmode pstderr = std::ios_base::app; ///< Read from stderr protected: enum { bufsz = 32 }; ///< Size of pstreambuf buffers. enum { pbsz = 2 }; ///< Number of putback characters kept. }; /// Class template for stream buffer. template > class basic_pstreambuf : public std::basic_streambuf , public pstreams { public: // Type definitions for dependent types typedef CharT char_type; typedef Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::off_type off_type; typedef typename traits_type::pos_type pos_type; /** @deprecated use pstreams::fd_type instead. */ typedef fd_type fd_t; /// Default constructor. basic_pstreambuf(); /// Constructor that initialises the buffer with @a command. basic_pstreambuf(const std::string& command, pmode mode); /// Constructor that initialises the buffer with @a file and @a argv. basic_pstreambuf( const std::string& file, const argv_type& argv, pmode mode ); /// Destructor. ~basic_pstreambuf(); /// Initialise the stream buffer with @a command. basic_pstreambuf* open(const std::string& command, pmode mode); /// Initialise the stream buffer with @a file and @a argv. basic_pstreambuf* open(const std::string& file, const argv_type& argv, pmode mode); /// Close the stream buffer and wait for the process to exit. basic_pstreambuf* close(); /// Send a signal to the process. basic_pstreambuf* kill(int signal = SIGTERM); /// Send a signal to the process' process group. basic_pstreambuf* killpg(int signal = SIGTERM); /// Close the pipe connected to the process' stdin. void peof(); /// Change active input source. bool read_err(bool readerr = true); /// Report whether the stream buffer has been initialised. bool is_open() const; /// Report whether the process has exited. bool exited(); #if REDI_EVISCERATE_PSTREAMS /// Obtain FILE pointers for each of the process' standard streams. std::size_t fopen(FILE*& in, FILE*& out, FILE*& err); #endif /// Return the exit status of the process. int status() const; /// Return the error number (errno) for the most recent failed operation. int error() const; protected: /// Transfer characters to the pipe when character buffer overflows. int_type overflow(int_type c); /// Transfer characters from the pipe when the character buffer is empty. int_type underflow(); /// Make a character available to be returned by the next extraction. int_type pbackfail(int_type c = traits_type::eof()); /// Write any buffered characters to the stream. int sync(); /// Insert multiple characters into the pipe. std::streamsize xsputn(const char_type* s, std::streamsize n); /// Insert a sequence of characters into the pipe. std::streamsize write(const char_type* s, std::streamsize n); /// Extract a sequence of characters from the pipe. std::streamsize read(char_type* s, std::streamsize n); /// Report how many characters can be read from active input without blocking. std::streamsize showmanyc(); protected: /// Enumerated type to indicate whether stdout or stderr is to be read. enum buf_read_src { rsrc_out = 0, rsrc_err = 1 }; /// Initialise pipes and fork process. pid_t fork(pmode mode); /// Wait for the child process to exit. int wait(bool nohang = false); /// Return the file descriptor for the output pipe. fd_type& wpipe(); /// Return the file descriptor for the active input pipe. fd_type& rpipe(); /// Return the file descriptor for the specified input pipe. fd_type& rpipe(buf_read_src which); void create_buffers(pmode mode); void destroy_buffers(pmode mode); /// Writes buffered characters to the process' stdin pipe. bool empty_buffer(); bool fill_buffer(bool non_blocking = false); /// Return the active input buffer. char_type* rbuffer(); buf_read_src switch_read_buffer(buf_read_src); private: basic_pstreambuf(const basic_pstreambuf&); basic_pstreambuf& operator=(const basic_pstreambuf&); void init_rbuffers(); pid_t ppid_; // pid of process fd_type wpipe_; // pipe used to write to process' stdin fd_type rpipe_[2]; // two pipes to read from, stdout and stderr char_type* wbuffer_; char_type* rbuffer_[2]; char_type* rbufstate_[3]; /// Index into rpipe_[] to indicate active source for read operations. buf_read_src rsrc_; int status_; // hold exit status of child process int error_; // hold errno if fork() or exec() fails }; /// Class template for common base class. template > class pstream_common : virtual public std::basic_ios , virtual public pstreams { protected: typedef basic_pstreambuf streambuf_type; typedef pstreams::pmode pmode; typedef pstreams::argv_type argv_type; /// Default constructor. pstream_common(); /// Constructor that initialises the stream by starting a process. pstream_common(const std::string& command, pmode mode); /// Constructor that initialises the stream by starting a process. pstream_common(const std::string& file, const argv_type& argv, pmode mode); /// Pure virtual destructor. virtual ~pstream_common() = 0; /// Start a process. void do_open(const std::string& command, pmode mode); /// Start a process. void do_open(const std::string& file, const argv_type& argv, pmode mode); public: /// Close the pipe. void close(); /// Report whether the stream's buffer has been initialised. bool is_open() const; /// Return the command used to initialise the stream. const std::string& command() const; /// Return a pointer to the stream buffer. streambuf_type* rdbuf() const; #if REDI_EVISCERATE_PSTREAMS /// Obtain FILE pointers for each of the process' standard streams. std::size_t fopen(FILE*& in, FILE*& out, FILE*& err); #endif protected: std::string command_; ///< The command used to start the process. streambuf_type buf_; ///< The stream buffer. }; /** * @class basic_ipstream * @brief Class template for Input PStreams. * * Reading from an ipstream reads the command's standard output and/or * standard error (depending on how the ipstream is opened) * and the command's standard input is the same as that of the process * that created the object, unless altered by the command itself. */ template > class basic_ipstream : public std::basic_istream , public pstream_common , virtual public pstreams { typedef std::basic_istream istream_type; typedef pstream_common pbase_type; using pbase_type::buf_; // declare name in this scope pmode readable(pmode mode) { if (!(mode & (pstdout|pstderr))) mode |= pstdout; return mode; } public: /// Type used to specify how to connect to the process. typedef typename pbase_type::pmode pmode; /// Type used to hold the arguments for a command. typedef typename pbase_type::argv_type argv_type; /// Default constructor, creates an uninitialised stream. basic_ipstream() : istream_type(NULL), pbase_type() { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ basic_ipstream(const std::string& command, pmode mode = pstdout) : istream_type(NULL), pbase_type(command, readable(mode)) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_ipstream( const std::string& file, const argv_type& argv, pmode mode = pstdout ) : istream_type(NULL), pbase_type(file, argv, readable(mode)) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling * @c do_open(argv[0],argv,mode|pstdout) * * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_ipstream(const argv_type& argv, pmode mode = pstdout) : istream_type(NULL), pbase_type(argv.at(0), argv, mode|pstdout) { } /** * @brief Destructor. * * Closes the stream and waits for the child to exit. */ ~basic_ipstream() { } /** * @brief Start a process. * * Calls do_open( @a %command , @a mode|pstdout ). * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ void open(const std::string& command, pmode mode = pstdout) { this->do_open(command, readable(mode)); } /** * @brief Start a process. * * Calls do_open( @a file , @a argv , @a mode|pstdout ). * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ void open( const std::string& file, const argv_type& argv, pmode mode = pstdout ) { this->do_open(file, argv, readable(mode)); } /** * @brief Set streambuf to read from process' @c stdout. * @return @c *this */ basic_ipstream& out() { this->buf_.read_err(false); return *this; } /** * @brief Set streambuf to read from process' @c stderr. * @return @c *this */ basic_ipstream& err() { this->buf_.read_err(true); return *this; } }; /** * @class basic_opstream * @brief Class template for Output PStreams. * * Writing to an open opstream writes to the standard input of the command; * the command's standard output is the same as that of the process that * created the pstream object, unless altered by the command itself. */ template > class basic_opstream : public std::basic_ostream , public pstream_common , virtual public pstreams { typedef std::basic_ostream ostream_type; typedef pstream_common pbase_type; using pbase_type::buf_; // declare name in this scope public: /// Type used to specify how to connect to the process. typedef typename pbase_type::pmode pmode; /// Type used to hold the arguments for a command. typedef typename pbase_type::argv_type argv_type; /// Default constructor, creates an uninitialised stream. basic_opstream() : ostream_type(NULL), pbase_type() { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ basic_opstream(const std::string& command, pmode mode = pstdin) : ostream_type(NULL), pbase_type(command, mode|pstdin) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_opstream( const std::string& file, const argv_type& argv, pmode mode = pstdin ) : ostream_type(NULL), pbase_type(file, argv, mode|pstdin) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling * @c do_open(argv[0],argv,mode|pstdin) * * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_opstream(const argv_type& argv, pmode mode = pstdin) : ostream_type(NULL), pbase_type(argv.at(0), argv, mode|pstdin) { } /** * @brief Destructor * * Closes the stream and waits for the child to exit. */ ~basic_opstream() { } /** * @brief Start a process. * * Calls do_open( @a %command , @a mode|pstdin ). * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ void open(const std::string& command, pmode mode = pstdin) { this->do_open(command, mode|pstdin); } /** * @brief Start a process. * * Calls do_open( @a file , @a argv , @a mode|pstdin ). * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ void open( const std::string& file, const argv_type& argv, pmode mode = pstdin) { this->do_open(file, argv, mode|pstdin); } }; /** * @class basic_pstream * @brief Class template for Bidirectional PStreams. * * Writing to a pstream opened with @c pmode @c pstdin writes to the * standard input of the command. * Reading from a pstream opened with @c pmode @c pstdout and/or @c pstderr * reads the command's standard output and/or standard error. * Any of the process' @c stdin, @c stdout or @c stderr that is not * connected to the pstream (as specified by the @c pmode) * will be the same as the process that created the pstream object, * unless altered by the command itself. */ template > class basic_pstream : public std::basic_iostream , public pstream_common , virtual public pstreams { typedef std::basic_iostream iostream_type; typedef pstream_common pbase_type; using pbase_type::buf_; // declare name in this scope public: /// Type used to specify how to connect to the process. typedef typename pbase_type::pmode pmode; /// Type used to hold the arguments for a command. typedef typename pbase_type::argv_type argv_type; /// Default constructor, creates an uninitialised stream. basic_pstream() : iostream_type(NULL), pbase_type() { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ basic_pstream(const std::string& command, pmode mode = pstdout|pstdin) : iostream_type(NULL), pbase_type(command, mode) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_pstream( const std::string& file, const argv_type& argv, pmode mode = pstdout|pstdin ) : iostream_type(NULL), pbase_type(file, argv, mode) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling * @c do_open(argv[0],argv,mode) * * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_pstream(const argv_type& argv, pmode mode = pstdout|pstdin) : iostream_type(NULL), pbase_type(argv.at(0), argv, mode) { } /** * @brief Destructor * * Closes the stream and waits for the child to exit. */ ~basic_pstream() { } /** * @brief Start a process. * * Calls do_open( @a %command , @a mode ). * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ void open(const std::string& command, pmode mode = pstdout|pstdin) { this->do_open(command, mode); } /** * @brief Start a process. * * Calls do_open( @a file , @a argv , @a mode ). * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ void open( const std::string& file, const argv_type& argv, pmode mode = pstdout|pstdin ) { this->do_open(file, argv, mode); } /** * @brief Set streambuf to read from process' @c stdout. * @return @c *this */ basic_pstream& out() { this->buf_.read_err(false); return *this; } /** * @brief Set streambuf to read from process' @c stderr. * @return @c *this */ basic_pstream& err() { this->buf_.read_err(true); return *this; } }; /** * @class basic_rpstream * @brief Class template for Restricted PStreams. * * Writing to an rpstream opened with @c pmode @c pstdin writes to the * standard input of the command. * It is not possible to read directly from an rpstream object, to use * an rpstream as in istream you must call either basic_rpstream::out() * or basic_rpstream::err(). This is to prevent accidental reads from * the wrong input source. If the rpstream was not opened with @c pmode * @c pstderr then the class cannot read the process' @c stderr, and * basic_rpstream::err() will return an istream that reads from the * process' @c stdout, and vice versa. * Reading from an rpstream opened with @c pmode @c pstdout and/or * @c pstderr reads the command's standard output and/or standard error. * Any of the process' @c stdin, @c stdout or @c stderr that is not * connected to the pstream (as specified by the @c pmode) * will be the same as the process that created the pstream object, * unless altered by the command itself. */ template > class basic_rpstream : public std::basic_ostream , private std::basic_istream , private pstream_common , virtual public pstreams { typedef std::basic_ostream ostream_type; typedef std::basic_istream istream_type; typedef pstream_common pbase_type; using pbase_type::buf_; // declare name in this scope public: /// Type used to specify how to connect to the process. typedef typename pbase_type::pmode pmode; /// Type used to hold the arguments for a command. typedef typename pbase_type::argv_type argv_type; /// Default constructor, creates an uninitialised stream. basic_rpstream() : ostream_type(NULL), istream_type(NULL), pbase_type() { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ basic_rpstream(const std::string& command, pmode mode = pstdout|pstdin) : ostream_type(NULL) , istream_type(NULL) , pbase_type(command, mode) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling do_open() with the supplied * arguments. * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_rpstream( const std::string& file, const argv_type& argv, pmode mode = pstdout|pstdin ) : ostream_type(NULL), istream_type(NULL), pbase_type(file, argv, mode) { } /** * @brief Constructor that initialises the stream by starting a process. * * Initialises the stream buffer by calling * @c do_open(argv[0],argv,mode) * * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ basic_rpstream(const argv_type& argv, pmode mode = pstdout|pstdin) : ostream_type(NULL), istream_type(NULL), pbase_type(argv.at(0), argv, mode) { } /// Destructor ~basic_rpstream() { } /** * @brief Start a process. * * Calls do_open( @a %command , @a mode ). * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ void open(const std::string& command, pmode mode = pstdout|pstdin) { this->do_open(command, mode); } /** * @brief Start a process. * * Calls do_open( @a file , @a argv , @a mode ). * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ void open( const std::string& file, const argv_type& argv, pmode mode = pstdout|pstdin ) { this->do_open(file, argv, mode); } /** * @brief Obtain a reference to the istream that reads * the process' @c stdout. * @return @c *this */ istream_type& out() { this->buf_.read_err(false); return *this; } /** * @brief Obtain a reference to the istream that reads * the process' @c stderr. * @return @c *this */ istream_type& err() { this->buf_.read_err(true); return *this; } }; /// Type definition for common template specialisation. typedef basic_pstreambuf pstreambuf; /// Type definition for common template specialisation. typedef basic_ipstream ipstream; /// Type definition for common template specialisation. typedef basic_opstream opstream; /// Type definition for common template specialisation. typedef basic_pstream pstream; /// Type definition for common template specialisation. typedef basic_rpstream rpstream; /** * When inserted into an output pstream the manipulator calls * basic_pstreambuf::peof() to close the output pipe, * causing the child process to receive the end-of-file indicator * on subsequent reads from its @c stdin stream. * * @brief Manipulator to close the pipe connected to the process' stdin. * @param s An output PStream class. * @return The stream object the manipulator was invoked on. * @see basic_pstreambuf::peof() * @relates basic_opstream basic_pstream basic_rpstream */ template inline std::basic_ostream& peof(std::basic_ostream& s) { typedef basic_pstreambuf pstreambuf; if (pstreambuf* p = dynamic_cast(s.rdbuf())) p->peof(); return s; } /* * member definitions for pstreambuf */ /** * @class basic_pstreambuf * Provides underlying streambuf functionality for the PStreams classes. */ /** Creates an uninitialised stream buffer. */ template inline basic_pstreambuf::basic_pstreambuf() : ppid_(-1) // initialise to -1 to indicate no process run yet. , wpipe_(-1) , wbuffer_(NULL) , rsrc_(rsrc_out) , status_(-1) , error_(0) { init_rbuffers(); } /** * Initialises the stream buffer by calling open() with the supplied * arguments. * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see open() */ template inline basic_pstreambuf::basic_pstreambuf(const std::string& command, pmode mode) : ppid_(-1) // initialise to -1 to indicate no process run yet. , wpipe_(-1) , wbuffer_(NULL) , rsrc_(rsrc_out) , status_(-1) , error_(0) { init_rbuffers(); open(command, mode); } /** * Initialises the stream buffer by calling open() with the supplied * arguments. * * @param file a string containing the name of a program to execute. * @param argv a vector of argument strings passsed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see open() */ template inline basic_pstreambuf::basic_pstreambuf( const std::string& file, const argv_type& argv, pmode mode ) : ppid_(-1) // initialise to -1 to indicate no process run yet. , wpipe_(-1) , wbuffer_(NULL) , rsrc_(rsrc_out) , status_(-1) , error_(0) { init_rbuffers(); open(file, argv, mode); } /** * Closes the stream by calling close(). * @see close() */ template inline basic_pstreambuf::~basic_pstreambuf() { close(); } /** * Starts a new process by passing @a command to the shell (/bin/sh) * and opens pipes to the process with the specified @a mode. * * If @a mode contains @c pstdout the initial read source will be * the child process' stdout, otherwise if @a mode contains @c pstderr * the initial read source will be the child's stderr. * * Will duplicate the actions of the shell in searching for an * executable file if the specified file name does not contain a slash (/) * character. * * @warning * There is no way to tell whether the shell command succeeded, this * function will always succeed unless resource limits (such as * memory usage, or number of processes or open files) are exceeded. * This means is_open() will return true even if @a command cannot * be executed. * Use pstreambuf::open(const std::string&, const argv_type&, pmode) * if you need to know whether the command failed to execute. * * @param command a string containing a shell command. * @param mode a bitwise OR of one or more of @c out, @c in, @c err. * @return NULL if the shell could not be started or the * pipes could not be opened, @c this otherwise. * @see execl(3) */ template basic_pstreambuf* basic_pstreambuf::open(const std::string& command, pmode mode) { const char * shell_path = "/bin/sh"; #if 0 const std::string argv[] = { "sh", "-c", command }; return this->open(shell_path, argv_type(argv, argv+3), mode); #else basic_pstreambuf* ret = NULL; if (!is_open()) { switch(fork(mode)) { case 0 : // this is the new process, exec command ::execl(shell_path, "sh", "-c", command.c_str(), (char*)NULL); // can only reach this point if exec() failed // parent can get exit code from waitpid() ::_exit(errno); // using std::exit() would make static dtors run twice case -1 : // couldn't fork, error already handled in pstreambuf::fork() break; default : // this is the parent process // activate buffers create_buffers(mode); ret = this; } } return ret; #endif } /** * @brief Helper function to close a file descriptor. * * Inspects @a fd and calls close(3) if it has a non-negative value. * * @param fd a file descriptor. * @relates basic_pstreambuf */ inline void close_fd(pstreams::fd_type& fd) { if (fd >= 0 && ::close(fd) == 0) fd = -1; } /** * @brief Helper function to close an array of file descriptors. * * Calls @c close_fd() on each member of the array. * The length of the array is determined automatically by * template argument deduction to avoid errors. * * @param fds an array of file descriptors. * @relates basic_pstreambuf */ template inline void close_fd_array(pstreams::fd_type (&fds)[N]) { for (std::size_t i = 0; i < N; ++i) close_fd(fds[i]); } /** * Starts a new process by executing @a file with the arguments in * @a argv and opens pipes to the process with the specified @a mode. * * By convention @c argv[0] should be the file name of the file being * executed. * * If @a mode contains @c pstdout the initial read source will be * the child process' stdout, otherwise if @a mode contains @c pstderr * the initial read source will be the child's stderr. * * Will duplicate the actions of the shell in searching for an * executable file if the specified file name does not contain a slash (/) * character. * * Iff @a file is successfully executed then is_open() will return true. * Otherwise, pstreambuf::error() can be used to obtain the value of * @c errno that was set by execvp(3) in the child process. * * The exit status of the new process will be returned by * pstreambuf::status() after pstreambuf::exited() returns true. * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode a bitwise OR of one or more of @c out, @c in and @c err. * @return NULL if a pipe could not be opened or if the program could * not be executed, @c this otherwise. * @see execvp(3) */ template basic_pstreambuf* basic_pstreambuf::open( const std::string& file, const argv_type& argv, pmode mode ) { basic_pstreambuf* ret = NULL; if (!is_open()) { // constants for read/write ends of pipe enum { RD, WR }; // open another pipe and set close-on-exec fd_type ck_exec[] = { -1, -1 }; if (-1 == ::pipe(ck_exec) || -1 == ::fcntl(ck_exec[RD], F_SETFD, FD_CLOEXEC) || -1 == ::fcntl(ck_exec[WR], F_SETFD, FD_CLOEXEC)) { error_ = errno; close_fd_array(ck_exec); } else { switch(fork(mode)) { case 0 : // this is the new process, exec command { char** arg_v = new char*[argv.size()+1]; for (std::size_t i = 0; i < argv.size(); ++i) { const std::string& src = argv[i]; char*& dest = arg_v[i]; dest = new char[src.size()+1]; dest[ src.copy(dest, src.size()) ] = '\0'; } arg_v[argv.size()] = NULL; ::execvp(file.c_str(), arg_v); // can only reach this point if exec() failed // parent can get error code from ck_exec pipe error_ = errno; while (::write(ck_exec[WR], &error_, sizeof(error_)) == -1 && errno == EINTR) { } ::close(ck_exec[WR]); ::close(ck_exec[RD]); ::_exit(error_); // using std::exit() would make static dtors run twice } case -1 : // couldn't fork, error already handled in pstreambuf::fork() close_fd_array(ck_exec); break; default : // this is the parent process // check child called exec() successfully ::close(ck_exec[WR]); switch (::read(ck_exec[RD], &error_, sizeof(error_))) { case 0: // activate buffers create_buffers(mode); ret = this; break; case -1: error_ = errno; break; default: // error_ contains error code from child // call wait() to clean up and set ppid_ to 0 this->wait(); break; } ::close(ck_exec[RD]); } } } return ret; } /** * Creates pipes as specified by @a mode and calls @c fork() to create * a new process. If the fork is successful the parent process stores * the child's PID and the opened pipes and the child process replaces * its standard streams with the opened pipes. * * If an error occurs the error code will be set to one of the possible * errors for @c pipe() or @c fork(). * See your system's documentation for these error codes. * * @param mode an OR of pmodes specifying which of the child's * standard streams to connect to. * @return On success the PID of the child is returned in the parent's * context and zero is returned in the child's context. * On error -1 is returned and the error code is set appropriately. */ template pid_t basic_pstreambuf::fork(pmode mode) { pid_t pid = -1; // Three pairs of file descriptors, for pipes connected to the // process' stdin, stdout and stderr // (stored in a single array so close_fd_array() can close all at once) fd_type fd[] = { -1, -1, -1, -1, -1, -1 }; fd_type* const pin = fd; fd_type* const pout = fd+2; fd_type* const perr = fd+4; // constants for read/write ends of pipe enum { RD, WR }; // N.B. // For the pstreambuf pin is an output stream and // pout and perr are input streams. if (!error_ && mode&pstdin && ::pipe(pin)) error_ = errno; if (!error_ && mode&pstdout && ::pipe(pout)) error_ = errno; if (!error_ && mode&pstderr && ::pipe(perr)) error_ = errno; if (!error_) { pid = ::fork(); switch (pid) { case 0 : { // this is the new process // for each open pipe close one end and redirect the // respective standard stream to the other end if (*pin >= 0) { ::close(pin[WR]); ::dup2(pin[RD], STDIN_FILENO); ::close(pin[RD]); } if (*pout >= 0) { ::close(pout[RD]); ::dup2(pout[WR], STDOUT_FILENO); ::close(pout[WR]); } if (*perr >= 0) { ::close(perr[RD]); ::dup2(perr[WR], STDERR_FILENO); ::close(perr[WR]); } #ifdef _POSIX_JOB_CONTROL // Change to a new process group ::setpgid(0, 0); #endif break; } case -1 : { // couldn't fork for some reason error_ = errno; // close any open pipes close_fd_array(fd); break; } default : { // this is the parent process, store process' pid ppid_ = pid; // store one end of open pipes and close other end if (*pin >= 0) { wpipe_ = pin[WR]; ::close(pin[RD]); } if (*pout >= 0) { rpipe_[rsrc_out] = pout[RD]; ::close(pout[WR]); } if (*perr >= 0) { rpipe_[rsrc_err] = perr[RD]; ::close(perr[WR]); } } } } else { // close any pipes we opened before failure close_fd_array(fd); } return pid; } /** * Closes all pipes and calls wait() to wait for the process to finish. * If an error occurs the error code will be set to one of the possible * errors for @c waitpid(). * See your system's documentation for these errors. * * @return @c this on successful close or @c NULL if there is no * process to close or if an error occurs. */ template basic_pstreambuf* basic_pstreambuf::close() { const bool running = is_open(); sync(); // this might call wait() and reap the child process // rather than trying to work out whether or not we need to clean up // just do it anyway, all cleanup functions are safe to call twice. destroy_buffers(pstdin|pstdout|pstderr); // close pipes before wait() so child gets EOF/SIGPIPE close_fd(wpipe_); close_fd_array(rpipe_); do { error_ = 0; } while (wait() == -1 && error() == EINTR); return running ? this : NULL; } /** * Called on construction to initialise the arrays used for reading. */ template inline void basic_pstreambuf::init_rbuffers() { rpipe_[rsrc_out] = rpipe_[rsrc_err] = -1; rbuffer_[rsrc_out] = rbuffer_[rsrc_err] = NULL; rbufstate_[0] = rbufstate_[1] = rbufstate_[2] = NULL; } template void basic_pstreambuf::create_buffers(pmode mode) { if (mode & pstdin) { delete[] wbuffer_; wbuffer_ = new char_type[bufsz]; this->setp(wbuffer_, wbuffer_ + bufsz); } if (mode & pstdout) { delete[] rbuffer_[rsrc_out]; rbuffer_[rsrc_out] = new char_type[bufsz]; rsrc_ = rsrc_out; this->setg(rbuffer_[rsrc_out] + pbsz, rbuffer_[rsrc_out] + pbsz, rbuffer_[rsrc_out] + pbsz); } if (mode & pstderr) { delete[] rbuffer_[rsrc_err]; rbuffer_[rsrc_err] = new char_type[bufsz]; if (!(mode & pstdout)) { rsrc_ = rsrc_err; this->setg(rbuffer_[rsrc_err] + pbsz, rbuffer_[rsrc_err] + pbsz, rbuffer_[rsrc_err] + pbsz); } } } template void basic_pstreambuf::destroy_buffers(pmode mode) { if (mode & pstdin) { this->setp(NULL, NULL); delete[] wbuffer_; wbuffer_ = NULL; } if (mode & pstdout) { if (rsrc_ == rsrc_out) this->setg(NULL, NULL, NULL); delete[] rbuffer_[rsrc_out]; rbuffer_[rsrc_out] = NULL; } if (mode & pstderr) { if (rsrc_ == rsrc_err) this->setg(NULL, NULL, NULL); delete[] rbuffer_[rsrc_err]; rbuffer_[rsrc_err] = NULL; } } template typename basic_pstreambuf::buf_read_src basic_pstreambuf::switch_read_buffer(buf_read_src src) { if (rsrc_ != src) { char_type* tmpbufstate[] = {this->eback(), this->gptr(), this->egptr()}; this->setg(rbufstate_[0], rbufstate_[1], rbufstate_[2]); for (std::size_t i = 0; i < 3; ++i) rbufstate_[i] = tmpbufstate[i]; rsrc_ = src; } return rsrc_; } /** * Suspends execution and waits for the associated process to exit, or * until a signal is delivered whose action is to terminate the current * process or to call a signal handling function. If the process has * already exited (i.e. it is a "zombie" process) then wait() returns * immediately. Waiting for the child process causes all its system * resources to be freed. * * error() will return EINTR if wait() is interrupted by a signal. * * @param nohang true to return immediately if the process has not exited. * @return 1 if the process has exited and wait() has not yet been called. * 0 if @a nohang is true and the process has not exited yet. * -1 if no process has been started or if an error occurs, * in which case the error can be found using error(). */ template int basic_pstreambuf::wait(bool nohang) { int exited = -1; if (is_open()) { int status; switch(::waitpid(ppid_, &status, nohang ? WNOHANG : 0)) { case 0 : // nohang was true and process has not exited exited = 0; break; case -1 : error_ = errno; break; default : // process has exited ppid_ = 0; status_ = status; exited = 1; // Close wpipe, would get SIGPIPE if we used it. destroy_buffers(pstdin); close_fd(wpipe_); // Must free read buffers and pipes on destruction // or next call to open()/close() break; } } return exited; } /** * Sends the specified signal to the process. A signal can be used to * terminate a child process that would not exit otherwise. * * If an error occurs the error code will be set to one of the possible * errors for @c kill(). See your system's documentation for these errors. * * @param signal A signal to send to the child process. * @return @c this or @c NULL if @c kill() fails. */ template inline basic_pstreambuf* basic_pstreambuf::kill(int signal) { basic_pstreambuf* ret = NULL; if (is_open()) { if (::kill(ppid_, signal)) error_ = errno; else { #if 0 // TODO call exited() to check for exit and clean up? leave to user? if (signal==SIGTERM || signal==SIGKILL) this->exited(); #endif ret = this; } } return ret; } /** * Sends the specified signal to the process group of the child process. * A signal can be used to terminate a child process that would not exit * otherwise, or to kill the process and its own children. * * If an error occurs the error code will be set to one of the possible * errors for @c getpgid() or @c kill(). See your system's documentation * for these errors. If the child is in the current process group then * NULL will be returned and the error code set to EPERM. * * @param signal A signal to send to the child process. * @return @c this on success or @c NULL on failure. */ template inline basic_pstreambuf* basic_pstreambuf::killpg(int signal) { basic_pstreambuf* ret = NULL; #ifdef _POSIX_JOB_CONTROL if (is_open()) { pid_t pgid = ::getpgid(ppid_); if (pgid == -1) error_ = errno; else if (pgid == ::getpgrp()) error_ = EPERM; // Don't commit suicide else if (::killpg(pgid, signal)) error_ = errno; else ret = this; } #endif return ret; } /** * This function can call pstreambuf::wait() and so may change the * object's state if the child process has already exited. * * @return True if the associated process has exited, false otherwise. * @see basic_pstreambuf::wait() */ template inline bool basic_pstreambuf::exited() { return ppid_ == 0 || wait(true)==1; } /** * @return The exit status of the child process, or -1 if wait() * has not yet been called to wait for the child to exit. * @see basic_pstreambuf::wait() */ template inline int basic_pstreambuf::status() const { return status_; } /** * @return The error code of the most recently failed operation, or zero. */ template inline int basic_pstreambuf::error() const { return error_; } /** * Closes the output pipe, causing the child process to receive the * end-of-file indicator on subsequent reads from its @c stdin stream. */ template inline void basic_pstreambuf::peof() { sync(); destroy_buffers(pstdin); close_fd(wpipe_); } /** * Unlike pstreambuf::exited(), this function will not call wait() and * so will not change the object's state. This means that once a child * process is executed successfully this function will continue to * return true even after the process exits (until wait() is called.) * * @return true if a previous call to open() succeeded and wait() has * not been called and determined that the process has exited, * false otherwise. */ template inline bool basic_pstreambuf::is_open() const { return ppid_ > 0; } /** * Toggle the stream used for reading. If @a readerr is @c true then the * process' @c stderr output will be used for subsequent extractions, if * @a readerr is false the the process' stdout will be used. * @param readerr @c true to read @c stderr, @c false to read @c stdout. * @return @c true if the requested stream is open and will be used for * subsequent extractions, @c false otherwise. */ template inline bool basic_pstreambuf::read_err(bool readerr) { buf_read_src src = readerr ? rsrc_err : rsrc_out; if (rpipe_[src]>=0) { switch_read_buffer(src); return true; } return false; } /** * Called when the internal character buffer is not present or is full, * to transfer the buffer contents to the pipe. * * @param c a character to be written to the pipe. * @return @c traits_type::eof() if an error occurs, otherwise if @a c * is not equal to @c traits_type::eof() it will be buffered and * a value other than @c traits_type::eof() returned to indicate * success. */ template typename basic_pstreambuf::int_type basic_pstreambuf::overflow(int_type c) { if (!empty_buffer()) return traits_type::eof(); else if (!traits_type::eq_int_type(c, traits_type::eof())) return this->sputc(c); else return traits_type::not_eof(c); } template int basic_pstreambuf::sync() { return !exited() && empty_buffer() ? 0 : -1; } /** * @param s character buffer. * @param n buffer length. * @return the number of characters written. */ template std::streamsize basic_pstreambuf::xsputn(const char_type* s, std::streamsize n) { std::streamsize done = 0; while (done < n) { if (std::streamsize nbuf = this->epptr() - this->pptr()) { nbuf = std::min(nbuf, n - done); traits_type::copy(this->pptr(), s + done, nbuf); this->pbump(nbuf); done += nbuf; } else if (!empty_buffer()) break; } return done; } /** * @return true if the buffer was emptied, false otherwise. */ template bool basic_pstreambuf::empty_buffer() { const std::streamsize count = this->pptr() - this->pbase(); if (count > 0) { const std::streamsize written = this->write(this->wbuffer_, count); if (written > 0) { if (const std::streamsize unwritten = count - written) traits_type::move(this->pbase(), this->pbase()+written, unwritten); this->pbump(-written); return true; } } return false; } /** * Called when the internal character buffer is is empty, to re-fill it * from the pipe. * * @return The first available character in the buffer, * or @c traits_type::eof() in case of failure. */ template typename basic_pstreambuf::int_type basic_pstreambuf::underflow() { if (this->gptr() < this->egptr() || fill_buffer()) return traits_type::to_int_type(*this->gptr()); else return traits_type::eof(); } /** * Attempts to make @a c available as the next character to be read by * @c sgetc(). * * @param c a character to make available for extraction. * @return @a c if the character can be made available, * @c traits_type::eof() otherwise. */ template typename basic_pstreambuf::int_type basic_pstreambuf::pbackfail(int_type c) { if (this->gptr() != this->eback()) { this->gbump(-1); if (!traits_type::eq_int_type(c, traits_type::eof())) *this->gptr() = traits_type::to_char_type(c); return traits_type::not_eof(c); } else return traits_type::eof(); } template std::streamsize basic_pstreambuf::showmanyc() { int avail = 0; if (sizeof(char_type) == 1) avail = fill_buffer(true) ? this->egptr() - this->gptr() : -1; #ifdef FIONREAD else { if (::ioctl(rpipe(), FIONREAD, &avail) == -1) avail = -1; else if (avail) avail /= sizeof(char_type); } #endif return std::streamsize(avail); } /** * @return true if the buffer was filled, false otherwise. */ template bool basic_pstreambuf::fill_buffer(bool non_blocking) { const std::streamsize pb1 = this->gptr() - this->eback(); const std::streamsize pb2 = pbsz; const std::streamsize npb = std::min(pb1, pb2); char_type* const rbuf = rbuffer(); traits_type::move(rbuf + pbsz - npb, this->gptr() - npb, npb); std::streamsize rc = -1; if (non_blocking) { const int flags = ::fcntl(rpipe(), F_GETFL); if (flags != -1) { const bool blocking = !(flags & O_NONBLOCK); if (blocking) ::fcntl(rpipe(), F_SETFL, flags | O_NONBLOCK); // set non-blocking error_ = 0; rc = read(rbuf + pbsz, bufsz - pbsz); if (rc == -1 && error_ == EAGAIN) // nothing available rc = 0; else if (rc == 0) // EOF rc = -1; if (blocking) ::fcntl(rpipe(), F_SETFL, flags); // restore } } else rc = read(rbuf + pbsz, bufsz - pbsz); if (rc > 0 || (rc == 0 && non_blocking)) { this->setg( rbuf + pbsz - npb, rbuf + pbsz, rbuf + pbsz + rc ); return true; } else { this->setg(NULL, NULL, NULL); return false; } } /** * Writes up to @a n characters to the pipe from the buffer @a s. * * @param s character buffer. * @param n buffer length. * @return the number of characters written. */ template inline std::streamsize basic_pstreambuf::write(const char_type* s, std::streamsize n) { std::streamsize nwritten = 0; if (wpipe() >= 0) { nwritten = ::write(wpipe(), s, n * sizeof(char_type)); if (nwritten == -1) error_ = errno; else nwritten /= sizeof(char_type); } return nwritten; } /** * Reads up to @a n characters from the pipe to the buffer @a s. * * @param s character buffer. * @param n buffer length. * @return the number of characters read. */ template inline std::streamsize basic_pstreambuf::read(char_type* s, std::streamsize n) { std::streamsize nread = 0; if (rpipe() >= 0) { nread = ::read(rpipe(), s, n * sizeof(char_type)); if (nread == -1) error_ = errno; else nread /= sizeof(char_type); } return nread; } /** @return a reference to the output file descriptor */ template inline pstreams::fd_type& basic_pstreambuf::wpipe() { return wpipe_; } /** @return a reference to the active input file descriptor */ template inline pstreams::fd_type& basic_pstreambuf::rpipe() { return rpipe_[rsrc_]; } /** @return a reference to the specified input file descriptor */ template inline pstreams::fd_type& basic_pstreambuf::rpipe(buf_read_src which) { return rpipe_[which]; } /** @return a pointer to the start of the active input buffer area. */ template inline typename basic_pstreambuf::char_type* basic_pstreambuf::rbuffer() { return rbuffer_[rsrc_]; } /* * member definitions for pstream_common */ /** * @class pstream_common * Abstract Base Class providing common functionality for basic_ipstream, * basic_opstream and basic_pstream. * pstream_common manages the basic_pstreambuf stream buffer that is used * by the derived classes to initialise an iostream class. */ /** Creates an uninitialised stream. */ template inline pstream_common::pstream_common() : std::basic_ios(NULL) , command_() , buf_() { this->std::basic_ios::rdbuf(&buf_); } /** * Initialises the stream buffer by calling * do_open( @a command , @a mode ) * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ template inline pstream_common::pstream_common(const std::string& command, pmode mode) : std::basic_ios(NULL) , command_(command) , buf_() { this->std::basic_ios::rdbuf(&buf_); do_open(command, mode); } /** * Initialises the stream buffer by calling * do_open( @a file , @a argv , @a mode ) * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ template inline pstream_common::pstream_common( const std::string& file, const argv_type& argv, pmode mode ) : std::basic_ios(NULL) , command_(file) , buf_() { this->std::basic_ios::rdbuf(&buf_); do_open(file, argv, mode); } /** * This is a pure virtual function to make @c pstream_common abstract. * Because it is the destructor it will be called by derived classes * and so must be defined. It is also protected, to discourage use of * the PStreams classes through pointers or references to the base class. * * @sa If defining a pure virtual seems odd you should read * http://www.gotw.ca/gotw/031.htm (and the rest of the site as well!) */ template inline pstream_common::~pstream_common() { } /** * Calls rdbuf()->open( @a command , @a mode ) * and sets @c failbit on error. * * @param command a string containing a shell command. * @param mode the I/O mode to use when opening the pipe. * @see basic_pstreambuf::open(const std::string&, pmode) */ template inline void pstream_common::do_open(const std::string& command, pmode mode) { if (!buf_.open((command_=command), mode)) this->setstate(std::ios_base::failbit); } /** * Calls rdbuf()->open( @a file, @a argv, @a mode ) * and sets @c failbit on error. * * @param file a string containing the pathname of a program to execute. * @param argv a vector of argument strings passed to the new program. * @param mode the I/O mode to use when opening the pipe. * @see basic_pstreambuf::open(const std::string&, const argv_type&, pmode) */ template inline void pstream_common::do_open( const std::string& file, const argv_type& argv, pmode mode ) { if (!buf_.open((command_=file), argv, mode)) this->setstate(std::ios_base::failbit); } /** Calls rdbuf->close() and sets @c failbit on error. */ template inline void pstream_common::close() { if (!buf_.close()) this->setstate(std::ios_base::failbit); } /** * @return rdbuf()->is_open(). * @see basic_pstreambuf::is_open() */ template inline bool pstream_common::is_open() const { return buf_.is_open(); } /** @return a string containing the command used to initialise the stream. */ template inline const std::string& pstream_common::command() const { return command_; } /** @return a pointer to the private stream buffer member. */ // TODO document behaviour if buffer replaced. template inline typename pstream_common::streambuf_type* pstream_common::rdbuf() const { return const_cast(&buf_); } #if REDI_EVISCERATE_PSTREAMS /** * @def REDI_EVISCERATE_PSTREAMS * If this macro has a non-zero value then certain internals of the * @c basic_pstreambuf template class are exposed. In general this is * a Bad Thing, as the internal implementation is largely undocumented * and may be subject to change at any time, so this feature is only * provided because it might make PStreams useful in situations where * it is necessary to do Bad Things. */ /** * @warning This function exposes the internals of the stream buffer and * should be used with caution. It is the caller's responsibility * to flush streams etc. in order to clear any buffered data. * The POSIX.1 function fdopen(3) is used to obtain the * @c FILE pointers from the streambuf's private file descriptor * members so consult your system's documentation for * fdopen(3). * * @param in A FILE* that will refer to the process' stdin. * @param out A FILE* that will refer to the process' stdout. * @param err A FILE* that will refer to the process' stderr. * @return An OR of zero or more of @c pstdin, @c pstdout, @c pstderr. * * For each open stream shared with the child process a @c FILE* is * obtained and assigned to the corresponding parameter. For closed * streams @c NULL is assigned to the parameter. * The return value can be tested to see which parameters should be * @c !NULL by masking with the corresponding @c pmode value. * * @see fdopen(3) */ template std::size_t basic_pstreambuf::fopen(FILE*& in, FILE*& out, FILE*& err) { in = out = err = NULL; std::size_t open_files = 0; if (wpipe() > -1) { if ((in = ::fdopen(wpipe(), "w"))) { open_files |= pstdin; } } if (rpipe(rsrc_out) > -1) { if ((out = ::fdopen(rpipe(rsrc_out), "r"))) { open_files |= pstdout; } } if (rpipe(rsrc_err) > -1) { if ((err = ::fdopen(rpipe(rsrc_err), "r"))) { open_files |= pstderr; } } return open_files; } /** * @warning This function exposes the internals of the stream buffer and * should be used with caution. * * @param in A FILE* that will refer to the process' stdin. * @param out A FILE* that will refer to the process' stdout. * @param err A FILE* that will refer to the process' stderr. * @return A bitwise-or of zero or more of @c pstdin, @c pstdout, @c pstderr. * @see basic_pstreambuf::fopen() */ template inline std::size_t pstream_common::fopen(FILE*& fin, FILE*& fout, FILE*& ferr) { return buf_.fopen(fin, fout, ferr); } #endif // REDI_EVISCERATE_PSTREAMS } // namespace redi /** * @mainpage PStreams Reference * @htmlinclude mainpage.html */ #endif // REDI_PSTREAM_H_SEEN // vim: ts=2 sw=2 expandtab pstreams-0.8.0/ChangeLog0000664000076400007640000012751412125363352013605 0ustar redirediAuthor: Jonathan Wakely Date: Fri Mar 29 19:07:19 2013 +0000 Makefile: Fix rule to not fail if no .git dir Author: Jonathan Wakely Date: Fri Mar 29 17:50:32 2013 +0000 .gitignore: Add dist files Author: Jonathan Wakely Date: Fri Mar 29 17:42:22 2013 +0000 pstream.h: Doc tweak Author: Jonathan Wakely Date: Fri Mar 29 15:48:29 2013 +0000 Makefile: Generate ChangeLog from Git Author: Jonathan Wakely Date: Fri Mar 29 15:16:39 2013 +0000 README: Note another improvement. Author: Jonathan Wakely Date: Wed Jan 23 00:43:11 2013 +0000 pstream.h: Put child in new process group and define pstreambuf::killpg() Thanks to Hein-Pieter van Braam for the suggestion. Author: Jonathan Wakely Date: Sun Jan 20 19:15:41 2013 +0000 pstream.h: Retry interrupted writes Author: Jonathan Wakely Date: Sun Jan 20 18:23:49 2013 +0000 Makefile: remove unused variable Author: Jonathan Wakely Date: Sun Jan 20 17:11:27 2013 +0000 pstream.h: Overload constructors for convenience. Bump version to 0.7.3 Author: Jonathan Wakely Date: Mon Jun 25 22:57:26 2012 +0100 pstream.h: Update copyright years and remove RCSID. Author: Jonathan Wakely Date: Mon Jun 25 22:48:53 2012 +0100 pstream.h (pstreambuf::xsputn): Optimize. Author: Jonathan Wakely Date: Mon Jun 25 22:20:48 2012 +0100 Remove outdated TODO comments. Author: Jonathan Wakely Date: Mon Jun 25 10:39:29 2012 +0000 Makefile: use order-only prerequisite to generate test file. Author: Jonathan Wakely Date: Sun Jun 24 13:03:43 2012 +0100 pstream.h (basic_pstreambuf::open): Work with _FORTIFY_SOURCE. Author: Jonathan Wakely Date: Sun Jun 24 13:02:03 2012 +0100 mainpage.html: Bump version. .gitignore: Add. Author: Jonathan Wakely Date: Sat Apr 14 14:23:51 2012 +0100 * Makefile: Fix typo in comment. Author: Jonathan Wakely Date: Tue Nov 15 11:12:10 2011 +0000 (basic_pstreambuf::wpipe, basic_pstreambuf::rpipe): Fix for clang. (PSTREAMS_VERSION): Bump to 0.7.2 Author: Jonathan Wakely Date: Thu Oct 14 21:38:38 2010 +0000 * pstreams-devel.spec: Update version and change make variable. Author: Jonathan Wakely Date: Thu Oct 14 21:35:22 2010 +0000 * Makefile: Extract version from header. * mainpage.html: Update version. Author: Jonathan Wakely Date: Thu Oct 14 19:57:41 2010 +0000 * pstream.h, test_pstreams.cc: Update copyright dates. Author: Jonathan Wakely Date: Thu Oct 14 19:55:19 2010 +0000 * pstream.h (pstreams_common::pstreams_common): Use basic_ios::rdbuf to set the streambuf, basic_ios::init(0) has already been called. Author: Jonathan Wakely Date: Wed May 12 15:45:21 2010 +0000 Add spec file to tarball Author: Jonathan Wakely Date: Wed May 12 15:37:34 2010 +0000 Fix spec file Author: Jonathan Wakely Date: Wed May 12 13:36:17 2010 +0000 Update. Author: Jonathan Wakely Date: Wed May 12 13:33:54 2010 +0000 Update version to 0.7.0 for release. Author: Jonathan Wakely Date: Wed May 12 13:17:14 2010 +0000 Use new name for cvs2cl script. Author: Jonathan Wakely Date: Wed May 12 12:45:25 2010 +0000 Add spec file from Fedora 12 Author: Jonathan Wakely Date: Sat Mar 20 14:54:35 2010 +0000 Test initial mode set correctly for ipstream. Author: Jonathan Wakely Date: Sat Mar 20 14:50:47 2010 +0000 Improve documentation for semantics of overflow. Author: Jonathan Wakely Date: Sat Mar 20 14:47:09 2010 +0000 Remove preprocessor check for Sun CC and define typedefs unconditionally. Author: Jonathan Wakely Date: Sat Mar 20 14:40:59 2010 +0000 Document previous change to initial read source. Author: Jonathan Wakely Date: Sat Mar 20 14:36:50 2010 +0000 Don't add pstdout to ipstream mode if pstderr given. Set initial mode correctly on open. Bump version to 0.7.0 due to change in behaviour. Author: Jonathan Wakely Date: Wed Sep 23 15:53:09 2009 +0000 Remove std qualifiers on FILE as is included and not . Author: Jonathan Wakely Date: Wed Sep 23 15:50:34 2009 +0000 Add 'check' target and make 'test' a synonym. Author: Jonathan Wakely Date: Mon Dec 15 00:02:04 2008 +0000 Add optimization to CXXFLAGS to get uninitialized warnings from gcc. Author: Jonathan Wakely Date: Mon Dec 15 00:00:18 2008 +0000 Replace 'whoami' with 'id -un' for Solaris portability. Author: Jonathan Wakely Date: Fri Nov 21 01:26:17 2008 +0000 Follow GNU make conventions. Author: Jonathan Wakely Date: Fri Nov 21 01:05:44 2008 +0000 Support DESTDIR and preserve timestamps, thanks to Till Maas. Author: Jonathan Wakely Date: Mon Sep 22 20:04:38 2008 +0000 Bug 2118980: Use more portable UTF-32 as iconv target. Author: Jonathan Wakely Date: Mon Sep 22 19:58:58 2008 +0000 Fix bug 2118980: generate dependency for test_pstreams Author: Jonathan Wakely Date: Sat Jul 12 17:25:07 2008 +0000 Change capitalistion. Author: Jonathan Wakely Date: Wed Jul 9 22:39:41 2008 +0000 Mention licence change! Author: Jonathan Wakely Date: Wed Jul 9 22:12:08 2008 +0000 Tweak comments. Author: Jonathan Wakely Date: Wed Jul 9 22:05:08 2008 +0000 Add example. Author: Jonathan Wakely Date: Mon Jul 7 22:33:17 2008 +0000 Only show trunk in ChangeLog. Author: Jonathan Wakely Date: Mon Jul 7 22:25:47 2008 +0000 Version to 0.6.0 Author: Jonathan Wakely Date: Mon Jul 7 22:24:14 2008 +0000 Fix typo. Author: Jonathan Wakely Date: Mon Jul 7 22:15:14 2008 +0000 Combine rules, set VERS=0.6.0 Author: Jonathan Wakely Date: Mon Jul 7 22:12:17 2008 +0000 Release notes for 0.6.0 Author: Jonathan Wakely Date: Mon Jul 7 21:38:14 2008 +0000 Change licence to LGPLv3. Author: Jonathan Wakely Date: Mon Dec 17 00:02:47 2007 +0000 Adjust copyright date. Author: Jonathan Wakely Date: Mon Dec 17 00:00:28 2007 +0000 Get rid of CONDITIONAL_SLEEP. Author: Jonathan Wakely Date: Sun Dec 16 23:49:21 2007 +0000 Remove extra tests left in from debugging. Author: Jonathan Wakely Date: Sun Dec 16 23:34:22 2007 +0000 (pstreambuf::fill_buffer): Option to work in non-blocking mode. (pstreambuf::showmanyc): New implementation using non-blocking fill_buffer. Author: Jonathan Wakely Date: Sun Dec 16 23:32:29 2007 +0000 Test streambuf::in_avail() and wide chars. Author: Jonathan Wakely Date: Sun Jul 15 16:39:08 2007 +0000 Fix missing qualification in example code (bug 1754057 - thanks to Brian Ray) Author: Jonathan Wakely Date: Sat Aug 19 16:37:21 2006 +0000 Replace memcpy/memmove with equivalent char_traits operations. Author: Jonathan Wakely Date: Sat Jul 22 01:24:18 2006 +0000 Update copyright year. Author: Jonathan Wakely Date: Sat Jul 22 01:20:43 2006 +0000 (pstreambuf::empty_buffer()): Adjust buffer on incomplete writes. (pstreambuf::write(),pstreambuf::read()): Adjust return value for wide chars. Author: Jonathan Wakely Date: Fri Jul 21 20:30:12 2006 +0000 (pstreambuf::fill_buffer()): Only call rbuffer() once. Author: Jonathan Wakely Date: Fri Jul 21 16:07:24 2006 +0000 Remove misleading comments, there are worse problems when sizeof(char_type)!=1 Author: Jonathan Wakely Date: Fri Jul 21 15:21:53 2006 +0000 (pstreambuf::showmanyc()): Fix overflow error. Author: Jonathan Wakely Date: Fri Jul 21 15:00:19 2006 +0000 Typo in comment. Author: Jonathan Wakely Date: Wed Jun 21 20:56:27 2006 +0000 Support Sun CC compiler (bug 1509533) Author: Jonathan Wakely Date: Sat Jan 21 21:02:06 2006 +0000 (pstreambuf::showmanyc()): Adjust result for sizeof(char_type) > 1 Author: Jonathan Wakely Date: Mon Jan 9 23:58:30 2006 +0000 Repeat file descriptor tests for vector open. Remove assumptions about what fd values will be found because pstreambuf can use extra pipes. Author: Jonathan Wakely Date: Sun Jan 8 23:08:19 2006 +0000 Update copyright date and fix signed/unsigned comparison warning. Author: Jonathan Wakely Date: Tue Sep 20 19:48:25 2005 +0000 Fix incorrect test numbering, caused by unintended template specialisations being created. Fix by keeping the counters with the labels. (Bug 650883) Author: Jonathan Wakely Date: Mon Sep 19 21:06:49 2005 +0000 Signal handler must have C linkage. Author: Jonathan Wakely Date: Mon Sep 5 01:15:27 2005 +0000 Use typedef name. Author: Jonathan Wakely Date: Mon Sep 5 00:39:27 2005 +0000 Use execl("/bin/sh", "sh", "-c", cmd) instead of execlp("sh", "sh", "-c", cmd) to avoid executing some other "sh" found in PATH (potential security hole). Version to 0.5.3 as this could change the behaviour of some programs. Author: Jonathan Wakely Date: Mon Sep 5 00:28:17 2005 +0000 Update fd leak test to match new behaviour (read pipes not closed right away). Test signal safety and exception-safety. Author: Jonathan Wakely Date: Mon Sep 5 00:18:21 2005 +0000 Delay cleaning up read buffers and pipes so that it is still possible to read from the pipes after the child has exited. Previously, sending peof could reap a zombie child and discard any unread data in the read buffers and/or pipes. Now the child is still reaped but the unread data is still available (bug 1163001). Clarify docs for wait() and exited(). Author: Jonathan Wakely Date: Sun Sep 4 15:31:41 2005 +0000 (pstreambuf::showmanyc): Fix broken logic (bug 1232564). Author: Jonathan Wakely Date: Tue Jul 19 08:24:29 2005 +0000 Apply improvements suggested by Antonio S. de A. Terceiro. Author: Jonathan Wakely Date: Sat Jul 16 01:21:59 2005 +0000 Update FSF postal address. Author: Jonathan Wakely Date: Sat Jul 16 01:07:42 2005 +0000 Return number of failed tests from main(). Author: Jonathan Wakely Date: Sat Jul 16 00:04:10 2005 +0000 Update copyright date to 2005. Author: Jonathan Wakely Date: Sat Jun 11 10:06:59 2005 +0000 Fix typo. Author: Jonathan Wakely Date: Sat Jun 11 09:59:20 2005 +0000 Release notes for 0.5.2. Author: Jonathan Wakely Date: Sat Jun 11 09:45:47 2005 +0000 Add note about performance. Author: Jonathan Wakely Date: Sat Jun 11 09:38:40 2005 +0000 Update version and rename "packages" target to more conventional "dist". Author: Jonathan Wakely Date: Sat Jun 11 09:36:42 2005 +0000 Update version number and use KBD.man_page style. Author: Jonathan Wakely Date: Sat Jun 11 09:25:06 2005 +0000 (pstreambuf::showmanyc()): New function to make streambuf::in_avail() work when FIONREAD supported by ioctl(). Author: Jonathan Wakely Date: Sat Jun 11 09:20:03 2005 +0000 Conditionally sleep depending on platform. Author: Jonathan Wakely Date: Sat Jun 11 09:18:53 2005 +0000 Add test for streambuf::in_avail(). Author: Jonathan Wakely Date: Sat Jun 11 09:17:53 2005 +0000 Use LDFLAGS when linking so it can be overridden on command line. Author: Jonathan Wakely Date: Wed Mar 16 02:12:16 2005 +0000 (pstreambuf::write()): Take pointer to const data. Author: Jonathan Wakely Date: Thu Dec 9 21:15:08 2004 +0000 Workarounds to make tests pass on Darwin (don't assume next fd is 3). Author: Jonathan Wakely Date: Thu Dec 9 20:57:18 2004 +0000 Workarounds to make tests pass on Solaris. Author: Jonathan Wakely Date: Thu Oct 21 00:17:09 2004 +0000 Doxygen comment corrections and formatting fixes. Author: Jonathan Wakely Date: Wed Oct 20 23:43:32 2004 +0000 Added install target and INSTALL_PREFIX variable. Author: Jonathan Wakely Date: Wed Oct 20 23:36:01 2004 +0000 (pstreambuf::open): Use close-on-exec pipe to detect execvp() failure. Author: Jonathan Wakely Date: Wed Oct 20 14:36:35 2004 +0000 (close_fd_array): Use template argument deduction to find array length. (close_fd): New helper to close single file descriptors. Author: Jonathan Wakely Date: Wed Oct 20 00:42:14 2004 +0000 Add tests for is_open() on bad commands. Author: Jonathan Wakely Date: Mon Oct 18 09:49:02 2004 +0000 Use constant for array length. Formatting fixes. Author: Jonathan Wakely Date: Sun Oct 17 16:12:19 2004 +0000 Fix URL of FAQ. Author: Jonathan Wakely Date: Sun Oct 17 16:07:32 2004 +0000 Don't generate ChangeLog if no CVS/Root file. Note about version numbers. Author: Jonathan Wakely Date: Sun Oct 17 15:46:05 2004 +0000 Update with "doxygen -u". Author: Jonathan Wakely Date: Sun Oct 17 15:44:05 2004 +0000 Add MANIFEST. Author: Jonathan Wakely Date: Sun Oct 17 15:43:16 2004 +0000 Version to 0.5.0 Author: Jonathan Wakely Date: Sun Oct 17 15:36:19 2004 +0000 Add INLINE_INHERITED_MEMB. Author: Jonathan Wakely Date: Sun Oct 3 05:01:40 2004 +0000 Whitespace change to comments. Author: Jonathan Wakely Date: Sun Oct 3 04:56:43 2004 +0000 Tidy up docs, be more consistent and remove duplication. Author: Jonathan Wakely Date: Sun Oct 3 04:15:21 2004 +0000 Cast execlp() sentinel to avoid problems where sizeof(int) != sizeof(void*). Use NULL instead of 0 where null pointer intended. Author: Jonathan Wakely Date: Fri Oct 1 19:00:43 2004 +0000 Ensure ipstreams always open for reading and opstreams always open for writing. Inherit from pstreams and use pmode names not ios_base::openmode names. Author: Jonathan Wakely Date: Wed Sep 29 08:29:25 2004 +0000 POSIX sed doesn't support "-" to mean stdin, use "cat -" instead. Author: Jonathan Wakely Date: Sun Sep 26 19:26:24 2004 +0000 Use argv_type typedef. Author: Jonathan Wakely Date: Sun Sep 26 19:25:51 2004 +0000 (pstreams::argv_type): New typedef for argument vector. (pstreams::fd_type,pstreams::fd_t): Rename fd_t to fd_type. Author: Jonathan Wakely Date: Sun Sep 26 19:12:16 2004 +0000 (pbsz,bufsz): Use enums for constants so no storage needed. Author: Jonathan Wakely Date: Fri Sep 24 23:44:56 2004 +0000 Test pstreambuf::exited() behaves sensibly. Author: Jonathan Wakely Date: Fri Sep 24 23:38:37 2004 +0000 (pstreambuf::exited): Return sensible values, bug #1014183. Author: Jonathan Wakely Date: Fri Sep 24 23:11:24 2004 +0000 Use "-" in tests, "/dev/stdin" may not be mounted (thanks to Jez Bromley). Author: Jonathan Wakely Date: Mon Sep 20 23:41:03 2004 +0000 (pstream_common::pmode): Remove unnecessary typedef. (pstreambuf::fopen): Surround assignments in parentheses. Author: Jonathan Wakely Date: Mon Sep 20 22:53:01 2004 +0000 Use /etc/hosts instead of /etc/motd, which may not exist. Author: Jonathan Wakely Date: Fri Jun 11 08:36:11 2004 +0000 Improve comment. Author: Jonathan Wakely Date: Fri Jun 11 00:08:12 2004 +0000 Add note about alpha compiler, thanks to Jez Bromley. Author: Jonathan Wakely Date: Thu Jun 10 23:57:29 2004 +0000 Qualify FILE and size_t with std:: namespace. Include stdio.h for FILE. Author: Jonathan Wakely Date: Thu Jun 10 15:21:53 2004 +0000 (pstreambuf::read_err()): use switch_read_buffer() to update stream position. (PSTREAMS_VERSION()): increment to 0.49, should make new release. Author: Jonathan Wakely Date: Thu Jun 10 15:14:48 2004 +0000 New test for read position. Author: Jonathan Wakely Date: Thu Jun 10 14:18:48 2004 +0000 Add extra testing that reading from terminated process fails. Author: Jonathan Wakely Date: Thu Jun 10 14:16:45 2004 +0000 Fix a test, add more tests for kill()/wait(), test for resource leaks. Author: Jonathan Wakely Date: Thu Jun 10 14:15:34 2004 +0000 (pstreambuf::wait()): Fix resource leaks when wait() called before close(). (pstreambuf::sync()): Use exited() to avoid writing to exited process. Author: Jonathan Wakely Date: Thu Jun 10 11:32:58 2004 +0000 Change formatting of comment. Author: Jonathan Wakely Date: Fri May 21 13:44:58 2004 +0000 Make some vars const. Author: Jonathan Wakely Date: Fri May 21 13:30:14 2004 +0000 Fix buggy test that raised SIGPIPE on FreeBSD: Stream was opened with all 3 pipes but process didn't read from stdin. By the time sync() was called the process had exited and closed its stdin. Author: Jonathan Wakely Date: Fri May 21 11:52:51 2004 +0000 Document that seeks will fail. Author: Jonathan Wakely Date: Fri May 21 10:52:27 2004 +0000 Clear stream state after reading to EOF. Include stack trace of FreeBSD failure. Add tests to check that seeking fails. Author: Jonathan Wakely Date: Fri Apr 30 19:30:27 2004 +0000 More release notes. Author: Jonathan Wakely Date: Fri Apr 30 19:13:14 2004 +0000 Add release notes for 0.48. Author: Jonathan Wakely Date: Fri Apr 30 18:39:12 2004 +0000 Append "_SEEN" to include guard macros. Version to 0.48. Author: Jonathan Wakely Date: Fri Apr 30 18:38:19 2004 +0000 Add some TODOs. Author: Jonathan Wakely Date: Fri Apr 30 18:37:01 2004 +0000 Fix typo. Author: Jonathan Wakely Date: Fri Apr 30 18:32:19 2004 +0000 Qualify more dependent names, needed for Comeau compiler. Author: Jonathan Wakely Date: Fri Apr 30 11:47:51 2004 +0000 Fix punctuation in some comments, no code changes. Author: Jonathan Wakely Date: Thu Apr 8 13:52:24 2004 +0000 Update version number. Author: Jonathan Wakely Date: Thu Apr 8 13:48:46 2004 +0000 (pstreambuf::read(char&)): Remove redundant function overload. (pstreambuf::write(char&)): Remove redundant function overload. (pstream_common::open()): Make non-virtual and rename to do_open(). (pstream_common): Make various functions and typedefs protected not public. (rpstream): Define all functions in class body. (PSTREAMS_VERSION): Increase to 0.47. Author: Jonathan Wakely Date: Tue Mar 30 11:51:26 2004 +0000 Merge with old_popen-branch. Author: Jonathan Wakely Date: Tue Mar 30 11:14:51 2004 +0000 Merge changes from old_popen-branch. Author: Jonathan Wakely Date: Sun Mar 28 13:27:31 2004 +0000 (peof()): Use dynamic_cast not static_cast. Version to 0.46. Author: Jonathan Wakely Date: Tue Mar 23 13:09:44 2004 +0000 Version to 0.45. Author: Jonathan Wakely Date: Tue Mar 23 13:09:14 2004 +0000 (pstreambuf::open()): Use ::_exit() instead of std::exit(). (pstreambuf::fill_buffer()): Use local vars instead of a cast and a temporary. (peof()): Add missing inline keyword. Version to 0.45, reformat some long lines. Author: Jonathan Wakely Date: Fri Mar 19 16:36:01 2004 +0000 (pstreambuf:empty_buffer()): More type fixes, 64-bit pointer bigger than int. Update copyright date, fix comments and version to 0.44. Author: Jonathan Wakely Date: Fri Mar 19 15:56:42 2004 +0000 (basic_pstreambuf::xsputn()): Qualify std::memcpy. (basic_pstreambuf::fill_buffer()): Fix problem with different sized types. Author: Jonathan Wakely Date: Fri Mar 19 15:54:52 2004 +0000 (clean): New target to remove test binaries. Author: Jonathan Wakely Date: Wed Mar 17 14:06:44 2004 +0000 Don't use typedef names for explicit instantiation. Author: Jonathan Wakely Date: Wed Feb 4 22:56:06 2004 +0000 (basic_pstreambuf): Default Traits to std::char_traits. Author: Jonathan Wakely Date: Sun Jan 25 03:21:36 2004 +0000 Add -W for extra warnings. Author: Jonathan Wakely Date: Wed Sep 3 23:56:28 2003 +0000 Don't use type-def names for explicit instantiations of templates. (test_type()): Remove names of unused parameters. Author: Jonathan Wakely Date: Wed Sep 3 23:53:16 2003 +0000 Qualify basic_streambuf members with "this->". Author: Jonathan Wakely Date: Thu Jul 17 23:45:37 2003 +0000 More doxygen. Author: Jonathan Wakely Date: Thu Jul 17 23:39:09 2003 +0000 Minor doxygen improvements. Author: Jonathan Wakely Date: Thu Jul 17 23:23:04 2003 +0000 Remove rpstream.h Author: Jonathan Wakely Date: Mon Apr 28 10:57:41 2003 +0000 Fix call to base class ctor for bidirectional pstream. Author: Jonathan Wakely Date: Sun Apr 20 13:29:42 2003 +0000 Compile test_pstreams with -pedantic and fix missing const qual. Author: Jonathan Wakely Date: Fri Mar 14 16:19:36 2003 +0000 Update copyright year. Author: Jonathan Wakely Date: Tue Mar 11 01:55:18 2003 +0000 Remove reference to old rpstream.h file. Author: Jonathan Wakely Date: Tue Mar 11 01:28:23 2003 +0000 Fix failing tests, eofbit is set when getline() reaches EOF. Author: Jonathan Wakely Date: Mon Mar 10 18:02:10 2003 +0000 Use more portable arguments to tr, works for Solaris now. Author: Jonathan Wakely Date: Mon Mar 10 01:42:07 2003 +0000 Explicitly instantiate all template classes in both test programs. Author: Jonathan Wakely Date: Mon Mar 10 01:34:53 2003 +0000 Don't #include rpstream.h, file removed. Author: Jonathan Wakely Date: Mon Mar 10 01:31:10 2003 +0000 Move rpstream definition into pstream.h and remove rpstream.h Author: Jonathan Wakely Date: Mon Mar 10 01:13:54 2003 +0000 (streambuf_type): remove unused typedef from concrete stream classes. Author: Jonathan Wakely Date: Mon Mar 10 01:12:33 2003 +0000 Remove TEST_RPSTREAM macro and always test rpstreams. Author: Jonathan Wakely Date: Wed Mar 5 23:52:06 2003 +0000 Fix typo in sed command. Author: Jonathan Wakely Date: Wed Mar 5 23:49:47 2003 +0000 Qualify dependent names with "this->" to delay lookup. Author: Jonathan Wakely Date: Thu Feb 27 17:51:40 2003 +0000 (rpstream::rpstream()): Remove redundant call to std::basic_ios::init(). Author: Jonathan Wakely Date: Thu Feb 27 17:35:58 2003 +0000 (pstream_common::open()): Use "this->" to prevent lookup finding ::setstate. Author: Jonathan Wakely Date: Thu Feb 27 17:29:42 2003 +0000 (pstream_common::buf_): Add using decls to access buf_ in derived class. (rpstream::pmode): Make typedef public, matches other classes. Author: Jonathan Wakely Date: Sat Dec 14 21:36:36 2002 +0000 Solaris sh(1) exit status is 1 when command not found (POSIX says 127). Author: Jonathan Wakely Date: Sat Dec 14 21:03:20 2002 +0000 Improve regex so empty lines prefixed with STDIN. Author: Jonathan Wakely Date: Sat Dec 14 20:55:40 2002 +0000 Fix some bugs in the tests due to portability issues. Author: Jonathan Wakely Date: Sat Dec 14 19:19:49 2002 +0000 Mention that Makefile doesn't work on Solaris (bug #650887) Author: Jonathan Wakely Date: Tue Dec 3 20:23:07 2002 +0000 Document that I/O is buffered now. Author: Jonathan Wakely Date: Wed Nov 13 01:40:48 2002 +0000 Add tests for rpstream. Author: Jonathan Wakely Date: Fri Nov 8 02:53:04 2002 +0000 Version 0.42, fully buffered now. Author: Jonathan Wakely Date: Fri Nov 8 02:51:51 2002 +0000 Version to 0.42, all I/O buffered. Move static constants into common base. Replace take_from_buf_ and char_buf_ with wbuffer_ and two rbuffer_ arrays. Remove take_from_buf(), char_buf(), uflow(). Add rbuffer(), switch_read_buffer(), fill_buffer(), create_buffers(), destroy_buffers(). read() and write() use multibyte strings now. Author: Jonathan Wakely Date: Thu Nov 7 01:20:40 2002 +0000 Rename COPYING to COPYING.LIB Author: Jonathan Wakely Date: Tue Oct 22 23:23:53 2002 +0000 Formatting changes: removed some braces, moved some functions. Author: Jonathan Wakely Date: Tue Oct 22 23:10:18 2002 +0000 (init_rbuffers()): New function called at construction to zero arrays. Fix bad variable name from copy'n'paste error. Author: Jonathan Wakely Date: Tue Oct 22 01:30:27 2002 +0000 Rename pstream_base class template to pstream_common. Author: Jonathan Wakely Date: Tue Oct 22 01:03:22 2002 +0000 Increase version number to match CVS HEAD. Author: Jonathan Wakely Date: Tue Oct 22 00:59:19 2002 +0000 (pstreambuf::readerr(bool)): Use ternary op for conditional, easier to read. Author: Jonathan Wakely Date: Tue Oct 22 00:56:33 2002 +0000 Remove verbose "this->" from member function calls. Author: Jonathan Wakely Date: Tue Oct 22 00:40:03 2002 +0000 Fix bad variable name from copy'n'paste error. Author: Jonathan Wakely Date: Sun Sep 22 01:05:15 2002 +0000 Add buffering for writes. Currently disabled. Author: Jonathan Wakely Date: Sat Sep 21 23:49:14 2002 +0000 Notes on new wait(), exited() and status() members. Author: Jonathan Wakely Date: Sat Sep 21 23:27:32 2002 +0000 Tidy up calls totest functions, use check_pass/check_fail where possible. Remove block of old, unused code. Author: Jonathan Wakely Date: Sat Sep 21 22:02:03 2002 +0000 New wait()-related functions are standard on pstreambuf now. Remove unnecessary static_casts. Author: Jonathan Wakely Date: Sat Sep 21 21:53:03 2002 +0000 (pstreambuf::wait(),pstreambuf::exited(),pstreambuf::status()): Use new functions. Version to 0.40 Author: Jonathan Wakely Date: Sat Sep 21 21:44:54 2002 +0000 Fix typo in comment. Author: Jonathan Wakely Date: Sat Sep 14 02:55:48 2002 +0000 Test pstreambuf::wait(), fixes last failure. Author: Jonathan Wakely Date: Sat Sep 14 02:54:50 2002 +0000 (pstream_base::rdbuf()): Return pointer to stream buffer. (pstreambuf::wait()): Experimental, -DPSTREAMS_WAIT. Wait for child exit. (pstreambuf::exited()): Experimental, -DPSTREAMS_WAIT. Check for child exit. Documentation improvements. Author: Jonathan Wakely Date: Sat Sep 14 02:52:05 2002 +0000 New variables to make it easier to give extra options to g++ Author: Jonathan Wakely Date: Tue Sep 10 00:10:59 2002 +0000 Fix test_minimum and run from Makefile again. Author: Jonathan Wakely Date: Mon Sep 9 22:44:14 2002 +0000 Give shell time to exit on bad command and don't write (causes SIGPIPE). Author: Jonathan Wakely Date: Mon Sep 9 22:40:44 2002 +0000 Fix missing '$' in shell cmd. Author: Jonathan Wakely Date: Mon Sep 9 00:28:12 2002 +0000 Lots of new and improved tests. Author: Jonathan Wakely Date: Mon Sep 9 00:27:29 2002 +0000 Mention kill() function. Author: Jonathan Wakely Date: Mon Sep 9 00:26:41 2002 +0000 (pstreambuf::fork()): Save errno instead of printing error message. (pstreambuf::kill()): New function to send a signal to child. (pstreambuf::error(),pstreambuf::error_): Report errno from system calls. (pstreambuf::status(),pstreambuf::status_): Report exit status of child process. (pstreambuf::peof(),peof): New function and manipulator to close pstdin pipe. (close_fd_array()): Make non-member. (iostream,cstring): Remove unnecesssary headers. Version to 0.39 Author: Jonathan Wakely Date: Mon Sep 9 00:11:43 2002 +0000 Ignore lots of files I have in my sandbox. Author: Jonathan Wakely Date: Sun Sep 8 22:39:22 2002 +0000 (docs): Automatically update version number in mainpage.html (OPTIM): New variable, can be overridden on command line. Author: Jonathan Wakely Date: Fri Aug 30 16:46:01 2002 +0000 Move standard headers to ensure pstream.h #incudes everything it needs. Author: Jonathan Wakely Date: Fri Aug 30 16:36:44 2002 +0000 Document errno=ESPIPE side effect of pstreambuf::fopen(). Author: Jonathan Wakely Date: Fri Aug 30 16:27:57 2002 +0000 (pstreambuf::fork(),pstreambuf::open()): Save errno instead of reporting to stderr. (pstreambuf::error_, pstreambuf::error()): New member for errors from sys calls. (pstreambuf::open(string, vector)): Make copies of args. (pstreambuf::close()): Don't use WNOHANG, wait for child to finish. (close_fd_array()): Make non-member, doesn't need special privileges. (PSTREAMS_VERSION): Increment to 0.39 Author: Jonathan Wakely Date: Fri Aug 30 16:17:48 2002 +0000 Ignore test binaries Author: Jonathan Wakely Date: Tue Aug 27 19:54:25 2002 +0000 (pstreambuf::rpipe(which)): Unnecessary enum keyword confuses Doxygen Author: Jonathan Wakely Date: Tue Aug 27 19:47:51 2002 +0000 Version to 0.38 (tag RELEASE_0_38) Author: Jonathan Wakely Date: Tue Aug 27 19:43:01 2002 +0000 Revert pstreambuf::fopen() to using FILE* parameters. Test properly. Author: Jonathan Wakely Date: Tue Aug 27 19:38:28 2002 +0000 (pstreambuf::fopen()): Revert to using FILE*s - it works now :-) Author: Jonathan Wakely Date: Tue Aug 27 02:11:00 2002 +0000 Version to 0.37 Author: Jonathan Wakely Date: Tue Aug 27 02:07:35 2002 +0000 (pstreambuf::fopen()): Expose file descriptors, not FILE*s as fdopen() fails. Author: Jonathan Wakely Date: Tue Aug 27 01:43:45 2002 +0000 (out(),err()): Move from opstream to ipstream (were on wrong class!) (pstreambuf::fopen()): Fix stupid copy'n'paste error, used same variable 3 times Author: Jonathan Wakely Date: Tue Aug 27 01:41:36 2002 +0000 Use sed not cat for better test. Author: Jonathan Wakely Date: Mon Aug 19 00:37:35 2002 +0000 Add test for REDI_EVISCERATE_PSTREAMS mode. Author: Jonathan Wakely Date: Mon Aug 19 00:36:40 2002 +0000 (pstreambuf::rpipe): Add missing definition of overloaded function. Author: Jonathan Wakely Date: Wed Jul 24 23:02:50 2002 +0000 (pstream_base::streambuf_type): Make protected so subclasses can access. Author: Jonathan Wakely Date: Wed Jul 24 23:00:21 2002 +0000 (distro): Remove target, didn't work right anyway. (MANIFEST): New target for list of files in releases. Author: Jonathan Wakely Date: Wed Jul 24 21:06:03 2002 +0000 (basic_pstreambuf::fork): Close other ends of pipes after dup2'ing them. Relicense under LGPL. Write stuff in README and INSTALL. Author: Jonathan Wakely Date: Wed May 15 01:27:47 2002 +0000 (pstreambuf::fork()): Open all pipes when pmode specifies more than one. Author: Jonathan Wakely Date: Mon Apr 29 23:44:52 2002 +0000 (pstream_base::~pstream_base()): Make pure virtual so class is abstract. Author: Jonathan Wakely Date: Mon Apr 29 23:03:03 2002 +0000 Typo in comment. Author: Jonathan Wakely Date: Mon Apr 29 22:58:48 2002 +0000 (pstreambuf): make copy ctor and operator= private again (oops) Some more doxygen comments. Author: Jonathan Wakely Date: Mon Apr 29 21:40:26 2002 +0000 (REDI_EVISCERATE_PSTREAMS): Macro to activate evil member functions. (pstreambuf::fopen()): Add evil function to expose FILE pointers. (pstream_base::fopen()): Add function to call evil function on streambuf Author: Jonathan Wakely Date: Mon Apr 29 21:27:48 2002 +0000 (pstreambuf::buf_read_src): Give enum a name. (pstreambuf::rpipe()): Add overload of function. (pstreambuf): Make private member functions protected. #include and add std:: to calls to strerror() Version to 0.35 Author: Jonathan Wakely Date: Sat Apr 27 14:58:29 2002 +0000 (pstreambuf::fdclose()): Rename to close_fd_array(), describes purpose better Author: Jonathan Wakely Date: Sat Apr 27 14:56:36 2002 +0000 Disable execution of test_minimum, doesn't work. Still compile it though. Author: Jonathan Wakely Date: Sat Apr 27 04:24:23 2002 +0000 Add link to pstreams home page. Author: Jonathan Wakely Date: Sat Apr 27 03:51:46 2002 +0000 Replace pstreams.html with mainpage.html and remove lots of text that is more relevant to PStreams home page than to the API reference. Author: Jonathan Wakely Date: Sat Apr 27 03:18:34 2002 +0000 Correct credit for ChildReader class. Author: Jonathan Wakely Date: Fri Apr 26 01:48:23 2002 +0000 Add a space Author: Jonathan Wakely Date: Fri Apr 26 01:39:30 2002 +0000 Link to archives of latest version and older (maybe more stable?) version. Author: Jonathan Wakely Date: Fri Apr 26 01:25:36 2002 +0000 brief README file (far too brief) Author: Jonathan Wakely Date: Fri Apr 26 01:23:36 2002 +0000 Add rpstream.h to SOURCES Author: Jonathan Wakely Date: Fri Apr 26 01:22:14 2002 +0000 Mention "make docs" Author: Jonathan Wakely Date: Fri Apr 26 01:17:57 2002 +0000 Add Id keyword Author: Jonathan Wakely Date: Fri Apr 26 01:16:47 2002 +0000 More stupid typos Author: Jonathan Wakely Date: Thu Apr 25 02:12:50 2002 +0000 (pstreambuf::fork()): Swap pstdin and pstdout AGAIN! Author: Jonathan Wakely Date: Thu Apr 25 02:00:32 2002 +0000 Fix several stupid typos and copy&paste errors. Compiles now. Fails tests. Author: Jonathan Wakely Date: Thu Apr 25 01:59:25 2002 +0000 Remove options that aren't available in g++ 3.1 Author: Jonathan Wakely Date: Wed Apr 24 23:23:33 2002 +0000 (pstream_base): New base class providing common functionality. (rpstream): Move restricted pstream class to separate file, rpstream.h Up version to 0.32 and update docs. Author: Jonathan Wakely Date: Wed Apr 24 22:00:17 2002 +0000 New file giving installation instructions (such as they are) Author: Jonathan Wakely Date: Sun Apr 21 01:40:30 2002 +0000 (rpstream::pmode, rpstream::istream_type): Add required typename keyword. Author: Jonathan Wakely Date: Sat Apr 20 20:33:52 2002 +0000 Merge with replace_popen-branch Author: Jonathan Wakely Date: Mon Jan 28 02:43:50 2002 +0000 (OUTPUT_DIRECTORY): change absolute path to relative Author: Jonathan Wakely Date: Mon Jan 28 02:41:36 2002 +0000 Add required typename specifiers Author: Jonathan Wakely Date: Sun Jan 27 13:16:26 2002 +0000 New file Author: Jonathan Wakely Date: Sun Jan 27 13:00:32 2002 +0000 New file Author: Jonathan Wakely Date: Sun Jan 27 13:00:17 2002 +0000 New tests Author: Jonathan Wakely Date: Sun Jan 27 12:36:18 2002 +0000 Use HTML entity for ampersands in URIs Author: Jonathan Wakely Date: Sun Jan 27 12:35:19 2002 +0000 Test writing to closed steam Author: Jonathan Wakely Date: Sun Jan 27 12:33:31 2002 +0000 (test_bidip, test_minimum): Add new tests (distro): Use DISTFILES variable Author: Jonathan Wakely Date: Sun Jan 13 05:01:16 2002 +0000 (read(),write()): Fix stupid mistake where int_type used instead of char_type (read(),write()): Overloads for writing character sequences Version to 0.17 Author: Jonathan Wakely Date: Sun Jan 13 04:53:23 2002 +0000 Refer to doxygen docs in usage secion. Note about upcoming version. Author: Jonathan Wakely Date: Sun Jan 13 04:30:37 2002 +0000 New file. Author: Jonathan Wakely Date: Wed Jan 9 03:39:03 2002 +0000 Removed file as it is not used anywhere. Author: Jonathan Wakely Date: Wed Jan 9 03:28:41 2002 +0000 (istream,ostream): Add required headers. (basic_pstreambuf::open): Fix typo. Version to 0.16 Author: Jonathan Wakely Date: Tue Jan 8 11:53:28 2002 +0000 (open,close): Add error checking. Version to 0.15 Author: Jonathan Wakely Date: Tue Jan 8 03:41:27 2002 +0000 Formatting changes, moved all function defs and docs out of class body. Version to 0.14 Author: Jonathan Wakely Date: Tue Jan 8 01:35:06 2002 +0000 (basic_pstream): Fix missing std:: qualifiers. Author: Jonathan Wakely Date: Tue Jan 8 00:35:44 2002 +0000 (openmode2str): Add inline keyword to prevent multiple definitions. Author: Jonathan Wakely Date: Mon Jan 7 20:35:32 2002 +0000 (BACK_COMPAT): Move non-standard versions from pstream.h to pstream_compat.h Author: Jonathan Wakely Date: Mon Jan 7 20:28:38 2002 +0000 (pbackfail): Fix missing '!' in condition. (basic_pstream): Fix typos in ctor/dtor names. (command_,buf_): Make protected member variables private in stream classes. (string,ios_base): remove typedefs and explicitly qualify each use with std:: (openmode2str): Make non-member function. (REDI_PSTREAMS_POPEN_USES_BIDIRECTIONAL_PIPE): only define if !defined Add comments for Doxygen. Version to 0.12 Author: Jonathan Wakely Date: Mon Jan 7 11:43:47 2002 +0000 Minor formatting change. Author: Jonathan Wakely Date: Mon Jan 7 11:36:54 2002 +0000 (test): Slight changes to test targets. Author: Jonathan Wakely Date: Mon Jan 7 11:35:58 2002 +0000 New file. Author: Jonathan Wakely Date: Mon Jan 7 11:33:09 2002 +0000 (command(),command_): Moved members from streambuf class to stream classes. (read(),write()): Check for null FILE* to prevent segfaults. Author: Jonathan Wakely Date: Mon Dec 31 22:02:33 2001 +0000 Added description and keywords tags for search engines and a TODO. Author: Jonathan Wakely Date: Mon Dec 31 21:57:46 2001 +0000 (command): member function added to all classes. minor format and comment changes Author: Jonathan Wakely Date: Sat Dec 15 19:50:21 2001 +0000 (ChangeLog) new target Author: Jonathan Wakely Date: Sat Dec 15 19:36:52 2001 +0000 New file Author: Jonathan Wakely Date: Sat Dec 15 19:05:12 2001 +0000 Correct version number to 0.11 Author: Jonathan Wakely Date: Sat Dec 15 19:03:58 2001 +0000 (MODE_MASK) remove this constant, only used in one place. (BACK_COMPAT GCC_BACK_COMPAT) #defines for backward compatible versions, standard conforming version now default. Update version to 0.11 Author: Jonathan Wakely Date: Sat Dec 15 18:53:47 2001 +0000 Updated to cover version 0.11 Validated HTML and CSS. Author: Jonathan Wakely Date: Sat Dec 15 18:00:19 2001 +0000 Updated version number to 0.10 Author: Jonathan Wakely Date: Sat Dec 15 17:44:24 2001 +0000 Updated documentation. Author: Jonathan Wakely Date: Sat Dec 15 17:37:21 2001 +0000 Added standard-conforming versions of (i|o|)pstream classes. Author: Jonathan Wakely Date: Thu Dec 13 03:27:44 2001 +0000 New file, currently unused. Author: Jonathan Wakely Date: Thu Dec 13 03:27:03 2001 +0000 Update to describe v0.02 Add usage section. Author: Jonathan Wakely Date: Thu Dec 13 03:23:11 2001 +0000 Move functionality into class pstreambase. Added pstream for bidirectional IO. Author: Jonathan Wakely Date: Thu Dec 13 02:15:11 2001 +0000 Added file back, with -kb option for binary file. Author: Jonathan Wakely Date: Thu Dec 13 02:14:21 2001 +0000 Removed file to re-add it with -kb binary option. Author: Jonathan Wakely Date: Thu Dec 13 00:39:16 2001 +0000 Initial revision pstreams-0.8.0/MANIFEST0000664000076400007640000000053012125363352013150 0ustar rediredipstreams-0.8.0/pstream.h pstreams-0.8.0/ChangeLog pstreams-0.8.0/MANIFEST pstreams-0.8.0/AUTHORS pstreams-0.8.0/COPYING.LIB pstreams-0.8.0/Doxyfile pstreams-0.8.0/INSTALL pstreams-0.8.0/Makefile pstreams-0.8.0/README pstreams-0.8.0/mainpage.html pstreams-0.8.0/test_pstreams.cc pstreams-0.8.0/test_minimum.cc pstreams-0.8.0/pstreams-devel.spec pstreams-0.8.0/AUTHORS0000664000076400007640000000005411742125321013064 0ustar redirediJonathan Wakely pstreams-0.8.0/COPYING.LIB0000664000076400007640000001672712077110431013470 0ustar rediredi GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. pstreams-0.8.0/Doxyfile0000664000076400007640000017373712077110431013543 0ustar rediredi# Doxyfile 1.6.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = PStreams # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc/ # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = YES # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it parses. # With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this tag. # The format is ext=language, where ext is a file extension, and language is one of # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will rougly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by # doxygen. The layout file controls the global structure of the generated output files # in an output format independent way. The create the layout file that represents # doxygen's defaults, run doxygen with the -l option. You can optionally specify a # file name after the option, if omitted DoxygenLayout.xml will be used as the name # of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = pstream.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = . # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # If the HTML_TIMESTAMP tag is set to YES then the generated HTML # documentation will contain the timesstamp. HTML_TIMESTAMP = NO # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER # are set, an additional index file will be generated that can be used as input for # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated # HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. # For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's # filter section matches. # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP) # there is already a search function so this one should typically # be disabled. SEARCHENGINE = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES pstreams-0.8.0/INSTALL0000664000076400007640000000074211742125321013051 0ustar redirediThere is no configure script or install process for PStreams yet. It's simple enough to not need one. Just copy pstream.h to some directory and include in your programs. The documentation is generated by running "make docs" To run the test program compile and run test_pstreams.cc This can be done with "make test_pstreams" if you have GNU or BSD make (the Makefile doesn't work with Solaris, and probably other versions too) $Id: INSTALL,v 1.5 2003/03/11 01:55:18 redi Exp $ pstreams-0.8.0/Makefile0000664000076400007640000000545112125363120013457 0ustar rediredi# $Id: Makefile,v 1.39 2010/10/14 21:35:22 redi Exp $ # PStreams Makefile # Copyright (C) Jonathan Wakely # # This file is part of PStreams. # # PStreams is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # PStreams is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # TODO configure script (allow doxygenating of EVISCERATE functions) OPTIM= -O1 -g3 EXTRA_CXXFLAGS= CFLAGS=-pedantic -Werror -Wall -W -Wpointer-arith -Wcast-qual -Wcast-align -Wredundant-decls $(OPTIM) CXXFLAGS=$(CFLAGS) -std=c++98 -Woverloaded-virtual prefix = /usr/local includedir = $(prefix)/include INSTALL = install INSTALL_DATA = $(INSTALL) -p -v -m 0644 SOURCES = pstream.h GENERATED_FILES = ChangeLog MANIFEST EXTRA_FILES = AUTHORS COPYING.LIB Doxyfile INSTALL Makefile README \ mainpage.html test_pstreams.cc test_minimum.cc pstreams-devel.spec DIST_FILES = $(SOURCES) $(GENERATED_FILES) $(EXTRA_FILES) VERS := $(shell awk -F' ' '/^\#define *PSTREAMS_VERSION/{ print $$NF }' pstream.h) all: docs $(GENERATED_FILES) check: test_pstreams test_minimum | pstreams.wout @for test in $^ ; do echo $$test ; ./$$test >/dev/null 2>&1 || echo "$$test EXITED WITH STATUS $$?" ; done test run_tests: check test_%: test_%.cc pstream.h $(CXX) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(LDFLAGS) -o $@ $< MANIFEST: Makefile @for i in $(DIST_FILES) ; do echo "pstreams-$(VERS)/$$i" ; done > $@ docs: pstream.h mainpage.html @doxygen Doxyfile mainpage.html: pstream.h Makefile @perl -pi -e "s/^(

Version) [0-9\.]*(<\/p>)/\1 $(VERS)\2/" $@ ChangeLog: @if [ -d .git ]; then git log --no-merges | grep -v '^commit ' > $@ ; fi dist: pstreams-$(VERS).tar.gz pstreams-docs-$(VERS).tar.gz pstreams-$(VERS).tar.gz: pstream.h $(GENERATED_FILES) @ln -s . pstreams-$(VERS) @tar -czvf $@ `cat MANIFEST` @rm pstreams-$(VERS) pstreams-docs-$(VERS).tar.gz: docs @ln -s doc/html pstreams-docs-$(VERS) @tar -czvhf $@ pstreams-docs-$(VERS) @rm pstreams-docs-$(VERS) TODO : pstream.h mainpage.html test_pstreams.cc @grep -nH TODO $^ | sed -e 's@ *// *@@' > $@ clean: @rm -f test_minimum test_pstreams @rm -rf doc TODO install: @install -d $(DESTDIR)$(includedir)/pstreams @$(INSTALL_DATA) pstream.h $(DESTDIR)$(includedir)/pstreams/pstream.h pstreams.wout: @echo "Wide Load" | iconv -f ascii -t UTF-32 > $@ .PHONY: TODO check test ChangeLog run_tests pstreams-0.8.0/README0000664000076400007640000002152312125352167012706 0ustar redirediPStreams README file ==================== Contents ======== Introduction Release notes for recent versions The PStream Buffer class Signalling and Termination The Good, the Bad and the Ugly Introduction ============ This is the README file for PStreams, a C++ utility for simple IOStream-based Inter-Process Communication. PStreams is a tool. Not the most efficient or flexible method of IPC, but fairly simple and IOStream-based, with all the advantages that provides. I hope you find it useful. PStreams is free software, see the file COPYING.LIB for copying permission. The latest version can be found at http://pstreams.sourceforge.net/ and frequently asked questions at http://pstreams.sourceforge.net/faq.html The author can be contacted at pstreams@kayari.org To use the PStreams classes copy the required header files to somewhere your compiler can find them and #include them. The headers are commented so that API documentation to be generated using Doxygen (http://www.doxygen.org/) This file contains some notes on PStreams, but is quite incomplete. There may be some notes here that aren't covered in the API documentation, but see those docs for most questions about usage (or at least, how things _should_ work). PStreams has mostly been tested with gcc so far, if you have problems (or better still - solutions) with PStreams and other compilers please let me know. To use PStreams with the alpha cxx compiler you must not use strict_ansi mode and define __USE_STD_IOSTREAM to use the standard IOStream classes. To run the test program compile and run test_pstreams.cc This can be done with "make test_pstreams" if you have GNU or BSD make. The Makefile doesn't work with Solaris make, and probably other versions of make. Release notes for PStreams 0.8.0 ================================ The child process will now switch to a new process group, with the process group ID the same as the PID. The basic_pstreambuf::killpg() member function has been added to send a signal to the child's process group. New constructors to simplify the common case where the string specifying the file to be executed is the same as the first element of the argv_type vector. Fixes for compatibility with Clang++ and _FORTIFY_SOURCE. Release notes for PStreams 0.7.0 ================================ When opening a pstream for reading with mode pstderr, the pstdout mode is no longer added, and the initial read source will be set the the child process' stdout stream. The RPM spec file from the Fedora pstreams-devel package is now included. Release notes for PStreams 0.6.0 ================================ The Library's licence has changed to LGPL version 3. If the read buffer is empty pstreambuf::in_avail() now performs a non-blocking read to fetch only as many characters as are available. This means that istream::readsome() won't block and can be used to test if characters are available on the child process' stdout or stderr pipes without blocking. Release notes for PStreams 0.5.2 ================================ Support for streambuf::in_avail() added for platforms that support the FIONREAD ioctl request (known to work on Linux, FreeBSD and Solaris.) It is now possible to detect when the shell command failed to execute, as long as you open the pstream using the functions taking argv_type. If the command is not found or cannot be executed then pstreambuf::is_open() will return false. This makes it possible to distinguish the cases where the command cannot be run and when it runs but exits with an error. Release notes for PStreams 0.5.0 ================================ Version numbering changed to the GNU-style major.minor.patchlevel scheme. The PSTREAMS_VERSION macro has jumped to 0x0050, 1.0.0 will still be 0x0100. The current release would have been 0.50 with the old scheme. Because all names ending in _t are reserved by POSIX, the pstreambuf::fd_t typedef has been renamed to fd_type. The fd_t name is still available, but is deprecated and will be removed soon. If you've used that type in your code please change it to fd_type (which is a better name anyway). There is also a new argv_type typedef for std::vector, the type used to hold the argument list for a command. Thanks to Tommi Maekitalo for the argv_type suggestion. Added a FAQ, which is very incomplete. Thanks to Jez Bromley, Brett Williams, Danny Aizer and everyone else who has helped. The pstreambuf class will soon be split into separate process control and stream buffer classes, thanks to Angus Leeming. Possible Win32 version coming as well, thanks to Francis Andre. Release notes for PStreams 0.49 =============================== Seek operations on the streams are not supported. Trying to seek on a PStream object will cause std::ios_base::failbit to be set, requiring a call to std::basic_ios::clear() to clear the stream state and allow further I/O to take place. This behaviour is analogous to calling std::fseek() on a pipe, which always fails and sets errno to ESPIPE ("Illegal seek"). Fixed memory and file descriptor leaks that occurred if wait() reported the process had exited without close() having been called. Writing to process that has already exited no longer raises SIGPIPE. Fixed a serious bug where switching between reading stdout and stderr didn't update the streambuf's read position to point into the correct buffer. Jez Bromley has found that the eviscerated PStreams can not be used with the alpha's native cxx compiler in strict_ansi mode. To workaround this don't use strict_ansi and define __USE_STD_IOSTREAM to get the standard IOStream classes. Release notes for PStreams 0.48 =============================== This release includes changes to allow PStreams to be used with G++ 3.4, which is far more standards compliant that previous releases and caught several bugs in the code. Let me know if you have any problems. I've removed the rpstream.h header and moved the definition of the redi::rpstream class into pstream.h. This is now the only file needed. Please ensure you remove any copies of rpstream.h from your system if you're using this release. Fixed a 64-bit bug where int was compared to a pointer. The redi::peof IO manipulator now uses dynamic_cast not static_cast. This is safer, but if you don't want to use dynamic_cast you'll have to change it back to using static_cast. Use POSIX's ::_exit() instead of std::exit() to terminate child if exec() fails. This will prevent static destructors being run in the child process (which could try to destroy resources twice). I've also changed the macro that guards the pstream.h header from being included multiple times, by appending "_SEEN" to the names. If this causes any problems make sure you dont have any old versions of pstream.h on your system. This release has been long overdue and it shouldn't be as long before the next one. I have some good suggestions to incorporate. Thanks to everyone who suggested fixes and improvements, or just got in touch to say they were using the code. Jon Wakely The PStream Buffer class ============================ The pstreambuf used by the PStreams classes buffers all reads and writes as of version 0.42 (released 2002-12-03). Signalling and Termination ========================== The pstreambuf class now provides a kill(int) member function which is similar to the C library call and allows signals to be sent to the child. The stream buffer class also provides an exited() member which will return true if the child process has terminated, and a status() member which returns the exit status of the child. This exit status can be evaluated using the WIFEXITED() and related macros as with the C library function waitpid(). The Good, the Bad and the Ugly ============================== PStreams is intended to be a clean design based on the standard IOStreams, but first and foremost it's a handy little tool, and so should be as useful as possible. Because it is not always possible to redesign a program to use IOStreams instead of C-style I/O it is possible to expose some internal details of the PStreams classes. If the macro REDI_EVISCERATE_PSTREAMS has a non-zero value then the following public method is added to each stream class: pmode fopen(FILE*& in, FILE*& out, FILE*& err); Obtains FILE pointers relating to each open pipe to the process and assigns them to the corresponding FILE* parameters. These functions should be used with caution because mixing C++ and C I/O on the same stream may cause problems. The caller should be aware of the issues involved in using the stream buffer's FILE pointer (see your system's docs for the fdopen() function that is used by the pstreambuf). The fdopen() call to obtain a FILE* sets errno to ESPIPE because fdopen() tries to lseek() on the stream, which is not supported on pipes. This error is expected and does not cause a problem, so errno is set to zero before returning from pstreambuf::fopen(). $Id: README,v 1.21 2010/05/12 13:33:54 redi Exp $ :vim: set tw=78 pstreams-0.8.0/mainpage.html0000664000076400007640000001747312125352167014506 0ustar rediredi

A C++ iostream interface to POSIX process I/O.

The library is a work in progress. It is intended to provide a C++ re-implementation of the POSIX.2 functions popen(3) and pclose(3), using iostreams to read from and write to the opened process.

The advantages over the standard popen() function are:

  • Standard C++ interface. PStreams classes can be used in any code that expects an iostream class, giving all the advantages of type-safety and localisation that iostreams have over the printf()/scanf() functions in standard C.
  • Bidirectional I/O. Implementations of popen() vary between systems. Some systems use bidirectional pipes, allowing reading and writing on the same stream, but this is not supported everywhere. Because PStreams doesn't use popen() but re-implements it at a lower level, bidirectional I/O is available on all systems.
  • Reading from the process' stderr. Input PStreams can read from the process' stderr as well as stdout.
  • More flexible interface. In addition to handling a shell command in the same way as popen() the PStreams classes can open a process specified by a filename and a vector of arguments, similar to the execv() function.
  • Signals. The child process can be sent any signal, which can be used to kill or otherwise control it.

The library is available under the GNU Lesser General Public License

To help improve PStreams see the SourceForge project page.

 

Current status

Version 0.8.0

Working ipstream, opstream and pstream classes for ISO C++-compliant compilers. The classes are fully functional and the public interfaces should be stable for all except the pstreambuf class, which may be extended to add new features.

The stream buffer class, pstreambuf, doesn't use popen(). It uses up to three pipes shared with the associated process, giving access to any combination of the process' stdin, stdout and stderr streams. I/O operations on these pipes are buffered to avoid making a system call for every character written or read.

Another class, rpstream (Restricted PStream) is similar to pstream except that the child process' stdout and stderr cannot be read directly from an rpstream. To read from the process you must call either rpstream::out() or rpstream::err() to obtain a reference to an istream that reads from the process' corresponding output stream. This class is not as well tested as the others (i.e. it's hardly tested at all).

No code-conversion is performed on multi-byte character streams. It should be possible to use the PStreams classes templatized with character types other than char (e.g. basic_pstream<int>) but note that characters are transfered in a bytewise manner, so it is the programmer's responsibility to interpret the resulting character strings. Since the classes are intended to be used to read/write data between processes, which will usually share an internal character representation, rather than to/from files, this behaviour should be sufficient.

The PStreams code has not been optimised, the emphasis is on simplicity and correctness, not performance. If you have any performance benchmarks or ideas for (portable) ways to speed up the code then please share them.

 

Usage

Please refer to the doxygen-generated API documentation, accessible through the links at the top of the page.

Using the PStreams classes is similar to using a std::fstream, except that a shell command is given rather than a filename:


// print names of all header files in current directory
redi::ipstream in("ls ./*.h");
std::string str;
while (in >> str) {
    std::cout << str << std::endl;
}

The command argument is a pointer to a null-terminated string containing a shell command line. This command is passed to /bin/sh using the -c flag; Alias and wildcard interpretation, if any, is performed by the shell.

Alternatively, the process can be started with a vector of arguments:


// remove some files, capturing any error messages
std::vector<std::string> argv;
std::vector<std::string> errors;
argv.push_back("rm");
argv.push_back("-rf");
argv.push_back("./foo.txt");
argv.push_back("./bar.html");
argv.push_back("./fnord/");
redi::ipstream in("rm", argv, redi::pstreambuf::pstderr);
std::string errmsg;
while (std::getline(in, errmsg)) {
    errors.push_back(errmsg);
}

If this form of initialisation is used and the file argument doesn't contain a slash then the actions of the shell will be duplicated in searching for an executable in PATH. The shell will not interpret the other arguments, so wildcard expansion will not take place if this interface is used.

If an rpstream was used in the example above it would be necessary to replace the while condition like so:


while (std::getline(in.err(), errmsg)) {
    errors.push_back(errmsg);
}

This form can also be used with the unrestricted pstream and ipstream classes, but it is not strictly necessary.

Here is a more complete example, showing how to use std::istream::readsome() to read without blocking:

const pstreams::pmode mode = pstreams::pstdout|pstreams::pstderr;
ipstream child("echo OUT1; sleep 1; echo ERR >&2; sleep 1; echo OUT2", mode);
char buf[1024];
std::streamsize n;
bool finished[2] = { false, false };
while (!finished[0] || !finished[1])
{
    if (!finished[0])
    {
        while ((n = child.err().readsome(buf, sizeof(buf))) > 0)
            std::cerr.write(buf, n).flush();
        if (child.eof())
        {
            finished[0] = true;
            if (!finished[1])
                child.clear();
        }
    }

    if (!finished[1])
    {
        while ((n = child.out().readsome(buf, sizeof(buf))) > 0)
            std::cout.write(buf, n).flush();
        if (child.eof())
        {
            finished[1] = true;
            if (!finished[0])
                child.clear();
        }
    }
}

Since the underlying streams controlled by the pstreambuf are pipes, seek operations will not succeed. pstreambuf::seekoff() and pstreambuf::seekpos() will always fail, even for what may seem like no-ops, such as seeking with an offset of zero relative to the current position. Because the streambuf operations aren't successful and return off_type(-1), calling std::istream::seekg() or std::ostream::seekp() on a PStream object will cause failbit to be added to the stream state. Following this you will need to call std::basic_ios::clear() on the stream object to clear the stream state information before further I/O can take place. This behaviour is analogous to calling std::fseek() on a pipe, which always fails and sets errno to ESPIPE ("Illegal seek").


The latest version of PStreams can be found at http://pstreams.sf.net

pstreams-0.8.0/test_pstreams.cc0000664000076400007640000005475012125352167015242 0ustar rediredi/* PStreams - POSIX Process I/O for C++ Copyright (C) 2002-2010 Jonathan Wakely This file is part of PStreams. PStreams is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. PStreams is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #include // TODO test rpstream more // TODO test whether error_ cleared after successful open(). // TODO more tests for vector open() // test for failures. test opening pstream with neither pstdin nor pstdout. // maybe set failbit if !(mode&(pstdin|pstdout|pstderr)) ? // test passing std::ios::binary and others (should have no effect) // // test eviscerated pstreams #define REDI_EVISCERATE_PSTREAMS 1 #include "pstream.h" // include these after pstream.h to ensure it #includes everything it needs #include #include #include #include #include #include #include #include #include //#include #include #define PSTREAMS_VERSION_MAJOR PSTREAMS_VERSION & 0xff00 #define PSTREAMS_VERSION_MINOR PSTREAMS_VERSION & 0x00f0 #define PSTREAMS_VERSION_PATCHLEVEL PSTREAMS_VERSION & 0x000f #ifndef SLEEP_TIME // increase these if your OS takes a while for processes to exit # if defined (__sun) || defined(__APPLE__) # define SLEEP_TIME 2 # else # define SLEEP_TIME 1 # endif #endif using namespace std; using namespace redi; #if 0 // specialise basic_pstreambuf::sync() to add a delay, allowing // terminated processes to finish exiting, making it easier to detect // possible writes to closed pipes (which would raise SIGPIPE and exit). template <> int basic_pstreambuf::sync() { std::cout.flush(); // makes terminated process clean up faster. sleep(SLEEP_TIME+3); std::cout.flush(); // makes terminated process clean up faster. return !exited() && empty_buffer() ? 0 : -1; } #endif // explicit instantiations of template classes template class redi::basic_pstreambuf; template class redi::pstream_common; template class redi::basic_ipstream; template class redi::basic_opstream; template class redi::basic_pstream; template class redi::basic_rpstream; namespace // anon { // process' exit status int exit_status = 0; // helper functions for printing test results void test_type(istream const&, char& c, int& i) { static int count=0; c='r'; i=++count; } void test_type(ostream const&, char& c, int& i) { static int count=0; c='w'; i=++count; } void test_type(iostream const&, char& c, int& i) { static int count=0; c='b'; i=++count; } void test_type(rpstream const&, char& c, int& i) { static int count=0; c='x'; i=++count; } template string test_id(T const& s) { char label = '?'; int count = 0; test_type(s, label, count); ostringstream buf; buf << label << count; return buf.str(); } template void print_result(T const& s, bool result) { clog << "Test " << setw(4) << test_id(s) << ": " << (result ? "Pass" : "Fail!") << endl; exit_status += !result; } template bool check_pass(T const& s, bool expected = true) { const bool res = s.good() == expected; print_result(s, res); return res; } template bool check_fail(T const& s) { return check_pass(s, false); } // exit status of shell when command not found #if defined(__sun) int sh_cmd_not_found = 1; #else int sh_cmd_not_found = 127; #endif } sig_atomic_t sig_counter = 0; extern "C" void my_sig_handler(int) { ++sig_counter; } int main() { ios_base::sync_with_stdio(); const pstreams::pmode all3streams = pstreams::pstdin|pstreams::pstdout|pstreams::pstderr; string str; clog << "# Testing basic I/O\n"; { // test formatted output // // This should read the strings on stdin and print them on stdout // prefixed by "STDOUT: " opstream os("cat - /etc/resolv.conf | sed 's/^/STDIN: /'"); os << ".fnord.\n"; str = "..fnord..\n"; os << str << std::flush; check_pass(os); os << peof; check_pass(os); } { // test execve() style construction // // This should read the strings on stdin and print them on stdout // prefixed by "STDIN: " pstreams::argv_type argv; argv.push_back("sed"); argv.push_back("s/^/STDIN: /"); opstream os("sed", argv); check_pass(os << "Magic Monkey\n"); } { // test execve() style construction // // This should read the strings on stdin and print them on stdout // prefixed by "STDIN: " pstreams::argv_type argv; argv.push_back("sed"); argv.push_back("s/^/STDIN: /"); opstream os(argv); check_pass(os << "Tragic Donkey\n"); } { // test unformatted output // // This should read the strings on stdin and print them on stdout // prefixed by "STDIN: " opstream sed("sed 's/^/STDIN: /'"); str = "Monkey Magic\n"; for (string::const_iterator i = str.begin(); i!=str.end(); ++i) sed.put(*i); check_pass(sed); } { // test formatted input // should print hostname on stdout, prefixed by "STDOUT: " ipstream host("hostname"); if (getline(host, str)) // extracts up to newline, eats newline cout << "STDOUT: " << str << endl; check_pass(host); // check we hit EOF at next read char c; print_result(host, !host.get(c)); print_result(host, host.eof()); check_fail(host); } { // test unformatted input // should print hostname on stdout, prefixed by "STDOUT: " ipstream host("date"); str.clear(); char c; while (host.get(c)) // extracts up to EOF (including newline) str += c; cout << "STDOUT: " << str << flush; print_result(host, host.eof()); } { // open after construction, then write opstream os; os.open("sed 's/^/STDIN: /'"); os << "Hello, world!\n"; check_pass(os); } { // open after construction, then read ipstream is; is.open("hostname"); string s; is >> s; cout << "STDOUT: " << s << endl; check_pass(is); } { // open after construction, then write ipstream host; host.open("hostname"); if (host >> str) cout << "STDOUT: " << str << endl; check_pass(host); // chomp newline and try to read past end char c; host.get(c); host.get(c); check_fail(host); } clog << "# Testing bidirectional PStreams\n"; { // test reading from bidirectional pstream const string cmd = "grep '^127' /etc/hosts /no/such/file /dev/stdin"; pstream ps(cmd, all3streams); print_result(ps, ps.is_open()); check_pass(ps.out()); check_pass(ps.err()); ps << "127721\n" << peof; string buf; while (getline(ps.out(), buf)) cout << "STDOUT: " << buf << endl; check_fail(ps); ps.clear(); while (getline(ps.err(), buf)) cout << "STDERR: " << buf << endl; check_fail(ps); ps.clear(); } { // test input on bidirectional pstream // and test child moves onto next file after peof on stdin const string cmd = "grep fnord /etc/hosts /dev/stdin"; pstream ps(cmd, all3streams); print_result(ps, ps.is_open()); check_pass(ps); ps << "12345\nfnord\n0000" << peof; // manip calls ps.rdbuf()->peof(); string buf; getline(ps.out(), buf); do { print_result(ps, buf.find("fnord") != std::string::npos); cout << "STDOUT: " << buf << endl; } while (getline(ps.out(), buf)); check_fail(ps << "pipe closed, no fnord now"); } { // test signals const string cmd = "grep 127 -- -"; pstream ps(cmd, all3streams); ps << "fnord"; // write some output to buffer pstreambuf* pbuf = ps.rdbuf(); const int e1 = pbuf->error(); print_result(ps, e1 == 0); pbuf->kill(SIGTERM); const int e2 = pbuf->error(); print_result(ps, e1 == e2); sleep(SLEEP_TIME); // allow time for child process to exit completely // close() will call sync(), which shouldn't flush buffer after kill() pbuf->close(); const int e3 = pbuf->error(); check_fail(ps << "127 fail 127\n"); print_result(ps, e1 == e3); } { // test killing and checking for exit const string cmd = "grep '^127' -- -"; pstream ps(cmd, all3streams); print_result(ps, ps.is_open()); check_pass(ps.out()); check_pass(ps.err()); ps.rdbuf()->kill(); ::sleep(SLEEP_TIME); print_result(ps, ps.is_open()); print_result(ps, ps.rdbuf()->exited()); print_result(ps, !ps.is_open()); string buf; while (getline(ps.out(), buf)) cout << "STDOUT: " << buf << endl; check_fail(ps); ps.clear(); while (getline(ps.err(), buf)) cout << "STDERR: " << buf << endl; check_fail(ps); ps.clear(); } clog << "# Testing pstreambuf::exited()" << endl; { // test streambuf::exited() works sanely const string cmd = "cat"; opstream ps; pstreambuf* pbuf = ps.rdbuf(); print_result(ps, !pbuf->exited()); ps.open(cmd); print_result(ps, ps.is_open()); print_result(ps, !pbuf->exited()); ps.close(); print_result(ps, pbuf->exited()); check_pass(ps); ps.close(); // should set failbit on second call: check_fail(ps); ps.clear(); ps.open(cmd); print_result(ps, ps.is_open()); print_result(ps, !pbuf->exited()); ps.close(); print_result(ps, pbuf->exited()); } clog << "# Testing behaviour with bad commands" << endl; //string badcmd = "hgfhdgf"; const string badcmd = "hgfhdgf 2>/dev/null"; { // check is_open() works ipstream is(badcmd); // print_result(is, !is.is_open()); // XXX cannot pass this test! (void) is.err(); while (!is.rdbuf()->in_avail()) // need to wait for exit ::sleep(1); print_result(is, is.rdbuf()->exited() && !is.is_open()); } { // check is_open() works pstreams::argv_type argv; argv.push_back("hdhdhd"); argv.push_back("arg1"); argv.push_back("arg2"); ipstream ifail("hdhdhd", argv); print_result(ifail, !ifail.is_open()); } { // check eof() works ipstream is(badcmd); print_result(is, is.get()==EOF); print_result(is, is.eof() ); } { // test writing to bad command opstream ofail(badcmd); ::sleep(SLEEP_TIME); // this would cause SIGPIPE: ofail<<"blahblah"; // does not show failure: print_result(ofail, !ofail.is_open()); pstreambuf* buf = ofail.rdbuf(); print_result(ofail, buf->exited()); int status = buf->status(); print_result( ofail, WIFEXITED(status) && WEXITSTATUS(status) == sh_cmd_not_found ); } { // reading from bad cmd pstreams::argv_type argv; argv.push_back("hdhdhd"); argv.push_back("arg1"); argv.push_back("arg2"); ipstream ifail("hdhdhd", argv); check_fail(ifail>>str); } clog << "# Testing behaviour with uninit'ed streams" << endl; { // check eof() works ipstream is; print_result(is, is.get()==EOF); print_result(is, is.eof() ); } { // test writing to no command opstream ofail; check_fail(ofail<<"blahblah"); } clog << "# Testing other member functions\n"; { const string cmd("grep re"); opstream s(cmd); print_result(s, cmd == s.command()); } { const string cmd("grep re"); opstream s; s.open(cmd); print_result(s, cmd == s.command()); } { const string cmd("/bin/ls"); ipstream s(cmd); print_result(s, cmd == s.command()); } { const string cmd("/bin/ls"); ipstream s; s.open(cmd); print_result(s, cmd == s.command()); } { // testing streambuf::in_avail() ipstream in("{ printf 'this is ' ; sleep 2 ; printf 'hardcore' ; }"); sleep(1); streamsize avail = in.rdbuf()->in_avail(); print_result(in, avail > 0); print_result(in, size_t(avail) == strlen("this is ")); std::vector buf; int tries = 0; while (in && avail >= 0) { if (avail > 0) { if (tries) { cout << "Nothing to read " << tries << " times." << endl; tries = 0; } buf.resize(avail); in.readsome(&buf.front(), avail); cout << "STDOUT: " << avail << " characters: " << string(buf.begin(), buf.end()) << endl; } else ++tries; avail = in.rdbuf()->in_avail(); } if (tries) cout << "Nothing to read " << tries << " times." << endl; char c; check_pass(in); check_fail(in >> c); print_result(in, in.eof()); } // TODO more testing of other members clog << "# Testing writing to closed stream\n"; { opstream os("tr '[:lower:]' '[:upper:]' | sed 's/^/STDIN: /'"); os << "foo\n"; os.close(); if (os << "bar\n") cout << "Wrote to closed stream" << endl; check_fail(os << "bar\n"); } clog << "# Testing EOF detected correctly\n"; { pstream p("tr '[:lower:]' '[:upper:]'"); p << "newline\neof" << peof; string s; check_pass(std::getline(p.out(),s)); print_result(p, s.size()>0); cout << "STDOUT: " << s << endl; s.clear(); std::getline(p.out(),s); // sets eofbit print_result(p, p.eof()); print_result(p, s.size()>0); cout << "STDOUT: " << s << endl; } clog << "# Testing restricted pstream\n"; { rpstream rs("tr '[:lower:]' '[:upper:]'"); rs << "foo\n" << peof; string s; check_pass(std::getline(rs.out(),s)); print_result(rs, s.size()>0); cout << "STDOUT: " << s << endl; } clog << "# Testing for errors when seeking\n"; { ipstream in("hostname"); check_fail(in.seekg(0)); in.clear(); check_fail(in.seekg(0, std::ios_base::beg)); opstream out("cat"); check_fail(out.seekp(0)); out.clear(); check_fail(out.seekp(0, std::ios_base::beg)); } clog << "# Testing read position tracked correctly\n"; { ipstream in("echo 'abc' >&2 && echo '123'", all3streams); string s; s += in.out().get(); s += in.err().get(); s += in.out().get(); s += in.err().get(); s += in.out().get(); s += in.err().get(); const string s_expected = "1a2b3c"; cout << s << " == " << s_expected << endl; print_result(in, s == s_expected); print_result(in, in.out().get() == '\n'); print_result(in, in.err().get() == '\n'); char c; check_fail(in.out().get(c)); in.clear(); // clear EOF check_fail(in.err().get(c)); } clog << "# Testing initial pmode set correctly\n"; { char c; string s; ipstream in("echo 'abc' >&2", pstreambuf::pstderr); print_result(in, getline(in, s)); print_result(in, s == "abc"); check_fail(in.get(c)); in.close(); in.clear(); // clear EOF s.erase(); in.open("echo 'abc'", pstreambuf::pstdout); print_result(in, getline(in, s)); print_result(in, s == "abc"); check_fail(in.get(c)); in.close(); in.clear(); // clear EOF s.erase(); in.open("echo 'abc' >&2", pstreambuf::pstderr); print_result(in, getline(in, s)); print_result(in, s == "abc"); check_fail(in.get(c)); in.close(); in.clear(); // clear EOF s.erase(); } #if REDI_EVISCERATE_PSTREAMS clog << "# Testing eviscerated pstream\n"; { opstream os("tr '[:lower:]' '[:upper:]' | sed 's/^/STDIN: /'"); FILE *in, *out, *err; size_t res = os.fopen(in, out, err); print_result(os, res & pstreambuf::pstdin); print_result(os, in!=NULL); int i = fputs("flax\n", in); fflush(in); print_result(os, i>=0 && i!=EOF); } { string cmd = "ls /etc/hosts /no/such/file"; ipstream is(cmd, pstreambuf::pstdout|pstreambuf::pstderr); FILE *in, *out, *err; size_t res = is.fopen(in, out, err); print_result(is, res & pstreambuf::pstdout); print_result(is, res & pstreambuf::pstderr); print_result(is, out!=NULL); print_result(is, err!=NULL); const size_t len = 256; char buf[len]; char* p = fgets(buf, len, out); cout << "STDOUT: " << buf; print_result(is, p!=NULL); p = fgets(buf, len, err); cout << "STDERR: " << buf; print_result(is, p!=NULL); } { string cmd = "grep 127 -- - /etc/hosts /no/such/file"; pstream ps(cmd, all3streams); FILE *in, *out, *err; size_t res = ps.fopen(in, out, err); print_result(ps, res & pstreambuf::pstdin); print_result(ps, res & pstreambuf::pstdout); print_result(ps, res & pstreambuf::pstderr); print_result(ps, in!=NULL); print_result(ps, out!=NULL); print_result(ps, err!=NULL); // ps << "12345\n1112777\n0000" << EOF; #if 0 size_t len = 256; char buf[len]; char* p = fgets(buf, len, out); cout << "STDOUT: " << buf; print_result(ps, p!=NULL); p = fgets(buf, len, err); cout << "STDERR: " << buf; print_result(ps, p!=NULL); #endif } #endif clog << "# Testing resources freed correctly\n"; { const int next_fd = dup(0); ::close(next_fd); pstream p("cat", all3streams); p << "fnord" << peof; ::sleep(SLEEP_TIME); // wait for process to exit p.rdbuf()->exited(); // test for exit, destroys write buffer // check we can still read the output std::string s; print_result(p, p >> s || p.err() >> s); p.close(); // destroys read buffers, closes all pipes check_fail(p >> s); // check no open files except for stdin, stdout, stderr int fd = dup(0); print_result(p, next_fd == fd); ::close(fd); // reopen and check again with vector-open std::vector argv; argv.push_back("cat"); p.open(argv[0], argv, all3streams); p.close(); // reopen and check again p.open(argv[0], all3streams); p.close(); fd = dup(0); print_result(p, next_fd == fd); ::close(fd); } { // let's see if we can leak in the face of signals... const int next_fd = dup(0); ::close(next_fd); typedef struct sigaction sa; sa act = sa(), oldact; act.sa_handler = my_sig_handler; sigaction(SIGALRM, &act, &oldact); std::vector argv; argv.push_back("sleep 5"); ipstream in(argv[0]); alarm(3); // close() should hang until interrupted then finish closing in.close(); // check no open files except for stdin, stdout, stderr int fd = dup(0); print_result(in, fd == next_fd); ::close(fd); in.open(argv[0], argv); alarm(3); in.close(); sigaction(SIGALRM, &oldact, 0); // check no open files except for stdin, stdout, stderr fd = dup(0); print_result(in, fd == next_fd); ::close(fd); class pguard { public: explicit pguard(ipstream& in, int signal=SIGKILL) : buf_(*in.rdbuf()), signal_(signal) { } ~pguard() { if (signal_) buf_.kill(signal_); } void release() { signal_ = 0; } private: pstreambuf& buf_; int signal_; }; in.clear(); in.open("echo sleeping && sleep 5"); std::string s; print_result(in, in.is_open() && in >> s); sigaction(SIGALRM, &act, &oldact); sig_counter = 0; alarm(3); try { pguard pg(in, SIGTERM); // should kill child throw 0; } catch(...) { in.close(); // should return immediately if child killed print_result(in, alarm(0) > 0 && sig_counter == 0); sigaction(SIGALRM, &oldact, 0); int status = in.rdbuf()->status(); print_result(in, WIFSIGNALED(status) && WTERMSIG(status)==SIGTERM); } } clog << "# Testing wide chars\n"; { ipstream dummy("true"); basic_ipstream in("cat ./pstreams.wout"); wstring s; in >> s; wcout << s; print_result(dummy, in); wchar_t wc; int count=0, gcount=0; while (in.get(wc)) { wcout << wc; ++count; gcount += in.gcount(); } wcout << L'\n'; print_result(dummy, in.eof() && in.fail()); print_result(dummy, gcount == count); wcout << L"Read: " << gcount << L" chars." << endl; } return exit_status; } pstreams-0.8.0/test_minimum.cc0000664000076400007640000000153312077110431015036 0ustar rediredi#include "pstream.h" #include // TODO abstract process creation and control to a process class. template class redi::basic_pstreambuf; template class redi::pstream_common; template class redi::basic_pstream; template class redi::basic_ipstream; template class redi::basic_opstream; template class redi::basic_rpstream; int main() { using namespace redi; char c; ipstream who("id -un"); if (!(who >> c)) return 1; redi::opstream cat("cat"); if (!(cat << c)) return 2; while (who >> c) cat << c; cat << '\n' << peof; pstream fail("ghghghg", pstreambuf::pstderr); std::string s; if (!std::getline(fail, s)) return 3; std::cerr << s << '\n'; rpstream who2("id -un"); if (!(who2.out() >> c)) return 4; } pstreams-0.8.0/pstreams-devel.spec0000664000076400007640000000433112125352167015633 0ustar rediredi%define packagename pstreams Name: pstreams-devel Version: 0.8.0 Release: 1%{?dist} Summary: POSIX Process Control in C++ Group: Development/Libraries License: LGPLv3+ URL: http://%{packagename}.sourceforge.net/ Source0: http://downloads.sourceforge.net/%{packagename}/%{packagename}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: doxygen BuildArch: noarch %description PStreams class is like a C++ wrapper for the POSIX.2 functions popen(3) and pclose(3), using C++ iostreams instead of C's stdio library. %prep %setup -q -n %{packagename}-%{version} %build make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT includedir=%{_includedir} %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc doc/html COPYING.LIB README AUTHORS ChangeLog %{_includedir}/pstreams %changelog * Wed Jan 23 2013 Jonathan Wakely - 0.8.0-1 - Update version. * Thu Oct 14 2010 Jonathan Wakely - 0.7.1-1 - Update version and override includedir make variable instead of prefix. * Wed May 12 2010 Jonathan Wakely - 0.7.0-1 - Add spec file to upstream repo and update. * Sun Jul 26 2009 Fedora Release Engineering - 0.6.0-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild * Thu Feb 26 2009 Fedora Release Engineering - 0.6.0-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild * Fri Nov 07 2008 Rakesh Pandit 0.6.0-6 - timestamp patch (Till Mass) * Fri Nov 07 2008 Rakesh Pandit 0.6.0-5 - saving timestamp using "install -p" * Fri Nov 07 2008 Rakesh Pandit 0.6.0-4 - included docs, license and other missing files. * Fri Nov 07 2008 Rakesh Pandit 0.6.0-3 - consistent use of macros - replaced %%{buildroot} with $RPM_BUILD_ROOT * Thu Nov 06 2008 Rakesh Pandit 0.6.0-2 - Cleaned up buildrequire * Tue Nov 04 2008 Rakesh Pandit 0.6.0-1 - initial package