More FTP client debug fixes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3662 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-06-02 23:45:31 +00:00
parent 0d964dcdd6
commit a41d37a05b
28 changed files with 136 additions and 37 deletions

View File

@ -66,7 +66,7 @@
#endif
#ifndef CONFIG_FTP_MAXREPLY
# define CONFIG_FTP_MAXREPLY 21
# define CONFIG_FTP_MAXREPLY 256
#endif
#ifndef CONFIG_FTP_TMPDIR
@ -74,7 +74,7 @@
#endif
#ifndef CONFIG_FTP_BUFSIZE
# define CONFIG_FTP_BUFSIZE 4096
# define CONFIG_FTP_BUFSIZE 1024
#endif
#ifndef CONFIG_FTP_MAXPATH

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <debug.h>
#include <apps/ftpc.h>

View File

@ -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");

View File

@ -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 */

View File

@ -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;

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdlib.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdint.h>
#include <stdio.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <string.h>
#include <time.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <sys/stat.h>
#include <stdlib.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <debug.h>
#include <apps/ftpc.h>

View File

@ -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 */

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <sys/stat.h>
#include <stdlib.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <string.h>
#include <errno.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <sys/stat.h>
#include <stdlib.h>

View File

@ -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;
}
pwd = (char *)malloc(end-start+1);
strncpy(pwd, start, end-start);
/* 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 */
ftpc_stripslash(pwd);
/* Change DOS style directory separator ('\') to UNIX style ('/') */

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <time.h>
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <string.h>
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>

View File

@ -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;
}

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <apps/ftpc.h>

View File

@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "ftpc_config.h"
#include <stdlib.h>
#include <string.h>