mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-05 20:55:47 +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:
@@ -330,6 +330,8 @@ typedef struct _LIBSSH2_SK_SIG_INFO {
|
||||
#define LIBSSH2_SK_PRESENCE_REQUIRED 0x01
|
||||
#define LIBSSH2_SK_VERIFICATION_REQUIRED 0x04
|
||||
|
||||
/* FIXME: update lengths to size_t (or ssize_t): */
|
||||
|
||||
/* Callbacks for special SSH packets */
|
||||
#define LIBSSH2_IGNORE_FUNC(name) \
|
||||
void name(LIBSSH2_SESSION *session, const char *message, int message_len, \
|
||||
@@ -645,6 +647,13 @@ libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)),
|
||||
|
||||
LIBSSH2_API void **libssh2_session_abstract(LIBSSH2_SESSION *session);
|
||||
|
||||
typedef void (libssh2_cb_generic)(void);
|
||||
|
||||
LIBSSH2_API libssh2_cb_generic *
|
||||
libssh2_session_callback_set2(LIBSSH2_SESSION *session, int cbtype,
|
||||
libssh2_cb_generic *callback);
|
||||
|
||||
LIBSSH2_DEPRECATED(1.11.1, "Use libssh2_session_callback_set2()")
|
||||
LIBSSH2_API void *libssh2_session_callback_set(LIBSSH2_SESSION *session,
|
||||
int cbtype, void *callback);
|
||||
LIBSSH2_API int libssh2_session_banner_set(LIBSSH2_SESSION *session,
|
||||
|
Reference in New Issue
Block a user