Added option parsing using GNU argp.
Этот коммит содержится в:
родитель
7b7280e728
Коммит
f0858ff6b2
@ -79,12 +79,19 @@ static struct argp_option options[] = {
|
|||||||
.doc = "Set the rsa key.",
|
.doc = "Set the rsa key.",
|
||||||
.group = 0
|
.group = 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "verbose",
|
||||||
|
.key = 'v',
|
||||||
|
.arg = NULL,
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "Get verbose output.",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
{NULL, 0, 0, 0, NULL, 0}
|
{NULL, 0, 0, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Parse a single option. */
|
/* Parse a single option. */
|
||||||
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
||||||
int i;
|
|
||||||
/* Get the input argument from argp_parse, which we
|
/* Get the input argument from argp_parse, which we
|
||||||
* know is a pointer to our arguments structure.
|
* know is a pointer to our arguments structure.
|
||||||
*/
|
*/
|
||||||
@ -92,8 +99,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'p':
|
case 'p':
|
||||||
i = atoi(arg);
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT_STR, arg);
|
||||||
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &i);
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, arg);
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, arg);
|
||||||
@ -104,6 +110,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
case 'r':
|
case 'r':
|
||||||
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
|
||||||
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
if (state->arg_num >= 1) {
|
if (state->arg_num >= 1) {
|
||||||
/* Too many arguments. */
|
/* Too many arguments. */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user