aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/colors.c10
-rw-r--r--src/colors.h6
-rw-r--r--src/command.c8
-rw-r--r--src/command.h12
-rw-r--r--src/conf.c8
-rw-r--r--src/libmpdclient.c11
-rw-r--r--src/libmpdclient.h4
-rw-r--r--src/list_window.c10
-rw-r--r--src/list_window.h10
-rw-r--r--src/main.c8
-rw-r--r--src/mpdclient.c14
-rw-r--r--src/mpdclient.h4
-rw-r--r--src/ncmpc.h2
-rw-r--r--src/options.c16
-rw-r--r--src/screen.c16
-rw-r--r--src/screen.h8
-rw-r--r--src/screen_browse.h2
-rw-r--r--src/screen_clock.c2
-rw-r--r--src/screen_file.c6
-rw-r--r--src/screen_help.c6
-rw-r--r--src/screen_keydef.c4
-rw-r--r--src/screen_lyrics.c4
-rw-r--r--src/screen_play.c4
-rw-r--r--src/screen_search.c12
-rw-r--r--src/screen_utils.c14
-rw-r--r--src/screen_utils.h12
-rw-r--r--src/strfsong.c10
-rw-r--r--src/support.c8
-rw-r--r--src/support.h6
-rw-r--r--src/utils.c6
-rw-r--r--src/utils.h6
-rw-r--r--src/wreadln.c16
-rw-r--r--src/wreadln.h4
33 files changed, 135 insertions, 134 deletions
diff --git a/src/colors.c b/src/colors.c
index c504e0085..e60399ea7 100644
--- a/src/colors.c
+++ b/src/colors.c
@@ -64,7 +64,7 @@ typedef struct {
typedef struct {
int id;
- char *name;
+ const char *name;
short fg;
attr_t attrs;
} color_entry_t;
@@ -107,7 +107,7 @@ colors_lookup(int id)
}
static color_entry_t *
-colors_lookup_by_name(char *name)
+colors_lookup_by_name(const char *name)
{
int i;
@@ -147,7 +147,7 @@ colors_update_pair(int id)
}
short
-colors_str2color(char *str)
+colors_str2color(const char *str)
{
if( !strcasecmp(str,"black") )
return COLOR_BLACK;
@@ -191,7 +191,7 @@ colors_str2color(char *str)
* it adds the definition to the color_definition_list and init_color() is
* done in colors_start() */
int
-colors_define(char *name, short r, short g, short b)
+colors_define(const char *name, short r, short g, short b)
{
color_definition_entry_t *entry;
short color = colors_str2color(name);
@@ -212,7 +212,7 @@ colors_define(char *name, short r, short g, short b)
int
-colors_assign(char *name, char *value)
+colors_assign(const char *name, const char *value)
{
color_entry_t *entry = colors_lookup_by_name(name);
short color;
diff --git a/src/colors.h b/src/colors.h
index a66d693cc..421163006 100644
--- a/src/colors.h
+++ b/src/colors.h
@@ -13,10 +13,10 @@
#define COLOR_STATUS_TIME 10
#define COLOR_STATUS_ALERT 11
-short colors_str2color(char *str);
+short colors_str2color(const char *str);
-int colors_assign(char *name, char *value);
-int colors_define(char *name, short r, short g, short b);
+int colors_assign(const char *name, const char *value);
+int colors_define(const char *name, short r, short g, short b);
int colors_start(void);
int colors_use(WINDOW *w, int id);
diff --git a/src/command.c b/src/command.c
index a565c25ec..4f4a8e938 100644
--- a/src/command.c
+++ b/src/command.c
@@ -213,7 +213,7 @@ get_command_definitions(void)
return cmds;
}
-char *
+const char *
key2str(int key)
{
static char buf[32];
@@ -307,7 +307,7 @@ set_key_flags(command_definition_t *cp, command_t command, int flags)
return 1;
}
-char *
+const char *
get_key_names(command_t command, int all)
{
int i;
@@ -337,7 +337,7 @@ get_key_names(command_t command, int all)
return NULL;
}
-char *
+const char *
get_key_description(command_t command)
{
int i;
@@ -352,7 +352,7 @@ get_key_description(command_t command)
return NULL;
}
-char *
+const char *
get_key_command_name(command_t command)
{
int i;
diff --git a/src/command.h b/src/command.h
index 568f05098..75886d5ef 100644
--- a/src/command.h
+++ b/src/command.h
@@ -75,8 +75,8 @@ typedef struct {
int keys[MAX_COMMAND_KEYS];
char flags;
command_t command;
- char *name;
- char *description;
+ const char *name;
+ const char *description;
} command_definition_t;
command_definition_t *get_command_definitions(void);
@@ -86,10 +86,10 @@ void command_dump_keys(void);
int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
int write_key_bindings(FILE *f, int all);
-char *key2str(int key);
-char *get_key_description(command_t command);
-char *get_key_command_name(command_t command);
-char *get_key_names(command_t command, int all);
+const char *key2str(int key);
+const char *get_key_description(command_t command);
+const char *get_key_command_name(command_t command);
+const char *get_key_names(command_t command, int all);
command_t get_key_command(int key);
command_t get_key_command_from_name(char *name);
int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
diff --git a/src/conf.c b/src/conf.c
index dda13f56b..0e477db88 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -218,8 +218,8 @@ parse_key_definition(char *str)
return assign_keys(cmd, keys);
}
-static char *
-parse_timedisplay_type(char *str)
+static const char *
+parse_timedisplay_type(const char *str)
{
if((!strcmp(str,"elapsed")) || (!strcmp(str,"remaining"))){
return str;
@@ -232,8 +232,8 @@ parse_timedisplay_type(char *str)
static int
parse_color(char *str)
{
- char *name = str;
- char *value = NULL;
+ const char *name = str;
+ const char *value = NULL;
int len,i;
i=0;
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index c9641e9e4..a52ce23ca 100644
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
@@ -233,7 +233,7 @@ static int mpd_connect(mpd_Connection * connection, const char * host, int port,
}
#endif /* !MPD_HAVE_GAI */
-char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES] =
+const char *const mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES] =
{
"Artist",
"Album",
@@ -419,11 +419,12 @@ void mpd_closeConnection(mpd_Connection * connection) {
WSACleanup();
}
-static void mpd_executeCommand(mpd_Connection * connection, char * command) {
+static void mpd_executeCommand(mpd_Connection *connection,
+ const char *command) {
int ret;
struct timeval tv;
fd_set fds;
- char * commandPtr = command;
+ const char *commandPtr = command;
int commandLen = strlen(command);
if(!connection->doneProcessing && !connection->commandList) {
@@ -1432,8 +1433,8 @@ void mpd_sendSeekIdCommand(mpd_Connection * connection, int id, int time) {
free(string);
}
-void mpd_sendUpdateCommand(mpd_Connection * connection, char * path) {
- char * sPath = mpd_sanitizeArg(path);
+void mpd_sendUpdateCommand(mpd_Connection * connection, const char *path) {
+ char *sPath = mpd_sanitizeArg(path);
char * string = malloc(strlen("update")+strlen(sPath)+5);
sprintf(string,"update \"%s\"\n",sPath);
mpd_sendInfoCommand(connection,string);
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index 437951b31..fe1991edc 100644
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
@@ -91,7 +91,7 @@ typedef enum mpd_TagItems
MPD_TAG_NUM_OF_ITEM_TYPES
}mpd_TagItems;
-extern char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES];
+extern const char *const mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES];
/* internal stuff don't touch this struct */
typedef struct _mpd_ReturnElement {
@@ -498,7 +498,7 @@ void mpd_sendVolumeCommand(mpd_Connection * connection, int volumeChange);
void mpd_sendCrossfadeCommand(mpd_Connection * connection, int seconds);
-void mpd_sendUpdateCommand(mpd_Connection * connection, char * path);
+void mpd_sendUpdateCommand(mpd_Connection * connection, const char *path);
/* returns the update job id, call this after a update command*/
int mpd_getUpdateId(mpd_Connection * connection);
diff --git a/src/list_window.c b/src/list_window.c
index 96ea7c110..a6bc911c3 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -168,7 +168,7 @@ list_window_paint(list_window_t *lw,
for (i = 0; i < lw->rows; i++) {
int highlight = 0;
- char *label;
+ const char *label;
label = callback(lw->start + i, &highlight, callback_data);
wmove(lw->w, i, 0);
@@ -204,12 +204,12 @@ int
list_window_find(list_window_t *lw,
list_window_callback_fn_t callback,
void *callback_data,
- char *str,
+ const char *str,
int wrap)
{
int h;
int i = lw->selected + 1;
- char *label;
+ const char *label;
while (wrap || i == lw->selected + 1) {
while ((label = callback(i,&h,callback_data))) {
@@ -236,13 +236,13 @@ int
list_window_rfind(list_window_t *lw,
list_window_callback_fn_t callback,
void *callback_data,
- char *str,
+ const char *str,
int wrap,
int rows)
{
int h;
int i = lw->selected-1;
- char *label;
+ const char *label;
if (rows == 0)
return 1;
diff --git a/src/list_window.h b/src/list_window.h
index 9ef67214b..114f71eff 100644
--- a/src/list_window.h
+++ b/src/list_window.h
@@ -7,9 +7,9 @@
#define LW_HIDE_CURSOR 0x01
-typedef char *(*list_window_callback_fn_t)(int index,
- int *highlight,
- void *data);
+typedef const char *(*list_window_callback_fn_t)(int index,
+ int *highlight,
+ void *data);
typedef struct {
WINDOW *w;
@@ -60,7 +60,7 @@ void list_window_check_selected(list_window_t *lw, int length);
int list_window_find(list_window_t *lw,
list_window_callback_fn_t callback,
void *callback_data,
- char *str,
+ const char *str,
int wrap);
/* find a string in a list window (reversed) */
@@ -68,7 +68,7 @@ int
list_window_rfind(list_window_t *lw,
list_window_callback_fn_t callback,
void *callback_data,
- char *str,
+ const char *str,
int wrap,
int rows);
diff --git a/src/main.c b/src/main.c
index 1d93b69fc..022802c80 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,8 +44,8 @@ static mpdclient_t *mpd = NULL;
static gboolean connected = FALSE;
static GTimer *timer = NULL;
-static gchar *
-error_msg(gchar *msg)
+static const gchar *
+error_msg(const gchar *msg)
{
gchar *p;
@@ -58,7 +58,7 @@ error_msg(gchar *msg)
}
static void
-error_callback(mpdclient_t *c, gint error, gchar *msg)
+error_callback(mpdclient_t *c, gint error, const gchar *msg)
{
gint code = GET_ACK_ERROR_CODE(error);
@@ -156,7 +156,7 @@ sigstop(void)
#ifndef NDEBUG
void
-D(char *format, ...)
+D(const char *format, ...)
{
if( options.debug )
{
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 9f060c46d..941c09114 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -51,12 +51,12 @@ static gint
compare_filelistentry_dir(gconstpointer filelist_entry1,
gconstpointer filelist_entry2)
{
- mpd_InfoEntity *e1, *e2;
+ const mpd_InfoEntity *e1, *e2;
char *key1, *key2;
int n = 0;
- e1 = ((filelist_entry_t *)filelist_entry1)->entity;
- e2 = ((filelist_entry_t *)filelist_entry2)->entity;
+ e1 = ((const filelist_entry_t *)filelist_entry1)->entity;
+ e2 = ((const filelist_entry_t *)filelist_entry2)->entity;
if (e1 && e2 &&
e1->type == MPD_INFO_ENTITY_TYPE_DIRECTORY &&
@@ -76,12 +76,12 @@ gint
compare_filelistentry_format(gconstpointer filelist_entry1,
gconstpointer filelist_entry2)
{
- mpd_InfoEntity *e1, *e2;
+ const mpd_InfoEntity *e1, *e2;
char key1[BUFSIZE], key2[BUFSIZE];
int n = 0;
- e1 = ((filelist_entry_t *)filelist_entry1)->entity;
- e2 = ((filelist_entry_t *)filelist_entry2)->entity;
+ e1 = ((const filelist_entry_t *)filelist_entry1)->entity;
+ e2 = ((const filelist_entry_t *)filelist_entry2)->entity;
if (e1 && e2 &&
e1->type == MPD_INFO_ENTITY_TYPE_SONG &&
@@ -884,7 +884,7 @@ mpdclient_filelist_free(mpdclient_filelist_t *filelist)
mpdclient_filelist_t *
-mpdclient_filelist_get(mpdclient_t *c, gchar *path)
+mpdclient_filelist_get(mpdclient_t *c, const gchar *path)
{
mpdclient_filelist_t *filelist;
mpd_InfoEntity *entity;
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 44c266afc..5f231c383 100644
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
@@ -114,7 +114,7 @@ GList *mpdclient_get_albums_utf8(mpdclient_t *c, gchar *artist_utf8);
#define IS_ACK_ERROR(n) (n & MPD_ERROR_ACK)
#define GET_ACK_ERROR_CODE(n) ((n & 0xFF00) >> 8)
-typedef void (*mpdc_error_cb_t) (mpdclient_t *c, gint error, gchar *msg);
+typedef void (*mpdc_error_cb_t) (mpdclient_t *c, gint error, const gchar *msg);
void mpdclient_install_error_callback(mpdclient_t *c, mpdc_error_cb_t cb);
void mpdclient_remove_error_callback(mpdclient_t *c, mpdc_error_cb_t cb);
@@ -161,7 +161,7 @@ void mpdclient_playlist_callback(mpdclient_t *c, int event, gpointer data);
/*** filelist functions ***************************************************/
mpdclient_filelist_t *mpdclient_filelist_free(mpdclient_filelist_t *filelist);
-mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, gchar *path);
+mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, const gchar *path);
mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c,
int exact_match,
int table,
diff --git a/src/ncmpc.h b/src/ncmpc.h
index 033145f91..9caf8601a 100644
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
@@ -22,7 +22,7 @@
#endif
#ifndef NDEBUG
-void D(char *format, ...);
+void D(const char *format, ...);
#else
#define D(...)
#endif
diff --git a/src/options.c b/src/options.c
index 1ecc79103..668fe7522 100644
--- a/src/options.c
+++ b/src/options.c
@@ -40,13 +40,13 @@
typedef struct {
int shortopt;
- char *longopt;
- char *argument;
- char *descrition;
+ const char *longopt;
+ const char *argument;
+ const char *descrition;
} arg_opt_t;
-typedef void (*option_callback_fn_t)(int c, char *arg);
+typedef void (*option_callback_fn_t)(int c, const char *arg);
options_t options;
@@ -92,7 +92,7 @@ lookup_option(int s, char *l)
}
static void
-option_error(int error, char *option, char *arg)
+option_error(int error, const char *option, const char *arg)
{
switch(error)
{
@@ -141,7 +141,7 @@ display_help(void)
}
static void
-handle_option(int c, char *arg)
+handle_option(int c, const char *arg)
{
D("option callback -%c %s\n", c, arg);
switch(c)
@@ -241,7 +241,7 @@ options_parse(int argc, const char *argv[])
i=1;
while (i < argc) {
- char *arg = (char *) argv[i];
+ const char *arg = argv[i];
size_t len = strlen(arg);
/* check for a long option */
@@ -351,7 +351,7 @@ options_init( void )
options.crossfade_time = DEFAULT_CROSSFADE_TIME;
options.seek_time = 1;
options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
- options.timedisplay_type = DEFAULT_TIMEDISPLAY_TYPE;
+ options.timedisplay_type = g_strdup(DEFAULT_TIMEDISPLAY_TYPE);
options.lyrics_timeout = DEFAULT_LYRICS_TIMEOUT;
options.scroll = DEFAULT_SCROLL;
options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
diff --git a/src/screen.c b/src/screen.c
index f4ced308c..af3417a3e 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -67,7 +67,7 @@ typedef screen_functions_t * (*screen_get_mode_functions_fn_t) (void);
typedef struct
{
gint id;
- gchar *name;
+ const gchar *name;
screen_get_mode_functions_fn_t get_mode_functions;
} screen_mode_info_t;
@@ -101,7 +101,7 @@ static int seek_id = -1;
static int seek_target_time = 0;
gint
-screen_get_id(char *name)
+screen_get_id(const char *name)
{
gint i=0;
@@ -186,7 +186,7 @@ screen_next_mode(mpdclient_t *c, int offset)
}
static void
-paint_top_window2(char *header, mpdclient_t *c)
+paint_top_window2(const char *header, mpdclient_t *c)
{
char flags[5];
WINDOW *w = screen->top_window.w;
@@ -258,7 +258,7 @@ paint_top_window2(char *header, mpdclient_t *c)
}
static void
-paint_top_window(char *header, mpdclient_t *c, int clear)
+paint_top_window(const char *header, mpdclient_t *c, int clear)
{
static int prev_volume = -1;
static int prev_header_len = -1;
@@ -314,7 +314,7 @@ paint_status_window(mpdclient_t *c)
mpd_Status *status = c->status;
mpd_Song *song = c->song;
int elapsedTime = 0;
- char *str = NULL;
+ const char *str = NULL;
int x = 0;
if( time(NULL) - screen->status_timestamp <= SCREEN_STATUS_MESSAGE_TIME )
@@ -499,7 +499,7 @@ screen_resize(void)
}
void
-screen_status_message(char *msg)
+screen_status_message(const char *msg)
{
WINDOW *w = screen->status_window.w;
@@ -512,7 +512,7 @@ screen_status_message(char *msg)
}
void
-screen_status_printf(char *format, ...)
+screen_status_printf(const char *format, ...)
{
char *msg;
va_list ap;
@@ -662,7 +662,7 @@ screen_init(mpdclient_t *c)
void
screen_paint(mpdclient_t *c)
{
- char *title = NULL;
+ const char *title = NULL;
if (mode_fn && mode_fn->get_title)
title = mode_fn->get_title(screen->buf, screen->buf_size);
diff --git a/src/screen.h b/src/screen.h
index f2c54d3da..4f3057df8 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -49,7 +49,7 @@ typedef void (*screen_resize_fn_t)(int cols, int rows);
typedef void (*screen_paint_fn_t)(screen_t *screen, mpdclient_t *c);
typedef void (*screen_update_fn_t)(screen_t *screen, mpdclient_t *c);
typedef int (*screen_cmd_fn_t)(screen_t *scr, mpdclient_t *c, command_t cmd);
-typedef char *(*screen_title_fn_t)(char *s, size_t size);
+typedef const char *(*screen_title_fn_t)(char *s, size_t size);
typedef list_window_t *(*screen_get_lw_fn_t) (void);
typedef struct {
@@ -69,14 +69,14 @@ typedef struct {
int screen_init(mpdclient_t *c);
int screen_exit(void);
void screen_resize(void);
-void screen_status_message(char *msg);
-void screen_status_printf(char *format, ...);
+void screen_status_message(const char *msg);
+void screen_status_printf(const char *format, ...);
char *screen_error(void);
void screen_paint(mpdclient_t *c);
void screen_update(mpdclient_t *c);
void screen_idle(mpdclient_t *c);
void screen_cmd(mpdclient_t *c, command_t cmd);
-gint screen_get_id(char *name);
+gint screen_get_id(const char *name);
gint get_cur_mode_id();
diff --git a/src/screen_browse.h b/src/screen_browse.h
index 3487b2d38..c58867500 100644
--- a/src/screen_browse.h
+++ b/src/screen_browse.h
@@ -6,7 +6,7 @@ void set_highlight(mpdclient_filelist_t *filelist,
int highlight);
-char *browse_lw_callback(int index, int *highlight, void *filelist);
+const char *browse_lw_callback(int index, int *highlight, void *filelist);
int browse_handle_select(screen_t *screen,
mpdclient_t *c,
diff --git a/src/screen_clock.c b/src/screen_clock.c
index d55328189..0839304a1 100644
--- a/src/screen_clock.c
+++ b/src/screen_clock.c
@@ -146,7 +146,7 @@ clock_close(void)
{
}
-static char *
+static const char *
clock_title(char *str, size_t size)
{
return _("Clock");
diff --git a/src/screen_file.c b/src/screen_file.c
index c8468cc81..35245a194 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -146,7 +146,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
}
/* list_window callback */
-char *
+const char *
browse_lw_callback(int index, int *highlight, void *data)
{
static char buf[BUFSIZE];
@@ -195,7 +195,7 @@ browse_lw_callback(int index, int *highlight, void *data)
/* chdir */
static int
change_directory(screen_t *screen, mpdclient_t *c, filelist_entry_t *entry,
- char *new_path)
+ const char *new_path)
{
mpd_InfoEntity *entity = NULL;
gchar *path = NULL;
@@ -591,7 +591,7 @@ browse_close(void)
{
}
-static char *
+static const char *
browse_title(char *str, size_t size)
{
char *pathcopy;
diff --git a/src/screen_help.c b/src/screen_help.c
index 46fefd9d6..80495a297 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -34,7 +34,7 @@
typedef struct {
signed char highlight;
command_t command;
- char *text;
+ const char *text;
} help_text_row_t;
static help_text_row_t help_text[] =
@@ -146,7 +146,7 @@ static int help_text_rows = -1;
static list_window_t *lw = NULL;
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char buf[512];
@@ -211,7 +211,7 @@ help_exit(void)
}
-static char *
+static const char *
help_title(char *str, size_t size)
{
return _("Help");
diff --git a/src/screen_keydef.c b/src/screen_keydef.c
index a8f32d3da..8571ca279 100644
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
@@ -182,7 +182,7 @@ assign_new_key(WINDOW *w, int cmd_index, int key_index)
check_key_bindings(cmds, NULL, 0);
}
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char buf[BUFSIZE];
@@ -275,7 +275,7 @@ keydef_close(void)
screen_status_printf(_("Note: Did you forget to \'Apply\' your changes?"));
}
-static char *
+static const char *
keydef_title(char *str, size_t size)
{
if( subcmd<0 )
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index ec028a392..4417d1385 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -151,7 +151,7 @@ gpointer get_lyr(void *c)
return &lyr_text;
}
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char buf[512];
@@ -204,7 +204,7 @@ lyrics_exit(void)
}
-static char *
+static const char *
lyrics_title(char *str, size_t size)
{
static GString *msg;
diff --git a/src/screen_play.c b/src/screen_play.c
index f94b5fbfe..1878bd9ce 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -71,7 +71,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
list_window_check_selected(lw, c->playlist.length);
}
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char songname[MAX_SONG_LENGTH];
@@ -356,7 +356,7 @@ play_exit(void)
list_window_free(lw);
}
-static char *
+static const char *
play_title(char *str, size_t size)
{
if( strcmp(options.host, "localhost") == 0 )
diff --git a/src/screen_search.c b/src/screen_search.c
index 234c91a52..816968619 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -47,8 +47,8 @@ extern gint mpdclient_finish_command(mpdclient_t *c);
typedef struct {
int id;
- char *name;
- char *localname;
+ const char *name;
+ const char *localname;
} search_tag_t;
static search_tag_t search_tag[] = {
@@ -94,7 +94,7 @@ search_get_tag_id(char *name)
typedef struct {
int table;
- char *label;
+ const char *label;
} search_type_t;
static search_type_t mode[] = {
@@ -114,11 +114,11 @@ static gboolean advanced_search_mode = FALSE;
/* search info */
-static char *
+static const char *
lw_search_help_callback(int index, int *highlight, void *data)
{
int text_rows;
- static char *text[] = {
+ static const char *text[] = {
"Quick - just enter a string and ncmpc will search according",
" to the current search mode (displayed above).",
"",
@@ -435,7 +435,7 @@ update(screen_t *screen, mpdclient_t *c)
wnoutrefresh(lw->w);
}
-static char *
+static const char *
get_title(char *str, size_t size)
{
if( advanced_search_mode && pattern )
diff --git a/src/screen_utils.c b/src/screen_utils.c
index a5ccd58f4..9b3bfa266 100644
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
@@ -48,7 +48,7 @@ screen_bell(void)
}
int
-screen_getch(WINDOW *w, char *prompt)
+screen_getch(WINDOW *w, const char *prompt)
{
int key = -1;
int prompt_len = strlen(prompt);
@@ -81,8 +81,8 @@ screen_getch(WINDOW *w, char *prompt)
char *
screen_readln(WINDOW *w,
- char *prompt,
- char *value,
+ const char *prompt,
+ const char *value,
GList **history,
GCompletion *gcmp)
{
@@ -97,13 +97,13 @@ screen_readln(WINDOW *w,
}
char *
-screen_getstr(WINDOW *w, char *prompt)
+screen_getstr(WINDOW *w, const char *prompt)
{
return screen_readln(w, prompt, NULL, NULL, NULL);
}
char *
-screen_read_password(WINDOW *w, char *prompt)
+screen_read_password(WINDOW *w, const char *prompt)
{
if(w == NULL)
{
@@ -155,7 +155,7 @@ screen_find(screen_t *screen,
{
int reversed = 0;
int retval = 0;
- char *prompt = FIND_PROMPT;
+ const char *prompt = FIND_PROMPT;
char *value = options.find_show_last_pattern ? (char *) -1 : NULL;
if (findcmd == CMD_LIST_RFIND || findcmd == CMD_LIST_RFIND_NEXT) {
@@ -255,7 +255,7 @@ screen_display_completion_list(screen_t *screen, GList *list)
}
void
-set_xterm_title(char *format, ...)
+set_xterm_title(const char *format, ...)
{
/* the current xterm title exists under the WM_NAME property */
/* and can be retreived with xprop -id $WINDOWID */
diff --git a/src/screen_utils.h b/src/screen_utils.h
index a5adf79f4..0bb52262e 100644
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
@@ -5,14 +5,14 @@
void screen_bell(void);
/* read a characher from the status window */
-int screen_getch(WINDOW *w, char *prompt);
+int screen_getch(WINDOW *w, const char *prompt);
/* read a string from the status window */
-char *screen_getstr(WINDOW *w, char *prompt);
-char *screen_readln(WINDOW *w, char *prompt, char *value,
+char *screen_getstr(WINDOW *w, const char *prompt);
+char *screen_readln(WINDOW *w, const char *prompt, const char *value,
GList **history, GCompletion *gcmp);
-char *screen_readln_masked(WINDOW *w, char *prompt);
-char *screen_read_pasword(WINDOW *w, char *prompt);
+char *screen_readln_masked(WINDOW *w, const char *prompt);
+char *screen_read_pasword(WINDOW *w, const char *prompt);
/* query user for a string and find it in a list window */
int screen_find(screen_t *screen,
list_window_t *lw,
@@ -25,6 +25,6 @@ gint screen_auth(mpdclient_t *c);
void screen_display_completion_list(screen_t *screen, GList *list);
-void set_xterm_title(char *format, ...);
+void set_xterm_title(const char *format, ...);
#endif
diff --git a/src/strfsong.c b/src/strfsong.c
index 27eadb236..22f2e2e6d 100644
--- a/src/strfsong.c
+++ b/src/strfsong.c
@@ -34,8 +34,8 @@
#include "support.h"
#include "strfsong.h"
-static gchar *
-skip(gchar * p)
+static const gchar *
+skip(const gchar * p)
{
gint stack = 0;
@@ -62,9 +62,9 @@ _strfsong(gchar *s,
gsize max,
const gchar *format,
mpd_Song *song,
- gchar **last)
+ const gchar **last)
{
- gchar *p, *end;
+ const gchar *p, *end;
gchar *temp;
gsize n, length = 0;
gboolean found = FALSE;
@@ -73,7 +73,7 @@ _strfsong(gchar *s,
if( song==NULL )
return 0;
- for (p = (gchar *)format; *p != '\0' && length<max;) {
+ for (p = format; *p != '\0' && length<max;) {
/* OR */
if (p[0] == '|') {
++p;
diff --git a/src/support.c b/src/support.c
index 2f3e4fd5d..b7117e5be 100644
--- a/src/support.c
+++ b/src/support.c
@@ -31,12 +31,12 @@
#define BUFSIZE 1024
-extern void screen_status_printf(char *format, ...);
+extern void screen_status_printf(const char *format, ...);
static gboolean noconvert = TRUE;
size_t
-my_strlen(char *str)
+my_strlen(const char *str)
{
if( g_utf8_validate(str,-1,NULL) )
return g_utf8_strlen(str,-1);
@@ -157,7 +157,7 @@ charset_init(gboolean disable)
}
char *
-utf8_to_locale(char *utf8str)
+utf8_to_locale(const char *utf8str)
{
gchar *str;
gsize rb, wb;
@@ -189,7 +189,7 @@ utf8_to_locale(char *utf8str)
}
char *
-locale_to_utf8(char *localestr)
+locale_to_utf8(const char *localestr)
{
gchar *str;
gsize rb, wb;
diff --git a/src/support.h b/src/support.h
index 089a6863a..c9cfed090 100644
--- a/src/support.h
+++ b/src/support.h
@@ -23,11 +23,11 @@ typedef struct {
char *strscroll(char *str, char *separator, int width, scroll_state_t *st);
void charset_init(gboolean disable);
-char *utf8_to_locale(char *str);
-char *locale_to_utf8(char *str);
+char *utf8_to_locale(const char *str);
+char *locale_to_utf8(const char *str);
/* number of characters in str */
-size_t my_strlen(char *str);
+size_t my_strlen(const char *str);
/* number of bytes in str */
size_t my_strsize(char *str);
diff --git a/src/utils.c b/src/utils.c
index 014136480..5f7f5ef1a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -48,7 +48,7 @@ string_list_free(GList *string_list)
}
GList *
-string_list_find(GList *string_list, gchar *str)
+string_list_find(GList *string_list, const gchar *str)
{
GList *list = g_list_first(string_list);
@@ -61,7 +61,7 @@ string_list_find(GList *string_list, gchar *str)
}
GList *
-string_list_remove(GList *string_list, gchar *str)
+string_list_remove(GList *string_list, const gchar *str)
{
GList *list = g_list_first(string_list);
@@ -78,7 +78,7 @@ string_list_remove(GList *string_list, gchar *str)
/* create a list suiteble for GCompletion from path */
GList *
-gcmp_list_from_path(mpdclient_t *c, gchar *path, GList *list, gint types)
+gcmp_list_from_path(mpdclient_t *c, const gchar *path, GList *list, gint types)
{
GList *flist = NULL;
mpdclient_filelist_t *filelist;
diff --git a/src/utils.h b/src/utils.h
index a7f81bf1a..fe913afce 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -4,8 +4,8 @@
/* functions for lists containing strings */
GList *string_list_free(GList *string_list);
-GList *string_list_find(GList *string_list, gchar *str);
-GList *string_list_remove(GList *string_list, gchar *str);
+GList *string_list_find(GList *string_list, const gchar *str);
+GList *string_list_remove(GList *string_list, const gchar *str);
/* create a string list from path - used for completion */
#define GCMP_TYPE_DIR (0x01 << 0)
@@ -15,7 +15,7 @@ GList *string_list_remove(GList *string_list, gchar *str);
#define GCMP_TYPE_RPLAYLIST (GCMP_TYPE_DIR | GCMP_TYPE_PLAYLIST)
GList *gcmp_list_from_path(mpdclient_t *c,
- gchar *path,
+ const gchar *path,
GList *list,
gint types);
diff --git a/src/wreadln.c b/src/wreadln.c
index 2ae03f83f..e49308a3f 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -125,8 +125,8 @@ static inline void drawline(gint cursor,
gchar *
_wreadln(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp,
@@ -477,8 +477,8 @@ static inline void drawline(gint cursor,
gchar *
_wreadln(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp,
@@ -763,8 +763,8 @@ _wreadln(WINDOW *w,
gchar *
wreadln(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp)
@@ -774,8 +774,8 @@ wreadln(WINDOW *w,
gchar *
wreadln_masked(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp)
diff --git a/src/wreadln.h b/src/wreadln.h
index 72ef411c4..35e91bcf2 100644
--- a/src/wreadln.h
+++ b/src/wreadln.h
@@ -26,8 +26,8 @@ extern wrln_gcmp_post_cb_t wrln_post_completion_callback;
/* Note, wreadln calls curs_set() and noecho(), to enable cursor and
* disable echo. wreadln will not restore these settings when exiting! */
gchar *wreadln(WINDOW *w, /* the curses window to use */
- gchar *prompt, /* the prompt string or NULL */
- gchar *initial_value, /* initial value or NULL for a empty line
+ const gchar *prompt, /* the prompt string or NULL */
+ const gchar *initial_value, /* initial value or NULL for a empty line
* (char *) -1 = get value from history */
gint x1, /* the maximum x position or 0 */
GList **history, /* a pointer to a history list or NULL */