netutils/ftpc: fix incorrect comments, nxstyle
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
parent
810398de01
commit
2a11d60246
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* apps/include/system/ftpc.h
|
||||
* apps/include/netutils/ftpc.h
|
||||
*
|
||||
* Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -53,6 +53,7 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_FTP_DEFTIMEO
|
||||
@ -88,6 +89,7 @@
|
||||
#endif
|
||||
|
||||
/* Interface arguments ******************************************************/
|
||||
|
||||
/* These definitions describe how a put operation should be performed */
|
||||
|
||||
#define FTPC_PUT_NORMAL 0 /* Just PUT the file on the server */
|
||||
@ -110,18 +112,15 @@
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This "handle" describes the FTP 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
|
||||
* 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).
|
||||
* in4, in6 - The IPv4 or IPv6 address of the FTP server (or the proxy)
|
||||
* for the FTP server.
|
||||
*/
|
||||
|
||||
union ftpc_sockaddr_u
|
||||
@ -181,8 +180,9 @@ extern "C"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Connection management ****************************************************/
|
||||
|
||||
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_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);
|
||||
time_t ftpc_filetime(SESSION handle, FAR const char *filename);
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# DHCP Daemn Library
|
||||
# DHCP Daemon Library
|
||||
|
||||
ifeq ($(CONFIG_NET_UDP),y)
|
||||
CSRCS = dhcpd.c
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# DHCP Daemn Library
|
||||
|
||||
ifeq ($(CONFIG_NET_TCP),y)
|
||||
# FTP connection management
|
||||
CSRCS += ftpc_connect.c ftpc_disconnect.c
|
||||
|
@ -47,26 +47,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@ -106,8 +86,9 @@ static int ftpc_restore(struct ftpc_session_s *session)
|
||||
|
||||
ftpc_reset(session);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
@ -136,15 +117,15 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
|
||||
/* Verify that we are still connected to the server */
|
||||
|
||||
if (!ftpc_sockconnected(&session->cmd))
|
||||
{
|
||||
nwarn("WARNING: Cmd channel is not connected\n");
|
||||
goto errout;
|
||||
}
|
||||
{
|
||||
nwarn("WARNING: Cmd channel is not connected\n");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Loop, reconnecting as necessary until the command is sent */
|
||||
|
||||
#ifdef CONFIG_FTP_AUTORECONNECT
|
||||
for (;;)
|
||||
for (; ; )
|
||||
#endif
|
||||
{
|
||||
/* Send the command */
|
||||
@ -159,6 +140,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
|
||||
ret = ftpc_sockflush(&session->cmd);
|
||||
}
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
/* Check for an error in sending the data */
|
||||
@ -167,7 +149,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
|
||||
{
|
||||
nerr("ERROR: Error sending cmd %s: %d\n", cmd, errno);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the response to the command */
|
||||
|
||||
@ -176,7 +158,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
|
||||
{
|
||||
nerr("ERROR: Error getting reply: %d\n", errno);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for "421 Service not available, closing control connection" */
|
||||
|
||||
@ -214,6 +196,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
|
||||
nwarn("WARNING: Failed to restore the connection");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -51,24 +51,12 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef void (*callback_t)(FAR const char *name, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* by concatenating the pathname of the directory and the pathname.
|
||||
* pathname does not start with a slash, it represents 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
|
||||
* 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,
|
||||
FAR void *arg)
|
||||
{
|
||||
char buffer[CONFIG_FTP_MAXPATH+1];
|
||||
char buffer[CONFIG_FTP_MAXPATH + 1];
|
||||
|
||||
/* Read every filename from the temporary file */
|
||||
|
||||
for (;;)
|
||||
for (; ; )
|
||||
{
|
||||
/* Read the next line from the file */
|
||||
|
||||
@ -145,6 +134,7 @@ static void ftpc_nlstparse(FAR FILE *instream, callback_t callback,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ninfo("File: %s\n", buffer);
|
||||
|
||||
/* 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
|
||||
* special knowledge about the home and current directories. But otherwise
|
||||
* 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");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
ninfo("nnames: %d\n", nnames);
|
||||
|
||||
/* Allocate and initialize a directory container */
|
||||
|
@ -32,26 +32,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -46,26 +46,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -46,26 +46,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private 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;
|
||||
char *oldcopy;
|
||||
|
@ -45,26 +45,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -76,6 +56,7 @@
|
||||
* Deletes the named directory on the remote server.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ftpc_rmdir(SESSION handle, FAR const char *path)
|
||||
{
|
||||
FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
|
||||
|
@ -47,26 +47,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -103,6 +83,7 @@ FAR char *ftpc_rpwd(SESSION handle)
|
||||
nwarn("WARNING: Opening quote not found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
start++;
|
||||
|
||||
end = strchr(start, '\"');
|
||||
@ -133,7 +114,7 @@ FAR char *ftpc_rpwd(SESSION handle)
|
||||
memcpy(pwd, start, len);
|
||||
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);
|
||||
|
||||
|
@ -56,22 +56,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -44,22 +44,6 @@
|
||||
|
||||
#include "ftpc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@ -139,6 +123,7 @@ FAR const char *ftpc_lpwd(void)
|
||||
{
|
||||
val = CONFIG_FTP_TMPDIR;
|
||||
}
|
||||
|
||||
return val;
|
||||
#else
|
||||
return CONFIG_FTP_TMPDIR;
|
||||
@ -178,8 +163,8 @@ void ftpc_stripcrlf(FAR char *str)
|
||||
* Name: ftpc_stripslash
|
||||
*
|
||||
* Description:
|
||||
* Strip any trailing slashes from a string (by overwriting them with NUL
|
||||
* characters.
|
||||
* Strip single trailing slash from a string (by overwriting it with NUL
|
||||
* character).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -223,7 +208,7 @@ FAR char *ftpc_dequote(FAR const char *str)
|
||||
/* Allocate space for a modifiable copy of the string */
|
||||
|
||||
len = strlen(str);
|
||||
allocstr = (FAR char*)malloc(len + 1);
|
||||
allocstr = (FAR char *)malloc(len + 1);
|
||||
if (allocstr)
|
||||
{
|
||||
/* Search the string */
|
||||
|
Loading…
x
Reference in New Issue
Block a user