summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-08-28 17:57:54 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-08-28 17:57:54 +0200
commita51ff9507217bf68c98ee3ec121df9bfe1bbccb5 (patch)
tree95c95cc477fc1fdd4a974ece64776589462f16e3
parentd9912f986e0f56d113d40d87977a7a6a1f30327c (diff)
downloadcssh-a51ff9507217bf68c98ee3ec121df9bfe1bbccb5.tar.gz
cssh-a51ff9507217bf68c98ee3ec121df9bfe1bbccb5.tar.bz2
some playing with receiving files
-rw-r--r--src/cssh.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/cssh.c b/src/cssh.c
index c0c6c27..8aa9a0c 100644
--- a/src/cssh.c
+++ b/src/cssh.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
+#include <inttypes.h>
#include "msleep.h"
@@ -786,7 +787,7 @@ int main( int argc, char *argv[] )
// TODO: host destination can be explicit (one without -H hosts
// parameter) or it is a placeholder host @HOST@:/dira/dirb
copy_direction_e copy_direction = CSSH_COPY_DIRECTION_DOWNLOAD;
- const char *local_directory = ".";
+ const char *local_directory = "x";
fprintf( stderr, "Copy mode\n" );
@@ -841,9 +842,21 @@ int main( int argc, char *argv[] )
// TODO: leave current workspace
break;
- case SSH_SCP_REQUEST_NEWFILE:
+ case SSH_SCP_REQUEST_NEWFILE: {
+ const char *filename = ssh_scp_request_get_filename( scp[i] );
+ int mode = ssh_scp_request_get_permissions( scp[i] );
+ uint64_t size = ssh_scp_request_get_size64( scp[i] );
+ fprintf( stderr, "Receiving file '%s' with permissions '0%o' of size '%"PRIu64"'\n",
+ filename, mode, size );
+ rc = ssh_scp_accept_request( scp[i] );
+ if( rc != SSH_OK ) {
+ fprintf( stderr, "ERROR: accepting request for file '%s' failed: %s\n",
+ filename, ssh_get_error( scp[i] ) );
+ cleanup_sessions( &session, NULL, &scp, host, port, nof_sessions, args_info.verbose_given > 0 );
+ exit( EXIT_FAILURE );
+ }
// TODO: receive file in workdir of host[i]
- break;
+ } break;
case SSH_SCP_REQUEST_EOF:
// TODO: keep array of eof flags and terminate