Commit 76162ace authored by Niels Möller's avatar Niels Möller
Browse files

Constification. Fixed warnings for mising

prototypes and unused arguments.

Rev: src/sftp/commands.c:1.2
parent 4e764b3c
...@@ -172,25 +172,27 @@ command commands[] = { ...@@ -172,25 +172,27 @@ command commands[] = {
{ "!", com_escape, "Send COMMAND to /bin/sh", { "!", com_escape, "Send COMMAND to /bin/sh",
"Executes system(\"COMMAND\");" , OTHERARG, 1, 1 }, "Executes system(\"COMMAND\");" , OTHERARG, 1, 1 },
{ (char *)NULL, NULL, (char *)NULL, (char*) NULL, 0, 0 } { NULL, NULL, NULL, NULL, 0, 0, 0 }
}; };
int com_disconnected() static int
com_disconnected(void)
{ {
printf( "This command doesn't work in disconnected mode!\n" ); printf( "This command doesn't work in disconnected mode!\n" );
return -1; return -1;
} }
int com_connected() static int
com_connected(void)
{ {
printf( "This command doesn't work in connected mode!\n" ); printf( "This command doesn't work in connected mode!\n" );
return -1; return -1;
} }
int com_help( char* arg, char* command ) int
com_help(const char *arg, const char *command UNUSED)
{ {
const char *s;
char* s;
char tmp[PATH_MAX]; char tmp[PATH_MAX];
char* cmdname; char* cmdname;
int i=0; int i=0;
...@@ -246,12 +248,14 @@ int com_help( char* arg, char* command ) ...@@ -246,12 +248,14 @@ int com_help( char* arg, char* command )
} }
int com_mail( char* arg, char* command ) int
com_mail(const char *arg UNUSED, const char *command)
{ {
return system( command ); return system(command);
} }
int com_umask( char* arg, char* command ) int
com_umask(const char *arg, const char *command UNUSED)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
int given = 0; int given = 0;
...@@ -285,9 +289,12 @@ int com_umask( char* arg, char* command ) ...@@ -285,9 +289,12 @@ int com_umask( char* arg, char* command )
printf( "Your current umask is %o.\n", oldmask ); printf( "Your current umask is %o.\n", oldmask );
} }
/* FIXME: What does return value mean? */
return 0;
} }
int com_escape( char* arg, char* command ) int
com_escape(const char *arg, const char *command UNUSED)
{ {
int ret; int ret;
printf( "Launching %s\n", arg ); printf( "Launching %s\n", arg );
...@@ -297,7 +304,8 @@ int com_escape( char* arg, char* command ) ...@@ -297,7 +304,8 @@ int com_escape( char* arg, char* command )
return ret; return ret;
} }
int com_quit( char* arg, char* command ) int
com_quit(const char *arg UNUSED, const char *command UNUSED)
{ {
com_close( "", "INTERNAL CLOSE COMMAND" ); com_close( "", "INTERNAL CLOSE COMMAND" );
printf( "Bye\n" ); printf( "Bye\n" );
...@@ -306,7 +314,8 @@ int com_quit( char* arg, char* command ) ...@@ -306,7 +314,8 @@ int com_quit( char* arg, char* command )
return 0; return 0;
} }
int com_about( char* arg, char* command ) int
com_about(const char *arg UNUSED, const char *command UNUSED)
{ {
printf("%s %s\n", PACKAGE, VERSION); printf("%s %s\n", PACKAGE, VERSION);
printf("Copyright (C) 2001, Pontus Sköld and various contributors\n\n"); printf("Copyright (C) 2001, Pontus Sköld and various contributors\n\n");
...@@ -323,7 +332,8 @@ int com_about( char* arg, char* command ) ...@@ -323,7 +332,8 @@ int com_about( char* arg, char* command )
} }
int com_close( char* arg, char* command ) int
com_close(const char *arg UNUSED, const char *command UNUSED)
{ {
/* Close any existing connections */ /* Close any existing connections */
...@@ -334,11 +344,12 @@ int com_close( char* arg, char* command ) ...@@ -334,11 +344,12 @@ int com_close( char* arg, char* command )
} }
int com_open( char* arg, char* command ) int
com_open(const char *arg, const char *command UNUSED)
{ {
char** myargv; char** myargv;
char** freeargv; char** freeargv;
char* s; const char *s;
char tmp[PATH_MAX]; /* Used for arguments */ char tmp[PATH_MAX]; /* Used for arguments */
int argcount = 0; int argcount = 0;
...@@ -380,7 +391,8 @@ int com_open( char* arg, char* command ) ...@@ -380,7 +391,8 @@ int com_open( char* arg, char* command )
freeargv++; /* Skip first entry, we may not free that one */ freeargv++; /* Skip first entry, we may not free that one */
while( (s = *(freeargv++) ) ) while( (s = *(freeargv++) ) )
free( s ); /* Free doesn't take const pointers */
free((void *) s );
free( myargv ); free( myargv );
...@@ -399,7 +411,8 @@ int com_open( char* arg, char* command ) ...@@ -399,7 +411,8 @@ int com_open( char* arg, char* command )
int com_cd( char* arg, char* command ) int
com_cd(const char *arg, const char *command UNUSED)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
...@@ -415,8 +428,8 @@ int com_cd( char* arg, char* command ) ...@@ -415,8 +428,8 @@ int com_cd( char* arg, char* command )
( arg = lsftp_s_strtok( arg," \n\t\r", tmp, PATH_MAX ) ) ( arg = lsftp_s_strtok( arg," \n\t\r", tmp, PATH_MAX ) )
) )
{ {
char** mglob; const char **mglob;
char* ptr = 0; const char *ptr = 0;
mglob = lsftp_dc_r_startglob( tmp, 0, 1 ); mglob = lsftp_dc_r_startglob( tmp, 0, 1 );
...@@ -438,10 +451,13 @@ int com_cd( char* arg, char* command ) ...@@ -438,10 +451,13 @@ int com_cd( char* arg, char* command )
if( !didcd ) if( !didcd )
return lsftp_do_cd( "" ); return lsftp_do_cd( "" );
/* FIXME: What does return value mean? */
return 0;
} }
int com_mkdir( char* arg, char* command ) int com_mkdir(const char *arg, const char *command)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
...@@ -465,15 +481,14 @@ int com_mkdir( char* arg, char* command ) ...@@ -465,15 +481,14 @@ int com_mkdir( char* arg, char* command )
return 0; return 0;
} }
static int
rm_file_or_folder(const char *path, const char *command, int recursive )
int rm_file_or_folder( char* path, char* command, int recursive )
{ {
int isdir = lsftp_dc_r_isdir( path ); int isdir = lsftp_dc_r_isdir(path);
char* sub = 0; char *sub = 0;
char** subglob = 0; const char **subglob = 0;
char** orgglob = 0; const char **orgglob = 0;
char* ptr; const char *ptr;
int err = 0; int err = 0;
int id; int id;
...@@ -548,7 +563,7 @@ int rm_file_or_folder( char* path, char* command, int recursive ) ...@@ -548,7 +563,7 @@ int rm_file_or_folder( char* path, char* command, int recursive )
if( subglob ) /* Glob returned allright */ if( subglob ) /* Glob returned allright */
while( !err && while( !err &&
( ptr = *(subglob++) ) ) ( (ptr = *subglob++) ) )
err = rm_file_or_folder( ptr, command, recursive ); err = rm_file_or_folder( ptr, command, recursive );
lsftp_dc_endglob( orgglob ); lsftp_dc_endglob( orgglob );
...@@ -571,7 +586,8 @@ int rm_file_or_folder( char* path, char* command, int recursive ) ...@@ -571,7 +586,8 @@ int rm_file_or_folder( char* path, char* command, int recursive )
} }
int com_rm( char* arg, char* command ) int
com_rm(const char *arg, const char *command)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
...@@ -607,15 +623,15 @@ int com_rm( char* arg, char* command ) ...@@ -607,15 +623,15 @@ int com_rm( char* arg, char* command )
rm_file_or_folder( tmp, command, recurse ); rm_file_or_folder( tmp, command, recurse );
else /* Globbing desired */ else /* Globbing desired */
{ {
char** mglob; const char **mglob;
char** orgglob; const char **orgglob;
char* ptr; const char *ptr;
mglob = lsftp_dc_r_startglob( tmp, 0, 1 ); mglob = lsftp_dc_r_startglob( tmp, 0, 1 );
orgglob = mglob; orgglob = mglob;
if( mglob ) /* Glob returned allright? */ if( mglob ) /* Glob returned allright? */
while( ptr = *( mglob++ ) ) while( (ptr = *mglob++) )
rm_file_or_folder( ptr, command, recurse ); rm_file_or_folder( ptr, command, recurse );
lsftp_dc_endglob( orgglob ); lsftp_dc_endglob( orgglob );
...@@ -626,10 +642,8 @@ int com_rm( char* arg, char* command ) ...@@ -626,10 +642,8 @@ int com_rm( char* arg, char* command )
return 0; return 0;
} }
int
com_ls(const char *arg, const char *command)
int com_ls( char* arg, char* command )
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
...@@ -683,9 +697,8 @@ int com_ls( char* arg, char* command ) ...@@ -683,9 +697,8 @@ int com_ls( char* arg, char* command )
return 0; return 0;
} }
int
com_set(const char *arg, const char *command UNUSED)
int com_set( char* arg, char* command )
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
...@@ -789,18 +802,18 @@ int com_set( char* arg, char* command ) ...@@ -789,18 +802,18 @@ int com_set( char* arg, char* command )
return 0; return 0;
} }
static int
get_file_or_folder(const char *arg, const char *command,
int get_file_or_folder( char* arg, char* command, int cont, char* destname ) int cont, const char *destname )
{ {
char** dirinfo = 0; const char **dirinfo = NULL;
char** curdirinfo; const char **curdirinfo;
char* localwd; const char *localwd;
char* remotewd; const char *remotewd;
char* tmp; const char *tmp;
char buffer[PATH_MAX+1]; char buffer[PATH_MAX+1];
struct stat st; struct stat st;
...@@ -808,7 +821,6 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -808,7 +821,6 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname )
int mode = 0700; int mode = 0700;
int mask; int mask;
int isdir = lsftp_dc_r_isdir( arg ); int isdir = lsftp_dc_r_isdir( arg );
int err;
int ret; int ret;
if( -1 == isdir ) /* Unable to determine dir or not? */ if( -1 == isdir ) /* Unable to determine dir or not? */
...@@ -948,7 +960,7 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -948,7 +960,7 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname )
return -1; return -1;
} }
free( remotewd ); free( (void *) remotewd );
remotewd = tmp; remotewd = tmp;
/* Do globbing */ /* Do globbing */
...@@ -957,12 +969,14 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -957,12 +969,14 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname )
if( tmp ) if( tmp )
dirinfo = lsftp_dc_r_startglob( tmp, 0, 1 ); dirinfo = lsftp_dc_r_startglob( tmp, 0, 1 );
free( tmp ); /* free doesn't accept const poitners */
free( (void *) tmp );
tmp = lsftp_concat( remotewd, ".*" ); tmp = lsftp_concat( remotewd, ".*" );
if( tmp ) if( tmp )
dirinfo = lsftp_dc_r_contglob( tmp, dirinfo, 1 ); dirinfo = lsftp_dc_r_contglob( tmp, dirinfo, 1 );
free( tmp ); /* free doesn't accept const pointers */
free( (void *) tmp );
if( dirinfo ) if( dirinfo )
{ {
...@@ -970,7 +984,7 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -970,7 +984,7 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname )
while( *curdirinfo ) while( *curdirinfo )
{ {
char* curentry = lsftp_skip_common( *curdirinfo, remotewd ); const char *curentry = lsftp_skip_common( *curdirinfo, remotewd );
if( !( /* Not . or .. */ if( !( /* Not . or .. */
!strcmp( curentry, "." ) || !strcmp( curentry, "." ) ||
...@@ -978,8 +992,8 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -978,8 +992,8 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname )
) )
) )
{ {
char* src; char *src;
char* dst; char *dst;
src = lsftp_concat( remotewd, curentry ); src = lsftp_concat( remotewd, curentry );
dst = lsftp_concat( localwd, curentry ); dst = lsftp_concat( localwd, curentry );
...@@ -1001,16 +1015,15 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1001,16 +1015,15 @@ int get_file_or_folder( char* arg, char* command, int cont, char* destname )
lsftp_dc_endglob( dirinfo ); lsftp_dc_endglob( dirinfo );
} }
free( remotewd ); /* Free memory used by to hold remote wd */ free( (void *) remotewd ); /* Free memory used by to hold remote wd */
free( localwd ); /* Free memory used by to hold remote wd */ free( (void *) localwd ); /* Free memory used by to hold remote wd */
return 0; return 0;
} }
int com_get( char* arg, char* command ) int
com_get(const char *arg, const char *command)
{ {
int cont = gp_cont; int cont = gp_cont;
char tmp[PATH_MAX]; char tmp[PATH_MAX];
...@@ -1033,14 +1046,14 @@ int com_get( char* arg, char* command ) ...@@ -1033,14 +1046,14 @@ int com_get( char* arg, char* command )
} }
else else
{ {
char** glob; const char **glob;
char** orgglob; const char **orgglob;
char* ptr; const char *ptr;
glob = lsftp_dc_r_startglob( tmp, 0, 1 ); glob = lsftp_dc_r_startglob( tmp, 0, 1 );
orgglob = glob; orgglob = glob;
while( ptr = *(glob++) ) while( (ptr = *glob++) )
get_file_or_folder( ptr, command, cont, 0 ); get_file_or_folder( ptr, command, cont, 0 );
lsftp_dc_endglob( orgglob ); lsftp_dc_endglob( orgglob );
...@@ -1049,27 +1062,17 @@ int com_get( char* arg, char* command ) ...@@ -1049,27 +1062,17 @@ int com_get( char* arg, char* command )
return 0; return 0;
} }
static int
put_file_or_folder(const char *arg, const char *command,
int cont, const char *destname )
int put_file_or_folder( char* arg, char* command, int cont, char* destname )
{ {
char** dirinfo = 0; const char **dirinfo = NULL;
char** curdirinfo; const char **curdirinfo;
char* localwd; const char *localwd;
char* remotewd; const char *remotewd;
char* tmp; const char *tmp;
char buffer[PATH_MAX]; char buffer[PATH_MAX];
struct stat st; struct stat st;
...@@ -1081,7 +1084,8 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1081,7 +1084,8 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname )
if( -1 == isdir ) /* Unable to determine dir or not? */ if( -1 == isdir ) /* Unable to determine dir or not? */
{ {
if( !strncmp( filename_part( arg ), "*", 2 ) ) /* Empty directory will make globbing fail => * */ if( !strncmp( filename_part( arg ), "*", 2 ) )
/* Empty directory will make globbing fail => * */
return 0; return 0;
printf( "Unable to determine status of %s\n", arg ); printf( "Unable to determine status of %s\n", arg );
...@@ -1203,7 +1207,7 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1203,7 +1207,7 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname )
return -1; return -1;
} }
free( remotewd ); free( (void *) remotewd );
remotewd = tmp; remotewd = tmp;
/* Do globbing */ /* Do globbing */
...@@ -1212,12 +1216,12 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1212,12 +1216,12 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname )
if( tmp ) if( tmp )
dirinfo = lsftp_dc_l_startglob( tmp, 1 ); dirinfo = lsftp_dc_l_startglob( tmp, 1 );
free( tmp ); free( (void *) tmp );
tmp = lsftp_concat( localwd, ".*" ); tmp = lsftp_concat( localwd, ".*" );
if( tmp ) if( tmp )
dirinfo = lsftp_dc_l_contglob( tmp, dirinfo, 1 ); dirinfo = lsftp_dc_l_contglob( tmp, dirinfo, 1 );
free( tmp ); free( (void *) tmp );
if( dirinfo ) if( dirinfo )
{ {
...@@ -1225,7 +1229,7 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1225,7 +1229,7 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname )
while( *curdirinfo ) while( *curdirinfo )
{ {
char* curentry = lsftp_skip_common( *curdirinfo, localwd ); const char *curentry = lsftp_skip_common( *curdirinfo, localwd );
if( !( /* Not . or .. */ if( !( /* Not . or .. */
!strcmp( curentry, "." ) || !strcmp( curentry, "." ) ||
...@@ -1233,8 +1237,8 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1233,8 +1237,8 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname )
) )
) )
{ {
char* src; char *src;
char* dst; char *dst;
src = lsftp_concat( localwd, curentry ); src = lsftp_concat( localwd, curentry );
dst = lsftp_concat( remotewd, curentry ); dst = lsftp_concat( remotewd, curentry );
...@@ -1257,15 +1261,15 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname ) ...@@ -1257,15 +1261,15 @@ int put_file_or_folder( char* arg, char* command, int cont, char* destname )
lsftp_dc_endglob( dirinfo ); lsftp_dc_endglob( dirinfo );
} }
free( remotewd ); /* Free memory used by to hold remote wd */ free( (void *) remotewd ); /* Free memory used by to hold remote wd */
free( localwd ); /* Free memory used by to hold remote wd */ free( (void *) localwd ); /* Free memory used by to hold remote wd */
return 0; return 0;
} }