John Sullivan's patches plus more fixes:
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 8 Jan 1999 13:10:19 +0000 (13:10 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 8 Jan 1999 13:10:19 +0000 (13:10 +0000)
  - Stop using the identifier `environ' as some platforms make it a macro
  - Fix silly error box at end of connection in FWHACK mode
  - Fix GPF on maximise-then-restore
  - Use SetCapture to allow drag-selecting outside the window
  - Correctly update window title when iconic and in win_name_always mode

git-svn-id: svn://svn.tartarus.org/sgt/putty@12 cda61777-01e9-0310-a592-d414129be87e

putty.h
ssh.c
ssh.h
sshdes.c
telnet.c
terminal.c
windlg.c
window.c

diff --git a/putty.h b/putty.h
index c570392..a456fdb 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -98,7 +98,7 @@ typedef struct {
     /* Telnet options */
     char termtype[32];
     char termspeed[32];
-    char environ[1024];                       /* VAR\tvalue\0VAR\tvalue\0\0 */
+    char environmt[1024];                    /* VAR\tvalue\0VAR\tvalue\0\0 */
     char username[32];
     int rfc_environ;
     /* Keyboard options */
diff --git a/ssh.c b/ssh.c
index f80055c..8092c98 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -114,6 +114,12 @@ static void ssh_gotdata(unsigned char *data, int datalen) {
            data++, datalen--;
        }
 
+#ifdef FWHACK
+        if (len == 0x52656d6f) {       /* "Remo"te server has closed ... */
+            len = 0x300;               /* big enough to carry to end */
+        }
+#endif
+
        pad = 8 - (len%8);
 
        biglen = len + pad;
diff --git a/ssh.h b/ssh.h
index 260d062..5c72eeb 100644 (file)
--- a/ssh.h
+++ b/ssh.h
@@ -1,3 +1,5 @@
+#include <string.h>
+
 struct RSAKey {
     int bits;
     int bytes;
index 897457a..66e7041 100644 (file)
--- a/sshdes.c
+++ b/sshdes.c
@@ -17,10 +17,15 @@ information.
 */
 
 /*
- * $Id: sshdes.c,v 1.1 1999/01/08 13:02:12 simon Exp $
+ * $Id: sshdes.c,v 1.2 1999/01/08 13:10:15 simon Exp $
  * $Log: sshdes.c,v $
- * Revision 1.1  1999/01/08 13:02:12  simon
- * Initial checkin: beta 0.43
+ * Revision 1.2  1999/01/08 13:10:15  simon
+ * John Sullivan's patches plus more fixes:
+ *   - Stop using the identifier `environ' as some platforms make it a macro
+ *   - Fix silly error box at end of connection in FWHACK mode
+ *   - Fix GPF on maximise-then-restore
+ *   - Use SetCapture to allow drag-selecting outside the window
+ *   - Correctly update window title when iconic and in win_name_always mode
  *
  * Revision 1.1.1.1  1996/02/18 21:38:11  ylo
  *     Imported ssh-1.2.13.
@@ -111,10 +116,15 @@ cryptography and data security, including the following:
 */
 
 /*
- * $Id: sshdes.c,v 1.1 1999/01/08 13:02:12 simon Exp $
+ * $Id: sshdes.c,v 1.2 1999/01/08 13:10:15 simon Exp $
  * $Log: sshdes.c,v $
- * Revision 1.1  1999/01/08 13:02:12  simon
- * Initial checkin: beta 0.43
+ * Revision 1.2  1999/01/08 13:10:15  simon
+ * John Sullivan's patches plus more fixes:
+ *   - Stop using the identifier `environ' as some platforms make it a macro
+ *   - Fix silly error box at end of connection in FWHACK mode
+ *   - Fix GPF on maximise-then-restore
+ *   - Use SetCapture to allow drag-selecting outside the window
+ *   - Correctly update window title when iconic and in win_name_always mode
  *
  * Revision 1.1.1.1  1996/02/18 21:38:11  ylo
  *     Imported ssh-1.2.13.
index 14881f9..b6e4802 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -350,7 +350,7 @@ static void process_subneg (void) {
            b[0] = IAC; b[1] = SB; b[2] = sb_opt;
            b[3] = TELQUAL_IS;
            n = 4;
-           e = cfg.environ;
+          e = cfg.environmt;
            while (*e) {
                b[n++] = var;
                while (*e && *e != '\t') b[n++] = *e++;
index 1e286ce..feec70a 100644 (file)
@@ -1254,8 +1254,8 @@ void term_paint (Context ctx, int l, int t, int r, int b) {
     right = (r - 1) / font_width;
     top = t / font_height;
     bottom = (b - 1) / font_height;
-    for (i = top; i <= bottom; i++)
-       for (j = left; j <= right; j++)
+    for (i = top; i <= bottom && j<rows ; i++)
+      for (j = left; j <= right && j<cols ; j++)
            disptext[i*(cols+1)+j] = ATTR_INVALID;
 
     do_paint (ctx, FALSE);
@@ -1339,7 +1339,14 @@ static void sel_spread (void) {
 }
 
 void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
-    unsigned long *selpoint = disptop + y * (cols+1) + x;
+    unsigned long *selpoint;
+    
+    if (y<0) y = 0;
+    if (y>=rows) y = rows-1;
+    if (x<0) x = 0;
+    if (x>=cols) x = cols-1;
+
+    selpoint = disptop + y * (cols+1) + x;
 
     if (b == MB_SELECT && a == MA_CLICK) {
        deselect();
index ecd3e5f..b5d1b57 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -134,9 +134,9 @@ static void save_settings (char *section, int do_host) {
     wpps (sesskey, "TerminalType", cfg.termtype);
     wpps (sesskey, "TerminalSpeed", cfg.termspeed);
     {
-       char buf[2*sizeof(cfg.environ)], *p, *q;
+      char buf[2*sizeof(cfg.environmt)], *p, *q;
        p = buf;
-       q = cfg.environ;
+      q = cfg.environmt;
        while (*q) {
            while (*q) {
                int c = *q++;
@@ -245,10 +245,10 @@ static void load_settings (char *section, int do_host) {
     gpps (sesskey, "TerminalSpeed", "38400,38400", cfg.termspeed,
          sizeof(cfg.termspeed));
     {
-       char buf[2*sizeof(cfg.environ)], *p, *q;
+      char buf[2*sizeof(cfg.environmt)], *p, *q;
        gpps (sesskey, "Environment", "", buf, sizeof(buf));
        p = buf;
-       q = cfg.environ;
+      q = cfg.environmt;
        while (*p) {
            while (*p && *p != ',') {
                int c = *p++;
@@ -712,7 +712,7 @@ static int CALLBACK TelnetProc (HWND hwnd, UINT msg,
        SetDlgItemText (hwnd, IDC3_TSEDIT, cfg.termspeed);
        SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
        {
-           char *p = cfg.environ;
+          char *p = cfg.environmt;
            while (*p) {
                SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_ADDSTRING, 0,
                                    (LPARAM) p);
@@ -746,7 +746,7 @@ static int CALLBACK TelnetProc (HWND hwnd, UINT msg,
          case IDC3_ENVADD:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED) {
-               char str[sizeof(cfg.environ)];
+              char str[sizeof(cfg.environmt)];
                char *p;
                GetDlgItemText (hwnd, IDC3_VAREDIT, str, sizeof(str)-1);
                if (!*str) {
@@ -760,12 +760,12 @@ static int CALLBACK TelnetProc (HWND hwnd, UINT msg,
                    MessageBeep(0);
                    break;
                }
-               p = cfg.environ;
+              p = cfg.environmt;
                while (*p) {
                    while (*p) p++;
                    p++;
                }
-               if ((p-cfg.environ) + strlen(str) + 2 < sizeof(cfg.environ)) {
+              if ((p-cfg.environmt) + strlen(str) + 2 < sizeof(cfg.environmt)) {
                    strcpy (p, str);
                    p[strlen(str)+1] = '\0';
                    SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_ADDSTRING,
@@ -790,7 +790,7 @@ static int CALLBACK TelnetProc (HWND hwnd, UINT msg,
 
                SendDlgItemMessage (hwnd, IDC3_ENVLIST, LB_DELETESTRING,
                                    i, 0);
-               p = cfg.environ;
+              p = cfg.environmt;
                while (i > 0) {
                    if (!*p)
                        goto disaster;
index 151441f..9210d15 100644 (file)
--- a/window.c
+++ b/window.c
@@ -698,33 +698,43 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
            break;
        }
        break;
+
+#define X_POS(l) ((int)(short)LOWORD(l))
+#define Y_POS(l) ((int)(short)HIWORD(l))
+
       case WM_LBUTTONDOWN:
-       click (MB_SELECT, LOWORD(lParam) / font_width,
-              HIWORD(lParam) / font_height);
+        SetCapture(hwnd);
+       click (MB_SELECT, X_POS(lParam) / font_width,
+              Y_POS(lParam) / font_height);
        return 0;
       case WM_LBUTTONUP:
-       term_mouse (MB_SELECT, MA_RELEASE, LOWORD(lParam) / font_width,
-                   HIWORD(lParam) / font_height);
+       term_mouse (MB_SELECT, MA_RELEASE, X_POS(lParam) / font_width,
+                   Y_POS(lParam) / font_height);
+        ReleaseCapture();
        return 0;
       case WM_MBUTTONDOWN:
+        SetCapture(hwnd);
        click (cfg.mouse_is_xterm ? MB_PASTE : MB_EXTEND,
-              LOWORD(lParam) / font_width,
-              HIWORD(lParam) / font_height);
+              X_POS(lParam) / font_width,
+              Y_POS(lParam) / font_height);
        return 0;
       case WM_MBUTTONUP:
        term_mouse (cfg.mouse_is_xterm ? MB_PASTE : MB_EXTEND,
-                   MA_RELEASE, LOWORD(lParam) / font_width,
-                   HIWORD(lParam) / font_height);
+                   MA_RELEASE, X_POS(lParam) / font_width,
+                   Y_POS(lParam) / font_height);
        return 0;
+        ReleaseCapture();
       case WM_RBUTTONDOWN:
+        SetCapture(hwnd);
        click (cfg.mouse_is_xterm ? MB_EXTEND : MB_PASTE,
-              LOWORD(lParam) / font_width,
-              HIWORD(lParam) / font_height);
+              X_POS(lParam) / font_width,
+              Y_POS(lParam) / font_height);
        return 0;
       case WM_RBUTTONUP:
        term_mouse (cfg.mouse_is_xterm ? MB_EXTEND : MB_PASTE,
-                   MA_RELEASE, LOWORD(lParam) / font_width,
-                   HIWORD(lParam) / font_height);
+                   MA_RELEASE, X_POS(lParam) / font_width,
+                   Y_POS(lParam) / font_height);
+        ReleaseCapture();
        return 0;
       case WM_MOUSEMOVE:
        /*
@@ -742,8 +752,8 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
                b = cfg.mouse_is_xterm ? MB_PASTE : MB_EXTEND;
            else
                b = cfg.mouse_is_xterm ? MB_EXTEND : MB_PASTE;
-           term_mouse (b, MA_DRAG, LOWORD(lParam) / font_width,
-                       HIWORD(lParam) / font_height);
+           term_mouse (b, MA_DRAG, X_POS(lParam) / font_width,
+                       Y_POS(lParam) / font_height);
        }
        lastbtn = MB_NOTHING;
        lastact = MA_NOTHING;
@@ -1315,7 +1325,7 @@ void set_title (char *title) {
     sfree (window_name);
     window_name = smalloc(1+strlen(title));
     strcpy (window_name, title);
-    if (!IsIconic(hwnd))
+    if (cfg.win_name_always || !IsIconic(hwnd))
        SetWindowText (hwnd, title);
 }
 
@@ -1323,7 +1333,7 @@ void set_icon (char *title) {
     sfree (icon_name);
     icon_name = smalloc(1+strlen(title));
     strcpy (icon_name, title);
-    if (IsIconic(hwnd))
+    if (!cfg.win_name_always && IsIconic(hwnd))
        SetWindowText (hwnd, title);
 }