mirror of
https://github.com/curl/curl.git
synced 2026-08-25 23:13:38 +03:00
lib: separate scheme info from protocol implementation
This allows builds know about all schemes - but only have the protocol implementations for those actually built-in. It further allows multiple protocols to reuse the same protocol setup and functions for both TLS and non-TLS implementations instead of needing two (or more) structs. The scheme information is now in 'struct Curl_scheme' and all the function pointers for each scheme/protocol implementation are in struct Curl_protocol. The URL API now always work with all known protocols. Closes #20351
This commit is contained in:
parent
63baa10951
commit
8edc0338f3
59 changed files with 831 additions and 1040 deletions
|
|
@ -1034,7 +1034,7 @@ static int myssh_in_AUTH_DONE(struct Curl_easy *data,
|
|||
conn->recv_idx = FIRSTSOCKET;
|
||||
conn->send_idx = -1;
|
||||
|
||||
if(conn->handler->protocol == CURLPROTO_SFTP) {
|
||||
if(conn->scheme->protocol == CURLPROTO_SFTP) {
|
||||
myssh_to(data, sshc, SSH_SFTP_INIT);
|
||||
return SSH_NO_ERROR;
|
||||
}
|
||||
|
|
@ -2501,7 +2501,7 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done)
|
|||
return CURLE_FAILED_INIT;
|
||||
|
||||
CURL_TRC_SSH(data, "myssh_connect");
|
||||
if(conn->handler->protocol & CURLPROTO_SCP) {
|
||||
if(conn->scheme->protocol & CURLPROTO_SCP) {
|
||||
conn->recv[FIRSTSOCKET] = scp_recv;
|
||||
conn->send[FIRSTSOCKET] = scp_send;
|
||||
}
|
||||
|
|
@ -3034,7 +3034,7 @@ static CURLcode myssh_do_it(struct Curl_easy *data, bool *done)
|
|||
|
||||
Curl_pgrsReset(data);
|
||||
|
||||
if(conn->handler->protocol & CURLPROTO_SCP)
|
||||
if(conn->scheme->protocol & CURLPROTO_SCP)
|
||||
result = scp_perform(data, &connected, done);
|
||||
else
|
||||
result = sftp_perform(data, &connected, done);
|
||||
|
|
@ -3062,10 +3062,9 @@ void Curl_ssh_version(char *buffer, size_t buflen)
|
|||
}
|
||||
|
||||
/*
|
||||
* SCP protocol handler.
|
||||
* SCP.
|
||||
*/
|
||||
const struct Curl_handler Curl_handler_scp = {
|
||||
"SCP", /* scheme */
|
||||
const struct Curl_protocol Curl_protocol_scp = {
|
||||
myssh_setup_connection, /* setup_connection */
|
||||
myssh_do_it, /* do_it */
|
||||
scp_done, /* done */
|
||||
|
|
@ -3083,18 +3082,12 @@ const struct Curl_handler Curl_handler_scp = {
|
|||
ZERO_NULL, /* connection_check */
|
||||
ZERO_NULL, /* attach connection */
|
||||
ZERO_NULL, /* follow */
|
||||
PORT_SSH, /* defport */
|
||||
CURLPROTO_SCP, /* protocol */
|
||||
CURLPROTO_SCP, /* family */
|
||||
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */
|
||||
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE
|
||||
};
|
||||
|
||||
/*
|
||||
* SFTP protocol handler.
|
||||
* SFTP.
|
||||
*/
|
||||
const struct Curl_handler Curl_handler_sftp = {
|
||||
"SFTP", /* scheme */
|
||||
const struct Curl_protocol Curl_protocol_sftp = {
|
||||
myssh_setup_connection, /* setup_connection */
|
||||
myssh_do_it, /* do_it */
|
||||
sftp_done, /* done */
|
||||
|
|
@ -3112,11 +3105,6 @@ const struct Curl_handler Curl_handler_sftp = {
|
|||
ZERO_NULL, /* connection_check */
|
||||
ZERO_NULL, /* attach connection */
|
||||
ZERO_NULL, /* follow */
|
||||
PORT_SSH, /* defport */
|
||||
CURLPROTO_SFTP, /* protocol */
|
||||
CURLPROTO_SFTP, /* family */
|
||||
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */
|
||||
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE
|
||||
};
|
||||
|
||||
#endif /* USE_LIBSSH */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue