diff -c -r putty-src/PUTTY.H putty-src2/PUTTY.H *** putty-src/PUTTY.H Mon Oct 7 18:44:26 2002 --- putty-src2/PUTTY.H Sat Apr 12 18:06:42 2003 *************** *** 234,239 **** --- 234,240 ---- typedef struct { /* Basic options */ + char session_name[512]; char host[512]; int port; enum { PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH } protocol; *************** *** 332,337 **** --- 333,340 ---- int blinktext; int win_name_always; int width, height; + int win_x, win_y; + int force_position; char font[64]; int fontisbold; int fontheight; diff -c -r putty-src/README putty-src2/README *** putty-src/README Fri Sep 20 19:57:06 2002 --- putty-src2/README Sat Apr 12 17:26:12 2003 *************** *** 47,49 **** --- 47,226 ---- ours. See the file LICENCE for the licence conditions. + + + ------------------------------------------- + Source Walkthrough + ------------------------------------------- + + The Putty code is written in modular-C with global state. + That means it's pretty easy to hook different parts together + and alter a component at a particular level. It also means + that it's hard to "reset" and "reinitialize" things because + there is lots of global state around which cannot be put back + to its initial condition. + + ** Applications + + PAGEANT.C : Putty Authentication Agent + WinMain entry point w/event loop + + WINDOW.C : Main Putty SSH + WinMain entry point w/event loop + main window handling/resize + color palette, fonts + WndProc event handling + + + PUTTYGEN.C : Putty Key Generation UI + WinMain entry point w/event loop + + PLINK.C : Console app for command line ssh + C "main" entry point + + PSFTP.C : Console app for secure ftp + C "main" entry point + + SCP.C : Console app for secure copy + C "main" entry point + + + ****** Shared Code ***************************** + + ** Console Handling + + LDISC.C : Line Discipline (key input) Handling + ldisc_send comes from window.c:WndProc + talks to putty.h:"GLOBAL Backend back" + + ** Global Header + + PUTTY.H : Global Header Defines: + "typedef struct Backend", network backend interface + "typedef struct Config", session config information + - all globally exported functions from all + other files. + + WINSTUFF.H : windows specific exports and global defines + + ** Network Backends + + "typedef struct Backend" defined in putty.h + + + SSH.C : SSH Backend + SSH.H + + RAW.C : RAW Backend + + TELNET.C : TELNET Backend + + RLOGIN.C : RLOGIN Backend + + BE_ALL.C : different linking modules to list necessary + BE_NOSSH.C backends for different builds + BE_NONE.C + + ** Network Sockets Abstraction + + NETWORK.H : header and structs for async i/o network abstraction + WINNET.C : talks to winsock and creates a network abstraction + PROXY.C : implements "proxy" network abstraction + PROXY.H + + ** SSL/Cryptography + + NOISE.C : noise generate/collect for random number generator + IMPORT.C : import/export key files in a few formats + + SSHAES.C : SSH algorithm implementations + SSHBLOWF.C + SSHBN.C + SSHCRC.C + SSHCRCDA.C + SSHDES.C + SSHDH.C + SSHDSS.C + SSHDSSG.C + SSHMD5.C + SSHPRIME.C + SSHPUBK.C + SSHRAND.C + SSHRSA.C + SSHRSAG.C + SSHSH512.C + SSHSHA.C + SSHZLIB.C + + + ** Other + + CMDLINE.C : Process and save command line paramaters + CONSOLE.C : various "console interactions" with the user + LOGGING.C : logging to event log + VERSION.C : version numbering + WINCTRLS.C : routines to manage controls in a dialog + WINDLG.C : dialog definitions (about, license, settings, etc) + WINUTILS.C : windows arg parsing and arg parse test code + WIN_RES.H : resource IDs + + INT64.C : handle 64 bit ints + INT64.H + + MISC.C : string handling, base64, buffer chains, + MISC.H "minefield" malloc replacement (mini-electric fence), + debug print + PUTTYMEM.H : headers for "minefield" malloc replacement + + TREE234.C : 2-3-4 tree routines + TREE234.H + + ***** Application Specific Code ******************* + + ** Putty Application Code + + PAGEANTC.C : pageant client (putty ssh to talk to pageant) + PRINTING.C : putty.exe printing + SETTINGS.C : read and write settings "Config" structure + STORAGE.H : storage abstraction used by settings + WINSTORE.C : implementation of storage.h functions on windows + + UNICODE.C : unicode conversion tables + WCWIDTH.C : wide character handling + + PORTFWD.C : putty.exe port forwarding + X11FWD.C : handling for X11 port forwarding + + TERMINAL.C : terminal emulation + + SIZETIP.C : Windows Tooltop implementation + + ** Secure FTP application + + SFTP.C : SFTP implementation + SFTP.H + WILDCARD.C : handle command line file wildcards + + ------------------------------------------- + Task Walkthrough + ------------------------------------------- + + 1) how does a putty.exe SSH connection start? + + window.c : WinMain + + - "Process the command line" + - calls do_config() to show main config dialog + - "Start up the telnet connection" + - calls "back->init(cfg.host, cfg.port, &realhost, cfg.tcl_nodelay) + + ssh.c : ssh_init (Backend->init) + + - initializes ssh state variables + - calls connect_to_host + + ssh.c : connect_to_host + + - creates the async i/o network callback table + - opens the necessary sockets + diff -c -r putty-src/SETTINGS.C putty-src2/SETTINGS.C *** putty-src/SETTINGS.C Thu Sep 26 19:37:34 2002 --- putty-src2/SETTINGS.C Sat Apr 12 18:36:50 2003 *************** *** 121,126 **** --- 121,130 ---- int i; char *p; void *sesskey; + + /* be sure to name this session before we save it */ + strncpy(cfg->session_name,section,sizeof(cfg->session_name)); + cfg->session_name[sizeof(cfg->session_name)-1] = 0; sesskey = open_settings_w(section); if (!sesskey) *************** *** 129,134 **** --- 133,139 ---- write_setting_i(sesskey, "Present", 1); if (do_host) { write_setting_s(sesskey, "HostName", cfg->host); + write_setting_s(sesskey, "SessionName", cfg->session_name); write_setting_s(sesskey, "LogFileName", cfg->logfilename); write_setting_i(sesskey, "LogType", cfg->logtype); write_setting_i(sesskey, "LogFileClash", cfg->logxfovr); *************** *** 240,245 **** --- 245,253 ---- write_setting_s(sesskey, "WinTitle", cfg->wintitle); write_setting_i(sesskey, "TermWidth", cfg->width); write_setting_i(sesskey, "TermHeight", cfg->height); + write_setting_i(sesskey, "WinX", cfg->win_x); + write_setting_i(sesskey, "WinY", cfg->win_y); + cfg->force_position = 0; write_setting_s(sesskey, "Font", cfg->font); write_setting_i(sesskey, "FontIsBold", cfg->fontisbold); write_setting_i(sesskey, "FontCharSet", cfg->fontcharset); *************** *** 327,334 **** --- 335,344 ---- if (do_host) { gpps(sesskey, "HostName", "", cfg->host, sizeof(cfg->host)); + gpps(sesskey, "SessionName", "", cfg->session_name, sizeof(cfg->session_name)); } else { cfg->host[0] = '\0'; /* blank hostname */ + cfg->session_name[0] = '\0'; /* blank session_name */ } gpps(sesskey, "LogFileName", "putty.log", cfg->logfilename, sizeof(cfg->logfilename)); *************** *** 462,467 **** --- 472,479 ---- gpps(sesskey, "WinTitle", "", cfg->wintitle, sizeof(cfg->wintitle)); gppi(sesskey, "TermWidth", 80, &cfg->width); gppi(sesskey, "TermHeight", 24, &cfg->height); + gppi(sesskey, "WinX", 0, &cfg->win_x); + gppi(sesskey, "WinY", 0, &cfg->win_y); gpps(sesskey, "Font", "Courier New", cfg->font, sizeof(cfg->font)); gppi(sesskey, "FontIsBold", 0, &cfg->fontisbold); gppi(sesskey, "FontCharSet", ANSI_CHARSET, &cfg->fontcharset); Only in putty-src: SSH.C diff -c -r putty-src/WINDOW.C putty-src2/WINDOW.C *** putty-src/WINDOW.C Fri Nov 8 08:19:48 2002 --- putty-src2/WINDOW.C Sat Apr 12 18:21:24 2003 *************** *** 58,63 **** --- 58,65 ---- #define IDM_SESSLGP 0x0250 /* log type printable */ #define IDM_SESSLGA 0x0260 /* log type all chars */ #define IDM_SESSLGE 0x0270 /* log end */ + #define IDM_RECONNECT 0x0280 + #define IDM_SAVESESS 0x0290 #define IDM_SAVED_MIN 0x1000 #define IDM_SAVED_MAX 0x2000 *************** *** 166,171 **** --- 168,174 ---- static UINT wm_mousewheel = WM_MOUSEWHEEL; + /* Dummy routine, only required in plink. */ void ldisc_update(int echo, int edit) { *************** *** 179,184 **** --- 182,188 ---- WNDCLASS wndclass; MSG msg; int guess_width, guess_height; + int force_position = FALSE; hinst = inst; flags = FLAG_VERBOSE | FLAG_INTERACTIVE; *************** *** 300,305 **** --- 304,310 ---- cfg = *cp; UnmapViewOfFile(cp); CloseHandle(filemap); + force_position = cfg.force_position; } else if (!do_config()) { WSACleanup(); return 0; *************** *** 508,513 **** --- 513,520 ---- { int winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL; int exwinmode = 0; + int x = CW_USEDEFAULT,y = CW_USEDEFAULT; + if (!cfg.scrollbar) winmode &= ~(WS_VSCROLL); if (cfg.resize_action == RESIZE_DISABLED) *************** *** 516,523 **** exwinmode |= WS_EX_TOPMOST; if (cfg.sunken_edge) exwinmode |= WS_EX_CLIENTEDGE; hwnd = CreateWindowEx(exwinmode, appname, appname, ! winmode, CW_USEDEFAULT, CW_USEDEFAULT, guess_width, guess_height, NULL, NULL, inst, NULL); } --- 523,536 ---- exwinmode |= WS_EX_TOPMOST; if (cfg.sunken_edge) exwinmode |= WS_EX_CLIENTEDGE; + + if (force_position == TRUE) { + x = cfg.win_x; + y = cfg.win_y; + } + hwnd = CreateWindowEx(exwinmode, appname, appname, ! winmode, x, y, guess_width, guess_height, NULL, NULL, inst, NULL); } *************** *** 577,586 **** SetScrollInfo(hwnd, SB_VERT, &si, FALSE); } /* ! * Start up the telnet connection. */ ! { char *error; char msg[1024], *title; char *realhost; --- 590,602 ---- SetScrollInfo(hwnd, SB_VERT, &si, FALSE); } + /* ! * Start up the currently configured connection. ! * (telnet, ssh, etc) */ ! ! { char *error; char msg[1024], *title; char *realhost; *************** *** 645,650 **** --- 661,668 ---- AppendMenu(m, MF_SEPARATOR, 0, 0); } AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log"); + AppendMenu(m, MF_ENABLED, IDM_RECONNECT, "&Reconnect"); + AppendMenu(m, MF_ENABLED, IDM_SAVESESS, "Save Current Session"); AppendMenu(m, MF_SEPARATOR, 0, 0); AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session..."); AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session"); *************** *** 839,844 **** --- 857,866 ---- send_raw_mouse = activate; SetCursor(LoadCursor(NULL, activate ? IDC_ARROW : IDC_IBEAM)); } + + void c_write_str(char *str) { + from_backend(1,str,strlen(str)); + } /* * Print a message box and close the connection. *************** *** 857,862 **** --- 879,885 ---- else { session_closed = TRUE; SetWindowText(hwnd, "PuTTY (inactive)"); + c_write_str("\r\n\r\n[ Fatal Error ]\r\n"); } } *************** *** 901,906 **** --- 924,930 ---- else { session_closed = TRUE; SetWindowText(hwnd, "PuTTY (inactive)"); + c_write_str("\r\n\r\n[ Disconnected ]\r\n"); MessageBox(hwnd, "Connection closed by remote host", "PuTTY", MB_OK | MB_ICONINFORMATION); } *************** *** 1617,1625 **** --- 1641,1657 ---- case IDM_SHOWLOG: showeventlog(hwnd); break; + case IDM_SAVESESS: + if (cfg.session_name[0] != 0) { + save_settings(cfg.session_name,1,&cfg); + } else { + save_settings(cfg.host,1,&cfg); + } + break; case IDM_NEWSESS: case IDM_DUPSESS: case IDM_SAVEDSESS: + case IDM_RECONNECT: { char b[2048]; char c[30], *cl; *************** *** 1627,1634 **** STARTUPINFO si; PROCESS_INFORMATION pi; HANDLE filemap = NULL; ! if (wParam == IDM_DUPSESS) { /* * Allocate a file-mapping memory chunk for the * config structure. --- 1659,1675 ---- STARTUPINFO si; PROCESS_INFORMATION pi; HANDLE filemap = NULL; + RECT wininfo; + + if (GetWindowRect(hwnd, &wininfo)) { + cfg.win_x = wininfo.left; + cfg.win_y = wininfo.top; + } + if (wParam == IDM_RECONNECT) { + cfg.force_position = 1; + } ! if (wParam == IDM_DUPSESS || wParam == IDM_RECONNECT) { /* * Allocate a file-mapping memory chunk for the * config structure. *************** *** 1669,1676 **** } } else break; ! } else cl = NULL; GetModuleFileName(NULL, b, sizeof(b) - 1); si.cb = sizeof(si); --- 1710,1718 ---- } } else break; ! } else { cl = NULL; + } GetModuleFileName(NULL, b, sizeof(b) - 1); si.cb = sizeof(si); *************** *** 1687,1692 **** --- 1729,1738 ---- CloseHandle(filemap); if (freecl) sfree(cl); + + if (wParam == IDM_RECONNECT) { + exit(0); + } } break; case IDM_RECONF: *************** *** 2424,2431 **** * messages. We _have_ to buffer everything * we're sent. */ ! ldisc_send(buf, len, 1); ! show_mouseptr(0); } } } --- 2470,2484 ---- * messages. We _have_ to buffer everything * we're sent. */ ! if (session_closed == TRUE) { ! // respawn a new session if the previous session was closed ! if (buf[0] == '\r') { ! SendMessage(hwnd, WM_SYSCOMMAND, IDM_RECONNECT, 0); ! } ! } else { ! ldisc_send(buf, len, 1); ! show_mouseptr(0); ! } } } } ***************