Joris's RSA works; reformat and remove old version
[u/mdw/putty] / windlg.c
index b3bfcbf..757300d 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -213,14 +213,17 @@ static void load_settings (char *section, int do_host) {
 
     p = malloc(3*strlen(section)+1);
     mungestr(section, p);
-    
-    if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS ||
-       RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) {
+
+    if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS) {
        sesskey = NULL;
+    } else {
+       if (RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) {
+           sesskey = NULL;
+       }
+       RegCloseKey(subkey1);
     }
 
     free(p);
-    RegCloseKey(subkey1);
 
     if (do_host) {
        char prot[10];
@@ -357,6 +360,27 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
     return 0;
 }
 
+static int CALLBACK LicenceProc (HWND hwnd, UINT msg,
+                                WPARAM wParam, LPARAM lParam) {
+    switch (msg) {
+      case WM_INITDIALOG:
+       return 1;
+      case WM_COMMAND:
+       switch (LOWORD(wParam)) {
+         case IDOK:
+           abtbox = NULL;
+           DestroyWindow (hwnd);
+           return 0;
+       }
+       return 0;
+      case WM_CLOSE:
+       abtbox = NULL;
+       DestroyWindow (hwnd);
+       return 0;
+    }
+    return 0;
+}
+
 static int CALLBACK AboutProc (HWND hwnd, UINT msg,
                               WPARAM wParam, LPARAM lParam) {
     switch (msg) {
@@ -377,7 +401,7 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg,
          case IDA_LICENCE:
            EnableWindow(hwnd, 0);
            DialogBox (hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
-                      NULL, AboutProc);
+                      NULL, LicenceProc);
            EnableWindow(hwnd, 1);
            return 0;
        }