- Timestamp:
- 03/05/08 13:57:16 (5 years ago)
- Location:
- lang/c/partty/trunk
- Files:
-
- 4 modified
-
emtelnet.cc (modified) (1 diff)
-
host.cc (modified) (1 diff)
-
multiplexer.cc (modified) (3 diffs)
-
multiplexer.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/partty/trunk/emtelnet.cc
r7417 r7485 124 124 { 125 125 owrite3(IAC, SB, cmd); 126 owrite((const byte*)msg, len); 126 // don't send IAC alone 127 #ifdef EMTELNET_CONVERT_CRLF_LF 128 // don't convert CRLF to LF 129 const byte* p = (const byte*)msg; 130 const byte* endp = p + len; 131 for(; p != endp; ++p) { 132 if( *p == IAC ) { 133 owrite2(IAC, IAC); 134 } else { 135 owrite1(*p); 136 } 137 } 138 #else 139 send(msg, len); 140 #endif 127 141 owrite2(IAC, SE); 128 142 } -
lang/c/partty/trunk/host.cc
r7473 r7485 219 219 } else if( len == 0 ) { throw io_end_error("server connection closed"); } 220 220 // ロック中ならServerからの入力は捨てる 221 if( m_locking ) { return 0; } 221 if( m_locking ) { return 0; } // XXX Telnetの返答も無視している 222 222 // Telnetフィルタ 223 223 m_telnet.recv(shared_buffer, len); -
lang/c/partty/trunk/multiplexer.cc
r7472 r7485 19 19 // FIXME perror -> ログ 20 20 21 filt_telnetd::filt_telnetd( ) :21 filt_telnetd::filt_telnetd(sender_telnetd& host_telnet) : 22 22 emtelnet((void*)this), 23 m_enable_ws(true) // XXX デフォルトtrue 23 m_host_telnet(host_telnet), 24 m_enable_ws(false) 24 25 { 25 26 // use these options … … 60 61 void filt_telnetd::enable_ws_handler(char cmd, bool sw, emtelnet& base) 61 62 { 62 static_cast<filt_telnetd&>(base).m_enable_ws = sw; 63 filt_telnetd& self( static_cast<filt_telnetd&>(base) ); 64 self.m_enable_ws = sw; 65 if(sw) { 66 sender_telnetd& host( self.m_host_telnet ); 67 if( host.ws_initialized() ) { 68 // 初期ウィンドウサイズを設定 69 if( host.ws_initialized() ) { 70 char sbbuf[4]; 71 *((short*)sbbuf) = htons(host.get_rows()); 72 *((short*)(sbbuf+2)) = htons(host.get_cols()); 73 self.send_ws(sbbuf, sizeof(sbbuf)); 74 } 75 } 76 } 63 77 } 64 78 … … 250 264 return 0; 251 265 } 252 guest_set.set (guest);266 guest_set.set<sender_telnetd&>(guest, m_host_telnet); 253 267 // 書き込み待ちバッファにSERVER_WELCOME_MESSAGEを加える 254 268 guest_set.data(guest).send(SERVER_WELCOME_MESSAGE, strlen(SERVER_WELCOME_MESSAGE), NULL); 255 269 num_guest++; 256 // 初期ウィンドウサイズを設定257 if( m_host_telnet.ws_initialized() ) {258 char sbbuf[4];259 *((short*)sbbuf) = htons(m_host_telnet.get_rows());260 *((short*)(sbbuf+2)) = htons(m_host_telnet.get_cols());261 guest_set.data(guest).send_ws(sbbuf, sizeof(sbbuf));262 }263 270 return 0; 264 271 } -
lang/c/partty/trunk/multiplexer.h
r7417 r7485 8 8 namespace Partty { 9 9 10 class sender_telnetd : public emtelnet { 11 public: 12 sender_telnetd(); 13 private: 14 static void pass_through_handler(char cmd, bool sw, emtelnet& base) {} 15 static void window_size_handler(char cmd, const char* msg, size_t len, emtelnet& self); 16 public: 17 void ws_change(short cols, short rows) { 18 m_cols = cols; 19 m_rows = rows; 20 m_ws_changed = true; 21 } 22 bool ws_changed(void) const { return m_ws_changed; } 23 short get_cols(void) const { return m_cols; } 24 short get_rows(void) const { return m_rows; } 25 void ws_flush(void) { m_ws_changed = false; } 26 bool ws_initialized(void) const { return (m_cols != 0 && m_rows != 0); } 27 private: 28 short m_cols; 29 short m_rows; 30 bool m_ws_changed; 31 }; 32 33 10 34 class filt_telnetd : public emtelnet { 11 35 public: … … 15 39 }; 16 40 public: 17 filt_telnetd();41 explicit filt_telnetd(sender_telnetd& host_telnet); 18 42 inline void send(const void* buf, size_t len, buffer_t* out); 19 43 inline void recv(const void* buf, size_t len, buffer_t* in, buffer_t* out); … … 31 55 static void pass_through_handler(char cmd, bool sw, emtelnet& base) {} 32 56 static void enable_ws_handler(char cmd, bool sw, emtelnet& base); 57 sender_telnetd& m_host_telnet; 33 58 bool m_enable_ws; 34 59 }; … … 69 94 out->len = olength; 70 95 } 71 72 73 class sender_telnetd : public emtelnet {74 public:75 sender_telnetd();76 private:77 static void pass_through_handler(char cmd, bool sw, emtelnet& base) {}78 static void window_size_handler(char cmd, const char* msg, size_t len, emtelnet& self);79 public:80 void ws_change(short cols, short rows) {81 m_cols = cols;82 m_rows = rows;83 m_ws_changed = true;84 }85 bool ws_changed(void) const { return m_ws_changed; }86 short get_cols(void) const { return m_cols; }87 short get_rows(void) const { return m_rows; }88 void ws_flush(void) { m_ws_changed = false; }89 bool ws_initialized(void) const { return (m_cols != 0 && m_rows != 0); }90 private:91 short m_cols;92 short m_rows;93 bool m_ws_changed;94 };95 96 96 97
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)