PTLib  Version 2.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PCLITelnet Class Reference

Command Line Interpreter over Telnet sockets. More...

#include <cli.h>

Inheritance diagram for PCLITelnet:
PCLISocket PCLI PObject

Public Member Functions

Construction
 PCLITelnet (WORD port=0, const char *prompt=NULL, bool singleThreadForAll=false)
- Public Member Functions inherited from PCLISocket
 PCLISocket (WORD port=0, const char *prompt=NULL, bool singleThreadForAll=false)
 ~PCLISocket ()
virtual bool Start (bool runInBackground=true)
 Start a command line interpreter.
virtual void Stop ()
 Stop and clean up command line interpreters.
virtual Context * AddContext (Context *context=NULL)
 Add a command line interpreter context to the system.
virtual void RemoveContext (Context *context)
 Remove the command line interpreter context.
bool Listen (WORD port=0)
 Start listening socket.
WORD GetPort () const
 Get the port we are listing on.
- Public Member Functions inherited from PCLI
virtual ContextStartForeground ()
 Initialise a foreground context and return it.
virtual bool RunContext (Context *context)
 Run a context.
 PCLI (const char *prompt=NULL)
 Contracut a new command line interpreter.
virtual ~PCLI ()
 Destroy the command line interpreter.
bool StartContext (PChannel *channel, bool autoDelete=true, bool runInBackground=true)
 Open a command line interpreter context.
bool StartContext (PChannel *readChannel, PChannel *writeChannel, bool autoDeleteRead=true, bool autoDeleteWrite=true, bool runInBackground=true)
virtual ContextCreateContext ()
 Create a new context.
virtual ContextAddContext (Context *context=NULL)
 Add a command line interpreter context to the system.
virtual void RemoveContext (Context *context)
 Remove the command line interpreter context.
virtual void GarbageCollection ()
 Remove any closed command line interpreter contexts.
virtual void OnReceivedLine (Arguments &line)
 Received a completed command line.
virtual bool OnLogIn (const PString &username, const PString &password)
 Received a login name/pasword to be verified.
void Broadcast (const PString &message) const
 Set a string to all command line interpreter contexts.
bool SetCommand (const char *command, const PNotifier &notifier, const char *help=NULL, const char *usage=NULL)
 Register a new command to be interpreted.
void ShowHelp (Context &context)
 Show help for registered commands to the context.
const PStringGetNewLine () const
 Get new line string output at the end of every line.
void SetNewLine (const PString &newLine)
 Set new line string output at the end of every line.
bool GetRequireEcho () const
 Get flag for echo is required for entered characters.
void SetRequireEcho (bool requireEcho)
 Set flag for echo is required for entered characters.
const PStringGetEditCharacters () const
 Get characters used for editing (backspace/delete) command lines.
void SetEditCharacters (const PString &editCharacters)
 Set characters used for editing (backspace/delete) command lines.
const PStringGetPrompt () const
 Get prompt used for command line interpreter.
void SetPrompt (const PString &prompt)
 Set prompt used for command line interpreter.
const PStringGetUsernamePrompt () const
 Get prompt used for login (if enabled).
void SetUsernamePrompt (const PString &prompt)
 Set prompt used for login (if enabled).
const PStringGetPasswordPrompt () const
 Get prompt used for password (if enabled).
void SetPasswordPrompt (const PString &prompt)
 Set prompt used for password (if enabled).
const PStringGetUsername () const
 Get username for log in validation.
void SetUsername (const PString &username)
 Set username for log in validation.
const PStringGetPassword () const
 Get password for log in validation.
void SetPassword (const PString &password)
 Set password for log in validation.
const PCaselessStringGetExitCommand () const
 Get command to be used to exit session.
void SetExitCommand (const PCaselessString &exitCommand)
 Set command to be used to exit session.
const PCaselessStringGetHelpCommand () const
 Get command to be used to display help.
