aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorIsaac Dunham <ibid.ag@gmail.com>2013-12-27 08:36:03 -0600
committerIsaac Dunham <ibid.ag@gmail.com>2013-12-27 08:36:03 -0600
commitfc33eb78115adf8a90875f822706bdf3d462524c (patch)
tree8f814833f6e63e3a8f348701c23b4a1ad4109f7d /toys
parent8471dc08c411822480b2bf622a5ea7fce1cef33d (diff)
downloadtoybox-fc33eb78115adf8a90875f822706bdf3d462524c.tar.gz
Noticed a few differences from standard help messages, plus a small
problem with the port number handling: when no port was specified, it failed. The solution ended up dropping a couple lines.
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/ftpget.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/toys/pending/ftpget.c b/toys/pending/ftpget.c
index bd44289e..8643badb 100644
--- a/toys/pending/ftpget.c
+++ b/toys/pending/ftpget.c
@@ -5,15 +5,15 @@
*
* No Standard.
*
-USE_FTPGET(NEWTOY(ftpget, "<2cvu:p:P:", TOYFLAG_BIN))
-USE_FTPGET(OLDTOY(ftpput,ftpget, "<2vu:p:P:", TOYFLAG_BIN))
+USE_FTPGET(NEWTOY(ftpget, "<2cvu:p:P#<0=21>65535", TOYFLAG_BIN))
+USE_FTPGET(OLDTOY(ftpput,ftpget, "<2vu:p:P#<0=21>65535", TOYFLAG_BIN))
config FTPGET
bool "ftpget/ftpput"
default n
help
- usage: ftpget [-cv] [-u username -p password -P PortNumber] HOST_NAME [LOCAL_FILENAME] REMOTE_FILENAME
- usage: ftpput [-v] [-u username -p password -P PortNumber] HOST_NAME [REMOTE_FILENAME] LOCAL_FILENAME
+ usage: ftpget [-cv] [-u USER -p PASSWORD -P PORT] HOST_NAME [LOCAL_FILENAME] REMOTE_FILENAME
+ usage: ftpput [-v] [-u USER -p PASSWORD -P PORT] HOST_NAME [REMOTE_FILENAME] LOCAL_FILENAME
ftpget - Get a remote file from FTP.
ftpput - Upload a local file on remote machine through FTP.
@@ -22,13 +22,13 @@ config FTPGET
-v Verbose.
-u User name.
-p Password.
- -P Port Number.
+ -P Port Number (default 21).
*/
#define FOR_ftpget
#include "toys.h"
GLOBALS(
- char *port;
+ long port; // char *port;
char *password;
char *username;
@@ -129,18 +129,17 @@ static void send_requests(void)
static void get_sockaddr(char *host)
{
struct addrinfo hints, *result;
- char *ptr;
- int status, port;
+ char *ptr, port[6];
+ int status;
errno = 0;
- port = strtoul(TT.port, &ptr, 10);
- if (errno || port > 65535) error_exit("Invalid port, Range is [0-65535]");
+ snprintf(port, 6, "%ld", TT.port);
memset(&hints, 0 , sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- status = getaddrinfo(host, TT.port, &hints, &result);
+ status = getaddrinfo(host, port, &hints, &result);
if (status) error_exit("bad address '%s' : %s", host, gai_strerror(status));
memcpy(TT.buf, result->ai_addr, result->ai_addrlen);
@@ -272,7 +271,6 @@ void ftpget_main(void)
if (!(toys.optflags & FLAG_u) && !(toys.optflags & FLAG_p))
TT.username = TT.password ="anonymous";
- if (!(toys.optflags & FLAG_P)) TT.port = "ftp"; //use default ftp port 21.
//if continue is not in the command line argument.
if (TT.isget && !(toys.optflags & FLAG_c)) TT.c = 0;