diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-11-10 09:09:35 +0100 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-11-10 09:12:07 +0100 |
commit | 12da24c0565d0de234cc89336062b8fd06b583ac (patch) | |
tree | 4e15c680cc4ab90903e24dfb19afc6dc11ca8dc8 | |
parent | d821117033278c1304cd2baef0ad50fa4a2e2629 (diff) | |
download | libssh-12da24c0565d0de234cc89336062b8fd06b583ac.tar.gz libssh-12da24c0565d0de234cc89336062b8fd06b583ac.tar.xz libssh-12da24c0565d0de234cc89336062b8fd06b583ac.zip |
Added an option to set log verbosity as string.
-rw-r--r-- | include/libssh/libssh.h | 1 | ||||
-rw-r--r-- | libssh/options.c | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 483b5c35..53423ad3 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -256,6 +256,7 @@ enum ssh_options_e { SSH_OPTIONS_SSH1, SSH_OPTIONS_SSH2, SSH_OPTIONS_LOG_VERBOSITY, + SSH_OPTIONS_LOG_VERBOSITY_STR, SSH_OPTIONS_CIPHERS_C_S, SSH_OPTIONS_CIPHERS_S_C, diff --git a/libssh/options.c b/libssh/options.c index a6b524a0..65511d19 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -298,6 +298,19 @@ char *dir_expand_dup(ssh_session session, const char *value, int allowsshdir) { * SSH_LOG_PACKET: Packet id and size * SSH_LOG_FUNCTIONS: Function entering and leaving * + * SSH_OPTIONS_LOG_VERBOSITY_STR: + * Set the session logging verbosity (string). + * + * The verbosity of the messages. Every log smaller or + * equal to verbosity will be shown. + * SSH_LOG_NOLOG: No logging + * SSH_LOG_RARE: Rare conditions or warnings + * SSH_LOG_ENTRY: API-accessible entrypoints + * SSH_LOG_PACKET: Packet id and size + * SSH_LOG_FUNCTIONS: Function entering and leaving + * + * See the corresponding numbers in libssh.h. + * * SSH_OPTTIONS_AUTH_CALLBACK: * Set a callback to use your own authentication function * (function pointer). @@ -540,6 +553,24 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, session->log_verbosity = *x; } + case SSH_OPTIONS_LOG_VERBOSITY_STR: + if (value == NULL) { + session->port = 0 & 0xffff; + } else { + q = strdup(value); + if (q == NULL) { + ssh_set_error_oom(session); + return -1; + } + i = strtol(q, &p, 10); + if (q == p) { + SAFE_FREE(q); + } + SAFE_FREE(q); + + session->port = i & 0xffff; + } + break; case SSH_OPTIONS_CIPHERS_C_S: if (value == NULL) { ssh_set_error_invalid(session, __FUNCTION__); |