Removed unnecessary casts and added const where necessary.

This commit is contained in:
Dan Fandrich 2007-08-09 01:10:11 +00:00
parent 17173aab0e
commit c4630d1ffb
14 changed files with 66 additions and 66 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: scp.c,v 1.9 2007/07/31 11:00:29 bagder Exp $ * $Id: scp.c,v 1.10 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do a simple SCP transfer. * Sample showing how to do a simple SCP transfer.
*/ */
@ -40,9 +40,9 @@ int main(int argc, char *argv[])
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel; LIBSSH2_CHANNEL *channel;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *scppath=(char *)"/tmp/TEST"; const char *scppath="/tmp/TEST";
struct stat fileinfo; struct stat fileinfo;
int rc; int rc;
off_t got=0; off_t got=0;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: scp_nonblock.c,v 1.8 2007/07/31 11:00:29 bagder Exp $ * $Id: scp_nonblock.c,v 1.9 2007/08/09 01:10:11 dfandrich 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.
*/ */
@ -40,9 +40,9 @@ int main(int argc, char *argv[])
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel; LIBSSH2_CHANNEL *channel;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *scppath=(char *)"/tmp/TEST"; const char *scppath="/tmp/TEST";
struct stat fileinfo; struct stat fileinfo;
int rc; int rc;
off_t got=0; off_t got=0;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: scp_write.c,v 1.4 2007/07/31 11:00:29 bagder Exp $ * $Id: scp_write.c,v 1.5 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do a simple SCP transfer. * Sample showing how to do a simple SCP transfer.
*/ */
@ -40,10 +40,10 @@ int main(int argc, char *argv[])
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel; LIBSSH2_CHANNEL *channel;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *loclfile=(char *)"scp_write.c"; const char *loclfile="scp_write.c";
char *scppath=(char *)"/tmp/TEST"; const char *scppath="/tmp/TEST";
FILE *local; FILE *local;
int rc; int rc;
char mem[1024]; char mem[1024];

View File

