fp)) { $this->close(); } } public function __construct($fp){ $this->set_stream_fp($fp); } /** * Close fp resource * * @return bool */ public function close(){ if (is_resource($this->fp)) { fclose($this->fp); return true; } trigger_error('no stream resource to close', E_USER_NOTICE); } /** * Enter description here... * * @return bool */ public function eof(){ if (is_resource($this->fp)) { return foef($this->fp); } trigger_error("No connection open", E_USER_NOTICE); } /** * Enter description here... * * @param int $length * @return string */ public function read($length = 2048){ if (is_resource($this->fp)) { return fread($this->fp, $length); } trigger_error("No connection open", E_USER_NOTICE); } /** * Enter description here... * * @return string */ public function get(){ if (is_resource($this->fp)) { return fgets($this->fp); } trigger_error("No connection open", E_USER_NOTICE); } /** * Enter description here... * * @param string $string * @return bool */ public function write($string){ if (is_resource($this->fp)) { fwrite($this->fp, $string, strlen($string)); return true; } trigger_error("No connection open", E_USER_NOTICE); } /** * Enter description here... * * @param string $string * @return bool */ public function put($string){ if (is_resource($this->fp)) { fputs($this->fp,$string); return true; } trigger_error("No connection open", E_USER_NOTICE); } /** * Enter description here... * * @param fp resource $fp * @return bool */ protected function set_stream_fp($fp){ if (is_resource($fp) && !is_resource($this->fp)) { $this->fp = $fp; $this->set_io_watches(); return true; } trigger_error('stream resource invalid or already set', E_USER_NOTICE); return false; } /** * Called when there is data to read * * @return bool */ protected function io_in($fp){ return true; } /** * Called when data can be written (without blocking) * * @return bool */ protected function io_out($fp){ return true; } /** * Enter description here... * * @return bool */ protected function io_hup($fp){ return true; } /** * Enter description here... * * @return bool */ protected function io_pri($fp){ return true; } /** * Enter description here... * * @return bool */ protected function io_nval($fp){ return true; } /** * Enter description here... * * @return bool */ protected function set_io_watches(){ if (is_resource($this->fp)) { parent::io_add_watch($this->fp, Gtk::IO_IN, array($this, 'io_in'),$this->fp); parent::io_add_watch($this->fp, Gtk::IO_OUT, array($this, 'io_out'),$this->fp); parent::io_add_watch($this->fp, Gtk::IO_HUP, array($this, 'io_hup'),$this->fp); parent::io_add_watch($this->fp, Gtk::IO_PRI, array($this, 'io_pri'),$this->fp); parent::io_add_watch($this->fp, Gtk::IO_ERR, array($this, 'io_err'),$this->fp); parent::io_add_watch($this->fp, Gtk::IO_NVAL, array($this, 'io_nval'),$this->fp); return true; } return false; } } ?>