mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-18 17:32:09 +08:00
system/telnet: Fix the style warning
and remove the unused code Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:

committed by
Masayuki Ishikawa

parent
58c3dbac95
commit
12863fbd52
@@ -53,16 +53,6 @@
|
|||||||
|
|
||||||
#include "nxterm_internal.h"
|
#include "nxterm_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* The NSH telnet console requires networking support (and TCP/IP) */
|
|
||||||
|
|
||||||
#ifndef CONFIG_NET
|
|
||||||
# undef CONFIG_NSH_TELNET
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@@ -76,7 +76,7 @@ static void telnetd_parse(FAR char *line, int len);
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static struct ptentry_s g_parsetab[] =
|
static const struct ptentry_s g_parsetab[] =
|
||||||
{
|
{
|
||||||
{"help", telnetd_help},
|
{"help", telnetd_help},
|
||||||
{"exit", telnetd_quit},
|
{"exit", telnetd_quit},
|
||||||
@@ -127,7 +127,7 @@ static void telnetd_quit(int argc, char **argv)
|
|||||||
|
|
||||||
static void telnetd_parse(FAR char *line, int len)
|
static void telnetd_parse(FAR char *line, int len)
|
||||||
{
|
{
|
||||||
struct ptentry_s *entry;
|
FAR const struct ptentry_s *entry;
|
||||||
FAR char *cmd;
|
FAR char *cmd;
|
||||||
FAR char *saveptr;
|
FAR char *saveptr;
|
||||||
|
|
||||||
@@ -140,7 +140,8 @@ static void telnetd_parse(FAR char *line, int len)
|
|||||||
|
|
||||||
for (entry = g_parsetab; entry->commandstr != NULL; entry++)
|
for (entry = g_parsetab; entry->commandstr != NULL; entry++)
|
||||||
{
|
{
|
||||||
if (strncmp(entry->commandstr, cmd, strlen(entry->commandstr)) == 0)
|
if (strncmp(entry->commandstr, cmd,
|
||||||
|
strlen(entry->commandstr)) == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -161,7 +162,7 @@ int telnetd_session(int argc, char *argv[])
|
|||||||
printf("uIP command shell -- NuttX style\n");
|
printf("uIP command shell -- NuttX style\n");
|
||||||
printf("Type '?' and return for help\n");
|
printf("Type '?' and return for help\n");
|
||||||
|
|
||||||
for (;;)
|
for (; ; )
|
||||||
{
|
{
|
||||||
printf(SHELL_PROMPT);
|
printf(SHELL_PROMPT);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@@ -188,7 +189,7 @@ static void telnetd_netinit(void)
|
|||||||
uint8_t mac[IFHWADDRLEN];
|
uint8_t mac[IFHWADDRLEN];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Many embedded network interfaces must have a software assigned MAC */
|
/* Many embedded network interfaces must have a software assigned MAC */
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_TELNETD_NOMAC
|
#ifdef CONFIG_EXAMPLES_TELNETD_NOMAC
|
||||||
mac[0] = 0x00;
|
mac[0] = 0x00;
|
||||||
|
@@ -56,9 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_FILE_STREAM
|
#ifndef CONFIG_FILE_STREAM
|
||||||
# undef CONFIG_NSH_TELNET
|
|
||||||
# undef CONFIG_NSH_FILE_APPS
|
# undef CONFIG_NSH_FILE_APPS
|
||||||
# undef CONFIG_NSH_TELNET
|
|
||||||
# undef CONFIG_NSH_CMDPARMS
|
# undef CONFIG_NSH_CMDPARMS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -33,16 +33,6 @@
|
|||||||
|
|
||||||
#include "nshlib/nshlib.h"
|
#include "nshlib/nshlib.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* The NSH telnet console requires networking support (and TCP/IP) */
|
|
||||||
|
|
||||||
#ifndef CONFIG_NET
|
|
||||||
# undef CONFIG_NSH_TELNET
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@@ -115,13 +115,17 @@ static const struct telnet_telopt_s g_telopts[] =
|
|||||||
|
|
||||||
static void send_local_input(char *buffer, int size)
|
static void send_local_input(char *buffer, int size)
|
||||||
{
|
{
|
||||||
static char crlf[] = { '\r', '\n' };
|
static char crlf[] =
|
||||||
|
{
|
||||||
|
'\r', '\n'
|
||||||
|
};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i != size; ++i)
|
for (i = 0; i != size; ++i)
|
||||||
{
|
{
|
||||||
/* If we got a CR or LF, replace with CRLF NOTE that usually you'd get a
|
/* If we got a CR or LF, replace with CRLF NOTE that usually you'd get
|
||||||
* CR in UNIX, but in raw mode we get LF instead (not sure why).
|
* a CR in UNIX, but in raw mode we get LF instead (not sure why).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (buffer[i] == '\r' || buffer[i] == '\n')
|
if (buffer[i] == '\r' || buffer[i] == '\n')
|
||||||
@@ -165,6 +169,7 @@ static void telnet_ev_send(int sock, const char *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "send() unexpectedly returned 0\n");
|
fprintf(stderr, "send() unexpectedly returned 0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
telnet_free(g_telnet);
|
telnet_free(g_telnet);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -199,6 +204,7 @@ static void _event_handler(struct telnet_s *telnet,
|
|||||||
/* Request to enable remote feature (or receipt) */
|
/* Request to enable remote feature (or receipt) */
|
||||||
|
|
||||||
case TELNET_EV_WILL:
|
case TELNET_EV_WILL:
|
||||||
|
|
||||||
/* We'll agree to turn off our echo if server wants us to stop */
|
/* We'll agree to turn off our echo if server wants us to stop */
|
||||||
|
|
||||||
if (ev->neg.telopt == TELNET_TELOPT_ECHO)
|
if (ev->neg.telopt == TELNET_TELOPT_ECHO)
|
||||||
@@ -230,6 +236,7 @@ static void _event_handler(struct telnet_s *telnet,
|
|||||||
/* Respond to TTYPE commands */
|
/* Respond to TTYPE commands */
|
||||||
|
|
||||||
case TELNET_EV_TTYPE:
|
case TELNET_EV_TTYPE:
|
||||||
|
|
||||||
/* Respond with our terminal type, if requested */
|
/* Respond with our terminal type, if requested */
|
||||||
|
|
||||||
if (ev->ttype.cmd == TELNET_TTYPE_SEND)
|
if (ev->ttype.cmd == TELNET_TTYPE_SEND)
|
||||||
@@ -251,6 +258,7 @@ static void _event_handler(struct telnet_s *telnet,
|
|||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
/* Ignore */
|
/* Ignore */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -262,10 +270,13 @@ static void show_usage(const char *progname, int exitcode)
|
|||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
fprintf(stderr, "\t%s <server-IP-addr> [<port>]\n", progname);
|
fprintf(stderr, "\t%s <server-IP-addr> [<port>]\n", progname);
|
||||||
fprintf(stderr, "Where:\n");
|
fprintf(stderr, "Where:\n");
|
||||||
fprintf(stderr, "\t<server-IP-addr> is the address of the Telnet server. Either\n");
|
fprintf(stderr,
|
||||||
|
"\t<server-IP-addr> is the address of the Telnet server. Either\n");
|
||||||
fprintf(stderr, "\t\tIPv4 form: ddd.ddd.ddd.ddd\n");
|
fprintf(stderr, "\t\tIPv4 form: ddd.ddd.ddd.ddd\n");
|
||||||
fprintf(stderr, "\t\tIPv6 form: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr, "\t<port> is the (optional) listening port of the Telnet server.\n");
|
"\t\tIPv6 form: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"\t<port> is the (optional) listening port of the Telnet server.\n");
|
||||||
fprintf(stderr, "\t\tDefault: %u\n", DEFAULT_PORT);
|
fprintf(stderr, "\t\tDefault: %u\n", DEFAULT_PORT);
|
||||||
exit(exitcode);
|
exit(exitcode);
|
||||||
}
|
}
|
||||||
@@ -286,7 +297,9 @@ int main(int argc, FAR char *argv[])
|
|||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
struct sockaddr_in ipv4;
|
struct sockaddr_in ipv4;
|
||||||
#endif
|
#endif
|
||||||
} server;
|
}
|
||||||
|
|
||||||
|
server;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
@@ -295,7 +308,9 @@ int main(int argc, FAR char *argv[])
|
|||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
struct sockaddr_in ipv4;
|
struct sockaddr_in ipv4;
|
||||||
#endif
|
#endif
|
||||||
} local;
|
}
|
||||||
|
|
||||||
|
local;
|
||||||
struct pollfd pfd[2];
|
struct pollfd pfd[2];
|
||||||
sa_family_t family;
|
sa_family_t family;
|
||||||
uint16_t addrlen;
|
uint16_t addrlen;
|
||||||
@@ -364,7 +379,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
/* Create server socket */
|
/* Create server socket */
|
||||||
|
|
||||||
sock = socket(family, SOCK_STREAM, 0);
|
sock = socket(family, SOCK_STREAM, 0);
|
||||||
if (sock < 0)
|
if (sock < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "socket() failed: %d\n", errno);
|
fprintf(stderr, "socket() failed: %d\n", errno);
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user