From 86e6444656d140a7cb4c7931f32729d2e5a85d81 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Wed, 2 Sep 2009 11:27:31 +0300 Subject: Begin of scp reading in example --- examples/libssh_scp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'examples') 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){ -- cgit v1.2.3