X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fftpgetput.c;h=e866a7754ac72127470358613d37842a21381bdd;hb=9c143ce52da11ec3d21a3491c3749841d3dc10f0;hp=abdf94c459f92374b1b6a5569e006ae13f3384f9;hpb=66426760beef7e87c4735f433d123daf911b5b4a;p=oweals%2Fbusybox.git diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index abdf94c45..e866a7754 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -12,44 +12,50 @@ * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ +//config:config FTPGET +//config: bool "ftpget (8 kb)" +//config: default y +//config: help +//config: Retrieve a remote file via FTP. +//config: +//config:config FTPPUT +//config: bool "ftpput (7.7 kb)" +//config: default y +//config: help +//config: Store a remote file via FTP. +//config: +//config:config FEATURE_FTPGETPUT_LONG_OPTIONS +//config: bool "Enable long options in ftpget/ftpput" +//config: default y +//config: depends on LONG_OPTS && (FTPGET || FTPPUT) + +//applet:IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpget)) +//applet:IF_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpput)) + +//kbuild:lib-$(CONFIG_FTPGET) += ftpgetput.o +//kbuild:lib-$(CONFIG_FTPPUT) += ftpgetput.o //usage:#define ftpget_trivial_usage //usage: "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE" //usage:#define ftpget_full_usage "\n\n" -//usage: "Retrieve a remote file via FTP\n" -//usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS( -//usage: "\n -c,--continue Continue previous transfer" -//usage: "\n -v,--verbose Verbose" -//usage: "\n -u,--username Username" -//usage: "\n -p,--password Password" -//usage: "\n -P,--port Port number" -//usage: ) -//usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( +//usage: "Download a file via FTP\n" //usage: "\n -c Continue previous transfer" //usage: "\n -v Verbose" -//usage: "\n -u Username" -//usage: "\n -p Password" -//usage: "\n -P Port number" -//usage: ) +//usage: "\n -u USER Username" +//usage: "\n -p PASS Password" +//usage: "\n -P NUM Port" //usage: //usage:#define ftpput_trivial_usage //usage: "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE" //usage:#define ftpput_full_usage "\n\n" -//usage: "Store a local file on a remote machine via FTP\n" -//usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS( -//usage: "\n -v,--verbose Verbose" -//usage: "\n -u,--username Username" -//usage: "\n -p,--password Password" -//usage: "\n -P,--port Port number" -//usage: ) -//usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( +//usage: "Upload a file to a FTP server\n" //usage: "\n -v Verbose" -//usage: "\n -u Username" -//usage: "\n -p Password" -//usage: "\n -P Port number" -//usage: ) +//usage: "\n -u USER Username" +//usage: "\n -p PASS Password" +//usage: "\n -P NUM Port number" #include "libbb.h" +#include "common_bufsiz.h" struct globals { const char *user; @@ -60,11 +66,8 @@ struct globals { int do_continue; char buf[4]; /* actually [BUFSZ] */ } FIX_ALIASING; -#define G (*(struct globals*)&bb_common_bufsiz1) +#define G (*(struct globals*)bb_common_bufsiz1) enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) }; -struct BUG_G_too_big { - char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; -}; #define user (G.user ) #define password (G.password ) #define lsa (G.lsa ) @@ -72,7 +75,10 @@ struct BUG_G_too_big { #define verbose_flag (G.verbose_flag ) #define do_continue (G.do_continue ) #define buf (G.buf ) -#define INIT_G() do { } while (0) +#define INIT_G() do { \ + setup_common_bufsiz(); \ + BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ +} while (0) static void ftp_die(const char *msg) NORETURN; @@ -338,12 +344,15 @@ int ftpgetput_main(int argc UNUSED_PARAM, char **argv) /* * Decipher the command line */ + /* must have 2 to 3 params; -v and -c count */ +#define OPTSTRING "^cvu:p:P:" "\0" "-2:?3:vv:cc" #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS - applet_long_options = ftpgetput_longopts; + getopt32long(argv, OPTSTRING, ftpgetput_longopts, +#else + getopt32(argv, OPTSTRING, #endif - opt_complementary = "-2:vv:cc"; /* must have 2 to 3 params; -v and -c count */ - getopt32(argv, "cvu:p:P:", &user, &password, &port, - &verbose_flag, &do_continue); + &user, &password, &port, &verbose_flag, &do_continue + ); argv += optind; /* We want to do exactly _one_ DNS lookup, since some