mirror of
https://github.com/moparisthebest/curl
synced 2024-11-12 12:35:04 -05:00
vssh: move ssh init/cleanup functions into backend code
This commit is contained in:
parent
5b2d703fe5
commit
d6dea75af7
20
lib/easy.c
20
lib/easy.c
@ -187,16 +187,8 @@ static CURLcode global_init(long flags, bool memoryfuncs)
|
||||
|
||||
(void)Curl_ipv6works();
|
||||
|
||||
#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT)
|
||||
if(libssh2_init(0)) {
|
||||
DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n"));
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIBSSH)
|
||||
if(ssh_init()) {
|
||||
DEBUGF(fprintf(stderr, "Error: libssh_init failed\n"));
|
||||
#if defined(USE_SSH)
|
||||
if(Curl_ssh_init()) {
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
#endif
|
||||
@ -274,13 +266,7 @@ void curl_global_cleanup(void)
|
||||
|
||||
Curl_amiga_cleanup();
|
||||
|
||||
#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_EXIT)
|
||||
(void)libssh2_exit();
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIBSSH)
|
||||
(void)ssh_finalize();
|
||||
#endif
|
||||
Curl_ssh_cleanup();
|
||||
|
||||
init_flags = 0;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -240,6 +240,11 @@ extern const struct Curl_handler Curl_handler_sftp;
|
||||
extern const struct Curl_handler Curl_handler_scp;
|
||||
extern const struct Curl_handler Curl_handler_sftp;
|
||||
|
||||
CURLcode Curl_ssh_init(void);
|
||||
void Curl_ssh_cleanup(void);
|
||||
|
||||
#else
|
||||
#define Curl_ssh_cleanup()
|
||||
#endif /* USE_LIBSSH2 */
|
||||
|
||||
#endif /* HEADER_CURL_SSH_H */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user