Add the ability to do ssh by default: using -ssh command line option,
[u/mdw/putty] / windlg.c
index a700081..79faca3 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -42,8 +42,6 @@ static void mungestr(char *in, char *out) {
 }
 
 static void unmungestr(char *in, char *out) {
-    int candot = 0;
-
     while (*in) {
        if (*in == '%' && in[1] && in[2]) {
            int i, j;
@@ -150,7 +148,7 @@ static void save_settings (char *section, int do_host) {
     wpps (sesskey, "UserName", cfg.username);
     wppi (sesskey, "NoPTY", cfg.nopty);
     wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" :
-                             "3des");
+                             cfg.cipher == CIPHER_DES ? "des" : "3des");
     wppi (sesskey, "RFCEnviron", cfg.rfc_environ);
     wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete);
     wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend);
@@ -212,6 +210,7 @@ static void load_settings (char *section, int do_host) {
     int i;
     HKEY subkey1, sesskey;
     char *p;
+    char prot[10];
 
     p = malloc(3*strlen(section)+1);
     mungestr(section, p);
@@ -227,19 +226,16 @@ static void load_settings (char *section, int do_host) {
 
     free(p);
 
-    if (do_host) {
-       char prot[10];
-       gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host));
-       gppi (sesskey, "PortNumber", 23, &cfg.port);
-       gpps (sesskey, "Protocol", "telnet", prot, 10);
-       if (!strcmp(prot, "ssh"))
-           cfg.protocol = PROT_SSH;
-       else
-           cfg.protocol = PROT_TELNET;
-    } else {
-       cfg.port = 23;
-       *cfg.host = '\0';
-    }
+    gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host));
+    gppi (sesskey, "PortNumber", default_port, &cfg.port);
+    gpps (sesskey, "Protocol", "default", prot, 10);
+    if (!strcmp(prot, "ssh"))
+       cfg.protocol = PROT_SSH;
+    else if (!strcmp(prot, "telnet"))
+       cfg.protocol = PROT_TELNET;
+    else
+       cfg.protocol = default_protocol;
+
     gppi (sesskey, "CloseOnExit", 1, &cfg.close_on_exit);
     gpps (sesskey, "TerminalType", "xterm", cfg.termtype,
          sizeof(cfg.termtype));
@@ -271,6 +267,8 @@ static void load_settings (char *section, int do_host) {
        gpps (sesskey, "Cipher", "3des", cipher, 10);
        if (!strcmp(cipher, "blowfish"))
            cfg.cipher = CIPHER_BLOWFISH;
+       else if (!strcmp(cipher, "des"))
+           cfg.cipher = CIPHER_DES;
        else
            cfg.cipher = CIPHER_3DES;
     }
@@ -875,8 +873,10 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
        SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
        SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
        CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty);
-       CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERBLOWF,
+       CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERDES,
                          cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF :
+                         cfg.cipher == CIPHER_DES ? IDC3_CIPHERDES :
+
                          IDC3_CIPHER3DES);
        break;
       case WM_COMMAND:
@@ -898,12 +898,15 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
            break;
          case IDC3_CIPHER3DES:
          case IDC3_CIPHERBLOWF:
+         case IDC3_CIPHERDES:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED) {
                if (IsDlgButtonChecked (hwnd, IDC3_CIPHER3DES))
                    cfg.cipher = CIPHER_3DES;
                else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERBLOWF))
                    cfg.cipher = CIPHER_BLOWFISH;
+               else if (IsDlgButtonChecked (hwnd, IDC3_CIPHERDES))
+                   cfg.cipher = CIPHER_DES;
            }
            break;
        }