include libssh_config.h to get the configure vars in.
Этот коммит содержится в:
родитель
40970adb53
Коммит
145bbabb96
@ -9,7 +9,7 @@ noinst_PROGRAMS = ssh2 \
|
|||||||
sftp_RW_nonblock \
|
sftp_RW_nonblock \
|
||||||
sftpdir sftpdir_nonblock
|
sftpdir sftpdir_nonblock
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src
|
||||||
LDADD = $(top_builddir)/src/libssh2.la
|
LDADD = $(top_builddir)/src/libssh2.la
|
||||||
|
|
||||||
ssh2_SOURCES = ssh2.c
|
ssh2_SOURCES = ssh2.c
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: scp.c,v 1.5 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: scp.c,v 1.6 2007/04/26 23:59:14 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do a simple SCP transfer.
|
* Sample showing how to do a simple SCP transfer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: scp_nonblock.c,v 1.2 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: scp_nonblock.c,v 1.3 2007/04/26 23:59:14 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SCP transfers in a non-blocking manner.
|
* Sample showing how to do SCP transfers in a non-blocking manner.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp.c,v 1.6 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp.c,v 1.7 2007/04/26 23:59:14 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP transfers.
|
* Sample showing how to do SFTP transfers.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_RW_nonblock.c,v 1.2 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp_RW_nonblock.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP transfers in a non-blocking manner.
|
* Sample showing how to do SFTP transfers in a non-blocking manner.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_mkdir.c,v 1.2 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp_mkdir.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP mkdir
|
* Sample showing how to do SFTP mkdir
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_mkdir_nonblock.c,v 1.2 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp_mkdir_nonblock.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP non-blocking mkdir.
|
* Sample showing how to do SFTP non-blocking mkdir.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_nonblock.c,v 1.6 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp_nonblock.c,v 1.7 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP non-blocking transfers.
|
* Sample showing how to do SFTP non-blocking transfers.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_write.c,v 1.2 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp_write.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP write transfers.
|
* Sample showing how to do SFTP write transfers.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftp_write_nonblock.c,v 1.2 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftp_write_nonblock.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SFTP non-blocking write transfers.
|
* Sample showing how to do SFTP non-blocking write transfers.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftpdir.c,v 1.3 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftpdir.c,v 1.4 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample doing an SFTP directory listing.
|
* Sample doing an SFTP directory listing.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sftpdir_nonblock.c,v 1.3 2007/04/26 22:59:29 gknauf Exp $
|
* $Id: sftpdir_nonblock.c,v 1.4 2007/04/26 23:59:15 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample doing an SFTP directory listing.
|
* Sample doing an SFTP directory listing.
|
||||||
*
|
*
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
@ -1,4 +1,17 @@
|
|||||||
#include "libssh2.h"
|
/*
|
||||||
|
* $Id: ssh2.c,v 1.3 2007/04/26 23:59:15 gknauf Exp $
|
||||||
|
*
|
||||||
|
* Sample showing how to do SSH2 connect.
|
||||||
|
*
|
||||||
|
* The sample code has default values for host name, user name, password
|
||||||
|
* and path to copy, but you can specify them on the command line like:
|
||||||
|
*
|
||||||
|
* "ssh2 host user password"
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libssh2.h>
|
||||||
|
#include <libssh2_sftp.h>
|
||||||
|
#include <libssh2_config.h>
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
@ -21,6 +34,7 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
unsigned long hostaddr;
|
||||||
int sock, i, auth_pw = 1;
|
int sock, i, auth_pw = 1;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
const char *fingerprint;
|
const char *fingerprint;
|
||||||
@ -34,6 +48,19 @@ int main(int argc, char *argv[])
|
|||||||
WSAStartup(WINSOCK_VERSION, &wsadata);
|
WSAStartup(WINSOCK_VERSION, &wsadata);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
hostaddr = inet_addr(argv[1]);
|
||||||
|
} else {
|
||||||
|
hostaddr = htonl(0x7F000001);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(argc > 2) {
|
||||||
|
username = argv[2];
|
||||||
|
}
|
||||||
|
if(argc > 3) {
|
||||||
|
password = argv[3];
|
||||||
|
}
|
||||||
|
|
||||||
/* Ultra basic "connect to port 22 on localhost"
|
/* Ultra basic "connect to port 22 on localhost"
|
||||||
* Your code is responsible for creating the socket establishing the connection
|
* Your code is responsible for creating the socket establishing the connection
|
||||||
*/
|
*/
|
||||||
@ -43,8 +70,9 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_port = htons(22);
|
sin.sin_port = htons(22);
|
||||||
sin.sin_addr.s_addr = htonl(0x7F000001);
|
sin.sin_addr.s_addr = hostaddr;
|
||||||
if (connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in)) != 0) {
|
if (connect(sock, (struct sockaddr*)(&sin),
|
||||||
|
sizeof(struct sockaddr_in)) != 0) {
|
||||||
fprintf(stderr, "failed to connect!\n");
|
fprintf(stderr, "failed to connect!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -69,13 +97,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if(argc > 1) {
|
|
||||||
username = argv[1];
|
|
||||||
}
|
|
||||||
if(argc > 2) {
|
|
||||||
password = argv[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth_pw) {
|
if (auth_pw) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if (libssh2_userauth_password(session, username, password)) {
|
if (libssh2_userauth_password(session, username, password)) {
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user