diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-08-27 17:07:03 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-08-27 17:07:03 +0200 |
commit | 5d2a21c2d41b3735172a7e03745f19adc3f21352 (patch) | |
tree | a9a704a5d6fd4c59d944b260db748e910c191c56 | |
parent | 648886a5914fab9444ec4ce02abde8eb1a3bb4f8 (diff) | |
download | cssh-5d2a21c2d41b3735172a7e03745f19adc3f21352.tar.gz cssh-5d2a21c2d41b3735172a7e03745f19adc3f21352.tar.bz2 |
started to handle the receiving part of a SCP download
-rw-r--r-- | man/cscp.1 | 5 | ||||
-rw-r--r-- | src/cssh.c | 60 |
2 files changed, 64 insertions, 1 deletions
diff --git a/man/cscp.1 b/man/cscp.1 new file mode 100644 index 0000000..0eb03db --- /dev/null +++ b/man/cscp.1 @@ -0,0 +1,5 @@ +.TH CScp "1" "08/15/2015" "CScp" "User Commands" +.SH NAME +CScp \- Cluster Secure Copy based on libssh +.SH AUTHOR +CScp has been written by Andreas Baumann <mail@andreasbaumann.cc> @@ -12,7 +12,7 @@ #include "msleep.h" -#include "cssh_options.h" +#include "options.h" #include "version.h" static int parse_options_and_arguments( int argc, char *argv[], struct gengetopt_args_info *args_info ) { @@ -807,6 +807,64 @@ int main( int argc, char *argv[] ) } } + for( unsigned int i = 0; i < nof_sessions; i++ ) { + rc = ssh_scp_init( scp[i] ); + if( rc != SSH_OK ) { + fprintf( stderr, "ERROR: Unable to initialize SCP sessions: %s\n", + ssh_get_error( session[i] ) ); + cleanup_sessions( &session, NULL, &scp, host, port, nof_sessions, args_info.verbose_given > 0 ); + exit( EXIT_FAILURE ); + } + } + + switch( copy_direction ) { + case CSSH_COPY_DIRECTION_UPLOAD: { + } break; + + case CSSH_COPY_DIRECTION_DOWNLOAD: { + // TODO: we receive files from N hosts, so we should + // have a method to create separate directories or + // files, e.g. file.host1, file.host2, etc. + // or dirs host1/file host2/file. Maybe this depends + // also on whether we specify recursive mode or not + for( unsigned int i = 0; i < nof_sessions; i++ ) { + rc = ssh_scp_pull_request( scp[i] ); + switch( rc ) { + case SSH_SCP_REQUEST_NEWDIR: + // TODO: mkdir in host[i] workspace + break; + + case SSH_SCP_REQUEST_ENDDIR: + // TODO: leave current workspace + break; + + case SSH_SCP_REQUEST_NEWFILE: + // TODO: receive file in workdir of host[i] + break; + + case SSH_SCP_REQUEST_EOF: + // TODO: keep array of eof flags and terminate + // loop if all hosts have terminated + break; + + case SSH_ERROR: + fprintf( stderr, "ERROR: error from remote host '%s': %s\n", + host[i], ssh_get_error( session[i] ) ); + cleanup_sessions( &session, NULL, &scp, host, port, nof_sessions, args_info.verbose_given > 0 ); + exit( EXIT_FAILURE ); + break; + + case SSH_SCP_REQUEST_WARNING: + fprintf( stderr, "WARNING: remote host '%s': %s\n", + host[i], ssh_scp_request_get_warning( scp[i] ) ); + cleanup_sessions( &session, NULL, &scp, host, port, nof_sessions, args_info.verbose_given > 0 ); + exit( EXIT_FAILURE ); + break; + } + } + } break; + } + cleanup_sessions( &session, NULL, &scp, host, port, nof_sessions, args_info.verbose_given > 0 ); } break; |