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
This commit is contained in:
parent
22efbd5eca
commit
6fbdc721d9
@ -67,9 +67,9 @@ void finishAudioOutputPlugins(void)
|
|||||||
int initAudioOutput(AudioOutput *ao, ConfigParam * param)
|
int initAudioOutput(AudioOutput *ao, ConfigParam * param)
|
||||||
{
|
{
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
char *name = NULL;
|
const char *name = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
char *type = NULL;
|
const char *type = NULL;
|
||||||
BlockParam *bp = NULL;
|
BlockParam *bp = NULL;
|
||||||
AudioOutputPlugin *plugin = NULL;
|
AudioOutputPlugin *plugin = NULL;
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ typedef void (*AudioOutputSendMetadataFunc) (AudioOutput * audioOutput,
|
|||||||
|
|
||||||
struct _AudioOutput {
|
struct _AudioOutput {
|
||||||
int open;
|
int open;
|
||||||
char *name;
|
const char *name;
|
||||||
char *type;
|
const char *type;
|
||||||
|
|
||||||
AudioOutputFinishDriverFunc finishDriverFunc;
|
AudioOutputFinishDriverFunc finishDriverFunc;
|
||||||
AudioOutputOpenDeviceFunc openDeviceFunc;
|
AudioOutputOpenDeviceFunc openDeviceFunc;
|
||||||
@ -77,7 +77,7 @@ struct _AudioOutput {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _AudioOutputPlugin {
|
typedef struct _AudioOutputPlugin {
|
||||||
char *name;
|
const char *name;
|
||||||
|
|
||||||
AudioOutputTestDefaultDeviceFunc testDefaultDeviceFunc;
|
AudioOutputTestDefaultDeviceFunc testDefaultDeviceFunc;
|
||||||
AudioOutputInitDriverFunc initDriverFunc;
|
AudioOutputInitDriverFunc initDriverFunc;
|
||||||
|
@ -116,7 +116,7 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
|
|||||||
char *host;
|
char *host;
|
||||||
char *mount;
|
char *mount;
|
||||||
char *passwd;
|
char *passwd;
|
||||||
char *user;
|
const char *user;
|
||||||
char *name;
|
char *name;
|
||||||
BlockParam *blockParam;
|
BlockParam *blockParam;
|
||||||
int public;
|
int public;
|
||||||
@ -388,8 +388,13 @@ static void myShout_closeDevice(AudioOutput * audioOutput)
|
|||||||
audioOutput->open = 0;
|
audioOutput->open = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define addTag(name, value) { \
|
static void addTag(ShoutData *sd, const char *name, char *value)
|
||||||
if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
|
{
|
||||||
|
if (value) {
|
||||||
|
union const_hack u;
|
||||||
|
u.in = name;
|
||||||
|
vorbis_comment_add_tag(&(sd->vc), u.out, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyTagToVorbisComment(ShoutData * sd)
|
static void copyTagToVorbisComment(ShoutData * sd)
|
||||||
@ -400,13 +405,13 @@ static void copyTagToVorbisComment(ShoutData * sd)
|
|||||||
for (i = 0; i < sd->tag->numOfItems; i++) {
|
for (i = 0; i < sd->tag->numOfItems; i++) {
|
||||||
switch (sd->tag->items[i].type) {
|
switch (sd->tag->items[i].type) {
|
||||||
case TAG_ITEM_ARTIST:
|
case TAG_ITEM_ARTIST:
|
||||||
addTag("ARTIST", sd->tag->items[i].value);
|
addTag(sd, "ARTIST", sd->tag->items[i].value);
|
||||||
break;
|
break;
|
||||||
case TAG_ITEM_ALBUM:
|
case TAG_ITEM_ALBUM:
|
||||||
addTag("ALBUM", sd->tag->items[i].value);
|
addTag(sd, "ALBUM", sd->tag->items[i].value);
|
||||||
break;
|
break;
|
||||||
case TAG_ITEM_TITLE:
|
case TAG_ITEM_TITLE:
|
||||||
addTag("TITLE", sd->tag->items[i].value);
|
addTag(sd, "TITLE", sd->tag->items[i].value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ static mpd_sint8 char_conv_latin1ToUtf8;
|
|||||||
|
|
||||||
static void closeCharSetConversion(void);
|
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_to && char_conv_from) {
|
||||||
if (char_conv_latin1ToUtf8 &&
|
if (char_conv_latin1ToUtf8 &&
|
||||||
@ -93,7 +93,7 @@ int setCharSetConversion(char *to, char *from)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *char_conv_str(char *dest, char *string)
|
char *char_conv_str(char *dest, const char *string)
|
||||||
{
|
{
|
||||||
if (!char_conv_to)
|
if (!char_conv_to)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
#include "../config.h"
|
#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
|
#endif
|
||||||
|
@ -128,7 +128,7 @@ typedef int (*CommandListHandlerFunction)
|
|||||||
/* if min: -1 don't check args *
|
/* if min: -1 don't check args *
|
||||||
* if max: -1 no max args */
|
* if max: -1 no max args */
|
||||||
struct _CommandEntry {
|
struct _CommandEntry {
|
||||||
char *cmd;
|
const char *cmd;
|
||||||
int min;
|
int min;
|
||||||
int max;
|
int max;
|
||||||
int reqPermission;
|
int reqPermission;
|
||||||
@ -136,7 +136,6 @@ struct _CommandEntry {
|
|||||||
CommandListHandlerFunction listHandler;
|
CommandListHandlerFunction listHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* this should really be "need a non-negative integer": */
|
/* this should really be "need a non-negative integer": */
|
||||||
static const char need_positive[] = "need a positive integer"; /* no-op */
|
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_boolean[] = "\"%s\" is not 0 or 1";
|
||||||
static const char check_non_negative[] = "\"%s\" is not an integer >= 0";
|
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 int command_listNum;
|
||||||
|
|
||||||
static CommandEntry *getCommandEntryFromString(char *string, int *permission);
|
static CommandEntry *getCommandEntryFromString(char *string, int *permission);
|
||||||
@ -215,7 +214,7 @@ static int mpd_fprintf__ check_int(int fd, int *dst,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addCommand(char *name,
|
static void addCommand(const char *name,
|
||||||
int reqPermission,
|
int reqPermission,
|
||||||
int minargs,
|
int minargs,
|
||||||
int maxargs,
|
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[])
|
static int commandStatus(int fd, int *permission, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *state = NULL;
|
const char *state = NULL;
|
||||||
int updateJobId;
|
int updateJobId;
|
||||||
int song;
|
int song;
|
||||||
|
|
||||||
@ -450,7 +449,7 @@ static int handleListPlaylistInfo(int fd, int *permission,
|
|||||||
|
|
||||||
static int handleLsInfo(int fd, int *permission, int argc, char *argv[])
|
static int handleLsInfo(int fd, int *permission, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *path = "";
|
const char *path = "";
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
|
16
src/conf.c
16
src/conf.c
@ -121,7 +121,7 @@ static void freeConfigEntry(ConfigEntry * entry)
|
|||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void registerConfigParam(char *name, int repeatable, int block)
|
static void registerConfigParam(const char *name, int repeatable, int block)
|
||||||
{
|
{
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void readConf(char *file)
|
void readConf(const char *file)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char string[MAX_STRING_SIZE + 1];
|
char string[MAX_STRING_SIZE + 1];
|
||||||
@ -321,7 +321,7 @@ void readConf(char *file)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParam *getNextConfigParam(char *name, ConfigParam * last)
|
ConfigParam *getNextConfigParam(const char *name, ConfigParam * last)
|
||||||
{
|
{
|
||||||
void *voidPtr;
|
void *voidPtr;
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
@ -352,7 +352,7 @@ ConfigParam *getNextConfigParam(char *name, ConfigParam * last)
|
|||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getConfigParamValue(char *name)
|
char *getConfigParamValue(const char *name)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(name);
|
ConfigParam *param = getConfigParam(name);
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ char *getConfigParamValue(char *name)
|
|||||||
return param->value;
|
return param->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockParam *getBlockParam(ConfigParam * param, char *name)
|
BlockParam *getBlockParam(ConfigParam * param, const char *name)
|
||||||
{
|
{
|
||||||
BlockParam *ret = NULL;
|
BlockParam *ret = NULL;
|
||||||
int i;
|
int i;
|
||||||
@ -381,7 +381,7 @@ BlockParam *getBlockParam(ConfigParam * param, char *name)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigParam *parseConfigFilePath(char *name, int force)
|
ConfigParam *parseConfigFilePath(const char *name, int force)
|
||||||
{
|
{
|
||||||
ConfigParam *param = getConfigParam(name);
|
ConfigParam *param = getConfigParam(name);
|
||||||
char *path;
|
char *path;
|
||||||
@ -402,7 +402,7 @@ ConfigParam *parseConfigFilePath(char *name, int force)
|
|||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBoolConfigParam(char *name, int force)
|
int getBoolConfigParam(const char *name, int force)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ConfigParam *param = getConfigParam(name);
|
ConfigParam *param = getConfigParam(name);
|
||||||
@ -418,7 +418,7 @@ int getBoolConfigParam(char *name, int force)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBoolBlockParam(ConfigParam *param, char *name, int force)
|
int getBoolBlockParam(ConfigParam *param, const char *name, int force)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
BlockParam *bp = getBlockParam(param, name);
|
BlockParam *bp = getBlockParam(param, name);
|
||||||
|
14
src/conf.h
14
src/conf.h
@ -83,22 +83,22 @@ typedef struct _ConfigParam {
|
|||||||
void initConf(void);
|
void initConf(void);
|
||||||
void finishConf(void);
|
void finishConf(void);
|
||||||
|
|
||||||
void readConf(char *file);
|
void readConf(const char *file);
|
||||||
|
|
||||||
/* don't free the returned value
|
/* don't free the returned value
|
||||||
set _last_ to NULL to get first entry */
|
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)
|
#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
|
#endif
|
||||||
|
@ -330,7 +330,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
|
|||||||
|
|
||||||
/* if that fails, try suffix matching the URL: */
|
/* if that fails, try suffix matching the URL: */
|
||||||
if (plugin == NULL) {
|
if (plugin == NULL) {
|
||||||
char *s = getSuffix(dc->utf8url);
|
const char *s = getSuffix(dc->utf8url);
|
||||||
next = 0;
|
next = 0;
|
||||||
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
|
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
|
||||||
if (!plugin->streamDecodeFunc)
|
if (!plugin->streamDecodeFunc)
|
||||||
@ -356,7 +356,7 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned int next = 0;
|
unsigned int next = 0;
|
||||||
char *s = getSuffix(dc->utf8url);
|
const char *s = getSuffix(dc->utf8url);
|
||||||
cb->acceptMetadata = 0;
|
cb->acceptMetadata = 0;
|
||||||
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
|
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
|
||||||
if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
|
if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
|
||||||
|
@ -66,7 +66,8 @@ static volatile mpd_uint16 directory_updateJobId;
|
|||||||
|
|
||||||
static DirectoryList *newDirectoryList(void);
|
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);
|
static void freeDirectoryList(DirectoryList * list);
|
||||||
|
|
||||||
@ -78,19 +79,22 @@ static int updateDirectory(Directory * directory);
|
|||||||
|
|
||||||
static void deleteEmptyDirectoriesInDirectory(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,
|
static int addSubDirectoryToDirectory(Directory * directory,
|
||||||
char *name, struct stat *st);
|
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);
|
Directory ** directoryRet);
|
||||||
|
|
||||||
static int updatePath(char *utf8path);
|
static int updatePath(const char *utf8path);
|
||||||
|
|
||||||
static void sortDirectory(Directory * directory);
|
static void sortDirectory(Directory * directory);
|
||||||
|
|
||||||
@ -251,7 +255,7 @@ static DirectoryList *newDirectoryList(void)
|
|||||||
return makeList((ListFreeDataFunc *) freeDirectory, 1);
|
return makeList((ListFreeDataFunc *) freeDirectory, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Directory *newDirectory(char *dirname, Directory * parent)
|
static Directory *newDirectory(const char *dirname, Directory * parent)
|
||||||
{
|
{
|
||||||
Directory *directory;
|
Directory *directory;
|
||||||
|
|
||||||
@ -286,7 +290,7 @@ static void freeDirectoryList(DirectoryList * directoryList)
|
|||||||
freeList(directoryList);
|
freeList(directoryList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeSongFromDirectory(Directory * directory, char *shortname)
|
static void removeSongFromDirectory(Directory * directory, const char *shortname)
|
||||||
{
|
{
|
||||||
void *song;
|
void *song;
|
||||||
|
|
||||||
@ -321,7 +325,8 @@ static void deleteEmptyDirectoriesInDirectory(Directory * directory)
|
|||||||
0 -> no error, but nothing updated
|
0 -> no error, but nothing updated
|
||||||
1 -> no error, and stuff 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 *song;
|
||||||
void *subDir;
|
void *subDir;
|
||||||
@ -415,7 +420,8 @@ static int removeDeletedFromDirectory(char *path_max_tmp, Directory * directory)
|
|||||||
return ret;
|
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 path_max_tmp[MPD_PATH_MAX];
|
||||||
char *parent;
|
char *parent;
|
||||||
@ -456,7 +462,7 @@ static Directory *addDirectoryPathToDB(char *utf8path, char **shortname)
|
|||||||
return (Directory *) directory;
|
return (Directory *) directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Directory *addParentPathToDB(char *utf8path, char **shortname)
|
static Directory *addParentPathToDB(const char *utf8path, const char **shortname)
|
||||||
{
|
{
|
||||||
char *parent;
|
char *parent;
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
@ -484,12 +490,12 @@ static Directory *addParentPathToDB(char *utf8path, char **shortname)
|
|||||||
0 -> no error, but nothing updated
|
0 -> no error, but nothing updated
|
||||||
1 -> no error, and stuff updated
|
1 -> no error, and stuff updated
|
||||||
*/
|
*/
|
||||||
static int updatePath(char *utf8path)
|
static int updatePath(const char *utf8path)
|
||||||
{
|
{
|
||||||
Directory *directory;
|
Directory *directory;
|
||||||
Directory *parentDirectory;
|
Directory *parentDirectory;
|
||||||
Song *song;
|
Song *song;
|
||||||
char *shortname;
|
const char *shortname;
|
||||||
char *path = sanitizePathDup(utf8path);
|
char *path = sanitizePathDup(utf8path);
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -575,7 +581,7 @@ static int updatePath(char *utf8path)
|
|||||||
return ret;
|
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')
|
if (*dirname != '\0')
|
||||||
return rmp2amp_r(path_max_tmp,
|
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)
|
static int updateDirectory(Directory * directory)
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
char *dirname = getDirectoryPath(directory);
|
const char *dirname = getDirectoryPath(directory);
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -639,7 +645,7 @@ static int updateDirectory(Directory * directory)
|
|||||||
static int exploreDirectory(Directory * directory)
|
static int exploreDirectory(Directory * directory)
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
char *dirname = getDirectoryPath(directory);
|
const char *dirname = getDirectoryPath(directory);
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -705,8 +711,9 @@ static int inodeFoundInParent(Directory * parent, ino_t inode, dev_t device)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int addSubDirectoryToDirectory(Directory * directory, char *shortname,
|
static int addSubDirectoryToDirectory(Directory * directory,
|
||||||
char *name, struct stat *st)
|
const char *shortname,
|
||||||
|
const char *name, struct stat *st)
|
||||||
{
|
{
|
||||||
Directory *subDirectory;
|
Directory *subDirectory;
|
||||||
|
|
||||||
@ -726,7 +733,8 @@ static int addSubDirectoryToDirectory(Directory * directory, char *shortname,
|
|||||||
return 1;
|
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;
|
struct stat st;
|
||||||
|
|
||||||
@ -758,7 +766,7 @@ void closeMp3Directory(void)
|
|||||||
freeDirectory(mp3rootDirectory);
|
freeDirectory(mp3rootDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Directory *findSubDirectory(Directory * directory, char *name)
|
static Directory *findSubDirectory(Directory * directory, const char *name)
|
||||||
{
|
{
|
||||||
void *subDirectory;
|
void *subDirectory;
|
||||||
char *duplicated = xstrdup(name);
|
char *duplicated = xstrdup(name);
|
||||||
@ -779,7 +787,7 @@ static Directory *findSubDirectory(Directory * directory, char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isRootDirectory(char *name)
|
int isRootDirectory(const char *name)
|
||||||
{
|
{
|
||||||
if (name == NULL || name[0] == '\0' || strcmp(name, "/") == 0) {
|
if (name == NULL || name[0] == '\0' || strcmp(name, "/") == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -787,8 +795,8 @@ int isRootDirectory(char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Directory *getSubDirectory(Directory * directory, char *name,
|
static Directory *getSubDirectory(Directory * directory, const char *name,
|
||||||
char **shortname)
|
const char **shortname)
|
||||||
{
|
{
|
||||||
Directory *subDirectory;
|
Directory *subDirectory;
|
||||||
int len;
|
int len;
|
||||||
@ -811,16 +819,16 @@ static Directory *getSubDirectory(Directory * directory, char *name,
|
|||||||
return getSubDirectory(subDirectory, &(name[len]), shortname);
|
return getSubDirectory(subDirectory, &(name[len]), shortname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Directory *getDirectoryDetails(char *name, char **shortname)
|
static Directory *getDirectoryDetails(const char *name, const char **shortname)
|
||||||
{
|
{
|
||||||
*shortname = NULL;
|
*shortname = NULL;
|
||||||
|
|
||||||
return getSubDirectory(mp3rootDirectory, name, shortname);
|
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);
|
return getSubDirectory(mp3rootDirectory, name, &shortname);
|
||||||
}
|
}
|
||||||
@ -840,7 +848,7 @@ static int printDirectoryList(int fd, DirectoryList * directoryList)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int printDirectoryInfo(int fd, char *name)
|
int printDirectoryInfo(int fd, const char *name)
|
||||||
{
|
{
|
||||||
Directory *directory;
|
Directory *directory;
|
||||||
|
|
||||||
@ -1258,7 +1266,7 @@ void initMp3Directory(void)
|
|||||||
stats.dbPlayTime = sumSongTimesIn(STDERR_FILENO, NULL);
|
stats.dbPlayTime = sumSongTimesIn(STDERR_FILENO, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Song *getSongDetails(char *file, char **shortnameRet,
|
static Song *getSongDetails(const char *file, const char **shortnameRet,
|
||||||
Directory ** directoryRet)
|
Directory ** directoryRet)
|
||||||
{
|
{
|
||||||
void *song = NULL;
|
void *song = NULL;
|
||||||
|
@ -51,9 +51,9 @@ void initMp3Directory(void);
|
|||||||
|
|
||||||
void closeMp3Directory(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);
|
int checkDirectoryDB(void);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void unloadInputPlugin(InputPlugin * inputPlugin)
|
|||||||
deleteFromList(inputPlugin_list, inputPlugin->name);
|
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) {
|
while (array && *array) {
|
||||||
if (strcasecmp(*array, suffix) == 0)
|
if (strcasecmp(*array, suffix) == 0)
|
||||||
@ -55,7 +55,7 @@ static int stringFoundInStringArray(char **array, char *suffix)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next)
|
InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
|
||||||
{
|
{
|
||||||
static ListNode *pos;
|
static ListNode *pos;
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
@ -84,7 +84,7 @@ InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputPlugin *getInputPluginFromMimeType(char *mimeType, unsigned int next)
|
InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
|
||||||
{
|
{
|
||||||
static ListNode *pos;
|
static ListNode *pos;
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
@ -107,7 +107,7 @@ InputPlugin *getInputPluginFromMimeType(char *mimeType, unsigned int next)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputPlugin *getInputPluginFromName(char *name)
|
InputPlugin *getInputPluginFromName(const char *name)
|
||||||
{
|
{
|
||||||
void *plugin = NULL;
|
void *plugin = NULL;
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ void printAllInputPluginSuffixes(FILE * fp)
|
|||||||
{
|
{
|
||||||
ListNode *node = inputPlugin_list->firstNode;
|
ListNode *node = inputPlugin_list->firstNode;
|
||||||
InputPlugin *plugin;
|
InputPlugin *plugin;
|
||||||
char **suffixes;
|
const char *const*suffixes;
|
||||||
|
|
||||||
while (node) {
|
while (node) {
|
||||||
plugin = (InputPlugin *) node->data;
|
plugin = (InputPlugin *) node->data;
|
||||||
|
@ -60,7 +60,7 @@ typedef int (*InputPlugin_fileDecodeFunc) (OutputBuffer *, DecoderControl *,
|
|||||||
typedef MpdTag *(*InputPlugin_tagDupFunc) (char *file);
|
typedef MpdTag *(*InputPlugin_tagDupFunc) (char *file);
|
||||||
|
|
||||||
typedef struct _InputPlugin {
|
typedef struct _InputPlugin {
|
||||||
char *name;
|
const char *name;
|
||||||
InputPlugin_initFunc initFunc;
|
InputPlugin_initFunc initFunc;
|
||||||
InputPlugin_finishFunc finishFunc;
|
InputPlugin_finishFunc finishFunc;
|
||||||
InputPlugin_tryDecodeFunc tryDecodeFunc;
|
InputPlugin_tryDecodeFunc tryDecodeFunc;
|
||||||
@ -72,8 +72,8 @@ typedef struct _InputPlugin {
|
|||||||
unsigned char streamTypes;
|
unsigned char streamTypes;
|
||||||
|
|
||||||
/* last element in these arrays must always be a NULL: */
|
/* last element in these arrays must always be a NULL: */
|
||||||
char **suffixes;
|
const char *const*suffixes;
|
||||||
char **mimeTypes;
|
const char *const*mimeTypes;
|
||||||
} InputPlugin;
|
} InputPlugin;
|
||||||
|
|
||||||
/* individual functions to load/unload plugins */
|
/* individual functions to load/unload plugins */
|
||||||
@ -82,11 +82,11 @@ void unloadInputPlugin(InputPlugin * inputPlugin);
|
|||||||
|
|
||||||
/* interface for using plugins */
|
/* 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);
|
void printAllInputPluginSuffixes(FILE * fp);
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ static MpdTag *audiofileTagDup(char *file)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL };
|
static const char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL };
|
||||||
|
|
||||||
InputPlugin audiofilePlugin = {
|
InputPlugin audiofilePlugin = {
|
||||||
"audiofile",
|
"audiofile",
|
||||||
|
@ -473,11 +473,11 @@ static unsigned int oggflac_try_decode(InputStream * inStream)
|
|||||||
return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0;
|
return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *oggflac_suffixes[] = { "ogg", "oga", NULL };
|
static const char *oggflac_suffixes[] = { "ogg", "oga", NULL };
|
||||||
static char *oggflac_mime_types[] = { "audio/x-flac+ogg",
|
static const char *oggflac_mime_types[] = { "audio/x-flac+ogg",
|
||||||
"application/ogg",
|
"application/ogg",
|
||||||
"application/x-ogg",
|
"application/x-ogg",
|
||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
static int flac_plugin_init(void)
|
static int flac_plugin_init(void)
|
||||||
{
|
{
|
||||||
@ -501,10 +501,10 @@ static int flac_plugin_init(void)
|
|||||||
|
|
||||||
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
|
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
|
||||||
|
|
||||||
static char *flacSuffixes[] = { "flac", NULL };
|
static const char *flacSuffixes[] = { "flac", NULL };
|
||||||
static char *flac_mime_types[] = { "audio/x-flac",
|
static const char *flac_mime_types[] = { "audio/x-flac",
|
||||||
"application/x-flac",
|
"application/x-flac",
|
||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
InputPlugin flacPlugin = {
|
InputPlugin flacPlugin = {
|
||||||
"flac",
|
"flac",
|
||||||
|
@ -249,7 +249,7 @@ static MpdTag *modTagDup(char *file)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *modSuffixes[] = { "amf",
|
static const char *modSuffixes[] = { "amf",
|
||||||
"dsm",
|
"dsm",
|
||||||
"far",
|
"far",
|
||||||
"gdm",
|
"gdm",
|
||||||
|
@ -1111,8 +1111,8 @@ static MpdTag *mp3_tagDup(char *file)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *mp3_suffixes[] = { "mp3", "mp2", NULL };
|
static const char *mp3_suffixes[] = { "mp3", "mp2", NULL };
|
||||||
static char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
|
static const char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
|
||||||
|
|
||||||
InputPlugin mp3Plugin = {
|
InputPlugin mp3Plugin = {
|
||||||
"mp3",
|
"mp3",
|
||||||
|
@ -317,7 +317,7 @@ static MpdTag *mpcTagDup(char *file)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *mpcSuffixes[] = { "mpc", NULL };
|
static const char *mpcSuffixes[] = { "mpc", NULL };
|
||||||
|
|
||||||
InputPlugin mpcPlugin = {
|
InputPlugin mpcPlugin = {
|
||||||
"mpc",
|
"mpc",
|
||||||
|
@ -390,11 +390,11 @@ fail:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *oggflac_Suffixes[] = { "ogg", NULL };
|
static const char *oggflac_Suffixes[] = { "ogg", NULL };
|
||||||
static char *oggflac_mime_types[] = { "audio/x-flac+ogg",
|
static const char *oggflac_mime_types[] = { "audio/x-flac+ogg",
|
||||||
"application/ogg",
|
"application/ogg",
|
||||||
"application/x-ogg",
|
"application/x-ogg",
|
||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
InputPlugin oggflacPlugin = {
|
InputPlugin oggflacPlugin = {
|
||||||
"oggflac",
|
"oggflac",
|
||||||
|
@ -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)
|
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)
|
if(data->dc->stop)
|
||||||
return -1;
|
return -1;
|
||||||
return seekInputStream(data->inStream, offset, whence);
|
return seekInputStream(data->inStream, offset, whence);
|
||||||
@ -94,12 +94,12 @@ static int ogg_close_cb(void *vdata)
|
|||||||
|
|
||||||
static long ogg_tell_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);
|
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);
|
int len = strlen(needle);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ static char *ogg_parseComment(char *comment, char *needle)
|
|||||||
|
|
||||||
static void ogg_getReplayGainInfo(char **comments, ReplayGainInfo ** infoPtr)
|
static void ogg_getReplayGainInfo(char **comments, ReplayGainInfo ** infoPtr)
|
||||||
{
|
{
|
||||||
char *temp;
|
const char *temp;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
if (*infoPtr)
|
if (*infoPtr)
|
||||||
@ -236,7 +236,7 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
long test;
|
long test;
|
||||||
ReplayGainInfo *replayGainInfo = NULL;
|
ReplayGainInfo *replayGainInfo = NULL;
|
||||||
char **comments;
|
char **comments;
|
||||||
char *errorStr;
|
const char *errorStr;
|
||||||
|
|
||||||
data.inStream = inStream;
|
data.inStream = inStream;
|
||||||
data.dc = dc;
|
data.dc = dc;
|
||||||
@ -383,11 +383,11 @@ static unsigned int oggvorbis_try_decode(InputStream * inStream)
|
|||||||
return (ogg_stream_type_detect(inStream) == VORBIS) ? 1 : 0;
|
return (ogg_stream_type_detect(inStream) == VORBIS) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *oggvorbis_Suffixes[] = { "ogg", NULL };
|
static const char *oggvorbis_Suffixes[] = { "ogg", NULL };
|
||||||
static char *oggvorbis_MimeTypes[] = { "application/ogg",
|
static const char *oggvorbis_MimeTypes[] = { "application/ogg",
|
||||||
"audio/x-vorbis+ogg",
|
"audio/x-vorbis+ogg",
|
||||||
"application/x-ogg",
|
"application/x-ogg",
|
||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
InputPlugin oggvorbisPlugin = {
|
InputPlugin oggvorbisPlugin = {
|
||||||
"oggvorbis",
|
"oggvorbis",
|
||||||
|
@ -187,7 +187,8 @@ static char *base64Dup(char *s)
|
|||||||
return ret;
|
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;
|
char *ret = NULL;
|
||||||
int templen;
|
int templen;
|
||||||
|
23
src/list.c
23
src/list.c
@ -63,7 +63,7 @@ List *makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
|
ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
|
||||||
char *key, void *data)
|
const char *key, void *data)
|
||||||
{
|
{
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListNode *insertInList(List * list, char *key, void *data)
|
ListNode *insertInList(List * list, const char *key, void *data)
|
||||||
{
|
{
|
||||||
ListNode *node;
|
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
|
/* if _key_ is not found, *_node_ is assigned to the node before which
|
||||||
the info would be found */
|
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 high;
|
||||||
long low;
|
long low;
|
||||||
@ -268,7 +268,7 @@ int findNodeInList(List * list, char *key, ListNode ** node, int *pos)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int findInList(List * list, char *key, void **data)
|
int findInList(List * list, const char *key, void **data)
|
||||||
{
|
{
|
||||||
ListNode *node;
|
ListNode *node;
|
||||||
int pos;
|
int pos;
|
||||||
@ -282,7 +282,7 @@ int findInList(List * list, char *key, void **data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int deleteFromList(List * list, char *key)
|
int deleteFromList(List * list, const char *key)
|
||||||
{
|
{
|
||||||
ListNode *tmpNode;
|
ListNode *tmpNode;
|
||||||
|
|
||||||
@ -302,6 +302,11 @@ int deleteFromList(List * list, char *key)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_const_string(const char *p)
|
||||||
|
{
|
||||||
|
free((char *)p);
|
||||||
|
}
|
||||||
|
|
||||||
void deleteNodeFromList(List * list, ListNode * node)
|
void deleteNodeFromList(List * list, ListNode * node)
|
||||||
{
|
{
|
||||||
assert(list != NULL);
|
assert(list != NULL);
|
||||||
@ -322,7 +327,7 @@ void deleteNodeFromList(List * list, ListNode * node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (list->strdupKeys)
|
if (list->strdupKeys)
|
||||||
free(node->key);
|
free_const_string(node->key);
|
||||||
free(node);
|
free(node);
|
||||||
list->numberOfNodes--;
|
list->numberOfNodes--;
|
||||||
|
|
||||||
@ -349,7 +354,7 @@ void freeList(void *list)
|
|||||||
while (tmpNode != NULL) {
|
while (tmpNode != NULL) {
|
||||||
tmpNode2 = tmpNode->nextNode;
|
tmpNode2 = tmpNode->nextNode;
|
||||||
if (((List *) list)->strdupKeys)
|
if (((List *) list)->strdupKeys)
|
||||||
free(tmpNode->key);
|
free_const_string(tmpNode->key);
|
||||||
if (((List *) list)->freeDataFunc) {
|
if (((List *) list)->freeDataFunc) {
|
||||||
((List *) list)->freeDataFunc(tmpNode->data);
|
((List *) list)->freeDataFunc(tmpNode->data);
|
||||||
}
|
}
|
||||||
@ -362,7 +367,7 @@ void freeList(void *list)
|
|||||||
|
|
||||||
static void swapNodes(ListNode * nodeA, ListNode * nodeB)
|
static void swapNodes(ListNode * nodeA, ListNode * nodeB)
|
||||||
{
|
{
|
||||||
char *key;
|
const char *key;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
assert(nodeA != NULL);
|
assert(nodeA != NULL);
|
||||||
@ -408,7 +413,7 @@ static void quickSort(ListNode ** nodesArray, long start, long end)
|
|||||||
ListNode *node;
|
ListNode *node;
|
||||||
long pivot;
|
long pivot;
|
||||||
ListNode *pivotNode;
|
ListNode *pivotNode;
|
||||||
char *pivotKey;
|
const char *pivotKey;
|
||||||
|
|
||||||
List *startList = makeList(free, 0);
|
List *startList = makeList(free, 0);
|
||||||
List *endList = makeList(free, 0);
|
List *endList = makeList(free, 0);
|
||||||
|
12
src/list.h
12
src/list.h
@ -30,7 +30,7 @@ typedef void ListFreeDataFunc(void *);
|
|||||||
|
|
||||||
typedef struct _ListNode {
|
typedef struct _ListNode {
|
||||||
/* used to identify node (ie. when using findInList) */
|
/* used to identify node (ie. when using findInList) */
|
||||||
char *key;
|
const char *key;
|
||||||
/* data store in node */
|
/* data store in node */
|
||||||
void *data;
|
void *data;
|
||||||
/* next node in list */
|
/* next node in list */
|
||||||
@ -69,10 +69,10 @@ List *makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys);
|
|||||||
* _data_ -> data to be inserted in list
|
* _data_ -> data to be inserted in list
|
||||||
* returns 1 if successful, 0 otherwise
|
* 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,
|
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);
|
int insertInListWithoutKey(List * list, void *data);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ int insertInListWithoutKey(List * list, void *data);
|
|||||||
* _key_ -> key used to identify node to delete
|
* _key_ -> key used to identify node to delete
|
||||||
* returns 1 if node is found and deleted, 0 otherwise
|
* 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);
|
void deleteNodeFromList(List * list, ListNode * node);
|
||||||
|
|
||||||
@ -93,11 +93,11 @@ void deleteNodeFromList(List * list, ListNode * node);
|
|||||||
* _data_ can be NULL
|
* _data_ can be NULL
|
||||||
* returns 1 if successful, 0 otherwise
|
* 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
|
/* if _key_ is not found, *_node_ is assigned to the node before which
|
||||||
the info would be found */
|
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
|
/* frees memory malloc'd for list and its nodes
|
||||||
* _list_ -> List to be free'd
|
* _list_ -> List to be free'd
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define LOCATE_TAG_FILE_KEY_OLD "filename"
|
#define LOCATE_TAG_FILE_KEY_OLD "filename"
|
||||||
#define LOCATE_TAG_ANY_KEY "any"
|
#define LOCATE_TAG_ANY_KEY "any"
|
||||||
|
|
||||||
int getLocateTagItemType(char *str)
|
int getLocateTagItemType(const char *str)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -48,7 +48,8 @@ int getLocateTagItemType(char *str)
|
|||||||
return -1;
|
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);
|
item->tagType = getLocateTagItemType(typeStr);
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ static int initLocateTagItem(LocateTagItem * item, char *typeStr, char *needle)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocateTagItem *newLocateTagItem(char *typeStr, char *needle)
|
LocateTagItem *newLocateTagItem(const char *typeStr, const char *needle)
|
||||||
{
|
{
|
||||||
LocateTagItem *ret = xmalloc(sizeof(LocateTagItem));
|
LocateTagItem *ret = xmalloc(sizeof(LocateTagItem));
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ typedef struct _LocateTagItem {
|
|||||||
char *needle;
|
char *needle;
|
||||||
} LocateTagItem;
|
} LocateTagItem;
|
||||||
|
|
||||||
int getLocateTagItemType(char *str);
|
int getLocateTagItemType(const char *str);
|
||||||
|
|
||||||
/* returns NULL if not a known type */
|
/* 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 */
|
/* return number of items or -1 on error */
|
||||||
int newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
|
int newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
|
||||||
|
34
src/ls.c
34
src/ls.c
@ -25,14 +25,14 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
static char *remoteUrlPrefixes[] = {
|
static const char *remoteUrlPrefixes[] = {
|
||||||
"http://",
|
"http://",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
int printRemoteUrlHandlers(int fd)
|
int printRemoteUrlHandlers(int fd)
|
||||||
{
|
{
|
||||||
char **prefixes = remoteUrlPrefixes;
|
const char **prefixes = remoteUrlPrefixes;
|
||||||
|
|
||||||
while (*prefixes) {
|
while (*prefixes) {
|
||||||
fdprintf(fd, "handler: %s\n", *prefixes);
|
fdprintf(fd, "handler: %s\n", *prefixes);
|
||||||
@ -85,7 +85,7 @@ int isValidRemoteUtf8Url(char *utf8url)
|
|||||||
int isRemoteUrl(char *url)
|
int isRemoteUrl(char *url)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char **urlPrefixes = remoteUrlPrefixes;
|
const char **urlPrefixes = remoteUrlPrefixes;
|
||||||
|
|
||||||
while (*urlPrefixes) {
|
while (*urlPrefixes) {
|
||||||
count++;
|
count++;
|
||||||
@ -98,7 +98,7 @@ int isRemoteUrl(char *url)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsPlaylists(int fd, char *utf8path)
|
int lsPlaylists(int fd, const char *utf8path)
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -181,11 +181,11 @@ int lsPlaylists(int fd, char *utf8path)
|
|||||||
return 0;
|
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 path_max_tmp[MPD_PATH_MAX];
|
||||||
char *file = utf8_to_fs_charset(path_max_tmp, utf8file);
|
const char *file = utf8_to_fs_charset(path_max_tmp, utf8file);
|
||||||
char *actualFile = file;
|
const char *actualFile = file;
|
||||||
|
|
||||||
if (actualFile[0] != '/')
|
if (actualFile[0] != '/')
|
||||||
actualFile = rmp2amp_r(path_max_tmp, file);
|
actualFile = rmp2amp_r(path_max_tmp, file);
|
||||||
@ -193,7 +193,7 @@ int myStat(char *utf8file, struct stat *st)
|
|||||||
return stat(actualFile, st);
|
return stat(actualFile, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
int isFile(char *utf8file, time_t * mtime)
|
int isFile(const char *utf8file, time_t * mtime)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -215,9 +215,9 @@ int isFile(char *utf8file, time_t * mtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* suffixes should be ascii only characters */
|
/* 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) {
|
while (*utf8file) {
|
||||||
if (*utf8file == '.')
|
if (*utf8file == '.')
|
||||||
@ -228,15 +228,15 @@ char *getSuffix(char *utf8file)
|
|||||||
return ret;
|
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))
|
if (s && 0 == strcmp(s, suffix))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isPlaylist(char *utf8file)
|
int isPlaylist(const char *utf8file)
|
||||||
{
|
{
|
||||||
if (isFile(utf8file, NULL)) {
|
if (isFile(utf8file, NULL)) {
|
||||||
return hasSuffix(utf8file, PLAYLIST_FILE_SUFFIX);
|
return hasSuffix(utf8file, PLAYLIST_FILE_SUFFIX);
|
||||||
@ -244,7 +244,7 @@ int isPlaylist(char *utf8file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isDir(char *utf8name)
|
int isDir(const char *utf8name)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -257,11 +257,11 @@ int isDir(char *utf8name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputPlugin *hasMusicSuffix(char *utf8file, unsigned int next)
|
InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next)
|
||||||
{
|
{
|
||||||
InputPlugin *ret = NULL;
|
InputPlugin *ret = NULL;
|
||||||
|
|
||||||
char *s = getSuffix(utf8file);
|
const char *s = getSuffix(utf8file);
|
||||||
if (s) {
|
if (s) {
|
||||||
ret = getInputPluginFromSuffix(s, next);
|
ret = getInputPluginFromSuffix(s, next);
|
||||||
} else {
|
} else {
|
||||||
@ -272,7 +272,7 @@ InputPlugin *hasMusicSuffix(char *utf8file, unsigned int next)
|
|||||||
return ret;
|
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)) {
|
if (isFile(utf8file, mtime)) {
|
||||||
InputPlugin *plugin = hasMusicSuffix(utf8file, next);
|
InputPlugin *plugin = hasMusicSuffix(utf8file, next);
|
||||||
|
16
src/ls.h
16
src/ls.h
@ -24,26 +24,26 @@
|
|||||||
#include "inputPlugin.h"
|
#include "inputPlugin.h"
|
||||||
#include "os_compat.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 isValidRemoteUtf8Url(char *utf8url);
|
||||||
|
|
||||||
int isRemoteUrl(char *url);
|
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 printRemoteUrlHandlers(int fd);
|
||||||
|
|
||||||
int isFile(char *utf8file, time_t * mtime);
|
int isFile(const char *utf8file, time_t * mtime);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,4 +41,9 @@ typedef unsigned long mpd_uint32;
|
|||||||
typedef signed long mpd_sint32;
|
typedef signed long mpd_sint32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
union const_hack {
|
||||||
|
const char *in;
|
||||||
|
char *out;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
15
src/path.c
15
src/path.c
@ -38,24 +38,25 @@ static size_t music_dir_len;
|
|||||||
static size_t playlist_dir_len;
|
static size_t playlist_dir_len;
|
||||||
static char *fsCharset;
|
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);
|
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);
|
char *ret = path_conv_charset(dst, "UTF-8", fsCharset, str);
|
||||||
return (ret && !validUtf8String(ret)) ? NULL : ret;
|
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);
|
char *ret = path_conv_charset(dst, fsCharset, "UTF-8", str);
|
||||||
return ret ? ret : strcpy(dst, str);
|
return ret ? ret : strcpy(dst, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFsCharset(char *charset)
|
void setFsCharset(const char *charset)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ void setFsCharset(char *charset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getFsCharset(void)
|
const char *getFsCharset(void)
|
||||||
{
|
{
|
||||||
return fsCharset;
|
return fsCharset;
|
||||||
}
|
}
|
||||||
@ -243,7 +244,7 @@ char *parent_path(char *path_max_tmp, const char *path)
|
|||||||
return path_max_tmp;
|
return path_max_tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *sanitizePathDup(char *path)
|
char *sanitizePathDup(const char *path)
|
||||||
{
|
{
|
||||||
int len = strlen(path) + 1;
|
int len = strlen(path) + 1;
|
||||||
char *ret = xmalloc(len);
|
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)
|
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);
|
rpp2app_r(path_max_tmp, path_max_tmp);
|
||||||
strncat(path_max_tmp, "." PLAYLIST_FILE_SUFFIX, MPD_PATH_MAX - 1);
|
strncat(path_max_tmp, "." PLAYLIST_FILE_SUFFIX, MPD_PATH_MAX - 1);
|
||||||
}
|
}
|
||||||
|
10
src/path.h
10
src/path.h
@ -38,13 +38,13 @@ void initPaths(void);
|
|||||||
|
|
||||||
void finishPaths(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
|
* 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);
|
char *parent_path(char *path_max_tmp, const char *path);
|
||||||
|
|
||||||
/* strips extra "///" and leading "/" and trailing "/" */
|
/* 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
|
/* 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
|
* blindly use it everywhere, only for paths that are OK to truncate (for
|
||||||
|
@ -44,7 +44,7 @@ Song *newNullSong(void)
|
|||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
Song *newSong(char *url, int type, Directory * parentDir)
|
Song *newSong(const char *url, int type, Directory * parentDir)
|
||||||
{
|
{
|
||||||
Song *song = NULL;
|
Song *song = NULL;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ SongList *newSongList(void)
|
|||||||
return makeList((ListFreeDataFunc *) freeSong, 0);
|
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)
|
int songType, Directory * parentDirectory)
|
||||||
{
|
{
|
||||||
Song *song = NULL;
|
Song *song = NULL;
|
||||||
|
@ -45,7 +45,7 @@ typedef List SongList;
|
|||||||
|
|
||||||
Song *newNullSong(void);
|
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 *);
|
void freeSong(Song *);
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ SongList *newSongList(void);
|
|||||||
|
|
||||||
void freeSongList(SongList * list);
|
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 songType, struct _Directory *parentDir);
|
||||||
|
|
||||||
int printSongInfo(int fd, Song * song);
|
int printSongInfo(int fd, Song * song);
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = {
|
const char *mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = {
|
||||||
"Artist",
|
"Artist",
|
||||||
"Album",
|
"Album",
|
||||||
"Title",
|
"Title",
|
||||||
@ -169,7 +169,8 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
|
|||||||
return utf8;
|
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;
|
struct id3_frame const *frame;
|
||||||
id3_ucs4_t const *ucs4;
|
id3_ucs4_t const *ucs4;
|
||||||
@ -480,7 +481,7 @@ MpdTag *apeDup(char *file)
|
|||||||
unsigned char reserved[8];
|
unsigned char reserved[8];
|
||||||
} footer;
|
} footer;
|
||||||
|
|
||||||
char *apeItems[7] = {
|
const char *apeItems[7] = {
|
||||||
"title",
|
"title",
|
||||||
"artist",
|
"artist",
|
||||||
"album",
|
"album",
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#define TAG_NUM_OF_ITEM_TYPES 11
|
#define TAG_NUM_OF_ITEM_TYPES 11
|
||||||
|
|
||||||
extern char *mpdTagItemKeys[];
|
extern const char *mpdTagItemKeys[];
|
||||||
|
|
||||||
typedef struct _MpdTagItem {
|
typedef struct _MpdTagItem {
|
||||||
mpd_sint8 type;
|
mpd_sint8 type;
|
||||||
|
20
src/utf8.c
20
src/utf8.c
@ -20,10 +20,10 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "os_compat.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 *cp = (unsigned char *)dest;
|
||||||
unsigned char *latin1 = (unsigned char *)in_latin1;
|
const unsigned char *latin1 = (const unsigned char *)in_latin1;
|
||||||
|
|
||||||
while (*latin1) {
|
while (*latin1) {
|
||||||
if (*latin1 < 128)
|
if (*latin1 < 128)
|
||||||
@ -45,7 +45,7 @@ char *latin1_to_utf8(char *dest, char *in_latin1)
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *latin1StrToUtf8Dup(char *latin1)
|
char *latin1StrToUtf8Dup(const char *latin1)
|
||||||
{
|
{
|
||||||
/* utf8 should have at most two char's per latin1 char */
|
/* utf8 should have at most two char's per latin1 char */
|
||||||
char *ret = xmalloc(strlen(latin1) * 2 + 1);
|
char *ret = xmalloc(strlen(latin1) * 2 + 1);
|
||||||
@ -55,10 +55,10 @@ char *latin1StrToUtf8Dup(char *latin1)
|
|||||||
return ((ret) ? xrealloc(ret, strlen((char *)ret) + 1) : NULL);
|
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 c = 0;
|
||||||
unsigned char *utf8 = (unsigned char *)inUtf8;
|
const unsigned char *utf8 = (const unsigned char *)inUtf8;
|
||||||
|
|
||||||
if (utf8[0] < 128)
|
if (utf8[0] < 128)
|
||||||
return utf8[0];
|
return utf8[0];
|
||||||
@ -69,9 +69,9 @@ static char utf8_to_latin1_char(char *inUtf8)
|
|||||||
return (char)(c + utf8[1]);
|
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)
|
if (utf8Char[0] < 0x80)
|
||||||
return 1;
|
return 1;
|
||||||
@ -95,7 +95,7 @@ static int validateUtf8Char(char *inUtf8Char)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int validUtf8String(char *string)
|
int validUtf8String(const char *string)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ int validUtf8String(char *string)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *utf8StrToLatin1Dup(char *utf8)
|
char *utf8StrToLatin1Dup(const char *utf8)
|
||||||
{
|
{
|
||||||
/* utf8 should have at most two char's per latin1 char */
|
/* utf8 should have at most two char's per latin1 char */
|
||||||
char *ret = xmalloc(strlen(utf8) + 1);
|
char *ret = xmalloc(strlen(utf8) + 1);
|
||||||
@ -133,7 +133,7 @@ char *utf8StrToLatin1Dup(char *utf8)
|
|||||||
return xrealloc(ret, len + 1);
|
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;
|
char *cp = dest;
|
||||||
int count;
|
int count;
|
||||||
|
10
src/utf8.h
10
src/utf8.h
@ -19,15 +19,15 @@
|
|||||||
#ifndef UTF_8_H
|
#ifndef UTF_8_H
|
||||||
#define 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
|
#endif
|
||||||
|
12
src/volume.c
12
src/volume.c
@ -57,7 +57,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT;
|
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;
|
static int volume_softwareSet = 100;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ static void closeOssMixer(void)
|
|||||||
volume_ossFd = -1;
|
volume_ossFd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prepOssMixer(char *device)
|
static int prepOssMixer(const char *device)
|
||||||
{
|
{
|
||||||
ConfigParam *param;
|
ConfigParam *param;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ static int prepOssMixer(char *device)
|
|||||||
param = getConfigParam(CONF_MIXER_CONTROL);
|
param = getConfigParam(CONF_MIXER_CONTROL);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
|
const char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
|
||||||
char *duplicated;
|
char *duplicated;
|
||||||
int i, j;
|
int i, j;
|
||||||
int devmask = 0;
|
int devmask = 0;
|
||||||
@ -211,11 +211,11 @@ static void closeAlsaMixer(void)
|
|||||||
volume_alsaMixerHandle = NULL;
|
volume_alsaMixerHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prepAlsaMixer(char *card)
|
static int prepAlsaMixer(const char *card)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
snd_mixer_elem_t *elem;
|
snd_mixer_elem_t *elem;
|
||||||
char *controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
|
const char *controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
|
||||||
ConfigParam *param;
|
ConfigParam *param;
|
||||||
|
|
||||||
err = snd_mixer_open(&volume_alsaMixerHandle, 0);
|
err = snd_mixer_open(&volume_alsaMixerHandle, 0);
|
||||||
@ -370,7 +370,7 @@ static int changeAlsaVolumeLevel(int fd, int change, int rel)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int prepMixer(char *device)
|
static int prepMixer(const char *device)
|
||||||
{
|
{
|
||||||
switch (volume_mixerType) {
|
switch (volume_mixerType) {
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
|
Loading…
Reference in New Issue
Block a user