Loading slc/trunk/src/connection.cc +19 −3 Original line number Diff line number Diff line Loading @@ -20,12 +20,10 @@ void Connection::start() { // send pass info return; } void Connection::stop() { return; disconnect_(); } void Connection::connect_(const char *addr, int port) { Loading Loading @@ -67,3 +65,21 @@ void Connection::disconnect_() { socket_ = 0; } void Connection::send(const string &data) { send(data.c_str(), data.length()); } void Connection::send(const char* buf, size_t len) { write(socket_, buf, len); } void Connection::sendln(const string &data) { sendln(data.c_str(), data.length()); } void Connection::sendln(const char* buf, size_t len) { write(socket_, buf, len); write(socket_, "\n", 1); } slc/trunk/src/connection.hh +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ public: void stop(); void send(const string &data); void send(const char* buf, size_t len); void sendln(const string &data); void sendln(const char* buf, size_t len); string recvln(); private: void connect_(const char *addr, int port); Loading slc/trunk/src/screen.cc +31 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "options.hh" #include "error.hh" #include "history.hh" #include "connection.hh" /* ********************************************************************************* Loading Loading @@ -193,8 +194,8 @@ void Screen::eventsloop() { if (*cmd_buffer_ == 0) break; // save in history H.add(cmd_buffer_); // print to msg msg_println(cmd_buffer_); // Send to execution cmd_exec(cmd_buffer_); // purge buffer *cmd_buffer_ = 0; cmd_buf_off_ = 0; Loading Loading @@ -498,6 +499,34 @@ void Screen::msg_save(const string &filename) const { } /*! ** Exec command or send if @param s is not a command. */ void Screen::cmd_exec(const char *s) { // string is a local command if (*s == '/') { if (!strcmp(s, "/exit")) { S << s << "\n"; exit(0); } else if (!strcmp(s, "/logout")) { C.stop(); S << s << "\n"; } else if (!strcmp(s, "/login")) { C.start(); S << s << "\n"; } else S << s << ": Unkown command.\n"; } // String is a remote command else { C.sendln(s, strlen(s)); msg_println(s); } } /*! ** This is a sugar to print msg on msg window ** Loading slc/trunk/src/screen.hh +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ private: void create_windows(); void cmd_draw(); void cmd_exec(const char *s); void msg_draw(); void msg_add(const string &s); Loading Loading
slc/trunk/src/connection.cc +19 −3 Original line number Diff line number Diff line Loading @@ -20,12 +20,10 @@ void Connection::start() { // send pass info return; } void Connection::stop() { return; disconnect_(); } void Connection::connect_(const char *addr, int port) { Loading Loading @@ -67,3 +65,21 @@ void Connection::disconnect_() { socket_ = 0; } void Connection::send(const string &data) { send(data.c_str(), data.length()); } void Connection::send(const char* buf, size_t len) { write(socket_, buf, len); } void Connection::sendln(const string &data) { sendln(data.c_str(), data.length()); } void Connection::sendln(const char* buf, size_t len) { write(socket_, buf, len); write(socket_, "\n", 1); }
slc/trunk/src/connection.hh +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ public: void stop(); void send(const string &data); void send(const char* buf, size_t len); void sendln(const string &data); void sendln(const char* buf, size_t len); string recvln(); private: void connect_(const char *addr, int port); Loading
slc/trunk/src/screen.cc +31 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "options.hh" #include "error.hh" #include "history.hh" #include "connection.hh" /* ********************************************************************************* Loading Loading @@ -193,8 +194,8 @@ void Screen::eventsloop() { if (*cmd_buffer_ == 0) break; // save in history H.add(cmd_buffer_); // print to msg msg_println(cmd_buffer_); // Send to execution cmd_exec(cmd_buffer_); // purge buffer *cmd_buffer_ = 0; cmd_buf_off_ = 0; Loading Loading @@ -498,6 +499,34 @@ void Screen::msg_save(const string &filename) const { } /*! ** Exec command or send if @param s is not a command. */ void Screen::cmd_exec(const char *s) { // string is a local command if (*s == '/') { if (!strcmp(s, "/exit")) { S << s << "\n"; exit(0); } else if (!strcmp(s, "/logout")) { C.stop(); S << s << "\n"; } else if (!strcmp(s, "/login")) { C.start(); S << s << "\n"; } else S << s << ": Unkown command.\n"; } // String is a remote command else { C.sendln(s, strlen(s)); msg_println(s); } } /*! ** This is a sugar to print msg on msg window ** Loading
slc/trunk/src/screen.hh +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ private: void create_windows(); void cmd_draw(); void cmd_exec(const char *s); void msg_draw(); void msg_add(const string &s); Loading