ok, now song->url is only the filename, not the full path to the song
git-svn-id: https://svn.musicpd.org/mpd/trunk@2602 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
@@ -24,7 +24,7 @@ void unloadAudioOutputPlugin(AudioOutputPlugin * audioOutputPlugin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initAudioOutputPlugins() {
|
void initAudioOutputPlugins() {
|
||||||
audioOutputPluginList = makeList(NULL);
|
audioOutputPluginList = makeList(NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishAudioOutputPlugins() {
|
void finishAudioOutputPlugins() {
|
||||||
|
@@ -486,7 +486,7 @@ int listHandleUpdate(FILE * fp, unsigned int * permission, int argArrayLength,
|
|||||||
CommandEntry * nextCmd = NULL;
|
CommandEntry * nextCmd = NULL;
|
||||||
ListNode * nextNode = commandNode->nextNode;;
|
ListNode * nextNode = commandNode->nextNode;;
|
||||||
|
|
||||||
if(!pathList) pathList = makeList(NULL);
|
if(!pathList) pathList = makeList(NULL, 1);
|
||||||
|
|
||||||
if(argArrayLength==2) insertInList(pathList,argArray[1],NULL);
|
if(argArrayLength==2) insertInList(pathList,argArray[1],NULL);
|
||||||
else insertInList(pathList,"",NULL);
|
else insertInList(pathList,"",NULL);
|
||||||
@@ -511,7 +511,7 @@ int handleUpdate(FILE * fp, unsigned int * permission, int argArrayLength,
|
|||||||
{
|
{
|
||||||
if(argArrayLength==2) {
|
if(argArrayLength==2) {
|
||||||
int ret;
|
int ret;
|
||||||
List * pathList = makeList(NULL);
|
List * pathList = makeList(NULL, 1);
|
||||||
insertInList(pathList,argArray[1],NULL);
|
insertInList(pathList,argArray[1],NULL);
|
||||||
ret = updateInit(fp,pathList);
|
ret = updateInit(fp,pathList);
|
||||||
freeList(pathList);
|
freeList(pathList);
|
||||||
@@ -881,7 +881,7 @@ int handleCommands(FILE * fp, unsigned int * permission, int argArrayLength,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initCommands() {
|
void initCommands() {
|
||||||
commandList = makeList(free);
|
commandList = makeList(free, 1);
|
||||||
|
|
||||||
addCommand(COMMAND_PLAY ,PERMISSION_CONTROL, 0, 1,handlePlay,NULL);
|
addCommand(COMMAND_PLAY ,PERMISSION_CONTROL, 0, 1,handlePlay,NULL);
|
||||||
addCommand(COMMAND_PLAYID ,PERMISSION_CONTROL, 0, 1,handlePlayId,NULL);
|
addCommand(COMMAND_PLAYID ,PERMISSION_CONTROL, 0, 1,handlePlayId,NULL);
|
||||||
|
@@ -86,7 +86,7 @@ ConfigEntry * newConfigEntry(int repeatable, int block) {
|
|||||||
ConfigEntry * ret = malloc(sizeof(ConfigEntry));
|
ConfigEntry * ret = malloc(sizeof(ConfigEntry));
|
||||||
|
|
||||||
ret->mask = 0;
|
ret->mask = 0;
|
||||||
ret->configParamList = makeList((ListFreeDataFunc *)freeConfigParam);
|
ret->configParamList = makeList((ListFreeDataFunc *)freeConfigParam, 1);
|
||||||
|
|
||||||
if(repeatable) ret->mask |= CONF_REPEATABLE_MASK;
|
if(repeatable) ret->mask |= CONF_REPEATABLE_MASK;
|
||||||
if(block) ret->mask |= CONF_BLOCK_MASK;
|
if(block) ret->mask |= CONF_BLOCK_MASK;
|
||||||
@@ -113,7 +113,7 @@ void registerConfigParam(char * name, int repeatable, int block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initConf() {
|
void initConf() {
|
||||||
configEntriesList = makeList((ListFreeDataFunc *)freeConfigEntry);
|
configEntriesList = makeList((ListFreeDataFunc *)freeConfigEntry, 1);
|
||||||
|
|
||||||
registerConfigParam(CONF_PORT, 0, 0);
|
registerConfigParam(CONF_PORT, 0, 0);
|
||||||
registerConfigParam(CONF_MUSIC_DIR, 0, 0);
|
registerConfigParam(CONF_MUSIC_DIR, 0, 0);
|
||||||
|
@@ -277,6 +277,17 @@ int sumSavedMemoryInDirectory(FILE * fp, Directory * dir, void * data) {
|
|||||||
|
|
||||||
*sum += (strlen(dir->utf8name)+1-sizeof(Directory *))*
|
*sum += (strlen(dir->utf8name)+1-sizeof(Directory *))*
|
||||||
dir->songs->numberOfNodes;
|
dir->songs->numberOfNodes;
|
||||||
|
|
||||||
|
/**sum += (strlen(dir->utf8name)+1)*
|
||||||
|
dir->subDirectories->numberOfNodes;*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sumSavedMemoryInSong(FILE * fp, Song * song, void * data) {
|
||||||
|
int * sum = data;
|
||||||
|
|
||||||
|
*sum += strlen(song->url)+1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -284,8 +295,8 @@ int sumSavedMemoryInDirectory(FILE * fp, Directory * dir, void * data) {
|
|||||||
void printSavedMemoryFromFilenames() {
|
void printSavedMemoryFromFilenames() {
|
||||||
int sum;
|
int sum;
|
||||||
|
|
||||||
traverseAllIn(stderr, NULL, NULL, sumSavedMemoryInDirectory,
|
traverseAllIn(stderr, NULL, sumSavedMemoryInSong,
|
||||||
(void *)&sum);
|
sumSavedMemoryInDirectory, (void *)&sum);
|
||||||
|
|
||||||
DEBUG("saved memory from filenames: %i\n", sum);
|
DEBUG("saved memory from filenames: %i\n", sum);
|
||||||
}
|
}
|
||||||
|
@@ -269,7 +269,7 @@ void freeDirectory(Directory * directory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DirectoryList * newDirectoryList() {
|
DirectoryList * newDirectoryList() {
|
||||||
return makeList((ListFreeDataFunc *)freeDirectory);
|
return makeList((ListFreeDataFunc *)freeDirectory, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeDirectoryList(DirectoryList * directoryList) {
|
void freeDirectoryList(DirectoryList * directoryList) {
|
||||||
@@ -352,7 +352,7 @@ int removeDeletedFromDirectory(Directory * directory, DIR * dir) {
|
|||||||
char cwd[2];
|
char cwd[2];
|
||||||
struct dirent * ent;
|
struct dirent * ent;
|
||||||
char * dirname = directory->utf8name;
|
char * dirname = directory->utf8name;
|
||||||
List * entList = makeList(free);
|
List * entList = makeList(free, 1);
|
||||||
void * name;
|
void * name;
|
||||||
char * s;
|
char * s;
|
||||||
char * utf8;
|
char * utf8;
|
||||||
|
@@ -117,7 +117,7 @@ extern InputPlugin aacPlugin;
|
|||||||
extern InputPlugin modPlugin;
|
extern InputPlugin modPlugin;
|
||||||
|
|
||||||
void initInputPlugins() {
|
void initInputPlugins() {
|
||||||
inputPlugin_list = makeList(NULL);
|
inputPlugin_list = makeList(NULL, 1);
|
||||||
|
|
||||||
/* load plugins here */
|
/* load plugins here */
|
||||||
loadInputPlugin(&mp3Plugin);
|
loadInputPlugin(&mp3Plugin);
|
||||||
|
@@ -288,7 +288,8 @@ int interfaceReadInput(Interface * interface) {
|
|||||||
if(strcmp(interface->buffer,
|
if(strcmp(interface->buffer,
|
||||||
INTERFACE_LIST_MODE_BEGIN)==0)
|
INTERFACE_LIST_MODE_BEGIN)==0)
|
||||||
{
|
{
|
||||||
interface->commandList = makeList(free);
|
interface->commandList = makeList(free,
|
||||||
|
1);
|
||||||
interface->commandListSize =
|
interface->commandListSize =
|
||||||
sizeof(List);
|
sizeof(List);
|
||||||
interface->commandListOK = 0;
|
interface->commandListOK = 0;
|
||||||
@@ -298,7 +299,8 @@ int interfaceReadInput(Interface * interface) {
|
|||||||
INTERFACE_LIST_OK_MODE_BEGIN)
|
INTERFACE_LIST_OK_MODE_BEGIN)
|
||||||
==0)
|
==0)
|
||||||
{
|
{
|
||||||
interface->commandList = makeList(free);
|
interface->commandList = makeList(free,
|
||||||
|
1);
|
||||||
interface->commandListSize =
|
interface->commandListSize =
|
||||||
sizeof(List);
|
sizeof(List);
|
||||||
interface->commandListOK = 1;
|
interface->commandListOK = 1;
|
||||||
@@ -654,7 +656,7 @@ void printInterfaceOutBuffer(Interface * interface) {
|
|||||||
memcpy(buffer,interface->outBuffer,
|
memcpy(buffer,interface->outBuffer,
|
||||||
interface->outBuflen);
|
interface->outBuflen);
|
||||||
buffer[interface->outBuflen] = '\0';
|
buffer[interface->outBuflen] = '\0';
|
||||||
interface->bufferList = makeList(free);
|
interface->bufferList = makeList(free, 1);
|
||||||
insertInListWithoutKey(interface->bufferList,
|
insertInListWithoutKey(interface->bufferList,
|
||||||
(void *)buffer);
|
(void *)buffer);
|
||||||
}
|
}
|
||||||
@@ -670,7 +672,7 @@ void printInterfaceOutBuffer(Interface * interface) {
|
|||||||
memcpy(buffer,interface->outBuffer+ret,
|
memcpy(buffer,interface->outBuffer+ret,
|
||||||
interface->outBuflen-ret);
|
interface->outBuflen-ret);
|
||||||
buffer[interface->outBuflen-ret] = '\0';
|
buffer[interface->outBuflen-ret] = '\0';
|
||||||
interface->bufferList = makeList(free);
|
interface->bufferList = makeList(free, 1);
|
||||||
insertInListWithoutKey(interface->bufferList,buffer);
|
insertInListWithoutKey(interface->bufferList,buffer);
|
||||||
}
|
}
|
||||||
/* if we needed to create buffer, initialize bufferSize info */
|
/* if we needed to create buffer, initialize bufferSize info */
|
||||||
|
32
src/list.c
32
src/list.c
@@ -42,7 +42,7 @@ void freeListNodesArray(List * list) {
|
|||||||
list->nodesArray = NULL;
|
list->nodesArray = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
List * makeList(ListFreeDataFunc * freeDataFunc) {
|
List * makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys) {
|
||||||
List * list = malloc(sizeof(List));
|
List * list = malloc(sizeof(List));
|
||||||
|
|
||||||
assert(list!=NULL);
|
assert(list!=NULL);
|
||||||
@@ -52,6 +52,7 @@ List * makeList(ListFreeDataFunc * freeDataFunc) {
|
|||||||
list->freeDataFunc = freeDataFunc;
|
list->freeDataFunc = freeDataFunc;
|
||||||
list->numberOfNodes = 0;
|
list->numberOfNodes = 0;
|
||||||
list->nodesArray = NULL;
|
list->nodesArray = NULL;
|
||||||
|
list->strdupKeys = strdupKeys;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -93,10 +94,12 @@ int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key,
|
|||||||
}
|
}
|
||||||
beforeNode->prevNode = node;
|
beforeNode->prevNode = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->key = malloc((strlen(key)+1)*sizeof(char));
|
if(list->strdupKeys) node->key = strdup(key);
|
||||||
|
else node->key = key;
|
||||||
|
|
||||||
assert(node->key!=NULL);
|
assert(node->key!=NULL);
|
||||||
strcpy(node->key,key);
|
|
||||||
node->data = data;
|
node->data = data;
|
||||||
|
|
||||||
list->numberOfNodes++;
|
list->numberOfNodes++;
|
||||||
@@ -104,7 +107,7 @@ int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListNode * insertInList(List * list,char * key,void * data) {
|
ListNode * insertInList(List * list, char * key, void * data) {
|
||||||
ListNode * node;
|
ListNode * node;
|
||||||
|
|
||||||
assert(list!=NULL);
|
assert(list!=NULL);
|
||||||
@@ -125,10 +128,10 @@ ListNode * insertInList(List * list,char * key,void * data) {
|
|||||||
assert(list->lastNode->nextNode==NULL);
|
assert(list->lastNode->nextNode==NULL);
|
||||||
list->lastNode->nextNode = node;
|
list->lastNode->nextNode = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->key = malloc((strlen(key)+1)*sizeof(char));
|
if(list->strdupKeys) node->key = strdup(key);
|
||||||
assert(node->key!=NULL);
|
else node->key = key;
|
||||||
strcpy(node->key,key);
|
|
||||||
node->data = data;
|
node->data = data;
|
||||||
node->nextNode = NULL;
|
node->nextNode = NULL;
|
||||||
node->prevNode = list->lastNode;
|
node->prevNode = list->lastNode;
|
||||||
@@ -267,7 +270,8 @@ void deleteNodeFromList(List * list,ListNode * node) {
|
|||||||
if(list->freeDataFunc) {
|
if(list->freeDataFunc) {
|
||||||
list->freeDataFunc(node->data);
|
list->freeDataFunc(node->data);
|
||||||
}
|
}
|
||||||
free(node->key);
|
|
||||||
|
if(list->strdupKeys) free(node->key);
|
||||||
free(node);
|
free(node);
|
||||||
list->numberOfNodes--;
|
list->numberOfNodes--;
|
||||||
|
|
||||||
@@ -290,7 +294,7 @@ void freeList(void * list) {
|
|||||||
|
|
||||||
while(tmpNode!=NULL) {
|
while(tmpNode!=NULL) {
|
||||||
tmpNode2 = tmpNode->nextNode;
|
tmpNode2 = tmpNode->nextNode;
|
||||||
free(tmpNode->key);
|
if(((List *)list)->strdupKeys) free(tmpNode->key);
|
||||||
if(((List *)list)->freeDataFunc) {
|
if(((List *)list)->freeDataFunc) {
|
||||||
((List *)list)->freeDataFunc(tmpNode->data);
|
((List *)list)->freeDataFunc(tmpNode->data);
|
||||||
}
|
}
|
||||||
@@ -311,7 +315,7 @@ void clearList(List * list) {
|
|||||||
|
|
||||||
while(tmpNode!=NULL) {
|
while(tmpNode!=NULL) {
|
||||||
tmpNode2 = tmpNode->nextNode;
|
tmpNode2 = tmpNode->nextNode;
|
||||||
free(tmpNode->key);
|
if(list->strdupKeys) free(tmpNode->key);
|
||||||
if(((List *)list)->freeDataFunc) {
|
if(((List *)list)->freeDataFunc) {
|
||||||
((List *)list)->freeDataFunc(tmpNode->data);
|
((List *)list)->freeDataFunc(tmpNode->data);
|
||||||
}
|
}
|
||||||
@@ -400,8 +404,8 @@ void quickSort(ListNode ** nodesArray, long start, long end) {
|
|||||||
ListNode * pivotNode;
|
ListNode * pivotNode;
|
||||||
char * pivotKey;
|
char * pivotKey;
|
||||||
|
|
||||||
List * startList = makeList(free);
|
List * startList = makeList(free, 0);
|
||||||
List * endList = makeList(free);
|
List * endList = makeList(free, 0);
|
||||||
long * startPtr = malloc(sizeof(long));
|
long * startPtr = malloc(sizeof(long));
|
||||||
long * endPtr = malloc(sizeof(long));
|
long * endPtr = malloc(sizeof(long));
|
||||||
*startPtr = start;
|
*startPtr = start;
|
||||||
|
@@ -52,6 +52,8 @@ typedef struct _List {
|
|||||||
long numberOfNodes;
|
long numberOfNodes;
|
||||||
/* array for searching when list is sorted */
|
/* array for searching when list is sorted */
|
||||||
ListNode ** nodesArray;
|
ListNode ** nodesArray;
|
||||||
|
/* weather to strdup() key's on insertion */
|
||||||
|
int strdupKeys;
|
||||||
} List;
|
} List;
|
||||||
|
|
||||||
/* allocates memory for a new list and initializes it
|
/* allocates memory for a new list and initializes it
|
||||||
@@ -59,7 +61,7 @@ typedef struct _List {
|
|||||||
* DEFAULT_FREE_DATAFUNC to use free()
|
* DEFAULT_FREE_DATAFUNC to use free()
|
||||||
* returns pointer to new list if successful, NULL otherwise
|
* returns pointer to new list if successful, NULL otherwise
|
||||||
*/
|
*/
|
||||||
List * makeList(ListFreeDataFunc * freeDataFunc);
|
List * makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys);
|
||||||
|
|
||||||
/* inserts a node into _list_ with _key_ and _data_
|
/* inserts a node into _list_ with _key_ and _data_
|
||||||
* _list_ -> list the data will be inserted in
|
* _list_ -> list the data will be inserted in
|
||||||
|
2
src/ls.c
2
src/ls.c
@@ -152,7 +152,7 @@ int lsPlaylists(FILE * fp, char * utf8path) {
|
|||||||
strncpy(s+actlen,ent->d_name,maxlen);
|
strncpy(s+actlen,ent->d_name,maxlen);
|
||||||
if(stat(s,&st)==0) {
|
if(stat(s,&st)==0) {
|
||||||
if(S_ISREG(st.st_mode)) {
|
if(S_ISREG(st.st_mode)) {
|
||||||
if(list==NULL) list = makeList(NULL);
|
if(list==NULL) list = makeList(NULL, 1);
|
||||||
dup = strdup(ent->d_name);
|
dup = strdup(ent->d_name);
|
||||||
dup[suff] = '\0';
|
dup[suff] = '\0';
|
||||||
if((utf8 = fsCharsetToUtf8(dup))) {
|
if((utf8 = fsCharsetToUtf8(dup))) {
|
||||||
|
@@ -75,7 +75,7 @@ void initPermissions() {
|
|||||||
unsigned int * permission;
|
unsigned int * permission;
|
||||||
ConfigParam * param;
|
ConfigParam * param;
|
||||||
|
|
||||||
permission_passwords = makeList(free);
|
permission_passwords = makeList(free, 1);
|
||||||
|
|
||||||
permission_default = PERMISSION_READ | PERMISSION_ADD |
|
permission_default = PERMISSION_READ | PERMISSION_ADD |
|
||||||
PERMISSION_CONTROL | PERMISSION_ADMIN;
|
PERMISSION_CONTROL | PERMISSION_ADMIN;
|
||||||
|
@@ -86,7 +86,7 @@ void freeJustSong(Song * song) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SongList * newSongList() {
|
SongList * newSongList() {
|
||||||
return makeList((ListFreeDataFunc *)freeSong);
|
return makeList((ListFreeDataFunc *)freeSong, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Song * addSongToList(SongList * list, char * url, char * utf8path,
|
Song * addSongToList(SongList * list, char * url, char * utf8path,
|
||||||
@@ -107,7 +107,7 @@ Song * addSongToList(SongList * list, char * url, char * utf8path,
|
|||||||
|
|
||||||
if(song==NULL) return NULL;
|
if(song==NULL) return NULL;
|
||||||
|
|
||||||
insertInList(list, url, (void *)song);
|
insertInList(list, song->url, (void *)song);
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ void insertSongIntoList(SongList * list, ListNode ** nextSongNode, char * key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!(*nextSongNode)) {
|
if(!(*nextSongNode)) {
|
||||||
insertInList(list,key,(void *)song);
|
insertInList(list, song->url, (void *)song);
|
||||||
}
|
}
|
||||||
else if(cmpRet == 0) {
|
else if(cmpRet == 0) {
|
||||||
Song * tempSong = (Song *)((*nextSongNode)->data);
|
Song * tempSong = (Song *)((*nextSongNode)->data);
|
||||||
@@ -188,7 +188,8 @@ void insertSongIntoList(SongList * list, ListNode ** nextSongNode, char * key,
|
|||||||
*nextSongNode = (*nextSongNode)->nextNode;
|
*nextSongNode = (*nextSongNode)->nextNode;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
insertInListBeforeNode(list,*nextSongNode,key,(void *)song);
|
insertInListBeforeNode(list, *nextSongNode, song->url,
|
||||||
|
(void *)song);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ char * getTagItemString(int type, char * string) {
|
|||||||
if(type == TAG_ITEM_TITLE) return strdup(string);
|
if(type == TAG_ITEM_TITLE) return strdup(string);
|
||||||
|
|
||||||
if(tagLists[type] == NULL) {
|
if(tagLists[type] == NULL) {
|
||||||
tagLists[type] = makeList(free);
|
tagLists[type] = makeList(free, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((node = findNodeInList(tagLists[type], string))) {
|
if((node = findNodeInList(tagLists[type], string))) {
|
||||||
|
Reference in New Issue
Block a user