mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 05:55:41 +02:00
Manual Merge change 3c6b77b4fdc45ada3a8b907cd4af6f73dfd70e66
3c6b77b4fdc45ada3a8b907cd4af6f73dfd70e66 Ray Hayes <rayhayes@rhbe.net> 7/28/2016 12:10:04 PM -07:00 First version with console changes.
This commit is contained in:
parent
367476c953
commit
c3b785a140
12
channels.c
12
channels.c
@ -2442,6 +2442,8 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
|
||||
char *data;
|
||||
u_int data_len, tcode;
|
||||
Channel *c;
|
||||
char *respbuf = NULL;
|
||||
size_t resplen = 0;
|
||||
|
||||
/* Get the channel number and verify it. */
|
||||
id = packet_get_int();
|
||||
@ -2480,8 +2482,14 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
|
||||
#ifndef WIN32_FIXME//N
|
||||
buffer_append(&c->extended, data, data_len);
|
||||
#else
|
||||
if ( c->client_tty )
|
||||
telProcessNetwork ( data, data_len ); // run it by ANSI engine if it is the ssh client
|
||||
if (c->client_tty) {
|
||||
if (telProcessNetwork(data, data_len, &respbuf, &resplen) > 0) // run it by ANSI engine if it is the ssh client
|
||||
buffer_append(&c->extended, data, data_len);
|
||||
|
||||
if (respbuf != NULL) {
|
||||
sshbuf_put(&c->input, respbuf, resplen);
|
||||
}
|
||||
}
|
||||
else
|
||||
buffer_append(&c->extended, data, data_len);
|
||||
#endif
|
||||
|
BIN
contrib/win32/openssh/Win32-OpenSSH.VC.db
Normal file
BIN
contrib/win32/openssh/Win32-OpenSSH.VC.db
Normal file
Binary file not shown.
@ -49,7 +49,6 @@
|
||||
#define TS_SEND 1
|
||||
|
||||
// items used from other modules
|
||||
int NetWriteString(char* pszString, size_t cbString);
|
||||
TelParams Parameters;
|
||||
|
||||
extern int ScreenX;
|
||||
@ -65,7 +64,6 @@ unsigned char VT_ST[] = { 0x1b, '/', '\0' };
|
||||
|
||||
static int AutoWrap = 1;
|
||||
|
||||
int marginTop, marginBottom;
|
||||
BOOL bAtEOLN = FALSE;
|
||||
|
||||
static int term_mode;
|
||||
@ -89,6 +87,7 @@ BOOL InPrintMode = FALSE;
|
||||
BOOL fPcMode = FALSE;
|
||||
|
||||
char printErr[] = "Unable to Print: Printer not assigned. Press any key to continue...";
|
||||
char cursor_report[255];
|
||||
|
||||
#define MODE_CURSORAPP 0x0001
|
||||
#define MODE_ANSIVT52 0x0002
|
||||
@ -117,12 +116,27 @@ int VTMode = 0;
|
||||
|
||||
char *GetTerminalId()
|
||||
{
|
||||
return "\033[?1;2c";
|
||||
return TERMINAL_ID;
|
||||
}
|
||||
|
||||
char * GetStatusReport()
|
||||
{
|
||||
return "\033[2;5R";
|
||||
return STATUS_REPORT;
|
||||
}
|
||||
|
||||
char * GetCursorPositionReport()
|
||||
{
|
||||
DWORD wr = 0;
|
||||
DWORD out = 0;
|
||||
|
||||
out = _snprintf_s(cursor_report, sizeof(cursor_report), _TRUNCATE,
|
||||
CURSOR_REPORT_FORMAT_STRING, ConGetCursorY() + 1, ConGetCursorX() + 1);
|
||||
|
||||
if (out > 0) {
|
||||
return cursor_report;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void BufConvertToG2(char * pszBuffer, int length)
|
||||
@ -147,202 +161,177 @@ void GoToNextLine()
|
||||
bAtEOLN = FALSE;
|
||||
}
|
||||
|
||||
unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd)
|
||||
unsigned char* ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd, unsigned char **respbuf, size_t *resplen)
|
||||
{
|
||||
int CurrentX;
|
||||
int CurrentY;
|
||||
int rc = 0, bufLen, cmpLen, i;
|
||||
int bufLen, cmpLen, i;
|
||||
|
||||
if (!fcompletion)
|
||||
{
|
||||
if (pszBuffer < pszBufferEnd - 1)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer+1;
|
||||
unsigned char * pszNewCurrent = pszCurrent;
|
||||
|
||||
if (!fcompletion)
|
||||
if (term_mode == TERM_ANSI)
|
||||
{
|
||||
if (pszBuffer < pszBufferEnd -1)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer+1;
|
||||
unsigned char * pszNewCurrent = pszCurrent;
|
||||
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
|
||||
{
|
||||
pszNewCurrent += ConWriteString( (char *)pszCurrent, 1);
|
||||
return pszBuffer + 1;
|
||||
}
|
||||
if (pszNewCurrent > pszCurrent)
|
||||
pszBuffer = pszNewCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
// This is handling special characters including locating the ESC which starts a
|
||||
// terminal control sequence.
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConClearNFromCursorLeft(1);
|
||||
ConMoveCursorPosition(-1, 0);
|
||||
}
|
||||
}
|
||||
bAtEOLN = FALSE;
|
||||
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++;
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = TRUE;
|
||||
break;
|
||||
|
||||
case 12:
|
||||
pszBuffer++;
|
||||
ConSetCursorPosition(0, 0);
|
||||
ConClearScreen();
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
pszBuffer++;
|
||||
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);
|
||||
pszNewCurrent = ParseANSI(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||
}
|
||||
else if (term_mode == TERM_VT52)
|
||||
{
|
||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd);
|
||||
pszNewCurrent = ParseVT52(pszCurrent, pszBufferEnd, respbuf, resplen);
|
||||
}
|
||||
if ( pszCurrent == pszNewCurrent ) // didn't move inside Parsefunction
|
||||
{
|
||||
pszNewCurrent += ConWriteString( (char *)pszCurrent, 1);
|
||||
return pszBuffer + 1;
|
||||
}
|
||||
if (pszNewCurrent > pszCurrent )
|
||||
pszBuffer = pszNewCurrent;
|
||||
}
|
||||
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;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
Beep( 1000, 400);
|
||||
pszBuffer++;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (bAtEOLN) GoToNextLine();
|
||||
|
||||
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;
|
||||
unsigned char* pszCurrent = pszBuffer;
|
||||
CurrentX = ConGetCursorX();
|
||||
|
||||
case 9:
|
||||
{
|
||||
if (bAtEOLN) GoToNextLine();
|
||||
int i, MoveRight = 8 - (ConGetCursorX() % 8);
|
||||
while ((pszCurrent < pszBufferEnd) && (*pszCurrent != (unsigned char)27)
|
||||
&& (*pszCurrent > (unsigned char)15) && (*pszCurrent != (unsigned char)255)
|
||||
&& (CurrentX++ < ScreenX))
|
||||
pszCurrent++;
|
||||
|
||||
for ( i = 0; i < MoveRight; i++ )
|
||||
ConWriteString( " ", 1 );
|
||||
pszBuffer++;
|
||||
AutoWrap = 1;
|
||||
bAtEOLN = FALSE;
|
||||
}
|
||||
break;
|
||||
if (fShiftOut)
|
||||
memset(pszBuffer, '|', pszCurrent - pszBuffer);
|
||||
|
||||
case 10:
|
||||
pszBuffer += ConWriteString((char *)pszBuffer, (int)(pszCurrent - pszBuffer));
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
if ((CurrentX >= ScreenX) && AutoWrap && !(VTMode & MODE_CURSORAPP))
|
||||
{
|
||||
bAtEOLN = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
|
||||
unsigned char * GetNextChar(unsigned char * pszBuffer, unsigned char *pszBufferEnd)
|
||||
unsigned char * GetNextChar(unsigned char *pszBuffer, unsigned char *pszBufferEnd)
|
||||
{
|
||||
if (++pszBuffer > pszBufferEnd)
|
||||
return NULL;
|
||||
@ -435,26 +424,25 @@ void ConSetExtendedMode(int iFunction, BOOL bEnable)
|
||||
|
||||
#define DIGI_MASK (MODE_CS0 | MODE_CS1 | MODE_CS2 | MODE_CS3 | MODE_CHAR)
|
||||
|
||||
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd)
|
||||
unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen)
|
||||
{
|
||||
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];
|
||||
const int nParam = 10; // Maximum number of parameters
|
||||
|
||||
fcompletion = 0;
|
||||
static int SavedX = 0;
|
||||
static int SavedY = 0;
|
||||
|
||||
unsigned char * pszCurrent = pszBuffer;
|
||||
|
||||
if (pszCurrent == NULL || pszBufferEnd == NULL)
|
||||
return NULL;
|
||||
|
||||
fcompletion = 0;
|
||||
do
|
||||
{
|
||||
switch ((unsigned char) *pszCurrent)
|
||||
{
|
||||
case ';': // delimiter
|
||||
// Delimiter
|
||||
case ';':
|
||||
bDelimiter = TRUE;
|
||||
break;
|
||||
// Modifiers
|
||||
@ -489,7 +477,7 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '<': // character set
|
||||
case '<': // Character set
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
@ -500,69 +488,63 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
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
|
||||
|
||||
case '^': // Private message
|
||||
while (pszCurrent && pszCurrent < pszBufferEnd &&
|
||||
_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) ) )
|
||||
if (pszCurrent && pszCurrent < pszBufferEnd &&
|
||||
_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
|
||||
case 'A': // Character Set change 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
|
||||
|
||||
case 'B': // Character set change or Cursor down
|
||||
if (bMode & MODE_CHAR)
|
||||
{
|
||||
// US ASCII Character Set
|
||||
// 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
|
||||
|
||||
case 'C': // Character Set change or Cursor right
|
||||
if (bMode & MODE_CHAR)
|
||||
{
|
||||
// Britsh Character Set
|
||||
// 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
|
||||
|
||||
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)
|
||||
{
|
||||
@ -573,38 +555,36 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
|
||||
case '=': // application mode
|
||||
case '=': // Application mode
|
||||
VTMode |= MODE_APPMODE;
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case '>': // numeric mode
|
||||
|
||||
case '>': // Numeric mode
|
||||
VTMode &= ~MODE_APPMODE;
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case '%': // character set definitions
|
||||
|
||||
case '%': // Character set definitions
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
case 'l': // ^[?25h
|
||||
if (bMode & MODE_EXT)
|
||||
{
|
||||
if (iParam[0] == 4){
|
||||
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);
|
||||
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);
|
||||
ConSetExtendedMode(iParam[0], *pszCurrent=='h' ? 1 : 0);
|
||||
if (iParam[0] == 4){
|
||||
VTMode &= ~MODE_IRM_INSERT;
|
||||
}
|
||||
@ -629,31 +609,25 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
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)
|
||||
{
|
||||
@ -668,35 +642,37 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
{
|
||||
int i ;
|
||||
for (i=0; i<iParam[0]; i++)
|
||||
ConScrollUp(ConGetCursorY(),ScrollTop + marginBottom - ConGetCursorY());
|
||||
ConScrollUp(ConGetCursorY(), ScrollTop - ConGetCursorY());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ConGetCursorY() <= ScrollTop + ConWindowSizeY()-2)
|
||||
if (ConGetCursorY() <= ScrollTop + ConWindowSizeY() - 2)
|
||||
{
|
||||
ConScrollUp(ConGetCursorY(),ScrollTop + marginBottom - ConGetCursorY());
|
||||
ConScrollUp(ConGetCursorY(), ScrollTop - ConGetCursorY());
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
bAtEOLN = FALSE;
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
case 'g':
|
||||
fcompletion = 1;
|
||||
break;
|
||||
case 'i': // ANSI or VTXXX Print
|
||||
fcompletion = 1;//
|
||||
|
||||
case 'i': // ANSI or VTXXX Print
|
||||
if ( iParam[0] == 5 )
|
||||
{
|
||||
}
|
||||
else if ( iParam[0] == 4 )
|
||||
InPrintMode = FALSE;
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
if (bMode & MODE_BRK)
|
||||
{
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 0;
|
||||
switch (iParam[0])
|
||||
{
|
||||
case 0:
|
||||
@ -719,8 +695,6 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
if (iCurrentParam < 1)
|
||||
iParam[0] = 0;
|
||||
switch (iParam[0])
|
||||
{
|
||||
case 0:
|
||||
@ -737,32 +711,54 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (iCurrentParam < 1)
|
||||
if (iCurrentParam == 1)
|
||||
{
|
||||
if (iParam[0] == 5)
|
||||
{
|
||||
char * szStatus = GetStatusReport();
|
||||
NetWriteString(szStatus, strlen(szStatus));
|
||||
if (respbuf != NULL)
|
||||
{
|
||||
*respbuf = szStatus;
|
||||
if (resplen != NULL)
|
||||
{
|
||||
*resplen = strlen(szStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( iParam[0] == 6 )
|
||||
{
|
||||
char * szStatus = GetStatusReport();
|
||||
NetWriteString(szStatus, strlen(szStatus));
|
||||
char * szStatus = GetCursorPositionReport();
|
||||
if (respbuf != NULL)
|
||||
{
|
||||
*respbuf = szStatus;
|
||||
if (resplen != NULL)
|
||||
{
|
||||
*resplen = strlen(szStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
|
||||
if (bMode == (MODE_BRK & MODE_EXT))
|
||||
{
|
||||
// What are you response
|
||||
// What is your response?
|
||||
}
|
||||
else if (bMode == MODE_BRK)
|
||||
{
|
||||
char* szTerminalId = GetTerminalId();
|
||||
NetWriteString(szTerminalId, strlen(szTerminalId));
|
||||
if (szTerminalId) {
|
||||
if (respbuf != NULL)
|
||||
{
|
||||
*respbuf = szTerminalId;
|
||||
if (resplen != NULL)
|
||||
{
|
||||
*resplen = strlen(szTerminalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
@ -772,24 +768,30 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
fcompletion = 1;
|
||||
break;
|
||||
|
||||
case 'Z': // Identify - This is really a VT52 command
|
||||
case 'Z': // Identify - This is really a VT52 command
|
||||
{
|
||||
char* szTerminalId = GetTerminalId();
|
||||
NetWriteString(szTerminalId, strlen(szTerminalId));
|
||||
if (szTerminalId) {
|
||||
*respbuf = szTerminalId;
|
||||
if (resplen != NULL)
|
||||
{
|
||||
*resplen = strlen(szTerminalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
fcompletion = 1;
|
||||
break;
|
||||
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!
|
||||
// pszHead should point to digit now. Otherwise we got a bad escape
|
||||
// sequence, so we just get out of here!
|
||||
if(*pszCurrent) {
|
||||
if (!isdigit(*pszCurrent))
|
||||
{
|
||||
pszCurrent = pszBuffer;
|
||||
@ -816,13 +818,18 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
SavedY = ConGetCursorY();
|
||||
break;
|
||||
case 8:
|
||||
ConSetCursorPosition(SavedX,SavedY);
|
||||
ConSetCursorPosition(SavedX, SavedY);
|
||||
break;
|
||||
}
|
||||
fcompletion = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pszCurrent = pszBuffer;
|
||||
return pszCurrent;
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
} while ((++pszCurrent < pszBufferEnd) && !fcompletion);
|
||||
@ -833,7 +840,6 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
iCurrentParam = 0;
|
||||
bDelimiter = 0;
|
||||
bMode = 0;
|
||||
// fcompletion = 0;
|
||||
bExtMode = 0;
|
||||
bCS0 = 0;
|
||||
bCS1 = 0;
|
||||
@ -845,7 +851,7 @@ unsigned char * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd)
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd, unsigned char **respbuf, size_t *resplen)
|
||||
{
|
||||
unsigned char * pszCurrent = pszBuffer;
|
||||
int iLine;
|
||||
@ -853,7 +859,6 @@ unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
|
||||
switch ((unsigned char) *pszCurrent)
|
||||
{
|
||||
|
||||
case 'A': // Cursor Up
|
||||
ConMoveCursorPosition(0, -1);
|
||||
pszCurrent++;
|
||||
@ -865,21 +870,24 @@ unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
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;
|
||||
@ -887,21 +895,24 @@ unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
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);
|
||||
pszCurrent = GetNextChar(pszCurrent, pszBufferEnd);
|
||||
if (pszCurrent != NULL)
|
||||
{
|
||||
iLine = *pszCurrent - 31;
|
||||
iLine = *pszCurrent - 31;
|
||||
|
||||
pszCurrent = GetNextChar(pszCurrent,pszBufferEnd);
|
||||
pszCurrent = GetNextChar(pszCurrent, pszBufferEnd);
|
||||
if (pszCurrent != NULL)
|
||||
{
|
||||
iColumn = *pszCurrent - 31;
|
||||
@ -916,21 +927,29 @@ unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEn
|
||||
break;
|
||||
|
||||
case 'Z': // Identify
|
||||
NetWriteString("\033/Z",3);
|
||||
*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;
|
||||
|
@ -39,16 +39,15 @@
|
||||
#define TERM_ANSI 0
|
||||
#define TERM_VT52 1
|
||||
|
||||
unsigned char * ParseBuffer(unsigned char* pszBuffer, unsigned char* pszBufferEnd);
|
||||
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 * ParseANSI(unsigned char * pszBuffer, unsigned char * pszBufferEnd);
|
||||
unsigned char * ParseVT52(unsigned char * pszBuffer, unsigned char * pszBufferEnd);
|
||||
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 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
|
||||
@ -60,22 +59,22 @@ typedef struct _TelParams
|
||||
|
||||
char *pInputFile;
|
||||
|
||||
char * szDebugInputFile;
|
||||
BOOL fDebugWait;
|
||||
char *szDebugInputFile;
|
||||
BOOL fDebugWait;
|
||||
|
||||
int timeOut;
|
||||
int fLocalEcho;
|
||||
int fTreatLFasCRLF;
|
||||
int fSendCROnly;
|
||||
int nReceiveCRLF;
|
||||
//_crlftype nReceiveCRLF;
|
||||
char sleepChar;
|
||||
char menuChar;
|
||||
|
||||
SOCKET Socket;
|
||||
char sleepChar;
|
||||
char menuChar;
|
||||
|
||||
SOCKET Socket;
|
||||
BOOL bVT100Mode;
|
||||
|
||||
char *pAltKey;
|
||||
char *pAltKey;
|
||||
|
||||
} TelParams;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -58,6 +58,7 @@
|
||||
#define ANSI_FOREGROUND_MAGENTA 35
|
||||
#define ANSI_FOREGROUND_CYAN 36
|
||||
#define ANSI_FOREGROUND_WHITE 37
|
||||
#define ANSI_DEFAULT_FOREGROUND 39
|
||||
#define ANSI_BACKGROUND_BLACK 40
|
||||
#define ANSI_BACKGROUND_RED 41
|
||||
#define ANSI_BACKGROUND_GREEN 42
|
||||
@ -66,6 +67,7 @@
|
||||
#define ANSI_BACKGROUND_MAGENTA 45
|
||||
#define ANSI_BACKGROUND_CYAN 46
|
||||
#define ANSI_BACKGROUND_WHITE 47
|
||||
#define ANSI_DEFAULT_BACKGROUND 49
|
||||
#define ANSI_BACKGROUND_BRIGHT 128
|
||||
|
||||
#define TAB_LENGTH 4
|
||||
@ -81,14 +83,14 @@ typedef void * SCREEN_HANDLE;
|
||||
int ConInit( DWORD OutputHandle, BOOL fSmartInit);
|
||||
int ConUnInitWithRestore( void );
|
||||
int ConUnInit( void );
|
||||
//void ConHideConsole(void);
|
||||
BOOL ConIsRedirected(HANDLE hInput);
|
||||
HANDLE GetConsoleOutputHandle();
|
||||
HANDLE GetConsoleInputHandle();
|
||||
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();
|
||||
@ -97,7 +99,6 @@ 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);
|
||||
@ -131,6 +132,7 @@ void ConDeleteScreenHandle( SCREEN_HANDLE hScreen );
|
||||
void ConSaveViewRect( void );
|
||||
void ConRestoreViewRect( void );
|
||||
void ConDeleteChars(int n);
|
||||
void ConSaveWindowsState(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -170,7 +170,7 @@ static int
|
||||
createFile_flags_setup(int flags, int mode, struct createFile_flags* cf_flags) {
|
||||
|
||||
/* check flags */
|
||||
int rwflags = flags & 0xf;
|
||||
int rwflags = flags & 0x3;
|
||||
int c_s_flags = flags & 0xfffffff0;
|
||||
|
||||
/*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,29 +43,9 @@
|
||||
|
||||
#define SocketErrorStringSize 1024
|
||||
|
||||
char * strerror_win32(int error)
|
||||
{
|
||||
|
||||
static char SocketErrorString[2 * SocketErrorStringSize] = { 0 };
|
||||
|
||||
DWORD error_win32 = WSAGetLastError();
|
||||
|
||||
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error_win32, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
|
||||
(LPTSTR) SocketErrorString, SocketErrorStringSize,
|
||||
NULL ) != 0)
|
||||
{
|
||||
return SocketErrorString;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert string encoding from one 8-bit CP to another 8-bit CP.
|
||||
* WARNING: Returned strong MUST be free by caller.
|
||||
* WARNING: Returned string MUST be freed by caller.
|
||||
*
|
||||
* src - source string (IN).
|
||||
* srcSize - size of src string in bytes or -1 if zero terminated (IN).
|
||||
@ -77,8 +57,7 @@ char * strerror_win32(int error)
|
||||
* or NULL if error.
|
||||
*
|
||||
*/
|
||||
|
||||
void *CovertCodePage(const char *src, int srcSize,
|
||||
void *ConvertCodePage(const char *src, int srcSize,
|
||||
DWORD srcCP, DWORD dstCP, int *retSize)
|
||||
{
|
||||
int exitCode = -1;
|
||||
@ -188,7 +167,7 @@ void *CovertCodePage(const char *src, int srcSize,
|
||||
}
|
||||
|
||||
/*
|
||||
* Covert string from UTF8 to CP used by current thread (Local8).
|
||||
* Convert string from UTF8 to CP used by current thread (Local8).
|
||||
*
|
||||
* utf8 - string in UTF8 (IN).
|
||||
* utf8Size - size of utf8 string in bytes or -1 if zero terminated (IN).
|
||||
@ -197,13 +176,13 @@ void *CovertCodePage(const char *src, int srcSize,
|
||||
* RETURNS: Pointer to new allocated Local8 string or NULL if error.
|
||||
*/
|
||||
|
||||
void *CovertUtf8ToLocal8(const char *utf8, int utf8Size, int *bytesReturned)
|
||||
void *ConvertUtf8ToLocal8(const char *utf8, int utf8Size, int *bytesReturned)
|
||||
{
|
||||
return CovertCodePage(utf8, utf8Size, CP_UTF8, GetACP(), bytesReturned);
|
||||
return ConvertCodePage(utf8, utf8Size, CP_UTF8, GetACP(), bytesReturned);
|
||||
}
|
||||
|
||||
/*
|
||||
* Covert string from CP used by current thread (Local8) to UTF8.
|
||||
* Convert string from CP used by current thread (Local8) to UTF8.
|
||||
*
|
||||
* local8 - string in Local8 CP (IN).
|
||||
* local8Size - size of local8 string in bytes or -1 if zero terminated (IN).
|
||||
@ -214,6 +193,6 @@ void *CovertUtf8ToLocal8(const char *utf8, int utf8Size, int *bytesReturned)
|
||||
|
||||
void *ConvertLocal8ToUtf8(const char *local8, int local8Size, int *bytesReturned)
|
||||
{
|
||||
return CovertCodePage(local8, local8Size,
|
||||
return ConvertCodePage(local8, local8Size,
|
||||
GetACP(), CP_UTF8, bytesReturned);
|
||||
}
|
||||
|
@ -32,15 +32,14 @@
|
||||
#ifndef StringHelp_H
|
||||
#define StringHelp_H 1
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char * strerror_win32(int);
|
||||
|
||||
void *CovertCodePage(const char *src, DWORD srcCP, DWORD dstCP, int *retSize);
|
||||
void *CovertUtf8ToLocal8(const char *utf8, int utf8Size, int *bytesReturned);
|
||||
void *CovertLocal8ToUtf8(const char *local8, int local8Size, int *bytesReturned);
|
||||
void *ConvertCodePage(const char *src, int srcSize, DWORD srcCP, DWORD dstCP, int *retSize);
|
||||
void *ConvertUtf8ToLocal8(const char *utf8, int utf8Size, int *bytesReturned);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <Windows.h>
|
||||
#include "w32fd.h"
|
||||
#include "tncon.h"
|
||||
#include "inc/defs.h"
|
||||
|
||||
#define TERM_IO_BUF_SIZE 2048
|
||||
@ -48,6 +49,33 @@ static DWORD WINAPI ReadThread(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DWORD WINAPI ReadConsoleThread(
|
||||
_In_ LPVOID lpParameter
|
||||
) {
|
||||
int nBytesReturned = 0;
|
||||
|
||||
struct w32_io* pio = (struct w32_io*)lpParameter;
|
||||
|
||||
debug3("TermRead thread, io:%p", pio);
|
||||
memset(&read_status, 0, sizeof(read_status));
|
||||
|
||||
while (nBytesReturned == 0) {
|
||||
nBytesReturned = ReadConsoleForTermEmul(WINHANDLE(pio),
|
||||
pio->read_details.buf, pio->read_details.buf_size);
|
||||
}
|
||||
|
||||
read_status.transferred = nBytesReturned;
|
||||
|
||||
if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) {
|
||||
debug("TermRead thread - ERROR QueueUserAPC failed %d, io:%p", GetLastError(), pio);
|
||||
pio->read_details.pending = FALSE;
|
||||
pio->read_details.error = GetLastError();
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
termio_initiate_read(struct w32_io* pio) {
|
||||
HANDLE read_thread;
|
||||
@ -63,7 +91,7 @@ termio_initiate_read(struct w32_io* pio) {
|
||||
pio->read_details.buf_size = TERM_IO_BUF_SIZE;
|
||||
}
|
||||
|
||||
read_thread = CreateThread(NULL, 0, ReadThread, pio, 0, NULL);
|
||||
read_thread = CreateThread(NULL, 0, ReadConsoleThread, pio, 0, NULL);
|
||||
if (read_thread == NULL) {
|
||||
errno = errno_from_Win32Error(GetLastError());
|
||||
debug("TermRead initiate - ERROR CreateThread %d, io:%p", GetLastError(), pio);
|
||||
@ -136,9 +164,9 @@ int termio_close(struct w32_io* pio) {
|
||||
HANDLE h;
|
||||
|
||||
CancelIoEx(WINHANDLE(pio), NULL);
|
||||
/* If io is pending, let worker threads exit*/
|
||||
if (pio->read_details.pending)
|
||||
WaitForSingleObject(pio->read_overlapped.hEvent, INFINITE);
|
||||
/* If io is pending, let write worker threads exit. The read thread is blocked so terminate it.*/
|
||||
if (pio->read_details.pending)
|
||||
TerminateThread(pio->read_overlapped.hEvent, 0);
|
||||
if (pio->write_details.pending)
|
||||
WaitForSingleObject(pio->write_overlapped.hEvent, INFINITE);
|
||||
/* drain queued APCs */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,141 +37,147 @@
|
||||
|
||||
#include "console.h"
|
||||
|
||||
#define UP_ARROW "\033[A"
|
||||
#define DOWN_ARROW "\033[B"
|
||||
#define RIGHT_ARROW "\033[C"
|
||||
#define LEFT_ARROW "\033[D"
|
||||
#define UP_ARROW "\x1b[A"
|
||||
#define DOWN_ARROW "\x1b[B"
|
||||
#define RIGHT_ARROW "\x1b[C"
|
||||
#define LEFT_ARROW "\x1b[D"
|
||||
|
||||
#define APP_UP_ARROW "\033OA"
|
||||
#define APP_DOWN_ARROW "\033OB"
|
||||
#define APP_RIGHT_ARROW "\033OC"
|
||||
#define APP_LEFT_ARROW "\033OD"
|
||||
#define APP_UP_ARROW "\x1bOA"
|
||||
#define APP_DOWN_ARROW "\x1bOB"
|
||||
#define APP_RIGHT_ARROW "\x1bOC"
|
||||
#define APP_LEFT_ARROW "\x1bOD"
|
||||
|
||||
// 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"
|
||||
#define VT100_PF1_KEY "\x1bO2"
|
||||
#define VT100_PF2_KEY "\x1bO3"
|
||||
#define VT100_PF3_KEY "\x1bO4"
|
||||
#define VT100_PF4_KEY "\x1bO5"
|
||||
#define VT100_PF5_KEY "\x1bO6"
|
||||
#define VT100_PF6_KEY "\x1bO7"
|
||||
#define VT100_PF7_KEY "\x1bO8"
|
||||
#define VT100_PF8_KEY "\x1bO9"
|
||||
#define VT100_PF9_KEY "\x1bO:"
|
||||
#define VT100_PF10_KEY "\x1bO;"
|
||||
|
||||
// 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 PF1_KEY "\x1b[11~"
|
||||
#define PF2_KEY "\x1b[12~"
|
||||
#define PF3_KEY "\x1b[13~"
|
||||
#define PF4_KEY "\x1b[14~"
|
||||
#define PF5_KEY "\x1b[15~"
|
||||
#define PF6_KEY "\x1b[17~"
|
||||
#define PF7_KEY "\x1b[18~"
|
||||
#define PF8_KEY "\x1b[19~"
|
||||
#define PF9_KEY "\x1b[20~"
|
||||
#define PF10_KEY "\x1b[21~"
|
||||
#define PF11_KEY "\x1b[23~"
|
||||
#define PF12_KEY "\x1b[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 SHIFT_PF1_KEY "\x1b[11;2~"
|
||||
#define SHIFT_PF2_KEY "\x1b[12;2~"
|
||||
#define SHIFT_PF3_KEY "\x1b[13;2~"
|
||||
#define SHIFT_PF4_KEY "\x1b[14;2~"
|
||||
#define SHIFT_PF5_KEY "\x1b[15;2~"
|
||||
#define SHIFT_PF6_KEY "\x1b[17;2~"
|
||||
#define SHIFT_PF7_KEY "\x1b[18;2~"
|
||||
#define SHIFT_PF8_KEY "\x1b[19;2~"
|
||||
#define SHIFT_PF9_KEY "\x1b[20;2~"
|
||||
#define SHIFT_PF10_KEY "\x1b[21;2~"
|
||||
#define SHIFT_PF11_KEY "\x1b[24;2~"
|
||||
#define SHIFT_PF12_KEY "\x1b[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 ALT_PF1_KEY "\x1b[11;3~"
|
||||
#define ALT_PF2_KEY "\x1b[12;3~"
|
||||
#define ALT_PF3_KEY "\x1b[13;3~"
|
||||
#define ALT_PF4_KEY "\x1b[14;3~"
|
||||
#define ALT_PF5_KEY "\x1b[15;3~"
|
||||
#define ALT_PF6_KEY "\x1b[17;3~"
|
||||
#define ALT_PF7_KEY "\x1b[18;3~"
|
||||
#define ALT_PF8_KEY "\x1b[19;3~"
|
||||
#define ALT_PF9_KEY "\x1b[20;3~"
|
||||
#define ALT_PF10_KEY "\x1b[21;3~"
|
||||
#define ALT_PF11_KEY "\x1b[24;3~"
|
||||
#define ALT_PF12_KEY "\x1b[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 CTRL_PF1_KEY "\x1b[11;4~"
|
||||
#define CTRL_PF2_KEY "\x1b[12;4~"
|
||||
#define CTRL_PF3_KEY "\x1b[13;4~"
|
||||
#define CTRL_PF4_KEY "\x1b[14;4~"
|
||||
#define CTRL_PF5_KEY "\x1b[15;4~"
|
||||
#define CTRL_PF6_KEY "\x1b[17;4~"
|
||||
#define CTRL_PF7_KEY "\x1b[18;4~"
|
||||
#define CTRL_PF8_KEY "\x1b[19;4~"
|
||||
#define CTRL_PF9_KEY "\x1b[20;4~"
|
||||
#define CTRL_PF10_KEY "\x1b[21;4~"
|
||||
#define CTRL_PF11_KEY "\x1b[24;4~"
|
||||
#define CTRL_PF12_KEY "\x1b[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_CTRL_PF1_KEY "\x1b[11;6~"
|
||||
#define SHIFT_CTRL_PF2_KEY "\x1b[12;6~"
|
||||
#define SHIFT_CTRL_PF3_KEY "\x1b[13;6~"
|
||||
#define SHIFT_CTRL_PF4_KEY "\x1b[14;6~"
|
||||
#define SHIFT_CTRL_PF5_KEY "\x1b[15;6~"
|
||||
#define SHIFT_CTRL_PF6_KEY "\x1b[17;6~"
|
||||
#define SHIFT_CTRL_PF7_KEY "\x1b[18;6~"
|
||||
#define SHIFT_CTRL_PF8_KEY "\x1b[19;6~"
|
||||
#define SHIFT_CTRL_PF9_KEY "\x1b[20;6~"
|
||||
#define SHIFT_CTRL_PF10_KEY "\x1b[21;6~"
|
||||
#define SHIFT_CTRL_PF11_KEY "\x1b[24;6~"
|
||||
#define SHIFT_CTRL_PF12_KEY "\x1b[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 SHIFT_ALT_PF1_KEY "\x1b[11;5~"
|
||||
#define SHIFT_ALT_PF2_KEY "\x1b[12;5~"
|
||||
#define SHIFT_ALT_PF3_KEY "\x1b[13;5~"
|
||||
#define SHIFT_ALT_PF4_KEY "\x1b[14;5~"
|
||||
#define SHIFT_ALT_PF5_KEY "\x1b[15;5~"
|
||||
#define SHIFT_ALT_PF6_KEY "\x1b[17;5~"
|
||||
#define SHIFT_ALT_PF7_KEY "\x1b[18;5~"
|
||||
#define SHIFT_ALT_PF8_KEY "\x1b[19;5~"
|
||||
#define SHIFT_ALT_PF9_KEY "\x1b[20;5~"
|
||||
#define SHIFT_ALT_PF10_KEY "\x1b[21;5~"
|
||||
#define SHIFT_ALT_PF11_KEY "\x1b[24;5~"
|
||||
#define SHIFT_ALT_PF12_KEY "\x1b[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 ALT_CTRL_PF1_KEY "\x1b[11;7~"
|
||||
#define ALT_CTRL_PF2_KEY "\x1b[12;7~"
|
||||
#define ALT_CTRL_PF3_KEY "\x1b[13;7~"
|
||||
#define ALT_CTRL_PF4_KEY "\x1b[14;7~"
|
||||
#define ALT_CTRL_PF5_KEY "\x1b[15;7~"
|
||||
#define ALT_CTRL_PF6_KEY "\x1b[17;7~"
|
||||
#define ALT_CTRL_PF7_KEY "\x1b[18;7~"
|
||||
#define ALT_CTRL_PF8_KEY "\x1b[19;7~"
|
||||
#define ALT_CTRL_PF9_KEY "\x1b[20;7~"
|
||||
#define ALT_CTRL_PF10_KEY "\x1b[21;7~"
|
||||
#define ALT_CTRL_PF11_KEY "\x1b[24;7~"
|
||||
#define ALT_CTRL_PF12_KEY "\x1b[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 SHIFT_ALT_CTRL_PF1_KEY "\x1b[11;8~"
|
||||
#define SHIFT_ALT_CTRL_PF2_KEY "\x1b[12;8~"
|
||||
#define SHIFT_ALT_CTRL_PF3_KEY "\x1b[13;8~"
|
||||
#define SHIFT_ALT_CTRL_PF4_KEY "\x1b[14;8~"
|
||||
#define SHIFT_ALT_CTRL_PF5_KEY "\x1b[15;8~"
|
||||
#define SHIFT_ALT_CTRL_PF6_KEY "\x1b[17;8~"
|
||||
#define SHIFT_ALT_CTRL_PF7_KEY "\x1b[18;8~"
|
||||
#define SHIFT_ALT_CTRL_PF8_KEY "\x1b[19;8~"
|
||||
#define SHIFT_ALT_CTRL_PF9_KEY "\x1b[20;8~"
|
||||
#define SHIFT_ALT_CTRL_PF10_KEY "\x1b[21;8~"
|
||||
#define SHIFT_ALT_CTRL_PF11_KEY "\x1b[24;8~"
|
||||
#define SHIFT_ALT_CTRL_PF12_KEY "\x1b[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"
|
||||
#define FIND_KEY "\x1b[1~"
|
||||
#define INSERT_KEY "\x1b[2~"
|
||||
#define REMOVE_KEY "\x1b[3~"
|
||||
#define SELECT_KEY "\x1b[4~"
|
||||
#define PREV_KEY "\x1b[5~"
|
||||
#define NEXT_KEY "\x1b[6~"
|
||||
#define SHIFT_TAB_KEY "\x1b[~"
|
||||
#define ESCAPE_KEY "\x1b"
|
||||
|
||||
#define TERMINAL_ID "\x1b[?1;2c"
|
||||
#define STATUS_REPORT "\x1b[2;5R"
|
||||
#define CURSOR_REPORT_FORMAT_STRING "\x1b[%d;%dR"
|
||||
#define VT52_TERMINAL_ID "\x1b/Z"
|
||||
|
||||
int ReadConsoleForTermEmul(HANDLE hInput, char *destin, int destinlen);
|
||||
|
||||
#endif
|
@ -37,60 +37,58 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "ansiprsr.h"
|
||||
#include "tncon.h"
|
||||
#include <ansiprsr.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 )
|
||||
// Server will always be returning a sequence of ANSI control characters which the client
|
||||
// protocol can either passthru directly to the console or transform based on an output terminal
|
||||
// type. We're not using termcap so we're only supporting the ANSI (vt100) sequences that
|
||||
// are hardcoded in the server and will be transformed to Windows Console commands.
|
||||
|
||||
size_t telProcessNetwork(char *buf, size_t len, unsigned char **respbuf, size_t *resplen)
|
||||
{
|
||||
unsigned char szBuffer[dwBuffer + 8];
|
||||
unsigned char* pszHead = szBuffer;
|
||||
unsigned char* pszTail = szBuffer;
|
||||
size_t Result;
|
||||
unsigned char* pszNewHead;
|
||||
|
||||
unsigned char* pszNewHead = NULL;
|
||||
|
||||
unsigned char* pszHead = NULL;
|
||||
unsigned char* pszTail = NULL;
|
||||
|
||||
char *term = NULL;
|
||||
|
||||
if (len == 0)
|
||||
return len;
|
||||
|
||||
term = getenv("TERM");
|
||||
|
||||
if (term != NULL && _stricmp(term, "passthru") == 0)
|
||||
return len;
|
||||
|
||||
// Transform a single carriage return into a single linefeed before
|
||||
// continuing.
|
||||
if ((len == 1) && (buf[0] == 13))
|
||||
buf[0] = 10;
|
||||
|
||||
if (1)
|
||||
{
|
||||
Result = len ;
|
||||
pszTail = (unsigned char *)buf ;
|
||||
pszHead = (unsigned char *)buf ;
|
||||
pszTail = (unsigned char *)buf;
|
||||
pszHead = (unsigned char *)buf;
|
||||
|
||||
pszTail += Result;
|
||||
pszTail += len;
|
||||
|
||||
pszNewHead = pszHead;
|
||||
pszNewHead = pszHead;
|
||||
|
||||
do
|
||||
{
|
||||
pszHead = pszNewHead;
|
||||
pszNewHead = ParseBuffer(pszHead, pszTail);
|
||||
} while ((pszNewHead != pszHead) && (pszNewHead < pszTail));
|
||||
// Loop through the network buffer transforming characters as necessary.
|
||||
// The buffer will be empty after the transformation
|
||||
// process since the buffer will contain only commands that are handled by the console API.
|
||||
do {
|
||||
pszHead = pszNewHead;
|
||||
pszNewHead = ParseBuffer(pszHead, pszTail, respbuf, resplen);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
} while ((pszNewHead != pszHead) && (pszNewHead < pszTail) && (resplen == NULL || (resplen != NULL && *resplen == 0)));
|
||||
|
||||
len = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -36,8 +36,7 @@
|
||||
#ifndef __TNNET_H
|
||||
#define __TNNET_H
|
||||
|
||||
int NetWriteString( char* pszString, size_t cbString);
|
||||
size_t telProcessNetwork ( char *buf, size_t len );
|
||||
size_t telProcessNetwork (char *buf, size_t len, unsigned char **respbuf, size_t *resplen);
|
||||
|
||||
#endif
|
||||
|
@ -362,6 +362,8 @@ fail:
|
||||
debug("ERROR. Cannot setup TOKEN_PRIVILEGES (err=%u, ntStat=%x).",
|
||||
GetLastError(), ntStat);
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
|
||||
|
5
mux.c
5
mux.c
@ -1846,7 +1846,10 @@ mux_client_request_session(int fd)
|
||||
}
|
||||
|
||||
term = getenv("TERM");
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
if (term != NULL && _stricmp(term, "passthru") == 0)
|
||||
term = "ansi";
|
||||
#endif
|
||||
buffer_init(&m);
|
||||
buffer_put_int(&m, MUX_C_NEW_SESSION);
|
||||
buffer_put_int(&m, muxclient_request_id);
|
||||
|
56
session.c
56
session.c
@ -97,6 +97,9 @@
|
||||
#include "kex.h"
|
||||
#include "monitor_wrap.h"
|
||||
#include "sftp.h"
|
||||
#ifdef WIN32_FIXME
|
||||
#include "console.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
|
||||
@ -581,7 +584,6 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
* Create three socket pairs for stdin, stdout and stderr
|
||||
*/
|
||||
pipe(pipein);
|
||||
|
||||
pipe(pipeout);
|
||||
pipe(pipeerr);
|
||||
|
||||
@ -590,8 +592,10 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
{
|
||||
prot_scr_width = s->col;
|
||||
prot_scr_height = s->row;
|
||||
extern HANDLE hConsole ;
|
||||
hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||
extern HANDLE hInputConsole;
|
||||
extern HANDLE hOutputConsole ;
|
||||
hInputConsole = GetConsoleInputHandle();
|
||||
hOutputConsole = GetConsoleOutputHandle();
|
||||
ConSetScreenSize( s->col, s->row );
|
||||
s->ptyfd = pipein[1]; // hConsole; // the pty is the Windows console output handle in our Win32 port
|
||||
}
|
||||
@ -616,24 +620,20 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
si.lpTitle = NULL; /* NULL means use exe name as title */
|
||||
si.dwX = 0;
|
||||
si.dwY = 0;
|
||||
si.dwXSize = prot_scr_width;
|
||||
si.dwYSize = prot_scr_height;
|
||||
si.dwXSize = 640;
|
||||
si.dwYSize = 480;
|
||||
si.dwXCountChars = prot_scr_width;
|
||||
si.dwYCountChars = prot_scr_height;
|
||||
si.dwFillAttribute = 0;
|
||||
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESIZE | STARTF_USECOUNTCHARS; // | STARTF_USESHOWWINDOW ;
|
||||
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESIZE | STARTF_USECOUNTCHARS;
|
||||
si.wShowWindow = 0; // FALSE ;
|
||||
si.cbReserved2 = 0;
|
||||
si.lpReserved2 = 0;
|
||||
|
||||
si.hStdInput = (HANDLE) sfd_to_handle(pipein[0]);
|
||||
si.hStdOutput = (HANDLE) sfd_to_handle(pipeout[1]);
|
||||
si.hStdError = (HANDLE) sfd_to_handle(pipeerr[1]);
|
||||
si.lpDesktop = NULL; //L"winsta0\\default";
|
||||
|
||||
//si.wShowWindow = SW_HIDE;
|
||||
//si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
||||
|
||||
si.hStdInput = (HANDLE) sfd_to_handle(pipein[0]);
|
||||
si.hStdOutput = (HANDLE) sfd_to_handle(pipeout[1]);
|
||||
si.hStdError = (HANDLE) sfd_to_handle(pipeerr[1]);
|
||||
si.lpDesktop = NULL;
|
||||
|
||||
SetEnvironmentVariable("USER", s->pw->pw_name);
|
||||
SetEnvironmentVariable("USERNAME", s->pw->pw_name);
|
||||
@ -694,7 +694,6 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
* token using CreateUserToken for non-password auth mechanisms.
|
||||
*/
|
||||
|
||||
|
||||
hToken = s -> authctxt -> methoddata;
|
||||
|
||||
|
||||
@ -759,7 +758,8 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
SetEnvironmentVariable("SSH_CONNECTION", buf);
|
||||
|
||||
if (original_command)
|
||||
SetEnvironmentVariable("SSH_ORIGINAL_COMMAND", original_command);
|
||||
SetEnvironmentVariable("SSH_ORIGINAL_COMMAND", original_command);
|
||||
|
||||
|
||||
// set better prompt for Windows cmd shell
|
||||
if (!s -> is_subsystem) {
|
||||
@ -779,22 +779,6 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
|
||||
GetUserName(name, &size);
|
||||
|
||||
//#ifndef WIN32_PRAGMA_REMCON
|
||||
// if ( (!s -> is_subsystem) && (s ->ttyfd != -1)) {
|
||||
// // Send to the remote client ANSI/VT Sequence so that they send us CRLF in place of LF
|
||||
// char *inittermseq = "\033[20h\033[?7h\0" ; // LFtoCRLF AUTOWRAPON
|
||||
// Channel *c=channel_by_id ( s->chanid );
|
||||
// buffer_append(&c->input, inittermseq, strlen(inittermseq));
|
||||
// channel_output_poll();
|
||||
// }
|
||||
//#endif
|
||||
|
||||
//if (s ->ttyfd != -1) {
|
||||
// set the channel to tty interactive type
|
||||
// Channel *c=channel_by_id ( s->chanid );
|
||||
// c->isatty = 1;
|
||||
//}
|
||||
|
||||
if ( (s->term) && (s->term[0]) )
|
||||
SetEnvironmentVariable("TERM", s->term);
|
||||
/*
|
||||
@ -898,7 +882,7 @@ do_exec_no_pty(Session *s, const char *command)
|
||||
if ( s->ttyfd == -1)
|
||||
session_set_fds(s, pipein[1], pipeout[0], pipeerr[0], s -> is_subsystem, 0);
|
||||
else
|
||||
session_set_fds(s, pipein[1], pipeout[0], pipeerr[0], s -> is_subsystem, 1); // tty interctive session
|
||||
session_set_fds(s, pipein[1], pipeout[0], pipeerr[0], s -> is_subsystem, 1); // tty interactive session
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2630,9 +2614,7 @@ session_pty_req(Session *s)
|
||||
pty_setowner(s->pw, s->tty);
|
||||
|
||||
/* Set window size from the packet. */
|
||||
#ifndef WIN32_FIXME
|
||||
pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);
|
||||
#endif
|
||||
|
||||
#ifndef WIN32_PRAGMA_REMCON
|
||||
packet_check_eom();
|
||||
@ -2874,7 +2856,7 @@ session_pty_cleanup2(Session *s)
|
||||
* Send exit signal to child 'cmd.exe' process.
|
||||
*/
|
||||
|
||||
if (s -> pid != NULL)
|
||||
if (s -> pid != 0)
|
||||
{
|
||||
|
||||
debug("Sending exit signal to child process [pid = %u]...", s -> pid);
|
||||
@ -2969,7 +2951,7 @@ session_close_single_x11(int id, void *arg)
|
||||
* Send exit signal to child 'cmd.exe' process.
|
||||
*/
|
||||
|
||||
if (s -> pid != NULL)
|
||||
if (s && s -> pid != 0)
|
||||
{
|
||||
debug("Sending exit signal to child process [pid = %u]...", s -> pid);
|
||||
|
||||
|
25
ssh.c
25
ssh.c
@ -115,10 +115,10 @@
|
||||
#endif
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
char dotsshdir[MAX_PATH];
|
||||
extern HANDLE hInputConsole;
|
||||
|
||||
#endif /* WIN32_FIXME */
|
||||
|
||||
@ -1462,8 +1462,9 @@ main(int ac, char **av)
|
||||
if (tty_flag) {
|
||||
//AllocConsole();
|
||||
ConInputInitParams(); // init the Console input side with global parameters
|
||||
HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
ConInit( STD_OUTPUT_HANDLE, TRUE ); //init the output console surface for us to write
|
||||
hInputConsole = GetStdHandle(STD_INPUT_HANDLE);
|
||||
ConInit(STD_OUTPUT_HANDLE, TRUE); //init the output console surface for us to write
|
||||
ConClearScreen();
|
||||
}
|
||||
else {
|
||||
//extern int glob_itissshclient;
|
||||
@ -1484,7 +1485,7 @@ main(int ac, char **av)
|
||||
#ifdef WIN32_FIXME
|
||||
|
||||
if (tty_flag)
|
||||
ConUnInitWithRestore(); // restore terminal to previous settings if it was a tty session
|
||||
ConUnInit(); // restore terminal to previous settings if it was a tty session
|
||||
#endif
|
||||
|
||||
/* Kill ProxyCommand if it is running. */
|
||||
@ -1772,6 +1773,10 @@ ssh_session(void)
|
||||
cp = getenv("TERM");
|
||||
if (!cp)
|
||||
cp = "";
|
||||
#ifdef WIN32_FIXME
|
||||
if (cp != NULL && _stricmp(cp, "passthru") == 0)
|
||||
cp = "ansi";
|
||||
#endif
|
||||
packet_put_cstring(cp);
|
||||
|
||||
/* Store window size in the packet. */
|
||||
@ -1945,8 +1950,18 @@ ssh_session2_setup(int id, int success, void *arg)
|
||||
packet_set_interactive(interactive,
|
||||
options.ip_qos_interactive, options.ip_qos_bulk);
|
||||
|
||||
client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
|
||||
#ifdef WIN32_FIXME
|
||||
char *term = getenv("TERM");
|
||||
|
||||
if (term != NULL && _stricmp(term, "passthru") == 0)
|
||||
term = "ansi";
|
||||
|
||||
client_session2_setup(id, tty_flag, subsystem_flag, term,
|
||||
NULL, fileno(stdin), &command, environ);
|
||||
#else
|
||||
client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
|
||||
NULL, fileno(stdin), &command, environ);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* open new channel for a session */
|
||||
|
10
sshpty.c
10
sshpty.c
@ -239,10 +239,14 @@ pty_change_window_size(int ptyfd, u_int row, u_int col,
|
||||
w.ws_ypixel = ypixel;
|
||||
(void) ioctl(ptyfd, TIOCSWINSZ, &w);
|
||||
#else
|
||||
extern HANDLE hConsole ;
|
||||
hConsole = ptyfd;
|
||||
extern HANDLE hOutputConsole ;
|
||||
if (ptyfd != 0) {
|
||||
hOutputConsole = (HANDLE)ptyfd;
|
||||
}
|
||||
#ifndef WIN32_PRAGMA_REMCON
|
||||
ConSetScreenSize( col, row );
|
||||
if (hOutputConsole != NULL) {
|
||||
ConSetScreenSize(col, row);
|
||||
}
|
||||
#else
|
||||
if (ptyfd > 0 )
|
||||
pty_change_window_size_oob(ptyfd, row, col, xpixel, ypixel);
|
||||
|
Loading…
x
Reference in New Issue
Block a user