mirror of
https://github.com/libssh2/libssh2.git
synced 2025-07-31 00:03:08 +03:00
Eat our own dog food, call libssh2_init and libssh2_exit in the examples.
This commit is contained in:
@ -81,6 +81,12 @@ int main(int argc, char *argv[])
|
|||||||
if (argc > 7)
|
if (argc > 7)
|
||||||
remote_destport = atoi(argv[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 */
|
/* Connect to SSH server */
|
||||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
@ -271,5 +277,8 @@ shutdown:
|
|||||||
#else
|
#else
|
||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,12 @@ int main(int argc, char *argv[])
|
|||||||
scppath = argv[4];
|
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"
|
/* Ultra basic "connect to port 22 on localhost"
|
||||||
* Your code is responsible for creating the socket establishing the
|
* Your code is responsible for creating the socket establishing the
|
||||||
* connection
|
* connection
|
||||||
@ -169,5 +175,8 @@ int main(int argc, char *argv[])
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,12 @@ int main(int argc, char *argv[])
|
|||||||
scppath = argv[4];
|
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"
|
/* Ultra basic "connect to port 22 on localhost"
|
||||||
* Your code is responsible for creating the socket establishing the
|
* Your code is responsible for creating the socket establishing the
|
||||||
* connection
|
* connection
|
||||||
@ -267,5 +273,8 @@ shutdown:
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,12 @@ int main(int argc, char *argv[])
|
|||||||
scppath = argv[5];
|
scppath = argv[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = libssh2_init (0);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
local = fopen(loclfile, "rb");
|
local = fopen(loclfile, "rb");
|
||||||
if (!local) {
|
if (!local) {
|
||||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||||
@ -204,5 +210,8 @@ int main(int argc, char *argv[])
|
|||||||
if (local)
|
if (local)
|
||||||
fclose(local);
|
fclose(local);
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,12 @@ int main(int argc, char *argv[])
|
|||||||
scppath = argv[5];
|
scppath = argv[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = libssh2_init (0);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
local = fopen(loclfile, "rb");
|
local = fopen(loclfile, "rb");
|
||||||
if (!local) {
|
if (!local) {
|
||||||
fprintf(stderr, "Can't local file %s\n", loclfile);
|
fprintf(stderr, "Can't local file %s\n", loclfile);
|
||||||
@ -218,5 +224,8 @@ int main(int argc, char *argv[])
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,13 @@ int main(int argc, char *argv[])
|
|||||||
if(argc > 4) {
|
if(argc > 4) {
|
||||||
sftppath = argv[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
|
* The application code is responsible for creating the socket
|
||||||
* and establishing the connection
|
* and establishing the connection
|
||||||
@ -241,5 +248,8 @@ int main(int argc, char *argv[])
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,12 @@ int main(int argc, char *argv[])
|
|||||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||||
#endif
|
#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"
|
/* Ultra basic "connect to port 22 on localhost"
|
||||||
* The application is responsible for creating the socket establishing
|
* The application is responsible for creating the socket establishing
|
||||||
* the connection
|
* the connection
|
||||||
@ -286,5 +292,8 @@ int main(int argc, char *argv[])
|
|||||||
if (tempstorage)
|
if (tempstorage)
|
||||||
fclose(tempstorage);
|
fclose(tempstorage);
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,12 @@ int main(int argc, char *argv[])
|
|||||||
sftppath = argv[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
|
* The application code is responsible for creating the socket
|
||||||
* and establishing the connection
|
* and establishing the connection
|
||||||
@ -159,6 +165,9 @@ int main(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,12 @@ int main(int argc, char *argv[])
|
|||||||
sftppath = argv[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
|
* The application code is responsible for creating the socket
|
||||||
* and establishing the connection
|
* and establishing the connection
|
||||||
@ -165,6 +171,9 @@ int main(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,13 @@ int main(int argc, char *argv[])
|
|||||||
if (argc > 4) {
|
if (argc > 4) {
|
||||||
sftppath = argv[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
|
* The application code is responsible for creating the socket
|
||||||
* and establishing the connection
|
* and establishing the connection
|
||||||
@ -269,5 +276,8 @@ shutdown:
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,12 @@ int main(int argc, char *argv[])
|
|||||||
sftppath = argv[5];
|
sftppath = argv[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = libssh2_init (0);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
local = fopen(loclfile, "rb");
|
local = fopen(loclfile, "rb");
|
||||||
if (!local) {
|
if (!local) {
|
||||||
printf("Can't local file %s\n", loclfile);
|
printf("Can't local file %s\n", loclfile);
|
||||||
@ -200,5 +206,8 @@ shutdown:
|
|||||||
if (local)
|
if (local)
|
||||||
fclose(local);
|
fclose(local);
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,12 @@ int main(int argc, char *argv[])
|
|||||||
sftppath = argv[5];
|
sftppath = argv[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = libssh2_init (0);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
local = fopen(loclfile, "rb");
|
local = fopen(loclfile, "rb");
|
||||||
if (!local) {
|
if (!local) {
|
||||||
printf("Can't local file %s\n", loclfile);
|
printf("Can't local file %s\n", loclfile);
|
||||||
@ -212,5 +218,8 @@ shutdown:
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,13 @@ int main(int argc, char *argv[])
|
|||||||
if(argc > 4) {
|
if(argc > 4) {
|
||||||
sftppath = argv[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
|
* The application code is responsible for creating the socket
|
||||||
* and establishing the connection
|
* and establishing the connection
|
||||||
@ -211,6 +218,9 @@ int main(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,13 @@ int main(int argc, char *argv[])
|
|||||||
if(argc > 4) {
|
if(argc > 4) {
|
||||||
sftppath = argv[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
|
* The application code is responsible for creating the socket
|
||||||
* and establishing the connection
|
* and establishing the connection
|
||||||
@ -224,5 +231,8 @@ int main(int argc, char *argv[])
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
printf("all done\n");
|
printf("all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,12 @@ int main(int argc, char *argv[])
|
|||||||
password = argv[3];
|
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
|
/* Ultra basic "connect to port 22 on localhost". Your code is
|
||||||
* responsible for creating the socket establishing the connection
|
* responsible for creating the socket establishing the connection
|
||||||
*/
|
*/
|
||||||
@ -247,5 +253,8 @@ int main(int argc, char *argv[])
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
printf("all done!\n");
|
printf("all done!\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,12 @@ int main(int argc, char *argv[])
|
|||||||
username = argv[2];
|
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
|
/* Ultra basic "connect to port 22 on localhost". Your code is
|
||||||
* responsible for creating the socket establishing the connection
|
* responsible for creating the socket establishing the connection
|
||||||
*/
|
*/
|
||||||
@ -225,5 +231,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("all done!\n");
|
printf("all done!\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,12 @@ int main(int argc, char *argv[])
|
|||||||
commandline = argv[4];
|
commandline = argv[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = libssh2_init (0);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
hostaddr = inet_addr(hostname);
|
hostaddr = inet_addr(hostname);
|
||||||
|
|
||||||
/* Ultra basic "connect to port 22 on localhost"
|
/* Ultra basic "connect to port 22 on localhost"
|
||||||
@ -289,6 +295,8 @@ shutdown:
|
|||||||
close(sock);
|
close(sock);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "all done\n");
|
fprintf(stderr, "all done\n");
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +277,12 @@ main (int argc, char *argv[])
|
|||||||
fprintf (stderr, "DEBUG is ON: %d\n", set_debug_on);
|
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);
|
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
@ -434,5 +440,8 @@ main (int argc, char *argv[])
|
|||||||
channel = NULL;
|
channel = NULL;
|
||||||
}
|
}
|
||||||
_normal_mode();
|
_normal_mode();
|
||||||
|
|
||||||
|
libssh2_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user