httpd: sendfile support
[oweals/busybox.git] / networking / ftpgetput.c
index ccc0b5e464afb948abc2c06b212e5b0808fddf95..f3d6009dd0a84451ecfa9cf41f13b00f4d2c0789 100644 (file)
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
-#include "busybox.h"
 #include <getopt.h>
+#include "libbb.h"
 
 typedef struct ftp_host_info_s {
-       char *user;
-       char *password;
+       const char *user;
+       const char *password;
        struct len_and_sockaddr *lsa;
 } ftp_host_info_t;
 
@@ -287,16 +287,16 @@ int ftp_send(ftp_host_info_t *server, FILE *control_stream,
 #define FTPGETPUT_OPT_PORT     16
 
 #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
-static const struct option ftpgetput_long_options[] = {
-       { "continue", 1, NULL, 'c' },
-       { "verbose", 0, NULL, 'v' },
-       { "username", 1, NULL, 'u' },
-       { "password", 1, NULL, 'p' },
-       { "port", 1, NULL, 'P' },
-       { 0, 0, 0, 0 }
-};
+static const char ftpgetput_longopts[] ALIGN1 =
+       "continue\0" Required_argument "c"
+       "verbose\0"  No_argument       "v"
+       "username\0" Required_argument "u"
+       "password\0" Required_argument "p"
+       "port\0"     Required_argument "P"
+       ;
 #endif
 
+int ftpgetput_main(int argc, char **argv);
 int ftpgetput_main(int argc, char **argv)
 {
        /* content-length of the file */
@@ -328,7 +328,7 @@ int ftpgetput_main(int argc, char **argv)
         * Decipher the command line
         */
 #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS
-       applet_long_options = ftpgetput_long_options;
+       applet_long_options = ftpgetput_longopts;
 #endif
        opt_complementary = "=3"; /* must have 3 params */
        opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
@@ -345,7 +345,7 @@ int ftpgetput_main(int argc, char **argv)
        /* We want to do exactly _one_ DNS lookup, since some
         * sites (i.e. ftp.us.debian.org) use round-robin DNS
         * and we want to connect to only one IP... */
-       server->lsa = host2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21));
+       server->lsa = xhost2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21));
        if (verbose_flag) {
                printf("Connecting to %s (%s)\n", argv[0],
                        xmalloc_sockaddr2dotted(&server->lsa->sa, server->lsa->len));