aboutsummaryrefslogtreecommitdiff
path: root/sample.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-07-25 11:54:37 +0200
committerAndreas Schneider <mail@cynapses.org>2009-07-25 11:55:42 +0200
commit6d5b36fb79d64d61baa9493ca48f70dd2d265eb2 (patch)
tree3a9d76e3d9a33fb33d91950eaa4b65328d3512a2 /sample.c
parent8ce6bd3459ed379337a709fa5d32b05021c7280f (diff)
downloadlibssh-6d5b36fb79d64d61baa9493ca48f70dd2d265eb2.tar.gz
libssh-6d5b36fb79d64d61baa9493ca48f70dd2d265eb2.tar.xz
libssh-6d5b36fb79d64d61baa9493ca48f70dd2d265eb2.zip
Add symlink and readlink test to sample.
Diffstat (limited to 'sample.c')
-rw-r--r--sample.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sample.c b/sample.c
index 2d725dc5..1132522e 100644
--- a/sample.c
+++ b/sample.c
@@ -285,6 +285,8 @@ void do_sftp(SSH_SESSION *session){
int len=1;
int i;
char data[8000]={0};
+ char *link;
+
if(!sftp_session){
fprintf(stderr, "sftp error initialising channel: %s\n",
ssh_get_error(session));
@@ -295,6 +297,23 @@ void do_sftp(SSH_SESSION *session){
ssh_get_error(session));
return;
}
+
+ /* test symlink and readlink */
+ if (sftp_symlink(sftp_session, "/tmp/this_is_the_link",
+ "/tmp/sftp_symlink_test") < 0) {
+ fprintf(stderr, "Could not create link (%s)\n", ssh_get_error(session));
+ return;
+ }
+
+ link = sftp_readlink(sftp_session, "/tmp/sftp_symlink_test");
+ if (link == NULL) {
+ fprintf(stderr, "Could not read link (%s)\n", ssh_get_error(session));
+ return;
+ }
+ printf("readlink /tmp/sftp_symlink_test: %s\n", link);
+
+ sftp_unlink(sftp_session, "/tmp/sftp_symlink_test");
+
/* the connection is made */
/* opening a directory */
dir=sftp_opendir(sftp_session,"./");