aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-02-05 10:17:33 +0000
committerEric Wong <normalperson@yhbt.net>2008-02-05 10:17:33 +0000
commit6fbdc721d972d8c1f823acd5473a3dce8836d5fa (patch)
treee72131541f4e887d5dedd6c75ffce455cbf6b97c
parent22efbd5eca4705426af5cee17a65a3e76c33bec6 (diff)
fix -Wconst warnings
[ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/audioOutput.c4
-rw-r--r--src/audioOutput.h6
-rw-r--r--src/audioOutputs/audioOutput_shout.c17
-rw-r--r--src/charConv.c4
-rw-r--r--src/charConv.h4
-rw-r--r--src/command.c11
-rw-r--r--src/conf.c16
-rw-r--r--src/conf.h14
-rw-r--r--src/decode.c4
-rw-r--r--src/directory.c68
-rw-r--r--src/directory.h4
-rw-r--r--src/inputPlugin.c10
-rw-r--r--src/inputPlugin.h12
-rw-r--r--src/inputPlugins/audiofile_plugin.c2
-rw-r--r--src/inputPlugins/flac_plugin.c18
-rw-r--r--src/inputPlugins/mod_plugin.c2
-rw-r--r--src/inputPlugins/mp3_plugin.c4
-rw-r--r--src/inputPlugins/mpc_plugin.c2
-rw-r--r--src/inputPlugins/oggflac_plugin.c10
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c20
-rw-r--r--src/inputStream_http.c3
-rw-r--r--src/list.c23
-rw-r--r--src/list.h12
-rw-r--r--src/locate.c7
-rw-r--r--src/locate.h4
-rw-r--r--src/ls.c34
-rw-r--r--src/ls.h16
-rw-r--r--src/mpd_types.h5
-rw-r--r--src/path.c15
-rw-r--r--src/path.h10
-rw-r--r--src/song.c4
-rw-r--r--src/song.h4
-rw-r--r--src/tag.c7
-rw-r--r--src/tag.h2
-rw-r--r--src/utf8.c20
-rw-r--r--src/utf8.h10
-rw-r--r--src/volume.c12
37 files changed, 223 insertions, 197 deletions
diff --git a/src/audioOutput.c b/src/audioOutput.c
index 43d073b4..d2fb2d77 100644
--- a/src/audioOutput.c
+++ b/src/audioOutput.c
@@ -67,9 +67,9 @@ void finishAudioOutputPlugins(void)
int initAudioOutput(AudioOutput *ao, ConfigParam * param)
{
void *data = NULL;
- char *name = NULL;
+ const char *name = NULL;
char *format = NULL;
- char *type = NULL;
+ const char *type = NULL;
BlockParam *bp = NULL;
AudioOutputPlugin *plugin = NULL;
diff --git a/src/audioOutput.h b/src/audioOutput.h
index 6c50776c..3953d262 100644
--- a/src/audioOutput.h
+++ b/src/audioOutput.h
@@ -54,8 +54,8 @@ typedef void (*AudioOutputSendMetadataFunc) (AudioOutput * audioOutput,
struct _AudioOutput {
int open;
- char *name;
- char *type;
+ const char *name;
+ const char *type;
AudioOutputFinishDriverFunc finishDriverFunc;
AudioOutputOpenDeviceFunc openDeviceFunc;
@@ -77,7 +77,7 @@ struct _AudioOutput {
};
typedef struct _AudioOutputPlugin {
- char *name;
+ const char *name;
AudioOutputTestDefaultDeviceFunc testDefaultDeviceFunc;
AudioOutputInitDriverFunc initDriverFunc;
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c
index 236e02b7..beacfeef 100644
--- a/src/audioOutputs/audioOutput_shout.c
+++ b/src/audioOutputs/audioOutput_shout.c
@@ -116,7 +116,7 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
char *host;
char *mount;
char *passwd;
- char *user;
+ const char *user;
char *name;
BlockParam *blockParam;
int public;
@@ -388,8 +388,13 @@ static void myShout_closeDevice(AudioOutput * audioOutput)
audioOutput->open = 0;
}
-#define addTag(name, value) { \
- if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
+static void addTag(ShoutData *sd, const char *name, char *value)
+{
+ if (value) {
+ union const_hack u;
+ u.in = name;
+ vorbis_comment_add_tag(&(sd->vc), u.out, value);
+ }
}
static void copyTagToVorbisComment(ShoutData * sd)
@@ -400,13 +405,13 @@ static void copyTagToVorbisComment(ShoutData * sd)
for (i = 0; i < sd->tag->numOfItems; i++) {
switch (sd->tag->items[i].type) {
case TAG_ITEM_ARTIST:
- addTag("ARTIST", sd->tag->items[i].value);
+ addTag(sd, "ARTIST", sd->tag->items[i].value);
break;
case TAG_ITEM_ALBUM:
- addTag("ALBUM", sd->tag->items[i].value);
+ addTag(sd, "ALBUM", sd->tag->items[i].value);
break;
case TAG_ITEM_TITLE:
- addTag("TITLE", sd->tag->items[i].value);
+ addTag(sd, "TITLE", sd->tag->items[i].value);
break;
}
}
diff --git a/src/charConv.c b/src/charConv.c
index 306ee999..895a695c 100644
--- a/src/charConv.c
+++ b/src/charConv.c
@@ -42,7 +42,7 @@ static mpd_sint8 char_conv_latin1ToUtf8;
static void closeCharSetConversion(void);
-int setCharSetConversion(char *to, char *from)
+int setCharSetConversion(const char *to, const char *from)
{
if (char_conv_to && char_conv_from) {
if (char_conv_latin1ToUtf8 &&
@@ -93,7 +93,7 @@ int setCharSetConversion(char *to, char *from)
return -1;
}
-char *char_conv_str(char *dest, char *string)
+char *char_conv_str(char *dest, const char *string)
{
if (!char_conv_to)
return NULL;
diff --git a/src/charConv.h b/src/charConv.h
index d50e8452..a416b5c8 100644
--- a/src/charConv.h
+++ b/src/charConv.h
@@ -21,8 +21,8 @@
#include "../config.h"
-int setCharSetConversion(char *to, char *from);
+int setCharSetConversion(const char *to, const char *from);
-char *char_conv_str(char *dest, char *string);
+char *char_conv_str(char *dest, const char *string);
#endif
diff --git a/src/command.c b/src/command.c
index eddb49af..78eb9a59 100644
--- a/src/command.c
+++ b/src/command.c
@@ -128,7 +128,7 @@ typedef int (*CommandListHandlerFunction)
/* if min: -1 don't check args *
* if max: -1 no max args */
struct _CommandEntry {
- char *cmd;
+ const char *cmd;
int min;
int max;
int reqPermission;
@@ -136,7 +136,6 @@ struct _CommandEntry {
CommandListHandlerFunction listHandler;
};
-
/* this should really be "need a non-negative integer": */
static const char need_positive[] = "need a positive integer"; /* no-op */
@@ -146,7 +145,7 @@ static const char need_integer[] = "need an integer";
static const char check_boolean[] = "\"%s\" is not 0 or 1";
static const char check_non_negative[] = "\"%s\" is not an integer >= 0";
-static char *current_command;
+static const char *current_command;
static int command_listNum;
static CommandEntry *getCommandEntryFromString(char *string, int *permission);
@@ -215,7 +214,7 @@ static int mpd_fprintf__ check_int(int fd, int *dst,
return 0;
}
-static void addCommand(char *name,
+static void addCommand(const char *name,
int reqPermission,
int minargs,
int maxargs,
@@ -291,7 +290,7 @@ static int handlePause(int fd, int *permission, int argc, char *argv[])
static int commandStatus(int fd, int *permission, int argc, char *argv[])
{
- char *state = NULL;
+ const char *state = NULL;
int updateJobId;
int song;
@@ -450,7 +449,7 @@ static int handleListPlaylistInfo(int fd, int *permission,
static int handleLsInfo(int fd, int *permission, int argc, char *argv[])
{
- char *path = "";
+ const char *path = "";
if (argc == 2)
path = argv[1];
diff --git a/src/conf.c b/src/conf.c
index 6b3973a1..10d0f9d3 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -121,7 +121,7 @@ static void freeConfigEntry(ConfigEntry * entry)
free(entry);
}
-static void registerConfigParam(char *name, int repeatable, int block)
+static void registerConfigParam(const char *name, int repeatable, int block)
{
ConfigEntry *entry;
@@ -253,7 +253,7 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
return ret;
}
-void readConf(char *file)
+void readConf(const char *file)
{
FILE *fp;
char string[MAX_STRING_SIZE + 1];
@@ -321,7 +321,7 @@ void readConf(char *file)
fclose(fp);
}
-ConfigParam *getNextConfigParam(char *name, ConfigParam * last)
+ConfigParam *getNextConfigParam(const char *name, ConfigParam * last)
{
void *voidPtr;
ConfigEntry *entry;
@@ -352,7 +352,7 @@ ConfigParam *getNextConfigParam(char *name, ConfigParam * last)
return param;
}
-char *getConfigParamValue(char *name)
+char *getConfigParamValue(const char *name)
{
ConfigParam *param = getConfigParam(name);
@@ -362,7 +362,7 @@ char *getConfigParamValue(char *name)
return param->value;
}
-BlockParam *getBlockParam(ConfigParam * param, char *name)
+BlockParam *getBlockParam(ConfigParam * param, const char *name)
{
BlockParam *ret = NULL;
int i;
@@ -381,7 +381,7 @@ BlockParam *getBlockParam(ConfigParam * param, char *name)
return ret;
}
-ConfigParam *parseConfigFilePath(char *name, int force)
+ConfigParam *parseConfigFilePath(const char *name, int force)
{
ConfigParam *param = getConfigParam(name);
char *path;
@@ -402,7 +402,7 @@ ConfigParam *parseConfigFilePath(char *name, int force)
return param;
}
-int getBoolConfigParam(char *name, int force)
+int getBoolConfigParam(const char *name, int force)
{
int ret;
ConfigParam *param = getConfigParam(name);
@@ -418,7 +418,7 @@ int getBoolConfigParam(char *name, int force)
return ret;
}
-int getBoolBlockParam(ConfigParam *param, char *name, int force)
+int getBoolBlockParam(ConfigParam *param, const char *name, int force)
{
int ret;
BlockParam *bp = getBlockParam(param, name);
diff --git a/src/conf.h b/src/conf.h
index 01337d34..79b6514c 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -83,22 +83,22 @@ typedef struct _ConfigParam {
void initConf(void);
void finishConf(void);
-void readConf(char *file);
+void readConf(const char *file);
/* don't free the returned value
set _last_ to NULL to get first entry */
-ConfigParam *getNextConfigParam(char *name, ConfigParam * last);
+ConfigParam *getNextConfigParam(const char *name, ConfigParam * last);
#define getConfigParam(name) getNextConfigParam(name, NULL)
-char *getConfigParamValue(char *name);
+char *getConfigParamValue(const char *name);
-BlockParam *getBlockParam(ConfigParam * param, char *name);
+BlockParam *getBlockParam(ConfigParam * param, const char *name);
-ConfigParam *parseConfigFilePath(char *name, int force);
+ConfigParam *parseConfigFilePath(const char *name, int force);
-int getBoolConfigParam(char *name, int force);
+int getBoolConfigParam(const char *name, int force);
-int getBoolBlockParam(ConfigParam *param, char *name, int force);
+int getBoolBlockParam(ConfigParam *param, const char *name, int force);
#endif
diff --git a/src/decode.c b/src/decode.c
index 0ebdb928..316cd34b 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -330,7 +330,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
/* if that fails, try suffix matching the URL: */
if (plugin == NULL) {
- char *s = getSuffix(dc->utf8url);
+ const char *s = getSuffix(dc->utf8url);
next = 0;
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
if (!plugin->streamDecodeFunc)
@@ -356,7 +356,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
}
} else {
unsigned int next = 0;
- char *s = getSuffix(dc->utf8url);
+ const char *s = getSuffix(dc->utf8url);
cb->acceptMetadata = 0;
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
diff --git a/src/directory.c b/src/directory.c
index 53b86401..3bb18bf5 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -66,7 +66,8 @@ static volatile mpd_uint16 directory_updateJobId;
static DirectoryList *newDirectoryList(void);
-static int addToDirectory(Directory * directory, char *shortname, char *name);
+static int addToDirectory(Directory * directory,
+ const char *shortname, const char *name);
static void freeDirectoryList(DirectoryList * list);
@@ -78,19 +79,22 @@ static int updateDirectory(Directory * directory);
static void deleteEmptyDirectoriesInDirectory(Directory * directory);
-static void removeSongFromDirectory(Directory * directory, char *shortname);
+static void removeSongFromDirectory(Directory * directory,
+ const char *shortname);
-static int addSubDirectoryToDirectory(Directory * directory, char *shortname,
- char *name, struct stat *st);
+static int addSubDirectoryToDirectory(Directory * directory,
+ const char *shortname,
+ const char *name, struct stat *st);
-static Directory *getDirectoryDetails(char *name, char **shortname);
+static Directory *getDirectoryDetails(const char *name,
+ const char **shortname);
-static Directory *getDirectory(char *name);
+static Directory *getDirectory(const char *name);
-static Song *getSongDetails(char *file, char **shortnameRet,
+static Song *getSongDetails(const char *file, const char **shortnameRet,
Directory ** directoryRet);
-static int updatePath(char *utf8path);
+static int updatePath(const char *utf8path);
static void sortDirectory(Directory * directory);
@@ -251,7 +255,7 @@ static DirectoryList *newDirectoryList(void)
return makeList((ListFreeDataFunc *) freeDirectory, 1);
}
-static Directory *newDirectory(char *dirname, Directory * parent)
+static Directory *newDirectory(const char *dirname, Directory * parent)
{
Directory *directory;
@@ -286,7 +290,7 @@ static void freeDirectoryList(DirectoryList * directoryList)
freeList(directoryList);
}
-static void removeSongFromDirectory(Directory * directory, char *shortname)
+static void removeSongFromDirectory(Directory * directory, const char *shortname)
{
void *song;
@@ -321,7 +325,8 @@ static void deleteEmptyDirectoriesInDirectory(Directory * directory)
0 -> no error, but nothing updated
1 -> no error, and stuff updated
*/
-static int updateInDirectory(Directory * directory, char *shortname, char *name)
+static int updateInDirectory(Directory * directory,
+ const char *shortname, const char *name)
{
void *song;
void *subDir;
@@ -415,7 +420,8 @@ static int removeDeletedFromDirectory(char *path_max_tmp, Directory * directory)
return ret;
}
-static Directory *addDirectoryPathToDB(char *utf8path, char **shortname)
+static Directory *addDirectoryPathToDB(const char *utf8path,
+ const char **shortname)
{
char path_max_tmp[MPD_PATH_MAX];
char *parent;
@@ -456,7 +462,7 @@ static Directory *addDirectoryPathToDB(char *utf8path, char **shortname)
return (Directory *) directory;
}
-static Directory *addParentPathToDB(char *utf8path, char **shortname)
+static Directory *addParentPathToDB(const char *utf8path, const char **shortname)
{
char *parent;
char path_max_tmp[MPD_PATH_MAX];
@@ -484,12 +490,12 @@ static Directory *addParentPathToDB(char *utf8path, char **shortname)
0 -> no error, but nothing updated
1 -> no error, and stuff updated
*/
-static int updatePath(char *utf8path)
+static int updatePath(const char *utf8path)
{
Directory *directory;
Directory *parentDirectory;
Song *song;
- char *shortname;
+ const char *shortname;
char *path = sanitizePathDup(utf8path);
time_t mtime;
int ret = 0;
@@ -575,7 +581,7 @@ static int updatePath(char *utf8path)
return ret;
}
-static const char *opendir_path(char *path_max_tmp, char *dirname)
+static const char *opendir_path(char *path_max_tmp, const char *dirname)
{
if (*dirname != '\0')
return rmp2amp_r(path_max_tmp,
@@ -591,7 +597,7 @@ static const char *opendir_path(char *path_max_tmp, char *dirname)
static int updateDirectory(Directory * directory)
{
DIR *dir;
- char *dirname = getDirectoryPath(directory);
+ const char *dirname = getDirectoryPath(directory);
struct dirent *ent;
char path_max_tmp[MPD_PATH_MAX];
int ret = 0;
@@ -639,7 +645,7 @@ static int updateDirectory(Directory * directory)
static int exploreDirectory(Directory * directory)
{
DIR *dir;
- char *dirname = getDirectoryPath(directory);
+ const char *dirname = getDirectoryPath(directory);
struct dirent *ent;
char path_max_tmp[MPD_PATH_MAX];
int ret = 0;
@@ -705,8 +711,9 @@ static int inodeFoundInParent(Directory * parent, ino_t inode, dev_t device)
return 0;
}
-static int addSubDirectoryToDirectory(Directory * directory, char *shortname,
- char *name, struct stat *st)
+static int addSubDirectoryToDirectory(Directory * directory,
+ const char *shortname,
+ const char *name, struct stat *st)
{
Directory *subDirectory;
@@ -726,7 +733,8 @@ static int addSubDirectoryToDirectory(Directory * directory, char *shortname,
return 1;
}
-static int addToDirectory(Directory * directory, char *shortname, char *name)
+static int addToDirectory(Directory * directory,
+ const char *shortname, const char *name)
{
struct stat st;
@@ -758,7 +766,7 @@ void closeMp3Directory(void)
freeDirectory(mp3rootDirectory);
}
-static Directory *findSubDirectory(Directory * directory, char *name)
+static Directory *findSubDirectory(Directory * directory, const char *name)
{
void *subDirectory;
char *duplicated = xstrdup(name);
@@ -779,7 +787,7 @@ static Directory *findSubDirectory(Directory * directory, char *name)
return NULL;
}
-int isRootDirectory(char *name)
+int isRootDirectory(const char *name)
{
if (name == NULL || name[0] == '\0' || strcmp(name, "/") == 0) {
return 1;
@@ -787,8 +795,8 @@ int isRootDirectory(char *name)
return 0;
}
-static Directory *getSubDirectory(Directory * directory, char *name,
- char **shortname)
+static Directory *getSubDirectory(Directory * directory, const char *name,
+ const char **shortname)
{
Directory *subDirectory;
int len;
@@ -811,16 +819,16 @@ static Directory *getSubDirectory(Directory * directory, char *name,
return getSubDirectory(subDirectory, &(name[len]), shortname);
}
-static Directory *getDirectoryDetails(char *name, char **shortname)
+static Directory *getDirectoryDetails(const char *name, const char **shortname)
{
*shortname = NULL;
return getSubDirectory(mp3rootDirectory, name, shortname);
}
-static Directory *getDirectory(char *name)
+static Directory *getDirectory(const char *name)
{
- char *shortname;
+ const char *shortname;
return getSubDirectory(mp3rootDirectory, name, &shortname);
}
@@ -840,7 +848,7 @@ static int printDirectoryList(int fd, DirectoryList * directoryList)
return 0;
}
-int printDirectoryInfo(int fd, char *name)
+int printDirectoryInfo(int fd, const char *name)
{
Directory *directory;
@@ -1258,7 +1266,7 @@ void initMp3Directory(void)
stats.dbPlayTime = sumSongTimesIn(STDERR_FILENO, NULL);
}
-static Song *getSongDetails(char *file, char **shortnameRet,
+static Song *getSongDetails(const char *file, const char **shortnameRet,
Directory ** directoryRet)
{
void *song = NULL;
diff --git a/src/directory.h b/src/directory.h
index b1482988..5782dd2c 100644
--- a/src/directory.h
+++ b/src/directory.h
@@ -51,9 +51,9 @@ void initMp3Directory(void);
void closeMp3Directory(void);
-int isRootDirectory(char *name);
+int isRootDirectory(const char *name);
-int printDirectoryInfo(int fd, char *dirname);
+int printDirectoryInfo(int fd, const char *dirname);
int checkDirectoryDB(void);
diff --git a/src/inputPlugin.c b/src/inputPlugin.c
index e9c6d4a7..18d86926 100644
--- a/src/inputPlugin.c
+++ b/src/inputPlugin.c
@@ -44,7 +44,7 @@ void unloadInputPlugin(InputPlugin * inputPlugin)
deleteFromList(inputPlugin_list, inputPlugin->name);
}
-static int stringFoundInStringArray(char **array, char *suffix)
+static int stringFoundInStringArray(const char *const*array, const char *suffix)
{
while (array && *array) {
if (strcasecmp(*array, suffix) == 0)
@@ -55,7 +55,7 @@ static int stringFoundInStringArray(char **array, char *suffix)
return 0;
}
-InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next)
+InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
{
static ListNode *pos;
ListNode *node;
@@ -84,7 +84,7 @@ InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next)
return NULL;
}
-InputPlugin *getInputPluginFromMimeType(char *mimeType, unsigned int next)
+InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
{
static ListNode *pos;
ListNode *node;
@@ -107,7 +107,7 @@ InputPlugin *getInputPluginFromMimeType(char *mimeType, unsigned int next)
return NULL;
}
-InputPlugin *getInputPluginFromName(char *name)
+InputPlugin *getInputPluginFromName(const char *name)
{
void *plugin = NULL;
@@ -120,7 +120,7 @@ void printAllInputPluginSuffixes(FILE * fp)
{
ListNode *node = inputPlugin_list->firstNode;
InputPlugin *plugin;
- char **suffixes;
+ const char *const*suffixes;
while (node) {
plugin = (InputPlugin *) node->data;
diff --git a/src/inputPlugin.h b/src/inputPlugin.h
index ecb1b980..c643cbdc 100644
--- a/src/inputPlugin.h
+++ b/src/inputPlugin.h
@@ -60,7 +60,7 @@ typedef int (*InputPlugin_fileDecodeFunc) (OutputBuffer *, DecoderControl *,
typedef MpdTag *(*InputPlugin_tagDupFunc) (char *file);
typedef struct _InputPlugin {
- char *name;
+ const char *name;
InputPlugin_initFunc initFunc;
InputPlugin_finishFunc finishFunc;
InputPlugin_tryDecodeFunc tryDecodeFunc;
@@ -72,8 +72,8 @@ typedef struct _InputPlugin {
unsigned char streamTypes;
/* last element in these arrays must always be a NULL: */
- char **suffixes;
- char **mimeTypes;
+ const char *const*suffixes;
+ const char *const*mimeTypes;
} InputPlugin;
/* individual functions to load/unload plugins */
@@ -82,11 +82,11 @@ void unloadInputPlugin(InputPlugin * inputPlugin);
/* interface for using plugins */
-InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next);
+InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next);
-InputPlugin *getInputPluginFromMimeType(char *mimeType, unsigned int next);
+InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next);
-InputPlugin *getInputPluginFromName(char *name);
+InputPlugin *getInputPluginFromName(const char *name);
void printAllInputPluginSuffixes(FILE * fp);
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index b5555f87..1213d31e 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -149,7 +149,7 @@ static MpdTag *audiofileTagDup(char *file)
return ret;
}
-static char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL };
+static const char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL };
InputPlugin audiofilePlugin = {
"audiofile",
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index 01436592..f929ef61 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -473,11 +473,11 @@ static unsigned int oggflac_try_decode(InputStream * inStream)
return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0;
}
-static char *oggflac_suffixes[] = { "ogg", "oga", NULL };
-static char *oggflac_mime_types[] = { "audio/x-flac+ogg",
- "application/ogg",
- "application/x-ogg",
- NULL };
+static const char *oggflac_suffixes[] = { "ogg", "oga", NULL };
+static const char *oggflac_mime_types[] = { "audio/x-flac+ogg",
+ "application/ogg",
+ "application/x-ogg",
+ NULL };
static int flac_plugin_init(void)
{
@@ -501,10 +501,10 @@ static int flac_plugin_init(void)
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
-static char *flacSuffixes[] = { "flac", NULL };
-static char *flac_mime_types[] = { "audio/x-flac",
- "application/x-flac",
- NULL };
+static const char *flacSuffixes[] = { "flac", NULL };
+static const char *flac_mime_types[] = { "audio/x-flac",
+ "application/x-flac",
+ NULL };
InputPlugin flacPlugin = {
"flac",
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 092d9bd5..22c364d7 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -249,7 +249,7 @@ static MpdTag *modTagDup(char *file)
return ret;
}
-static char *modSuffixes[] = { "amf",
+static const char *modSuffixes[] = { "amf",
"dsm",
"far",
"gdm",
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 3e507190..b008a1dd 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -1111,8 +1111,8 @@ static MpdTag *mp3_tagDup(char *file)
return ret;
}
-static char *mp3_suffixes[] = { "mp3", "mp2", NULL };
-static char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
+static const char *mp3_suffixes[] = { "mp3", "mp2", NULL };
+static const char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
InputPlugin mp3Plugin = {
"mp3",
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index db217f88..49142aae 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -317,7 +317,7 @@ static MpdTag *mpcTagDup(char *file)
return ret;
}
-static char *mpcSuffixes[] = { "mpc", NULL };
+static const char *mpcSuffixes[] = { "mpc", NULL };
InputPlugin mpcPlugin = {
"mpc",
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index e980a04b..6b8a682d 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -390,11 +390,11 @@ fail:
return ret;
}
-static char *oggflac_Suffixes[] = { "ogg", NULL };
-static char *oggflac_mime_types[] = { "audio/x-flac+ogg",
- "application/ogg",
- "application/x-ogg",
- NULL };
+static const char *oggflac_Suffixes[] = { "ogg", NULL };
+static const char *oggflac_mime_types[] = { "audio/x-flac+ogg",
+ "application/ogg",
+ "application/x-ogg",
+ NULL };
InputPlugin oggflacPlugin = {
"oggflac",
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index 2e934252..a2648ce6 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -80,7 +80,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
{
- OggCallbackData *data = (OggCallbackData *) vdata;
+ const OggCallbackData *data = (const OggCallbackData *) vdata;
if(data->dc->stop)
return -1;
return seekInputStream(data->inStream, offset, whence);
@@ -94,12 +94,12 @@ static int ogg_close_cb(void *vdata)
static long ogg_tell_cb(void *vdata)
{
- OggCallbackData *data = (OggCallbackData *) vdata;
+ const OggCallbackData *data = (const OggCallbackData *) vdata;
return (long)(data->inStream->offset);
}
-static char *ogg_parseComment(char *comment, char *needle)
+static const char *ogg_parseComment(const char *comment, const char *needle)
{
int len = strlen(needle);
@@ -112,7 +112,7 @@ static char *ogg_parseComment(char *comment, char *needle)
static void ogg_getReplayGainInfo(char **comments, ReplayGainInfo ** infoPtr)
{
- char *temp;
+ const char *temp;
int found = 0;
if (*infoPtr)
@@ -236,7 +236,7 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc,
long test;
ReplayGainInfo *replayGainInfo = NULL;
char **comments;
- char *errorStr;
+ const char *errorStr;
data.inStream = inStream;
data.dc = dc;
@@ -383,11 +383,11 @@ static unsigned int oggvorbis_try_decode(InputStream * inStream)
return (ogg_stream_type_detect(inStream) == VORBIS) ? 1 : 0;
}
-static char *oggvorbis_Suffixes[] = { "ogg", NULL };
-static char *oggvorbis_MimeTypes[] = { "application/ogg",
- "audio/x-vorbis+ogg",
- "application/x-ogg",
- NULL };
+static const char *oggvorbis_Suffixes[] = { "ogg", NULL };
+static const char *oggvorbis_MimeTypes[] = { "application/ogg",
+ "audio/x-vorbis+ogg",
+ "application/x-ogg",
+ NULL };
InputPlugin oggvorbisPlugin = {
"oggvorbis",
diff --git a/src/inputStream_http.c b/src/inputStream_http.c
index db8b3062..c5dccf9d 100644
--- a/src/inputStream_http.c
+++ b/src/inputStream_http.c
@@ -187,7 +187,8 @@ static char *base64Dup(char *s)
return ret;
}
-static char *authString(char *header, char *user, char *password)
+static char *authString(const char *header,
+ const char *user, const char *password)
{
char *ret = NULL;
int templen;
diff --git a/src/list.c b/src/list.c
index 6a54d8a5..65ad4ec9 100644
--- a/src/list.c
+++ b/src/list.c
@@ -63,7 +63,7 @@ List *makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys)
}
ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
- char *key, void *data)
+ const char *key, void *data)
{
ListNode *node;
@@ -126,7 +126,7 @@ ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
return node;
}
-ListNode *insertInList(List * list, char *key, void *data)
+ListNode *insertInList(List * list, const char *key, void *data)
{
ListNode *node;
@@ -201,7 +201,7 @@ int insertInListWithoutKey(List * list, void *data)
/* if _key_ is not found, *_node_ is assigned to the node before which
the info would be found */
-int findNodeInList(List * list, char *key, ListNode ** node, int *pos)
+int findNodeInList(List * list, const char *key, ListNode ** node, int *pos)
{
long high;
long low;
@@ -268,7 +268,7 @@ int findNodeInList(List * list, char *key, ListNode ** node, int *pos)
return 0;
}
-int findInList(List * list, char *key, void **data)
+int findInList(List * list, const char *key, void **data)
{
ListNode *node;
int pos;
@@ -282,7 +282,7 @@ int findInList(List * list, char *key, void **data)
return 0;
}
-int deleteFromList(List * list, char *key)
+int deleteFromList(List * list, const char *key)
{
ListNode *tmpNode;
@@ -302,6 +302,11 @@ int deleteFromList(List * list, char *key)
return 1;
}
+static void free_const_string(const char *p)
+{
+ free((char *)p);
+}
+
void deleteNodeFromList(List * list, ListNode * node)
{
assert(list != NULL);
@@ -322,7 +327,7 @@ void deleteNodeFromList(List * list, ListNode * node)
}
if (list->strdupKeys)
- free(node->key);
+ free_const_string(node->key);
free(node);
list->numberOfNodes--;
@@ -349,7 +354,7 @@ void freeList(void *list)
while (tmpNode != NULL) {
tmpNode2 = tmpNode->nextNode;
if (((List *) list)->strdupKeys)
- free(tmpNode->key);
+ free_const_string(tmpNode->key);
if (((List *) list)->freeDataFunc) {
((List *) list)->freeDataFunc(tmpNode->data);
}
@@ -362,7 +367,7 @@ void freeList(void *list)
static void swapNodes(ListNode * nodeA, ListNode * nodeB)
{
- char *key;
+ const char *key;
void *data;
assert(nodeA != NULL);
@@ -408,7 +413,7 @@ static void quickSort(ListNode ** nodesArray, long start, long end)
ListNode *node;
long pivot;
ListNode *pivotNode;
- char *pivotKey;
+ const char *pivotKey;
List *startList = makeList(free, 0);
List *endList = makeList(free, 0);
diff --git a/src/list.h b/src/list.h
index 62c40aef..6aca5f50 100644
--- a/src/list.h
+++ b/src/list.h
@@ -30,7 +30,7 @@ typedef void ListFreeDataFunc(void *);
typedef struct _ListNode {
/* used to identify node (ie. when using findInList) */
- char *key;
+ const char *key;
/* data store in node */
void *data;
/* next node in list */
@@ -69,10 +69,10 @@ List *makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys);
* _data_ -> data to be inserted in list
* returns 1 if successful, 0 otherwise
*/
-ListNode *insertInList(List * list, char *key, void *data);
+ListNode *insertInList(List * list, const char *key, void *data);
ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode,
- int pos, char *key, void *data);
+ int pos, const char *key, void *data);
int insertInListWithoutKey(List * list, void *data);
@@ -81,7 +81,7 @@ int insertInListWithoutKey(List * list, void *data);
* _key_ -> key used to identify node to delete
* returns 1 if node is found and deleted, 0 otherwise
*/
-int deleteFromList(List * list, char *key);
+int deleteFromList(List * list, const char *key);
void deleteNodeFromList(List * list, ListNode * node);
@@ -93,11 +93,11 @@ void deleteNodeFromList(List * list, ListNode * node);
* _data_ can be NULL
* returns 1 if successful, 0 otherwise
*/
-int findInList(List * list, char *key, void **data);
+int findInList(List * list, const char *key, void **data);
/* if _key_ is not found, *_node_ is assigned to the node before which
the info would be found */
-int findNodeInList(List * list, char *key, ListNode ** node, int *pos);
+int findNodeInList(List * list, const char *key, ListNode ** node, int *pos);
/* frees memory malloc'd for list and its nodes
* _list_ -> List to be free'd
diff --git a/src/locate.c b/src/locate.c
index 3a4e35b8..f459d276 100644
--- a/src/locate.c
+++ b/src/locate.c
@@ -24,7 +24,7 @@
#define LOCATE_TAG_FILE_KEY_OLD "filename"
#define LOCATE_TAG_ANY_KEY "any"
-int getLocateTagItemType(char *str)
+int getLocateTagItemType(const char *str)
{
int i;
@@ -48,7 +48,8 @@ int getLocateTagItemType(char *str)
return -1;
}
-static int initLocateTagItem(LocateTagItem * item, char *typeStr, char *needle)
+static int initLocateTagItem(LocateTagItem * item,
+ const char *typeStr, const char *needle)
{
item->tagType = getLocateTagItemType(typeStr);
@@ -60,7 +61,7 @@ static int initLocateTagItem(LocateTagItem * item, char *typeStr, char *needle)
return 0;
}
-LocateTagItem *newLocateTagItem(char *typeStr, char *needle)
+LocateTagItem *newLocateTagItem(const char *typeStr, const char *needle)
{
LocateTagItem *ret = xmalloc(sizeof(LocateTagItem));
diff --git a/src/locate.h b/src/locate.h
index c165a310..28b2782b 100644
--- a/src/locate.h
+++ b/src/locate.h
@@ -28,10 +28,10 @@ typedef struct _LocateTagItem {
char *needle;
} LocateTagItem;
-int getLocateTagItemType(char *str);
+int getLocateTagItemType(const char *str);
/* returns NULL if not a known type */
-LocateTagItem *newLocateTagItem(char *typeString, char *needle);
+LocateTagItem *newLocateTagItem(const char *typeString, const char *needle);
/* return number of items or -1 on error */
int newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
diff --git a/src/ls.c b/src/ls.c
index d06ae350..a858057c 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -25,14 +25,14 @@
#include "utils.h"
#include "os_compat.h"
-static char *remoteUrlPrefixes[] = {
+static const char *remoteUrlPrefixes[] = {
"http://",
NULL
};
int printRemoteUrlHandlers(int fd)
{
- char **prefixes = remoteUrlPrefixes;
+ const char **prefixes = remoteUrlPrefixes;
while (*prefixes) {
fdprintf(fd, "handler: %s\n", *prefixes);
@@ -85,7 +85,7 @@ int isValidRemoteUtf8Url(char *utf8url)
int isRemoteUrl(char *url)
{
int count = 0;
- char **urlPrefixes = remoteUrlPrefixes;
+ const char **urlPrefixes = remoteUrlPrefixes;
while (*urlPrefixes) {
count++;
@@ -98,7 +98,7 @@ int isRemoteUrl(char *url)
return 0;
}
-int lsPlaylists(int fd, char *utf8path)
+int lsPlaylists(int fd, const char *utf8path)
{
DIR *dir;
struct stat st;
@@ -181,11 +181,11 @@ int lsPlaylists(int fd, char *utf8path)
return 0;
}
-int myStat(char *utf8file, struct stat *st)
+int myStat(const char *utf8file, struct stat *st)
{
char path_max_tmp[MPD_PATH_MAX];
- char *file = utf8_to_fs_charset(path_max_tmp, utf8file);
- char *actualFile = file;
+ const char *file = utf8_to_fs_charset(path_max_tmp, utf8file);
+ const char *actualFile = file;
if (actualFile[0] != '/')
actualFile = rmp2amp_r(path_max_tmp, file);
@@ -193,7 +193,7 @@ int myStat(char *utf8file, struct stat *st)
return stat(actualFile, st);
}
-int isFile(char *utf8file, time_t * mtime)
+int isFile(const char *utf8file, time_t * mtime)
{
struct stat st;
@@ -215,9 +215,9 @@ int isFile(char *utf8file, time_t * mtime)
}
/* suffixes should be ascii only characters */
-char *getSuffix(char *utf8file)
+const char *getSuffix(const char *utf8file)
{
- char *ret = NULL;
+ const char *ret = NULL;
while (*utf8file) {
if (*utf8file == '.')
@@ -228,15 +228,15 @@ char *getSuffix(char *utf8file)
return ret;
}
-static int hasSuffix(char *utf8file, char *suffix)
+static int hasSuffix(const char *utf8file, const char *suffix)
{
- char *s = getSuffix(utf8file);
+ const char *s = getSuffix(utf8file);
if (s && 0 == strcmp(s, suffix))
return 1;
return 0;
}
-int isPlaylist(char *utf8file)
+int isPlaylist(const char *utf8file)
{
if (isFile(utf8file, NULL)) {
return hasSuffix(utf8file, PLAYLIST_FILE_SUFFIX);
@@ -244,7 +244,7 @@ int isPlaylist(char *utf8file)
return 0;
}
-int isDir(char *utf8name)
+int isDir(const char *utf8name)
{
struct stat st;
@@ -257,11 +257,11 @@ int isDir(char *utf8name)
return 0;
}
-InputPlugin *hasMusicSuffix(char *utf8file, unsigned int next)
+InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next)
{
InputPlugin *ret = NULL;
- char *s = getSuffix(utf8file);
+ const char *s = getSuffix(utf8file);
if (s) {
ret = getInputPluginFromSuffix(s, next);
} else {
@@ -272,7 +272,7 @@ InputPlugin *hasMusicSuffix(char *utf8file, unsigned int next)
return ret;
}
-InputPlugin *isMusic(char *utf8file, time_t * mtime, unsigned int next)
+InputPlugin *isMusic(const char *utf8file, time_t * mtime, unsigned int next)
{
if (isFile(utf8file, mtime)) {
InputPlugin *plugin = hasMusicSuffix(utf8file, next);
diff --git a/src/ls.h b/src/ls.h
index e14966ca..4eee3ca2 100644
--- a/src/ls.h
+++ b/src/ls.h
@@ -24,26 +24,26 @@
#include "inputPlugin.h"
#include "os_compat.h"
-int lsPlaylists(int fd, char *utf8path);
+int lsPlaylists(int fd, const char *utf8path);
-char *getSuffix(char *utf8file);
+const char *getSuffix(const char *utf8file);
int isValidRemoteUtf8Url(char *utf8url);
int isRemoteUrl(char *url);
-int myStat(char *utf8file, struct stat *st);
+int myStat(const char *utf8file, struct stat *st);
-int isDir(char *utf8name);
+int isDir(const char *utf8name);
-int isPlaylist(char *utf8file);
+int isPlaylist(const char *utf8file);
-InputPlugin *hasMusicSuffix(char *utf8file, unsigned int next);
+InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next);
-InputPlugin *isMusic(char *utf8file, time_t * mtime, unsigned int next);
+InputPlugin *isMusic(const char *utf8file, time_t * mtime, unsigned int next);
int printRemoteUrlHandlers(int fd);
-int isFile(char *utf8file, time_t * mtime);
+int isFile(const char *utf8file, time_t * mtime);
#endif
diff --git a/src/mpd_types.h b/src/mpd_types.h
index 765d0d00..35ff3604 100644
--- a/src/mpd_types.h
+++ b/src/mpd_types.h
@@ -41,4 +41,9 @@ typedef unsigned long mpd_uint32;
typedef signed long mpd_sint32;
#endif
+union const_hack {
+ const char *in;
+ char *out;
+};
+
#endif
diff --git a/src/path.c b/src/path.c
index 25836303..6aaff84c 100644
--- a/src/path.c
+++ b/src/path.c
@@ -38,24 +38,25 @@ static size_t music_dir_len;
static size_t playlist_dir_len;
static char *fsCharset;
-static char *path_conv_charset(char *dest, char *to, char *from, char *str)
+static char *path_conv_charset(char *dest, const char *to,
+ const char *from, const char *str)
{
return setCharSetConversion(to, from) ? NULL : char_conv_str(dest, str);
}
-char *fs_charset_to_utf8(char *dst, char *str)
+char *fs_charset_to_utf8(char *dst, const char *str)
{
char *ret = path_conv_charset(dst, "UTF-8", fsCharset, str);
return (ret && !validUtf8String(ret)) ? NULL : ret;
}
-char *utf8_to_fs_charset(char *dst, char *str)
+char *utf8_to_fs_charset(char *dst, const char *str)
{
char *ret = path_conv_charset(dst, fsCharset, "UTF-8", str);
return ret ? ret : strcpy(dst, str);
}
-void setFsCharset(char *charset)
+void setFsCharset(const char *charset)
{
int error = 0;
@@ -86,7 +87,7 @@ void setFsCharset(char *charset)
}
}
-char *getFsCharset(void)
+const char *getFsCharset(void)
{
return fsCharset;
}
@@ -243,7 +244,7 @@ char *parent_path(char *path_max_tmp, const char *path)
return path_max_tmp;
}
-char *sanitizePathDup(char *path)
+char *sanitizePathDup(const char *path)
{
int len = strlen(path) + 1;
char *ret = xmalloc(len);
@@ -285,7 +286,7 @@ char *sanitizePathDup(char *path)
void utf8_to_fs_playlist_path(char *path_max_tmp, const char *utf8path)
{
- utf8_to_fs_charset(path_max_tmp, (char *)utf8path);
+ utf8_to_fs_charset(path_max_tmp, utf8path);
rpp2app_r(path_max_tmp, path_max_tmp);
strncat(path_max_tmp, "." PLAYLIST_FILE_SUFFIX, MPD_PATH_MAX - 1);
}
diff --git a/src/path.h b/src/path.h
index 560cf607..d2935452 100644
--- a/src/path.h
+++ b/src/path.h
@@ -38,13 +38,13 @@ void initPaths(void);
void finishPaths(void);
-char *fs_charset_to_utf8(char *dst, char *str);
+char *fs_charset_to_utf8(char *dst, const char *str);
-char *utf8_to_fs_charset(char *dst, char *str);
+char *utf8_to_fs_charset(char *dst, const char *str);
-void setFsCharset(char *charset);
+void setFsCharset(const char *charset);
-char *getFsCharset(void);
+const char *getFsCharset(void);
/*
* pfx_dir - sets dst="$pfx/$path" and returns a pointer to path inside * dst
@@ -75,7 +75,7 @@ char *rpp2app_r(char *dst, const char *rel_path);
char *parent_path(char *path_max_tmp, const char *path);
/* strips extra "///" and leading "/" and trailing "/" */
-char *sanitizePathDup(char *path);
+char *sanitizePathDup(const char *path);
/* this is actually like strlcpy (OpenBSD), but we don't actually want to
* blindly use it everywhere, only for paths that are OK to truncate (for
diff --git a/src/song.c b/src/song.c
index d8d4251d..83781efb 100644
--- a/src/song.c
+++ b/src/song.c
@@ -44,7 +44,7 @@ Song *newNullSong(void)
return song;
}
-Song *newSong(char *url, int type, Directory * parentDir)
+Song *newSong(const char *url, int type, Directory * parentDir)
{
Song *song = NULL;
@@ -101,7 +101,7 @@ SongList *newSongList(void)
return makeList((ListFreeDataFunc *) freeSong, 0);
}
-Song *addSongToList(SongList * list, char *url, char *utf8path,
+Song *addSongToList(SongList * list, const char *url, const char *utf8path,
int songType, Directory * parentDirectory)
{
Song *song = NULL;
diff --git a/src/song.h b/src/song.h
index ccf87e34..6f06101b 100644
--- a/src/song.h
+++ b/src/song.h
@@ -45,7 +45,7 @@ typedef List SongList;
Song *newNullSong(void);
-Song *newSong(char *url, int songType, struct _Directory *parentDir);
+Song *newSong(const char *url, int songType, struct _Directory *parentDir);
void freeSong(Song *);
@@ -55,7 +55,7 @@ SongList *newSongList(void);
void freeSongList(SongList * list);
-Song *addSongToList(SongList * list, char *url, char *utf8path,
+Song *addSongToList(SongList * list, const char *url, const char *utf8path,
int songType, struct _Directory *parentDir);
int printSongInfo(int fd, Song * song);
diff --git a/src/tag.c b/src/tag.c
index bacc2cb1..cfda3add 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -44,7 +44,7 @@
# endif
#endif
-char *mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = {
+const char *mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = {
"Artist",
"Album",
"Title",
@@ -169,7 +169,8 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
return utf8;
}
-static MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag)
+static MpdTag *getID3Info(
+ struct id3_tag *tag, const char *id, int type, MpdTag * mpdTag)
{
struct id3_frame const *frame;
id3_ucs4_t const *ucs4;
@@ -480,7 +481,7 @@ MpdTag *apeDup(char *file)
unsigned char reserved[8];
} footer;
- char *apeItems[7] = {
+ const char *apeItems[7] = {
"title",
"artist",
"album",
diff --git a/src/tag.h b/src/tag.h
index a554ee1c..363ad98a 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -41,7 +41,7 @@
#define TAG_NUM_OF_ITEM_TYPES 11
-extern char *mpdTagItemKeys[];
+extern const char *mpdTagItemKeys[];
typedef struct _MpdTagItem {
mpd_sint8 type;
diff --git a/src/utf8.c b/src/utf8.c
index d7b1503c..f0d6b3b1 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -20,10 +20,10 @@
#include "utils.h"
#include "os_compat.h"
-char *latin1_to_utf8(char *dest, char *in_latin1)
+char *latin1_to_utf8(char *dest, const char *in_latin1)
{
unsigned char *cp = (unsigned char *)dest;
- unsigned char *latin1 = (unsigned char *)in_latin1;
+ const unsigned char *latin1 = (const unsigned char *)in_latin1;
while (*latin1) {
if (*latin1 < 128)
@@ -45,7 +45,7 @@ char *latin1_to_utf8(char *dest, char *in_latin1)
return dest;
}
-char *latin1StrToUtf8Dup(char *latin1)
+char *latin1StrToUtf8Dup(const char *latin1)
{
/* utf8 should have at most two char's per latin1 char */
char *ret = xmalloc(strlen(latin1) * 2 + 1);
@@ -55,10 +55,10 @@ char *latin1StrToUtf8Dup(char *latin1)
return ((ret) ? xrealloc(ret, strlen((char *)ret) + 1) : NULL);
}
-static char utf8_to_latin1_char(char *inUtf8)
+static char utf8_to_latin1_char(const char *inUtf8)
{
unsigned char c = 0;
- unsigned char *utf8 = (unsigned char *)inUtf8;
+ const unsigned char *utf8 = (const unsigned char *)inUtf8;
if (utf8[0] < 128)
return utf8[0];
@@ -69,9 +69,9 @@ static char utf8_to_latin1_char(char *inUtf8)
return (char)(c + utf8[1]);
}
-static int validateUtf8Char(char *inUtf8Char)
+static int validateUtf8Char(const char *inUtf8Char)
{
- unsigned char *utf8Char = (unsigned char *)inUtf8Char;
+ const unsigned char *utf8Char = (const unsigned char *)inUtf8Char;
if (utf8Char[0] < 0x80)
return 1;
@@ -95,7 +95,7 @@ static int validateUtf8Char(char *inUtf8Char)
return 0;
}
-int validUtf8String(char *string)
+int validUtf8String(const char *string)
{
int ret;
@@ -109,7 +109,7 @@ int validUtf8String(char *string)
return 1;
}
-char *utf8StrToLatin1Dup(char *utf8)
+char *utf8StrToLatin1Dup(const char *utf8)
{
/* utf8 should have at most two char's per latin1 char */
char *ret = xmalloc(strlen(utf8) + 1);
@@ -133,7 +133,7 @@ char *utf8StrToLatin1Dup(char *utf8)
return xrealloc(ret, len + 1);
}
-char *utf8_to_latin1(char *dest, char *utf8)
+char *utf8_to_latin1(char *dest, const char *utf8)
{
char *cp = dest;
int count;
diff --git a/src/utf8.h b/src/utf8.h
index 05e1a4a3..4a498306 100644
--- a/src/utf8.h
+++ b/src/utf8.h
@@ -19,15 +19,15 @@
#ifndef UTF_8_H
#define UTF_8_H
-char *latin1StrToUtf8Dup(char *latin1);
+char *latin1StrToUtf8Dup(const char *latin1);
-char *utf8StrToLatin1Dup(char *utf8);
+char *utf8StrToLatin1Dup(const char *utf8);
-int validUtf8String(char *string);
+int validUtf8String(const char *string);
-char *utf8_to_latin1(char *dest, char *utf8);
+char *utf8_to_latin1(char *dest, const char *utf8);
-char *latin1_to_utf8(char *dest, char *utf8);
+char *latin1_to_utf8(char *dest, const char *utf8);
#endif
diff --git a/src/volume.c b/src/volume.c
index 73683813..846a76ea 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -57,7 +57,7 @@
#endif
static int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT;
-static char *volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
+static const char *volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
static int volume_softwareSet = 100;
@@ -82,7 +82,7 @@ static void closeOssMixer(void)
volume_ossFd = -1;
}
-static int prepOssMixer(char *device)
+static int prepOssMixer(const char *device)
{
ConfigParam *param;
@@ -94,7 +94,7 @@ static int prepOssMixer(char *device)
param = getConfigParam(CONF_MIXER_CONTROL);
if (param) {
- char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
+ const char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
char *duplicated;
int i, j;
int devmask = 0;
@@ -211,11 +211,11 @@ static void closeAlsaMixer(void)
volume_alsaMixerHandle = NULL;
}
-static int prepAlsaMixer(char *card)
+static int prepAlsaMixer(const char *card)
{
int err;
snd_mixer_elem_t *elem;
- char *controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
+ const char *controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
ConfigParam *param;
err = snd_mixer_open(&volume_alsaMixerHandle, 0);
@@ -370,7 +370,7 @@ static int changeAlsaVolumeLevel(int fd, int change, int rel)
}
#endif
-static int prepMixer(char *device)
+static int prepMixer(const char *device)
{
switch (volume_mixerType) {
#ifdef HAVE_ALSA