mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-29 00:34:33 +02:00
Remove passthru, fix check for ansi console support. Removed VT52. (https://github.com/PowerShell/Win32-OpenSSH/issues/430)
This commit is contained in:
parent
d34edc89db
commit
d10d8a8f36
@ -56,6 +56,8 @@ extern int ScreenY;
|
|||||||
extern int ScrollTop;
|
extern int ScrollTop;
|
||||||
extern int ScrollBottom;
|
extern int ScrollBottom;
|
||||||
|
|
||||||
|
extern BOOL bAnsiParsing;
|
||||||
|
|
||||||
// end of imports from outside module
|
// end of imports from outside module
|
||||||
|
|
||||||
bool gbVTAppMode = false;
|
bool gbVTAppMode = false;
|
||||||
@ -67,7 +69,7 @@ static int AutoWrap = 1;
|
|||||||
|
|
||||||
BOOL bAtEOLN = FALSE;
|
BOOL bAtEOLN = FALSE;
|
||||||
|
|
||||||
static int term_mode;
|
static int term_mode = TERM_ANSI;
|
||||||
|
|
||||||
// ParseANSI globals - these need to be here, because sometimes blocks are sent
|
// ParseANSI globals - these need to be here, because sometimes blocks are sent
|
||||||
// in mid ANSI sequence
|
// in mid ANSI sequence
|
||||||
@ -176,14 +178,10 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
|
|||||||
unsigned char * pszCurrent = pszBuffer+1;
|
unsigned char * pszCurrent = pszBuffer+1;
|
||||||
unsigned char * pszNewCurrent = pszCurrent;
|
unsigned char * pszNewCurrent = pszCurrent;
|
||||||
|
|
||||||
if (term_mode == TERM_ANSI)
|
if (term_mode == TERM_ANSI && bAnsiParsing)
|
||||||
{
|
{
|
||||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||||
}
|
}
|
||||||
else if (term_mode == TERM_VT52)
|
|
||||||
{
|
|
||||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pszCurrent == pszNewCurrent) // Pointer didn't move inside Parse function
|
if (pszCurrent == pszNewCurrent) // Pointer didn't move inside Parse function
|
||||||
{
|
{
|
||||||
@ -294,10 +292,6 @@ unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd
|
|||||||
{
|
{
|
||||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||||
}
|
}
|
||||||
else if (term_mode == TERM_VT52)
|
|
||||||
{
|
|
||||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (pszNewCurrent > pszCurrent)
|
if (pszNewCurrent > pszCurrent)
|
||||||
pszBuffer = pszNewCurrent;
|
pszBuffer = pszNewCurrent;
|
||||||
@ -427,11 +421,6 @@ void ConSetExtendedMode(int iFunction, BOOL bEnable)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((iFunction == 2) && (bEnable))
|
|
||||||
{
|
|
||||||
term_mode = TERM_VT52;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MODE_EXT 0x00000001
|
#define MODE_EXT 0x00000001
|
||||||
@ -893,108 +882,3 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
|||||||
else
|
else
|
||||||
return pszBuffer;
|
return pszBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
*respbuf = VT52_TERMINAL_ID;
|
|
||||||
if (resplen != NULL)
|
|
||||||
{
|
|
||||||
*resplen = 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++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pszCurrent;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -37,12 +37,10 @@
|
|||||||
#define __ANSIPRSR_H
|
#define __ANSIPRSR_H
|
||||||
|
|
||||||
#define TERM_ANSI 0
|
#define TERM_ANSI 0
|
||||||
#define TERM_VT52 1
|
|
||||||
|
|
||||||
unsigned char * ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
unsigned char * ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
||||||
unsigned char * GetNextChar(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 **respbuf, size_t *resplen);
|
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
||||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen);
|
|
||||||
|
|
||||||
#define true TRUE
|
#define true TRUE
|
||||||
#define false FALSE
|
#define false FALSE
|
||||||
|
@ -57,6 +57,8 @@ int ScrollBottom;
|
|||||||
int LastCursorX;
|
int LastCursorX;
|
||||||
int LastCursorY;
|
int LastCursorY;
|
||||||
|
|
||||||
|
BOOL bAnsiParsing = FALSE;
|
||||||
|
|
||||||
char *pSavedScreen = NULL;
|
char *pSavedScreen = NULL;
|
||||||
static COORD ZeroCoord = {0,0};
|
static COORD ZeroCoord = {0,0};
|
||||||
COORD SavedScreenSize = {0,0};
|
COORD SavedScreenSize = {0,0};
|
||||||
@ -82,6 +84,7 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
|||||||
OSVERSIONINFO os;
|
OSVERSIONINFO os;
|
||||||
DWORD dwAttributes = 0;
|
DWORD dwAttributes = 0;
|
||||||
DWORD dwRet = 0;
|
DWORD dwRet = 0;
|
||||||
|
BOOL bRet = FALSE;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
static bool bFirstConInit = true;
|
static bool bFirstConInit = true;
|
||||||
|
|
||||||
@ -91,13 +94,13 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
|||||||
hOutputConsole = GetStdHandle(OutputHandle);
|
hOutputConsole = GetStdHandle(OutputHandle);
|
||||||
if (hOutputConsole == INVALID_HANDLE_VALUE) {
|
if (hOutputConsole == INVALID_HANDLE_VALUE) {
|
||||||
dwRet = GetLastError();
|
dwRet = GetLastError();
|
||||||
printf("GetStdHandle failed with %d\n", dwRet);
|
printf("GetStdHandle on OutputHandle failed with %d\n", dwRet);
|
||||||
return dwRet;
|
return dwRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes)) {
|
if (!GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes)) {
|
||||||
dwRet = GetLastError();
|
dwRet = GetLastError();
|
||||||
printf("GetConsoleMode failed with %d\n", GetLastError());
|
printf("GetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
|
||||||
return dwRet;
|
return dwRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +109,23 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
|||||||
ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
|
ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
|
||||||
dwAttributes |= ENABLE_WINDOW_INPUT;
|
dwAttributes |= ENABLE_WINDOW_INPUT;
|
||||||
|
|
||||||
char *term = getenv("TERM");
|
if (!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes)) { // Windows NT
|
||||||
|
dwRet = GetLastError();
|
||||||
|
printf("SetConsoleMode on STD_INPUT_HANDLE failed with %d\n", dwRet);
|
||||||
|
return dwRet;
|
||||||
|
}
|
||||||
|
|
||||||
if (term != NULL && (_stricmp(term, "ansi") == 0 || _stricmp(term, "passthru") == 0))
|
if (!GetConsoleMode(hOutputConsole, &dwAttributes)) {
|
||||||
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
dwRet = GetLastError();
|
||||||
|
printf("GetConsoleMode on hOutputConsole failed with %d\n", dwRet);
|
||||||
|
return dwRet;
|
||||||
|
}
|
||||||
|
|
||||||
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwAttributes); // Windows NT
|
dwAttributes |= (DWORD)ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
|
|
||||||
|
if (!SetConsoleMode(hOutputConsole, dwAttributes)) { // Windows NT
|
||||||
|
bAnsiParsing = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ConSetScreenX();
|
ConSetScreenX();
|
||||||
ConSetScreenY();
|
ConSetScreenY();
|
||||||
|
@ -57,16 +57,9 @@ size_t telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t
|
|||||||
unsigned char* pszHead = NULL;
|
unsigned char* pszHead = NULL;
|
||||||
unsigned char* pszTail = NULL;
|
unsigned char* pszTail = NULL;
|
||||||
|
|
||||||
char *term = NULL;
|
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
term = getenv("TERM");
|
|
||||||
|
|
||||||
if (term != NULL && _stricmp(term, "passthru") == 0)
|
|
||||||
return len;
|
|
||||||
|
|
||||||
// Transform a single carriage return into a single linefeed before
|
// Transform a single carriage return into a single linefeed before
|
||||||
// continuing.
|
// continuing.
|
||||||
if ((len == 1) && (buf[0] == 13))
|
if ((len == 1) && (buf[0] == 13))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user