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

style: make includes and examples code style strict

make travis and the makefile rule verify them too

Closes #334
This commit is contained in:
Daniel Stenberg
2019-03-21 09:19:48 +01:00
parent 4186a04cfd
commit 452517d96c
28 changed files with 1060 additions and 958 deletions

View File

@ -40,9 +40,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/sftp_mkdir_nonblock";
const char *username = "username";
const char *password = "password";
const char *sftppath = "/tmp/sftp_mkdir_nonblock";
int rc;
LIBSSH2_SFTP *sftp_session;
@ -50,16 +50,17 @@ int main(int argc, char *argv[])
WSADATA wsadata;
int err;
err = WSAStartup(MAKEWORD(2,0), &wsadata);
if (err != 0) {
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
if(err != 0) {
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
return 1;
}
#endif
if (argc > 1) {
if(argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
}
else {
hostaddr = htonl(0x7F000001);
}
@ -73,9 +74,9 @@ int main(int argc, char *argv[])
sftppath = argv[4];
}
rc = libssh2_init (0);
if (rc != 0) {
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
rc = libssh2_init(0);
if(rc != 0) {
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
return 1;
}
@ -88,7 +89,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),
if(connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
@ -121,15 +122,16 @@ int main(int argc, char *argv[])
}
fprintf(stderr, "\n");
if (auth_pw) {
if(auth_pw) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
if(libssh2_userauth_password(session, username, password)) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} else {
}
else {
/* Or by public key */
if (libssh2_userauth_publickey_fromfile(session, username,
if(libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) {
@ -141,7 +143,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "libssh2_sftp_init()!\n");
sftp_session = libssh2_sftp_init(session);
if (!sftp_session) {
if(!sftp_session) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
@ -151,7 +153,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "libssh2_sftp_mkdirnb()!\n");
/* Make a directory via SFTP */
while (libssh2_sftp_mkdir(sftp_session, sftppath,
while(libssh2_sftp_mkdir(sftp_session, sftppath,
LIBSSH2_SFTP_S_IRWXU|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IXGRP|
LIBSSH2_SFTP_S_IROTH|LIBSSH2_SFTP_S_IXOTH)
@ -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