X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FServer.hh;h=53aa9697eb0c0844cf69dbb99bf79bf96a3b36f0;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=ef38917a2c382726e827cb8a5dc9b9e8889b8fc0;hpb=958bdb52c39fa39f4ef91cafd9628bcb4f85a03c;p=senf.git diff --git a/Utils/Console/Server.hh b/Utils/Console/Server.hh index ef38917..53aa969 100644 --- a/Utils/Console/Server.hh +++ b/Utils/Console/Server.hh @@ -168,14 +168,51 @@ namespace console { void stop(); ///< Stop the client /**< This will close the client socket. */ - std::string const & name() const; - ClientHandle handle() const; - std::ostream & stream(); - std::string promptString() const; - DirectoryNode & root() const; - Server::Mode mode() const; + std::string const & name() const; ///< Get name of the client instance + /**< This name is used in the prompt string and is set by + the server. */ + ClientHandle handle() const; ///< Get the client's network socket handle + std::ostream & stream(); ///< Get client's output stream + /**< Data sent to this stream is sent out over the network + via the client's socket handle. Write operation is + non-blocking and data may be dropped. Data is written + using Client::write(). */ + std::string promptString() const; ///< Get the prompt string + DirectoryNode & root() const; ///< Get configured root node + DirectoryNode & cwd() const; ///< Get current directory + /**< This is the directory, the console currently is changed + into by the user of the console. */ + Server::Mode mode() const; ///< Get operation mode + /**< \see Server::mode() */ + void write(std::string const & data) const; + ///< Write data to network socket + /**< The data is automatically filtered depending on the + type of connection (e.g. on a telnet connection, + specific bytes are quoted). */ + std::string const & backtrace() const; ///< Get backtrace of last console error, if any + unsigned width() const; ///< Get console width + /**< If possible, this will be the width of the connected + terminal, otherwise a default value (normally 80) is + returned. */ static Client & get(std::ostream & os); + ///< Access client instance + /**< Allows to access the client instance from console + command implementations. The first argument to a + console command is a stream object. \e If this stream + object belongs to a network console client, this call + will return the associated Client instance reference. + \throws std::bad_cast if \a os is not associated with a + Client instance. */ + static unsigned getWidth(std::ostream & os, unsigned defaultWidth = 0, + unsigned minWidth = 0); + ///< Get width of client console if possible + /**< If possible, the width of the client console attached + to the stream \a os is returned. If this is not + possible, the \a defaultValue will be used. + + If the width obtained this way is smaller than \a + minWidth, \a defaultValue will be returned instead. */ protected: @@ -184,8 +221,7 @@ namespace console { void setInteractive(); void setNoninteractive(); - - void translate(std::string & data); + size_t handleInput(std::string input, bool incremental = false); virtual void v_write(senf::log::time_type timestamp, std::string const & stream, std::string const & area, unsigned level, @@ -198,13 +234,21 @@ namespace console { CommandParser parser_; Executor executor_; std::string name_; - std::string lastCommand_; boost::scoped_ptr reader_; Server::Mode mode_; + std::string backtrace_; friend class Server; friend class detail::ClientReader; friend class detail::NonblockingSocketSink; + + class SysBacktrace + { + SysBacktrace(); + static void backtrace(std::ostream & os); + static SysBacktrace instance_; + }; + }; /** \brief Output Console Client instance as it's string representation