1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

Pass user context through libssh2_trace_sethandler() to callback

The libssh2_trace_sethandler() call allows the user to handle the output of libssh2 rather than having it written to stderr.  This patch updates libssh2_trace_sethandler() to allow a user-defined void* context value to be passed back to the output handler.
This commit is contained in:
Dave McCaldon
2010-01-20 12:02:13 -05:00
committed by Daniel Stenberg
parent 44eba0c993
commit f077984394
5 changed files with 16 additions and 6 deletions

View File

@@ -313,9 +313,10 @@ libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
}
LIBSSH2_API int
libssh2_trace_sethandler(LIBSSH2_SESSION *session, libssh2_trace_handler_func callback)
libssh2_trace_sethandler(LIBSSH2_SESSION *session, void* handler_context, libssh2_trace_handler_func callback)
{
session->tracehandler = callback;
session->tracehandler_context = handler_context;
return 0;
}
@@ -362,7 +363,7 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
va_end(vargs);
if (session->tracehandler) {
(session->tracehandler)(session, buffer, len + 1);
(session->tracehandler)(session, session->tracehandler_context, buffer, len + 1);
} else {
write(2, buffer, len + 1);
}
@@ -378,9 +379,10 @@ libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
}
LIBSSH2_API int
libssh2_trace_sethandler(LIBSSH2_SESSION *session, libssh2_trace_handler_func callback)
libssh2_trace_sethandler(LIBSSH2_SESSION *session, void* handler_context, libssh2_trace_handler_func callback)
{
(void) session;
(void) handler_context;
(void) callback;
return 0;
}