From 8831000bc07de463d277975a3ddfb6a31dcf14b4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 14 Mar 2011 22:22:22 +0100 Subject: protocol handler: added flags field The protocol handler struct got a 'flags' field for special information and characteristics of the given protocol. This now enables us to move away central protocol information such as CLOSEACTION and DUALCHANNEL from single defines in a central place, out to each protocol's definition. It also made us stop abusing the protocol field for other info than the protocol, and we could start cleaning up other protocol-specific things by adding flags bits to set in the handler struct. The "protocol" field connectdata struct was removed as well and the code now refers directly to the conn->handler->protocol field instead. To make things work properly, the code now always store a conn->given pointer that points out the original handler struct so that the code can learn details from the original protocol even if conn->handler is modified along the way - for example when switching to go over a HTTP proxy. --- lib/ssh.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/ssh.c') diff --git a/lib/ssh.c b/lib/ssh.c index e85ad2631..1551ea910 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -175,7 +175,8 @@ const struct Curl_handler Curl_handler_scp = { ssh_perform_getsock, /* perform_getsock */ scp_disconnect, /* disconnect */ PORT_SSH, /* defport */ - PROT_SCP /* protocol */ + PROT_SCP, /* protocol */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION /* flags */ }; @@ -197,7 +198,8 @@ const struct Curl_handler Curl_handler_sftp = { ssh_perform_getsock, /* perform_getsock */ sftp_disconnect, /* disconnect */ PORT_SSH, /* defport */ - PROT_SFTP /* protocol */ + PROT_SFTP, /* protocol */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION /* flags */ }; @@ -411,7 +413,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, return CURLE_OUT_OF_MEMORY; /* Check for /~/ , indicating relative to the user's home directory */ - if(conn->protocol & PROT_SCP) { + if(conn->handler->protocol & PROT_SCP) { real_path = malloc(working_path_len+1); if(real_path == NULL) { free(working_path); @@ -423,7 +425,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, else memcpy(real_path, working_path, 1 + working_path_len); } - else if(conn->protocol & PROT_SFTP) { + else if(conn->handler->protocol & PROT_SFTP) { if((working_path_len > 1) && (working_path[1] == '~')) { size_t homelen = strlen(homedir); real_path = malloc(homelen + working_path_len + 1); @@ -931,7 +933,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) conn->sockfd = sock; conn->writesockfd = CURL_SOCKET_BAD; - if(conn->protocol == PROT_SFTP) { + if(conn->handler->protocol == PROT_SFTP) { state(conn, SSH_SFTP_INIT); break; } @@ -2566,7 +2568,7 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done) if(result) return result; - if(conn->protocol & PROT_SCP) { + if(conn->handler->protocol & PROT_SCP) { conn->recv[FIRSTSOCKET] = scp_recv; conn->send[FIRSTSOCKET] = scp_send; } else { @@ -2715,7 +2717,7 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done) Curl_pgrsSetUploadSize(data, 0); Curl_pgrsSetDownloadSize(data, 0); - if(conn->protocol & PROT_SCP) + if(conn->handler->protocol & PROT_SCP) res = scp_perform(conn, &connected, done); else res = sftp_perform(conn, &connected, done); -- cgit v1.2.3