diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-02 12:42:45 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-02 12:42:45 +0000 |
commit | da65ee4dbba6539ed92a28b5d6451b8f174ddcb8 (patch) | |
tree | 6aeb02d0193224457234d6c320e6769c5a9b8097 | |
parent | 0dee53353150b1d535d1eec6d1b61a0e9bf22592 (diff) | |
download | libssh-da65ee4dbba6539ed92a28b5d6451b8f174ddcb8.tar.gz libssh-da65ee4dbba6539ed92a28b5d6451b8f174ddcb8.tar.xz libssh-da65ee4dbba6539ed92a28b5d6451b8f174ddcb8.zip |
Improve ssh_options_set_log_function().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@368 7dcaeef0-15fb-0310-b436-a5af3365683c
-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 9049a788..94232b98 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 66870c8d..c9b938d2 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 |