aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-10-15 17:17:58 +0200
committerAndreas Schneider <mail@cynapses.org>2009-10-15 17:17:58 +0200
commitf0858ff6b2c677f05bc5a3459bf0bc326f9074bb (patch)
treeb83e387d306887c6d127b6f55f6e433979ae3514
parent7b7280e728466f2ce9e9faeb840093224ef5d3e3 (diff)
downloadlibssh-f0858ff6b2c677f05bc5a3459bf0bc326f9074bb.tar.gz
libssh-f0858ff6b2c677f05bc5a3459bf0bc326f9074bb.tar.xz
libssh-f0858ff6b2c677f05bc5a3459bf0bc326f9074bb.zip
Added option parsing using GNU argp.
-rw-r--r--examples/samplesshd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/examples/samplesshd.c b/examples/samplesshd.c
index 5c03192..142e880 100644
--- a/examples/samplesshd.c
+++ b/examples/samplesshd.c
@@ -79,12 +79,19 @@ static struct argp_option options[] = {
.doc = "Set the rsa key.",
.group = 0
},
+ {
+ .name = "verbose",
+ .key = 'v',
+ .arg = NULL,
+ .flags = 0,
+ .doc = "Get verbose output.",
+ .group = 0
+ },
{NULL, 0, 0, 0, NULL, 0}
};
/* Parse a single option. */
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
- int i;
/* Get the input argument from argp_parse, which we
* 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) {
case 'p':
- i = atoi(arg);
- ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &i);
+ ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT_STR, arg);
break;
case 'd':
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':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
break;
+ case 'v':
+ ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
+ break;
case ARGP_KEY_ARG:
if (state->arg_num >= 1) {
/* Too many arguments. */