From 829b3f1f71013d71548d650e9cd9d276c7ee9637 Mon Sep 17 00:00:00 2001 From: cyd01 Date: Sun, 30 Jun 2019 23:10:18 +0200 Subject: [PATCH] Tagging the 0.71.0.5 release of the kitty project. --- 0.71_My_PuTTY/logging.c | 3 + 0.71_My_PuTTY/windows/version_minor.txt | 2 +- 0.71_My_PuTTY/windows/windlg.c | 6 +- 0.71_My_PuTTY/windows/window.c | 57 ++++++++++++++----- adb/adb.c | 6 +- cygterm/cygterm.c | 19 +++++-- kitty.c | 74 +++++++++++++------------ kitty.h | 6 ++ kitty_ssh.c | 7 +-- kitty_tools.c | 3 +- kitty_tools.h | 2 - kitty_win.c | 17 ++++-- kitty_win.h | 3 + 13 files changed, 133 insertions(+), 72 deletions(-) diff --git a/0.71_My_PuTTY/logging.c b/0.71_My_PuTTY/logging.c index 88e0d13..b763efe 100644 --- a/0.71_My_PuTTY/logging.c +++ b/0.71_My_PuTTY/logging.c @@ -32,6 +32,8 @@ int insert( char * ch, const char * c, const int ipos ) ; int del( char * ch, const int start, const int length ) ; int poss( const char * c, const char * ch ) ; int posi( const char * c, const char * ch, const int ipos ) ; +static int LogMode = 1 ; +int SwitchLogMode(void) { LogMode = abs( LogMode - 1 ) ; return LogMode ; } // Test l'existance du répertoire, sinon le créé void test_dir( Filename *filename ) { @@ -153,6 +155,7 @@ static void logwrite(LogContext *ctx, ptrlen data) * those three _after_ processing L_CLOSED. */ #ifdef PERSOPORT + if( !LogMode ) return ; if( timestamp_newfile ) { if (ctx->state == L_OPEN) { logfclose(ctx);} timestamp_newfile = 0 ; diff --git a/0.71_My_PuTTY/windows/version_minor.txt b/0.71_My_PuTTY/windows/version_minor.txt index b8626c4..7ed6ff8 100644 --- a/0.71_My_PuTTY/windows/version_minor.txt +++ b/0.71_My_PuTTY/windows/version_minor.txt @@ -1 +1 @@ -4 +5 diff --git a/0.71_My_PuTTY/windows/windlg.c b/0.71_My_PuTTY/windows/windlg.c index fbc5c8d..98a2147 100644 --- a/0.71_My_PuTTY/windows/windlg.c +++ b/0.71_My_PuTTY/windows/windlg.c @@ -1037,7 +1037,7 @@ bool do_config(void) #ifdef PERSOPORT GotoConfigDirectory() ; - if( ret==0 ) SaveRegistryKey( ) ; // On sort de la config box par ESCAPE ou cancel + if( ret==false ) SaveRegistryKey( ) ; // On sort de la config box par ESCAPE ou cancel else _beginthread( routine_SaveRegistryKey, 0, (void*)NULL ) ; // On démarre une session #endif return ret; @@ -1067,8 +1067,8 @@ bool do_reconfig(HWND hwnd, int protcfginfo) dp.shortcuts['g'] = true; /* the treeview: `Cate&gory' */ ret = SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, - GenericMainDlgProc); - + GenericMainDlgProc) ; + ctrl_free_box(ctrlbox); winctrl_cleanup(&ctrls_base); winctrl_cleanup(&ctrls_panel); diff --git a/0.71_My_PuTTY/windows/window.c b/0.71_My_PuTTY/windows/window.c index a10ab49..cfbeb26 100644 --- a/0.71_My_PuTTY/windows/window.c +++ b/0.71_My_PuTTY/windows/window.c @@ -650,6 +650,13 @@ stpcpy_max(char *dst, const char *src, size_t n) bool get_got_host(void) ; void set_got_host(bool val ) ; #endif +#ifdef RECONNECTPORT +void RestartSession( void ) { + win_seat_connection_fatal( win_seat, "User request session restart..." ) ; + PostMessage(hwnd,WM_KEYDOWN,VK_RETURN ,0) ; + PostMessage(hwnd,WM_KEYUP,VK_RETURN ,1) ; +} +#endif int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { @@ -1453,9 +1460,15 @@ TrayIcone.hWnd = hwnd ; AppendMenu(m, MF_SEPARATOR, 0, 0); #endif /* rutty */ AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log"); +#ifdef PERSOPORT + AppendMenu(m, MF_ENABLED, IDM_EXPORTSETTINGS, "Export ¤t settings" ) ; +#endif AppendMenu(m, MF_SEPARATOR, 0, 0); AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session..."); AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session"); +#ifdef RECONNECTPORT + AppendMenu(m, MF_ENABLED, IDM_RESTARTSESSION, "Close+Restart") ; +#endif AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT_PTR) savedsess_menu, "Sa&ved Sessions"); AppendMenu(m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings..."); @@ -1486,18 +1499,20 @@ TrayIcone.hWnd = hwnd ; AppendMenu(m, MF_ENABLED, IDM_PROTECT, "Prote&ct"); //char b[256];sprintf(b,"%d",GetWinrolFlag());MessageBox(NULL,b,"info",MB_OK); if( GetWinrolFlag() ) AppendMenu(m, MF_ENABLED, IDM_WINROL, "Roll-u&p"); - AppendMenu(m, MF_ENABLED, IDM_SCRIPTFILE, "Send scr&ipt file" ) ; - if( PSCPPath!=NULL ) AppendMenu(m, MF_ENABLED, IDM_PSCP, "Send wit&h pscp"); - else AppendMenu(m, MF_DISABLED|MF_GRAYED, IDM_PSCP, "Send wit&h pscp"); - if( WinSCPPath!=NULL ) AppendMenu(m, MF_ENABLED, IDM_WINSCP, "&Start WinSCP"); - else AppendMenu(m, MF_DISABLED|MF_GRAYED, IDM_WINSCP, "&Start WinSCP"); - HMENU FontMenu = CreateMenu(); AppendMenu(FontMenu, MF_ENABLED, IDM_FONTUP, "Font up"); AppendMenu(FontMenu, MF_ENABLED, IDM_FONTDOWN, "Font down"); AppendMenu(FontMenu, MF_ENABLED, IDM_FONTNEGATIVE, "Negative"); AppendMenu(FontMenu, MF_ENABLED, IDM_FONTBLACKANDWHITE, "Black and White"); AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) FontMenu, "Font settings"); + AppendMenu(m, MF_SEPARATOR, 0, 0); + + AppendMenu(m, MF_ENABLED, IDM_SCRIPTFILE, "Send scr&ipt file" ) ; + if( PSCPPath!=NULL ) AppendMenu(m, MF_ENABLED, IDM_PSCP, "Send wit&h pscp"); + else AppendMenu(m, MF_DISABLED|MF_GRAYED, IDM_PSCP, "Send wit&h pscp"); + if( WinSCPPath!=NULL ) AppendMenu(m, MF_ENABLED, IDM_WINSCP, "&Start WinSCP"); + else AppendMenu(m, MF_DISABLED|MF_GRAYED, IDM_WINSCP, "&Start WinSCP"); + AppendMenu(m, MF_ENABLED, IDM_SHOWPORTFWD, "Po&rt forwarding"); #ifdef PORTKNOCKINGPORT @@ -1505,8 +1520,6 @@ TrayIcone.hWnd = hwnd ; AppendMenu(m, MF_ENABLED, IDM_PORTKNOCK, "Port &knock"); } #endif - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_ENABLED, IDM_EXPORTSETTINGS, "Export ¤t settings" ) ; } #endif #ifdef ZMODEMPORT @@ -2965,6 +2978,10 @@ static void reset_window(int reinit) { } } +#ifdef PERSOPORT +void ResetWindow(int reinit) { reset_window( reinit ) ; } +#endif + static void set_input_locale(HKL kl) { char lbuf[20]; @@ -3667,9 +3684,7 @@ else if((UINT_PTR)wParam == TIMER_LOGROTATION) { // log rotation prev_conf = conf_copy(conf); #ifdef PERSOPORT - if( force_reconf++ ) -#endif - + if( force_reconf++ ) { reconfig_result = do_reconfig(hwnd, backend ? backend_cfg_info(backend) : 0); reconfiguring = false; @@ -3677,8 +3692,19 @@ else if((UINT_PTR)wParam == TIMER_LOGROTATION) { // log rotation conf_free(prev_conf); break; } -#ifdef PERSOPORT + } else { + reconfig_result = true ; + reconfiguring = false ; + } SaveRegistryKey() ; +#else + reconfig_result = + do_reconfig(hwnd, backend ? backend_cfg_info(backend) : 0); + reconfiguring = false; + if (!reconfig_result) { + conf_free(prev_conf); + break; + } #endif #if (defined IMAGEPORT) && (!defined FDJ) if( GetBackgroundImageFlag() && (!GetPuttyFlag()) ) { @@ -3949,7 +3975,7 @@ else if((UINT_PTR)wParam == TIMER_LOGROTATION) { // log rotation } } break; -#endif /* rutty */ +#endif /* rutty */ #ifdef PERSOPORT /*case IDM_USERCMD: ManageSpecialCommand( hwnd, wParam-IDM_USERCMD ) ; @@ -4086,6 +4112,11 @@ else if((UINT_PTR)wParam == TIMER_LOGROTATION) { // log rotation } break ; #endif +#ifdef RECONNECTPORT + case IDM_RESTARTSESSION: // Redemarre une session en cours + RestartSession() ; + break ; +#endif case IDM_HELP: launch_help(hwnd, NULL); diff --git a/adb/adb.c b/adb/adb.c index c2b701c..b9a2355 100644 --- a/adb/adb.c +++ b/adb/adb.c @@ -25,14 +25,17 @@ typedef enum { STATE_WAITING_FOR_ERROR_MESSAGE, } adb_state; +size_t win_seat_output_local(Seat *seat, bool is_stderr, const void *data, size_t len) ; + typedef struct adb_backend_data { //const struct plug_function_table *fn; /* the above field _must_ be first in the structure */ - Socket *s; int bufsize; + Socket *s; Seat *seat; LogContext *logctx; + adb_state state; //void *frontend; Conf *conf; @@ -42,7 +45,6 @@ typedef struct adb_backend_data { } Adb; static void adb_size(void *handle, int width, int height); -size_t win_seat_output_local(Seat *seat, bool is_stderr, const void *data, size_t len) ; static void c_write(Adb *adb, const char *buf, int len) { diff --git a/cygterm/cygterm.c b/cygterm/cygterm.c index a81cebf..6aac4c6 100644 --- a/cygterm/cygterm.c +++ b/cygterm/cygterm.c @@ -33,15 +33,17 @@ size_t win_seat_output_local(Seat *seat, bool is_stderr, const void *data, size_ typedef struct cygterm_backend_data { //const struct plug_function_table *fn; - //void *frontend; Socket *a; Socket *s; Seat *seat; LogContext *logctx; + //void *frontend; + PROCESS_INFORMATION pi; HANDLE ctl; Conf * conf; + Plug plug; Backend backend; int bufsize; @@ -55,11 +57,18 @@ static void cygterm_log(Plug *p, int type, SockAddr *addr, int port, const char /* Do nothing */ } - +/* +static void c_write(Local *local, const char *buf, int len) +{ + //int backlog = from_backend(local->frontend, 0, buf, len); + int backlog = win_seat_output_local(local->seat,false,buf,len); + sk_set_frozen(local->s, backlog > CYGTERM_MAX_BACKLOG); +} +*/ static int cygterm_closing(Plug *plug, const char *error_msg, int error_code, bool calling_back) { //Local local = (Local)plug; - Local *local = container_of(plug,Local,plug); + Local *local = container_of(plug, Local, plug) ; cygterm_debug("top"); if (local->s) { @@ -196,7 +205,7 @@ static const char * cygterm_init(Seat *seat, Backend **backend_handle, local->backend.vt = &cygterm_backend; local->a = NULL; local->s = NULL; - local->conf = conf; + local->conf = conf_copy(conf); local->editing = 0; local->echoing = 0; local->exitcode = 0; @@ -212,7 +221,7 @@ static const char * cygterm_init(Seat *seat, Backend **backend_handle, /* let sk use INADDR_LOOPBACK and let WinSock choose a port */ //local->a = sk_newlistener(0, 0, (Plug)local, 1, ADDRTYPE_IPV4); - local->a = sk_newlistener(0, 0, (Plug*)local, 1, ADDRTYPE_IPV4); // local-> ou seat ou local tout court + local->a = sk_newlistener(0, 0, (Plug*)&local->plug, 1, ADDRTYPE_IPV4); // local-> ou seat ou local tout court if ((err = sk_socket_error(local->a)) != NULL) goto fail_free; diff --git a/kitty.c b/kitty.c index 09c6c91..5e3c3ca 100644 --- a/kitty.c +++ b/kitty.c @@ -504,6 +504,7 @@ static struct TShortcuts { int viewer ; int visible ; int winscp ; + int switchlogmode ; int showportforward ; int resetterminal ; int duplicate ; @@ -660,20 +661,7 @@ return ; } char *dupvprintf(const char *fmt, va_list ap) ; -void logevent(LogContext *logctx, const char *event); -// Affichage d'un message dans l'event log -void debug_logevent( const char *fmt, ... ) { - va_list ap; - char *buf; - va_start(ap, fmt); - buf = dupvprintf(fmt, ap) ; - va_end(ap); - //MessageBox(NULL,buf,"logevent",MB_OK); - logevent(NULL,buf); - free(buf); - } - // Procedure de recuperation de la valeur d'un flag int get_param( const char * val ) { if( !stricmp( val, "PUTTY" ) ) return PuttyFlag ; @@ -1409,9 +1397,10 @@ void CreateDefaultIniFile( void ) { writeINI( KittyIniFile, "Print", "maxline", "60" ) ; writeINI( KittyIniFile, "Print", "maxchar", "85" ) ; + writeINI( KittyIniFile, "Shortcuts", "#switchlogmode", "{SHIFT}{F5}" ) ; + writeINI( KittyIniFile, "Shortcuts", "#showportforward", "{SHIFT}{F6}" ) ; writeINI( KittyIniFile, "Shortcuts", "print", "{SHIFT}{F7}" ) ; writeINI( KittyIniFile, "Shortcuts", "printall", "{F7}" ) ; - } if( !existfile( KittyIniFile ) ) { MessageBox( NULL, "Unable to create configuration file !", "Error", MB_OK|MB_ICONERROR ) ; } } @@ -1774,7 +1763,7 @@ void SendAutoCommand( HWND hwnd, const char * cmd ) { buf=(char*)malloc( strlen(cmd)+30 ) ; strcpy( buf, "Send automatic command" ) ; if( debug_flag ) { strcat( buf, ": ") ; strcat( buf, cmd ) ; } - if( conf_get_int(conf,CONF_protocol) != PROT_TELNET ) logevent(NULL, buf ) ; // On logue que si on est pas en telnet (à cause du password envoyé en clair) + if( conf_get_int(conf,CONF_protocol) != PROT_TELNET ) debug_logevent( buf ) ; // On logue que si on est pas en telnet (à cause du password envoyé en clair) free(buf); if( existfile( cmd ) ) RunScriptFile( hwnd, cmd ) ; else if( (toupper(cmd[0])=='C')&&(toupper(cmd[1])==':')&&(toupper(cmd[2])=='\\') ) { @@ -2246,7 +2235,7 @@ void RunExternPlink( HWND hwnd, const char * cmd ) { strcat( buffer, "\"" ) ; strcat( buffer, cmd ) ; strcat(buffer,"\"") ; chdir( InitialDirectory ) ; - if( debug_flag ) {debug_logevent( "Run: %s", buffer); } + if( debug_flag ) { debug_logevent( "Run: %s", buffer) ; } if( system( buffer ) ) MessageBox( NULL, buffer, "Execute problem", MB_OK|MB_ICONERROR ) ; } @@ -2350,7 +2339,7 @@ void GetOneFile( HWND hwnd, char * directory, const char * filename ) { chdir( InitialDirectory ) ; - if( debug_flag ) {debug_logevent( "Run: %s", buffer); } + if( debug_flag ) { debug_logevent( "Run: %s", buffer) ; } if( system( buffer ) ) MessageBox( NULL, buffer, "Transfer problem", MB_OK|MB_ICONERROR ) ; //debug_log("%s\n",buffer);//MessageBox( NULL, buffer, "Info",MB_OK ); } @@ -2457,7 +2446,7 @@ void GetFile( HWND hwnd ) { } if( strlen( buffer ) > 0 ) { chdir( InitialDirectory ) ; - if( debug_flag ) { debug_logevent("Run: %s", buffer); } + if( debug_flag ) { debug_logevent("Run: %s", buffer) ; } if( system( buffer ) ) MessageBox( NULL, buffer, "Transfer problem", MB_OK|MB_ICONERROR ) ; //if( !system( buffer ) ) unlink( "kitty.log" ) ; } @@ -2566,7 +2555,7 @@ int ManageLocalCmd( HWND hwnd, const char * cmd ) { return 1 ; } else if( (cmd[0]=='i')&&(cmd[1]=='n')&&(cmd[2]==':') ) { // __in: Affiche d'information dans le log - logevent(NULL,cmd+3); + debug_logevent(cmd+3) ; return 1 ; } else if( (cmd[0]=='w')&&(cmd[1]=='s')&&(cmd[2]==':') ) { // __ws: Lance WinSCP dans un repertoire donne @@ -4536,9 +4525,11 @@ int Convert1Reg( const char * filename ) { return 0 ; } +void ResetWindow(int reinit) ; #ifndef IDM_RECONF #define IDM_RECONF 0x0050 #endif + void NegativeColours(HWND hwnd) { int i ; #ifdef TUTTYPORT @@ -4550,10 +4541,12 @@ void NegativeColours(HWND hwnd) { conf_set_int_int(conf, CONF_colours, i*3+1, 256-conf_get_int_int(conf, CONF_colours, i*3+1)); conf_set_int_int(conf, CONF_colours, i*3+2, 256-conf_get_int_int(conf, CONF_colours, i*3+2)); } - force_reconf=0; - PostMessage(hwnd,WM_COMMAND,IDM_RECONF,0); - RefreshBackground(hwnd); + force_reconf = 0 ; + PostMessage( hwnd, WM_COMMAND, IDM_RECONF, 0 ) ; + + RefreshBackground( hwnd ) ; } + static int * BlackOnWhiteColoursSave = NULL ; void BlackOnWhiteColours(HWND hwnd) { if( BlackOnWhiteColoursSave==NULL ) { @@ -4579,13 +4572,16 @@ void BlackOnWhiteColours(HWND hwnd) { conf_set_int_int(conf, CONF_colours, 6, BlackOnWhiteColoursSave[3]) ; conf_set_int_int(conf, CONF_colours, 7, BlackOnWhiteColoursSave[4]) ; conf_set_int_int(conf, CONF_colours, 8, BlackOnWhiteColoursSave[5]) ; - free(BlackOnWhiteColoursSave); BlackOnWhiteColoursSave=NULL; + free(BlackOnWhiteColoursSave) ; + BlackOnWhiteColoursSave=NULL ; } } - force_reconf=0; - PostMessage(hwnd,WM_COMMAND,IDM_RECONF,0); - RefreshBackground(hwnd); + force_reconf = 0 ; + PostMessage( hwnd, WM_COMMAND, IDM_RECONF, 0 ) ; + + ResetWindow(2); } + static int original_fontsize = -1 ; void ChangeFontSize(HWND hwnd, int dec) { FontSpec *fontspec = conf_get_fontspec(conf, CONF_font); @@ -4597,17 +4593,15 @@ void ChangeFontSize(HWND hwnd, int dec) { } conf_set_fontspec(conf, CONF_font, fontspec); fontspec_free(fontspec); - force_reconf=0; - - //char b[256];sprintf(b,"%d %d",hwnd,fontspec->height);MessageBox(NULL,b,"ici",MB_OK); - - SendMessage( hwnd, WM_COMMAND, IDM_RECONF, 0 ) ; - RefreshBackground(hwnd); + force_reconf = 0 ; + PostMessage( hwnd, WM_COMMAND, IDM_RECONF, 0 ) ; + + ResetWindow(2); } void ChangeSettings(HWND hwnd) { //NegativeColours(hwnd); - //BlackOnWhiteColours(hwnd); - ChangeFontSize(hwnd,1); + BlackOnWhiteColours(hwnd); + //ChangeFontSize(hwnd,1); //ChangeFontSize(hwnd,-1); } @@ -4775,6 +4769,8 @@ void InitShortcuts( void ) { shortcuts_tab.editorclipboard = CONTROLKEY+SHIFTKEY+VK_F2 ; if( !readINI(KittyIniFile,"Shortcuts","winscp",buffer) || ( (shortcuts_tab.winscp=DefineShortcuts(buffer))<=0 ) ) shortcuts_tab.winscp = SHIFTKEY+VK_F3 ; + if( !readINI(KittyIniFile,"Shortcuts","switchlogmode",buffer) || ( (shortcuts_tab.switchlogmode=DefineShortcuts(buffer))<=0 ) ) + shortcuts_tab.switchlogmode = SHIFTKEY+VK_F5 ; if( !readINI(KittyIniFile,"Shortcuts","showportforward",buffer) || ( (shortcuts_tab.showportforward=DefineShortcuts(buffer))<=0 ) ) shortcuts_tab.showportforward = SHIFTKEY+VK_F6 ; if( !IsWow64() ) { @@ -4843,6 +4839,7 @@ void InitShortcuts( void ) { } } +int SwitchLogMode(void) ; int ManageShortcuts( HWND hwnd, const int* clips_system, int key_num, int shift_flag, int control_flag, int alt_flag, int altgr_flag, int win_flag ) { int key, i ; key = key_num ; @@ -4858,6 +4855,11 @@ int ManageShortcuts( HWND hwnd, const int* clips_system, int key_num, int shift_ { SendMessage( hwnd, WM_COMMAND, IDM_PROTECT, 0 ) ; InvalidateRect( hwnd, NULL, TRUE ) ; return 1 ; } if( key == shortcuts_tab.rollup ) // Fonction winroll { SendMessage( hwnd, WM_COMMAND, IDM_WINROL, 0 ) ; return 1 ; } + if( key == shortcuts_tab.switchlogmode ) { + i = SwitchLogMode() ; + if( i==1 ) { debug_logevent( "Enable logging" ) ; } else { debug_logevent( "Disable logging" ) ; } + return 1 ; + } if( key == shortcuts_tab.showportforward ) // Fonction show port forward { SendMessage( hwnd, WM_COMMAND, IDM_SHOWPORTFWD, 0 ) ; return 1 ; } @@ -4988,7 +4990,7 @@ void SetPasteCommand( void ) { PasteCommand = (char*) malloc( strlen(pst)+1 ) ; strcpy( PasteCommand, pst ) ; SetTimer(hwnd, TIMER_AUTOPASTE, autocommand_delay, NULL) ; - logevent(NULL,"Sent paste command"); + debug_logevent( "Sent paste command" ) ; GlobalUnlock( hglb ) ; } } @@ -5423,7 +5425,7 @@ void InitWinMain( void ) { i = 4095 ; GetComputerName( hostname, (void*)&i ) ; sprintf( buffer, "Starting %ld from %s@%s", GetCurrentProcessId(), username, hostname ) ; - logevent(NULL,buffer); + debug_logevent(buffer) ; } diff --git a/kitty.h b/kitty.h index 1a477ae..f76c11a 100644 --- a/kitty.h +++ b/kitty.h @@ -580,6 +580,12 @@ int getpid(void) ; #define IDM_CLEARLOGFILE 0x0610 #endif +#ifdef RECONNECTPORT +#ifndef IDM_RESTARTSESSION +#define IDM_RESTARTSESSION 0x0450 +#endif +#endif + // Doit etre le dernier #ifndef IDM_LAUNCHER #define IDM_LAUNCHER 0x1000 diff --git a/kitty_ssh.c b/kitty_ssh.c index 7497cbd..4c5b8ba 100644 --- a/kitty_ssh.c +++ b/kitty_ssh.c @@ -2,16 +2,13 @@ #include "kitty_tools.h" #ifdef PORTKNOCKINGPORT - -void logevent(void *frontend, const char *string); - void vprint(char *fmt, ...) { char buf[1024]; va_list args; va_start(args, fmt); vsprintf(buf,fmt, args); if( buf[strlen(buf)-1]=='\n' ) buf[strlen(buf)-1]='\0'; - logevent(NULL,buf); + printf(buf) ; va_end(args); } @@ -94,7 +91,7 @@ int ManagePortKnocking( char* host, char *portknockseqorig ) { if( !stricmp(protostr,"s") ) { Sleep( atof(portstr)*1000 ) ; } else { - if( knock(host,port,proto) ) logevent( NULL, "Unable to knock port" ) ; + if( knock(host,port,proto) ) fprintf(stderr, "Unable to knock port" ) ; Sleep( 40 ) ; } } diff --git a/kitty_tools.c b/kitty_tools.c index f362028..52e6d49 100644 --- a/kitty_tools.c +++ b/kitty_tools.c @@ -251,4 +251,5 @@ int MakeDir( const char * directory ) { } return existdirectory(fullpath) ; - } +} + diff --git a/kitty_tools.h b/kitty_tools.h index b5eaf58..e426266 100644 --- a/kitty_tools.h +++ b/kitty_tools.h @@ -60,6 +60,4 @@ int add_env( char * name, char * value ) ; // Creer un repertoire recurssif (rep1 / rep2 / ...) int MakeDir( const char * directory ) ; -// Affichage d'un message dans l'event log -void debug_logevent( const char *fmt, ... ) ; #endif diff --git a/kitty_win.c b/kitty_win.c index d591ba4..391df92 100644 --- a/kitty_win.c +++ b/kitty_win.c @@ -1,7 +1,5 @@ #include "kitty_win.h" -void logevent(void *frontend, const char *); - // Modifie la transparence void SetTransparency( HWND hwnd, int value ) { #ifndef NO_TRANSPARENCY @@ -402,7 +400,7 @@ void RunPuttyEd( HWND hwnd, char * filename ) { if( GetShortPathName( buffer, shortname, 1023 ) ) { strcat( shortname, " -ed" ); if( filename!=NULL ) if( strlen(filename)>0 ) { strcat( shortname, "b " ) ; strcat( shortname, filename ) ; } - logevent(NULL, shortname ) ; + debug_logevent( shortname ) ; RunCommand( hwnd, shortname ) ; } } @@ -418,4 +416,15 @@ void CheckVersionFromWebSite( HWND hwnd ) { } sprintf( buffer, "http://www.9bis.net/kitty/check_update.php?version=%s", vers ) ; ShellExecute(hwnd, "open", buffer, 0, 0, SW_SHOWDEFAULT); - } +} + +// Affichage d'un message dans l'event log +void debug_logevent( const char *fmt, ... ) { + va_list ap; + char *buf; + va_start(ap, fmt); + buf = dupvprintf(fmt, ap) ; + va_end(ap); + lp_eventlog(default_logpolicy,buf) ; + free(buf); +} diff --git a/kitty_win.h b/kitty_win.h index 98767ea..8145313 100644 --- a/kitty_win.h +++ b/kitty_win.h @@ -4,6 +4,7 @@ #include #include #include +#include "putty.h" void SetTransparency( HWND hwnd, int value ) ; void GetOSInfo( char * version ) ; @@ -33,4 +34,6 @@ void RunPuttyEd( HWND hwnd, char * filename ) ; // Verifie si une mise a jour est disponible sur le site web void CheckVersionFromWebSite( HWND hwnd ) ; +// Affichage d'un message dans l'event log +void debug_logevent( const char *fmt, ... ) ; #endif