summaryrefslogtreecommitdiff
path: root/apps/netutils
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-06-02 23:45:31 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-06-02 23:45:31 +0000
commit80d5b281209708972a1e484f10f9b1cf74868ea4 (patch)
tree055ca499f7321151291d83afc6a5585c0bdde1ae /apps/netutils
parent944bf89644559cd2ae021122451ff5d0a740cb85 (diff)
downloadnuttx-80d5b281209708972a1e484f10f9b1cf74868ea4.tar.gz
nuttx-80d5b281209708972a1e484f10f9b1cf74868ea4.tar.bz2
nuttx-80d5b281209708972a1e484f10f9b1cf74868ea4.zip
More FTP client debug fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3662 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/netutils')
-rw-r--r--apps/netutils/ftpc/ftpc_cdup.c2
-rw-r--r--apps/netutils/ftpc/ftpc_chdir.c2
-rw-r--r--apps/netutils/ftpc/ftpc_chmod.c2
-rw-r--r--apps/netutils/ftpc/ftpc_cmd.c4
-rw-r--r--apps/netutils/ftpc/ftpc_config.h72
-rw-r--r--apps/netutils/ftpc/ftpc_connect.c5
-rw-r--r--apps/netutils/ftpc/ftpc_disconnect.c2
-rw-r--r--apps/netutils/ftpc/ftpc_filesize.c2
-rw-r--r--apps/netutils/ftpc/ftpc_filetime.c2
-rw-r--r--apps/netutils/ftpc/ftpc_getfile.c2
-rw-r--r--apps/netutils/ftpc/ftpc_getreply.c2
-rw-r--r--apps/netutils/ftpc/ftpc_help.c2
-rw-r--r--apps/netutils/ftpc/ftpc_idle.c2
-rw-r--r--apps/netutils/ftpc/ftpc_internal.h6
-rw-r--r--apps/netutils/ftpc/ftpc_listdir.c2
-rw-r--r--apps/netutils/ftpc/ftpc_login.c2
-rw-r--r--apps/netutils/ftpc/ftpc_mkdir.c2
-rw-r--r--apps/netutils/ftpc/ftpc_noop.c2
-rw-r--r--apps/netutils/ftpc/ftpc_putfile.c2
-rw-r--r--apps/netutils/ftpc/ftpc_pwd.c34
-rw-r--r--apps/netutils/ftpc/ftpc_quit.c2
-rw-r--r--apps/netutils/ftpc/ftpc_rename.c2
-rw-r--r--apps/netutils/ftpc/ftpc_response.c2
-rw-r--r--apps/netutils/ftpc/ftpc_rmdir.c2
-rw-r--r--apps/netutils/ftpc/ftpc_socket.c6
-rw-r--r--apps/netutils/ftpc/ftpc_unlink.c2
-rw-r--r--apps/netutils/ftpc/ftpc_utils.c2
27 files changed, 134 insertions, 35 deletions
diff --git a/apps/netutils/ftpc/ftpc_cdup.c b/apps/netutils/ftpc/ftpc_cdup.c
index 323033390..a5f22bbc2 100644
--- a/apps/netutils/ftpc/ftpc_cdup.c
+++ b/apps/netutils/ftpc/ftpc_cdup.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_chdir.c b/apps/netutils/ftpc/ftpc_chdir.c
index ddf6452c4..0bc47ddf8 100644
--- a/apps/netutils/ftpc/ftpc_chdir.c
+++ b/apps/netutils/ftpc/ftpc_chdir.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_chmod.c b/apps/netutils/ftpc/ftpc_chmod.c
index 332df2b0c..f349edb09 100644
--- a/apps/netutils/ftpc/ftpc_chmod.c
+++ b/apps/netutils/ftpc/ftpc_chmod.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <debug.h>
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_cmd.c b/apps/netutils/ftpc/ftpc_cmd.c
index 277899433..ec89050ba 100644
--- a/apps/netutils/ftpc/ftpc_cmd.c
+++ b/apps/netutils/ftpc/ftpc_cmd.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -149,7 +149,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
/* Send the command */
va_start(ap, cmd);
- ret = ftpc_sockprintf(&session->cmd, cmd, ap);
+ ret = ftpc_sockvprintf(&session->cmd, cmd, ap);
if (ret >= 0)
{
ret = ftpc_sockprintf(&session->cmd, "\r\n");
diff --git a/apps/netutils/ftpc/ftpc_config.h b/apps/netutils/ftpc/ftpc_config.h
new file mode 100644
index 000000000..9dc90085c
--- /dev/null
+++ b/apps/netutils/ftpc/ftpc_config.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * apps/netutils/ftpc/ftpc_config.h
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __APPS_NETUTILS_FTPC_FTPC_CONFIG_H
+#define __APPS_NETUTILS_FTPC_FTPC_CONFIG_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+/* This is a mindless little wrapper around include/nuttx/config.h. Every
+ * file in the ftpc directory includes this file at the very beginning of
+ * of the file (instead of include/nuttx/config.h). The only purpose of
+ * this file is to muck with some of the settings to support some debug
+ * features.
+ *
+ * The FPT client uses common networking debug macros (ndbg and nvdbg).
+ * This can be overwhelming if there is a lot of networking debug output
+ * as well. But by defining CONFIG_DEBUG_FTPC, this file will force
+ * networking debug ON only for the files within this directory.
+ */
+
+#if !defined(CONFIG_DEBUG_NET) && defined(CONFIG_DEBUG_FTPC)
+# define CONFIG_DEBUG_NET 1
+#endif
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#endif /* __APPS_NETUTILS_FTPC_FTPC_CONFIG_H */
diff --git a/apps/netutils/ftpc/ftpc_connect.c b/apps/netutils/ftpc/ftpc_connect.c
index 2b4701d42..3c9c460aa 100644
--- a/apps/netutils/ftpc/ftpc_connect.c
+++ b/apps/netutils/ftpc/ftpc_connect.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <unistd.h>
@@ -97,6 +97,7 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server)
/* Initialize the session structure */
+ ftpc_reset(session);
session->addr.s_addr = server->addr.s_addr;
session->pid = getpid();
@@ -223,7 +224,7 @@ int ftpc_reconnect(FAR struct ftpc_session_s *session)
tmp = inet_ntoa(addr.sin_addr);
ndbg(" Remote address: %s:%d\n", tmp, ntohs(addr.sin_port));
tmp = inet_ntoa(session->cmd.laddr.sin_addr);
- ndbg(" Local address: %s:%d\n", tmp, ntohs(session->cmd.laddr.sin_port));
+ ndbg(" Local address: %s:%d\n", tmp, ntohs(session->cmd.laddr.sin_port));
#endif
return OK;
diff --git a/apps/netutils/ftpc/ftpc_disconnect.c b/apps/netutils/ftpc/ftpc_disconnect.c
index e55c35e34..90c47ee1d 100644
--- a/apps/netutils/ftpc/ftpc_disconnect.c
+++ b/apps/netutils/ftpc/ftpc_disconnect.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
diff --git a/apps/netutils/ftpc/ftpc_filesize.c b/apps/netutils/ftpc/ftpc_filesize.c
index afd773e41..18561eb1d 100644
--- a/apps/netutils/ftpc/ftpc_filesize.c
+++ b/apps/netutils/ftpc/ftpc_filesize.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdint.h>
#include <stdio.h>
diff --git a/apps/netutils/ftpc/ftpc_filetime.c b/apps/netutils/ftpc/ftpc_filetime.c
index 331e7e7b6..a9558f22d 100644
--- a/apps/netutils/ftpc/ftpc_filetime.c
+++ b/apps/netutils/ftpc/ftpc_filetime.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <string.h>
#include <time.h>
diff --git a/apps/netutils/ftpc/ftpc_getfile.c b/apps/netutils/ftpc/ftpc_getfile.c
index 039643d0e..e9816e5b4 100644
--- a/apps/netutils/ftpc/ftpc_getfile.c
+++ b/apps/netutils/ftpc/ftpc_getfile.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <sys/stat.h>
#include <stdlib.h>
diff --git a/apps/netutils/ftpc/ftpc_getreply.c b/apps/netutils/ftpc/ftpc_getreply.c
index 89dab6e81..50d392a5f 100644
--- a/apps/netutils/ftpc/ftpc_getreply.c
+++ b/apps/netutils/ftpc/ftpc_getreply.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>
diff --git a/apps/netutils/ftpc/ftpc_help.c b/apps/netutils/ftpc/ftpc_help.c
index 2501ca365..63e3132b8 100644
--- a/apps/netutils/ftpc/ftpc_help.c
+++ b/apps/netutils/ftpc/ftpc_help.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_idle.c b/apps/netutils/ftpc/ftpc_idle.c
index 945ca8577..2d049f8b4 100644
--- a/apps/netutils/ftpc/ftpc_idle.c
+++ b/apps/netutils/ftpc/ftpc_idle.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <debug.h>
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_internal.h b/apps/netutils/ftpc/ftpc_internal.h
index 4a7a3ca9b..5e177b36b 100644
--- a/apps/netutils/ftpc/ftpc_internal.h
+++ b/apps/netutils/ftpc/ftpc_internal.h
@@ -40,7 +40,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -200,6 +200,8 @@ extern "C" {
fgetc((s)->instream)
#define ftpc_sockflush(s) \
fflush((s)->outstream)
+#define ftpc_sockvprintf(s,f,ap) \
+ vfprintf((s)->outstream,f,ap)
/****************************************************************************
* Public Functions
@@ -237,7 +239,7 @@ EXTERN void ftpc_sockcopy(FAR struct ftpc_socket_s *dest,
/* Socket I/O helpers */
-EXTERN int ftpc_sockprintf(FAR struct ftpc_socket_s *sock, const char *str, ...);
+EXTERN int ftpc_sockprintf(FAR struct ftpc_socket_s *sock, const char *fmt, ...);
EXTERN void ftpc_timeout(int argc, uint32_t arg1, ...);
/* Transfer helpers */
diff --git a/apps/netutils/ftpc/ftpc_listdir.c b/apps/netutils/ftpc/ftpc_listdir.c
index 20653799c..4c36445ad 100644
--- a/apps/netutils/ftpc/ftpc_listdir.c
+++ b/apps/netutils/ftpc/ftpc_listdir.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <sys/stat.h>
#include <stdlib.h>
diff --git a/apps/netutils/ftpc/ftpc_login.c b/apps/netutils/ftpc/ftpc_login.c
index 4fa8171da..83d2cde05 100644
--- a/apps/netutils/ftpc/ftpc_login.c
+++ b/apps/netutils/ftpc/ftpc_login.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <string.h>
#include <errno.h>
diff --git a/apps/netutils/ftpc/ftpc_mkdir.c b/apps/netutils/ftpc/ftpc_mkdir.c
index 0662f2cbc..59684f07d 100644
--- a/apps/netutils/ftpc/ftpc_mkdir.c
+++ b/apps/netutils/ftpc/ftpc_mkdir.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>
diff --git a/apps/netutils/ftpc/ftpc_noop.c b/apps/netutils/ftpc/ftpc_noop.c
index 5e6874f02..48d9ccafd 100644
--- a/apps/netutils/ftpc/ftpc_noop.c
+++ b/apps/netutils/ftpc/ftpc_noop.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_putfile.c b/apps/netutils/ftpc/ftpc_putfile.c
index edee42e41..f0e85a0bc 100644
--- a/apps/netutils/ftpc/ftpc_putfile.c
+++ b/apps/netutils/ftpc/ftpc_putfile.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <sys/stat.h>
#include <stdlib.h>
diff --git a/apps/netutils/ftpc/ftpc_pwd.c b/apps/netutils/ftpc/ftpc_pwd.c
index f6bde0e13..809002c9b 100644
--- a/apps/netutils/ftpc/ftpc_pwd.c
+++ b/apps/netutils/ftpc/ftpc_pwd.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>
@@ -86,26 +86,50 @@ FAR char *ftpc_pwd(SESSION handle)
FAR char *end;
FAR char *pwd;
FAR char *ptr;
+ int len;
int ret;
+ /* Send the PWD command */
+
ret = ftpc_cmd(session, "PWD");
+
+ /* Response is like: 257 "/home/gnutt" (from vsftpd).
+ *
+ * Extract the quoated path name into allocated memory.
+ */
+
start = strchr(session->reply, '\"');
if (!start)
{
ndbg("Opening quote not found\n");
return NULL;
}
-
start++;
+
end = strchr(start, '\"');
if (!end)
{
- ndbg("Clsoing quote not found\n");
+ ndbg("Closing quote not found\n");
+ return NULL;
+ }
+
+ /* Allocate memory for the path name */
+
+ len = end - start;
+ pwd = (char *)malloc(len + 1);
+ if (!pwd)
+ {
+ ndbg("Failed to allocate string\n");
return NULL;
}
+
+ /* Copy the string into the allocated memory */
+
+ memcpy(pwd, start, len);
+ pwd[len] = '\0';
+
+ /* Remove any trailing slashes that the server may have added */
- pwd = (char *)malloc(end-start+1);
- strncpy(pwd, start, end-start);
ftpc_stripslash(pwd);
/* Change DOS style directory separator ('\') to UNIX style ('/') */
diff --git a/apps/netutils/ftpc/ftpc_quit.c b/apps/netutils/ftpc/ftpc_quit.c
index daae04e88..25ec8b16f 100644
--- a/apps/netutils/ftpc/ftpc_quit.c
+++ b/apps/netutils/ftpc/ftpc_quit.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <time.h>
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_rename.c b/apps/netutils/ftpc/ftpc_rename.c
index d14bdf3f3..f2355fdd5 100644
--- a/apps/netutils/ftpc/ftpc_rename.c
+++ b/apps/netutils/ftpc/ftpc_rename.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>
diff --git a/apps/netutils/ftpc/ftpc_response.c b/apps/netutils/ftpc/ftpc_response.c
index 3bf1ee54b..275b48123 100644
--- a/apps/netutils/ftpc/ftpc_response.c
+++ b/apps/netutils/ftpc/ftpc_response.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <string.h>
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_rmdir.c b/apps/netutils/ftpc/ftpc_rmdir.c
index bb86941ae..4a2c27f48 100644
--- a/apps/netutils/ftpc/ftpc_rmdir.c
+++ b/apps/netutils/ftpc/ftpc_rmdir.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>
diff --git a/apps/netutils/ftpc/ftpc_socket.c b/apps/netutils/ftpc/ftpc_socket.c
index 5747a7c66..129e6f565 100644
--- a/apps/netutils/ftpc/ftpc_socket.c
+++ b/apps/netutils/ftpc/ftpc_socket.c
@@ -332,13 +332,13 @@ int ftpc_socklisten(struct ftpc_socket_s *sock)
*
****************************************************************************/
-int ftpc_sockprintf(struct ftpc_socket_s *sock, const char *str, ...)
+int ftpc_sockprintf(struct ftpc_socket_s *sock, const char *fmt, ...)
{
va_list ap;
int r;
- va_start(ap, str);
- r = vfprintf(sock->outstream, str, ap);
+ va_start(ap, fmt);
+ r = vfprintf(sock->outstream, fmt, ap);
va_end(ap);
return r;
}
diff --git a/apps/netutils/ftpc/ftpc_unlink.c b/apps/netutils/ftpc/ftpc_unlink.c
index 2af5d4f29..cf6733eca 100644
--- a/apps/netutils/ftpc/ftpc_unlink.c
+++ b/apps/netutils/ftpc/ftpc_unlink.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <apps/ftpc.h>
diff --git a/apps/netutils/ftpc/ftpc_utils.c b/apps/netutils/ftpc/ftpc_utils.c
index 0b5251fe1..45994532e 100644
--- a/apps/netutils/ftpc/ftpc_utils.c
+++ b/apps/netutils/ftpc/ftpc_utils.c
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
+#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>