@ -1,5 +1,5 @@
/* /*
* $Id: scp_write_nonblock.c,v 1.6 2007/07/31 11:00:29 bagder Exp $ * $Id: scp_write_nonblock.c,v 1.7 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do a simple SCP transfer. * Sample showing how to do a simple SCP transfer.
*/ */
@ -41,10 +41,10 @@ int main(int argc, char *argv[])
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel; LIBSSH2_CHANNEL *channel;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *loclfile=(char *)"scp_write.c"; const char *loclfile="scp_write.c";
char *scppath=(char *)"/tmp/TEST"; const char *scppath="/tmp/TEST";
FILE *local; FILE *local;
int rc; int rc;
char mem[1024]; char mem[1024];

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp.c,v 1.12 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp.c,v 1.13 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SFTP transfers. * Sample showing how to do SFTP transfers.
* *
@ -39,11 +39,11 @@
#include <ctype.h> #include <ctype.h>
char *keyfile1=(char *)"~/.ssh/id_rsa.pub"; const char *keyfile1="~/.ssh/id_rsa.pub";
char *keyfile2=(char *)"~/.ssh/id_rsa"; const char *keyfile2="~/.ssh/id_rsa";
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/TEST"; const char *sftppath="/tmp/TEST";
static void kbd_callback(const char *name, int name_len, static void kbd_callback(const char *name, int name_len,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_RW_nonblock.c,v 1.9 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp_RW_nonblock.c,v 1.10 2007/08/09 01:10:11 dfandrich 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.
* *
@ -48,10 +48,10 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/TEST"; /* source path */ const char *sftppath="/tmp/TEST"; /* source path */
char *dest=(char *)"/tmp/TEST2"; /* destination path */ const char *dest="/tmp/TEST2"; /* destination path */
int rc; int rc;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle; LIBSSH2_SFTP_HANDLE *sftp_handle;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_mkdir.c,v 1.6 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp_mkdir.c,v 1.7 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SFTP mkdir * Sample showing how to do SFTP mkdir
* *
@ -42,9 +42,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/sftp_mkdir"; const char *sftppath="/tmp/sftp_mkdir";
int rc; int rc;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_mkdir_nonblock.c,v 1.8 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp_mkdir_nonblock.c,v 1.9 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SFTP non-blocking mkdir. * Sample showing how to do SFTP non-blocking mkdir.
* *
@ -42,9 +42,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/sftp_mkdir_nonblock"; const char *sftppath="/tmp/sftp_mkdir_nonblock";
int rc; int rc;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_nonblock.c,v 1.12 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp_nonblock.c,v 1.13 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SFTP non-blocking transfers. * Sample showing how to do SFTP non-blocking transfers.
* *
@ -45,9 +45,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/TEST"; const char *sftppath="/tmp/TEST";
int rc; int rc;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle; LIBSSH2_SFTP_HANDLE *sftp_handle;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_write.c,v 1.7 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp_write.c,v 1.8 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SFTP write transfers. * Sample showing how to do SFTP write transfers.
* *
@ -42,10 +42,10 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *loclfile=(char *)"sftp_write.c"; const char *loclfile="sftp_write.c";
char *sftppath=(char *)"/tmp/TEST"; const char *sftppath="/tmp/TEST";
int rc; int rc;
FILE *local; FILE *local;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_write_nonblock.c,v 1.9 2007/07/31 11:00:29 bagder Exp $ * $Id: sftp_write_nonblock.c,v 1.10 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SFTP non-blocking write transfers. * Sample showing how to do SFTP non-blocking write transfers.
* *
@ -42,10 +42,10 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *loclfile=(char *)"sftp_write_nonblock.c"; const char *loclfile="sftp_write_nonblock.c";
char *sftppath=(char *)"/tmp/sftp_write_nonblock.c"; const char *sftppath="/tmp/sftp_write_nonblock.c";
int rc; int rc;
FILE *local; FILE *local;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftpdir.c,v 1.8 2007/07/31 11:00:29 bagder Exp $ * $Id: sftpdir.c,v 1.9 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample doing an SFTP directory listing. * Sample doing an SFTP directory listing.
* *
@ -42,9 +42,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/secretdir"; const char *sftppath="/tmp/secretdir";
int rc; int rc;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle; LIBSSH2_SFTP_HANDLE *sftp_handle;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftpdir_nonblock.c,v 1.9 2007/07/31 11:00:29 bagder Exp $ * $Id: sftpdir_nonblock.c,v 1.10 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample doing an SFTP directory listing. * Sample doing an SFTP directory listing.
* *
@ -42,9 +42,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin; struct sockaddr_in sin;
const char *fingerprint; const char *fingerprint;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
char *sftppath=(char *)"/tmp/secretdir"; const char *sftppath="/tmp/secretdir";
int rc; int rc;
LIBSSH2_SFTP *sftp_session; LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle; LIBSSH2_SFTP_HANDLE *sftp_handle;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ssh2.c,v 1.16 2007/08/03 15:08:28 jehousley Exp $ * $Id: ssh2.c,v 1.17 2007/08/09 01:10:11 dfandrich Exp $
* *
* Sample showing how to do SSH2 connect. * Sample showing how to do SSH2 connect.
* *
@ -36,10 +36,10 @@
#include <ctype.h> #include <ctype.h>
char *keyfile1=(char *)"~/.ssh/id_rsa.pub"; const char *keyfile1="~/.ssh/id_rsa.pub";
char *keyfile2=(char *)"~/.ssh/id_rsa"; const char *keyfile2="~/.ssh/id_rsa";
char *username=(char *)"username"; const char *username="username";
char *password=(char *)"password"; const char *password="password";
static void kbd_callback(const char *name, int name_len, static void kbd_callback(const char *name, int name_len,
@ -189,12 +189,12 @@ int main(int argc, char *argv[])
/* Some environment variables may be set, /* Some environment variables may be set,
* It's up to the server which ones it'll allow though * It's up to the server which ones it'll allow though
*/ */
libssh2_channel_setenv(channel, (char *)"FOO", (char *)"bar"); libssh2_channel_setenv(channel, "FOO", "bar");
/* Request a terminal with 'vanilla' terminal emulation /* Request a terminal with 'vanilla' terminal emulation
* See /etc/termcap for more options * See /etc/termcap for more options
*/ */
if (libssh2_channel_request_pty(channel, (char *)"vanilla")) { if (libssh2_channel_request_pty(channel, "vanilla")) {
fprintf(stderr, "Failed requesting pty\n"); fprintf(stderr, "Failed requesting pty\n");
goto skip_shell; goto skip_shell;
} }