/* This file is part of cardwords
   (c) 1998 1999 2000 Tobias Peters
   see file COPYING for the copyright terms.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program 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 General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_pipe.hh

#ifndef CARDWORDS_PIPE_HH
#define CARDWORDS_PIPE_HH
namespace CardWords {

class Pipe {
public:
  // construct the pipe:
  Pipe(unsigned int tries = 1);
  
  int
  get_talkFD(void)const;
  int
  get_listenFD(void)const;

  // test if everything went ok so far:
  bool is_good(void) const;
  bool is_bad(void) const;

  // get the error number of the last error:
  int
  get_errno (void);

  // ignore an error:
  void
  set_good(void);

  // close one end of the line:
  int
  close_talk(void);

  int
  close_listen(void);

  // the destructor closes open FD's:
  ~Pipe();

private:
  int talkFD, listenFD;
  bool talkOpen, listenOpen;
  bool good;
  int my_errno;
};
}
#endif

