* Code cleanup: Added const qualifier for variables and

function declarations where possible. No functional changes.
This commit is contained in:
Roland Illig 2004-08-29 17:15:23 +00:00
parent 8458240147
commit 4baefa09c2
9 changed files with 35 additions and 35 deletions

View File

@ -85,9 +85,9 @@ typedef struct Dlg_head {
/* Set by the user */ /* Set by the user */
int flags; /* User flags */ int flags; /* User flags */
char *help_ctx; /* Name of the help entry */ const char *help_ctx; /* Name of the help entry */
const int *color; /* Color set */ const int *color; /* Color set */
char *title; /* Title of the dialog */ const char *title; /* Title of the dialog */
/* Set and received by the user */ /* Set and received by the user */
int ret_value; /* Result of run_dlg() */ int ret_value; /* Result of run_dlg() */

View File

@ -272,7 +272,7 @@ static int edit_one_file_start_line = 0;
int midnight_shutdown = 0; int midnight_shutdown = 0;
/* The user's shell */ /* The user's shell */
char *shell = NULL; const char *shell = NULL;
/* mc_home: The home of MC */ /* mc_home: The home of MC */
char *mc_home = NULL; char *mc_home = NULL;
@ -319,7 +319,7 @@ reload_panelized (WPanel *panel)
static void static void
update_one_panel_widget (WPanel *panel, int force_update, update_one_panel_widget (WPanel *panel, int force_update,
char *current_file) const char *current_file)
{ {
int free_pointer; int free_pointer;
@ -367,7 +367,7 @@ panel_clean_dir (WPanel *panel)
} }
static void static void
update_one_panel (int which, int force_update, char *current_file) update_one_panel (int which, int force_update, const char *current_file)
{ {
WPanel *panel; WPanel *panel;
@ -387,7 +387,7 @@ update_one_panel (int which, int force_update, char *current_file)
* will not reload the other panel. * will not reload the other panel.
*/ */
void void
update_panels (int force_update, char *current_file) update_panels (int force_update, const char *current_file)
{ {
int reload_other = !(force_update & UP_ONLY_CURRENT); int reload_other = !(force_update & UP_ONLY_CURRENT);
WPanel *panel; WPanel *panel;
@ -418,7 +418,7 @@ save_cwds_stat (void)
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef HAVE_SUBSHELL_SUPPORT
void void
do_possible_cd (char *new_dir) do_possible_cd (const char *new_dir)
{ {
if (!do_cd (new_dir, cd_exact)) if (!do_cd (new_dir, cd_exact))
message (1, _("Warning"), message (1, _("Warning"),
@ -514,7 +514,7 @@ repaint_screen (void)
/* Wrapper for do_subshell_chdir, check for availability of subshell */ /* Wrapper for do_subshell_chdir, check for availability of subshell */
void void
subshell_chdir (char *directory) subshell_chdir (const char *directory)
{ {
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef HAVE_SUBSHELL_SUPPORT
if (use_subshell) { if (use_subshell) {
@ -543,7 +543,7 @@ directory_history_add (struct WPanel *panel, const char *dir)
* You do _NOT_ want to add any vfs aware code here. <pavel@ucw.cz> * You do _NOT_ want to add any vfs aware code here. <pavel@ucw.cz>
*/ */
static char * static char *
get_parent_dir_name (char *cwd, char *lwd) get_parent_dir_name (const char *cwd, const char *lwd)
{ {
char *p; char *p;
if (strlen (lwd) > strlen (cwd)) if (strlen (lwd) > strlen (cwd))
@ -558,7 +558,7 @@ get_parent_dir_name (char *cwd, char *lwd)
* Don't record change in the directory history. * Don't record change in the directory history.
*/ */
static int static int
_do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type) _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type)
{ {
char *directory, *olddir; char *directory, *olddir;
char temp[MC_MAXPATHLEN]; char temp[MC_MAXPATHLEN];
@ -618,7 +618,7 @@ _do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
* Record change in the directory history. * Record change in the directory history.
*/ */
int int
do_panel_cd (struct WPanel *panel, char *new_dir, enum cd_enum cd_type) do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type)
{ {
int r; int r;
@ -629,7 +629,7 @@ do_panel_cd (struct WPanel *panel, char *new_dir, enum cd_enum cd_type)
} }
int int
do_cd (char *new_dir, enum cd_enum exact) do_cd (const char *new_dir, enum cd_enum exact)
{ {
return (do_panel_cd (current_panel, new_dir, exact)); return (do_panel_cd (current_panel, new_dir, exact));
} }
@ -2088,7 +2088,7 @@ handle_args (int argc, char *argv[])
*/ */
static int static int
do_mc_filename_rename (char *mc_dir, char *o_name, char *n_name) do_mc_filename_rename (const char *mc_dir, const char *o_name, const char *n_name)
{ {
char *full_o_name = concat_dir_and_file (home_dir, o_name); char *full_o_name = concat_dir_and_file (home_dir, o_name);
char *full_n_name = g_strconcat (home_dir, MC_BASE, n_name, NULL); char *full_n_name = g_strconcat (home_dir, MC_BASE, n_name, NULL);

View File

@ -18,7 +18,7 @@ extern volatile int quit;
/* If true, after executing a command, wait for a keystroke */ /* If true, after executing a command, wait for a keystroke */
enum { pause_never, pause_on_dumb_terminals, pause_always }; enum { pause_never, pause_on_dumb_terminals, pause_always };
void subshell_chdir (char *command); void subshell_chdir (const char *command);
/* See main.c for details on these variables */ /* See main.c for details on these variables */
extern int mark_moves_down; extern int mark_moves_down;
@ -65,7 +65,7 @@ extern int only_leading_plus_minus;
extern int output_starts_shell; extern int output_starts_shell;
extern int midnight_shutdown; extern int midnight_shutdown;
extern char cmd_buf [512]; extern char cmd_buf [512];
extern char *shell; extern const char *shell;
/* Ugly hack in order to distinguish between left and right panel in menubar */ /* Ugly hack in order to distinguish between left and right panel in menubar */
extern int is_right; /* If the selected menu was the right */ extern int is_right; /* If the selected menu was the right */
@ -81,7 +81,7 @@ typedef struct {
key_callback fn; key_callback fn;
} key_map; } key_map;
void update_panels (int force_update, char *current_file); void update_panels (int force_update, const char *current_file);
void repaint_screen (void); void repaint_screen (void);
void do_update_prompt (void); void do_update_prompt (void);
@ -90,7 +90,7 @@ enum cd_enum {
cd_exact cd_exact
}; };
int do_cd (char *new_dir, enum cd_enum cd_type); /* For find.c */ int do_cd (const char *new_dir, enum cd_enum cd_type); /* For find.c */
void change_panel (void); void change_panel (void);
int load_prompt (int fd, void *unused); int load_prompt (int fd, void *unused);
void save_cwds_stat (void); void save_cwds_stat (void);
@ -108,7 +108,7 @@ extern char *mc_home;
char *get_mc_lib_dir (void); char *get_mc_lib_dir (void);
int maybe_cd (int char_code, int move_up_dir); int maybe_cd (int char_code, int move_up_dir);
void do_possible_cd (char *dir); void do_possible_cd (const char *dir);
#ifdef WANT_WIDGETS #ifdef WANT_WIDGETS
extern WButtonBar *the_bar; extern WButtonBar *the_bar;
@ -127,6 +127,6 @@ void init_menu (void);
struct WPanel; struct WPanel;
void directory_history_add (struct WPanel *panel, const char *dir); void directory_history_add (struct WPanel *panel, const char *dir);
int do_panel_cd (struct WPanel *panel, char *new_dir, enum cd_enum cd_type); int do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type);
#endif /* !__MAIN_H */ #endif /* !__MAIN_H */

View File

@ -7,7 +7,7 @@ typedef void (*callfn) (void);
typedef struct { typedef struct {
char first_letter; char first_letter;
char *text; const char *text;
int hot_key; int hot_key;
callfn call_back; callfn call_back;
} menu_entry; } menu_entry;

View File

@ -57,8 +57,8 @@ struct poptOption {
int argInfo; int argInfo;
void * arg; /* depends on argInfo */ void * arg; /* depends on argInfo */
int val; /* 0 means don't return, just update flag */ int val; /* 0 means don't return, just update flag */
char * descrip; /* description for autohelp -- may be NULL */ const char * descrip; /* description for autohelp -- may be NULL */
char * argDescrip; /* argument description for autohelp */ const char * argDescrip; /* argument description for autohelp */
}; };
struct poptAlias { struct poptAlias {

View File

@ -828,7 +828,7 @@ do_select (WPanel *panel, int i)
} }
static inline void static inline void
do_try_to_select (WPanel *panel, char *name) do_try_to_select (WPanel *panel, const char *name)
{ {
int i; int i;
char *subdir; char *subdir;

View File

@ -70,7 +70,7 @@ socket_read_block (int sock, char *dest, int len)
} }
int int
socket_write_block (int sock, char *buffer, int len) socket_write_block (int sock, const char *buffer, int len)
{ {
int left, status; int left, status;

View File

@ -19,5 +19,5 @@ enum {
int rpc_get (int sock, ...); int rpc_get (int sock, ...);
int rpc_send (int sock, ...); int rpc_send (int sock, ...);
int socket_read_block (int sock, char *dest, int len); int socket_read_block (int sock, char *dest, int len);
int socket_write_block (int sock, char *buffer, int len); int socket_write_block (int sock, const char *buffer, int len);
#endif /* !__MCFSUTIL_H */ #endif /* !__MCFSUTIL_H */

View File

@ -774,7 +774,7 @@ static struct pam_conv conv = { &mc_pam_conversation, NULL };
/* Return 0 if authentication failed, 1 otherwise */ /* Return 0 if authentication failed, 1 otherwise */
static int static int
mc_pam_auth (char *username, char *password) mc_pam_auth (const char *username, const char *password)
{ {
pam_handle_t *pamh; pam_handle_t *pamh;
struct user_pass up; struct user_pass up;
@ -818,7 +818,7 @@ next_line (int socket)
} }
static int static int
ftp_answer (int sock, char *text) ftp_answer (int sock, const char *text)
{ {
char answer[4]; char answer[4];
@ -831,13 +831,13 @@ ftp_answer (int sock, char *text)
} }
static int static int
send_string (int sock, char *string) send_string (int sock, const char *string)
{ {
return socket_write_block (sock, string, strlen (string)); return socket_write_block (sock, string, strlen (string));
} }
static int static int
do_ftp_auth (char *username, char *password) do_ftp_auth (const char *username, const char *password)
{ {
struct sockaddr_in local_address; struct sockaddr_in local_address;
unsigned long inaddr; unsigned long inaddr;
@ -892,10 +892,10 @@ do_ftp_auth (char *username, char *password)
#ifdef HAVE_CRYPT #ifdef HAVE_CRYPT
static int static int
do_classic_auth (char *username, char *password) do_classic_auth (const char *username, const char *password)
{ {
int ret = 0; int ret = 0;
char *encr_pwd = NULL; const char *encr_pwd = NULL;
struct passwd *pw; struct passwd *pw;
#ifdef HAVE_SHADOW #ifdef HAVE_SHADOW
struct spwd *spw; struct spwd *spw;
@ -934,7 +934,7 @@ do_classic_auth (char *username, char *password)
- try to contact the local ftp server and login (if -f flag used) - try to contact the local ftp server and login (if -f flag used)
*/ */
static int static int
do_auth (char *username, char *password) do_auth (const char *username, const char *password)
{ {
int auth = 0; int auth = 0;
struct passwd *this; struct passwd *this;
@ -1088,7 +1088,7 @@ do_login (void)
/* This structure must be kept in synch with mcfs.h enums */ /* This structure must be kept in synch with mcfs.h enums */
static const struct _command { static const struct _command {
char *command; const char *command;
void (*callback) (void); void (*callback) (void);
} commands[] = { } commands[] = {
{ {
@ -1178,7 +1178,7 @@ server (int sock)
/* {{{ Net support code */ /* {{{ Net support code */
static char * static const char *
get_client (int portnum) get_client (int portnum)
{ {
int sock, clilen, newsocket; int sock, clilen, newsocket;
@ -1295,7 +1295,7 @@ register_port (int portnum, int abort_if_fail)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
char *result; const char *result;
int c; int c;
while ((c = getopt (argc, argv, "fdiqp:v")) != -1) { while ((c = getopt (argc, argv, "fdiqp:v")) != -1) {