mirror of https://github.com/macssh/macssh.git
Add and use enum for window/connection protocol (telnet, rlogin, rsh, rexec, ssh)
This commit is contained in:
parent
e58448dc38
commit
0a2a8ea1e5
|
@ -333,7 +333,7 @@ void RSdrawlocker(short w, RgnHandle visRgn)
|
|||
/* draw locker icon */
|
||||
if ( RSlocal[w].left && !RSlocal[w].hideScrollBars ) {
|
||||
short sn = findbyVS(w);
|
||||
if ( sn >= 0 && screens[sn].protocol == 4 ) {
|
||||
if ( sn >= 0 && screens[sn].protocol == PROTOCOL_SSH ) {
|
||||
Rect iconRect = (**RSlocal[w].left).contrlRect;
|
||||
iconRect.top += 1;
|
||||
iconRect.right = iconRect.left;
|
||||
|
@ -600,7 +600,7 @@ short RSsize (GrafPtr window, long *where, long modifiers)
|
|||
if (screens[sn].naws) {
|
||||
SendNAWSinfo(&screens[sn], cwidth, (y2-y1+1));
|
||||
}
|
||||
if (screens[sn].protocol == 4) {
|
||||
if (screens[sn].protocol == PROTOCOL_SSH) {
|
||||
ssh_glue_wresize(&screens[sn]);
|
||||
}
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ short RSnewwindow
|
|||
|
||||
if (RScurrent->scroll == 0L) return(-3);
|
||||
|
||||
if ( screens[screenNumber].protocol == 4 ) {
|
||||
if ( screens[screenNumber].protocol == PROTOCOL_SSH ) {
|
||||
i = LOCKWIDTH + 1;
|
||||
} else {
|
||||
i = 0;
|
||||
|
|
|
@ -1327,7 +1327,7 @@ void RSsetsize( short w, short v, short h, short screenIndex)
|
|||
short i;
|
||||
if (screenIndex < 0)
|
||||
screenIndex = findbyVS(w);
|
||||
if ( screenIndex >= 0 && screens[screenIndex].protocol == 4 ) {
|
||||
if ( screenIndex >= 0 && screens[screenIndex].protocol == PROTOCOL_SSH ) {
|
||||
i = LOCKWIDTH + 1;
|
||||
} else {
|
||||
i = 0;
|
||||
|
|
|
@ -26,6 +26,17 @@
|
|||
|
||||
#define SLC_ARRAY_SIZE 30 // This should match the value of SLC_MAX from parse.h
|
||||
|
||||
|
||||
// enums for supported protocols
|
||||
enum protocol {
|
||||
PROTOCOL_TELNET,
|
||||
PROTOCOL_RLOGIN,
|
||||
PROTOCOL_RSH,
|
||||
PROTOCOL_REXEC,
|
||||
PROTOCOL_SSH,
|
||||
};
|
||||
|
||||
|
||||
// RAB BetterTelnet 2.0b2 - the struct for ssh stuff
|
||||
|
||||
typedef struct sshinfo {
|
||||
|
@ -145,8 +156,11 @@ char
|
|||
clientuser[256],
|
||||
command[256];
|
||||
|
||||
enum protocol
|
||||
protocol;
|
||||
|
||||
short
|
||||
protocol, encryption;
|
||||
encryption;
|
||||
|
||||
sshinfo sshdata;
|
||||
|
||||
|
|
|
@ -291,11 +291,11 @@ pascal OSErr MyHandleConnect (AppleEvent *theAppleEvent, AppleEvent* reply,
|
|||
pstrcpy((unsigned char *)SessPtr->password, passwordString);
|
||||
if ( protoID ) {
|
||||
switch ( protoID ) {
|
||||
case 'Tlnt': SessPtr->protocol = 0; break;
|
||||
case 'Rlog': SessPtr->protocol = 1; break;
|
||||
case 'Rsh ': SessPtr->protocol = 2; break;
|
||||
case 'Rexe': SessPtr->protocol = 3; break;
|
||||
case 'Ssh ': SessPtr->protocol = 4; break;
|
||||
case 'Tlnt': SessPtr->protocol = PROTOCOL_TELNET; break;
|
||||
case 'Rlog': SessPtr->protocol = PROTOCOL_RLOGIN; break;
|
||||
case 'Rsh ': SessPtr->protocol = PROTOCOL_RSH; break;
|
||||
case 'Rexe': SessPtr->protocol = PROTOCOL_REXEC; break;
|
||||
case 'Ssh ': SessPtr->protocol = PROTOCOL_SSH; break;
|
||||
}
|
||||
/* reset default port if none specified */
|
||||
GetAEStringParam(theAppleEvent, 'host', hostString);
|
||||
|
|
|
@ -2022,7 +2022,7 @@ Boolean EditSession(StringPtr PrefRecordNamePtr)
|
|||
// SetTEText(dptr, 59, (unsigned char *)SessPrefsPtr->password);
|
||||
SetTEText(dptr, 60, (unsigned char *)SessPrefsPtr->clientuser);
|
||||
|
||||
if ( SessPrefsPtr->protocol != 4 ) {
|
||||
if ( SessPrefsPtr->protocol != PROTOCOL_SSH ) {
|
||||
GetIndString(scratchPstring, MISC_STRINGS, MISC_COMMAND);
|
||||
} else {
|
||||
GetIndString(scratchPstring, MISC_STRINGS, MISC_ARGUMENTS);
|
||||
|
|
|
@ -231,7 +231,7 @@ static void SetCurrentSession(DialogPtr dptr, Str255 scratchPstring)
|
|||
SetCntrl(dptr, NCauthenticate, (**tempSessHdl).authenticate);//update the auth status
|
||||
SetCntrl(dptr, NCencrypt, (**tempSessHdl).encrypt);
|
||||
SetCntrl(dptr, NCforward, (**tempSessHdl).forward);
|
||||
SetCntrl(dptr, NCssh2, (**tempSessHdl).protocol == 4);
|
||||
SetCntrl(dptr, NCssh2, (**tempSessHdl).protocol == PROTOCOL_SSH);
|
||||
setSessStates(dptr);//encrypt cant be on w/o authenticate
|
||||
ReleaseResource((Handle)tempSessHdl);
|
||||
}
|
||||
|
@ -527,17 +527,17 @@ Boolean PresentOpenConnectionDialog(void)
|
|||
(**(**InitParams).session).forward = GetCntlVal(dptr, NCforward);
|
||||
|
||||
if ( GetCntlVal(dptr, NCssh2) ) {
|
||||
if ((**(**InitParams).session).protocol != 4) {
|
||||
(**(**InitParams).session).protocol = 4;
|
||||
if ((**(**InitParams).session).protocol != PROTOCOL_SSH) {
|
||||
(**(**InitParams).session).protocol = PROTOCOL_SSH;
|
||||
if ( !portSet ) {
|
||||
(**(**InitParams).session).port = getDefaultPort(4);
|
||||
(**(**InitParams).session).port = getDefaultPort(PROTOCOL_SSH);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((**(**InitParams).session).protocol == 4) {
|
||||
(**(**InitParams).session).protocol = 0;
|
||||
if ((**(**InitParams).session).protocol == PROTOCOL_SSH) {
|
||||
(**(**InitParams).session).protocol = PROTOCOL_TELNET;
|
||||
if ( !portSet ) {
|
||||
(**(**InitParams).session).port = getDefaultPort(0);
|
||||
(**(**InitParams).session).port = getDefaultPort(PROTOCOL_TELNET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -621,8 +621,8 @@ Boolean OpenConnectionFromURL(char *host, char *portstring, char *user, char *pa
|
|||
BlockMoveData(host, (**(**Params).session).hostname, host[0]+1);
|
||||
|
||||
if ( ssh != 0 ) {
|
||||
(**(**Params).session).protocol = 4;
|
||||
(**(**Params).session).port = getDefaultPort(4);
|
||||
(**(**Params).session).protocol = PROTOCOL_SSH;
|
||||
(**(**Params).session).port = getDefaultPort(PROTOCOL_SSH);
|
||||
if ( user != NULL ) {
|
||||
strcpy((**(**Params).session).username, user);
|
||||
CtoPstr((**(**Params).session).username);
|
||||
|
@ -631,10 +631,10 @@ Boolean OpenConnectionFromURL(char *host, char *portstring, char *user, char *pa
|
|||
strcpy((**(**Params).session).password, password);
|
||||
CtoPstr((**(**Params).session).password);
|
||||
}
|
||||
} else if ( (**(**Params).session).protocol == 4 ) {
|
||||
} else if ( (**(**Params).session).protocol == PROTOCOL_SSH ) {
|
||||
/* default to telnet */
|
||||
(**(**Params).session).protocol = 0;
|
||||
(**(**Params).session).port = getDefaultPort(0);
|
||||
(**(**Params).session).protocol = PROTOCOL_TELNET;
|
||||
(**(**Params).session).port = getDefaultPort(PROTOCOL_TELNET);
|
||||
}
|
||||
|
||||
if (portstring != nil) {
|
||||
|
@ -699,7 +699,7 @@ Boolean CreateConnectionFromParams( ConnInitParams **Params)
|
|||
goto failed;
|
||||
}
|
||||
/* we have SSH.
|
||||
if (SessPtr->protocol == 4) // make sure we have SSH
|
||||
if (SessPtr->protocol == PROTOCOL_SSH) // make sure we have SSH
|
||||
{
|
||||
if (!ssh_glue_installed()) {
|
||||
OperationFailedAlert(6, 0, 0);
|
||||
|
@ -836,7 +836,7 @@ Boolean CreateConnectionFromParams( ConnInitParams **Params)
|
|||
theScreen->vs = -1;
|
||||
theScreen->wind = NULL;
|
||||
|
||||
if (SessPtr->protocol == 4) {
|
||||
if (SessPtr->protocol == PROTOCOL_SSH) {
|
||||
memcpy(theScreen->sshdata.host, theScreen->machine, theScreen->machine[0] + 1);
|
||||
memcpy(theScreen->sshdata.login, theScreen->username, theScreen->username[0] + 1);
|
||||
memcpy(theScreen->sshdata.password, theScreen->password, theScreen->password[0] + 1);
|
||||
|
@ -1068,11 +1068,11 @@ void CompleteConnectionOpening(short dat, ip_addr the_IP, OSErr DNRerror, char *
|
|||
|
||||
if (setReadBlockSize((**(**Params).session).NetBlockSize,dat) != 0) //couldnt get read buffer
|
||||
return;
|
||||
if ((tw->protocol == 1) || (tw->protocol == 2)) netfromport(768);
|
||||
if ((tw->protocol == PROTOCOL_RLOGIN) || (tw->protocol == PROTOCOL_RSH)) netfromport(768);
|
||||
|
||||
/* NONO */
|
||||
#if 1
|
||||
if ( tw->protocol == 4 ) {
|
||||
if ( tw->protocol == PROTOCOL_SSH ) {
|
||||
// dummy makestream for ssh2...
|
||||
tw->port = makestream();
|
||||
tw->sshdata.ip = the_IP;
|
||||
|
@ -1211,7 +1211,7 @@ void ConnectionDataEvent(short port)
|
|||
else {
|
||||
cnt = netread(port,gReadspace,gBlocksize); /* BYU LSC */
|
||||
// urgent data isn't working right now, so this is turned off
|
||||
/* if ((screens[i].protocol >= 1) && (screens[i].protocol <= 3)) {
|
||||
/* if ((screens[i].protocol >= PROTOCOL_RLOGIN) && (screens[i].protocol <= PROTOCOL_REXEC)) {
|
||||
urgent = getUrgentFlag(port);
|
||||
if (urgent) {
|
||||
rlogin_parse( &screens[i], gReadspace, cnt);
|
||||
|
@ -1239,7 +1239,7 @@ void ConnectionDataEvent(short port)
|
|||
cnt--;
|
||||
st++;
|
||||
}
|
||||
if (/*screens[i].protocol != 4*/ true ) // ssh handles differently
|
||||
if (/*screens[i].protocol != PROTOCOL_SSH*/ true ) // ssh handles differently
|
||||
parse( &screens[i], st, cnt); /* BYU LSC */
|
||||
else {
|
||||
screens[i].jsNoFlush = 1; // RAB BetterTelnet 2.0b4
|
||||
|
@ -1404,7 +1404,7 @@ void removeport(WindRecPtr tw)
|
|||
if (tw->curgraph >= 0)
|
||||
detachGraphics( tw->curgraph); /* Detach the Tek screen */
|
||||
|
||||
if (tw->protocol == 4) {
|
||||
if (tw->protocol == PROTOCOL_SSH) {
|
||||
ssh_glue_close(tw);
|
||||
}
|
||||
|
||||
|
|
|
@ -1455,10 +1455,10 @@ void HandleMenuCommand( long mResult, short modifiers)
|
|||
}
|
||||
screens[scrn].echo = !screens[scrn].echo; /* toggle */
|
||||
if (screens[scrn].echo) { /* LOCAL ECHO */
|
||||
if (!(modifiers & optionKey) && (screens[scrn].protocol == 0))
|
||||
if (!(modifiers & optionKey) && (screens[scrn].protocol == PROTOCOL_TELNET))
|
||||
send_dont(screens[scrn].port,1);
|
||||
} else { /* REMOTE ECHO */
|
||||
if (!(modifiers & optionKey) && (screens[scrn].protocol == 0))
|
||||
if (!(modifiers & optionKey) && (screens[scrn].protocol == PROTOCOL_TELNET))
|
||||
send_do(screens[scrn].port,1);
|
||||
}
|
||||
CheckItem(myMenus[Emul], theItem, screens[scrn].echo);
|
||||
|
|
|
@ -405,7 +405,7 @@ short netread(short pnum, void *buffer, short n)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum); /* BYU */
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
reqdamt = 0;
|
||||
|
@ -518,7 +518,7 @@ short netwrite(short pnum, void *buffer, short nsend)
|
|||
if (i < 0) return Rnetwrite(pnum, buffer, nsend);
|
||||
|
||||
/* NONO */
|
||||
if ( screens[i].protocol == 4 ) {
|
||||
if ( screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
short n = nsend;
|
||||
|
@ -550,7 +550,7 @@ short netwrite(short pnum, void *buffer, short nsend)
|
|||
return nsend;
|
||||
}
|
||||
/*
|
||||
if (screens[i].protocol == 4) {
|
||||
if (screens[i].protocol == PROTOCOL_SSH) {
|
||||
ssh_glue_write(&screens[i], buffer, nsend);
|
||||
return nsend;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ short Rnetwrite(short pnum, void *buffer, short nsend)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
//TRACE(PRINTF("### Rnetwrite\n"));
|
||||
//TRACEN(DUMP("Rnetwrite\n", buffer, nsend));
|
||||
return nsend;
|
||||
|
@ -706,7 +706,7 @@ short netpush(short pnum)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
TRACEN(PRINTF("netpush\n"));
|
||||
|
@ -760,7 +760,7 @@ short netqlen(short pnum)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
TRACEN(PRINTF("netqlen\n"));
|
||||
|
@ -802,7 +802,7 @@ short netroom(short pnum)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
TRACEN(PRINTF("netroom\n"));
|
||||
|
@ -878,7 +878,7 @@ short netgetport(short pnum)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
TRACEN(PRINTF("netgetport\n"));
|
||||
// FIXME: this is completely wrong...
|
||||
|
@ -925,7 +925,7 @@ short netest(short pnum)
|
|||
|
||||
/* NONO */
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
TRACEN(PRINTF("netest\n"));
|
||||
|
@ -1101,7 +1101,7 @@ short netclose(short pnum)
|
|||
|
||||
|
||||
/* NONO */
|
||||
if ( (i = WindByPort(pnum)) >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( (i = WindByPort(pnum)) >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
TRACEN(PRINTF("netclose\n"));
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ short netabort(short pnum)
|
|||
if ((p = streams[pnum]) != NULL) /* something there */
|
||||
{
|
||||
i = WindByPort(pnum);
|
||||
if ( i >= 0 && screens[i].protocol == 4 ) {
|
||||
if ( i >= 0 && screens[i].protocol == PROTOCOL_SSH ) {
|
||||
WindRec *wind = &screens[i];
|
||||
lshcontext *context = (lshcontext *)wind->sshdata.context;
|
||||
if (context) {
|
||||
|
|
|
@ -183,7 +183,7 @@ void SendCRAsIfTyped(struct WindRec *tw)
|
|||
if (tw->echo)
|
||||
parse(tw,(unsigned char *) "\012\015",2); /* BYU LSC */
|
||||
|
||||
if ((tw->protocol >= 1) && (tw->protocol <= 4)) { // for rlogin/rsh, ssh
|
||||
if ((tw->protocol >= PROTOCOL_RLOGIN) && (tw->protocol <= PROTOCOL_SSH)) { // for rlogin/rsh, ssh
|
||||
netwrite(tw->port,"\015",1);
|
||||
return;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ void parse (struct WindRec *tw, unsigned char *st, short cnt)
|
|||
|
||||
if (!tw->eightbit) { /* BYU 2.4.10 */
|
||||
while (st < mark) { /* BYU 2.4.10 */
|
||||
if ((*st == IAC) && (tw->protocol == 0)) // RAB BetterTelnet 2.0b2
|
||||
if ((*st == IAC) && (tw->protocol == PROTOCOL_TELNET)) // RAB BetterTelnet 2.0b2
|
||||
break; /* BYU 2.4.10 */
|
||||
else { /* BYU 2.4.10 */
|
||||
*st &= 0x7f; /* BYU 2.4.10 */
|
||||
|
@ -520,7 +520,7 @@ void parse (struct WindRec *tw, unsigned char *st, short cnt)
|
|||
if (st < mark)
|
||||
switch (*st) {
|
||||
case TEL_IAC: /* telnet IAC */
|
||||
if (tw->protocol == 0) tw->telstate = IACFOUND; // RAB BetterTelnet 2.0b2
|
||||
if (tw->protocol == PROTOCOL_TELNET) tw->telstate = IACFOUND; // RAB BetterTelnet 2.0b2
|
||||
st++;
|
||||
break;
|
||||
case GS:
|
||||
|
@ -563,7 +563,7 @@ void SendNAWSinfo(WindRec *s, short horiz, short vert)
|
|||
char blah[20];
|
||||
unsigned char height, width;
|
||||
|
||||
if (s->protocol != 0) return;
|
||||
if (s->protocol != PROTOCOL_TELNET) return;
|
||||
|
||||
height = vert & 0xff;
|
||||
width = horiz & 0xff;
|
||||
|
@ -706,9 +706,9 @@ void telnet_send_initial_options(WindRec *tw)
|
|||
|
||||
// RAB BetterTelnet 2.0b2 - revised to support multiple protocols
|
||||
|
||||
if ((tw->protocol >= 1) && (tw->protocol <= 3)) { // initial rlogin stuff
|
||||
if ((tw->protocol >= PROTOCOL_RLOGIN) && (tw->protocol <= PROTOCOL_REXEC)) { // initial rlogin stuff
|
||||
netwrite(tw->port, "\000", 1);
|
||||
if ((tw->protocol == 3) || (!tw->clientuser[0]))
|
||||
if ((tw->protocol == PROTOCOL_REXEC) || (!tw->clientuser[0]))
|
||||
// rexec sends username, rlogin/rsh need client username
|
||||
// but we use server username if we don't have a client
|
||||
// username...
|
||||
|
@ -716,12 +716,12 @@ void telnet_send_initial_options(WindRec *tw)
|
|||
else
|
||||
netwrite(tw->port, &tw->clientuser[1], tw->clientuser[0]);
|
||||
netwrite(tw->port, "\000", 1);
|
||||
if (tw->protocol == 3) // rexec sends password, rlogin/rsh send server username
|
||||
if (tw->protocol == PROTOCOL_REXEC) // rexec sends password, rlogin/rsh send server username
|
||||
netwrite(tw->port, &tw->password[1], tw->password[0]);
|
||||
else
|
||||
netwrite (tw->port, &tw->username[1], tw->username[0]);
|
||||
netwrite(tw->port, "\000", 1);
|
||||
if (tw->protocol == 1) { // rlogin sends terminal type & speed, rsh/rexec send command
|
||||
if (tw->protocol == PROTOCOL_RLOGIN) { // rlogin sends terminal type & speed, rsh/rexec send command
|
||||
netwrite(tw->port, &tw->answerback[1], tw->answerback[0]);
|
||||
netwrite(tw->port, "/9600\000", 6);
|
||||
} else {
|
||||
|
@ -733,12 +733,12 @@ void telnet_send_initial_options(WindRec *tw)
|
|||
return;
|
||||
}
|
||||
|
||||
if (tw->protocol == 4) { // initial ssh stuff
|
||||
if (tw->protocol == PROTOCOL_SSH) { // initial ssh stuff
|
||||
ssh_glue_initial(tw);
|
||||
tw->echo = 0; // NO local echo for ssh either!
|
||||
tw->Usga = 1;
|
||||
// return;
|
||||
} else if (tw->protocol != 0) {
|
||||
} else if (tw->protocol != PROTOCOL_TELNET) {
|
||||
tw->echo = 1;
|
||||
tw->Usga = 1;
|
||||
return;
|
||||
|
@ -754,7 +754,7 @@ void telnet_send_initial_options(WindRec *tw)
|
|||
}
|
||||
}
|
||||
|
||||
if (tw->protocol == 4) {
|
||||
if (tw->protocol == PROTOCOL_SSH) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue