1
1

Added a userdata generic pointer to the log callback function.

Этот коммит содержится в:
Andreas Schneider 2009-09-22 12:27:28 +02:00
родитель 88f4e9ea24
Коммит 7de3122b42
4 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -376,6 +376,9 @@ LIBSSH_API int channel_get_exit_status(ssh_channel channel);
typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata);
typedef void (*ssh_log_callback) (ssh_session session, int priority,
const char *message, void *userdata);
LIBSSH_API SSH_OPTIONS *ssh_options_new(void);
LIBSSH_API SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt);
LIBSSH_API void ssh_options_free(SSH_OPTIONS *opt);
@ -396,7 +399,7 @@ LIBSSH_API int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec
LIBSSH_API int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
LIBSSH_API int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
LIBSSH_API int ssh_options_set_log_function(SSH_OPTIONS *opt,
void (*callback)(const char *message, SSH_SESSION *session, int verbosity));
ssh_log_callback cb, void *userdata);
LIBSSH_API int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity);
LIBSSH_API int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);
LIBSSH_API int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey);

Просмотреть файл

@ -296,7 +296,8 @@ struct ssh_options_struct {
char *dsakey;
char *rsakey; /* host key for server implementation */
int log_verbosity;
void (*log_function)(const char *message, SSH_SESSION *session, int verbosity); //log callback
ssh_log_callback log_function; //log callback
void *log_userdata;
};
typedef struct ssh_crypto_struct {

Просмотреть файл

@ -56,7 +56,8 @@ void ssh_log(SSH_SESSION *session, int verbosity, const char *format, ...) {
va_end(va);
if (session->options->log_function) {
session->options->log_function(buffer, session, verbosity);
session->options->log_function(session, verbosity, buffer,
session->options->log_userdata);
} else if (verbosity == SSH_LOG_FUNCTIONS) {
if (session->log_indent > 255) {
min = 255;

Просмотреть файл

@ -762,13 +762,14 @@ int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow) {
*
* @warning The message string may contain format string characters.
*/
int ssh_options_set_log_function(SSH_OPTIONS *opt,
void (*callback)(const char *message, SSH_SESSION *session, int priority)) {
if (opt == NULL || callback == NULL) {
int ssh_options_set_log_function(SSH_OPTIONS *opt, ssh_log_callback cb,
void *userdata) {
if (opt == NULL || cb == NULL) {
return -1;
}
opt->log_function = callback;
opt->log_function = cb;
opt->log_userdata = userdata;
return 0;
}