diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-09-02 11:27:31 +0300 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-09-13 14:03:33 +0300 |
commit | 86e6444656d140a7cb4c7931f32729d2e5a85d81 (patch) | |
tree | 72575c00f7bf9716b629a369573b47c80fcf2b56 /examples/libssh_scp.c | |
parent | 8ef62cf784b34fb6306f160f46fa020f4171eef1 (diff) | |
download | libssh-86e6444656d140a7cb4c7931f32729d2e5a85d81.tar.gz libssh-86e6444656d140a7cb4c7931f32729d2e5a85d81.tar.xz libssh-86e6444656d140a7cb4c7931f32729d2e5a85d81.zip |
Begin of scp reading in example
Diffstat (limited to 'examples/libssh_scp.c')
-rw-r--r-- | examples/libssh_scp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/libssh_scp.c b/examples/libssh_scp.c index 626bd3f2..25d95ad6 100644 --- a/examples/libssh_scp.c +++ b/examples/libssh_scp.c @@ -167,6 +167,23 @@ static int open_location(struct location *loc, int flag){ return -1; } return 0; + } else if(loc->is_ssh && flag==READ){ + loc->session=connect_ssh(loc->host, loc->user); + if(!loc->session){ + fprintf(stderr,"Couldn't connect to %s\n",loc->host); + return -1; + } + loc->scp=ssh_scp_new(loc->session,SSH_SCP_READ,loc->path); + if(!loc->scp){ + fprintf(stderr,"error : %s\n",ssh_get_error(loc->session)); + return -1; + } + if(ssh_scp_init(loc->scp)==SSH_ERROR){ + fprintf(stderr,"error : %s\n",ssh_get_error(loc->session)); + ssh_scp_free(loc->scp); + return -1; + } + return 0; } else { loc->file=fopen(loc->path,flag==READ ? "r":"w"); if(!loc->file){ |