mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-01 11:26:53 +03:00
session: add libssh2_session_callback_set2()
Add new `libssh2_session_callback_set2()` API that deprecates `libssh2_session_callback_set()`. The new implementation offers the same functionality, but accepts and returns a generic function pointer (of type `libssh2_cb_generic *`), as opposed to the old function that used data pointers (`void *`). The new solution thus avoids data to function (and vice versa) pointer conversions, which has undefined behaviour in standard C. About the name: It seems the `*2` suffix was used in the past for replacement functions for deprecated ones. Let's stick with that. `*_ex` was preferred for new functions that extend existing ones with new features. Closes #1285
This commit is contained in:
@ -339,13 +339,9 @@ int main(int argc, char *argv[])
|
||||
if(set_debug_on == 1)
|
||||
libssh2_trace(session, LIBSSH2_TRACE_CONN);
|
||||
|
||||
/* ignore pedantic warnings by gcc on the callback argument */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
/* Set X11 Callback */
|
||||
libssh2_session_callback_set(session, LIBSSH2_CALLBACK_X11,
|
||||
(void *)x11_callback);
|
||||
#pragma GCC diagnostic pop
|
||||
libssh2_session_callback_set2(session, LIBSSH2_CALLBACK_X11,
|
||||
(libssh2_cb_generic *)x11_callback);
|
||||
|
||||
/* Authenticate via password */
|
||||
rc = libssh2_userauth_password(session, username, password);
|
||||
|
Reference in New Issue
Block a user