00001 // -*- C++ -*- 00002 // Definitions for the connection to a TTY that's connected to a real user 00003 // 00004 // ***** BEGIN LICENSE BLOCK ***** 00005 // Version: MPL 1.1/GPL 2.0/LGPL 2.1 00006 // 00007 // The contents of this file are subject to the Mozilla Public License 00008 // Version 1.1 (the "License"); you may not use this file except in 00009 // compliance with the License. You may obtain a copy of the License at 00010 // http://www.mozilla.org/MPL/ 00011 // 00012 // Software distributed under the License is distributed on an "AS IS" 00013 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00014 // the License for the specific language governing rights and limitations 00015 // under the License. 00016 // 00017 // The Original Code is the consmgr network/serial-line monitoring package. 00018 // 00019 // The Initial Developer of the Original Code is Chris P. Ross. 00020 // Portions created by the Initial Developer are Copyright (C) 2000-2008 00021 // the Initial Developer. All Rights Reserved. 00022 // 00023 // Contributor(s): 00024 // Geoff Adams 00025 // 00026 // Alternatively, the contents of this file may be used under the terms of 00027 // either the GNU General Public License Version 2 or later (the "GPL"), or 00028 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00029 // in which case the provisions of the GPL or the LGPL are applicable instead 00030 // of those above. If you wish to allow use of your version of this file only 00031 // under the terms of either the GPL or the LGPL, and not to allow others to 00032 // use your version of this file under the terms of the MPL, indicate your 00033 // decision by deleting the provisions above and replace them with the notice 00034 // and other provisions required by the GPL or the LGPL. If you do not delete 00035 // the provisions above, a recipient may use your version of this file under 00036 // the terms of any one of the MPL, the GPL or the LGPL. 00037 // 00038 // ***** END LICENSE BLOCK ***** 00039 00040 #ifndef __USERTTYCONN_H 00041 #define __USERTTYCONN_H 00042 00043 extern "C" { 00044 #include <sys/types.h> 00045 #include <termios.h> 00046 } 00047 00048 // Get the base class 00049 #include "ttyconn.h" 00050 00051 // A UserTTYConn handles a connection to a tty that interacts directly with 00052 // a user. That is, it's most likely stdin/stdout, and we can expect that a 00053 // keyboard and some sort of terminal window are attached. In particular, 00054 // this means that we'll be handling OOB command sequences from the user. 00055 00057 class UserTTYConn : public TTYConnector { 00058 public: 00059 //UserTTYConn() : TTYConnector(), at_line_start(1), in_oob_sequence(0) {} 00060 UserTTYConn(int in,int out) : TTYConnector(in,out), at_line_start(1), 00061 in_oob_sequence(0) {} 00062 00063 protected: 00064 // Look for OOB command sequences in the user input 00065 void process_data(Data*); 00066 00067 private: 00068 bool at_line_start, in_oob_sequence; 00069 00070 bool handle_oob_sequence(Data *blob, size_t offset); 00071 00072 }; 00073 00074 #endif /* __USERTTYCONN_H */