removed compiler warnings, narrowed some source lines, killed trailing
whitespace
This commit is contained in:
parent
14881b2370
commit
e0254f3936
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: scp_write.c,v 1.1 2007/06/06 12:34:08 jehousley Exp $
|
* $Id: scp_write.c,v 1.2 2007/07/14 20:54:47 bagder Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do a simple SCP transfer.
|
* Sample showing how to do a simple SCP transfer.
|
||||||
*/
|
*/
|
||||||
@ -142,10 +142,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//libssh2_trace(session, 0xFFFF);
|
|
||||||
|
|
||||||
/* Request a file via SCP */
|
/* Request a file via SCP */
|
||||||
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode, (unsigned long)fileinfo.st_size);
|
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode,
|
||||||
|
(unsigned long)fileinfo.st_size);
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
fprintf(stderr, "Unable to open a session\n");
|
fprintf(stderr, "Unable to open a session\n");
|
||||||
@ -178,9 +177,6 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "Waiting for channel to close\n");
|
fprintf(stderr, "Waiting for channel to close\n");
|
||||||
libssh2_channel_wait_closed(channel);
|
libssh2_channel_wait_closed(channel);
|
||||||
|
|
||||||
// fprintf(stderr, "Closing channel\n");
|
|
||||||
// libssh2_channel_close(channel);
|
|
||||||
|
|
||||||
libssh2_channel_free(channel);
|
libssh2_channel_free(channel);
|
||||||
channel = NULL;
|
channel = NULL;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: scp_write_nonblock.c,v 1.3 2007/07/05 11:08:17 jehousley Exp $
|
* $Id: scp_write_nonblock.c,v 1.4 2007/07/14 20:54:47 bagder Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do a simple SCP transfer.
|
* Sample showing how to do a simple SCP transfer.
|
||||||
*/
|
*/
|
||||||
@ -141,7 +141,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (auth_pw) {
|
if (auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
|
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||||
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "Authentication by password failed.\n");
|
fprintf(stderr, "Authentication by password failed.\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
@ -158,13 +159,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// libssh2_trace(session, 0xFF7D);
|
|
||||||
|
|
||||||
/* Request a file via SCP */
|
/* Request a file via SCP */
|
||||||
do {
|
do {
|
||||||
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode, (unsigned long)fileinfo.st_size);
|
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode,
|
||||||
|
(unsigned long)fileinfo.st_size);
|
||||||
|
|
||||||
if ((!channel) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
if ((!channel) && (libssh2_session_last_errno(session) !=
|
||||||
|
LIBSSH2_ERROR_EAGAIN)) {
|
||||||
char *err_msg;
|
char *err_msg;
|
||||||
|
|
||||||
libssh2_session_last_error(session, &err_msg, NULL, 0);
|
libssh2_session_last_error(session, &err_msg, NULL, 0);
|
||||||
@ -184,7 +185,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
/* write data in a loop until we block */
|
/* write data in a loop until we block */
|
||||||
while ((rc = libssh2_channel_write(channel, ptr, nread)) == LIBSSH2_ERROR_EAGAIN);
|
while ((rc = libssh2_channel_write(channel, ptr, nread)) ==
|
||||||
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "ERROR %d\n", rc);
|
fprintf(stderr, "ERROR %d\n", rc);
|
||||||
}
|
}
|
||||||
@ -202,15 +204,13 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "Waiting for channel to close\n");
|
fprintf(stderr, "Waiting for channel to close\n");
|
||||||
while (libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
|
while (libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||||
|
|
||||||
// fprintf(stderr, "Closing channel\n");
|
|
||||||
// while (libssh2_channel_close(channel) == LIBSSH2_ERROR_EAGAIN);
|
|
||||||
|
|
||||||
libssh2_channel_free(channel);
|
libssh2_channel_free(channel);
|
||||||
channel = NULL;
|
channel = NULL;
|
||||||
|
|
||||||
shutdown:
|
shutdown:
|
||||||
|
|
||||||
while ((rc = libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
|
while ((rc = libssh2_session_disconnect(session,
|
||||||
|
"Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
|
||||||
libssh2_session_free(session);
|
libssh2_session_free(session);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_write.c,v 1.4 2007/06/06 12:34:09 jehousley Exp $
|
* $Id: sftp_write.c,v 1.5 2007/07/14 20:54:47 bagder Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP write transfers.
|
* Sample showing how to do SFTP write transfers.
|
||||||
*
|
*
|
||||||
@ -147,8 +147,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//libssh2_trace(session, 0xFFFF);
|
|
||||||
|
|
||||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||||
sftp_session = libssh2_sftp_init(session);
|
sftp_session = libssh2_sftp_init(session);
|
||||||
|
|
||||||
@ -195,7 +193,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
shutdown:
|
shutdown:
|
||||||
|
|
||||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
libssh2_session_disconnect(session,
|
||||||
|
"Normal Shutdown, Thank you for playing");
|
||||||
libssh2_session_free(session);
|
libssh2_session_free(session);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: ssh2.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
* $Id: ssh2.c,v 1.4 2007/07/14 20:54:47 bagder Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SSH2 connect.
|
* Sample showing how to do SSH2 connect.
|
||||||
*
|
*
|
||||||
@ -25,6 +25,9 @@
|
|||||||
# ifdef HAVE_UNISTD_H
|
# ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
# ifdef HAVE_ARPA_INET_H
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user