Commit b9a7f4e5 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Move connection-oriented variables from the SessionHandle struct to the

connectdata struct. This will in theory enable us to do persistent connections
with SCP+SFTP, but currently the state machine always (and wrongly) cleanup
everything in the 'done' action instead of in 'disconnect'. Also did a bunch
of indent fixes, if () => if() and a few other source cleanups like added
comments etc.
parent 51009a40
Loading
Loading
Loading
Loading
+320 −324

File changed.

Preview size limit exceeded, changes collapsed.

+27 −19
Original line number Diff line number Diff line
@@ -485,6 +485,10 @@ typedef enum {
  SSH_LAST  /* never used */
} sshstate;

/* this struct is used in the HandleData struct which is part of the
   SessionHandle, which means this is used on a per-easy handle basis.
   Everything that is strictly related to a connection is banned from this
   struct. */
struct SSHPROTO {
  curl_off_t *bytecountp;
  char *user;
@@ -492,12 +496,6 @@ struct SSHPROTO {
  char *path;                   /* the path we operate on */
  char *homedir;
  char *errorstr;
#ifdef USE_LIBSSH2
  LIBSSH2_SESSION       *ssh_session;  /* Secure Shell session */
  LIBSSH2_CHANNEL       *ssh_channel;  /* Secure Shell channel handle */
  LIBSSH2_SFTP          *sftp_session; /* SFTP handle */
  LIBSSH2_SFTP_HANDLE   *sftp_handle;
#endif /* USE_LIBSSH2 */
};

/* ssh_conn is used for struct connection-oriented data in the connectdata
@@ -505,25 +503,35 @@ struct SSHPROTO {
struct ssh_conn {
  const char *authlist;       /* List of auth. methods, managed by libssh2 */
#ifdef USE_LIBSSH2
  const char *passphrase;
  char *rsa_pub;
  char *rsa;
  bool authed;
  const char *passphrase;     /* passphrase to use */
  char *rsa_pub;              /* path name */
  char *rsa;                  /* path name */
  bool authed;                /* the connection has been authenticated fine */
  sshstate state;             /* always use ssh.c:state() to change state! */
  sshstate nextState;         /* the state to goto after stopping */
  CURLcode actualCode;        /* the actual error code */
  struct curl_slist *quote_item;
  char *quote_path1;
  struct curl_slist *quote_item; /* for the quote option */
  char *quote_path1;          /* two generic pointers for the QUOTE stuff */
  char *quote_path2;
  LIBSSH2_SFTP_ATTRIBUTES quote_attrs;
  LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */

  /* Here's a set of struct members used by the SFTP_READDIR state */
  LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
  char *readdir_filename;
  char *readdir_longentry;
  int readdir_len, readdir_totalLen, readdir_currLen;
  char *readdir_line;
  char *readdir_linkPath;
  int secondCreateDirs;
  char *slash_pos;
  /* end of READDIR stuff */

  int secondCreateDirs;         /* counter use by the code to see if the
                                   second attempt has been made to change
                                   to/create a directory */
  char *slash_pos;              /* used by the SFTP_CREATE_DIRS state */
  LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
  LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
  LIBSSH2_SFTP *sftp_session;   /* SFTP handle */
  LIBSSH2_SFTP_HANDLE *sftp_handle;
#endif /* USE_LIBSSH2 */
};