tncon.cpp
上传用户:tigerk9
上传日期:2020-03-10
资源大小:237k
文件大小:11k
- ///////////////////////////////////////////////////////////////////////////////
- //Telnet Win32 : an ANSI telnet client.
- //Copyright (C) 1998-2000 Paul Brannan
- //Copyright (C) 1998 I.Ioannou
- //Copyright (C) 1997 Brad Johnson
- //
- //This program is free software; you can redistribute it and/or
- //modify it under the terms of the GNU General Public License
- //as published by the Free Software Foundation; either version 2
- //of the License, or (at your option) any later version.
- //
- //This program is distributed in the hope that it will be useful,
- //but WITHOUT ANY WARRANTY; without even the implied warranty of
- //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- //GNU General Public License for more details.
- //
- //You should have received a copy of the GNU General Public License
- //along with this program; if not, write to the Free Software
- //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- //
- //I.Ioannou
- //roryt@hol.gr
- //
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- //
- // Module: tncon.cpp
- //
- // Contents: telnet console processing
- //
- // Product: telnet
- //
- // Revisions: August 30, 1998 Paul Brannan <pbranna@clemson.edu>
- // July 29, 1998 Paul Brannan
- // June 15, 1998 Paul Brannan
- // May 16, 1998 Paul Brannan
- // 5.April.1997 jbj@nounname.com
- // 9.Dec.1996 jbj@nounname.com
- // Version 2.0
- //
- // 02.Apr.1995 igor.milavec@uni-lj.si
- // Original code
- //
- ///////////////////////////////////////////////////////////////////////////////
- #include "tncon.h"
- #include "keytrans.h"
- #include "ttelhndl.h"
- #include "tconsole.h"
- #define KEYEVENT InputRecord[i].Event.KeyEvent
- // Paul Brannan 6/25/98
- // #ifdef __MINGW32__
- // #define KEYEVENT_CHAR KEYEVENT.AsciiChar
- // #else
- #define KEYEVENT_CHAR KEYEVENT.uChar.AsciiChar
- // #endif
- #define KEYEVENT_PCHAR &KEYEVENT_CHAR
- // This is for local echo (Paul Brannan 5/16/98)
- inline void DoEcho(const char *p, int l, TConsole &Console,
- TNetwork &Network, NetParams *pParams) {
- // Pause the console (Paul Brannan 8/24/98)
- if(Network.get_local_echo()) {
- ResetEvent(pParams->hUnPause);
- SetEvent(pParams->hPause);
- while (!*pParams->bNetPaused); // Pause
- Console.WriteCtrlString(p, l);
- SetEvent(pParams->hUnPause); // Unpause
- }
- }
- // This is for line mode (Paul Brannan 12/31/98)
- static char buffer[1024];
- static unsigned int bufptr = 0;
- // Line mode -- currently uses sga/echo to determine when to enter line mode
- // (as in RFC 858), but correct behaviour is as described in RFC 1184.
- // (Paul Brannan 12/31/98)
- // FIX ME!! What to do with unflushed data when we change from line mode
- // to character mode?
- inline bool DoLineModeSpecial(char keychar, TConsole &Console, TNetwork &Network,
- NetParams *pParams) {
- if(keychar == VK_BACK) {
- if(bufptr) bufptr--;
- DoEcho("b b", 3, Console, Network, pParams);
- return true;
- } else if(keychar == VK_RETURN) {
- Network.WriteString(buffer, bufptr);
- Network.WriteString("