1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

examples: use stderr for messages, stdout for data

Reported by: Karel Srot
Bug: https://bugzilla.redhat.com/867462
This commit is contained in:
Kamil Dudka
2012-10-22 13:29:27 +02:00
parent e2bb780d77
commit b31e35aba6
20 changed files with 148 additions and 141 deletions

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
local = fopen(loclfile, "rb");
if (!local) {
printf("Can't local file %s\n", loclfile);
fprintf(stderr, "Can't open local file %s\n", loclfile);
return -1;
}
@ -129,16 +129,16 @@ int main(int argc, char *argv[])
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
printf("Fingerprint: ");
fprintf(stderr, "Fingerprint: ");
for(i = 0; i < 20; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
fprintf(stderr, "\n");
if (auth_pw) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
printf("Authentication by password failed.\n");
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} else {
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) {
printf("\tAuthentication by public key failed\n");
fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown;
}
}
@ -174,12 +174,12 @@ int main(int argc, char *argv[])
}
if(libssh2_sftp_fstat_ex(sftp_handle, &attrs, 0) < 0) {
printf("libssh2_sftp_fstat_ex failed\n");
fprintf(stderr, "libssh2_sftp_fstat_ex failed\n");
goto shutdown;
}
else
libssh2_sftp_seek64(sftp_handle, attrs.filesize);
printf("Did a seek to position %ld\n", (long) attrs.filesize);
fprintf(stderr, "Did a seek to position %ld\n", (long) attrs.filesize);
fprintf(stderr, "libssh2_sftp_open() a handle for APPEND\n");
@ -222,7 +222,7 @@ shutdown:
#endif
if (local)
fclose(local);
printf("all done\n");
fprintf(stderr, "all done\n");
libssh2_exit();