projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gzip cleanup part #8
[oweals/busybox.git]
/
networking
/
telnet.c
diff --git
a/networking/telnet.c
b/networking/telnet.c
index 05c7786ab335e4485cdf3c05f32d874a430e623f..e65b6918d8d9f8eb9df0a2b2142050d8f2a43bf7 100644
(file)
--- a/
networking/telnet.c
+++ b/
networking/telnet.c
@@
-34,10
+34,6
@@
#include <netinet/in.h>
#include "busybox.h"
#include <netinet/in.h>
#include "busybox.h"
-#if 0
-static const int DOTRACE = 1;
-#endif
-
#ifdef DOTRACE
#include <arpa/inet.h> /* for inet_ntoa()... */
#define TRACE(x, y) do { if (x) printf y; } while (0)
#ifdef DOTRACE
#include <arpa/inet.h> /* for inet_ntoa()... */
#define TRACE(x, y) do { if (x) printf y; } while (0)
@@
-45,24
+41,17
@@
static const int DOTRACE = 1;
#define TRACE(x, y)
#endif
#define TRACE(x, y)
#endif
-#if 0
-#define USE_POLL
-#include <sys/poll.h>
-#else
-#include <sys/time.h>
-#endif
-
#define DATABUFSIZE 128
#define IACBUFSIZE 128
#define DATABUFSIZE 128
#define IACBUFSIZE 128
-static const int CHM_TRY = 0;
-static const int CHM_ON = 1;
-static const int CHM_OFF = 2;
+enum {
+ CHM_TRY = 0,
+ CHM_ON = 1,
+ CHM_OFF = 2,
-static const int UF_ECHO = 0x01;
-static const int UF_SGA = 0x02;
+ UF_ECHO = 0x01,
+ UF_SGA = 0x02,
-enum {
TS_0 = 1,
TS_IAC = 2,
TS_OPT = 3,
TS_0 = 1,
TS_IAC = 2,
TS_OPT = 3,
@@
-99,7
+88,7
@@
struct Globalvars * Gptr;
#define G (*Gptr)
#endif
#define G (*Gptr)
#endif
-static
inline
void iacflush(void)
+static void iacflush(void)
{
write(G.netfd, G.iacbuf, G.iaclen);
G.iaclen = 0;
{
write(G.netfd, G.iacbuf, G.iaclen);
G.iaclen = 0;
@@
-114,7
+103,7
@@
static void telopt(byte c);
static int subneg(byte c);
/* Some globals */
static int subneg(byte c);
/* Some globals */
-static int one = 1;
+static
const
int one = 1;
#ifdef CONFIG_FEATURE_TELNET_TTYPE
static char *ttype;
#ifdef CONFIG_FEATURE_TELNET_TTYPE
static char *ttype;
@@
-196,9
+185,9
@@
static void handlenetoutput(int len)
* I don't agree.
* first - I cannot use programs like sz/rz
* second - the 0x0D is sent as one character and if the next
* I don't agree.
* first - I cannot use programs like sz/rz
* second - the 0x0D is sent as one character and if the next
- * char is 0x0A then it's eaten by a server side.
+ * char is 0x0A then it's eaten by a server side.
* third - whay doy you have to make 'many write()s'?
* third - whay doy you have to make 'many write()s'?
- * I don't understand.
+ * I don't understand.
* So I implemented it. It's realy useful for me. I hope that
* others people will find it interesting to.
*/
* So I implemented it. It's realy useful for me. I hope that
* others people will find it interesting to.
*/
@@
-216,12
+205,12
@@
static void handlenetoutput(int len)
}
outbuf[j++] = *p;
if (*p == 0xff)
}
outbuf[j++] = *p;
if (*p == 0xff)
- outbuf[j++] = 0xff;
+
outbuf[j++] = 0xff;
else if (*p == 0x0d)
else if (*p == 0x0d)
- outbuf[j++] = 0x00;
+
outbuf[j++] = 0x00;
}
if (j > 0 )
}
if (j > 0 )
- write(G.netfd, outbuf, j);
+
write(G.netfd, outbuf, j);
}
}
@@
-302,7
+291,7
@@
static void handlenetinput(int len)
/* ******************************* */
/* ******************************* */
-static
inline
void putiac(int c)
+static void putiac(int c)
{
G.iacbuf[G.iaclen++] = c;
}
{
G.iacbuf[G.iaclen++] = c;
}
@@
-318,17
+307,6
@@
static void putiac2(byte wwdd, byte c)
putiac(c);
}
putiac(c);
}
-#if 0
-static void putiac1(byte c)
-{
- if (G.iaclen + 2 > IACBUFSIZE)
- iacflush();
-
- putiac(IAC);
- putiac(c);
-}
-#endif
-
#ifdef CONFIG_FEATURE_TELNET_TTYPE
static void putiac_subopt(byte c, char *str)
{
#ifdef CONFIG_FEATURE_TELNET_TTYPE
static void putiac_subopt(byte c, char *str)
{
@@
-342,7
+320,7
@@
static void putiac_subopt(byte c, char *str)
putiac(c);
putiac(0);
putiac(c);
putiac(0);
- while(*str)
+ while
(*str)
putiac(*str++);
putiac(IAC);
putiac(*str++);
putiac(IAC);
@@
-365,12
+343,12
@@
static void putiac_subopt_autologin(void)
putiac(TELQUAL_IS);
putiac(NEW_ENV_VAR);
putiac(TELQUAL_IS);
putiac(NEW_ENV_VAR);
- while(*user)
+ while
(*user)
putiac(*user++);
putiac(NEW_ENV_VALUE);
putiac(*user++);
putiac(NEW_ENV_VALUE);
- while(*autologin)
+ while
(*autologin)
putiac(*autologin++);
putiac(IAC);
putiac(*autologin++);
putiac(IAC);
@@
-450,13
+428,13
@@
static void do_linemode(void)
/* ******************************* */
/* ******************************* */
-static
inline
void to_notsup(char c)
+static void to_notsup(char c)
{
if (G.telwish == WILL) putiac2(DONT, c);
else if (G.telwish == DO) putiac2(WONT, c);
}
{
if (G.telwish == WILL) putiac2(DONT, c);
else if (G.telwish == DO) putiac2(WONT, c);
}
-static
inline
void to_echo(void)
+static void to_echo(void)
{
/* if server requests ECHO, don't agree */
if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; }
{
/* if server requests ECHO, don't agree */
if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; }
@@
-483,7
+461,7
@@
static inline void to_echo(void)
WriteCS(1, "\r\n"); /* sudden modec */
}
WriteCS(1, "\r\n"); /* sudden modec */
}
-static
inline
void to_sga(void)
+static void to_sga(void)
{
/* daemon always sends will/wont, client do/dont */
{
/* daemon always sends will/wont, client do/dont */
@@
-505,7
+483,7
@@
static inline void to_sga(void)
}
#ifdef CONFIG_FEATURE_TELNET_TTYPE
}
#ifdef CONFIG_FEATURE_TELNET_TTYPE
-static
inline
void to_ttype(void)
+static void to_ttype(void)
{
/* Tell server we will (or won't) do TTYPE */
{
/* Tell server we will (or won't) do TTYPE */
@@
-519,7
+497,7
@@
static inline void to_ttype(void)
#endif
#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
#endif
#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
-static
inline
void to_new_environ(void)
+static void to_new_environ(void)
{
/* Tell server we will (or will not) do AUTOLOGIN */
{
/* Tell server we will (or will not) do AUTOLOGIN */
@@
-533,7
+511,7
@@
static inline void to_new_environ(void)
#endif
#ifdef CONFIG_FEATURE_AUTOWIDTH
#endif
#ifdef CONFIG_FEATURE_AUTOWIDTH
-static
inline
void to_naws(void)
+static void to_naws(void)
{
/* Tell server we will do NAWS */
putiac2(WILL, TELOPT_NAWS);
{
/* Tell server we will do NAWS */
putiac2(WILL, TELOPT_NAWS);
@@
-613,7
+591,7
@@
static void cookmode(void)
if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def);
}
if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def);
}
-
extern
int telnet_main(int argc, char** argv)
+int telnet_main(int argc, char** argv)
{
int len;
struct sockaddr_in s_in;
{
int len;
struct sockaddr_in s_in;
@@
-629,7
+607,7
@@
extern int telnet_main(int argc, char** argv)
#endif
#ifdef CONFIG_FEATURE_TELNET_TTYPE
#endif
#ifdef CONFIG_FEATURE_TELNET_TTYPE
- ttype = getenv("TERM");
+
ttype = getenv("TERM");
#endif
memset(&G, 0, sizeof G);
#endif
memset(&G, 0, sizeof G);
@@
-645,7
+623,7
@@
extern int telnet_main(int argc, char** argv)
bb_show_usage();
#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
bb_show_usage();
#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
- if (1 &
bb_getopt_ulflags
(argc, argv, "al:", &autologin))
+ if (1 &
getopt32
(argc, argv, "al:", &autologin))
autologin = getenv("USER");
if (optind < argc) {
autologin = getenv("USER");
if (optind < argc) {
@@
-661,7
+639,7
@@
extern int telnet_main(int argc, char** argv)
s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23);
#endif
s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23);
#endif
- G.netfd = xconnect(&s_in);
+ G.netfd = xconnect
_tcp_v4
(&s_in);
setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one);
setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one);
@@
-734,11
+712,3
@@
extern int telnet_main(int argc, char** argv)
}
}
}
}
}
}
-
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/