diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-19 14:52:26 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-19 14:52:26 +0000 |
commit | 54e3d1f00d161ee6713d9f8795fe54ad3af61122 (patch) | |
tree | 8b2deaa360da113b349109fe6729ffd45a58e03c | |
parent | f24cdf1554a4481bf7c86eb167d62dc7c67f8026 (diff) | |
download | busybox-w32-54e3d1f00d161ee6713d9f8795fe54ad3af61122.tar.gz busybox-w32-54e3d1f00d161ee6713d9f8795fe54ad3af61122.tar.bz2 busybox-w32-54e3d1f00d161ee6713d9f8795fe54ad3af61122.zip |
telnet: finish style cleanup bits
-rw-r--r-- | networking/telnet.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/networking/telnet.c b/networking/telnet.c index 82dbb588d..cd88a9b3d 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -72,7 +72,8 @@ struct globals { | |||
72 | int win_width, win_height; | 72 | int win_width, win_height; |
73 | #endif | 73 | #endif |
74 | /* same buffer used both for network and console read/write */ | 74 | /* same buffer used both for network and console read/write */ |
75 | char buf[DATABUFSIZE]; /* allocating so static size is smaller */ | 75 | char buf[DATABUFSIZE]; |
76 | /* buffer to handle telnet negotiations */ | ||
76 | char iacbuf[IACBUFSIZE]; | 77 | char iacbuf[IACBUFSIZE]; |
77 | struct termios termios_def; | 78 | struct termios termios_def; |
78 | struct termios termios_raw; | 79 | struct termios termios_raw; |
@@ -97,8 +98,7 @@ static void iacflush(void) | |||
97 | 98 | ||
98 | #define write_str(fd, str) write(fd, str, sizeof(str) - 1) | 99 | #define write_str(fd, str) write(fd, str, sizeof(str) - 1) |
99 | 100 | ||
100 | static void /* buffer to handle telnet negotiations */ | 101 | static void doexit(int ev) |
101 | doexit(int ev) | ||
102 | { | 102 | { |
103 | cookmode(); | 103 | cookmode(); |
104 | exit(ev); | 104 | exit(ev); |
@@ -151,6 +151,7 @@ static void conescape(void) | |||
151 | G.gotsig = 0; | 151 | G.gotsig = 0; |
152 | 152 | ||
153 | } | 153 | } |
154 | |||
154 | static void handlenetoutput(int len) | 155 | static void handlenetoutput(int len) |
155 | { | 156 | { |
156 | /* here we could do smart tricks how to handle 0xFF:s in output | 157 | /* here we could do smart tricks how to handle 0xFF:s in output |
@@ -191,7 +192,6 @@ static void handlenetoutput(int len) | |||
191 | write(G.netfd, outbuf, j); | 192 | write(G.netfd, outbuf, j); |
192 | } | 193 | } |
193 | 194 | ||
194 | |||
195 | static void handlenetinput(int len) | 195 | static void handlenetinput(int len) |
196 | { | 196 | { |
197 | int i; | 197 | int i; |
@@ -266,15 +266,11 @@ static void handlenetinput(int len) | |||
266 | write(1, G.buf, len); | 266 | write(1, G.buf, len); |
267 | } | 267 | } |
268 | 268 | ||
269 | |||
270 | /* ******************************* */ | ||
271 | |||
272 | static void putiac(int c) | 269 | static void putiac(int c) |
273 | { | 270 | { |
274 | G.iacbuf[G.iaclen++] = c; | 271 | G.iacbuf[G.iaclen++] = c; |
275 | } | 272 | } |
276 | 273 | ||
277 | |||
278 | static void putiac2(byte wwdd, byte c) | 274 | static void putiac2(byte wwdd, byte c) |
279 | { | 275 | { |
280 | if (G.iaclen + 3 > IACBUFSIZE) | 276 | if (G.iaclen + 3 > IACBUFSIZE) |
@@ -354,24 +350,17 @@ static void putiac_naws(byte c, int x, int y) | |||
354 | } | 350 | } |
355 | #endif | 351 | #endif |
356 | 352 | ||
357 | /* void putiacstring (subneg strings) */ | ||
358 | |||
359 | /* ******************************* */ | ||
360 | |||
361 | static char const escapecharis[] = "\r\nEscape character is "; | 353 | static char const escapecharis[] = "\r\nEscape character is "; |
362 | 354 | ||
363 | static void setConMode(void) | 355 | static void setConMode(void) |
364 | { | 356 | { |
365 | if (G.telflags & UF_ECHO) | 357 | if (G.telflags & UF_ECHO) { |
366 | { | ||
367 | if (G.charmode == CHM_TRY) { | 358 | if (G.charmode == CHM_TRY) { |
368 | G.charmode = CHM_ON; | 359 | G.charmode = CHM_ON; |
369 | printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis); | 360 | printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis); |
370 | rawmode(); | 361 | rawmode(); |
371 | } | 362 | } |
372 | } | 363 | } else { |
373 | else | ||
374 | { | ||
375 | if (G.charmode != CHM_OFF) { | 364 | if (G.charmode != CHM_OFF) { |
376 | G.charmode = CHM_OFF; | 365 | G.charmode = CHM_OFF; |
377 | printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis); | 366 | printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis); |
@@ -380,8 +369,6 @@ static void setConMode(void) | |||
380 | } | 369 | } |
381 | } | 370 | } |
382 | 371 | ||
383 | /* ******************************* */ | ||
384 | |||
385 | static void will_charmode(void) | 372 | static void will_charmode(void) |
386 | { | 373 | { |
387 | G.charmode = CHM_TRY; | 374 | G.charmode = CHM_TRY; |
@@ -404,8 +391,6 @@ static void do_linemode(void) | |||
404 | iacflush(); | 391 | iacflush(); |
405 | } | 392 | } |
406 | 393 | ||
407 | /* ******************************* */ | ||
408 | |||
409 | static void to_notsup(char c) | 394 | static void to_notsup(char c) |
410 | { | 395 | { |
411 | if (G.telwish == WILL) | 396 | if (G.telwish == WILL) |
@@ -517,11 +502,7 @@ static void telopt(byte c) | |||
517 | } | 502 | } |
518 | } | 503 | } |
519 | 504 | ||
520 | |||
521 | /* ******************************* */ | ||
522 | |||
523 | /* subnegotiation -- ignore all (except TTYPE,NAWS) */ | 505 | /* subnegotiation -- ignore all (except TTYPE,NAWS) */ |
524 | |||
525 | static int subneg(byte c) | 506 | static int subneg(byte c) |
526 | { | 507 | { |
527 | switch (G.telstate) { | 508 | switch (G.telstate) { |
@@ -548,8 +529,6 @@ static int subneg(byte c) | |||
548 | return FALSE; | 529 | return FALSE; |
549 | } | 530 | } |
550 | 531 | ||
551 | /* ******************************* */ | ||
552 | |||
553 | static void fgotsig(int sig) | 532 | static void fgotsig(int sig) |
554 | { | 533 | { |
555 | G.gotsig = sig; | 534 | G.gotsig = sig; |
@@ -558,12 +537,14 @@ static void fgotsig(int sig) | |||
558 | 537 | ||
559 | static void rawmode(void) | 538 | static void rawmode(void) |
560 | { | 539 | { |
561 | if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_raw); | 540 | if (G.do_termios) |
541 | tcsetattr(0, TCSADRAIN, &G.termios_raw); | ||
562 | } | 542 | } |
563 | 543 | ||
564 | static void cookmode(void) | 544 | static void cookmode(void) |
565 | { | 545 | { |
566 | if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def); | 546 | if (G.do_termios) |
547 | tcsetattr(0, TCSADRAIN, &G.termios_def); | ||
567 | } | 548 | } |
568 | 549 | ||
569 | void BUG_telnet_globals_too_big(void); | 550 | void BUG_telnet_globals_too_big(void); |