style: make includes and examples code style strict
make travis and the makefile rule verify them too Closes #334
Этот коммит содержится в:
родитель
4186a04cfd
Коммит
452517d96c
@ -102,7 +102,7 @@ install:
|
||||
script:
|
||||
- |
|
||||
if [ "$B" = "style" ]; then
|
||||
perl src/checksrc.pl -i4 -m79 -ASIZEOFNOPAREN -ASNPRINTF -ACOPYRIGHT -AFOPENMODE -Wsrc/libssh2_config.h src/*.[ch]
|
||||
perl src/checksrc.pl -i4 -m79 -ASIZEOFNOPAREN -ASNPRINTF -ACOPYRIGHT -AFOPENMODE -Wsrc/libssh2_config.h src/*.[ch] include/*.h example/*.c
|
||||
fi
|
||||
- |
|
||||
if [ "$B" = "configure" ]; then
|
||||
|
@ -149,4 +149,4 @@ $(VCPROJ): win32/vc8proj.head win32/vc8proj.foot Makefile.am
|
||||
awk '{printf("%s\r\n", gensub("\r", "", "g"))}' > $@ )
|
||||
|
||||
checksrc:
|
||||
perl src/checksrc.pl -i4 -m79 -ASIZEOFNOPAREN -ASNPRINTF -ACOPYRIGHT -AFOPENMODE -Wsrc/libssh2_config.h src/*.[ch]
|
||||
perl src/checksrc.pl -i4 -m79 -ASIZEOFNOPAREN -ASNPRINTF -ACOPYRIGHT -AFOPENMODE -Wsrc/libssh2_config.h src/*.[ch] include/*.h example/*.c
|
||||
|
@ -98,7 +98,7 @@ int main(int argc, char *argv[])
|
||||
remote_destport = atoi(argv[7]);
|
||||
|
||||
rc = libssh2_init(0);
|
||||
if (rc != 0) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
@ -118,7 +118,8 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
return -1;
|
||||
}
|
||||
@ -177,14 +178,16 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
}
|
||||
else if(auth & AUTH_PUBLICKEY) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@ -204,12 +207,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(local_listenport);
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(local_listenip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(local_listenip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
goto shutdown;
|
||||
}
|
||||
sockopt = 1;
|
||||
setsockopt(listensock, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(sockopt));
|
||||
setsockopt(listensock, SOL_SOCKET, SO_REUSEADDR, &sockopt,
|
||||
sizeof(sockopt));
|
||||
sinlen = sizeof(sin);
|
||||
if(-1 == bind(listensock, (struct sockaddr *)&sin, sinlen)) {
|
||||
perror("bind");
|
||||
@ -269,7 +274,8 @@ int main(int argc, char *argv[])
|
||||
if(len < 0) {
|
||||
perror("read");
|
||||
goto shutdown;
|
||||
} else if (0 == len) {
|
||||
}
|
||||
else if(0 == len) {
|
||||
fprintf(stderr, "The client at %s:%d disconnected!\n", shost,
|
||||
sport);
|
||||
goto shutdown;
|
||||
|
@ -58,7 +58,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if(argc > 2) {
|
||||
@ -72,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
rc = libssh2_init(0);
|
||||
if (rc != 0) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
@ -125,11 +126,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
#define HOME_DIR "/home/username/"
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
HOME_DIR ".ssh/id_rsa.pub",
|
||||
HOME_DIR ".ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
@ -170,7 +173,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
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);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -112,7 +112,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if(argc > 2) {
|
||||
@ -140,7 +141,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
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))) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -187,7 +188,8 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
@ -262,7 +264,8 @@ int main(int argc, char *argv[])
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %ld bytes in %ld ms = %.1f bytes/sec spin: %d\n", (long)total,
|
||||
fprintf(stderr, "Got %ld bytes in %ld ms = %.1f bytes/sec spin: %d\n",
|
||||
(long)total,
|
||||
time_ms, total/(time_ms/1000.0), spin);
|
||||
#else
|
||||
fprintf(stderr, "Got %ld bytes spin: %d\n", (long)total, spin);
|
||||
|
@ -62,7 +62,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if(argc > 2) {
|
||||
@ -144,11 +145,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
#define HOME "/home/username/"
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
HOME ".ssh/id_rsa.pub",
|
||||
HOME ".ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
@ -207,7 +210,7 @@ int main(int argc, char *argv[])
|
||||
shutdown:
|
||||
|
||||
if(session) {
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
}
|
||||
#ifdef WIN32
|
||||
|
@ -101,7 +101,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if(argc > 2) {
|
||||
@ -185,12 +186,15 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
#define HOME "/home/username/"
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) == LIBSSH2_ERROR_EAGAIN);
|
||||
HOME ".ssh/id_rsa.pub",
|
||||
HOME ".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
@ -266,7 +270,7 @@ int main(int argc, char *argv[])
|
||||
shutdown:
|
||||
|
||||
while(libssh2_session_disconnect(session,
|
||||
"Normal Shutdown, Thank you for playing") ==
|
||||
"Normal Shutdown,") ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
|
@ -45,7 +45,8 @@ const char *sftppath="/tmp/TEST";
|
||||
|
||||
|
||||
static void kbd_callback(const char *name, int name_len,
|
||||
const char *instruction, int instruction_len, int num_prompts,
|
||||
const char *instruction, int instruction_len,
|
||||
int num_prompts,
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||
void **abstract)
|
||||
@ -117,7 +118,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -214,25 +216,32 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
}
|
||||
else if(auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username, &kbd_callback) ) {
|
||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
}
|
||||
else if(auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1, keyfile2, password)) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@ -264,7 +273,8 @@ int main(int argc, char *argv[])
|
||||
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
|
||||
if(rc > 0) {
|
||||
write(1, mem, rc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} while(1);
|
||||
@ -274,7 +284,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -180,7 +180,8 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while((rc =
|
||||
libssh2_userauth_publickey_fromfile(session, username,
|
||||
@ -339,7 +340,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if (err != 0) {
|
||||
if(err) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
@ -66,7 +66,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -84,7 +85,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
rc = libssh2_init(0);
|
||||
if (rc != 0) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
@ -146,11 +147,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
#define HOME "/home/username/"
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
HOME ".ssh/id_rsa.pub",
|
||||
HOME ".ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
|
@ -59,7 +59,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -127,7 +128,8 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
@ -161,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -59,7 +59,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -127,7 +128,8 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
@ -161,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -112,7 +112,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -189,7 +190,8 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while((rc =
|
||||
libssh2_userauth_publickey_fromfile(session, username,
|
||||
@ -255,7 +257,8 @@ int main(int argc, char *argv[])
|
||||
if(rc > 0) {
|
||||
total += rc;
|
||||
write(1, mem, rc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} while(1);
|
||||
@ -263,7 +266,8 @@ int main(int argc, char *argv[])
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&end, NULL);
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n",
|
||||
total,
|
||||
time_ms, total/(time_ms/1000.0), spin);
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
|
@ -65,7 +65,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -145,11 +146,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *privkey = "/home/username/.ssh/id_rsa.pub";
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
pubkey, privkey,
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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:
|
||||
*
|
||||
* "sftp 192.168.0.1 user password sftp_write_nonblock.c /tmp/sftp_write_nonblock.c"
|
||||
* "sftp 192.168.0.1 user password thisfile /tmp/storehere"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
@ -105,7 +105,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -188,11 +189,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *privkey = "/home/username/.ssh/id_rsa";
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
pubkey, privkey,
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
@ -217,10 +220,10 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
sftp_handle =
|
||||
libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|
|
||||
LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
|
||||
if(!sftp_handle &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
@ -268,7 +271,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
while (libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")
|
||||
while(libssh2_session_disconnect(session, "Normal Shutdown")
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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:
|
||||
*
|
||||
* "sftp 192.168.0.1 user password sftp_write_nonblock.c /tmp/sftp_write_nonblock.c"
|
||||
* "sftp 192.168.0.1 user password file /tmp/storehere"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
@ -105,7 +105,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -188,11 +189,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
#define PUBKEY "/home/username/.ssh/id_rsa.pub"
|
||||
#define PRIVKEY "/home/username/.ssh/id_rsa"
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
PUBKEY, PRIVKEY,
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
@ -217,7 +220,8 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
sftp_handle =
|
||||
libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|
|
||||
LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
|
||||
@ -277,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
while (libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")
|
||||
while(libssh2_session_disconnect(session, "Normal Shutdown")
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
|
@ -91,7 +91,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -184,30 +185,36 @@ int main(int argc, char *argv[])
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "\tAuthentication by password failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by password succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
}
|
||||
else if(auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
}
|
||||
else if(auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@ -246,7 +253,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(longentry[0] != '\0') {
|
||||
printf("%s\n", longentry);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) {
|
||||
/* this should check what permissions it
|
||||
is and print the output accordingly */
|
||||
@ -280,7 +288,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -52,6 +52,8 @@ int main(int argc, char *argv[])
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/secretdir";
|
||||
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *privkey = "/home/username/.ssh/id_rsa";
|
||||
int rc;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
@ -69,7 +71,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -143,12 +146,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) == LIBSSH2_ERROR_EAGAIN);
|
||||
pubkey, privkey,
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
@ -196,13 +200,15 @@ int main(int argc, char *argv[])
|
||||
/* this should check what permissions it
|
||||
is and print the output accordingly */
|
||||
printf("--fix----- ");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf("---------- ");
|
||||
}
|
||||
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_UIDGID) {
|
||||
printf("%4d %4d ", (int) attrs.uid, (int) attrs.gid);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf(" - - ");
|
||||
}
|
||||
|
||||
@ -215,7 +221,8 @@ int main(int argc, char *argv[])
|
||||
else if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
/* blocking */
|
||||
fprintf(stderr, "Blocking\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -226,7 +233,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -86,7 +86,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -169,36 +170,43 @@ int main(int argc, char *argv[])
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "\tAuthentication by password failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by password succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
}
|
||||
else if(auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
}
|
||||
else if(auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* Request a shell */
|
||||
if (!(channel = libssh2_channel_open_session(session))) {
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Unable to open a session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@ -156,7 +157,8 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s failed!\n",
|
||||
username, identity->comment);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s succeeded!\n",
|
||||
username, identity->comment);
|
||||
@ -172,7 +174,8 @@ int main(int argc, char *argv[])
|
||||
/* We're authenticated now. */
|
||||
|
||||
/* Request a shell */
|
||||
if (!(channel = libssh2_channel_open_session(session))) {
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Unable to open a session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
@ -239,7 +239,8 @@ int main(int argc, char *argv[])
|
||||
for(i = 0; i < BUFSIZE; i++)
|
||||
buffer[i] = 'A';
|
||||
|
||||
if ((fds = malloc (sizeof (LIBSSH2_POLLFD))) == NULL) {
|
||||
fds = malloc(sizeof (LIBSSH2_POLLFD));
|
||||
if(!fds) {
|
||||
fprintf(stderr, "malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -301,7 +302,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* all data written, send EOF */
|
||||
rc = libssh2_channel_send_eof(channel);
|
||||
|
||||
|
@ -237,35 +237,28 @@ int main(int argc, char *argv[])
|
||||
/* Exec non-blocking on the remove host */
|
||||
while((channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
||||
LIBSSH2_ERROR_EAGAIN )
|
||||
{
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if( channel == NULL )
|
||||
{
|
||||
if(channel == NULL) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||
LIBSSH2_ERROR_EAGAIN )
|
||||
{
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if( rc != 0 )
|
||||
{
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
for( ;; )
|
||||
{
|
||||
for(;;) {
|
||||
/* loop until we block */
|
||||
int rc;
|
||||
do
|
||||
{
|
||||
do {
|
||||
char buffer[0x4000];
|
||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
||||
if( rc > 0 )
|
||||
{
|
||||
if(rc > 0) {
|
||||
int i;
|
||||
bytecount += rc;
|
||||
fprintf(stderr, "We read:\n");
|
||||
@ -283,8 +276,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* this is due to blocking that would occur otherwise so we loop on
|
||||
this condition */
|
||||
if( rc == LIBSSH2_ERROR_EAGAIN )
|
||||
{
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
else
|
||||
@ -294,8 +286,7 @@ int main(int argc, char *argv[])
|
||||
while((rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN)
|
||||
waitsocket(sock, session);
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
if(rc == 0) {
|
||||
exitcode = libssh2_channel_get_exit_status(channel);
|
||||
libssh2_channel_get_exit_signal(channel, &exitsignal,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
|
@ -98,7 +98,8 @@ static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
||||
} while(!specialsequence && rd < buflen);
|
||||
|
||||
if(!specialsequence) {
|
||||
fprintf(stderr, "%s: ]]>]]> not found! read buffer too small?\n", __func__);
|
||||
fprintf(stderr, "%s: ]]>]]> not found! read buffer too small?\n",
|
||||
__func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -162,7 +163,8 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
||||
return -1;
|
||||
}
|
||||
@ -221,14 +223,16 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
}
|
||||
else if(auth & AUTH_PUBLICKEY) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "Authentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "Authentication by public key succeeded.\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@ -269,7 +273,8 @@ int main(int argc, char *argv[])
|
||||
if(-1 == len)
|
||||
goto shutdown;
|
||||
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s", (int)len, buf);
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s",
|
||||
(int)len, buf);
|
||||
|
||||
fprintf(stderr, "Sending NETCONF <rpc>\n");
|
||||
snprintf(buf, sizeof(buf),
|
||||
@ -286,7 +291,8 @@ int main(int argc, char *argv[])
|
||||
if(-1 == len)
|
||||
goto shutdown;
|
||||
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s", (int)len, buf);
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s",
|
||||
(int)len, buf);
|
||||
|
||||
shutdown:
|
||||
if(channel)
|
||||
|
@ -115,7 +115,8 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
return -1;
|
||||
}
|
||||
@ -174,14 +175,16 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
}
|
||||
else if(auth & AUTH_PUBLICKEY) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@ -228,7 +231,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(local_destport);
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(local_destip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(local_destip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
goto shutdown;
|
||||
}
|
||||
@ -258,7 +262,8 @@ int main(int argc, char *argv[])
|
||||
if(len < 0) {
|
||||
perror("read");
|
||||
goto shutdown;
|
||||
} else if (0 == len) {
|
||||
}
|
||||
else if(0 == len) {
|
||||
fprintf(stderr, "The local server at %s:%d disconnected!\n",
|
||||
local_destip, local_destport);
|
||||
goto shutdown;
|
||||
|
@ -197,10 +197,12 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
||||
FD_ZERO(&set);
|
||||
FD_SET(sock, &set);
|
||||
|
||||
if ((buf = calloc (bufsize, sizeof(char))) == NULL)
|
||||
buf = calloc(bufsize, sizeof(char));
|
||||
if(!buf)
|
||||
return 0;
|
||||
|
||||
if ((fds = malloc (sizeof (LIBSSH2_POLLFD))) == NULL) {
|
||||
fds = malloc(sizeof (LIBSSH2_POLLFD));
|
||||
if(!fds) {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
@ -403,10 +405,12 @@ main (int argc, char *argv[])
|
||||
w_size.ws_row);
|
||||
}
|
||||
|
||||
if ((buf = calloc (bufsiz, sizeof(char))) == NULL)
|
||||
buf = calloc(bufsiz, sizeof(char));
|
||||
if(buf == NULL)
|
||||
break;
|
||||
|
||||
if ((fds = malloc (sizeof (LIBSSH2_POLLFD))) == NULL) {
|
||||
fds = malloc(sizeof (LIBSSH2_POLLFD));
|
||||
if(fds == NULL) {
|
||||
free(buf);
|
||||
break;
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ typedef off_t libssh2_struct_stat_size;
|
||||
|
||||
#ifndef LIBSSH2_STRUCT_STAT_SIZE_FORMAT
|
||||
# ifdef __VMS
|
||||
/* We have to roll our own format here because %z is a C99-ism we don't have. */
|
||||
/* We have to roll our own format here because %z is a C99-ism we don't
|
||||
have. */
|
||||
# if __USE_OFF64_T || __USING_STD_STAT
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%Ld"
|
||||
# else
|
||||
@ -229,11 +230,11 @@ typedef off_t libssh2_struct_stat_size;
|
||||
/* Part of every banner, user specified or not */
|
||||
#define LIBSSH2_SSH_BANNER "SSH-2.0-libssh2_" LIBSSH2_VERSION
|
||||
|
||||
/* We *could* add a comment here if we so chose */
|
||||
#define LIBSSH2_SSH_DEFAULT_BANNER LIBSSH2_SSH_BANNER
|
||||
#define LIBSSH2_SSH_DEFAULT_BANNER_WITH_CRLF LIBSSH2_SSH_DEFAULT_BANNER "\r\n"
|
||||
|
||||
/* Default generate and safe prime sizes for diffie-hellman-group-exchange-sha1 */
|
||||
/* Default generate and safe prime sizes for
|
||||
diffie-hellman-group-exchange-sha1 */
|
||||
#define LIBSSH2_DH_GEX_MINGROUP 1024
|
||||
#define LIBSSH2_DH_GEX_OPTGROUP 1536
|
||||
#define LIBSSH2_DH_GEX_MAXGROUP 2048
|
||||
@ -324,10 +325,12 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
LIBSSH2_CHANNEL *channel, void **channel_abstract)
|
||||
|
||||
/* I/O callbacks */
|
||||
#define LIBSSH2_RECV_FUNC(name) ssize_t name(libssh2_socket_t socket, \
|
||||
#define LIBSSH2_RECV_FUNC(name) \
|
||||
ssize_t name(libssh2_socket_t socket, \
|
||||
void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
#define LIBSSH2_SEND_FUNC(name) ssize_t name(libssh2_socket_t socket, \
|
||||
#define LIBSSH2_SEND_FUNC(name) \
|
||||
ssize_t name(libssh2_socket_t socket, \
|
||||
const void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
|
||||
@ -468,7 +471,8 @@ typedef struct _LIBSSH2_POLLFD {
|
||||
#define LIBSSH2_ERROR_FILE -16
|
||||
#define LIBSSH2_ERROR_METHOD_NONE -17
|
||||
#define LIBSSH2_ERROR_AUTHENTICATION_FAILED -18
|
||||
#define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED LIBSSH2_ERROR_AUTHENTICATION_FAILED
|
||||
#define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED \
|
||||
LIBSSH2_ERROR_AUTHENTICATION_FAILED
|
||||
#define LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED -19
|
||||
#define LIBSSH2_ERROR_CHANNEL_OUTOFORDER -20
|
||||
#define LIBSSH2_ERROR_CHANNEL_FAILURE -21
|
||||
@ -609,12 +613,14 @@ LIBSSH2_API char *libssh2_userauth_list(LIBSSH2_SESSION *session,
|
||||
unsigned int username_len);
|
||||
LIBSSH2_API int libssh2_userauth_authenticated(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
unsigned int username_len,
|
||||
const char *password,
|
||||
unsigned int password_len,
|
||||
LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)));
|
||||
LIBSSH2_PASSWD_CHANGEREQ_FUNC
|
||||
((*passwd_change_cb)));
|
||||
|
||||
#define libssh2_userauth_password(session, username, password) \
|
||||
libssh2_userauth_password_ex((session), (username), \
|
||||
@ -641,7 +647,8 @@ libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const unsigned char *pubkeydata,
|
||||
size_t pubkeydata_len,
|
||||
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*sign_callback)),
|
||||
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC
|
||||
((*sign_callback)),
|
||||
void **abstract);
|
||||
|
||||
LIBSSH2_API int
|
||||
@ -733,7 +740,8 @@ libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host,
|
||||
|
||||
LIBSSH2_API LIBSSH2_LISTENER *
|
||||
libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, const char *host,
|
||||
int port, int *bound_port, int queue_maxsize);
|
||||
int port, int *bound_port,
|
||||
int queue_maxsize);
|
||||
#define libssh2_channel_forward_listen(session, port) \
|
||||
libssh2_channel_forward_listen_ex((session), NULL, (port), NULL, 16)
|
||||
|
||||
@ -764,8 +772,10 @@ LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel,
|
||||
libssh2_channel_request_pty_ex((channel), (term), \
|
||||
(unsigned int)strlen(term), \
|
||||
NULL, 0, \
|
||||
LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, \
|
||||
LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX)
|
||||
LIBSSH2_TERM_WIDTH, \
|
||||
LIBSSH2_TERM_HEIGHT, \
|
||||
LIBSSH2_TERM_WIDTH_PX, \
|
||||
LIBSSH2_TERM_HEIGHT_PX)
|
||||
|
||||
LIBSSH2_API int libssh2_channel_request_pty_size_ex(LIBSSH2_CHANNEL *channel,
|
||||
int width, int height,
|
||||
@ -835,7 +845,8 @@ LIBSSH2_API ssize_t libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel,
|
||||
#define libssh2_channel_write(channel, buf, buflen) \
|
||||
libssh2_channel_write_ex((channel), 0, (buf), (buflen))
|
||||
#define libssh2_channel_write_stderr(channel, buf, buflen) \
|
||||
libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen))
|
||||
libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, \
|
||||
(buf), (buflen))
|
||||
|
||||
LIBSSH2_API unsigned long
|
||||
libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel,
|
||||
|
@ -81,9 +81,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Publickey Subsystem */
|
||||
LIBSSH2_API LIBSSH2_PUBLICKEY *libssh2_publickey_init(LIBSSH2_SESSION *session);
|
||||
LIBSSH2_API LIBSSH2_PUBLICKEY *
|
||||
libssh2_publickey_init(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey,
|
||||
LIBSSH2_API int
|
||||
libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey,
|
||||
const unsigned char *name,
|
||||
unsigned long name_len,
|
||||
const unsigned char *blob,
|
||||
@ -107,7 +109,8 @@ LIBSSH2_API int
|
||||
libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey,
|
||||
unsigned long *num_keys,
|
||||
libssh2_publickey_list **pkey_list);
|
||||
LIBSSH2_API void libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey,
|
||||
LIBSSH2_API void
|
||||
libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey,
|
||||
libssh2_publickey_list *pkey_list);
|
||||
|
||||
LIBSSH2_API int libssh2_publickey_shutdown(LIBSSH2_PUBLICKEY *pkey);
|
||||
|
@ -224,7 +224,8 @@ LIBSSH2_API unsigned long libssh2_sftp_last_error(LIBSSH2_SFTP *sftp);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp);
|
||||
|
||||
/* File / Directory Ops */
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp,
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp,
|
||||
const char *filename,
|
||||
unsigned int filename_len,
|
||||
unsigned long flags,
|
||||
@ -331,7 +332,8 @@ LIBSSH2_API int libssh2_sftp_symlink_ex(LIBSSH2_SFTP *sftp,
|
||||
const char *path,
|
||||
unsigned int path_len,
|
||||
char *target,
|
||||
unsigned int target_len, int link_type);
|
||||
unsigned int target_len,
|
||||
int link_type);
|
||||
#define libssh2_sftp_symlink(sftp, orig, linkpath) \
|
||||
libssh2_sftp_symlink_ex((sftp), (orig), strlen(orig), (linkpath), \
|
||||
strlen(linkpath), LIBSSH2_SFTP_SYMLINK)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user