netutils/ftpc: fix incorrect comments, nxstyle

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
Juha Niskanen 2020-12-13 17:35:40 +02:00 committed by Xiang Xiao
parent 810398de01
commit 2a11d60246
12 changed files with 40 additions and 195 deletions

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* apps/include/system/ftpc.h * apps/include/netutils/ftpc.h
* *
* Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@ -53,6 +53,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
#ifndef CONFIG_FTP_DEFTIMEO #ifndef CONFIG_FTP_DEFTIMEO
@ -88,6 +89,7 @@
#endif #endif
/* Interface arguments ******************************************************/ /* Interface arguments ******************************************************/
/* These definitions describe how a put operation should be performed */ /* These definitions describe how a put operation should be performed */
#define FTPC_PUT_NORMAL 0 /* Just PUT the file on the server */ #define FTPC_PUT_NORMAL 0 /* Just PUT the file on the server */
@ -110,18 +112,15 @@
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
/* This "handle" describes the FTP session */ /* This "handle" describes the FTP session */
typedef FAR void *SESSION; typedef FAR void *SESSION;
/* This union provides information to connect to a host FTP server. /* This union provides socket address to connect to a host FTP server.
* *
* addr - The IPv4 or IPv6 address of the FTP server (or the proxy) for the FTP * in4, in6 - The IPv4 or IPv6 address of the FTP server (or the proxy)
* server. * for the FTP server.
* port - The port number on the FTP server to connect to (in host byte
* order). This is usually port 21 for FTP. You may set this
* value to zero to let FTPC select the default port number for
* you (it will use CONFIG_FTP_DEFPORT).
*/ */
union ftpc_sockaddr_u union ftpc_sockaddr_u
@ -181,8 +180,9 @@ extern "C"
#endif #endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Connection management ****************************************************/ /* Connection management ****************************************************/
SESSION ftpc_connect(FAR union ftpc_sockaddr_u *server); SESSION ftpc_connect(FAR union ftpc_sockaddr_u *server);
@ -201,7 +201,8 @@ int ftpc_rmdir(SESSION handle, FAR const char *path);
int ftpc_unlink(SESSION handle, FAR const char *path); int ftpc_unlink(SESSION handle, FAR const char *path);
int ftpc_chmod(SESSION handle, FAR const char *path, FAR const char *mode); int ftpc_chmod(SESSION handle, FAR const char *path, FAR const char *mode);
int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname); int ftpc_rename(SESSION handle, FAR const char *oldname,
FAR const char *newname);
off_t ftpc_filesize(SESSION handle, FAR const char *path); off_t ftpc_filesize(SESSION handle, FAR const char *path);
time_t ftpc_filetime(SESSION handle, FAR const char *filename); time_t ftpc_filetime(SESSION handle, FAR const char *filename);

View File

@ -35,7 +35,7 @@
include $(APPDIR)/Make.defs include $(APPDIR)/Make.defs
# DHCP Daemn Library # DHCP Daemon Library
ifeq ($(CONFIG_NET_UDP),y) ifeq ($(CONFIG_NET_UDP),y)
CSRCS = dhcpd.c CSRCS = dhcpd.c

View File

@ -35,8 +35,6 @@
include $(APPDIR)/Make.defs include $(APPDIR)/Make.defs
# DHCP Daemn Library
ifeq ($(CONFIG_NET_TCP),y) ifeq ($(CONFIG_NET_TCP),y)
# FTP connection management # FTP connection management
CSRCS += ftpc_connect.c ftpc_disconnect.c CSRCS += ftpc_connect.c ftpc_disconnect.c

View File

@ -47,26 +47,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -106,6 +86,7 @@ static int ftpc_restore(struct ftpc_session_s *session)
ftpc_reset(session); ftpc_reset(session);
} }
return ret; return ret;
} }
@ -144,7 +125,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
/* Loop, reconnecting as necessary until the command is sent */ /* Loop, reconnecting as necessary until the command is sent */
#ifdef CONFIG_FTP_AUTORECONNECT #ifdef CONFIG_FTP_AUTORECONNECT
for (;;) for (; ; )
#endif #endif
{ {
/* Send the command */ /* Send the command */
@ -159,6 +140,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
ret = ftpc_sockflush(&session->cmd); ret = ftpc_sockflush(&session->cmd);
} }
} }
va_end(ap); va_end(ap);
/* Check for an error in sending the data */ /* Check for an error in sending the data */
@ -214,6 +196,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
nwarn("WARNING: Failed to restore the connection"); nwarn("WARNING: Failed to restore the connection");
goto errout; goto errout;
} }
continue; continue;
} }
} }

View File

