Main Page | Class Hierarchy | Class List | File List | Class Members

Vty.h

00001 // This is part of tacppd project (extended tacacs++ daemon)
00002 // (c) Copyright in 2000-2004 by tacppd team and contributors
00003 // see http://tacppd.org for more information
00004 //
00005 // file: Vty.h
00006 // description:
00007 
00008 //  This program is free software; you can redistribute it and/or modify
00009 //  it under the terms of the GNU General Public License as published by
00010 //  the Free Software Foundation; either version 2 of the License, or
00011 //  (at your option) any later version.
00012 //
00013 //  This program is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //  GNU General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU General Public License
00019 //  along with this program; if not, write to the Free Software
00020 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 // modifications:
00023 //
00024 
00025 // all comments which start from /** - this is comments for KDoc */
00026 //  for classes
00027 //    @short [short description of the class]
00028 //    @author [class author]
00029 //    @version [class version]
00030 //    @see [references to other classes or methods]
00031 //  for methods
00032 //    @see [references]
00033 //    @return [sentence describing the return value]
00034 //    @exception [list the exeptions that could be thrown]
00035 //    @param [name id] [description]    - can be multiple
00036 #ifndef __VTY_H__
00037 #define __VTY_H__
00038 
00039 #include "global.h"
00040 
00041 namespace tacpp {
00042 
00043 #define TERMINAL_TIMEOUT        10000
00044 enum command {
00045   T_KEY_INSERT_CHAR=0,
00046   T_KEY_BEGINNING_OF_LINE,      
00047   T_KEY_BACKWARD_CHAR,  
00048   T_KEY_DELETE_CHAR,
00049   T_KEY_END_OF_LINE,
00050   T_KEY_FORWARD_CHAR,
00051   T_KEY_DELETE_BACKWARD_CHAR,
00052   T_KEY_CLEAR_LINE,
00053   T_KEY_NEXT_COMMAND,
00054   T_KEY_PREVIOUS_COMMAND,
00055   T_KEY_CLEAR_LINE_FROM_BEGINNING,
00056   T_KEY_KILL_WORD,
00057   T_KEY_EXECUTE_COMMAND,
00058   T_KEY_COMPLETE_COMMAND,
00059   T_KEY_GET_HELP,
00060 
00061   T_KEY_UP,
00062   T_KEY_DOWN,
00063   T_KEY_LEFT,
00064   T_KEY_RIGHT,
00065 
00066   T_KEY_EOF
00067 };
00068 
00069 enum telnetOpt {
00070   TELOPT_BINARY=0,
00071   TELOPT_ECHO=1,
00072   TELOPT_SGA=3,
00073   TELOPT_STATUS=5,
00074   TELOPT_NAOFFD=13,
00075   TELOPT_NAWS=31,
00076 };
00077 enum telnetCmd {
00078   SE=240,
00079   NOP,
00080   DMARK,
00081   BRK,
00082   IP,
00083   AO,
00084   AYT,
00085   EC,
00086   EL,
00087   GA,
00088   SB,
00089   WILL,
00090   WONT,
00091   DO,
00092   DONT,
00093   IAC
00094 };
00095 
00096 const int maxVtyInput=512;
00101 class VtyLineSplitter;
00102 class Vty {
00103  protected:
00106   char vty_line[maxVtyInput+1];
00109   int vtylinepos;
00110  public:
00116   bool isChanged;
00119   VtyLineSplitter *vtSplit;
00122   virtual string vty_get_line();
00125   virtual int vty_get_linepos();
00129   virtual void vty_cleanup();
00132   virtual void vty_set_line(const char *);
00135   virtual bool twriteErr(const char*);
00138   virtual bool twrite(const char*);
00141   virtual int treadstr()=0;
00144   virtual char * readstr()=0;
00145 };
00146 
00149 class VtyStream : public Vty {
00150  private:
00153   std::istream * cfstr;
00154  public:
00157   VtyStream(const char * fileName)throw(VtyErr);
00160   VtyStream(const  string strAsBuffer);
00163   virtual ~VtyStream();
00166   virtual int treadstr()throw(VtyErr);
00169   virtual bool twriteErr(const char*)throw(VtyErr);
00172   virtual char * readstr()throw(VtyErr) ;
00173 };
00174 
00177 class VtyTerm : public Packet,public Vty {
00178  private:
00181   int handle;
00184   struct in_addr in_address;
00187   char address[100];
00190   int vty_height;
00193   int vty_width;
00194 
00195  public:
00199   bool local_echo;
00202   void vty_clear_input();
00205   void vty_insert_char(unsigned char);
00208   void vty_del_char();
00211   void vty_del_backward_char();
00214   void vty_clear_line_from_beg();
00217   void vty_redraw_line();
00220   void vty_move_forward();
00223   void vty_move_backward();
00226   void vty_move_beginning_of_line();
00229   void vty_move_end_of_line();
00232   void vty_move_to(int pos);
00235   virtual int treadstr();
00238   char * readstr();
00241   virtual bool twriteErr(const char*);
00244   bool twrite(const char*);
00247   bool twrite(unsigned char );
00249   void twrite_marker_at(int pos,char a='^');
00252   unsigned char tsymbol(int &);
00255   void echo(bool);
00258   void linemode(bool);
00261   void toptions();
00264   void tset();
00267   void pager(const char*sourcePage,int height=0);
00270   int get_handle();
00273   VtyTerm(int,struct in_addr);
00276   virtual ~VtyTerm();
00277 };
00278 
00279 };
00280 
00281 #endif //__VTY_H__

Generated on Thu Jul 21 23:09:46 2005 for tacppd.kdevelop by doxygen 1.3.5