diff --git a/include/netutils/ftpc.h b/include/netutils/ftpc.h index 64c16a87a..5b2dbab06 100644 --- a/include/netutils/ftpc.h +++ b/include/netutils/ftpc.h @@ -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 @@ -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); diff --git a/netutils/dhcpd/Makefile b/netutils/dhcpd/Makefile index b393b3297..515b7746a 100644 --- a/netutils/dhcpd/Makefile +++ b/netutils/dhcpd/Makefile @@ -35,7 +35,7 @@ include $(APPDIR)/Make.defs -# DHCP Daemn Library +# DHCP Daemon Library ifeq ($(CONFIG_NET_UDP),y) CSRCS = dhcpd.c diff --git a/netutils/ftpc/Makefile b/netutils/ftpc/Makefile index 2396a3519..bfa2cedd5 100644 --- a/netutils/ftpc/Makefile +++ b/netutils/ftpc/Makefile @@ -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 diff --git a/netutils/ftpc/ftpc_cmd.c b/netutils/ftpc/ftpc_cmd.c index d12a24bc4..ec85e5c63 100644 --- a/netutils/ftpc/ftpc_cmd.c +++ b/netutils/ftpc/ftpc_cmd.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; } } diff --git a/netutils/ftpc/ftpc_listdir.c b/netutils/ftpc/ftpc_listdir.c index 60ff3704f..213ed2268 100644 --- a/netutils/ftpc/ftpc_listdir.c +++ b/netutils/ftpc/ftpc_listdir.c @@ -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 */ diff --git a/netutils/ftpc/ftpc_login.c b/netutils/ftpc/ftpc_login.c index 6f9f53472..7691ae44d 100644 --- a/netutils/ftpc/ftpc_login.c +++ b/netutils/ftpc/ftpc_login.c @@ -32,26 +32,6 @@ #include "ftpc_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/netutils/ftpc/ftpc_mkdir.c b/netutils/ftpc/ftpc_mkdir.c index bd32121c3..15e93d390 100644 --- a/netutils/ftpc/ftpc_mkdir.c +++ b/netutils/ftpc/ftpc_mkdir.c @@ -46,26 +46,6 @@ #include "ftpc_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/netutils/ftpc/ftpc_rename.c b/netutils/ftpc/ftpc_rename.c index c5d735a7a..3b67671e9 100644 --- a/netutils/ftpc/ftpc_rename.c +++ b/netutils/ftpc/ftpc_rename.c @@ -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; diff --git a/netutils/ftpc/ftpc_rmdir.c b/netutils/ftpc/ftpc_rmdir.c index 5f78ef2b3..d9ddbed9c 100644 --- a/netutils/ftpc/ftpc_rmdir.c +++ b/netutils/ftpc/ftpc_rmdir.c @@ -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; diff --git a/netutils/ftpc/ftpc_rpwd.c b/netutils/ftpc/ftpc_rpwd.c index 5c8e49e4d..db4d21087 100644 --- a/netutils/ftpc/ftpc_rpwd.c +++ b/netutils/ftpc/ftpc_rpwd.c @@ -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); diff --git a/netutils/ftpc/ftpc_transfer.c b/netutils/ftpc/ftpc_transfer.c index b983a13fb..47f0d2e58 100644 --- a/netutils/ftpc/ftpc_transfer.c +++ b/netutils/ftpc/ftpc_transfer.c @@ -56,22 +56,6 @@ #include "ftpc_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/netutils/ftpc/ftpc_utils.c b/netutils/ftpc/ftpc_utils.c index 90793d1b8..8dca41a09 100644 --- a/netutils/ftpc/ftpc_utils.c +++ b/netutils/ftpc/ftpc_utils.c @@ -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 */