summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1f0ff95)
raw | patch | inline | side by side (parent: 1f0ff95)
author | Max Kellermann <max@duempel.org> | |
Mon, 15 Sep 2008 10:27:28 +0000 (12:27 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 15 Sep 2008 10:27:28 +0000 (12:27 +0200) |
Convert pointers to const whenever it is possible. Fixes all those
-Wconst warnings.
-Wconst warnings.
33 files changed:
diff --git a/src/colors.c b/src/colors.c
index c504e0085922d524877d13614f302be9f5527de0..e60399ea7a20e22f3def6137b8d582650e28b062 100644 (file)
--- a/src/colors.c
+++ b/src/colors.c
typedef struct {
int id;
- char *name;
+ const char *name;
short fg;
attr_t attrs;
} color_entry_t;
}
static color_entry_t *
-colors_lookup_by_name(char *name)
+colors_lookup_by_name(const char *name)
{
int i;
}
short
-colors_str2color(char *str)
+colors_str2color(const char *str)
{
if( !strcasecmp(str,"black") )
return COLOR_BLACK;
* 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);
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 a66d693ccd75b3b37e63323c84e7ddf445bea44b..4211630065e6f9dad899690bc26af6f77b3898ad 100644 (file)
--- a/src/colors.h
+++ b/src/colors.h
#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 a565c25ec49779242597983ce426673339640f4c..4f4a8e938b0a6f0f23951f2abb63315d33729763 100644 (file)
--- a/src/command.c
+++ b/src/command.c
return cmds;
}
-char *
+const char *
key2str(int key)
{
static char buf[32];
return 1;
}
-char *
+const char *
get_key_names(command_t command, int all)
{
int i;
return NULL;
}
-char *
+const char *
get_key_description(command_t command)
{
int i;
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 568f05098b89adcbae4de61d806dfa25b17d7a9a..75886d5eff0cd40c77662cf0aa0fd2d9ec4de31f 100644 (file)
--- a/src/command.h
+++ b/src/command.h
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);
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 dda13f56bf40fc5b0b32f160b7712bcc1cdafa0b..0e477db880fec5ca46089c05c0f0edcf7582a34a 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
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;
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 c9641e9e42572e212e635d0d77b73c9d1ed545b1..a52ce23ca1e4c177ea901288ce744f2b2a8f97ed 100644 (file)
--- 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",
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) {
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 437951b31069de465928d22e0f0308c71fffe231..fe1991edc28f1f63d03e991b1e5ba0be8001fb8b 100644 (file)
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
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 {
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 96ea7c110fc896408689f1ebe9fac942ad78008e..a6bc911c384a4b8bf2c456085318c72a031bc47d 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
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);
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))) {
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 9ef67214b347e1fa6095d68c2e92f3b74824c4b3..114f71effcf6eabaa167c21b54e9906b9ff51664 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
#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;
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) */
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 1d93b69fc524364dfa9398fef5518201398efa6a..022802c8027d31b2d252d2c7075b1cc1f21ac713 100644 (file)
--- a/src/main.c
+++ b/src/main.c
static gboolean connected = FALSE;
static GTimer *timer = NULL;
-static gchar *
-error_msg(gchar *msg)
+static const gchar *
+error_msg(const gchar *msg)
{
gchar *p;
}
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);
#ifndef NDEBUG
void
-D(char *format, ...)
+D(const char *format, ...)
{
if( options.debug )
{
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 9f060c46d4834535e26eb979a34044b43dbea0ee..941c0911444cbf10c007c161dd3cc463bf790b52 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
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 &&
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 &&
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 44c266afc51472b85628264e4796575de2dff529..5f231c3833386ae10a661210fa1dbe626d8776c1 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
#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);
/*** 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 033145f916239f69f73ff7b4e4569d5b60dde990..9caf8601a2aa45795f4b46c6770e8f0b082095c1 100644 (file)
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
#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 1ecc791034eb490cf31173b53850912bba83077b..668fe7522c402b242d474903fbed0747e511bbda 100644 (file)
--- a/src/options.c
+++ b/src/options.c
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;
}
static void
-option_error(int error, char *option, char *arg)
+option_error(int error, const char *option, const char *arg)
{
switch(error)
{
}
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)
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 */
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 f4ced308c567dc80cf6d713729982c00e786ee9f..af3417a3ed104e8079fc732e656b21c84302a489 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
typedef struct
{
gint id;
- gchar *name;
+ const gchar *name;
screen_get_mode_functions_fn_t get_mode_functions;
} screen_mode_info_t;
static int seek_target_time = 0;
gint
-screen_get_id(char *name)
+screen_get_id(const char *name)
{
gint i=0;
}
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;
}
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;
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 )
}
void
-screen_status_message(char *msg)
+screen_status_message(const char *msg)
{
WINDOW *w = screen->status_window.w;
}
void
-screen_status_printf(char *format, ...)
+screen_status_printf(const char *format, ...)
{
char *msg;
va_list ap;
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 f2c54d3da956b19032dc2a5524c183a1a4ba5d36..4f3057df8172b7ba4292c71d9a1a7f3f3f52bd17 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
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 {
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 3487b2d38422b0869a3512017e81206822cd4741..c58867500028bf9af71b9a49ae82d1edcb5935b6 100644 (file)
--- a/src/screen_browse.h
+++ b/src/screen_browse.h
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 d55328189417c5c6dcb470f3da32a5439fdf1122..0839304a152dfd0c935ac87bd640b1b748a56aa2 100644 (file)
--- a/src/screen_clock.c
+++ b/src/screen_clock.c
{
}
-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 c8468cc810fd665001154e20990446f81c61e041..35245a194f6050fea2e59ef53688dcbf809126d1 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
}
/* list_window callback */
-char *
+const char *
browse_lw_callback(int index, int *highlight, void *data)
{
static char buf[BUFSIZE];
/* 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;
{
}
-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 46fefd9d6e435c15729a80d52f6313bd9d3a87f3..80495a297eb84f5b3afacc285179096e1fa9255a 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
typedef struct {
signed char highlight;
command_t command;
- char *text;
+ const char *text;
} help_text_row_t;
static help_text_row_t help_text[] =
static list_window_t *lw = NULL;
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char buf[512];
}
-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 a8f32d3dab17317b1f2fbe28298bfc39ce7fb54f..8571ca2790f01ac260171daf239a9f7f176ec50d 100644 (file)
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
check_key_bindings(cmds, NULL, 0);
}
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char buf[BUFSIZE];
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 ec028a3924c558540828682c2c88b1d4f1634439..4417d138596a9dad125e3b56c9fb8c6c89b80ae7 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
return &lyr_text;
}
-static char *
+static const char *
list_callback(int index, int *highlight, void *data)
{
static char buf[512];
}
-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 f94b5fbfe63ad0e75ef822e60eb9075a22b53378..1878bd9ce8ae9bd85854a67773657834539d7e39 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
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];
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 234c91a52416106f1987bc8f648ed00cadcbb087..816968619bc3c5f248da7641eae8f6f4390e8601 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
typedef struct {
int id;
- char *name;
- char *localname;
+ const char *name;
+ const char *localname;
} search_tag_t;
static search_tag_t search_tag[] = {
typedef struct {
int table;
- char *label;
+ const char *label;
} search_type_t;
static search_type_t mode[] = {
/* 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).",
"",
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 a5ccd58f44c062748d34c977fefcabbda898567b..9b3bfa26628d7f311f679917c74d108cf821c604 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
}
int
-screen_getch(WINDOW *w, char *prompt)
+screen_getch(WINDOW *w, const char *prompt)
{
int key = -1;
int prompt_len = strlen(prompt);
char *
screen_readln(WINDOW *w,
- char *prompt,
- char *value,
+ const char *prompt,
+ const char *value,
GList **history,
GCompletion *gcmp)
{
}
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)
{
{
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) {
}
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 a5adf79f4dc8b682124de551b844c9331fdcc479..0bb52262e81764bd573118f7221e0d7b0e2132d3 100644 (file)
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
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,
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 27eadb236686055d594c113b05eb6af21f26ffc0..22f2e2e6d10d5ca1bc7229e020eab55cfa6d843e 100644 (file)
--- a/src/strfsong.c
+++ b/src/strfsong.c
#include "support.h"
#include "strfsong.h"
-static gchar *
-skip(gchar * p)
+static const gchar *
+skip(const gchar * p)
{
gint stack = 0;
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;
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 2f3e4fd5d919adbf12c556dab386ef798df1670f..b7117e5bee2827525918c21ccb92ce2bd07065dc 100644 (file)
--- a/src/support.c
+++ b/src/support.c
#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);
}
char *
-utf8_to_locale(char *utf8str)
+utf8_to_locale(const char *utf8str)
{
gchar *str;
gsize rb, wb;
}
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 089a6863a541cda36c20d286a1d848020c2368e4..c9cfed090ae28e1fa3267f78ddfc6c04f6580696 100644 (file)
--- a/src/support.h
+++ b/src/support.h
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 01413648015d5e4675bde9d5316d20e000a12ccd..5f7f5ef1a139aa756409fc068a4f226d25202a97 100644 (file)
--- a/src/utils.c
+++ b/src/utils.c
}
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);
}
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);
/* 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 a7f81bf1a3f5bdc799319724ec345b418cc19e81..fe913afcef7253307f9bd79246dee9ee5a18441e 100644 (file)
--- a/src/utils.h
+++ b/src/utils.h
/* 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)
#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 2ae03f83f53beddc1f05fa2caa3b1d5922f20e1c..e49308a3f78cd4cd1810d7cacf2ac3928683b3df 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
gchar *
_wreadln(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp,
gchar *
_wreadln(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp,
gchar *
wreadln(WINDOW *w,
- gchar *prompt,
- gchar *initial_value,
+ const gchar *prompt,
+ const gchar *initial_value,
gint x1,
GList **history,
GCompletion *gcmp)
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 72ef411c4402a034ab3c000c3c1e22c734ad7bb8..35e91bcf2a90006acc0735ee87c75ad50e948c98 100644 (file)
--- a/src/wreadln.h
+++ b/src/wreadln.h
/* 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 */