@ -51,24 +51,12 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
typedef void (*callback_t)(FAR const char *name, FAR void *arg); typedef void (*callback_t)(FAR const char *name, FAR void *arg);
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -111,8 +99,9 @@ static void ftpc_addname(FAR const char *name, FAR void *arg)
* sequence of pathnames. Each pathname is terminated by \r\n. * sequence of pathnames. Each pathname is terminated by \r\n.
* *
* If a pathname starts with a slash, it represents the pathname. If a * If a pathname starts with a slash, it represents the pathname. If a
* pathname does not start with a slash, it represents the pathname obtained * pathname does not start with a slash, it represents the pathname
* by concatenating the pathname of the directory and the pathname. * obtained by concatenating the pathname of the directory and the
* pathname.
* *
* IF NLST of directory /pub produces foo\r\nbar\r\n, it refers to the * IF NLST of directory /pub produces foo\r\nbar\r\n, it refers to the
* pathnames /pub/foo and /pub/bar. * pathnames /pub/foo and /pub/bar.
@ -122,11 +111,11 @@ static void ftpc_addname(FAR const char *name, FAR void *arg)
static void ftpc_nlstparse(FAR FILE *instream, callback_t callback, static void ftpc_nlstparse(FAR FILE *instream, callback_t callback,
FAR void *arg) FAR void *arg)
{ {
char buffer[CONFIG_FTP_MAXPATH+1]; char buffer[CONFIG_FTP_MAXPATH + 1];
/* Read every filename from the temporary file */ /* Read every filename from the temporary file */
for (;;) for (; ; )
{ {
/* Read the next line from the file */ /* Read the next line from the file */
@ -145,6 +134,7 @@ static void ftpc_nlstparse(FAR FILE *instream, callback_t callback,
{ {
break; break;
} }
ninfo("File: %s\n", buffer); ninfo("File: %s\n", buffer);
/* Perform the callback operation */ /* Perform the callback operation */
@ -265,7 +255,7 @@ static int ftpc_recvdir(FAR struct ftpc_session_s *session,
* expansion "~/xyz" and relative paths (abc/def) because we do have * expansion "~/xyz" and relative paths (abc/def) because we do have
* special knowledge about the home and current directories. But otherwise * special knowledge about the home and current directories. But otherwise
* the paths are expected to be pre-sanitized: No . or .. in paths, * the paths are expected to be pre-sanitized: No . or .. in paths,
* no '//' in paths, etc. * no multiple consecutive '/' in paths, etc.
* *
****************************************************************************/ ****************************************************************************/
@ -367,6 +357,7 @@ FAR struct ftpc_dirlist_s *ftpc_listdir(SESSION handle,
nwarn("WARNING: Nothing found in directory\n"); nwarn("WARNING: Nothing found in directory\n");
goto errout; goto errout;
} }
ninfo("nnames: %d\n", nnames); ninfo("nnames: %d\n", nnames);
/* Allocate and initialize a directory container */ /* Allocate and initialize a directory container */

View File

@ -32,26 +32,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/

View File

@ -46,26 +46,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/

View File

@ -46,26 +46,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -78,7 +58,8 @@
* *
****************************************************************************/ ****************************************************************************/
int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname) int ftpc_rename(SESSION handle, FAR const char *oldname,
FAR const char *newname)
{ {
FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle; FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
char *oldcopy; char *oldcopy;

View File

@ -45,26 +45,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -76,6 +56,7 @@
* Deletes the named directory on the remote server. * Deletes the named directory on the remote server.
* *
****************************************************************************/ ****************************************************************************/
int ftpc_rmdir(SESSION handle, FAR const char *path) int ftpc_rmdir(SESSION handle, FAR const char *path)
{ {
FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle; FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;

View File

@ -47,26 +47,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -103,6 +83,7 @@ FAR char *ftpc_rpwd(SESSION handle)
nwarn("WARNING: Opening quote not found\n"); nwarn("WARNING: Opening quote not found\n");
return NULL; return NULL;
} }
start++; start++;
end = strchr(start, '\"'); end = strchr(start, '\"');
@ -133,7 +114,7 @@ FAR char *ftpc_rpwd(SESSION handle)
memcpy(pwd, start, len); memcpy(pwd, start, len);
pwd[len] = '\0'; pwd[len] = '\0';
/* Remove any trailing slashes that the server may have added */ /* Remove any trailing slash that the server may have added */
ftpc_stripslash(pwd); ftpc_stripslash(pwd);

View File

@ -56,22 +56,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/

View File

@ -44,22 +44,6 @@
#include "ftpc_internal.h" #include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -139,6 +123,7 @@ FAR const char *ftpc_lpwd(void)
{ {
val = CONFIG_FTP_TMPDIR; val = CONFIG_FTP_TMPDIR;
} }
return val; return val;
#else #else
return CONFIG_FTP_TMPDIR; return CONFIG_FTP_TMPDIR;
@ -178,8 +163,8 @@ void ftpc_stripcrlf(FAR char *str)
* Name: ftpc_stripslash * Name: ftpc_stripslash
* *
* Description: * Description:
* Strip any trailing slashes from a string (by overwriting them with NUL * Strip single trailing slash from a string (by overwriting it with NUL
* characters. * character).
* *
****************************************************************************/ ****************************************************************************/
@ -223,7 +208,7 @@ FAR char *ftpc_dequote(FAR const char *str)
/* Allocate space for a modifiable copy of the string */ /* Allocate space for a modifiable copy of the string */
len = strlen(str); len = strlen(str);
allocstr = (FAR char*)malloc(len + 1); allocstr = (FAR char *)malloc(len + 1);
if (allocstr) if (allocstr)
{ {
/* Search the string */ /* Search the string */