From e74305c5ebd7d68f0fff01f1cf49eefa132826a2 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Sat, 10 Oct 2009 20:55:17 +0200 Subject: updated the sftp subsystem to follow the type conv --- examples/sample.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'examples') diff --git a/examples/sample.c b/examples/sample.c index c0084c4..d8cbc53 100644 --- a/examples/sample.c +++ b/examples/sample.c @@ -37,7 +37,7 @@ clients must be made or how a client should react. #define MAXCMD 10 char *host; char *user; -int sftp; +int is_sftp; char *cmds[MAXCMD]; struct termios terminal; @@ -97,7 +97,7 @@ static void usage(){ static int opts(int argc, char **argv){ int i; if(strstr(argv[0],"sftp")) - sftp=1; + is_sftp=1; // for(i=0;iname, file->permissions, @@ -452,14 +452,14 @@ void do_sftp(ssh_session session){ /* this will open a file and copy it into your /home directory */ /* the small buffer size was intended to stress the library. of course, you can use a buffer till 20kbytes without problem */ - fichier=sftp_open(sftp_session,"/usr/bin/ssh",O_RDONLY, 0); + fichier=sftp_open(sftp,"/usr/bin/ssh",O_RDONLY, 0); if(!fichier){ fprintf(stderr, "Error opening /usr/bin/ssh: %s\n", ssh_get_error(session)); return; } /* open a file for writing... */ - to=sftp_open(sftp_session,"ssh-copy",O_WRONLY | O_CREAT, 0700); + to=sftp_open(sftp,"ssh-copy",O_WRONLY | O_CREAT, 0700); if(!to){ fprintf(stderr, "Error opening ssh-copy for writing: %s\n", ssh_get_error(session)); @@ -478,7 +478,7 @@ void do_sftp(ssh_session session){ sftp_close(fichier); sftp_close(to); printf("fichiers ferm\n"); - to=sftp_open(sftp_session,"/tmp/grosfichier",O_WRONLY|O_CREAT, 0644); + to=sftp_open(sftp,"/tmp/grosfichier",O_WRONLY|O_CREAT, 0644); for(i=0;i<1000;++i){ len=sftp_write(to,data,8000); printf("wrote %d bytes\n",len); @@ -489,7 +489,7 @@ void do_sftp(ssh_session session){ sftp_close(to); /* close the sftp session */ - sftp_free(sftp_session); + sftp_free(sftp); printf("sftp session terminated\n"); } #endif @@ -682,10 +682,10 @@ int main(int argc, char **argv){ } ssh_log(session, SSH_LOG_FUNCTIONS, "Authentication success"); if(strstr(argv[0],"sftp")){ - sftp=1; + is_sftp=1; ssh_log(session, SSH_LOG_FUNCTIONS, "Doing sftp instead"); } - if(!sftp){ + if(!is_sftp){ if(!cmds[0]) shell(session); else @@ -695,7 +695,7 @@ int main(int argc, char **argv){ else do_sftp(session); #endif - if(!sftp && !cmds[0]) + if(!is_sftp && !cmds[0]) do_cleanup(0); ssh_disconnect(session); ssh_free(session); -- cgit v1.2.3