Definition at line 66 of file file_port.cpp.
file_port_rep | ( | int | kind, | |
FILE * | f2, | |||
bool | cf2, | |||
bool | lock2, | |||
const string & | name2 | |||
) | [inline] |
Definition at line 105 of file file_port.cpp.
References mmx::get_lock().
00106 : 00107 posix_port_rep (kind, fileno (f2)), 00108 f (f2), cf (cf2), lock (lock2), name (name2), next (-1) { 00109 if (lock) get_lock (f, this->kind); } inline ~file_port_rep () {
~file_port_rep | ( | ) | [inline] |
Definition at line 110 of file file_port.cpp.
References mmx::release_lock().
00110 { 00111 if (lock) release_lock (f); 00112 if (cf) fclose (f); }
port accept | ( | ) | [virtual, inherited] |
Reimplemented in socket_port_rep.
Definition at line 88 of file port.cpp.
References ERROR, port_rep::expression(), mmx::lf, and mmx::mmerr.
00088 { 00089 mmerr << "port= " << expression () << lf; 00090 ERROR ("socket server port expected"); 00091 }
bool busy | ( | ) | [inline, virtual] |
Reimplemented from posix_port_rep.
Definition at line 80 of file file_port.cpp.
References file_port_rep::can_read(), and posix_port_rep::kind.
nat can_read | ( | ) | [inline, virtual] |
Reimplemented from posix_port_rep.
Definition at line 88 of file file_port.cpp.
References posix_port_rep::kind.
Referenced by file_port_rep::busy().
00088 { 00089 if (next != -1) return 1; 00090 if (this->kind == 1 || feof (f) != 0) return 0; 00091 next= fgetc (f); 00092 if (next != -1) return 1; 00093 return 0; 00094 }
nat can_write | ( | ) | [inline, virtual] |
Reimplemented from posix_port_rep.
Definition at line 84 of file file_port.cpp.
References posix_port_rep::kind.
Reimplemented in composite_port_rep, and formatting_port_rep.
Definition at line 94 of file port.cpp.
References ERROR, port_rep::expression(), mmx::lf, and mmx::mmerr.
00094 { 00095 mmerr << "port= " << expression () << lf; 00096 ERROR ("composite port expected"); 00097 }
bool error_flag | ( | ) | [virtual, inherited] |
Reimplemented in composite_port_rep, formatting_port_rep, and error_port_rep.
string error_message | ( | ) | [virtual, inherited] |
Reimplemented in composite_port_rep, formatting_port_rep, and error_port_rep.
syntactic expression | ( | ) | const [inline, virtual] |
Implements port_rep.
Definition at line 74 of file file_port.cpp.
References posix_port_rep::kind, and mmx::syn().
void feed | ( | ) | [virtual, inherited] |
Reimplemented in socket_port_rep.
Definition at line 67 of file posix_port.cpp.
References posix_port_rep::alive, posix_port_rep::buffer, ERROR, posix_port_rep::fd, posix_port_rep::read(), and posix_port_rep::wait().
Referenced by posix_port_rep::busy(), posix_port_rep::can_read(), and posix_port_rep::read().
00067 { 00068 while (alive && wait (0)) { 00069 int r; 00070 char tempout[1024]; 00071 r = ::read (fd, tempout, 1024); 00072 if (r == -1) { 00073 #if defined(__MINGW__) || defined(__MINGW32__) 00074 _cwait (NULL, 0, _WAIT_CHILD); 00075 #else 00076 ::wait (NULL); 00077 #endif 00078 ERROR ("read failed"); 00079 } 00080 else if (r == 0) alive= false; 00081 else buffer << string (tempout, r); 00082 } 00083 }
void flush | ( | ) | [inline, virtual] |
void format | ( | const print_format & | fm | ) | [virtual, inherited] |
Reimplemented in formatting_port_rep.
Definition at line 100 of file port.cpp.
References ERROR, port_rep::expression(), mmx::lf, and mmx::mmerr.
00100 { 00101 mmerr << "port= " << expression () << lf; 00102 ERROR ("formatting port expected"); 00103 }
virtual bool is_input_port | ( | ) | [inline, virtual, inherited] |
Reimplemented from port_rep.
Definition at line 40 of file posix_port.hpp.
References posix_port_rep::kind.
00040 { return (kind & 2) != 0; }
virtual bool is_output_port | ( | ) | [inline, virtual, inherited] |
Reimplemented from port_rep.
Definition at line 39 of file posix_port.hpp.
References posix_port_rep::kind.
00039 { return (kind & 1) != 0; }
void read | ( | char * | s, | |
nat | n | |||
) | [inline, virtual] |
Reimplemented from posix_port_rep.
Definition at line 98 of file file_port.cpp.
virtual void send | ( | const char * | s, | |
nat | n | |||
) | [virtual, inherited] |
Referenced by posix_port_rep::write().
bool wait | ( | int | msecs | ) | [virtual, inherited] |
Reimplemented from port_rep.
Definition at line 86 of file posix_port.cpp.
References posix_port_rep::alive, posix_port_rep::fd, and posix_port_rep::kind.
Referenced by socket_port_rep::accept(), socket_port_rep::feed(), and posix_port_rep::feed().
00086 { 00087 //mmout << "Wait " << msecs << " ms on " << expression () << "\n"; 00088 if ((kind & 2) == 0 || !alive) return false; 00089 fd_set in_fds; 00090 FD_ZERO (&in_fds); 00091 FD_SET (fd, &in_fds); 00092 00093 nat nr; 00094 struct timeval tv; 00095 tv.tv_sec = msecs / 1000; 00096 tv.tv_usec = 1000 * (msecs % 1000); 00097 if (msecs < 0) nr= select (fd + 1, &in_fds, NULL, NULL, NULL); 00098 else nr= select (fd + 1, &in_fds, NULL, NULL, &tv); 00099 //mmout << "Received " << nr << " on " << fd << "\n"; 00100 return nr > 0; 00101 }
void write | ( | const char * | s, | |
nat | n | |||
) | [inline, virtual] |
Reimplemented from posix_port_rep.
Definition at line 96 of file file_port.cpp.
bool alive [protected, inherited] |
Definition at line 32 of file posix_port.hpp.
Referenced by socket_port_rep::accept(), posix_port_rep::busy(), posix_port_rep::can_write(), socket_port_rep::feed(), posix_port_rep::feed(), socket_port_rep::send(), and posix_port_rep::wait().
Definition at line 30 of file posix_port.hpp.
Referenced by posix_port_rep::busy(), posix_port_rep::can_read(), socket_port_rep::feed(), posix_port_rep::feed(), and posix_port_rep::read().
int fd [protected, inherited] |
Definition at line 29 of file posix_port.hpp.
Referenced by socket_port_rep::accept(), socket_port_rep::feed(), posix_port_rep::feed(), posix_port_rep::posix_port_rep(), socket_port_rep::send(), posix_port_rep::wait(), pipe_port_rep::~pipe_port_rep(), posix_port_rep::~posix_port_rep(), and socket_port_rep::~socket_port_rep().
int kind [protected, inherited] |
Definition at line 28 of file posix_port.hpp.
Referenced by file_port_rep::busy(), file_port_rep::can_read(), file_port_rep::can_write(), file_port_rep::expression(), posix_port_rep::is_input_port(), posix_port_rep::is_output_port(), posix_port_rep::posix_port_rep(), posix_port_rep::wait(), and posix_port_rep::~posix_port_rep().
Definition at line 31 of file posix_port.hpp.
Referenced by posix_port_rep::busy(), posix_port_rep::can_read(), socket_port_rep::feed(), and posix_port_rep::read().