]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - windows/winpgnt.c
Merge branch 'pre-0.67'
[PuTTY.git] / windows / winpgnt.c
index 73de99dd3fa1e8fa63d57470f21b2703f74260bc..6e8016408186a9fe3a9e00672bb2aa8642749d40 100644 (file)
@@ -16,6 +16,7 @@
 #include "tree234.h"
 #include "winsecur.h"
 #include "pageant.h"
+#include "licence.h"
 
 #include <shellapi.h>
 
@@ -120,11 +121,12 @@ struct PassphraseProcStruct {
 /*
  * Dialog-box function for the Licence box.
  */
-static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
+static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
                                WPARAM wParam, LPARAM lParam)
 {
     switch (msg) {
       case WM_INITDIALOG:
+        SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n"));
        return 1;
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
@@ -144,12 +146,19 @@ static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
 /*
  * Dialog-box function for the About box.
  */
-static int CALLBACK AboutProc(HWND hwnd, UINT msg,
+static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
                              WPARAM wParam, LPARAM lParam)
 {
     switch (msg) {
       case WM_INITDIALOG:
-       SetDlgItemText(hwnd, 100, ver);
+        {
+            char *text = dupprintf
+                ("Pageant\r\n\r\n%s\r\n\r\n%s",
+                 ver,
+                 "\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
+            SetDlgItemText(hwnd, 1000, text);
+            sfree(text);
+        }
        return 1;
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
@@ -179,7 +188,7 @@ static HWND passphrase_box;
 /*
  * Dialog-box function for the passphrase box.
  */
-static int CALLBACK PassphraseProc(HWND hwnd, UINT msg,
+static INT_PTR CALLBACK PassphraseProc(HWND hwnd, UINT msg,
                                   WPARAM wParam, LPARAM lParam)
 {
     static char **passphrase = NULL;
@@ -291,7 +300,7 @@ void keylist_update(void)
        }
        for (i = 0; NULL != (skey = pageant_nth_ssh2_key(i)); i++) {
            char *listentry, *p;
-           int pos, fp_len;
+           int pos;
            /*
             * Replace spaces with tabs in the fingerprint prefix, for
             * nice alignment in the list box, until we encounter a :
@@ -299,13 +308,12 @@ void keylist_update(void)
             */
            p = ssh2_fingerprint(skey->alg, skey->data);
             listentry = dupprintf("%s\t%s", p, skey->comment);
-            fp_len = strlen(listentry);
             sfree(p);
 
             pos = 0;
             while (1) {
                 pos += strcspn(listentry + pos, " :");
-                if (listentry[pos] == ':')
+                if (listentry[pos] == ':' || !listentry[pos])
                     break;
                 listentry[pos++] = '\t';
             }
@@ -369,7 +377,7 @@ static void win_add_keyfile(Filename *filename)
      * comment to use in the passphrase prompt.
      */
     while (1) {
-        int dlgret;
+        INT_PTR dlgret;
         struct PassphraseProcStruct pps;
 
         pps.passphrase = &passphrase;
@@ -378,11 +386,11 @@ static void win_add_keyfile(Filename *filename)
                                 NULL, PassphraseProc, (LPARAM) &pps);
         passphrase_box = NULL;
 
-        sfree(err);
-
         if (!dlgret)
             goto done;                /* operation cancelled */
 
+        sfree(err);
+
         assert(passphrase != NULL);
 
         ret = pageant_add_keyfile(filename, passphrase, &err);
@@ -462,7 +470,7 @@ static void prompt_add_keyfile(void)
 /*
  * Dialog-box function for the key list box.
  */
-static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
+static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg,
                                WPARAM wParam, LPARAM lParam)
 {
     struct RSAKey *rkey;
@@ -745,7 +753,6 @@ PSID get_default_sid(void)
 static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                                WPARAM wParam, LPARAM lParam)
 {
-    int ret;
     static int menuinprogress;
     static UINT msgTaskbarCreated = 0;
 
@@ -780,10 +787,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
            menuinprogress = 1;
            update_sessions();
            SetForegroundWindow(hwnd);
-           ret = TrackPopupMenu(systray_menu,
-                                TPM_RIGHTALIGN | TPM_BOTTOMALIGN |
-                                TPM_RIGHTBUTTON,
-                                wParam, lParam, 0, hwnd, NULL);
+           TrackPopupMenu(systray_menu,
+                          TPM_RIGHTALIGN | TPM_BOTTOMALIGN |
+                          TPM_RIGHTBUTTON,
+                          wParam, lParam, 0, hwnd, NULL);
            menuinprogress = 0;
        }
        break;
@@ -791,7 +798,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
       case WM_SYSCOMMAND:
        switch (wParam & ~0xF) {       /* low 4 bits reserved to Windows */
          case IDM_PUTTY:
-           if((int)ShellExecute(hwnd, NULL, putty_path, _T(""), _T(""),
+           if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, _T(""), _T(""),
                                 SW_SHOW) <= 32) {
                MessageBox(NULL, "Unable to execute PuTTY!",
                           "Error", MB_OK | MB_ICONERROR);
@@ -858,7 +865,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                    GetMenuItemInfo(session_menu, wParam, FALSE, &mii);
                    strcpy(param, "@");
                    strcat(param, mii.dwTypeData);
-                   if((int)ShellExecute(hwnd, NULL, putty_path, param,
+                   if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param,
                                         _T(""), SW_SHOW) <= 32) {
                        MessageBox(NULL, "Unable to execute PuTTY!", "Error",
                                   MB_OK | MB_ICONERROR);
@@ -914,7 +921,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                        debug(("couldn't get default SID\n"));
 #endif
                         CloseHandle(filemap);
-                        sfree(ourself);
                        return 0;
                     }
 
@@ -927,7 +933,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                                rc));
 #endif
                         CloseHandle(filemap);
-                        sfree(ourself);
                         sfree(ourself2);
                        return 0;
                    }
@@ -948,7 +953,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                         !EqualSid(mapowner, ourself2)) {
                         CloseHandle(filemap);
                         LocalFree(psd);
-                        sfree(ourself);
                         sfree(ourself2);
                        return 0;      /* security ID mismatch! */
                     }
@@ -956,7 +960,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                    debug(("security stuff matched\n"));
 #endif
                     LocalFree(psd);
-                    sfree(ourself);
                     sfree(ourself2);
                } else {
 #ifdef DEBUG_IPC
@@ -1193,7 +1196,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        session_menu = CreateMenu();
        AppendMenu(systray_menu, MF_ENABLED, IDM_PUTTY, "&New Session");
        AppendMenu(systray_menu, MF_POPUP | MF_ENABLED,
-                  (UINT) session_menu, "&Saved Sessions");
+                  (UINT_PTR) session_menu, "&Saved Sessions");
        AppendMenu(systray_menu, MF_SEPARATOR, 0, 0);
     }
     AppendMenu(systray_menu, MF_ENABLED, IDM_VIEWKEYS,