terminal_width now also working over telnet.
This commit is contained in:
parent
d3104d6d78
commit
f36609e9b6
@ -180,8 +180,8 @@ void set_options() {
|
|||||||
telnet_willack[ECHO] = DO;
|
telnet_willack[ECHO] = DO;
|
||||||
/* The client can set a graphics mode */
|
/* The client can set a graphics mode */
|
||||||
telnet_willack[SGA] = DO;
|
telnet_willack[SGA] = DO;
|
||||||
/* The client should not change the window size */
|
/* The client should not change, but it should tell us its window size */
|
||||||
telnet_willack[NAWS] = DONT;
|
telnet_willack[NAWS] = DO;
|
||||||
/* The client should tell us its terminal type (very important) */
|
/* The client should tell us its terminal type (very important) */
|
||||||
telnet_willack[TTYPE] = DO;
|
telnet_willack[TTYPE] = DO;
|
||||||
/* No linemode */
|
/* No linemode */
|
||||||
@ -262,7 +262,7 @@ int main(int argc, char ** argv) {
|
|||||||
alarm(1);
|
alarm(1);
|
||||||
|
|
||||||
/* Let's do this */
|
/* Let's do this */
|
||||||
while (!feof(stdin) && !done) {
|
while (!feof(stdin) && done < 2) {
|
||||||
/* Get either IAC (start command) or a regular character (break, unless in SB mode) */
|
/* Get either IAC (start command) or a regular character (break, unless in SB mode) */
|
||||||
unsigned char i = getchar();
|
unsigned char i = getchar();
|
||||||
unsigned char opt = 0;
|
unsigned char opt = 0;
|
||||||
@ -278,7 +278,14 @@ int main(int argc, char ** argv) {
|
|||||||
* that this should be a terminal type */
|
* that this should be a terminal type */
|
||||||
alarm(0);
|
alarm(0);
|
||||||
strcpy(term, &sb[2]);
|
strcpy(term, &sb[2]);
|
||||||
goto ready;
|
done++;
|
||||||
|
}
|
||||||
|
else if (sb[0] == NAWS) {
|
||||||
|
/* This was a response to the NAWS command, meaning
|
||||||
|
* that this should be a window size */
|
||||||
|
alarm(0);
|
||||||
|
terminal_width = sb[2];
|
||||||
|
done++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NOP:
|
case NOP:
|
||||||
@ -326,7 +333,7 @@ int main(int argc, char ** argv) {
|
|||||||
break;
|
break;
|
||||||
case IAC:
|
case IAC:
|
||||||
/* IAC IAC? That's probably not right. */
|
/* IAC IAC? That's probably not right. */
|
||||||
done = 1;
|
done = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -338,7 +345,7 @@ int main(int argc, char ** argv) {
|
|||||||
* but only if it doesn't put us over
|
* but only if it doesn't put us over
|
||||||
* our limit; honestly, we shouldn't hit
|
* our limit; honestly, we shouldn't hit
|
||||||
* the limit, as we're only collecting characters
|
* the limit, as we're only collecting characters
|
||||||
* for a terminal type, but better safe than
|
* for a terminal type or window size, but better safe than
|
||||||
* sorry (and vulernable).
|
* sorry (and vulernable).
|
||||||
*/
|
*/
|
||||||
sb[sb_len] = i;
|
sb[sb_len] = i;
|
||||||
@ -361,7 +368,7 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
if(terminal_width > 80) terminal_width = 80;
|
if(terminal_width > 80) terminal_width = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Labels. Yes, and I used a goto.
|
* Labels. Yes, and I used a goto.
|
||||||
* If you're going to complain about this, you
|
* If you're going to complain about this, you
|
||||||
|
Loading…
Reference in New Issue
Block a user