netutils/ftpd, examples/ftpd: code cleanup and nxstyle
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
parent
31f52a1971
commit
eceaeb926a
@ -36,7 +36,7 @@
|
||||
#define __APPS_EXAMPLES_FTPD_FTPD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
@ -48,7 +48,9 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* CONFIG_EXAMPLES_FTPD_PRIO - Priority of the FTP daemon.
|
||||
* Default: SCHED_PRIORITY_DEFAULT
|
||||
* CONFIG_EXAMPLES_FTPD_STACKSIZE - Stack size allocated for the
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/telnetd/shell.c
|
||||
* examples/ftpd/ftpd_main.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -90,6 +90,7 @@ struct ftpd_globals_s g_ftpdglob;
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fptd_netinit
|
||||
****************************************************************************/
|
||||
@ -153,7 +154,7 @@ static void ftpd_accounts(FTPD_SESSION handle)
|
||||
account = &g_ftpdaccounts[i];
|
||||
|
||||
printf("%d. %s account: USER=%s PASSWORD=%s HOME=%s\n", i + 1,
|
||||
(account->flags & FTPD_ACCOUNTFLAG_SYSTEM) != 0 ? "Root" : "User",
|
||||
(account->flags & FTPD_ACCOUNTFLAG_SYSTEM) ? "Root" : "User",
|
||||
(!account->user) ? "(none)" : account->user,
|
||||
(!account->password) ? "(none)" : account->password,
|
||||
(!account->home) ? "(none)" : account->home);
|
||||
@ -214,7 +215,8 @@ int ftpd_daemon(int s_argc, char **s_argv)
|
||||
|
||||
if (ret != -ETIMEDOUT)
|
||||
{
|
||||
printf("FTP daemon [%d] ftpd_session returned %d\n", g_ftpdglob.pid, ret);
|
||||
printf("FTP daemon [%d] ftpd_session returned %d\n",
|
||||
g_ftpdglob.pid, ret);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,6 +234,7 @@ int ftpd_daemon(int s_argc, char **s_argv)
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ftpd_main
|
||||
****************************************************************************/
|
||||
@ -242,7 +245,6 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
if (!g_ftpdglob.initialized)
|
||||
{
|
||||
|
||||
/* Bring up the network */
|
||||
|
||||
printf("Initializing the network\n");
|
||||
@ -263,6 +265,7 @@ int main(int argc, FAR char *argv[])
|
||||
printf("Waiting for FTP daemon [%d] to stop\n", g_ftpdglob.pid);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!g_ftpdglob.running)
|
||||
{
|
||||
printf("Starting the FTP daemon\n");
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Telnet daemon
|
||||
|
||||
ifeq ($(CONFIG_NET_TCP),y)
|
||||
CSRCS = ftpd.c
|
||||
endif
|
||||
|
@ -1910,9 +1910,7 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype)
|
||||
|
||||
if (cmdtype == 0)
|
||||
{
|
||||
/* Read from the file.
|
||||
* Read returns the error condition via errno.
|
||||
*/
|
||||
/* Read from the file. */
|
||||
|
||||
rdbytes = read(session->fd, session->data.buffer, wantsize);
|
||||
if (rdbytes < 0)
|
||||
@ -2384,7 +2382,7 @@ static int fptd_listscan(FAR struct ftpd_session_s *session, FAR char *path,
|
||||
if (!dir)
|
||||
{
|
||||
int errval = errno;
|
||||
nerr("ERROR: dir() failed: %d\n", errval);
|
||||
nerr("ERROR: opendir() failed: %d\n", errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
@ -3557,10 +3555,10 @@ static int ftpd_command_size(FAR struct ftpd_session_s *session)
|
||||
}
|
||||
else if (!S_ISREG(st.st_mode))
|
||||
{
|
||||
ret = ftpd_response(session->cmd.sd, session->txtimeout,
|
||||
ret = -EPERM;
|
||||
ftpd_response(session->cmd.sd, session->txtimeout,
|
||||
g_respfmt2, 550, ' ', session->param,
|
||||
": not a regular file.");
|
||||
ret = -EPERM;
|
||||
goto errout_with_abspath;
|
||||
}
|
||||
|
||||
@ -3673,9 +3671,9 @@ static int ftpd_command_rnto(FAR struct ftpd_session_s *session)
|
||||
|
||||
if (!session->renamefrom)
|
||||
{
|
||||
return ftpd_response(session->cmd.sd, session->txtimeout,
|
||||
ftpd_response(session->cmd.sd, session->txtimeout,
|
||||
g_respfmt1, 550, ' ', "RNTO error !");
|
||||
return ret;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = ftpd_getpath(session, session->param, &abspath, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user