void SetHelpCommand (const PCaselessString &helpCommand)
 Set command to be used to display help.
const PStringGetHelpOnHelp () const
 Get help on help.
void SetHelpOnHelp (const PCaselessString &helpOnHelp)
 Set help on help.
const PCaselessStringGetRepeatCommand () const
 Get the command to be used to repeat the last executed command.
void SetRepeatCommand (const PCaselessString &repeatCommand)
 Set the command to be used to repeat the last executed command.
const PCaselessStringGetHistoryCommand () const
 Get command that will list/execute command history.
void SetHistoryCommand (const PCaselessString &historyCommand)
 Set command that will list/execute command history.
const PStringGetNoHistoryError () const
 Get error message for if there is no history.
void SetNoHistoryError (const PString &noHistoryError)
 Set error message for if there is no history.
const PStringGetCommandUsagePrefix () const
 Get usage prefix for if Arguments::WriteUsage() called.
void SetCommandUsagePrefix (const PString &commandUsagePrefix)
 Set usage prefix for if Arguments::WriteUsage() called.
const PStringGetCommandErrorPrefix () const
 Get error prefix for if Arguments::WriteError() called.
void SetCommandErrorPrefix (const PString &commandErrorPrefix)
 Set error prefix for if Arguments::WriteError() called.
const PStringGetUnknownCommandError () const
 Get error message for if unknown command is entered.
void SetUnknownCommandError (const PString &unknownCommandError)
 Set error message for if unknown command is entered.
- Public Member Functions inherited from PObject
virtual ~PObject ()
virtual PObjectClone () const
 Create a copy of the class on the heap.
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class.
virtual Comparison Compare (const PObject &obj) const
 Compare the two objects and return their relative rank.
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects.
bool operator== (const PObject &obj) const
 Compare the two objects.
bool operator!= (const PObject &obj) const
 Compare the two objects.
bool operator< (const PObject &obj) const
 Compare the two objects.
bool operator> (const PObject &obj) const
 Compare the two objects.
bool operator<= (const PObject &obj) const
 Compare the two objects.
bool operator>= (const PObject &obj) const
 Compare the two objects.
virtual const char * GetClass (unsigned ancestor=0) const
 Get the current dynamic type of the object instance.
PBoolean IsClass (const char *cls) const
virtual PBoolean InternalIsDescendant (const char *clsName) const
 Determine if the dynamic type of the current instance is a descendent of the specified class.
virtual void PrintOn (ostream &strm) const
 Output the contents of the object to the stream.
virtual void ReadFrom (istream &strm)
 Input the contents of the object from the stream.

Protected Member Functions

virtual PTCPSocketCreateSocket ()
- Protected Member Functions inherited from PCLISocket
 PDECLARE_NOTIFIER (PThread, PCLISocket, ThreadMain)
bool HandleSingleThreadForAll ()
bool HandleIncoming ()

Additional Inherited Members

- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
- Static Public Member Functions inherited from PObject
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect()
static const char * Class ()
 Get the name of the class as a C string.
- Protected Types inherited from PCLISocket
typedef std::map< PSocket
*, Context * > 
ContextMap_t
- Protected Attributes inherited from PCLISocket
bool m_singleThreadForAll
PTCPSocket m_listenSocket
PThreadm_thread
ContextMap_t m_contextBySocket
- Friends inherited from PObject

Detailed Description

Command Line Interpreter over Telnet sockets.

This class allows for access and automatic creation of command line interpreter contexts from incoming Telnet connections on a listening port.

Constructor & Destructor Documentation

PCLITelnet::PCLITelnet ( WORD  port = 0,
const char *  prompt = NULL,
bool  singleThreadForAll = false 
)

Member Function Documentation

virtual PTCPSocket* PCLITelnet::CreateSocket ( )
protectedvirtual

Reimplemented from PCLISocket.


The documentation for this class was generated from the following file: