* Code cleanup: Added const qualifier for variables and
function declarations where possible. No functional changes.
Этот коммит содержится в:
родитель
3c4b2f8ff4
Коммит
8458240147
@ -1,3 +1,8 @@
|
||||
2004-08-29 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* Code cleanup: Added const qualifier for variables and
|
||||
function declarations where possible. No functional changes.
|
||||
|
||||
2004-08-26 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* cmd.c (do_link): Fixed memory leak and cleaned up code.
|
||||
|
@ -658,7 +658,7 @@ tree_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
|
||||
/* Show tree in a box, not on a panel */
|
||||
char *
|
||||
tree_box (char *current_dir)
|
||||
tree_box (const char *current_dir)
|
||||
{
|
||||
WTree *mytree;
|
||||
Dlg_head *dlg;
|
||||
@ -825,7 +825,7 @@ cd_dialog (void)
|
||||
}
|
||||
|
||||
void
|
||||
symlink_dialog (char *existing, char *new, char **ret_existing,
|
||||
symlink_dialog (const char *existing, const char *new, char **ret_existing,
|
||||
char **ret_new)
|
||||
{
|
||||
QuickDialog Quick_input;
|
||||
|
@ -10,8 +10,8 @@ void display_bits_box (void);
|
||||
void configure_vfs (void);
|
||||
void jobs_cmd (void);
|
||||
char *cd_dialog (void);
|
||||
void symlink_dialog (char *existing, char *new,
|
||||
void symlink_dialog (const char *existing, const char *new,
|
||||
char **ret_existing, char **ret_new);
|
||||
char *tree_box (char *current_dir);
|
||||
char *tree_box (const char *current_dir);
|
||||
|
||||
#endif
|
||||
|
@ -82,7 +82,7 @@ int use_internal_edit = 1;
|
||||
|
||||
|
||||
int
|
||||
view_file_at_line (char *filename, int plain_view, int internal,
|
||||
view_file_at_line (const char *filename, int plain_view, int internal,
|
||||
int start_line)
|
||||
{
|
||||
static char *viewer = 0;
|
||||
@ -149,7 +149,7 @@ view_file_at_line (char *filename, int plain_view, int internal,
|
||||
* internal: If set uses the internal viewer, otherwise an external viewer.
|
||||
*/
|
||||
int
|
||||
view_file (char *filename, int plain_view, int internal)
|
||||
view_file (const char *filename, int plain_view, int internal)
|
||||
{
|
||||
return view_file_at_line (filename, plain_view, internal, 0);
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ void smblink_cmd (void);
|
||||
void undelete_cmd (void);
|
||||
void help_cmd (void);
|
||||
void dirsizes_cmd (void);
|
||||
int view_file_at_line (char *filename, int plain_view, int internal,
|
||||
int view_file_at_line (const char *filename, int plain_view, int internal,
|
||||
int start_line);
|
||||
int view_file (char *filename, int normal, int internal);
|
||||
int view_file (const char *filename, int normal, int internal);
|
||||
void view_cmd (void);
|
||||
void view_file_cmd (void);
|
||||
void view_simple_cmd (void);
|
||||
|
@ -367,7 +367,7 @@ mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
||||
}
|
||||
|
||||
int
|
||||
try_alloc_color_pair (char *fg, char *bg)
|
||||
try_alloc_color_pair (const char *fg, const char *bg)
|
||||
{
|
||||
struct colors_avail *p = &c;
|
||||
|
||||
|
@ -88,6 +88,6 @@ extern int alarm_colors[4];
|
||||
void init_colors (void);
|
||||
void done_colors (void);
|
||||
void mc_init_pair (int index, CTYPE foreground, CTYPE background);
|
||||
int try_alloc_color_pair (char *fg, char *bg);
|
||||
int try_alloc_color_pair (const char *fg, const char *bg);
|
||||
|
||||
#endif /* __COLOR_H */
|
||||
|
10
src/dir.c
10
src/dir.c
@ -424,7 +424,7 @@ handle_dirent (dir_list *list, char *filter, struct dirent *dp,
|
||||
If you change handle_path then check also handle_dirent. */
|
||||
/* Return values: -1 = failure, 0 = don't add, 1 = add to the list */
|
||||
int
|
||||
handle_path (dir_list *list, char *path,
|
||||
handle_path (dir_list *list, const char *path,
|
||||
struct stat *buf1, int next_free, int *link_to_dir,
|
||||
int *stale_link)
|
||||
{
|
||||
@ -461,8 +461,8 @@ handle_path (dir_list *list, char *path,
|
||||
}
|
||||
|
||||
int
|
||||
do_load_dir (char *path, dir_list *list, sortfn *sort, int reverse,
|
||||
int case_sensitive, char *filter)
|
||||
do_load_dir (const char *path, dir_list *list, sortfn *sort, int reverse,
|
||||
int case_sensitive, const char *filter)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
@ -561,8 +561,8 @@ alloc_dir_copy (int size)
|
||||
|
||||
/* If filter is null, then it is a match */
|
||||
int
|
||||
do_reload_dir (char *path, dir_list *list, sortfn *sort, int count,
|
||||
int rev, int case_sensitive, char *filter)
|
||||
do_reload_dir (const char *path, dir_list *list, sortfn *sort, int count,
|
||||
int rev, int case_sensitive, const char *filter)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
|
12
src/dir.h
12
src/dir.h
@ -29,15 +29,15 @@ typedef struct {
|
||||
|
||||
typedef int sortfn (const void *, const void *);
|
||||
|
||||
int do_load_dir (char *path, dir_list * list, sortfn * sort, int reverse,
|
||||
int case_sensitive, char *filter);
|
||||
int do_load_dir (const char *path, dir_list * list, sortfn * sort, int reverse,
|
||||
int case_sensitive, const char *filter);
|
||||
void do_sort (dir_list * list, sortfn * sort, int top, int reverse,
|
||||
int case_sensitive);
|
||||
int do_reload_dir (char *path, dir_list * list, sortfn * sort, int count,
|
||||
int reverse, int case_sensitive, char *filter);
|
||||
int do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count,
|
||||
int reverse, int case_sensitive, const char *filter);
|
||||
void clean_dir (dir_list * list, int count);
|
||||
int set_zero_dir (dir_list * list);
|
||||
int handle_path (dir_list *list, char *path, struct stat *buf1,
|
||||
int handle_path (dir_list *list, const char *path, struct stat *buf1,
|
||||
int next_free, int *link_to_dir, int *stale_link);
|
||||
|
||||
/* Sorting functions */
|
||||
@ -66,7 +66,7 @@ int sort_group (const file_entry *a, const file_entry *b);
|
||||
#define SORT_TYPES_TOTAL (SORT_TYPES + SORT_TYPES_EXTRA)
|
||||
|
||||
typedef struct {
|
||||
char *sort_name;
|
||||
const char *sort_name;
|
||||
int (*sort_fn)(const file_entry *, const file_entry *);
|
||||
} sort_orders_t;
|
||||
|
||||
|
@ -411,7 +411,7 @@ regex_check_type (char *filename, char *ptr, int *have_type)
|
||||
* if the value for %d exists, then the viewer is started up at that line number.
|
||||
*/
|
||||
int
|
||||
regex_command (char *filename, char *action, int *move_dir)
|
||||
regex_command (const char *filename, const char *action, int *move_dir)
|
||||
{
|
||||
char *p, *q, *r, c;
|
||||
int file_len = strlen (filename);
|
||||
@ -427,7 +427,7 @@ regex_command (char *filename, char *action, int *move_dir)
|
||||
/* Check for the special View:%d parameter */
|
||||
if (strncmp (action, "View:", 5) == 0) {
|
||||
view_at_line_number = atoi (action + 5);
|
||||
action[4] = 0;
|
||||
action = "View";
|
||||
} else {
|
||||
view_at_line_number = 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __EXT_H
|
||||
#define __EXT_H
|
||||
|
||||
int regex_command (char *filename, char *action, int *move_dir);
|
||||
int regex_command (const char *filename, const char *action, int *move_dir);
|
||||
|
||||
/* Call it after the user has edited the mc.ext file,
|
||||
* to flush the cached mc.ext file
|
||||
|
34
src/file.c
34
src/file.c
@ -127,12 +127,12 @@ char *op_names[3] = {
|
||||
|
||||
/* }}} */
|
||||
|
||||
static int query_replace (FileOpContext * ctx, char *destname,
|
||||
static int query_replace (FileOpContext * ctx, const char *destname,
|
||||
struct stat *_s_stat, struct stat *_d_stat);
|
||||
static int query_recursive (FileOpContext * ctx, char *s);
|
||||
static int do_file_error (char *str);
|
||||
static int erase_dir_iff_empty (FileOpContext *ctx, char *s);
|
||||
static int erase_file (FileOpContext *ctx, char *s,
|
||||
static int query_recursive (FileOpContext * ctx, const char *s);
|
||||
static int do_file_error (const char *str);
|
||||
static int erase_dir_iff_empty (FileOpContext *ctx, const char *s);
|
||||
static int erase_file (FileOpContext *ctx, const char *s,
|
||||
off_t *progress_count, double *progress_bytes,
|
||||
int is_toplevel_file);
|
||||
static int files_error (const char *format, const char *file1,
|
||||
@ -457,7 +457,7 @@ enum {
|
||||
};
|
||||
|
||||
int
|
||||
copy_file_file (FileOpContext *ctx, char *src_path, char *dst_path,
|
||||
copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
||||
int ask_overwrite, off_t *progress_count,
|
||||
double *progress_bytes, int is_toplevel_file)
|
||||
{
|
||||
@ -854,7 +854,7 @@ copy_file_file (FileOpContext *ctx, char *src_path, char *dst_path,
|
||||
/* FIXME: This function needs to check the return values of the
|
||||
function calls */
|
||||
int
|
||||
copy_dir_dir (FileOpContext *ctx, char *s, char *d, int toplevel,
|
||||
copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
int move_over, int delete,
|
||||
struct link *parent_dirs,
|
||||
off_t *progress_count, double *progress_bytes)
|
||||
@ -1195,7 +1195,7 @@ move_file_file (FileOpContext *ctx, char *s, char *d,
|
||||
}
|
||||
|
||||
int
|
||||
move_dir_dir (FileOpContext *ctx, char *s, char *d,
|
||||
move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
||||
off_t *progress_count, double *progress_bytes)
|
||||
{
|
||||
struct stat sbuf, dbuf, destbuf;
|
||||
@ -1333,7 +1333,7 @@ move_dir_dir (FileOpContext *ctx, char *s, char *d,
|
||||
/* {{{ Erase routines */
|
||||
/* Don't update progress status if progress_count==NULL */
|
||||
static int
|
||||
erase_file (FileOpContext *ctx, char *s, off_t *progress_count,
|
||||
erase_file (FileOpContext *ctx, const char *s, off_t *progress_count,
|
||||
double *progress_bytes, int is_toplevel_file)
|
||||
{
|
||||
int return_status;
|
||||
@ -1445,7 +1445,7 @@ check_dir_is_empty (char *path)
|
||||
}
|
||||
|
||||
int
|
||||
erase_dir (FileOpContext *ctx, char *s, off_t *progress_count,
|
||||
erase_dir (FileOpContext *ctx, const char *s, off_t *progress_count,
|
||||
double *progress_bytes)
|
||||
{
|
||||
int error;
|
||||
@ -1488,7 +1488,7 @@ erase_dir (FileOpContext *ctx, char *s, off_t *progress_count,
|
||||
}
|
||||
|
||||
static int
|
||||
erase_dir_iff_empty (FileOpContext *ctx, char *s)
|
||||
erase_dir_iff_empty (FileOpContext *ctx, const char *s)
|
||||
{
|
||||
int error;
|
||||
|
||||
@ -1556,7 +1556,7 @@ panel_get_file (WPanel *panel, struct stat *stat_buf)
|
||||
* Computes the number of bytes used by the files in a directory
|
||||
*/
|
||||
void
|
||||
compute_dir_size (char *dirname, off_t *ret_marked, double *ret_total)
|
||||
compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
@ -2138,7 +2138,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
/* {{{ Query/status report routines */
|
||||
|
||||
static int
|
||||
real_do_file_error (enum OperationMode mode, char *error)
|
||||
real_do_file_error (enum OperationMode mode, const char *error)
|
||||
{
|
||||
int result;
|
||||
char *msg;
|
||||
@ -2165,7 +2165,7 @@ real_do_file_error (enum OperationMode mode, char *error)
|
||||
|
||||
/* Report error with one file */
|
||||
int
|
||||
file_error (char *format, char *file)
|
||||
file_error (const char *format, const char *file)
|
||||
{
|
||||
g_snprintf (cmd_buf, sizeof (cmd_buf), format,
|
||||
name_trunc (file, 30), unix_error_string (errno));
|
||||
@ -2234,7 +2234,7 @@ real_query_recursive (FileOpContext *ctx, enum OperationMode mode, char *s)
|
||||
|
||||
#ifdef WITH_BACKGROUND
|
||||
static int
|
||||
do_file_error (char *str)
|
||||
do_file_error (const char *str)
|
||||
{
|
||||
if (we_are_background)
|
||||
return parent_call (real_do_file_error, NULL, 1, strlen (str),
|
||||
@ -2244,7 +2244,7 @@ do_file_error (char *str)
|
||||
}
|
||||
|
||||
static int
|
||||
query_recursive (FileOpContext *ctx, char *s)
|
||||
query_recursive (FileOpContext *ctx, const char *s)
|
||||
{
|
||||
if (we_are_background)
|
||||
return parent_call (real_query_recursive, ctx, 1, strlen (s), s);
|
||||
@ -2253,7 +2253,7 @@ query_recursive (FileOpContext *ctx, char *s)
|
||||
}
|
||||
|
||||
static int
|
||||
query_replace (FileOpContext *ctx, char *destname, struct stat *_s_stat,
|
||||
query_replace (FileOpContext *ctx, const char *destname, struct stat *_s_stat,
|
||||
struct stat *_d_stat)
|
||||
{
|
||||
if (we_are_background)
|
||||
|
12
src/file.h
12
src/file.h
@ -7,15 +7,15 @@ extern int safe_delete;
|
||||
|
||||
struct link;
|
||||
|
||||
int copy_file_file (FileOpContext *ctx, char *s, char *d,
|
||||
int copy_file_file (FileOpContext *ctx, const char *s, const char *d,
|
||||
int ask_overwrite, off_t *progress_count,
|
||||
double *progress_bytes, int is_toplevel_file);
|
||||
int move_dir_dir (FileOpContext *ctx, char *s, char *d,
|
||||
int move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
||||
off_t *progress_count, double *progress_bytes);
|
||||
int copy_dir_dir (FileOpContext *ctx, char *s, char *d, int toplevel,
|
||||
int copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
int move_over, int delete, struct link *parent_dirs,
|
||||
off_t *progress_count, double *progress_bytes);
|
||||
int erase_dir (FileOpContext *ctx, char *s, off_t *progress_count,
|
||||
int erase_dir (FileOpContext *ctx, const char *s, off_t *progress_count,
|
||||
double *progress_bytes);
|
||||
|
||||
int panel_operate (void *source_panel, FileOperation op, int force_single);
|
||||
@ -25,11 +25,11 @@ extern int file_op_compute_totals;
|
||||
/* Error reporting routines */
|
||||
|
||||
/* Report error with one file */
|
||||
int file_error (char *format, char *file);
|
||||
int file_error (const char *format, const char *file);
|
||||
|
||||
/* Query routines */
|
||||
|
||||
void compute_dir_size (char *dirname, off_t *ret_marked,
|
||||
void compute_dir_size (const char *dirname, off_t *ret_marked,
|
||||
double *ret_total);
|
||||
|
||||
#endif /* !__FILE_H */
|
||||
|
@ -426,7 +426,7 @@ file_progress_show_bytes (FileOpContext *ctx, double done, double total)
|
||||
#define truncFileString(ui, s) name_trunc (s, ui->eta_extra + 47)
|
||||
|
||||
FileProgressStatus
|
||||
file_progress_show_source (FileOpContext *ctx, char *s)
|
||||
file_progress_show_source (FileOpContext *ctx, const char *s)
|
||||
{
|
||||
FileOpContextUI *ui;
|
||||
|
||||
@ -459,7 +459,7 @@ file_progress_show_source (FileOpContext *ctx, char *s)
|
||||
}
|
||||
|
||||
FileProgressStatus
|
||||
file_progress_show_target (FileOpContext *ctx, char *s)
|
||||
file_progress_show_target (FileOpContext *ctx, const char *s)
|
||||
{
|
||||
FileOpContextUI *ui;
|
||||
|
||||
@ -482,7 +482,7 @@ file_progress_show_target (FileOpContext *ctx, char *s)
|
||||
}
|
||||
|
||||
FileProgressStatus
|
||||
file_progress_show_deleting (FileOpContext *ctx, char *s)
|
||||
file_progress_show_deleting (FileOpContext *ctx, const char *s)
|
||||
{
|
||||
FileOpContextUI *ui;
|
||||
|
||||
@ -639,7 +639,7 @@ init_replace (FileOpContext *ctx, enum OperationMode mode)
|
||||
}
|
||||
|
||||
void
|
||||
file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg)
|
||||
file_progress_set_stalled_label (FileOpContext *ctx, const char *stalled_msg)
|
||||
{
|
||||
FileOpContextUI *ui;
|
||||
|
||||
@ -655,7 +655,7 @@ file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg)
|
||||
|
||||
FileProgressStatus
|
||||
file_progress_real_query_replace (FileOpContext *ctx,
|
||||
enum OperationMode mode, char *destname,
|
||||
enum OperationMode mode, const char *destname,
|
||||
struct stat *_s_stat,
|
||||
struct stat *_d_stat)
|
||||
{
|
||||
@ -848,8 +848,8 @@ fmd_init_i18n (int force)
|
||||
}
|
||||
|
||||
char *
|
||||
file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text,
|
||||
char *def_text, int only_one, int *do_background)
|
||||
file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
|
||||
const char *def_text, int only_one, int *do_background)
|
||||
{
|
||||
int source_easy_patterns = easy_patterns;
|
||||
char *source_mask, *orig_mask, *dest_dir;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
void fmd_init_i18n (int force);
|
||||
char *file_mask_dialog (FileOpContext *ctx, FileOperation operation,
|
||||
char *text, char *def_text, int only_one,
|
||||
const char *text, const char *def_text, int only_one,
|
||||
int *do_background);
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@ typedef enum {
|
||||
OP_DELETE
|
||||
} FileOperation;
|
||||
|
||||
typedef int (*mc_stat_fn) (char *filename, struct stat *buf);
|
||||
typedef int (*mc_stat_fn) (const char *filename, struct stat *buf);
|
||||
|
||||
/* This structure describes a context for file operations. It is used to update
|
||||
* the progress windows and pass around options.
|
||||
@ -146,15 +146,15 @@ void file_op_context_destroy_ui (FileOpContext *ctx);
|
||||
FileProgressStatus file_progress_show (FileOpContext *ctx, off_t done, off_t total);
|
||||
FileProgressStatus file_progress_show_count (FileOpContext *ctx, off_t done, off_t total);
|
||||
FileProgressStatus file_progress_show_bytes (FileOpContext *ctx, double done, double total);
|
||||
FileProgressStatus file_progress_show_source (FileOpContext *ctx, char *path);
|
||||
FileProgressStatus file_progress_show_target (FileOpContext *ctx, char *path);
|
||||
FileProgressStatus file_progress_show_deleting (FileOpContext *ctx, char *path);
|
||||
FileProgressStatus file_progress_show_source (FileOpContext *ctx, const char *path);
|
||||
FileProgressStatus file_progress_show_target (FileOpContext *ctx, const char *path);
|
||||
FileProgressStatus file_progress_show_deleting (FileOpContext *ctx, const char *path);
|
||||
|
||||
void file_progress_set_stalled_label (FileOpContext *ctx, char *stalled_msg);
|
||||
void file_progress_set_stalled_label (FileOpContext *ctx, const char *stalled_msg);
|
||||
|
||||
FileProgressStatus file_progress_real_query_replace (FileOpContext *ctx,
|
||||
enum OperationMode mode,
|
||||
char *destname,
|
||||
const char *destname,
|
||||
struct stat *_s_stat,
|
||||
struct stat *_d_stat);
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "findme.h"
|
||||
|
||||
char * findProgramPath(char * argv0) {
|
||||
const char * findProgramPath(const char * argv0) {
|
||||
char * path = getenv("PATH");
|
||||
char * pathbuf;
|
||||
char * start, * chptr;
|
||||
|
@ -5,6 +5,6 @@
|
||||
#ifndef H_FINDME
|
||||
#define H_FINDME
|
||||
|
||||
char * findProgramPath(char * argv0);
|
||||
const char * findProgramPath(const char * argv0);
|
||||
|
||||
#endif
|
||||
|
@ -749,7 +749,7 @@ interactive_display_finish (void)
|
||||
}
|
||||
|
||||
void
|
||||
interactive_display (char *filename, char *node)
|
||||
interactive_display (const char *filename, const char *node)
|
||||
{
|
||||
WButtonBar *help_bar;
|
||||
Widget *md;
|
||||
|
@ -17,5 +17,5 @@
|
||||
#define CHAR_FONT_NORMAL '\013' /* Ctrl-K */
|
||||
#define CHAR_FONT_ITALIC '\024' /* Ctrl-T */
|
||||
|
||||
void interactive_display (char *filename, char *node);
|
||||
void interactive_display (const char *filename, const char *node);
|
||||
#endif /* __HELP_H */
|
||||
|
@ -542,7 +542,7 @@ static int push_char (int c)
|
||||
* Return 1 on success, 0 on error.
|
||||
* An error happens if SEQ is a beginning of an existing longer sequence.
|
||||
*/
|
||||
int define_sequence (int code, char *seq, int action)
|
||||
int define_sequence (int code, const char *seq, int action)
|
||||
{
|
||||
key_def *base;
|
||||
|
||||
|
@ -56,7 +56,7 @@ int is_quit_char (int c);
|
||||
/* Return code for the mouse sequence */
|
||||
#define MCKEY_MOUSE -2
|
||||
|
||||
int define_sequence (int code, char *seq, int action);
|
||||
int define_sequence (int code, const char *seq, int action);
|
||||
|
||||
/* internally used in key.c, defined in keyxtra.c */
|
||||
void load_xtra_key_defines (void);
|
||||
|
@ -805,7 +805,7 @@ void use_dash (int flag)
|
||||
ok_to_refresh--;
|
||||
}
|
||||
|
||||
void set_hintbar(char *str)
|
||||
void set_hintbar(const char *str)
|
||||
{
|
||||
label_set_text (the_hint, str);
|
||||
if (ok_to_refresh > 0)
|
||||
@ -866,7 +866,7 @@ void rotate_dash (void)
|
||||
pos++;
|
||||
}
|
||||
|
||||
char *get_nth_panel_name (int num)
|
||||
const char *get_nth_panel_name (int num)
|
||||
{
|
||||
static char buffer [BUF_SMALL];
|
||||
|
||||
|
@ -16,7 +16,7 @@ int get_current_type (void);
|
||||
int get_other_type (void);
|
||||
int get_current_index (void);
|
||||
int get_other_index (void);
|
||||
char *get_nth_panel_name (int num);
|
||||
const char *get_nth_panel_name (int num);
|
||||
|
||||
struct Widget;
|
||||
struct Widget *get_panel_widget (int index);
|
||||
@ -24,7 +24,7 @@ struct Widget *get_panel_widget (int index);
|
||||
struct WPanel;
|
||||
struct WPanel *get_other_panel (void);
|
||||
|
||||
void set_hintbar (char *str);
|
||||
void set_hintbar (const char *str);
|
||||
|
||||
/* Clear screen */
|
||||
void clr_scr (void);
|
||||
|
@ -46,7 +46,7 @@ menu_scan_hotkey (Menu *menu)
|
||||
}
|
||||
|
||||
Menu *
|
||||
create_menu (char *name, menu_entry *entries, int count, char *help_node)
|
||||
create_menu (const char *name, menu_entry *entries, int count, const char *help_node)
|
||||
{
|
||||
Menu *menu;
|
||||
char *cp;
|
||||
|
@ -13,14 +13,14 @@ typedef struct {
|
||||
} menu_entry;
|
||||
|
||||
typedef struct Menu {
|
||||
char *name;
|
||||
const char *name;
|
||||
int count;
|
||||
int max_entry_len;
|
||||
int selected;
|
||||
int hotkey;
|
||||
menu_entry *entries;
|
||||
int start_x; /* position relative to menubar start */
|
||||
char *help_node;
|
||||
const char *help_node;
|
||||
} Menu;
|
||||
|
||||
extern int menubar_visible;
|
||||
@ -39,8 +39,8 @@ typedef struct WMenu {
|
||||
int previous_widget; /* Selected widget ID before activating menu */
|
||||
} WMenu;
|
||||
|
||||
Menu *create_menu (char *name, menu_entry *entries, int count,
|
||||
char *help_node);
|
||||
Menu *create_menu (const char *name, menu_entry *entries, int count,
|
||||
const char *help_node);
|
||||
void destroy_menu (Menu *menu);
|
||||
WMenu *menubar_new (int y, int x, int cols, Menu *menu[], int items);
|
||||
void menubar_arrange (WMenu *menubar);
|
||||
|
@ -588,7 +588,7 @@ init_my_statfs (void)
|
||||
}
|
||||
|
||||
void
|
||||
my_statfs (struct my_statfs *myfs_stats, char *path)
|
||||
my_statfs (struct my_statfs *myfs_stats, const char *path)
|
||||
{
|
||||
#ifdef HAVE_INFOMOUNT_LIST
|
||||
int i, len = 0;
|
||||
|
@ -31,6 +31,6 @@ struct my_statfs {
|
||||
};
|
||||
|
||||
void init_my_statfs (void);
|
||||
void my_statfs (struct my_statfs *myfs_stats, char *path);
|
||||
void my_statfs (struct my_statfs *myfs_stats, const char *path);
|
||||
|
||||
#endif /* __MOUNTLIST_H */
|
||||
|
@ -97,7 +97,7 @@ extern WPanel *left_panel;
|
||||
extern WPanel *right_panel;
|
||||
extern WPanel *current_panel;
|
||||
|
||||
void try_to_select (WPanel *panel, char *name);
|
||||
void try_to_select (WPanel *panel, const char *name);
|
||||
|
||||
void unmark_files (WPanel *panel);
|
||||
void select_item (WPanel *panel);
|
||||
|
@ -858,7 +858,7 @@ do_try_to_select (WPanel *panel, char *name)
|
||||
}
|
||||
|
||||
void
|
||||
try_to_select (WPanel *panel, char *name)
|
||||
try_to_select (WPanel *panel, const char *name)
|
||||
{
|
||||
do_try_to_select (panel, name);
|
||||
select_item (panel);
|
||||
|
@ -221,7 +221,7 @@ static const struct {
|
||||
};
|
||||
|
||||
void
|
||||
panel_save_setup (struct WPanel *panel, char *section)
|
||||
panel_save_setup (struct WPanel *panel, const char *section)
|
||||
{
|
||||
char buffer [BUF_TINY];
|
||||
int i;
|
||||
@ -359,7 +359,7 @@ save_setup (void)
|
||||
}
|
||||
|
||||
void
|
||||
panel_load_setup (WPanel *panel, char *section)
|
||||
panel_load_setup (WPanel *panel, const char *section)
|
||||
{
|
||||
int i;
|
||||
char buffer [BUF_TINY];
|
||||
|
@ -11,8 +11,8 @@ void load_key_defs (void);
|
||||
char *load_anon_passwd (void);
|
||||
|
||||
struct WPanel;
|
||||
void panel_save_setup (struct WPanel *panel, char *section);
|
||||
void panel_load_setup (struct WPanel *panel, char *section);
|
||||
void panel_save_setup (struct WPanel *panel, const char *section);
|
||||
void panel_load_setup (struct WPanel *panel, const char *section);
|
||||
|
||||
extern char *profile_name;
|
||||
extern char *global_profile_name;
|
||||
|
@ -443,7 +443,7 @@ static void tree_move_to_bottom (WTree *tree)
|
||||
tree->topdiff = tlines (tree) - 3 - 1;
|
||||
}
|
||||
|
||||
void tree_chdir (WTree *tree, char *dir)
|
||||
void tree_chdir (WTree *tree, const char *dir)
|
||||
{
|
||||
tree_entry *current;
|
||||
|
||||
@ -455,7 +455,7 @@ void tree_chdir (WTree *tree, char *dir)
|
||||
}
|
||||
|
||||
void
|
||||
sync_tree (char *path)
|
||||
sync_tree (const char *path)
|
||||
{
|
||||
tree_chdir (the_tree, path);
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ typedef struct WTree WTree;
|
||||
|
||||
#define tlines(t) (t->is_panel ? t->widget.lines-2 - (show_mini_info ? 2 : 0) : t->widget.lines)
|
||||
|
||||
int tree_init (char *current_dir, int lines);
|
||||
void tree_chdir (WTree *tree, char *dir);
|
||||
int tree_init (const char *current_dir, int lines);
|
||||
void tree_chdir (WTree *tree, const char *dir);
|
||||
char *tree_selected_name (WTree *tree);
|
||||
|
||||
void sync_tree (char *pathname);
|
||||
void sync_tree (const char *pathname);
|
||||
|
||||
extern int xtree_mode;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
static struct TreeStore ts;
|
||||
|
||||
static tree_entry *tree_store_add_entry(char *name);
|
||||
static tree_entry *tree_store_add_entry(const char *name);
|
||||
|
||||
static void
|
||||
tree_store_dirty(int state)
|
||||
@ -59,7 +59,7 @@ tree_store_dirty(int state)
|
||||
|
||||
/* Returns number of common characters */
|
||||
static int
|
||||
str_common(char *s1, char *s2)
|
||||
str_common(const char *s1, const char *s2)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
@ -109,7 +109,7 @@ pathcmp(const char *p1, const char *p2)
|
||||
|
||||
/* Searches for specified directory */
|
||||
tree_entry *
|
||||
tree_store_whereis(char *name)
|
||||
tree_store_whereis(const char *name)
|
||||
{
|
||||
tree_entry *current = ts.tree_first;
|
||||
int flag = -1;
|
||||
@ -271,10 +271,11 @@ tree_store_load(void)
|
||||
}
|
||||
|
||||
static char *
|
||||
encode(char *string)
|
||||
encode(const char *string)
|
||||
{
|
||||
int special_chars;
|
||||
char *p, *q;
|
||||
const char *p;
|
||||
char *q;
|
||||
char *res;
|
||||
|
||||
for (special_chars = 0, p = string; *p; p++) {
|
||||
@ -389,7 +390,7 @@ tree_store_save(void)
|
||||
}
|
||||
|
||||
static tree_entry *
|
||||
tree_store_add_entry(char *name)
|
||||
tree_store_add_entry(const char *name)
|
||||
{
|
||||
int flag = -1;
|
||||
tree_entry *current = ts.tree_first;
|
||||
@ -550,7 +551,7 @@ remove_entry(tree_entry * entry)
|
||||
}
|
||||
|
||||
void
|
||||
tree_store_remove_entry(char *name)
|
||||
tree_store_remove_entry(const char *name)
|
||||
{
|
||||
tree_entry *current, *base, *old;
|
||||
int len;
|
||||
@ -634,7 +635,7 @@ tree_store_mark_checked(const char *subname)
|
||||
|
||||
/* Mark the subdirectories of the current directory for delete */
|
||||
tree_entry *
|
||||
tree_store_start_check(char *path)
|
||||
tree_store_start_check(const char *path)
|
||||
{
|
||||
tree_entry *current, *retval;
|
||||
int len;
|
||||
@ -762,7 +763,7 @@ should_skip_directory(char *dir)
|
||||
}
|
||||
|
||||
tree_entry *
|
||||
tree_store_rescan(char *dir)
|
||||
tree_store_rescan(const char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
|
@ -10,7 +10,7 @@ typedef struct tree_entry {
|
||||
char *name; /* The full path of directory */
|
||||
int sublevel; /* Number of parent directories (slashes) */
|
||||
long submask; /* Bitmask of existing sublevels after this entry */
|
||||
char *subname; /* The last part of name (the actual name) */
|
||||
const char *subname; /* The last part of name (the actual name) */
|
||||
unsigned int mark:1; /* Flag: Is this entry marked (e. g. for delete)? */
|
||||
unsigned int scanned:1; /* Flag: childs scanned or not */
|
||||
struct tree_entry *next; /* Next item in the list */
|
||||
@ -30,12 +30,12 @@ struct TreeStore {
|
||||
struct TreeStore *tree_store_get (void);
|
||||
int tree_store_load (void);
|
||||
int tree_store_save (void);
|
||||
void tree_store_remove_entry (char *name);
|
||||
tree_entry *tree_store_start_check (char *path);
|
||||
void tree_store_remove_entry (const char *name);
|
||||
tree_entry *tree_store_start_check (const char *path);
|
||||
void tree_store_mark_checked (const char *subname);
|
||||
void tree_store_end_check (void);
|
||||
tree_entry *tree_store_whereis (char *name);
|
||||
tree_entry *tree_store_rescan (char *dir);
|
||||
tree_entry *tree_store_whereis (const char *name);
|
||||
tree_entry *tree_store_rescan (const char *dir);
|
||||
|
||||
/*
|
||||
* Register/unregister notification functions for "entry_remove"
|
||||
|
10
src/util.c
10
src/util.c
@ -122,7 +122,7 @@ int msglen (const char *text, int *lines)
|
||||
* bytes, not counting trailing 0.
|
||||
*/
|
||||
char *
|
||||
trim (char *s, char *d, int len)
|
||||
trim (const char *s, char *d, int len)
|
||||
{
|
||||
int source_len;
|
||||
|
||||
@ -218,7 +218,7 @@ fake_name_quote (const char *s, int quote_percent)
|
||||
* Use "~" to show where the string was truncated.
|
||||
* Return static buffer, no need to free() it.
|
||||
*/
|
||||
char *
|
||||
const char *
|
||||
name_trunc (const char *txt, int trunc_len)
|
||||
{
|
||||
static char x[MC_MAXPATHLEN + MC_MAXPATHLEN];
|
||||
@ -244,11 +244,11 @@ name_trunc (const char *txt, int trunc_len)
|
||||
return x;
|
||||
}
|
||||
|
||||
char *size_trunc (double size)
|
||||
const char *size_trunc (double size)
|
||||
{
|
||||
static char x [BUF_TINY];
|
||||
long int divisor = 1;
|
||||
char *xtra = "";
|
||||
const char *xtra = "";
|
||||
|
||||
if (size > 999999999L){
|
||||
divisor = 1024;
|
||||
@ -262,7 +262,7 @@ char *size_trunc (double size)
|
||||
return x;
|
||||
}
|
||||
|
||||
char *size_trunc_sep (double size)
|
||||
const char *size_trunc_sep (double size)
|
||||
{
|
||||
static char x [60];
|
||||
int count;
|
||||
|
35
src/util.h
35
src/util.h
@ -9,12 +9,39 @@
|
||||
void str_replace(char *s, char from, char to);
|
||||
int is_printable (int c);
|
||||
int msglen (const char *text, int *lines);
|
||||
char *trim (char *s, char *d, int len);
|
||||
|
||||
/* Copy from s to d, and trim the beginning if necessary, and prepend
|
||||
* "..." in this case. The destination string can have at most len
|
||||
* bytes, not counting trailing 0. */
|
||||
char *trim (const char *s, char *d, int len);
|
||||
|
||||
/* Quote the filename for the purpose of inserting it into the command
|
||||
* line. If quote_percent is 1, replace "%" with "%%" - the percent is
|
||||
* processed by the mc command line. */
|
||||
char *name_quote (const char *c, int quote_percent);
|
||||
|
||||
/* returns a duplicate of c. */
|
||||
char *fake_name_quote (const char *c, int quote_percent);
|
||||
char *name_trunc (const char *txt, int trunc_len);
|
||||
char *size_trunc (double size);
|
||||
char *size_trunc_sep (double size);
|
||||
|
||||
/* Remove the middle part of the string to fit given length.
|
||||
* Use "~" to show where the string was truncated.
|
||||
* Return static buffer, no need to free() it. */
|
||||
const char *name_trunc (const char *txt, int trunc_len);
|
||||
|
||||
/* return a static string representing size, appending "K" or "M" for
|
||||
* big sizes.
|
||||
* NOTE: uses the same static buffer as size_trunc_sep. */
|
||||
const char *size_trunc (double size);
|
||||
|
||||
/* return a static string representing size, appending "K" or "M" for
|
||||
* big sizes. Separates every three digits by ",".
|
||||
* NOTE: uses the same static buffer as size_trunc. */
|
||||
const char *size_trunc_sep (double size);
|
||||
|
||||
/* Print file SIZE to BUFFER, but don't exceed LEN characters,
|
||||
* not including trailing 0. BUFFER should be at least LEN+1 long.
|
||||
*
|
||||
* Units: size units (0=bytes, 1=Kbytes, 2=Mbytes, etc.) */
|
||||
void size_trunc_len (char *buffer, int len, off_t size, int units);
|
||||
int is_exe (mode_t mode);
|
||||
char *string_perm (mode_t mode_bits);
|
||||
|
@ -2387,7 +2387,7 @@ groupbox_callback (WGroupbox *g, widget_msg_t msg, int parm)
|
||||
}
|
||||
|
||||
WGroupbox *
|
||||
groupbox_new (int x, int y, int width, int height, char *title)
|
||||
groupbox_new (int x, int y, int width, int height, const char *title)
|
||||
{
|
||||
WGroupbox *g = g_new (WGroupbox, 1);
|
||||
|
||||
|
@ -145,7 +145,7 @@ WInput *input_new (int y, int x, int color, int len, const char *text, const
|
||||
WLabel *label_new (int y, int x, const char *text);
|
||||
WGauge *gauge_new (int y, int x, int shown, int max, int current);
|
||||
WListbox *listbox_new (int x, int y, int width, int height, lcback callback);
|
||||
WGroupbox *groupbox_new (int x, int y, int width, int height, char *title);
|
||||
WGroupbox *groupbox_new (int x, int y, int width, int height, const char *title);
|
||||
|
||||
/* Input lines */
|
||||
void winput_set_origin (WInput *i, int x, int field_len);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user