Skip to content

Commit

Permalink
Change disconnect message format
Browse files Browse the repository at this point in the history
  • Loading branch information
yongchaofan authored Jun 23, 2020
1 parent e8e6c95 commit 0f531a8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
4 changes: 1 addition & 3 deletions host.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// "$Id: host.c 31773 2020-06-06 15:05:10 $"
// "$Id: host.c 31682 2020-06-18 15:05:10 $"
//
// tinyTerm -- A minimal serail/telnet/ssh/sftp terminal emulator
//
Expand Down Expand Up @@ -289,7 +289,6 @@ DWORD WINAPI serial(void *pv)
CloseHandle( ph->hExitEvent );
CloseHandle( ph->hSerial );
ph->host_type = 0;
term_Disp( ph->term, "disconnected\r\n" );

comm_close:
ph->host_status=IDLE;
Expand Down Expand Up @@ -357,7 +356,6 @@ DWORD WINAPI telnet( void *pv )

ph->host_type = 0;
closesocket(ph->sock);
term_Disp( ph->term, "disconnected\r\n" );
}

ph->sock = 0;
Expand Down
15 changes: 9 additions & 6 deletions ssh2.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// "$Id: ssh2.c 40296 2020-06-06 15:05:10 $"
// "$Id: ssh2.c 40300 2020-06-18 15:05:10 $"
//
// tinyTerm -- A minimal serail/telnet/ssh/sftp terminal emulator
//
Expand Down Expand Up @@ -356,7 +356,7 @@ int ssh_authentication( HOST *ph )
{
char user[256], pw[256];
if ( ph->username==NULL ) {
char *p = ssh2_Gets( ph, "\r\nusername:", TRUE);
char *p = ssh2_Gets( ph, "\r\nusername: ", TRUE);
if ( p==NULL ) return -5;
strcpy(user, p);
ph->username = user;
Expand All @@ -383,7 +383,7 @@ int ssh_authentication( HOST *ph )
if ( strstr(authlist, "password")!=NULL ) {
for ( int rep=0; rep<3; rep++ ) {
if ( ph->password==NULL ) {
char *p = ssh2_Gets( ph, "password:", FALSE );
char *p = ssh2_Gets( ph, "password: ", FALSE );
if ( p==NULL ) return -5;
strcpy(pw, p);
ph->password = pw;
Expand Down Expand Up @@ -438,9 +438,13 @@ DWORD WINAPI ssh( void *pv )
term_Disp( ph->term, "\033[31msession failure!\r\n");
goto Session_Close;
}

const char *banner = libssh2_session_banner_get(ph->session);
if ( banner!=NULL ) term_Disp( ph->term, banner);

if ( banner!=NULL ) {
term_Disp( ph->term, banner);
term_Disp( ph->term, "\r\n");
}

ph->host_status=AUTHENTICATING;
if ( ssh_knownhost( ph )<0 ) {
term_Disp( ph->term, "\033[31mverification failure!\r\n" );
Expand Down Expand Up @@ -504,7 +508,6 @@ DWORD WINAPI ssh( void *pv )
}
tun_closeall( ph );
ph->host_type = 0;
term_Disp( ph->term, "disconnected\r\n");

Channel_Close:
if ( ph->channel!=NULL ) {
Expand Down
24 changes: 13 additions & 11 deletions tiny.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// "$Id: tiny.c 38235 2020-06-17 19:35:10 $"
// "$Id: tiny.c 38328 2020-06-18 19:35:10 $"
//
// tinyTerm -- A minimal serail/telnet/ssh/sftp terminal emulator
//
Expand Down Expand Up @@ -33,8 +33,8 @@ int dpi = 96;
int titleHeight;
int fontSize = 16;
WCHAR fontFace[32] = L"Consolas";
WCHAR wndTitle[256] = L" Term Script Options ";
const char TINYTERM[]="\n\033[32mtinyTerm > \033[37m";
WCHAR wndTitle[256] = L" Term Script Options ";
const char TINYTERM[]="\n\033[32mtinyTerm> \033[37m";
const char DICTFILE[]="tinyTerm.hist";
const char WELCOME[]="\r\n\
\ttinyTerm is a simple, small and scriptable terminal emulator,\r\n\n\
Expand Down Expand Up @@ -274,9 +274,12 @@ void cmd_Enter(WCHAR *wcmd)
term_Send( pt, cmd, cnt );
}
else {
term_Print(pt, "\033[33m%s\n", cmd);
host_Open(ph, cmd);
}
if ( *cmd ) {
term_Print(pt, "\033[33m%s\n", cmd);
host_Open(ph, cmd);
}
else
host_Open(ph, NULL); }
}
}
WNDPROC wpOrigCmdProc;
Expand Down Expand Up @@ -339,10 +342,9 @@ void tiny_Title( char *buf )
SetWindowText(hwndTerm, wndTitle);
if ( host_Status(ph)==IDLE )
{
if ( bLocalEdit )
term_Disp(pt, TINYTERM);
else
term_Print(pt, "\r\n\033[33mPress Enter to reconnect\r\n");
term_Print(pt, "\r\n\033[31mDisconnected! \
\033[37mPress \033[33mEnter\033[37m to reconnect\r\n");
if ( bLocalEdit ) term_Disp(pt, TINYTERM);
menu_Enable( ID_CONNECT, TRUE);
menu_Enable( ID_DISCONN, FALSE);
menu_Check( ID_ECHO, term.bEcho);
Expand Down Expand Up @@ -873,7 +875,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
//moves the composition window to cursor pos on Win10
break;
case WM_CHAR:
if ( host_Status( ph )==IDLE ) {//press Enter to restart
if ( host_Status( ph )==IDLE ) {//press Enter to reconnect
if ( (wParam&0xff)==0x0d ) host_Open(ph, NULL);
}
else {
Expand Down

0 comments on commit 0f531a8

Please sign in to comment.