From d6dea75af7c00e396cffa2e74350352703312180 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Aug 2019 16:16:33 +0200 Subject: vssh: move ssh init/cleanup functions into backend code --- lib/vssh/libssh.c | 13 +++++++++++++ lib/vssh/libssh2.c | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'lib/vssh') diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 4b34b0212..d8186e0b2 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -2725,5 +2725,18 @@ static void sftp_quote_stat(struct connectdata *conn) return; } +CURLcode Curl_ssh_init(void) +{ + if(ssh_init()) { + DEBUGF(fprintf(stderr, "Error: libssh_init failed\n")); + return CURLE_FAILED_INIT; + } + return CURLE_OK; +} + +void Curl_ssh_cleanup(void) +{ + (void)ssh_finalize(); +} #endif /* USE_LIBSSH */ diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 5dd6ee29e..011f1ecf3 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -3320,4 +3320,23 @@ static const char *sftp_libssh2_strerror(int err) return "Unknown error in libssh2"; } +CURLcode Curl_ssh_init(void) +{ +#ifdef HAVE_LIBSSH2_INIT + if(libssh2_init(0)) { + DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n")); + return CURLE_FAILED_INIT; + } +#endif + return CURLE_OK; +} + +void Curl_ssh_cleanup(void) +{ +#ifdef HAVE_LIBSSH2_EXIT + (void)libssh2_exit(); +#endif +} + + #endif /* USE_LIBSSH2 */ -- cgit v1.2.3