diff options
-rw-r--r-- | include/libssh/libssh.h | 4 | ||||
-rw-r--r-- | libssh/options.c | 29 |
2 files changed, 23 insertions, 10 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 9049a78..94232b9 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -323,10 +323,10 @@ int ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback) int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec); int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow); int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow); +int ssh_options_set_log_function(SSH_OPTIONS *opt, + void (*callback)(const char *message, SSH_SESSION *session, int verbosity)); void ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey); void ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey); -void ssh_options_set_log_function(SSH_OPTIONS *opt, - void (*callback)(const char *message, SSH_SESSION *session, int verbosity )); void ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity); /** diff --git a/libssh/options.c b/libssh/options.c index 66870c8..c9b938d 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -716,15 +716,28 @@ int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow) { return 0; } -/** Default is a write on stderr - * \brief Change the writer callback for logging - * \param opt options structure - * \param callback a callback function for the printing - * \warning the message string may contain format string characters. +/** + * @brief Change the writer callback for logging. + * + * Default is a write on stderr. + * + * @param opt The options structure to use. + * + * @param callback A callback function for the printing. + * + * @return 0 on success, < 0 on error. + * + * @warning The message string may contain format string characters. */ -void ssh_options_set_log_function(SSH_OPTIONS *opt, - void (*callback)(const char *message, SSH_SESSION *session, int priority )){ - opt->log_function=callback; +int ssh_options_set_log_function(SSH_OPTIONS *opt, + void (*callback)(const char *message, SSH_SESSION *session, int priority)) { + if (opt == NULL || callback == NULL) { + return -1; + } + + opt->log_function = callback; + + return 0; } /** \brief set this session's logging priority |