diff --git a/example/direct_tcpip.c b/example/direct_tcpip.c index 0e41f11..f7d81ce 100644 --- a/example/direct_tcpip.c +++ b/example/direct_tcpip.c @@ -81,6 +81,12 @@ int main(int argc, char *argv[]) if (argc > 7) remote_destport = atoi(argv[7]); + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* Connect to SSH server */ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); sin.sin_family = AF_INET; @@ -271,5 +277,8 @@ shutdown: #else close(sock); #endif + + libssh2_exit(); + return 0; } diff --git a/example/scp.c b/example/scp.c index fee7b07..e5b6803 100644 --- a/example/scp.c +++ b/example/scp.c @@ -68,6 +68,12 @@ int main(int argc, char *argv[]) scppath = argv[4]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* Ultra basic "connect to port 22 on localhost" * Your code is responsible for creating the socket establishing the * connection @@ -169,5 +175,8 @@ int main(int argc, char *argv[]) close(sock); #endif fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/scp_nonblock.c b/example/scp_nonblock.c index ff0c287..e235d80 100644 --- a/example/scp_nonblock.c +++ b/example/scp_nonblock.c @@ -121,6 +121,12 @@ int main(int argc, char *argv[]) scppath = argv[4]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* Ultra basic "connect to port 22 on localhost" * Your code is responsible for creating the socket establishing the * connection @@ -267,5 +273,8 @@ shutdown: close(sock); #endif fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/scp_write.c b/example/scp_write.c index 343c721..f577466 100644 --- a/example/scp_write.c +++ b/example/scp_write.c @@ -75,6 +75,12 @@ int main(int argc, char *argv[]) scppath = argv[5]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + local = fopen(loclfile, "rb"); if (!local) { fprintf(stderr, "Can't open local file %s\n", loclfile); @@ -204,5 +210,8 @@ int main(int argc, char *argv[]) if (local) fclose(local); fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/scp_write_nonblock.c b/example/scp_write_nonblock.c index d9509a1..688c8bb 100644 --- a/example/scp_write_nonblock.c +++ b/example/scp_write_nonblock.c @@ -79,6 +79,12 @@ int main(int argc, char *argv[]) scppath = argv[5]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + local = fopen(loclfile, "rb"); if (!local) { fprintf(stderr, "Can't local file %s\n", loclfile); @@ -218,5 +224,8 @@ int main(int argc, char *argv[]) close(sock); #endif fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp.c b/example/sftp.c index f443b90..7750d2f 100644 --- a/example/sftp.c +++ b/example/sftp.c @@ -98,6 +98,13 @@ int main(int argc, char *argv[]) if(argc > 4) { sftppath = argv[4]; } + + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* * The application code is responsible for creating the socket * and establishing the connection @@ -241,5 +248,8 @@ int main(int argc, char *argv[]) close(sock); #endif fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp_RW_nonblock.c b/example/sftp_RW_nonblock.c index 56fb339..01d3f93 100644 --- a/example/sftp_RW_nonblock.c +++ b/example/sftp_RW_nonblock.c @@ -72,6 +72,12 @@ int main(int argc, char *argv[]) WSAStartup(MAKEWORD(2,0), &wsadata); #endif + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* Ultra basic "connect to port 22 on localhost" * The application is responsible for creating the socket establishing * the connection @@ -286,5 +292,8 @@ int main(int argc, char *argv[]) if (tempstorage) fclose(tempstorage); printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp_mkdir.c b/example/sftp_mkdir.c index ccbabe0..c8326f5 100644 --- a/example/sftp_mkdir.c +++ b/example/sftp_mkdir.c @@ -70,6 +70,12 @@ int main(int argc, char *argv[]) sftppath = argv[4]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* * The application code is responsible for creating the socket * and establishing the connection @@ -159,6 +165,9 @@ int main(int argc, char *argv[]) #else close(sock); #endif -printf("all done\n"); + printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp_mkdir_nonblock.c b/example/sftp_mkdir_nonblock.c index c9303fa..8b7d338 100644 --- a/example/sftp_mkdir_nonblock.c +++ b/example/sftp_mkdir_nonblock.c @@ -73,6 +73,12 @@ int main(int argc, char *argv[]) sftppath = argv[4]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* * The application code is responsible for creating the socket * and establishing the connection @@ -165,6 +171,9 @@ int main(int argc, char *argv[]) #else close(sock); #endif -printf("all done\n"); + printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp_nonblock.c b/example/sftp_nonblock.c index 984ef84..a103ef4 100644 --- a/example/sftp_nonblock.c +++ b/example/sftp_nonblock.c @@ -121,6 +121,13 @@ int main(int argc, char *argv[]) if (argc > 4) { sftppath = argv[4]; } + + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* * The application code is responsible for creating the socket * and establishing the connection @@ -269,5 +276,8 @@ shutdown: close(sock); #endif fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp_write.c b/example/sftp_write.c index ca65b82..ba40226 100644 --- a/example/sftp_write.c +++ b/example/sftp_write.c @@ -79,6 +79,12 @@ int main(int argc, char *argv[]) sftppath = argv[5]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + local = fopen(loclfile, "rb"); if (!local) { printf("Can't local file %s\n", loclfile); @@ -200,5 +206,8 @@ shutdown: if (local) fclose(local); printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftp_write_nonblock.c b/example/sftp_write_nonblock.c index 3a7308a..a249852 100644 --- a/example/sftp_write_nonblock.c +++ b/example/sftp_write_nonblock.c @@ -82,6 +82,12 @@ int main(int argc, char *argv[]) sftppath = argv[5]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + local = fopen(loclfile, "rb"); if (!local) { printf("Can't local file %s\n", loclfile); @@ -212,5 +218,8 @@ shutdown: close(sock); #endif printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftpdir.c b/example/sftpdir.c index dfa7ad0..6e100be 100644 --- a/example/sftpdir.c +++ b/example/sftpdir.c @@ -70,6 +70,13 @@ int main(int argc, char *argv[]) if(argc > 4) { sftppath = argv[4]; } + + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* * The application code is responsible for creating the socket * and establishing the connection @@ -211,6 +218,9 @@ int main(int argc, char *argv[]) #else close(sock); #endif -printf("all done\n"); + printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/sftpdir_nonblock.c b/example/sftpdir_nonblock.c index 9de2e47..6bb35c8 100644 --- a/example/sftpdir_nonblock.c +++ b/example/sftpdir_nonblock.c @@ -73,6 +73,13 @@ int main(int argc, char *argv[]) if(argc > 4) { sftppath = argv[4]; } + + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* * The application code is responsible for creating the socket * and establishing the connection @@ -224,5 +231,8 @@ int main(int argc, char *argv[]) close(sock); #endif printf("all done\n"); + + libssh2_exit(); + return 0; } diff --git a/example/ssh2.c b/example/ssh2.c index 97fb0ce..afdf552 100644 --- a/example/ssh2.c +++ b/example/ssh2.c @@ -93,6 +93,12 @@ int main(int argc, char *argv[]) password = argv[3]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* Ultra basic "connect to port 22 on localhost". Your code is * responsible for creating the socket establishing the connection */ @@ -247,5 +253,8 @@ int main(int argc, char *argv[]) close(sock); #endif printf("all done!\n"); + + libssh2_exit(); + return 0; } diff --git a/example/ssh2_agent.c b/example/ssh2_agent.c index bebeb88..2327f21 100644 --- a/example/ssh2_agent.c +++ b/example/ssh2_agent.c @@ -65,6 +65,12 @@ int main(int argc, char *argv[]) username = argv[2]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + /* Ultra basic "connect to port 22 on localhost". Your code is * responsible for creating the socket establishing the connection */ @@ -225,5 +231,8 @@ int main(int argc, char *argv[]) } printf("all done!\n"); + + libssh2_exit(); + return rc; } diff --git a/example/ssh2_exec.c b/example/ssh2_exec.c index db4d445..6cd25c1 100644 --- a/example/ssh2_exec.c +++ b/example/ssh2_exec.c @@ -109,6 +109,12 @@ int main(int argc, char *argv[]) commandline = argv[4]; } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + hostaddr = inet_addr(hostname); /* Ultra basic "connect to port 22 on localhost" @@ -289,6 +295,8 @@ shutdown: close(sock); #endif fprintf(stderr, "all done\n"); + + libssh2_exit(); + return 0; } - diff --git a/example/x11.c b/example/x11.c index 793833d..650d0b4 100644 --- a/example/x11.c +++ b/example/x11.c @@ -277,6 +277,12 @@ main (int argc, char *argv[]) fprintf (stderr, "DEBUG is ON: %d\n", set_debug_on); } + rc = libssh2_init (0); + if (rc != 0) { + fprintf (stderr, "libssh2 initialization failed (%d)\n", rc); + return 1; + } + sock = socket (AF_INET, SOCK_STREAM, 0); sin.sin_family = AF_INET; @@ -434,5 +440,8 @@ main (int argc, char *argv[]) channel = NULL; } _normal_mode(); + + libssh2_exit(); + return 0; }