mirror of
https://github.com/sheumann/hush.git
synced 2024-07-06 19:28:59 +00:00
Use getopt_ulflags
This commit is contained in:
parent
07d2f4052f
commit
b51eb26568
@ -287,11 +287,25 @@ static int ftp_send(ftp_host_info_t *server, FILE *control_stream,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FTPGETPUT_OPT_CONTINUE 1
|
||||||
|
#define FTPGETPUT_OPT_VERBOSE 2
|
||||||
|
#define FTPGETPUT_OPT_USER 4
|
||||||
|
#define FTPGETPUT_OPT_PASSWORD 8
|
||||||
|
#define FTPGETPUT_OPT_PORT 16
|
||||||
|
|
||||||
|
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}
|
||||||
|
};
|
||||||
|
|
||||||
int ftpgetput_main(int argc, char **argv)
|
int ftpgetput_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* content-length of the file */
|
/* content-length of the file */
|
||||||
int option_index = -1;
|
unsigned long opt;
|
||||||
int opt;
|
|
||||||
|
|
||||||
/* socket to ftp server */
|
/* socket to ftp server */
|
||||||
FILE *control_stream;
|
FILE *control_stream;
|
||||||
@ -302,15 +316,6 @@ int ftpgetput_main(int argc, char **argv)
|
|||||||
|
|
||||||
int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = NULL;
|
int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = NULL;
|
||||||
|
|
||||||
struct option long_options[] = {
|
|
||||||
{"username", 1, NULL, 'u'},
|
|
||||||
{"password", 1, NULL, 'p'},
|
|
||||||
{"port", 1, NULL, 'P'},
|
|
||||||
{"continue", 1, NULL, 'c'},
|
|
||||||
{"verbose", 0, NULL, 'v'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef CONFIG_FTPPUT
|
#ifdef CONFIG_FTPPUT
|
||||||
if (bb_applet_name[3] == 'p') {
|
if (bb_applet_name[3] == 'p') {
|
||||||
ftp_action = ftp_send;
|
ftp_action = ftp_send;
|
||||||
@ -330,26 +335,13 @@ int ftpgetput_main(int argc, char **argv)
|
|||||||
* Decipher the command line
|
* Decipher the command line
|
||||||
*/
|
*/
|
||||||
server->port = "21";
|
server->port = "21";
|
||||||
while ((opt = getopt_long(argc, argv, "u:p:P:cv", long_options, &option_index)) != EOF) {
|
bb_applet_long_options = ftpgetput_long_options;
|
||||||
switch(opt) {
|
opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &server->port);
|
||||||
case 'c':
|
if (opt & FTPGETPUT_OPT_CONTINUE) {
|
||||||
do_continue = 1;
|
do_continue = 1;
|
||||||
break;
|
}
|
||||||
case 'u':
|
if (opt & FTPGETPUT_OPT_VERBOSE) {
|
||||||
server->user = optarg;
|
verbose_flag = 1;
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
server->password = optarg;
|
|
||||||
break;
|
|
||||||
case 'P':
|
|
||||||
server->port = optarg;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
verbose_flag = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user