diff --git a/0.74_My_PuTTY/version.h b/0.74_My_PuTTY/version.h index ea476aa..3355e34 100644 --- a/0.74_My_PuTTY/version.h +++ b/0.74_My_PuTTY/version.h @@ -1,5 +1,5 @@ #define RELEASE 0.74 #define TEXTVER "Release 0.74" #define SSHVER "-Release-0.74" -#define BINARY_VERSION 0,74,4,10 +#define BINARY_VERSION 0,74,4,11 #define SOURCE_COMMIT "unavailable" diff --git a/0.74_My_PuTTY/windows/version_minor.txt b/0.74_My_PuTTY/windows/version_minor.txt index f599e28..b4de394 100644 --- a/0.74_My_PuTTY/windows/version_minor.txt +++ b/0.74_My_PuTTY/windows/version_minor.txt @@ -1 +1 @@ -10 +11 diff --git a/0.74_My_PuTTY/windows/winpgnt.c b/0.74_My_PuTTY/windows/winpgnt.c index bbada0e..d5e03af 100644 --- a/0.74_My_PuTTY/windows/winpgnt.c +++ b/0.74_My_PuTTY/windows/winpgnt.c @@ -701,6 +701,73 @@ static BOOL AddTrayIcon(HWND hwnd) return res; } +#ifdef MOD_PERSO +#include +#include +#ifndef MOD_INTEGRATED_AGENT +// Teste l'existance d'un repertoire +int existdirectory( const char * filename ) { + struct _stat statBuf ; + + if( filename == NULL ) return 0 ; + if( strlen(filename)==0 ) return 0 ; + if( _stat( filename, &statBuf ) == -1 ) return 0 ; + + if( ( statBuf.st_mode & _S_IFMT ) == _S_IFDIR ) { return 1 ; } + else { return 0 ; } +} +#endif +int MakeSessionMenu( HMENU session_menu, const int start_menuitem, const char * directory ) { + int index_menu = start_menuitem ; + MENUITEMINFO mii; + char buffer[MAX_PATH],fList[MAX_PATH]; + DIR * dir ; + struct dirent * de ; + if( strlen(directory)>0 ) { + sprintf( buffer, ".\\Sessions\\%s", directory ) ; + } else { + sprintf( buffer, ".\\Sessions" ) ; + } + if( (dir=opendir(buffer)) != NULL ) { + while( (de=readdir(dir)) != NULL ) + if( strcmp(de->d_name, ".")&&strcmp(de->d_name, "..") ) { + unmungestr( de->d_name, fList, MAX_PATH ) ; + char *newpath; + newpath = (char*)malloc( strlen(buffer)+strlen(de->d_name)+2 ); + sprintf(newpath,"%s\\%s",buffer,de->d_name); + if( existdirectory(newpath) ) { + HMENU sub = CreateMenu(); + if( strlen(directory)>0 ) { + sprintf(newpath,"%s/%s",directory,de->d_name); + } else { + sprintf(newpath,"%s",de->d_name); + } + index_menu=MakeSessionMenu(sub,index_menu,newpath); + AppendMenu( session_menu, MF_POPUP, (UINT_PTR)sub, fList ) ; + index_menu++; + } else if( !strcmp(FileExtension,"") || !strcmp(FileExtension,fList+strlen(fList)-strlen(FileExtension)) ) { + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID; + mii.fType = MFT_STRING; + mii.fState = MFS_ENABLED; + mii.wID = (index_menu * 16) + IDM_SESSIONS_BASE; + if( strlen(directory)>0 ) { + sprintf(newpath,"%s/%s",directory,fList); + } else { + sprintf(newpath,"%s",fList); + } + mii.dwTypeData = newpath; + InsertMenuItem(session_menu, index_menu, true, &mii); + index_menu++; + } + free(newpath); + } + } + return index_menu ; +} +#endif + /* Update the saved-sessions menu. */ static void update_sessions(void) { @@ -717,36 +784,16 @@ static void update_sessions(void) #ifdef MOD_PERSO if( IniFileFlag==2 ) { - SetInitialSessPath(); + for(num_entries = GetMenuItemCount(session_menu); num_entries > initial_menuitems_count; num_entries--) RemoveMenu(session_menu, 0, MF_BYPOSITION); + + index_menu = 0; + index_menu = MakeSessionMenu( session_menu, index_menu, "" ) ; - index_key = 0; - index_menu = 0; - settings_e *handle; - sb = strbuf_new(); - if ((handle = enum_settings_start()) != NULL) { - while (enum_settings_next(handle, sb)) { - - if( !strcmp(FileExtension,"") || !strcmp(FileExtension,sb->s+strlen(sb->s)-strlen(FileExtension)) ) { - - memset(&mii, 0, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID; - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - mii.wID = (index_menu * 16) + IDM_SESSIONS_BASE; - mii.dwTypeData = sb->s; - InsertMenuItem(session_menu, index_menu, true, &mii); - index_menu++; - } - strbuf_clear(sb); - } - enum_settings_finish(handle); - } } else { #endif if(ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, PUTTY_REGKEY, &hkey)) @@ -1153,6 +1200,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, strcat(param, "&R"); strcat(param, "@"); strcat(param, mii.dwTypeData); +//MessageBox(NULL,param,"Launching",MB_OK) ; if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param, _T(""), SW_SHOW) <= 32) { MessageBox(NULL, "Unable to execute PuTTY!", "Error", @@ -1246,7 +1294,6 @@ int WINAPI Agent_WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show #ifdef MOD_PERSO IniFileFlag = 0 ; DirectoryBrowseFlag = 0 ; - loadPath() ; LoadParametersLight() ; #endif diff --git a/docs/version.txt b/docs/version.txt index b58d064..5286ba3 100644 --- a/docs/version.txt +++ b/docs/version.txt @@ -1 +1 @@ -0.74.4.10 \ No newline at end of file +0.74.4.11 \ No newline at end of file diff --git a/kitty.c b/kitty.c index 5bf8dc3..e0729a5 100644 --- a/kitty.c +++ b/kitty.c @@ -5076,7 +5076,8 @@ int ManageShortcuts( HWND hwnd, const int* clips_system, int key_num, int shift_ } if( key == (shortcuts_tab.editorclipboard ) ) { // Lancement d'un putty-ed qui charge le contenu du presse-papier if( debug_flag ) { debug_logevent( "Start internal editor fullfiled with clipboard" ) ; } - term_copyall(term,clips_system,lenof(clips_system)) ; RunPuttyEd( hwnd, "1" ) ; + //term_copyall(term,clips_system,lenof(clips_system)) /* Full term clipboard */ + RunPuttyEd( hwnd, "1" ) ; return 1 ; } else if( key == shortcuts_tab.winscp ) { // Lancement de WinSCP SendMessage( hwnd, WM_COMMAND, IDM_WINSCP, 0 ) ; return 1 ; diff --git a/kitty_launcher.c b/kitty_launcher.c index 4c03280..ca8b94c 100644 --- a/kitty_launcher.c +++ b/kitty_launcher.c @@ -151,10 +151,9 @@ HMENU InitLauncherMenu( char * Key ) { if( (IniFileFlag == SAVEMODE_REG)||(IniFileFlag == SAVEMODE_FILE) ) { sprintf( KeyName, "%s\\%s", TEXT(PUTTY_REG_POS), Key ) ; ReadSpecialMenu( menu, KeyName, &nbitem, 0 ) ; - } - else if( IniFileFlag == SAVEMODE_DIR ) { + } else if( IniFileFlag == SAVEMODE_DIR ) { ReadSpecialMenu( menu, Key, &nbitem, 0 ) ; - } + } if( GetMenuItemCount( menu ) > 0 ) AppendMenu( menu, MF_SEPARATOR, 0, 0 ) ; @@ -168,11 +167,10 @@ HMENU InitLauncherMenu( char * Key ) { //AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+5, "&Refresh list" ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+6, "&Window unique" ) ; CheckMenuItem( HideMenu, IDM_LAUNCHER+6, MF_BYCOMMAND | MF_UNCHECKED) ; - } - else { + } else { AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+6, "&Window unique" ) ; CheckMenuItem( HideMenu, IDM_LAUNCHER+6, MF_BYCOMMAND | MF_CHECKED) ; - } + } //AppendMenu( HideMenu, MF_ENABLED, IDM_GONEXT, "&Next" ) ; //AppendMenu( HideMenu, MF_ENABLED, IDM_GOPREVIOUS, "&Previous" ) ; if( RefreshWinList( MainHwnd ) > 0 ) { @@ -184,8 +182,8 @@ HMENU InitLauncherMenu( char * Key ) { CheckMenuItem( HideMenu, IDM_GOHIDE+i, MF_BYCOMMAND | MF_CHECKED) ; else CheckMenuItem( HideMenu, IDM_GOHIDE+i, MF_BYCOMMAND | MF_UNCHECKED) ; - } } + } AppendMenu( HideMenu, MF_SEPARATOR, 0, 0 ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_ABOUT, "&About" ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_QUIT, "&Quit" ) ; @@ -202,13 +200,13 @@ HMENU InitLauncherMenu( char * Key ) { AppendMenu( menu, MF_ENABLED, IDM_QUIT, "&Quit" ) ; return menu ; - } +} void RefreshMenuLauncher( void ) { DestroyMenu( MenuLauncher ) ; MenuLauncher = NULL ; MenuLauncher = InitLauncherMenu( "Launcher" ) ; - } +} // Nettoie les noms de folder en remplaçant les "/" par des "\" et les " \ " par des " \" // Deplace dans kitty_commun.c @@ -379,7 +377,7 @@ void DisplayContextMenu( HWND hwnd, HMENU menu ) { SetForegroundWindow( hwnd ) ; GetCursorPos (&pt); TrackPopupMenu (hMenuPopup, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, NULL); - } +} // Gestion Hide/UnHide all static int CurrentVisibleWin = -1 ; /* -1 = toutes visibles */ @@ -396,16 +394,16 @@ BOOL CALLBACK RefreshWinListProc( HWND hwnd, LPARAM lParam ) { TabWin[NbWin].hwnd=hwnd ; GetWindowText( hwnd, TabWin[NbWin].name, 127 ) ; NbWin++ ; - } + } return TRUE ; - } +} int RefreshWinList( HWND hwnd ) { NbWin=0 ; EnumWindows( RefreshWinListProc, 0 ) ; return NbWin ; - } +} void GoNext( HWND hwnd ) { int i ; @@ -416,15 +414,14 @@ void GoNext( HWND hwnd ) { if( i == (NbWin-1) ) { ManageUnHideOne( TabWin[0].hwnd ) ; SetFocus( TabWin[0].hwnd ) ; - } - else { + } else { ManageUnHideOne( TabWin[i+1].hwnd ) ; SetFocus( TabWin[i+1].hwnd ) ; - } - break ; } + break ; } } +} void GoPrevious( HWND hwnd ) { int i ; @@ -435,33 +432,32 @@ void GoPrevious( HWND hwnd ) { if( i == 0 ) { ManageUnHideOne( TabWin[NbWin-1].hwnd ) ; SetFocus( TabWin[NbWin-1].hwnd ) ; - } - else { + } else { ManageUnHideOne( TabWin[i-1].hwnd ) ; SetFocus( TabWin[i-1].hwnd ) ; - } - break ; } + break ; } } +} void ManageHideAll( HWND hwnd ) { int i ; if( RefreshWinList( hwnd ) > 0 ) { for( i=0 ; i 0 ) { for( i=0 ; i=NbWin ) CurrentVisibleWin=0 ; ManageUnHideOne( TabWin[CurrentVisibleWin].hwnd ) ; - } +} void ManageGoPrevious( HWND hwnd ) { if( CurrentVisibleWin == -1 ) return ; @@ -477,7 +473,7 @@ void ManageGoPrevious( HWND hwnd ) { CurrentVisibleWin-- ; if( CurrentVisibleWin<0 ) CurrentVisibleWin=NbWin-1 ; ManageUnHideOne( TabWin[CurrentVisibleWin].hwnd ) ; - } +} void ManageGo( const int n ) { if( CurrentVisibleWin == -1 ) return ; @@ -485,13 +481,13 @@ void ManageGo( const int n ) { ManageHideOne( TabWin[CurrentVisibleWin].hwnd ) ; CurrentVisibleWin = n ; ManageUnHideOne( TabWin[CurrentVisibleWin].hwnd ) ; - } +} void ManageSwitch( const int n ) { SendMessage( TabWin[n].hwnd, WM_COMMAND, IDM_SWITCH_HIDE, 0 ) ; SetForegroundWindow( TabWin[n].hwnd ) ; SetFocus( TabWin[n].hwnd ) ; - } +} // Procedures principales du launcher LRESULT CALLBACK Launcher_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -533,8 +529,8 @@ LRESULT CALLBACK Launcher_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP if (IsWindowVisible(hwnd)) ShowWindow(hwnd, SW_HIDE); //SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); return 1 ; - } - else return 0 ; + } else + return 0 ; break ; case KLWM_NOTIFYICON : @@ -660,9 +656,9 @@ LRESULT CALLBACK Launcher_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP Shell_NotifyIcon(NIM_MODIFY, &TrayIcone); } return DefWindowProc(hwnd, uMsg, wParam, lParam); - } - return -1 ; } + return -1 ; +} int WINAPI Launcher_WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { hinst = inst ; @@ -681,8 +677,9 @@ int WINAPI Launcher_WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int s if( FindWindow(className,className) ) { if( ReadParameter( "Launcher", "alreadyRunCheck", buffer ) ) { if( !stricmp( buffer, "yes" ) ) return 0 ; + } else { + return 0 ; } - else { return 0 ; } } if( strstr( cmdline, "-putty" ) != NULL ) PuttyFlag=1 ; @@ -704,7 +701,7 @@ int WINAPI Launcher_WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int s if( ReadParameter( "Launcher", "reload", buffer ) ) { if( !stricmp( buffer, "NO" ) ) LauncherConfReload = 0 ; - } + } if( LauncherConfReload ) InitLauncherRegistry() ; hwnd = CreateWindowEx(0, className, "KiTTYLauncher", @@ -720,86 +717,85 @@ int WINAPI Launcher_WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int s TranslateMessage(&msg); DispatchMessage(&msg); // } - } - return msg.wParam; } + return msg.wParam; +} #endif void RunConfig( Conf * conf ) { + char b[2048]; + //char c[180]; + //int freecl = FALSE; + char *cl; + const char *argprefix; + BOOL inherit_handles; + STARTUPINFO si; + PROCESS_INFORMATION pi; + HANDLE filemap = NULL; - char b[2048]; - //char c[180]; - //int freecl = FALSE; - char *cl; - const char *argprefix; - BOOL inherit_handles; - STARTUPINFO si; - PROCESS_INFORMATION pi; - HANDLE filemap = NULL; + char bufpass[1024] ; + strcpy( bufpass, conf_get_str(conf,CONF_password)) ; + MASKPASS(GetCryptSaltFlag(),bufpass) ; + conf_set_str(conf,CONF_password,bufpass) ; - char bufpass[1024] ; - strcpy( bufpass, conf_get_str(conf,CONF_password)) ; - MASKPASS(GetCryptSaltFlag(),bufpass) ; - conf_set_str(conf,CONF_password,bufpass) ; - - if (restricted_acl) { - argprefix = "&R"; - } else { - argprefix = ""; - } - /* - * Allocate a file-mapping memory chunk for the - * config structure. - */ - SECURITY_ATTRIBUTES sa; - strbuf *serbuf; - void *p; - int size; - - serbuf = strbuf_new(); - conf_serialise(BinarySink_UPCAST(serbuf), conf); - size = serbuf->len; - - sa.nLength = sizeof(sa); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - filemap = CreateFileMapping(INVALID_HANDLE_VALUE, - &sa, - PAGE_READWRITE, - 0, size, NULL); - if (filemap && filemap != INVALID_HANDLE_VALUE) { - p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size); - if (p) { - memcpy(p, serbuf->s, size); - UnmapViewOfFile(p); - } - } - strbuf_free(serbuf); - inherit_handles = true; - cl = dupprintf("putty %s&%p:%u", argprefix, - filemap, (unsigned)size); - - MASKPASS(GetCryptSaltFlag(),bufpass); - conf_set_str(conf,CONF_password,bufpass); - memset(bufpass,0,strlen(bufpass)); - - GetModuleFileName(NULL, b, sizeof(b) - 1); - si.cb = sizeof(si); - si.lpReserved = NULL; - si.lpDesktop = NULL; - si.lpTitle = NULL; - si.dwFlags = 0; - si.cbReserved2 = 0; - si.lpReserved2 = NULL; - CreateProcess(b, cl, NULL, NULL, inherit_handles, - NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - - if (filemap) - CloseHandle(filemap); - sfree(cl); + if (restricted_acl) { + argprefix = "&R"; + } else { + argprefix = ""; } + /* + * Allocate a file-mapping memory chunk for the + * config structure. + */ + SECURITY_ATTRIBUTES sa; + strbuf *serbuf; + void *p; + int size; + + serbuf = strbuf_new(); + conf_serialise(BinarySink_UPCAST(serbuf), conf); + size = serbuf->len; + + sa.nLength = sizeof(sa); + sa.lpSecurityDescriptor = NULL; + sa.bInheritHandle = TRUE; + filemap = CreateFileMapping(INVALID_HANDLE_VALUE, + &sa, + PAGE_READWRITE, + 0, size, NULL); + if (filemap && filemap != INVALID_HANDLE_VALUE) { + p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size); + if (p) { + memcpy(p, serbuf->s, size); + UnmapViewOfFile(p); + } + } + strbuf_free(serbuf); + inherit_handles = true; + cl = dupprintf("putty %s&%p:%u", argprefix, + filemap, (unsigned)size); + + MASKPASS(GetCryptSaltFlag(),bufpass); + conf_set_str(conf,CONF_password,bufpass); + memset(bufpass,0,strlen(bufpass)); + + GetModuleFileName(NULL, b, sizeof(b) - 1); + si.cb = sizeof(si); + si.lpReserved = NULL; + si.lpDesktop = NULL; + si.lpTitle = NULL; + si.dwFlags = 0; + si.cbReserved2 = 0; + si.lpReserved2 = NULL; + CreateProcess(b, cl, NULL, NULL, inherit_handles, + NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + if (filemap) + CloseHandle(filemap); + sfree(cl); +} void RunPuTTY( HWND hwnd, char * param ) { char buffer[4096]="",shortname[1024]="" ; ; @@ -810,8 +806,8 @@ void RunPuTTY( HWND hwnd, char * param ) { else strcpy( buffer, shortname ) ; RunCommand( hwnd, buffer ) ; - } - } + } +} int RunSession( HWND hwnd, const char * folder_in, char * session_in ) { char buffer[4096]="", shortname[1024]="" ; @@ -836,37 +832,34 @@ int RunSession( HWND hwnd, const char * folder_in, char * session_in ) { while( (session[strlen(session)-1]==' ')||(session[strlen(session)-1]=='\t') ) session[strlen(session)-1]='\0' ; if( PuttyFlag ) sprintf( buffer, "%s -putty -load \"%s\" -send-to-tray", shortname, session ) ; else sprintf( buffer, "%s -load \"%s\" -send-to-tray", shortname, session ) ; - } - else { + } else { if( PuttyFlag ) sprintf( buffer, "%s -putty -load \"%s\"", shortname, session ) ; else sprintf( buffer, "%s -load \"%s\"", shortname, session ) ; - } + } RunCommand( hwnd, buffer ) ; return_code = 1 ; - } - else { RunCommand( hwnd, session_in ) ; } + } else { + RunCommand( hwnd, session_in ) ; } - else if( IniFileFlag==SAVEMODE_DIR ) { + } else if( IniFileFlag==SAVEMODE_DIR ) { if( DirectoryBrowseFlag ) { if( (folder_in!=NULL)&&strcmp(folder_in,"")&&strcmp(folder_in,"Default") ) { strcat( shortname, " -folder \"" ) ; strcat( shortname, folder_in ) ; strcat( shortname, "\"" ) ; - } } - + } strcpy( session, session_in ) ; if( session[strlen(session)-1] == '&' ) { session[strlen(session)-1]='\0' ; while( (session[strlen(session)-1]==' ')||(session[strlen(session)-1]=='\t') ) session[strlen(session)-1]='\0' ; if( PuttyFlag ) sprintf( buffer, "%s -putty -load \"%s\" -send-to-tray", shortname, session ) ; else sprintf( buffer, "%s -load \"%s\" -send-to-tray", shortname, session ) ; - } - else { + } else { if( PuttyFlag ) sprintf( buffer, "%s -putty -load \"%s\"", shortname, session ) ; else sprintf( buffer, "%s -load \"%s\"", shortname, session ) ; //else sprintf( buffer, "%s @%s", shortname, session ) ; - } + } /* if( DirectoryBrowseFlag ) { if( strcmp(folder_in,"")&&strcmp(folder_in,"Default") ) { strcat( buffer, " -folder \"" ) ; @@ -877,8 +870,8 @@ int RunSession( HWND hwnd, const char * folder_in, char * session_in ) { //MessageBox( hwnd, buffer, "Info", MB_OK ) ; RunCommand( hwnd, buffer ) ; return_code = 1 ; - } + } free( session ) ; return return_code ; - } +} diff --git a/kitty_tools.c b/kitty_tools.c index 1c4235e..5f15f99 100644 --- a/kitty_tools.c +++ b/kitty_tools.c @@ -83,7 +83,7 @@ int existfile( const char * filename ) { if( ( statBuf.st_mode & _S_IFMT ) == _S_IFREG ) { return 1 ; } else { return 0 ; } } - + // Teste l'existance d'un repertoire int existdirectory( const char * filename ) { struct _stat statBuf ;