mirror of
https://github.com/curl/curl.git
synced 2026-08-24 14:23:30 +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. test1560: run without requiring all the protocols Closes #20351
This commit is contained in:
parent
9703dabd77
commit
fc53df4768
60 changed files with 830 additions and 1050 deletions
|
|
@ -23,9 +23,9 @@
|
|||
***************************************************************************/
|
||||
#include "../curl_setup.h"
|
||||
|
||||
#ifdef USE_SSH
|
||||
|
||||
#include "vssh.h"
|
||||
#include "ssh.h"
|
||||
#ifdef USE_SSH
|
||||
#include "../curlx/strparse.h"
|
||||
#include "../curl_trc.h"
|
||||
#include "../escape.h"
|
||||
|
|
@ -51,7 +51,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
|
|||
curlx_dyn_init(&npath, MAX_SSHPATH_LEN);
|
||||
|
||||
/* Check for /~/, indicating relative to the user's home directory */
|
||||
if((data->conn->handler->protocol & CURLPROTO_SCP) &&
|
||||
if((data->conn->scheme->protocol & CURLPROTO_SCP) &&
|
||||
(working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) {
|
||||
/* It is referenced to the home directory, so strip the leading '/~/' */
|
||||
if(curlx_dyn_addn(&npath, &working_path[3], working_path_len - 3)) {
|
||||
|
|
@ -59,7 +59,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
else if((data->conn->handler->protocol & CURLPROTO_SFTP) &&
|
||||
else if((data->conn->scheme->protocol & CURLPROTO_SFTP) &&
|
||||
(!strcmp("/~", working_path) ||
|
||||
((working_path_len > 2) && !memcmp(working_path, "/~/", 3)))) {
|
||||
if(curlx_dyn_add(&npath, homedir)) {
|
||||
|
|
@ -239,3 +239,34 @@ CURLcode Curl_ssh_range(struct Curl_easy *data,
|
|||
}
|
||||
|
||||
#endif /* USE_SSH */
|
||||
|
||||
/*
|
||||
* SFTP protocol handler.
|
||||
*/
|
||||
const struct Curl_scheme Curl_scheme_sftp = {
|
||||
"SFTP", /* scheme */
|
||||
#ifndef USE_SSH
|
||||
NULL,
|
||||
#else
|
||||
&Curl_protocol_sftp,
|
||||
#endif
|
||||
CURLPROTO_SFTP, /* protocol */
|
||||
CURLPROTO_SFTP, /* family */
|
||||
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */
|
||||
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE,
|
||||
PORT_SSH /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_scp = {
|
||||
"SCP", /* scheme */
|
||||
#ifndef USE_SSH
|
||||
NULL,
|
||||
#else
|
||||
&Curl_protocol_scp,
|
||||
#endif
|
||||
CURLPROTO_SCP, /* protocol */
|
||||
CURLPROTO_SCP, /* family */
|
||||
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */
|
||||
PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE,
|
||||
PORT_SSH, /* defport */
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue