Mark Baker's raw-TCP back end (untested and experimental as yet)
[u/mdw/putty] / windlg.c
index 79faca3..023ebbc 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -15,8 +15,6 @@
 
 static const char *const puttystr = PUTTY_REG_POS "\\Sessions";
 
-static void get_sesslist(int allocate);
-
 static char **negots = NULL;
 static int nnegots = 0, negsize = 0;
 static HWND logbox = NULL, abtbox = NULL;
@@ -95,9 +93,6 @@ static void gppi(HKEY key, LPCTSTR name, int def, int *i) {
 
 static HINSTANCE hinst;
 
-static char **sessions;
-static int nsessions;
-
 static int readytogo;
 
 static void save_settings (char *section, int do_host) {
@@ -121,7 +116,8 @@ static void save_settings (char *section, int do_host) {
        wpps (sesskey, "HostName", cfg.host);
        wppi (sesskey, "PortNumber", cfg.port);
        wpps (sesskey, "Protocol",
-             cfg.protocol == PROT_SSH ? "ssh" : "telnet");
+             cfg.protocol == PROT_SSH ? "ssh" : 
+                 cfg.protocol == PROT_TELNET ? "telnet" : "raw" );
     }
     wppi (sesskey, "CloseOnExit", !!cfg.close_on_exit);
     wpps (sesskey, "TerminalType", cfg.termtype);
@@ -233,6 +229,8 @@ static void load_settings (char *section, int do_host) {
        cfg.protocol = PROT_SSH;
     else if (!strcmp(prot, "telnet"))
        cfg.protocol = PROT_TELNET;
+    else if (!strcmp(prot, "raw"))
+       cfg.protocol = PROT_RAW;
     else
        cfg.protocol = default_protocol;
 
@@ -452,8 +450,9 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg,
        for (i = 0; i < nsessions; i++)
            SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_ADDSTRING,
                                0, (LPARAM) (sessions[i]));
-       CheckRadioButton (hwnd, IDC0_PROTTELNET, IDC0_PROTSSH,
-                         cfg.protocol==PROT_SSH ? IDC0_PROTSSH : IDC0_PROTTELNET);
+       CheckRadioButton (hwnd, IDC0_PROTRAW, IDC0_PROTSSH,
+                         cfg.protocol==PROT_SSH ? IDC0_PROTSSH : 
+                         cfg.protocol==PROT_TELNET ? IDC0_PROTTELNET : IDC0_PROTRAW );
        CheckDlgButton (hwnd, IDC0_CLOSEEXIT, cfg.close_on_exit);
        break;
       case WM_LBUTTONUP:
@@ -469,10 +468,12 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg,
        switch (LOWORD(wParam)) {
          case IDC0_PROTTELNET:
          case IDC0_PROTSSH:
+         case IDC0_PROTRAW:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED) {
                int i = IsDlgButtonChecked (hwnd, IDC0_PROTSSH);
-               cfg.protocol = i ? PROT_SSH : PROT_TELNET;
+               int j = IsDlgButtonChecked (hwnd, IDC0_PROTTELNET);
+               cfg.protocol = i ? PROT_SSH : j ? PROT_TELNET : PROT_RAW ;
                if ((cfg.protocol == PROT_SSH && cfg.port == 23) ||
                    (cfg.protocol == PROT_TELNET && cfg.port == 22)) {
                    cfg.port = i ? 22 : 23;
@@ -548,9 +549,9 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg,
                               !!strcmp(sessions[n], "Default Settings"));
                SetDlgItemText (hwnd, IDC0_HOST, cfg.host);
                SetDlgItemInt (hwnd, IDC0_PORT, cfg.port, FALSE);
-               CheckRadioButton (hwnd, IDC0_PROTTELNET, IDC0_PROTSSH,
+               CheckRadioButton (hwnd, IDC0_PROTRAW, IDC0_PROTSSH,
                                  (cfg.protocol==PROT_SSH ? IDC0_PROTSSH :
-                                  IDC0_PROTTELNET));
+                                 cfg.protocol==PROT_TELNET ? IDC0_PROTTELNET : IDC0_PROTRAW));
                CheckDlgButton (hwnd, IDC0_CLOSEEXIT, cfg.close_on_exit);
                SendDlgItemMessage (hwnd, IDC0_SESSLIST, LB_SETCURSEL,
                                    (WPARAM) -1, 0);
@@ -1225,7 +1226,7 @@ static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg,
                               RECONF_NPANELS, reconfp, &page);
 }
 
-static void get_sesslist(int allocate) {
+void get_sesslist(int allocate) {
     static char *buffer;
     int buflen, bufsize, i, ret;
     char otherbuf[2048];