#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
+#ifndef AUTO_WINSOCK
+#ifdef WINSOCK_TWO
+#include <winsock2.h>
+#else
#include <winsock.h>
+#endif
+#endif
#include <stdio.h>
#include <stdlib.h>
}
wpps (sesskey, "UserName", cfg.username);
wppi (sesskey, "NoPTY", cfg.nopty);
+ wppi (sesskey, "AgentFwd", cfg.agentfwd);
wpps (sesskey, "RemoteCmd", cfg.remote_cmd);
wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" :
cfg.cipher == CIPHER_DES ? "des" : "3des");
}
gpps (sesskey, "UserName", "", cfg.username, sizeof(cfg.username));
gppi (sesskey, "NoPTY", 0, &cfg.nopty);
+ gppi (sesskey, "AgentFwd", 0, &cfg.agentfwd);
gpps (sesskey, "RemoteCmd", "", cfg.remote_cmd, sizeof(cfg.remote_cmd));
{
char cipher[10];
logbox = NULL;
DestroyWindow (hwnd);
return 0;
+ case IDN_COPY:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ int selcount;
+ int *selitems;
+ selcount = SendDlgItemMessage(hwnd, IDN_LIST,
+ LB_GETSELCOUNT, 0, 0);
+ selitems = malloc(selcount * sizeof(int));
+ if (selitems) {
+ int count = SendDlgItemMessage(hwnd, IDN_LIST,
+ LB_GETSELITEMS,
+ selcount, (LPARAM)selitems);
+ int i;
+ int size;
+ char *clipdata;
+ static unsigned char sel_nl[] = SEL_NL;
+
+ size = 0;
+ for (i = 0; i < count; i++)
+ size += strlen(events[selitems[i]]) + sizeof(sel_nl);
+
+ clipdata = malloc(size);
+ if (clipdata) {
+ char *p = clipdata;
+ for (i = 0; i < count; i++) {
+ char *q = events[selitems[i]];
+ int qlen = strlen(q);
+ memcpy(p, q, qlen);
+ p += qlen;
+ memcpy(p, sel_nl, sizeof(sel_nl));
+ p += sizeof(sel_nl);
+ }
+ write_clip(clipdata, size);
+ term_deselect();
+ free(clipdata);
+ }
+ free(selitems);
+ }
+ }
+ return 0;
}
return 0;
case WM_CLOSE:
DialogBox (hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
NULL, LicenceProc);
EnableWindow(hwnd, 1);
+ SetActiveWindow(hwnd);
return 0;
}
return 0;
return 0;
}
+static char savedsession[2048];
+
static int CALLBACK ConnectionProc (HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
int i;
switch (msg) {
case WM_INITDIALOG:
SetDlgItemText (hwnd, IDC0_HOST, cfg.host);
+ SetDlgItemText (hwnd, IDC0_SESSEDIT, savedsession);
SetDlgItemInt (hwnd, IDC0_PORT, cfg.port, FALSE);
for (i = 0; i < nsessions; i++)
SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_ADDSTRING,
cfg.warn_on_close = IsDlgButtonChecked (hwnd, IDC0_CLOSEWARN);
break;
case IDC0_SESSEDIT:
- if (HIWORD(wParam) == EN_CHANGE)
+ if (HIWORD(wParam) == EN_CHANGE) {
SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_SETCURSEL,
(WPARAM) -1, 0);
+ GetDlgItemText (hwnd, IDC0_SESSEDIT,
+ savedsession, sizeof(savedsession)-1);
+ savedsession[sizeof(savedsession)-1] = '\0';
+ }
break;
case IDC0_SESSSAVE:
if (HIWORD(wParam) == BN_CLICKED ||
SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty);
+ CheckDlgButton (hwnd, IDC3_AGENTFWD, cfg.agentfwd);
CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERDES,
cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF :
cfg.cipher == CIPHER_DES ? IDC3_CIPHERDES :
HIWORD(wParam) == BN_DOUBLECLICKED)
cfg.nopty = IsDlgButtonChecked (hwnd, IDC3_NOPTY);
break;
+ case IDC3_AGENTFWD:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED)
+ cfg.agentfwd = IsDlgButtonChecked (hwnd, IDC3_AGENTFWD);
+ break;
case IDC3_CIPHER3DES:
case IDC3_CIPHERBLOWF:
case IDC3_CIPHERDES:
DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
GetParent(hwnd), AboutProc);
EnableWindow(hwnd, 1);
+ SetActiveWindow(hwnd);
}
return GenericMainDlgProc (hwnd, msg, wParam, lParam,
MAIN_NPANELS, mainp, &page);
int ret;
get_sesslist(TRUE);
+ savedsession[0] = '\0';
ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
get_sesslist(FALSE);
events[nevents] = smalloc(1+strlen(string));
strcpy (events[nevents], string);
nevents++;
- if (logbox)
+ if (logbox) {
+ int count;
SendDlgItemMessage (logbox, IDN_LIST, LB_ADDSTRING,
0, (LPARAM)string);
+ count = SendDlgItemMessage (logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
+ SendDlgItemMessage (logbox, IDN_LIST, LB_SETTOPINDEX, count-1, 0);
+ }
}
void showeventlog (HWND hwnd) {
RegCloseKey(rkey);
}
}
+
+/*
+ * Recursively delete a registry key and everything under it.
+ */
+static void registry_recursive_remove(HKEY key) {
+ DWORD i;
+ char name[MAX_PATH+1];
+ HKEY subkey;
+
+ i = 0;
+ while (RegEnumKey(key, i, name, sizeof(name)) == ERROR_SUCCESS) {
+ if (RegOpenKey(key, name, &subkey) == ERROR_SUCCESS) {
+ registry_recursive_remove(subkey);
+ RegCloseKey(subkey);
+ }
+ RegDeleteKey(key, name);
+ }
+}
+
+/*
+ * Destroy all registry information associated with PuTTY.
+ */
+void registry_cleanup(void) {
+ HKEY key;
+ int ret;
+ char name[MAX_PATH+1];
+
+ /*
+ * Open the main PuTTY registry key and remove everything in it.
+ */
+ if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_POS, &key) == ERROR_SUCCESS) {
+ registry_recursive_remove(key);
+ RegCloseKey(key);
+ }
+ /*
+ * Now open the parent key and remove the PuTTY main key. Once
+ * we've done that, see if the parent key has any other
+ * children.
+ */
+ if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_PARENT,
+ &key) == ERROR_SUCCESS) {
+ RegDeleteKey(key, PUTTY_REG_PARENT_CHILD);
+ ret = RegEnumKey(key, 0, name, sizeof(name));
+ RegCloseKey(key);
+ /*
+ * If the parent key had no other children, we must delete
+ * it in its turn. That means opening the _grandparent_
+ * key.
+ */
+ if (ret != ERROR_SUCCESS) {
+ if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_GPARENT,
+ &key) == ERROR_SUCCESS) {
+ RegDeleteKey(key, PUTTY_REG_GPARENT_CHILD);
+ RegCloseKey(key);
+ }
+ }
+ }
+ /*
+ * Now we're done.
+ */
+}