mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 14:04:59 +02:00
Add ANSI parsing engine and console draw support to ssh client
Makes the ssh.exe client more useable in interactive mode with ANSI color and a console screen support.
This commit is contained in:
parent
a55816fc15
commit
7aac59e524
17
channels.c
17
channels.c
@ -2454,25 +2454,16 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
|
||||
c->local_window -= win_len;
|
||||
}
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
if ( (c->client_tty) && (data_len >= 5) ) {
|
||||
if ( data[0] == '\033' ) { // escape char octal 33, decimal 27
|
||||
if ( (data[1] == '[') && (data[2]== '2') && (data[3]== '0') && ( data[4]== 'h' )) {
|
||||
lftocrlf = 1;
|
||||
data = data + 5 ; // we have processed the 5 bytes ESC sequence
|
||||
data_len = data_len - 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (c->datagram)
|
||||
buffer_put_string(&c->output, data, data_len);
|
||||
else {
|
||||
#ifndef WIN32_FIXME
|
||||
buffer_append(&c->output, data, data_len);
|
||||
#else
|
||||
buffer_append(&c->output, data, data_len);
|
||||
if ( c->client_tty )
|
||||
telProcessNetwork ( data, data_len ); // run it by ANSI engine if it is the ssh client
|
||||
else
|
||||
buffer_append(&c->output, data, data_len); // it is the sshd server, so pass it on
|
||||
if ( c->isatty ) {
|
||||
buffer_append(&c->input, data, data_len); // we echo the data if it is sshd server and pty interactive mode
|
||||
if ( (data_len ==1) && (data[0] == '\b') )
|
||||
|
@ -18,7 +18,7 @@ LDFLAGS=-L. @LDFLAGS@
|
||||
|
||||
WIN32COMPATFILES = daemon.o gettimeofday.o homedirhelp.o pwd.o sfds.o \
|
||||
socket.o startupneeds.o strcasecmp.o syslog.o lsalogon.o lsastring.o \
|
||||
stringhelp.o deskright.o win32auth.o kerberos.o
|
||||
stringhelp.o deskright.o win32auth.o kerberos.o ansiprsr.o console.o tnnet.o
|
||||
|
||||
WIN32COMPATLIB=@LIBWIN32COMPAT@
|
||||
|
||||
|
922
contrib/win32/win32compat/ansiprsr.c
Normal file
922
contrib/win32/win32compat/ansiprsr.c
Normal file
@ -0,0 +1,922 @@
|
||||
/* ansiprsr.c
|
||||
* Author: Pragma Systems, Inc. <www.pragmasys.com>
|
||||
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
|
||||
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* ANSI Parser to run on Win32 based operating systems.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice.
|
||||
* 2. Binaries produced provide no direct or implied warranties or any
|
||||
* guarantee of performance or suitability.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "ansiprsr.h"
|
||||
#include "tncon.h"
|
||||
#include "tnnet.h"
|
||||
|
||||
#define TS_IS 0
|
||||
#define TS_SEND 1
|
||||
|
||||
// items used from other modules
|
||||
int NetWriteString(char* pszString, size_t cbString);
|
||||
TelParams Parameters;
|
||||
extern int lftocrlf;
|
||||
|
||||
extern int ScreenX;
|
||||
extern int ScreenY;
|
||||
extern int ScrollTop;
|
||||
extern int ScrollBottom;
|
||||
// end of imports from outside module
|
||||
|
||||
bool gbVTAppMode = false;
|
||||
|
||||
// private message for port printing to
|
||||
unsigned char VT_ST[] = { 0x1b, '/', '\0' };
|
||||
|
||||
static int AutoWrap = 1;
|
||||
|
||||
int marginTop, marginBottom;
|
||||
BOOL bAtEOLN = FALSE;
|
||||
|
||||
static int term_mode;
|
||||
|
||||
// ParseANSI globals - these need to be here, because sometimes blocks are sent
|
||||
// in mid ANSI sequence
|
||||
int iParam[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int iCurrentParam = 0;
|
||||
int bDelimiter = 0;
|
||||
int bMode = 0;
|
||||
int fcompletion = 1;
|
||||
int bExtMode = 0;
|
||||
int bCS0 = 0;
|
||||
int bCS1 = 0;
|
||||
int bBkMode = 0;
|
||||
int bCharMode = 0;
|
||||
|
||||
|
||||
BOOL fShiftOut = FALSE;
|
||||
BOOL InPrintMode = FALSE;
|
||||
BOOL fPcMode = FALSE;
|
||||
|
||||
char printErr[] = "Unable to Print: Printer not assigned. Press any key to continue...";
|
||||
|
||||
#define MODE_CURSORAPP 0x0001
|
||||
#define MODE_ANSIVT52 0x0002
|
||||
#define MODE_COL132 0x0004
|
||||
#define MODE_SMOOTHSCROLL 0x0008
|
||||
#define MODE_REVERSESCREEN 0x0010
|
||||
#define MODE_ORIGINREL 0x0020
|
||||
#define MODE_WRAPAROUND 0x0040
|
||||
#define MODE_AUTOREPEAT 0x0080
|
||||
#define MODE_APPMODE 0x0100
|
||||
#define MODE_LNM 0x0200
|
||||
#define MODE_IRM_INSERT 0x0400
|
||||
|
||||
int VTMode = 0;
|
||||
|
||||
#define MODE_CURSORAPP 0x0001
|
||||
#define MODE_ANSIVT52 0x0002
|
||||
#define MODE_COL132 0x0004
|
||||
#define MODE_SMOOTHSCROLL 0x0008
|
||||
#define MODE_REVERSESCREEN 0x0010
|
||||
#define MODE_ORIGINREL 0x0020
|
||||
#define MODE_WRAPAROUND 0x0040
|
||||
#define MODE_AUTOREPEAT 0x0080
|
||||
#define MODE_APPMODE 0x0100
|
||||
#define MODE_LNM 0x0200
|
||||
|
||||
char *GetTerminalId()
|
||||
{
|
||||
return "\033[?1;2c";
|
||||
}
|
||||
|
||||
char * GetStatusReport()
|
||||
{
|
||||
return "\033[2;5R";
|
||||
}
|
||||
|
||||
void BufConvertToG2(char * pszBuffer, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<length;i++)
|
||||
pszBuffer[i]='|';
|
||||
//*(pszBuffer+i) += 20;
|
||||
}
|
||||
|
||||
|
||||
void GoToNextLine()
|
||||
{
|
||||
if (ConGetCursorY() >= (ConWindowSizeY()-1))
|
||||
{
|
||||
ConScrollDown(ScrollTop,ScrollBottom);
|
||||
ConMoveCursorPosition(-ConGetCursorX(),0);
|
||||
}
|
||||
else
|
||||
ConMoveCursorPosition(-ConGetCursorX(),1);
|
||||
bAtEOLN = FALSE;
|
||||
}
|
||||
|
||||
unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd)
|
||||
{
|
||||
int CurrentX;
|
||||
int CurrentY;
|
||||
int rc = 0, bufLen, cmpLen, i;
|
||||
|
||||
|
||||
if (!fcompletion)
|
||||
{
|
||||
if (pszBuffer < pszBufferEnd -1)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer+1;
|
||||
unsigned char * pszNewCurrent = pszCurrent;
|
||||
|
||||
if (term_mode == TERM_ANSI)
|
||||
{
|
||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd);
|
||||
}
|
||||
else if (term_mode == TERM_VT52)
|
||||
{
|
||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd);
|
||||
}
|
||||
if ( pszCurrent == pszNewCurrent ) // didn't move inside Parsefunction
|
||||
{
|
||||
pszNewCurrent += ConWriteString( (char *)pszCurrent, 1);
|
||||
return pszBuffer + 1;
|
||||
}
|
||||
if (pszNewCurrent > pszCurrent )
|
||||
pszBuffer = pszNewCurrent;
|
||||
}
|
||||
}
|
||||
switch ((unsigned char) (*pszBuffer))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 11:
|
||||
pszBuffer++;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
Beep( 1000, 400);
|
||||
pszBuffer++;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
pszBuffer++;
|
||||
if (!bAtEOLN)
|
||||
{
|
||||
CurrentX = ConGetCursorX();
|
||||
if (CurrentX == 0)
|
||||
{
|
||||
ConMoveCursorPosition( ScreenX-1,-1);
|
||||
ConWriteString(" ",1);
|
||||
// ConMoveCursorPosition(-1,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConClearNFromCursorLeft(1);
|
||||
ConMoveCursorPosition( -1, 0 );
|
||||
}
|
||||
}
|
||||
bAtEOLN = FALSE;
|
||||
|
||||
//ConWriteString( " ", 1 );
|
||||
//ConMoveCursorPosition( -1, 0 );
|
||||
break;
|
||||
|
||||
case 9:
|
||||
{
|
||||
if (bAtEOLN) GoToNextLine();
|
||||
int i, MoveRight = 8 - (ConGetCursorX() % 8);
|
||||
|
||||
for ( i = 0; i < MoveRight; i++ )
|
||||
ConWriteString( " ", 1 );
|
||||
pszBuffer++;
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 10:
|
||||
|
||||
|
||||
pszBuffer++;
|
||||
CurrentY = ConGetCursorY();
|
||||
|
||||
|
||||
if (CurrentY >= marginBottom )
|
||||
{
|
||||
if (VTMode & MODE_APPMODE)
|
||||
ConScrollDown(marginTop,marginBottom);
|
||||
else
|
||||
printf("\n");
|
||||
ConMoveCursorPosition(-ConGetCursorX(),0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConMoveCursorPosition(0,1);
|
||||
}
|
||||
if ( Parameters.nReceiveCRLF == ENUM_LF )
|
||||
ConMoveCursorPosition(-ConGetCursorX(),0);
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 12:
|
||||
pszBuffer++;
|
||||
ConSetCursorPosition(0, 0);
|
||||
ConClearScreen();
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
pszBuffer++;
|
||||
ConMoveCursorPosition(-ConGetCursorX(),0);
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
pszBuffer++;
|
||||
fShiftOut = TRUE;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
fShiftOut = FALSE;
|
||||
pszBuffer++;
|
||||
break;
|
||||
|
||||
case 27:
|
||||
if (pszBuffer < pszBufferEnd -1)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer+1;
|
||||
unsigned char * pszNewCurrent = pszCurrent;
|
||||
|
||||
if ( *pszCurrent == 27 )
|
||||
{
|
||||
pszNewCurrent += ConWriteString( (char *)pszCurrent, 1);
|
||||
return pszBuffer + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (term_mode == TERM_ANSI)
|
||||
{
|
||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd);
|
||||
}
|
||||
else if (term_mode == TERM_VT52)
|
||||
{
|
||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd);
|
||||
}
|
||||
}
|
||||
if (pszNewCurrent > pszCurrent )
|
||||
pszBuffer = pszNewCurrent;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if (bAtEOLN) GoToNextLine();
|
||||
|
||||
unsigned char* pszCurrent = pszBuffer;
|
||||
CurrentX = ConGetCursorX();
|
||||
|
||||
while ((pszCurrent < pszBufferEnd) && (*pszCurrent != (unsigned char)27)
|
||||
&& (*pszCurrent > (unsigned char)15) && (*pszCurrent != (unsigned char)255)
|
||||
&& (CurrentX++ < ScreenX ))
|
||||
// (*pszCurrent != (char)15) && (*pszCurrent != (char)14) &&
|
||||
// (*pszCurrent != (char)12) && (*pszCurrent != (char)13) && (*pszCurrent != (char)8) &&
|
||||
// (*pszCurrent != (char)9))
|
||||
pszCurrent++;
|
||||
|
||||
if (fShiftOut)
|
||||
memset( pszBuffer, '|', pszCurrent-pszBuffer );
|
||||
|
||||
pszBuffer += ConWriteString((char *)pszBuffer, (int)(pszCurrent - pszBuffer));
|
||||
|
||||
if ((CurrentX >= ScreenX) && AutoWrap && !(VTMode & MODE_CURSORAPP) )
|
||||
{
|
||||
bAtEOLN = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
|
||||
unsigned char * GetNextChar(unsigned char * pszBuffer, unsigned char *pszBufferEnd)
|
||||
{
|
||||
if (++pszBuffer > pszBufferEnd)
|
||||
return NULL;
|
||||
else
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
void ConSetExtendedMode(int iFunction, BOOL bEnable)
|
||||
{
|
||||
switch(iFunction)
|
||||
{
|
||||
case 1:
|
||||
if (bEnable){
|
||||
VTMode |= MODE_CURSORAPP;
|
||||
gbVTAppMode = true;
|
||||
}else{
|
||||
VTMode &= ~MODE_CURSORAPP;
|
||||
gbVTAppMode = false;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!bEnable)
|
||||
VTMode |= MODE_ANSIVT52;
|
||||
break;
|
||||
case 3:
|
||||
if (bEnable)
|
||||
VTMode |= MODE_COL132;
|
||||
else
|
||||
VTMode &= ~MODE_COL132;
|
||||
break;
|
||||
case 4:
|
||||
if (bEnable)
|
||||
VTMode |= MODE_SMOOTHSCROLL;
|
||||
else
|
||||
VTMode &= ~MODE_SMOOTHSCROLL;
|
||||
break;
|
||||
case 5:
|
||||
if (bEnable)
|
||||
VTMode |= MODE_REVERSESCREEN;
|
||||
else
|
||||
VTMode &= ~MODE_REVERSESCREEN;
|
||||
break;
|
||||
case 6:
|
||||
if (bEnable)
|
||||
VTMode |= MODE_ORIGINREL;
|
||||
else
|
||||
VTMode &= ~MODE_ORIGINREL;
|
||||
break;
|
||||
case 7:
|
||||
if (bEnable)
|
||||
VTMode |= MODE_WRAPAROUND;
|
||||
else
|
||||
VTMode &= ~MODE_WRAPAROUND;
|
||||
break;
|
||||
case 8:
|
||||
if (bEnable)
|
||||
VTMode |= MODE_AUTOREPEAT;
|
||||
else
|
||||
VTMode &= ~MODE_AUTOREPEAT;
|
||||
break;
|
||||
case 20: // LNM Mode CSI 20h
|
||||
if (bEnable){
|
||||
VTMode |= MODE_LNM;
|
||||
Parameters.nReceiveCRLF = ENUM_LF;
|
||||
lftocrlf = 1;
|
||||
}else{
|
||||
VTMode &= ~MODE_LNM;
|
||||
Parameters.nReceiveCRLF = ENUM_CRLF;
|
||||
lftocrlf = 0;
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
ConDisplayCursor(bEnable);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if ((iFunction == 2) && (bEnable))
|
||||
{
|
||||
term_mode = TERM_VT52;
|
||||
}
|
||||
}
|
||||
|
||||
#define MODE_EXT 0x00000001
|
||||
#define MODE_CS0 0x00000002
|
||||
#define MODE_CS1 0x00000004
|
||||
#define MODE_CS2 0x00000008
|
||||
#define MODE_CS3 0x00000010
|
||||
#define MODE_BRK 0x00000020
|
||||
#define MODE_CHAR 0x00000040
|
||||
#define MODE_K 0x00000080
|
||||
|
||||
#define DIGI_MASK (MODE_CS0 | MODE_CS1 | MODE_CS2 | MODE_CS3 | MODE_CHAR)
|
||||
|
||||
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer;
|
||||
const int nParam = 10; // Maximum number of parameters
|
||||
int rc = 0;
|
||||
static int SavedX = 0;
|
||||
static int SavedY = 0;
|
||||
SCREEN_HANDLE hScreen = NULL;
|
||||
char anyKey[2] = " ";
|
||||
WORD BytesRead;
|
||||
char pszServerPort[10];
|
||||
int indx;
|
||||
char jobName[40];
|
||||
|
||||
fcompletion = 0;
|
||||
do
|
||||
{
|
||||
switch ((unsigned char) *pszCurrent)
|
||||
{
|
||||
case ';': // delimiter
|
||||
bDelimiter = TRUE;
|
||||
break;
|
||||
// Modifiers
|
||||
case '?': // Extended Mode
|
||||
bMode |= MODE_EXT;
|
||||
break;
|
||||
case '(':
|
||||
bMode |= MODE_CS0;
|
||||
break;
|
||||
case ')':
|
||||
bMode |= MODE_CS1;
|
||||
break;
|
||||
case '*':
|
||||
bMode |= MODE_CS2;
|
||||
break;
|
||||
case '+':
|
||||
bMode |= MODE_CS3;
|
||||
break;
|
||||
case '[':
|
||||
bMode |= MODE_BRK;
|
||||
break;
|
||||
case '#':
|
||||
bMode |= MODE_CHAR;
|
||||
break;
|
||||
|
||||
// Termination Options
|
||||
case 0:
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '}':
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '<': // character set
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '~':
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case '^': // private message pszCurrent++;
|
||||
while (_strnicmp((const char *)pszCurrent, (const char *)VT_ST, strlen((const char *)VT_ST) ) )// while not stop
|
||||
{
|
||||
if (_strnicmp((const char *)pszCurrent, (const char *)VT_ST, strlen((const char *)VT_ST) ) )
|
||||
pszCurrent++;
|
||||
}
|
||||
pszCurrent += strlen((const char *)VT_ST) - 1;
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'A': // British Character Set or Cursor Up
|
||||
if (bMode & MODE_CHAR)
|
||||
{
|
||||
// Britsh Character Set
|
||||
}
|
||||
else if (bMode & MODE_BRK)
|
||||
{
|
||||
// Cursor UP
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 1;
|
||||
ConMoveCursorPosition(0, -iParam[0]);
|
||||
// AutoWrap = 0;
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'B': // US ASCII or Cursor down
|
||||
if (bMode & MODE_CHAR)
|
||||
{
|
||||
// US ASCII Character Set
|
||||
}
|
||||
else if (bMode & MODE_BRK)
|
||||
{
|
||||
// Cursor DOWN
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 1;
|
||||
ConMoveCursorPosition(0, iParam[0]);
|
||||
// AutoWrap = 0;
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'C': // Finish Character Set or Cursor right
|
||||
if (bMode & MODE_CHAR)
|
||||
{
|
||||
// Britsh Character Set
|
||||
}
|
||||
else if (bMode & MODE_BRK)
|
||||
{
|
||||
// Cursor right
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 1;
|
||||
ConMoveCursorPosition(iParam[0], 0);
|
||||
// AutoWrap = 0;
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'D': // Cursor left
|
||||
if (bMode & MODE_BRK)
|
||||
{
|
||||
// Cursor left
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 1;
|
||||
ConMoveCursorPosition(-iParam[0], 0);
|
||||
// AutoWrap = 0;
|
||||
}
|
||||
else if (bMode == 0)
|
||||
{
|
||||
// Index
|
||||
ConScrollDown(ScrollTop,ScrollBottom);
|
||||
}
|
||||
fcompletion = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
|
||||
case '=': // application mode
|
||||
VTMode |= MODE_APPMODE;
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case '>': // numeric mode
|
||||
VTMode &= ~MODE_APPMODE;
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '%': // character set definitions
|
||||
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'h':
|
||||
case 'l': // ^[?25h
|
||||
if (bMode & MODE_EXT)
|
||||
{
|
||||
if (iParam[0] == 4){
|
||||
VTMode |= MODE_IRM_INSERT;
|
||||
}
|
||||
// iParam[0] = atoi( (pszCurrent - iCurrentParam) );
|
||||
int i;
|
||||
for ( i = 0; i < iCurrentParam; i++ )
|
||||
ConSetExtendedMode(iParam[i], *pszCurrent=='h'?1:0);
|
||||
}
|
||||
else if (bMode & MODE_BRK)
|
||||
{
|
||||
// Possible set Line feed (option 20)
|
||||
// Possible set Line feed (option 20)
|
||||
if (iParam[0] == 20)
|
||||
ConSetExtendedMode(iParam[0], *pszCurrent=='h'?1:0);
|
||||
if (iParam[0] == 4){
|
||||
VTMode &= ~MODE_IRM_INSERT;
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if (iParam[0])
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<iParam[0]; i++)
|
||||
ConScrollUp(ConGetCursorY()-1,ScrollTop + ConWindowSizeY()-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ConGetCursorY() <= ScrollTop + ConWindowSizeY()-2)
|
||||
{
|
||||
ConScrollUp(ConGetCursorY()-1,ScrollTop + ConWindowSizeY()-2);
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
case 'N':
|
||||
case 'O':
|
||||
fcompletion =1;
|
||||
break;
|
||||
case 'm':
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 0;
|
||||
ConSetAttribute(iParam, iCurrentParam);
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
marginTop = (iParam[0] > 0) ? iParam[0] - 1 : 0;
|
||||
marginBottom = (iParam[1] > 0) ? iParam[1] - 1 : 0;
|
||||
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'H':
|
||||
case 'f':
|
||||
if (bMode & MODE_BRK)
|
||||
{
|
||||
if ((iParam[0]-1) > ConWindowSizeY())
|
||||
ConSetScreenRect(ConWindowSizeX(), iParam[0]-1);
|
||||
ConSetCursorPosition((iParam[1] > 0) ? iParam[1] - 1 : 0, (iParam[0] > 0) ? iParam[0] - 1 : 0);
|
||||
//AutoWrap = 0;
|
||||
}
|
||||
else if (bMode == 0)
|
||||
{
|
||||
//Set tab
|
||||
}
|
||||
fcompletion = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (iParam[0])
|
||||
{
|
||||
int i ;
|
||||
for (i=0; i<iParam[0]; i++)
|
||||
ConScrollUp(ConGetCursorY(),ScrollTop + marginBottom - ConGetCursorY());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ConGetCursorY() <= ScrollTop + ConWindowSizeY()-2)
|
||||
{
|
||||
ConScrollUp(ConGetCursorY(),ScrollTop + marginBottom - ConGetCursorY());
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
case 'E':
|
||||
case 'g':
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'i': // ANSI or VTXXX Print
|
||||
fcompletion = 1;//
|
||||
if ( iParam[0] == 5 )
|
||||
{
|
||||
}
|
||||
else if ( iParam[0] == 4 )
|
||||
InPrintMode = FALSE;
|
||||
break;
|
||||
case 'K':
|
||||
if (bMode & MODE_BRK)
|
||||
{
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 0;
|
||||
switch (iParam[0])
|
||||
{
|
||||
case 0:
|
||||
ConClearEOLine();
|
||||
break;
|
||||
case 1:
|
||||
ConClearBOLine();
|
||||
break;
|
||||
case 2:
|
||||
ConClearLine();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (bMode == 0)
|
||||
{
|
||||
bMode |= MODE_K;
|
||||
}
|
||||
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 0;
|
||||
switch (iParam[0])
|
||||
{
|
||||
case 0:
|
||||
ConClearEOScreen();
|
||||
break;
|
||||
case 1:
|
||||
ConClearBOScreen();
|
||||
break;
|
||||
case 2:
|
||||
ConClearScreen();
|
||||
break;
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (iCurrentParam < 1)
|
||||
{
|
||||
if (iParam[0] == 5)
|
||||
{
|
||||
char * szStatus = GetStatusReport();
|
||||
NetWriteString(szStatus, strlen(szStatus));
|
||||
}
|
||||
else if ( iParam[0] == 6 )
|
||||
{
|
||||
char * szStatus = GetStatusReport();
|
||||
NetWriteString(szStatus, strlen(szStatus));
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
|
||||
if (bMode == (MODE_BRK & MODE_EXT))
|
||||
{
|
||||
// What are you response
|
||||
}
|
||||
else if (bMode == MODE_BRK)
|
||||
{
|
||||
char* szTerminalId = GetTerminalId();
|
||||
NetWriteString(szTerminalId, strlen(szTerminalId));
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
case 'q':
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'Z': // Identify - This is really a VT52 command
|
||||
{
|
||||
char* szTerminalId = GetTerminalId();
|
||||
NetWriteString(szTerminalId, strlen(szTerminalId));
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
ConDeleteChars(iParam[0]);
|
||||
fcompletion = 1;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// pszHead should point to digit now. Otherwise we got bad escape
|
||||
// sequence, so we just get out of here!
|
||||
if (!isdigit(*pszCurrent))
|
||||
{
|
||||
pszCurrent = pszBuffer;
|
||||
return pszCurrent;
|
||||
}
|
||||
|
||||
iParam[iCurrentParam] = strtoul((const char *)pszCurrent, (char **)&pszCurrent, 10);
|
||||
|
||||
pszCurrent--;
|
||||
|
||||
if (iCurrentParam < nParam)
|
||||
iCurrentParam++;
|
||||
|
||||
// Check for digit completion
|
||||
if (bMode & DIGI_MASK)
|
||||
fcompletion = 1;
|
||||
|
||||
if (bMode == 0)
|
||||
{
|
||||
switch(iParam[0])
|
||||
{
|
||||
case 7:
|
||||
SavedX = ConGetCursorX();
|
||||
SavedY = ConGetCursorY();
|
||||
break;
|
||||
case 8:
|
||||
ConSetCursorPosition(SavedX,SavedY);
|
||||
break;
|
||||
}
|
||||
fcompletion = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
} while ((++pszCurrent < pszBufferEnd) && !fcompletion);
|
||||
|
||||
if (fcompletion)
|
||||
{
|
||||
memset(iParam, '\0', sizeof(iParam));
|
||||
iCurrentParam = 0;
|
||||
bDelimiter = 0;
|
||||
bMode = 0;
|
||||
// fcompletion = 0;
|
||||
bExtMode = 0;
|
||||
bCS0 = 0;
|
||||
bCS1 = 0;
|
||||
bBkMode = 0;
|
||||
bCharMode = 0;
|
||||
return pszCurrent;
|
||||
}
|
||||
else
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer;
|
||||
int iLine;
|
||||
int iColumn;
|
||||
|
||||
switch ((unsigned char) *pszCurrent)
|
||||
{
|
||||
|
||||
case 'A': // Cursor Up
|
||||
ConMoveCursorPosition(0, -1);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 'B': // Cursor Down
|
||||
ConMoveCursorPosition(0, 1);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
case 'C': // Cursor Right
|
||||
ConMoveCursorPosition(1, 0);
|
||||
pszCurrent++;
|
||||
break;
|
||||
case 'D': // Cursor Left
|
||||
ConMoveCursorPosition(-1, 0);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
case 'F': // Special Graphics Character Set
|
||||
case 'G': // ASCII Character Set
|
||||
pszCurrent++;
|
||||
break;
|
||||
case 'H': // Cursor Home
|
||||
|
||||
ConSetCursorPosition(1, 1);
|
||||
pszCurrent++;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
case 'I': // Reverse Line Feed
|
||||
pszCurrent++;
|
||||
break;
|
||||
case 'J': // Erase to End of Screen
|
||||
ConClearEOScreen();
|
||||
pszCurrent++;
|
||||
break;
|
||||
case 'K': // Erase to End of Line
|
||||
ConClearEOLine();
|
||||
pszCurrent++;
|
||||
break;
|
||||
case 'Y': // Direct Cursor Addressing
|
||||
pszCurrent = GetNextChar(pszCurrent,pszBufferEnd);
|
||||
if (pszCurrent != NULL)
|
||||
{
|
||||
iLine = *pszCurrent - 31;
|
||||
|
||||
pszCurrent = GetNextChar(pszCurrent,pszBufferEnd);
|
||||
if (pszCurrent != NULL)
|
||||
{
|
||||
iColumn = *pszCurrent - 31;
|
||||
ConSetCursorPosition(iLine,iColumn);
|
||||
pszCurrent++;
|
||||
}
|
||||
else
|
||||
pszCurrent = pszBuffer;
|
||||
}
|
||||
else
|
||||
pszCurrent = pszBuffer;
|
||||
break;
|
||||
|
||||
case 'Z': // Identify
|
||||
NetWriteString("\033/Z",3);
|
||||
pszCurrent++;
|
||||
break;
|
||||
case '=': // Enter Alt Keypad mode
|
||||
case '>': // Exit Alt Keypad mode
|
||||
case '1': // Graphics processor on
|
||||
case '2': // Graphics processor off
|
||||
pszCurrent++;
|
||||
break;
|
||||
case '<': // Enter ANSI mode
|
||||
term_mode = TERM_ANSI;
|
||||
pszCurrent++;
|
||||
break;
|
||||
default:
|
||||
pszCurrent++;
|
||||
}
|
||||
|
||||
return pszCurrent;
|
||||
|
||||
}
|
46
contrib/win32/win32compat/ansiprsr.h
Normal file
46
contrib/win32/win32compat/ansiprsr.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* ansiprsr.h
|
||||
* Author: Pragma Systems, Inc. <www.pragmasys.com>
|
||||
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
|
||||
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* ANSI Parser header file to run on Win32 based operating systems.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice.
|
||||
* 2. Binaries produced provide no direct or implied warranties or any
|
||||
* guarantee of performance or suitability.
|
||||
*/
|
||||
|
||||
#ifndef __ANSIPRSR_H
|
||||
#define __ANSIPRSR_H
|
||||
|
||||
#define TERM_ANSI 0
|
||||
#define TERM_VT52 1
|
||||
|
||||
unsigned char * ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd);
|
||||
unsigned char * GetNextChar(unsigned char * pszBuffer, unsigned char *pszBufferEnd);
|
||||
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd);
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd);
|
||||
|
||||
#define true TRUE
|
||||
#define false FALSE
|
||||
#define bool BOOL
|
||||
|
||||
//typedef enum _crlftype { CRLF = 0, LF, CR } CRLFType;
|
||||
#define ENUM_CRLF 0
|
||||
#define ENUM_LF 1
|
||||
#define ENUM_CR 2
|
||||
|
||||
typedef struct _TelParams
|
||||
{
|
||||
int timeOut;
|
||||
int fLocalEcho;
|
||||
int fTreatLFasCRLF;
|
||||
int fSendCROnly;
|
||||
int nReceiveCRLF;
|
||||
} TelParams;
|
||||
|
||||
#endif
|
1764
contrib/win32/win32compat/console.c
Normal file
1764
contrib/win32/win32compat/console.c
Normal file
File diff suppressed because it is too large
Load Diff
114
contrib/win32/win32compat/console.h
Normal file
114
contrib/win32/win32compat/console.h
Normal file
@ -0,0 +1,114 @@
|
||||
/* console.h
|
||||
* Author: Pragma Systems, Inc. <www.pragmasys.com>
|
||||
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
|
||||
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* Common library for Windows Console Screen IO.
|
||||
* Contains Windows console related definition so that emulation code can draw
|
||||
* on Windows console screen surface.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice.
|
||||
* 2. Binaries produced provide no direct or implied warranties or any
|
||||
* guarantee of performance or suitability.
|
||||
*/
|
||||
|
||||
#ifndef __PRAGMA_CONSOLE_h
|
||||
#define __PRAGMA_CONSOLE_h
|
||||
|
||||
#define ANSI_ATTR_RESET 0
|
||||
#define ANSI_BRIGHT 1
|
||||
#define ANSI_DIM 2
|
||||
#define ANSI_UNDERSCORE 4
|
||||
#define ANSI_BLINK 5
|
||||
#define ANSI_REVERSE 7
|
||||
#define ANSI_HIDDEN 8
|
||||
#define ANSI_NOREVERSE 27
|
||||
|
||||
#define ANSI_FOREGROUND_BLACK 30
|
||||
#define ANSI_FOREGROUND_RED 31
|
||||
#define ANSI_FOREGROUND_GREEN 32
|
||||
#define ANSI_FOREGROUND_YELLOW 33
|
||||
#define ANSI_FOREGROUND_BLUE 34
|
||||
#define ANSI_FOREGROUND_MAGENTA 35
|
||||
#define ANSI_FOREGROUND_CYAN 36
|
||||
#define ANSI_FOREGROUND_WHITE 37
|
||||
#define ANSI_BACKGROUND_BLACK 40
|
||||
#define ANSI_BACKGROUND_RED 41
|
||||
#define ANSI_BACKGROUND_GREEN 42
|
||||
#define ANSI_BACKGROUND_YELLOW 43
|
||||
#define ANSI_BACKGROUND_BLUE 44
|
||||
#define ANSI_BACKGROUND_MAGENTA 45
|
||||
#define ANSI_BACKGROUND_CYAN 46
|
||||
#define ANSI_BACKGROUND_WHITE 47
|
||||
#define ANSI_BACKGROUND_BRIGHT 128
|
||||
|
||||
#define TAB_LENGTH 4
|
||||
#define TAB_CHAR '\t'
|
||||
#define TAB_SPACE " "
|
||||
|
||||
#define true TRUE
|
||||
#define false FALSE
|
||||
#define bool BOOL
|
||||
|
||||
typedef void * SCREEN_HANDLE;
|
||||
|
||||
int ConInit( DWORD OutputHandle, BOOL fSmartInit);
|
||||
int ConUnInitWithRestore( void );
|
||||
int ConUnInit( void );
|
||||
//void ConHideConsole(void);
|
||||
BOOL ConSetScreenRect( int xSize, int ySize );
|
||||
BOOL ConSetScreenSize( int X, int Y );
|
||||
BOOL ConRestoreScreen( void );
|
||||
BOOL ConSaveScreen( void );
|
||||
DWORD ConRedrawScreen( void );
|
||||
void ConSetAttribute( int *iParam, int iParamCount );
|
||||
void ConSetScrollRegion( int Top, int Bottom );
|
||||
int ConScreenSizeX();
|
||||
int ConSetScreenX();
|
||||
int ConScreenSizeY();
|
||||
int ConWindowSizeX();
|
||||
int ConWindowSizeY();
|
||||
int ConSetScreenY();
|
||||
void ConFillToEndOfLine();
|
||||
int ConWriteString(char* pszString, int cbString);
|
||||
int ConWriteMenu(char* pszString, int cbString);
|
||||
BOOL ConWriteChar( CHAR ch );
|
||||
int ConWriteConsole( char *pData, int NumChars );
|
||||
PCHAR ConDisplayData(char* pData, int NumLines);
|
||||
PCHAR ConWriteLine(char* pData);
|
||||
int Con_printf( const char *Format, ... );
|
||||
void ConClearScrollRegion();
|
||||
void ConClearScreen();
|
||||
void ConClearEOScreen();
|
||||
void ConClearBOScreen();
|
||||
void ConClearLine();
|
||||
void ConClearEOLine();
|
||||
void ConClearNFromCursorRight(int n);
|
||||
void ConClearNFromCursorLeft(int n);
|
||||
void ConScrollUpEntireBuffer();
|
||||
void ConScrollDownEntireBuffer();
|
||||
void ConScrollUp(int topline,int botline);
|
||||
void ConScrollDown(int topline,int botline);
|
||||
void ConClearBOLine();
|
||||
BOOL ConChangeCursor( CONSOLE_CURSOR_INFO *pCursorInfo );
|
||||
void ConSetCursorPosition(int x, int y);
|
||||
int ConGetCursorX();
|
||||
int ConGetCursorY();
|
||||
int ConGetCursorInBufferY(void);
|
||||
BOOL ConDisplayCursor( BOOL bVisible );
|
||||
void ConMoveCursorPosition(int x, int y);
|
||||
void ConGetRelativeCursorPosition(int *x, int *y);
|
||||
BOOL ConRestoreScreenHandle( SCREEN_HANDLE hScreen );
|
||||
BOOL ConRestoreScreenColors( void );
|
||||
SCREEN_HANDLE ConSaveScreenHandle( SCREEN_HANDLE);
|
||||
void ConDeleteScreenHandle( SCREEN_HANDLE hScreen );
|
||||
void ConSaveViewRect( void );
|
||||
void ConRestoreViewRect( void );
|
||||
void ConDeleteChars(int n);
|
||||
|
||||
|
||||
#endif
|
158
contrib/win32/win32compat/tncon.h
Normal file
158
contrib/win32/win32compat/tncon.h
Normal file
@ -0,0 +1,158 @@
|
||||
/* tncon.h
|
||||
* Author: Pragma Systems, Inc. <www.pragmasys.com>
|
||||
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
|
||||
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* Contains terminal emulation console related key definition
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice.
|
||||
* 2. Binaries produced provide no direct or implied warranties or any
|
||||
* guarantee of performance or suitability.
|
||||
*/
|
||||
#ifndef __TNCON_H
|
||||
#define __TNCON_H
|
||||
|
||||
#include "console.h"
|
||||
|
||||
#define UP_ARROW "\033[A"
|
||||
#define DOWN_ARROW "\033[B"
|
||||
#define RIGHT_ARROW "\033[C"
|
||||
#define LEFT_ARROW "\033[D"
|
||||
|
||||
#define APP_UP_ARROW "\033OA"
|
||||
#define APP_DOWN_ARROW "\033OB"
|
||||
#define APP_RIGHT_ARROW "\033OC"
|
||||
#define APP_LEFT_ARROW "\033OD"
|
||||
|
||||
// VT100 Function Key's
|
||||
#define VT100_PF1_KEY "\x1b\x4f\x50"
|
||||
#define VT100_PF2_KEY "\x1b\x4f\x51"
|
||||
#define VT100_PF3_KEY "\x1b\x4f\x52"
|
||||
#define VT100_PF4_KEY "\x1b\x4f\x53"
|
||||
#define VT100_PF5_KEY "\x1b\x4f\x54"
|
||||
#define VT100_PF6_KEY "\x1b\x4f\x55"
|
||||
#define VT100_PF7_KEY "\x1b\x4f\x56"
|
||||
#define VT100_PF8_KEY "\x1b\x4f\x57"
|
||||
#define VT100_PF9_KEY "\x1b\x4f\x58"
|
||||
#define VT100_PF10_KEY "\x1b\x4f\x59"
|
||||
|
||||
// VT420 Key's
|
||||
#define PF1_KEY "\033[11~"
|
||||
#define PF2_KEY "\033[12~"
|
||||
#define PF3_KEY "\033[13~"
|
||||
#define PF4_KEY "\033[14~"
|
||||
#define PF5_KEY "\033[15~"
|
||||
#define PF6_KEY "\033[17~"
|
||||
#define PF7_KEY "\033[18~"
|
||||
#define PF8_KEY "\033[19~"
|
||||
#define PF9_KEY "\033[20~"
|
||||
#define PF10_KEY "\033[21~"
|
||||
#define PF11_KEY "\033[23~"
|
||||
#define PF12_KEY "\033[24~"
|
||||
|
||||
#define SHIFT_PF1_KEY "\033[11;2~"
|
||||
#define SHIFT_PF2_KEY "\033[12;2~"
|
||||
#define SHIFT_PF3_KEY "\033[13;2~"
|
||||
#define SHIFT_PF4_KEY "\033[14;2~"
|
||||
#define SHIFT_PF5_KEY "\033[15;2~"
|
||||
#define SHIFT_PF6_KEY "\033[17;2~"
|
||||
#define SHIFT_PF7_KEY "\033[18;2~"
|
||||
#define SHIFT_PF8_KEY "\033[19;2~"
|
||||
#define SHIFT_PF9_KEY "\033[20;2~"
|
||||
#define SHIFT_PF10_KEY "\033[21;2~"
|
||||
#define SHIFT_PF11_KEY "\033[24;2~"
|
||||
#define SHIFT_PF12_KEY "\033[25;2~"
|
||||
|
||||
#define ALT_PF1_KEY "\033[11;3~"
|
||||
#define ALT_PF2_KEY "\033[12;3~"
|
||||
#define ALT_PF3_KEY "\033[13;3~"
|
||||
#define ALT_PF4_KEY "\033[14;3~"
|
||||
#define ALT_PF5_KEY "\033[15;3~"
|
||||
#define ALT_PF6_KEY "\033[17;3~"
|
||||
#define ALT_PF7_KEY "\033[18;3~"
|
||||
#define ALT_PF8_KEY "\033[19;3~"
|
||||
#define ALT_PF9_KEY "\033[20;3~"
|
||||
#define ALT_PF10_KEY "\033[21;3~"
|
||||
#define ALT_PF11_KEY "\033[24;3~"
|
||||
#define ALT_PF12_KEY "\033[25;3~"
|
||||
|
||||
#define CTRL_PF1_KEY "\033[11;4~"
|
||||
#define CTRL_PF2_KEY "\033[12;4~"
|
||||
#define CTRL_PF3_KEY "\033[13;4~"
|
||||
#define CTRL_PF4_KEY "\033[14;4~"
|
||||
#define CTRL_PF5_KEY "\033[15;4~"
|
||||
#define CTRL_PF6_KEY "\033[17;4~"
|
||||
#define CTRL_PF7_KEY "\033[18;4~"
|
||||
#define CTRL_PF8_KEY "\033[19;4~"
|
||||
#define CTRL_PF9_KEY "\033[20;4~"
|
||||
#define CTRL_PF10_KEY "\033[21;4~"
|
||||
#define CTRL_PF11_KEY "\033[24;4~"
|
||||
#define CTRL_PF12_KEY "\033[25;4~"
|
||||
|
||||
#define SHIFT_CTRL_PF1_KEY "\033[11;6~"
|
||||
#define SHIFT_CTRL_PF2_KEY "\033[12;6~"
|
||||
#define SHIFT_CTRL_PF3_KEY "\033[13;6~"
|
||||
#define SHIFT_CTRL_PF4_KEY "\033[14;6~"
|
||||
#define SHIFT_CTRL_PF5_KEY "\033[15;6~"
|
||||
#define SHIFT_CTRL_PF6_KEY "\033[17;6~"
|
||||
#define SHIFT_CTRL_PF7_KEY "\033[18;6~"
|
||||
#define SHIFT_CTRL_PF8_KEY "\033[19;6~"
|
||||
#define SHIFT_CTRL_PF9_KEY "\033[20;6~"
|
||||
#define SHIFT_CTRL_PF10_KEY "\033[21;6~"
|
||||
#define SHIFT_CTRL_PF11_KEY "\033[24;6~"
|
||||
#define SHIFT_CTRL_PF12_KEY "\033[25;6~"
|
||||
|
||||
#define SHIFT_ALT_PF1_KEY "\033[11;5~"
|
||||
#define SHIFT_ALT_PF2_KEY "\033[12;5~"
|
||||
#define SHIFT_ALT_PF3_KEY "\033[13;5~"
|
||||
#define SHIFT_ALT_PF4_KEY "\033[14;5~"
|
||||
#define SHIFT_ALT_PF5_KEY "\033[15;5~"
|
||||
#define SHIFT_ALT_PF6_KEY "\033[17;5~"
|
||||
#define SHIFT_ALT_PF7_KEY "\033[18;5~"
|
||||
#define SHIFT_ALT_PF8_KEY "\033[19;5~"
|
||||
#define SHIFT_ALT_PF9_KEY "\033[20;5~"
|
||||
#define SHIFT_ALT_PF10_KEY "\033[21;5~"
|
||||
#define SHIFT_ALT_PF11_KEY "\033[24;5~"
|
||||
#define SHIFT_ALT_PF12_KEY "\033[25;5~"
|
||||
|
||||
#define ALT_CTRL_PF1_KEY "\033[11;7~"
|
||||
#define ALT_CTRL_PF2_KEY "\033[12;7~"
|
||||
#define ALT_CTRL_PF3_KEY "\033[13;7~"
|
||||
#define ALT_CTRL_PF4_KEY "\033[14;7~"
|
||||
#define ALT_CTRL_PF5_KEY "\033[15;7~"
|
||||
#define ALT_CTRL_PF6_KEY "\033[17;7~"
|
||||
#define ALT_CTRL_PF7_KEY "\033[18;7~"
|
||||
#define ALT_CTRL_PF8_KEY "\033[19;7~"
|
||||
#define ALT_CTRL_PF9_KEY "\033[20;7~"
|
||||
#define ALT_CTRL_PF10_KEY "\033[21;7~"
|
||||
#define ALT_CTRL_PF11_KEY "\033[24;7~"
|
||||
#define ALT_CTRL_PF12_KEY "\033[25;7~"
|
||||
|
||||
#define SHIFT_ALT_CTRL_PF1_KEY "\033[11;8~"
|
||||
#define SHIFT_ALT_CTRL_PF2_KEY "\033[12;8~"
|
||||
#define SHIFT_ALT_CTRL_PF3_KEY "\033[13;8~"
|
||||
#define SHIFT_ALT_CTRL_PF4_KEY "\033[14;8~"
|
||||
#define SHIFT_ALT_CTRL_PF5_KEY "\033[15;8~"
|
||||
#define SHIFT_ALT_CTRL_PF6_KEY "\033[17;8~"
|
||||
#define SHIFT_ALT_CTRL_PF7_KEY "\033[18;8~"
|
||||
#define SHIFT_ALT_CTRL_PF8_KEY "\033[19;8~"
|
||||
#define SHIFT_ALT_CTRL_PF9_KEY "\033[20;8~"
|
||||
#define SHIFT_ALT_CTRL_PF10_KEY "\033[21;8~"
|
||||
#define SHIFT_ALT_CTRL_PF11_KEY "\033[24;8~"
|
||||
#define SHIFT_ALT_CTRL_PF12_KEY "\033[25;8~"
|
||||
|
||||
#define FIND_KEY "\x1b\x5b\x31\x7e"
|
||||
#define INSERT_KEY "\x1b\x5b\x32\x7e"
|
||||
#define REMOVE_KEY "\x1b\x5b\x33\x7e"
|
||||
#define SELECT_KEY "\x1b\x5b\x34\x7e"
|
||||
#define PREV_KEY "\x1b\x5b\x35\x7e"
|
||||
#define NEXT_KEY "\x1b\x5b\x36\x7e"
|
||||
#define SHIFT_TAB_KEY "\x1b\x5b\x5A"
|
||||
#define ESCAPE_KEY "\x1b"
|
||||
|
||||
|
||||
#endif
|
74
contrib/win32/win32compat/tnnet.c
Normal file
74
contrib/win32/win32compat/tnnet.c
Normal file
@ -0,0 +1,74 @@
|
||||
/* tnnet.c
|
||||
* Author: Pragma Systems, Inc. <www.pragmasys.com>
|
||||
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
|
||||
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* Contains terminal emulation related network calls to invoke ANSI parsing engine
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice.
|
||||
* 2. Binaries produced provide no direct or implied warranties or any
|
||||
* guarantee of performance or suitability.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "ansiprsr.h"
|
||||
#include "tncon.h"
|
||||
|
||||
#define dwBuffer 4096
|
||||
|
||||
int NetWriteString( char* pszString, size_t cbString)
|
||||
{
|
||||
//return send_output_to_remote_client( sock, pszString, (int)cbString, 0 );
|
||||
return (int)cbString ;
|
||||
}
|
||||
|
||||
size_t telProcessNetwork ( char *buf, size_t len )
|
||||
{
|
||||
unsigned char szBuffer[dwBuffer + 8];
|
||||
unsigned char* pszHead = szBuffer;
|
||||
unsigned char* pszTail = szBuffer;
|
||||
size_t Result;
|
||||
unsigned char* pszNewHead;
|
||||
|
||||
if (1)
|
||||
{
|
||||
Result = len ;
|
||||
pszTail = (unsigned char *)buf ;
|
||||
pszHead = (unsigned char *)buf ;
|
||||
|
||||
pszTail += Result;
|
||||
|
||||
pszNewHead = pszHead;
|
||||
|
||||
do
|
||||
{
|
||||
pszHead = pszNewHead;
|
||||
pszNewHead = ParseBuffer(pszHead, pszTail);
|
||||
} while ((pszNewHead != pszHead) && (pszNewHead < pszTail));
|
||||
|
||||
if ( pszNewHead >= pszTail )
|
||||
{
|
||||
// Everything is okay and we will reset variables and continue
|
||||
pszTail = pszHead = szBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveMemory(szBuffer, pszNewHead, pszTail - pszNewHead);
|
||||
pszTail = szBuffer + (pszTail - pszNewHead);
|
||||
pszHead = szBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
24
contrib/win32/win32compat/tnnet.h
Normal file
24
contrib/win32/win32compat/tnnet.h
Normal file
@ -0,0 +1,24 @@
|
||||
/* tnnet.h
|
||||
* Author: Pragma Systems, Inc. <www.pragmasys.com>
|
||||
* Contribution by Pragma Systems, Inc. for Microsoft openssh win32 port
|
||||
* Copyright (c) 2011, 2015 Pragma Systems, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* Contains terminal emulation related network calls to invoke ANSI parsing engine
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice.
|
||||
* 2. Binaries produced provide no direct or implied warranties or any
|
||||
* guarantee of performance or suitability.
|
||||
*/
|
||||
|
||||
#ifndef __TNNET_H
|
||||
#define __TNNET_H
|
||||
|
||||
int NetWriteString( char* pszString, size_t cbString);
|
||||
size_t telProcessNetwork ( char *buf, size_t len );
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user