Skip to content
Snippets Groups Projects
Commit d6c53df4 authored by patacongo's avatar patacongo
Browse files

Fix some basic FTP client compilation errors

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3655 42af7a65-404d-4744-a932-0658087f49c3
parent 7ea870d4
No related branches found
No related tags found
No related merge requests found
...@@ -207,7 +207,7 @@ extern "C" { ...@@ -207,7 +207,7 @@ extern "C" {
/* Low-level string management */ /* Low-level string management */
EXTERN void ftpc_stripcrlf(FAR char *str); EXTERN void ftpc_stripcrlf(FAR char *str);
EXTERN void ftpc_stripslash(FAR const char *str); EXTERN void ftpc_stripslash(FAR char *str);
EXTERN FAR char *ftpc_dequote(FAR const char *hostname); EXTERN FAR char *ftpc_dequote(FAR const char *hostname);
/* FTP helpers */ /* FTP helpers */
......
...@@ -81,7 +81,7 @@ typedef void (*callback_t)(FAR const char *name, FAR void *arg); ...@@ -81,7 +81,7 @@ typedef void (*callback_t)(FAR const char *name, FAR void *arg);
****************************************************************************/ ****************************************************************************/
static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session, static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
FAR const char *relpath); FAR const char *relpath)
{ {
FAR char *ptr = NULL; FAR char *ptr = NULL;
int ret = OK; int ret = OK;
...@@ -101,7 +101,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session, ...@@ -101,7 +101,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
if (relpath[1] == '\0') if (relpath[1] == '\0')
{ {
return strdup(session->home); return strdup(session->homedir);
} }
/* No... then a '/' better follow the tilde */ /* No... then a '/' better follow the tilde */
...@@ -155,7 +155,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session, ...@@ -155,7 +155,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
static void ftpc_dircount(FAR const char *name, FAR void *arg) static void ftpc_dircount(FAR const char *name, FAR void *arg)
{ {
unsigned int *dircount = (unsigned int *)arg; FAR unsigned int *dircount = (FAR unsigned int *)arg;
(*dircount)++; (*dircount)++;
} }
......
...@@ -105,9 +105,9 @@ int ftpc_login(SESSION handle, FAR struct ftpc_login_s *login) ...@@ -105,9 +105,9 @@ int ftpc_login(SESSION handle, FAR struct ftpc_login_s *login)
/* Save the login parameter */ /* Save the login parameter */
session->uname = decode_rfc1738(login->uname); session->uname = ftpc_dequote(login->uname);
session->pwd = decode_rfc1738(login->pwd); session->pwd = ftpc_dequote(login->pwd);
session->initdir = decode_rfc1738(login->rdir); session->initdir = ftpc_dequote(login->rdir);
/* Is passive mode requested? */ /* Is passive mode requested? */
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "ftpc_internal.h" #include "ftpc_internal.h"
...@@ -136,7 +137,8 @@ void ftpc_curdir(struct ftpc_session_s *session) ...@@ -136,7 +137,8 @@ void ftpc_curdir(struct ftpc_session_s *session)
* Name: ftpc_stripcrlf * Name: ftpc_stripcrlf
* *
* Description: * Description:
* Strip any trailing carriage returns or line feeds from a string. * Strip any trailing carriage returns or line feeds from a string (by
* overwriting them with NUL characters).
* *
****************************************************************************/ ****************************************************************************/
...@@ -164,30 +166,32 @@ void ftpc_stripcrlf(FAR char *str) ...@@ -164,30 +166,32 @@ void ftpc_stripcrlf(FAR char *str)
* Name: ftpc_stripslash * Name: ftpc_stripslash
* *
* Description: * Description:
* Strip any trailing slashes from a string. * Strip any trailing slashes from a string (by overwriting them with NUL
* characters.
* *
****************************************************************************/ ****************************************************************************/
FAR char *ftpc_stripslash(FAR char *str) void ftpc_stripslash(FAR char *str)
{ {
FAR char *ptr; FAR char *ptr;
int len;
if (!str || !*str) if (str)
return str; {
len = strlen(str);
ptr = strchr(str, 0); if (len > 1)
if(!ptr) {
return str; ptr = str + len - 1;
ptr--; if (*ptr == '/');
if(*ptr == '/') { {
if(ptr != str) /* root directory */ *ptr = '\0';
*ptr = 0; }
} }
return str; }
} }
/**************************************************************************** /****************************************************************************
* Name: ftpc_stripslash * Name: ftpc_dequote
* *
* Description: * Description:
* Convert quoted hexadecimal constants to binary values. * Convert quoted hexadecimal constants to binary values.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment