From 699584aa8f83a581fc73d01fe12d85d32bd5b2ca Mon Sep 17 00:00:00 2001 From: chombier <> Date: Mon, 18 Jun 2001 09:14:15 +0000 Subject: [PATCH] cleanup --- macssh/source/Headers/Preferences.h | 12 ++- macssh/source/Screens/rsmac.c | 2 +- macssh/source/Screens/vsdata.h | 2 + macssh/source/Screens/wind.h | 4 +- macssh/source/parse/parse.c | 9 +-- macssh/source/parse/vsem.c | 118 ++++++++++++++++++---------- macssh/source/ssh/ssh2.c | 4 +- 7 files changed, 97 insertions(+), 54 deletions(-) diff --git a/macssh/source/Headers/Preferences.h b/macssh/source/Headers/Preferences.h index b9e9c35..084abb1 100755 --- a/macssh/source/Headers/Preferences.h +++ b/macssh/source/Headers/Preferences.h @@ -192,10 +192,7 @@ typedef struct { sockshost[256]; /* NONO */ -/* added fields below... - short - padding[100]; // Disk space is cheap.... (used to be [98]) -*/ +/* added fields below... */ short authentication, compression, @@ -209,6 +206,13 @@ typedef struct { remoteport; char remotehost[180]; + + Boolean + launchurlesc, + unused1; + + short + padding[100]; // Disk space is cheap.... (used to be [98]) /* NONO */ } SessionPrefs; diff --git a/macssh/source/Screens/rsmac.c b/macssh/source/Screens/rsmac.c index 79f8f86..66953c6 100755 --- a/macssh/source/Screens/rsmac.c +++ b/macssh/source/Screens/rsmac.c @@ -50,7 +50,7 @@ * RSupdate(wind) - Handle updates on WIND, return 0 if not an RS * RSactivate(w) - Handle activate events * RSdeactivate(w) - Handle deactivate events - * RSGetTextSel(w,table) - Returns handle to text selection of window w, table->tabs + * RSGetTextSel(w,table,clipspaces) - Returns handle to text selection of window w, table->tabs * RSnewwindow( wDims, sb, wid, lines * name,wrap,fnum,fsiz, * showit, goaway) - Returns VS # of newly created text window - diff --git a/macssh/source/Screens/vsdata.h b/macssh/source/Screens/vsdata.h index 064b60f..05cee48 100755 --- a/macssh/source/Screens/vsdata.h +++ b/macssh/source/Screens/vsdata.h @@ -125,6 +125,8 @@ struct VSscrn { short trinx; /* number of characters to draw at left of cursor */ short trintag; /* true if waiting for a second multi-byte character */ unsigned char trinbuf[4]; + Str255 tempstr; /* buffer to keep partial new window name/url in vsem */ + }; diff --git a/macssh/source/Screens/wind.h b/macssh/source/Screens/wind.h index 95e08a5..677480b 100755 --- a/macssh/source/Screens/wind.h +++ b/macssh/source/Screens/wind.h @@ -263,7 +263,9 @@ unsigned char TECObjectRef fromconverter, toconverter; - + +Boolean + launchurlesc; // true if we accept to process 'launchurl' escape sequences /* NONO */ }; diff --git a/macssh/source/parse/parse.c b/macssh/source/parse/parse.c index 3bcd969..b712502 100755 --- a/macssh/source/parse/parse.c +++ b/macssh/source/parse/parse.c @@ -662,11 +662,11 @@ void telnet_send_initial_options(WindRec *tw) return; } - if (tw->authenticate) { + if (tw->authenticate && authOK) { send_will(tw->port, OPT_AUTHENTICATION); (tw->myopts)[OPT_AUTHENTICATION-MHOPTS_BASE] = 1; - if (tw->encrypt) { + if (tw->encrypt && encryptOK) { send_will(tw->port, OPT_ENCRYPT); /* will encrypt */ (tw->myopts)[OPT_ENCRYPT-MHOPTS_BASE] = 1; } @@ -976,11 +976,10 @@ static void telnet_will(struct WindRec *tw, short option) case N_AUTHENTICATION: /* will auth */ if (!tw->hisopts[OPT_AUTHENTICATION-MHOPTS_BASE]) { - if (tw->authenticate) { + if (tw->authenticate && authOK) { (tw->hisopts)[OPT_AUTHENTICATION-MHOPTS_BASE] = 1; send_do(tw->port, N_AUTHENTICATION); - } - else { + } else { send_dont(tw->port, N_AUTHENTICATION); } } diff --git a/macssh/source/parse/vsem.c b/macssh/source/parse/vsem.c index 8348de5..43c9eb9 100755 --- a/macssh/source/parse/vsem.c +++ b/macssh/source/parse/vsem.c @@ -49,6 +49,7 @@ #include "printing.proto.h" #include "event.proto.h" #include "menuseg.proto.h" +#include "url.proto.h" #include "vsem.proto.h" @@ -379,7 +380,8 @@ enum { esc_G3, esc_G0j, esc_G2j, - esc_XTerm + esc_XTerm, + esc_url }; @@ -515,8 +517,8 @@ void VSem } break; } - c++; - ctr--; + ++c; + --ctr; } if ( escflg == esc_root && ctr > 0 && (*c & 0x80) && *c < 0xA0 && VSIw->vtemulation != 0 && VSIw->vteightbits ) { @@ -541,8 +543,8 @@ void VSem VSIapclear(); escflg = esc_csi; escflags = 0; - c++; //CCP - ctr--; + ++c; //CCP + --ctr; break; case 0x86: /* ssa */ // - same as ESC 'F' case 0x87: /* esa */ // - same as ESC 'G' @@ -870,11 +872,17 @@ void VSem // switch to charset // FIXME goto ShortCut; + + case '&': // URL processing + escflg = esc_url; + escflags = 0; + break; + default: goto ShortCut; } /* switch */ - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_csi && ctr > 0 ) { @@ -1115,7 +1123,7 @@ void VSem case 'i': /* PR: media copy */ if (VSIw->parms[VSIw->parmptr]==5) { /* PR */ - /*c++; ctr--; */ /* PR */ + /*++c; --ctr; */ /* PR */ VSprON(); /* PR - set status and open temp file etc */ /* PR - chars will be redirected at top of loop É */ /* PR - É in this procedure */ @@ -1303,8 +1311,8 @@ void VSem // VSprintf( "unknown csi : 0x%x\n", *c ); goto ShortCut; } /* switch */ - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_decl && ctr > 0 ) { @@ -1342,8 +1350,8 @@ void VSem VSredrawLine(VSIwn); goto ShortCut; } - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_descl && ctr > 0 ) { @@ -1374,8 +1382,8 @@ void VSem default: goto ShortCut; } /* switch */ - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_G0 && ctr > 0 ) { @@ -1422,8 +1430,8 @@ void VSem default: goto ShortCut; } /* switch */ - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_G1 && ctr > 0 ) { @@ -1451,8 +1459,8 @@ void VSem default: goto ShortCut; } /* switch */ - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_G2 && ctr > 0 ) { @@ -1466,8 +1474,8 @@ void VSem // FIXME... goto ShortCut; } - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_G3 && ctr > 0 ) { @@ -1481,8 +1489,8 @@ void VSem // FIXME... goto ShortCut; } - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_G0j && ctr > 0 ) { @@ -1559,8 +1567,8 @@ void VSem default: goto ShortCut; } /* switch */ - c++; - ctr--; + ++c; + --ctr; } /* while */ while ( escflg == esc_G2j && ctr > 0 ) { @@ -1581,23 +1589,22 @@ void VSem default: goto ShortCut; } - c++; - ctr--; + ++c; + --ctr; } /* while */ // Handle XTerm rename functions, code contributed by Bill Rausch // Modified by JMB to handle ESC]2; case as well. if ( escflg == esc_XTerm && ctr > 0 ) { - static Str255 newname; if ( escflags == 0 ) { if ( *c == '0' || *c == '2') { escflags = 1; - c++; - ctr--; + ++c; + --ctr; } else if ( *c == 'P') { /* palette escape sequence */ escflags = 3; - c++; - ctr--; + ++c; + --ctr; } else if ( *c == 'R') { /* reset palette */ RSresetcolors( VSIwn ); goto ShortCut; @@ -1606,20 +1613,20 @@ void VSem } } if ( escflags == 1 && ctr > 0 && *c == ';' ) { - c++; - ctr--; + ++c; + --ctr; escflags = 2; - newname[0] = 0; + *VSIw->tempstr = 0; } while ( escflags == 2 && ctr > 0 && *c != 7 && *c != 033) { - if (*newname < 255) { - newname[++(*newname)] = *c; + if (*VSIw->tempstr < sizeof(VSIw->tempstr) - 1) { + VSIw->tempstr[++(*VSIw->tempstr)] = *c; } - c++; - ctr--; + ++c; + --ctr; } if ( escflags == 2 && ctr > 0 && (*c == 7 || *c == 033) ) { - set_new_window_name( newname, RSgetwindow(VSIwn) ); + set_new_window_name( VSIw->tempstr, RSgetwindow(VSIwn) ); if (*c != 07) { /* This will be undone in the ShortCut below. */ c--; @@ -1644,14 +1651,43 @@ void VSem } } + while ( escflg == esc_url && ctr > 0 ) { + if ( (escflags == 0 && *c == '&') + || (escflags == 1 && *c == 'B') + || (escflags == 2 && *c == 'u') + || (escflags == 3 && *c == 'r') + || (escflags == 4 && *c == 'l') ) { + ++escflags; + if ( escflags == 5 ) { + *VSIw->tempstr = 0; + } + } else if ( escflags == 5 ) { + if ( *c == 0x0d || *c == 0x0a ) { + // completed. process url. + Boolean result = (tw && tw->launchurlesc) ? HandleURLString(VSIw->tempstr) : false; + RSsendstring( VSIwn, result ? "S" : "F", 1 ); + escflg = 0; + } else if (*VSIw->tempstr < sizeof(VSIw->tempstr) - 1) { + VSIw->tempstr[++(*VSIw->tempstr)] = *c; + } else { + // too big... + goto ShortCut; + } + } else { + goto ShortCut; + } + ++c; + --ctr; + } + if ( escflg > esc_csi && ctr > 0 ) { ShortCut: /* BYU 2.4.12 - well, sacrificing style for speed */ if ( VSIw->possibleForce && *c != 'H' ) //CCP better forcesave VSIw->possibleForce = FALSE; escflg = 0; escflags = 0; - c++; - ctr--; + ++c; + --ctr; } } /* while (ctr > 0) */ diff --git a/macssh/source/ssh/ssh2.c b/macssh/source/ssh/ssh2.c index 7736d56..5137973 100755 --- a/macssh/source/ssh/ssh2.c +++ b/macssh/source/ssh/ssh2.c @@ -842,13 +842,13 @@ char *getpass( const char *prompt ) strncat(cprompt, (char *)wind->sshdata.host + 1, wind->sshdata.host[0]); index = context->_pindex; - if ( gApplicationPrefs->cachePassphrase + if ( gApplicationPrefs->cachePassphrase && !wind->sshdata.password[0] && getnextcachedpassphrase(cprompt, password, &context->_pindex) ) { return password; } LockDialog(); context->_pindex = index; - if ( gApplicationPrefs->cachePassphrase + if ( gApplicationPrefs->cachePassphrase && !wind->sshdata.password[0] && getnextcachedpassphrase(cprompt, password, &context->_pindex) ) { UnlockDialog(); return password;