aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/command.c16
-rw-r--r--src/dbUtils.c32
-rw-r--r--src/dbUtils.h23
-rw-r--r--src/locate.c24
-rw-r--r--src/locate.h20
-rw-r--r--src/playlist.c9
-rw-r--r--src/playlist.h6
7 files changed, 70 insertions, 60 deletions
diff --git a/src/command.c b/src/command.c
index 2000ecd26..911b6e8d8 100644
--- a/src/command.c
+++ b/src/command.c
@@ -34,6 +34,7 @@
#include "stored_playlist.h"
#include "ack.h"
#include "audio.h"
+#include "locate.h"
#include "dbUtils.h"
#include "tag.h"
#include "client.h"
@@ -832,8 +833,7 @@ static enum command_return
handle_find(struct client *client, int argc, char *argv[])
{
int ret;
-
- LocateTagItem *items;
+ struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1,
&items);
@@ -857,8 +857,7 @@ static enum command_return
handle_search(struct client *client, int argc, char *argv[])
{
int ret;
-
- LocateTagItem *items;
+ struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1,
&items);
@@ -882,8 +881,7 @@ static enum command_return
handle_count(struct client *client, int argc, char *argv[])
{
int ret;
-
- LocateTagItem *items;
+ struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1,
&items);
@@ -906,7 +904,7 @@ handle_count(struct client *client, int argc, char *argv[])
static enum command_return
handle_playlistfind(struct client *client, int argc, char *argv[])
{
- LocateTagItem *items;
+ struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1,
&items);
@@ -926,7 +924,7 @@ handle_playlistfind(struct client *client, int argc, char *argv[])
static enum command_return
handle_playlistsearch(struct client *client, int argc, char *argv[])
{
- LocateTagItem *items;
+ struct locate_item *items;
int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
argc - 1,
&items);
@@ -1114,7 +1112,7 @@ static enum command_return
handle_list(struct client *client, int argc, char *argv[])
{
int numConditionals;
- LocateTagItem *conditionals = NULL;
+ struct locate_item *conditionals = NULL;
int tagType = getLocateTagItemType(argv[1]);
int ret;
diff --git a/src/dbUtils.c b/src/dbUtils.c
index 709bca120..6bd0fe1af 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -17,7 +17,7 @@
*/
#include "dbUtils.h"
-
+#include "locate.h"
#include "directory.h"
#include "database.h"
#include "client.h"
@@ -36,12 +36,12 @@
typedef struct _ListCommandItem {
int8_t tagType;
int numConditionals;
- const LocateTagItem *conditionals;
+ const struct locate_item *conditionals;
} ListCommandItem;
typedef struct _LocateTagItemArray {
int numItems;
- const LocateTagItem *items;
+ const struct locate_item *items;
} LocateTagItemArray;
typedef struct _SearchStats {
@@ -86,13 +86,14 @@ searchInDirectory(struct song *song, void *_data)
return 0;
}
-int searchForSongsIn(struct client *client, const char *name,
- int numItems, const LocateTagItem * items)
+int
+searchForSongsIn(struct client *client, const char *name,
+ int numItems, const struct locate_item *items)
{
int ret;
int i;
- LocateTagItem *new_items =
- g_memdup(items, sizeof(LocateTagItem) * numItems);
+ struct locate_item *new_items =
+ g_memdup(items, sizeof(items[0]) * numItems);
struct search_data data;
for (i = 0; i < numItems; i++)
@@ -121,8 +122,9 @@ findInDirectory(struct song *song, void *_data)
return 0;
}
-int findSongsIn(struct client *client, const char *name,
- int numItems, const LocateTagItem * items)
+int
+findSongsIn(struct client *client, const char *name,
+ int numItems, const struct locate_item *items)
{
struct search_data data;
@@ -154,8 +156,9 @@ searchStatsInDirectory(struct song *song, void *data)
return 0;
}
-int searchStatsForSongsIn(struct client *client, const char *name,
- int numItems, const LocateTagItem * items)
+int
+searchStatsForSongsIn(struct client *client, const char *name,
+ int numItems, const struct locate_item *items)
{
SearchStats stats;
int ret;
@@ -226,8 +229,9 @@ int printInfoForAllIn(struct client *client, const char *name)
printDirectoryInDirectory, client);
}
-static ListCommandItem *newListCommandItem(int tagType, int numConditionals,
- const LocateTagItem * conditionals)
+static ListCommandItem *
+newListCommandItem(int tagType, int numConditionals,
+ const struct locate_item *conditionals)
{
ListCommandItem *item = g_new(ListCommandItem, 1);
@@ -288,7 +292,7 @@ listUniqueTagsInDirectory(struct song *song, void *_data)
}
int listAllUniqueTags(struct client *client, int type, int numConditionals,
- const LocateTagItem *conditionals)
+ const struct locate_item *conditionals)
{
int ret;
ListCommandItem *item = newListCommandItem(type, numConditionals,
diff --git a/src/dbUtils.h b/src/dbUtils.h
index c7302a1b2..b32f6f41a 100644
--- a/src/dbUtils.h
+++ b/src/dbUtils.h
@@ -19,9 +19,8 @@
#ifndef MPD_DB_UTILS_H
#define MPD_DB_UTILS_H
-#include "locate.h"
-
struct client;
+struct locate_item;
int printAllIn(struct client *client, const char *name);
@@ -31,19 +30,23 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file);
int printInfoForAllIn(struct client *client, const char *name);
-int searchForSongsIn(struct client *client, const char *name,
- int numItems, const LocateTagItem * items);
+int
+searchForSongsIn(struct client *client, const char *name,
+ int numItems, const struct locate_item * items);
-int findSongsIn(struct client *client, const char *name,
- int numItems, const LocateTagItem * items);
+int
+findSongsIn(struct client *client, const char *name,
+ int numItems, const struct locate_item * items);
-int searchStatsForSongsIn(struct client *client, const char *name,
- int numItems, const LocateTagItem * items);
+int
+searchStatsForSongsIn(struct client *client, const char *name,
+ int numItems, const struct locate_item * items);
unsigned long sumSongTimesIn(const char *name);
-int listAllUniqueTags(struct client *client, int type, int numConditiionals,
- const LocateTagItem *conditionals);
+int
+listAllUniqueTags(struct client *client, int type, int numConditiionals,
+ const struct locate_item *conditionals);
void printSavedMemoryFromFilenames(void);
diff --git a/src/locate.c b/src/locate.c
index a7804ea49..dbb73a861 100644
--- a/src/locate.c
+++ b/src/locate.c
@@ -53,7 +53,7 @@ int getLocateTagItemType(const char *str)
return -1;
}
-static int initLocateTagItem(LocateTagItem * item,
+static int initLocateTagItem(struct locate_item *item,
const char *typeStr, const char *needle)
{
item->tagType = getLocateTagItemType(typeStr);
@@ -66,9 +66,10 @@ static int initLocateTagItem(LocateTagItem * item,
return 0;
}
-LocateTagItem *newLocateTagItem(const char *typeStr, const char *needle)
+struct locate_item *
+newLocateTagItem(const char *typeStr, const char *needle)
{
- LocateTagItem *ret = g_new(LocateTagItem, 1);
+ struct locate_item *ret = g_new(struct locate_item, 1);
if (initLocateTagItem(ret, typeStr, needle) < 0) {
free(ret);
@@ -78,7 +79,7 @@ LocateTagItem *newLocateTagItem(const char *typeStr, const char *needle)
return ret;
}
-void freeLocateTagItemArray(int count, LocateTagItem * array)
+void freeLocateTagItemArray(int count, struct locate_item *array)
{
int i;
@@ -88,11 +89,12 @@ void freeLocateTagItemArray(int count, LocateTagItem * array)
free(array);
}
-int newLocateTagItemArrayFromArgArray(char *argArray[],
- int numArgs, LocateTagItem ** arrayRet)
+int
+newLocateTagItemArrayFromArgArray(char *argArray[],
+ int numArgs, struct locate_item **arrayRet)
{
int i, j;
- LocateTagItem *item;
+ struct locate_item *item;
if (numArgs == 0)
return 0;
@@ -100,7 +102,7 @@ int newLocateTagItemArrayFromArgArray(char *argArray[],
if (numArgs % 2 != 0)
return -1;
- *arrayRet = g_new(LocateTagItem, numArgs / 2);
+ *arrayRet = g_new(struct locate_item, numArgs / 2);
for (i = 0, item = *arrayRet; i < numArgs / 2; i++, item++) {
if (initLocateTagItem
@@ -120,7 +122,7 @@ fail:
return -1;
}
-void freeLocateTagItem(LocateTagItem * item)
+void freeLocateTagItem(struct locate_item *item)
{
free(item->needle);
free(item);
@@ -178,7 +180,7 @@ strstrSearchTag(const struct song *song, enum tag_type type, const char *str)
int
strstrSearchTags(const struct song *song, int numItems,
- const LocateTagItem *items)
+ const struct locate_item *items)
{
int i;
@@ -240,7 +242,7 @@ tagItemFoundAndMatches(const struct song *song, enum tag_type type,
int
tagItemsFoundAndMatches(const struct song *song, int numItems,
- const LocateTagItem * items)
+ const struct locate_item *items)
{
int i;
diff --git a/src/locate.h b/src/locate.h
index fbcc8831d..3ae70ceab 100644
--- a/src/locate.h
+++ b/src/locate.h
@@ -27,31 +27,33 @@
struct song;
/* struct used for search, find, list queries */
-typedef struct _LocateTagItem {
+struct locate_item {
int8_t tagType;
/* what we are looking for */
char *needle;
-} LocateTagItem;
+};
int getLocateTagItemType(const char *str);
/* returns NULL if not a known type */
-LocateTagItem *newLocateTagItem(const char *typeString, const char *needle);
+struct locate_item *
+newLocateTagItem(const char *typeString, const char *needle);
/* return number of items or -1 on error */
-int newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
- LocateTagItem ** arrayRet);
+int
+newLocateTagItemArrayFromArgArray(char *argArray[], int numArgs,
+ struct locate_item **arrayRet);
-void freeLocateTagItemArray(int count, LocateTagItem * array);
+void freeLocateTagItemArray(int count, struct locate_item *array);
-void freeLocateTagItem(LocateTagItem * item);
+void freeLocateTagItem(struct locate_item *item);
int
strstrSearchTags(const struct song *song, int numItems,
- const LocateTagItem * items);
+ const struct locate_item *items);
int
tagItemsFoundAndMatches(const struct song *song, int numItems,
- const LocateTagItem * items);
+ const struct locate_item *items);
#endif
diff --git a/src/playlist.c b/src/playlist.c
index 32e5bba78..d63180305 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -20,6 +20,7 @@
#include "playlist_save.h"
#include "queue_print.h"
#include "queue_save.h"
+#include "locate.h"
#include "player_control.h"
#include "command.h"
#include "ls.h"
@@ -1178,11 +1179,11 @@ enum playlist_result loadPlaylist(const char *utf8file)
void
searchForSongsInPlaylist(struct client *client,
- unsigned numItems, const LocateTagItem *items)
+ unsigned numItems, const struct locate_item *items)
{
unsigned i;
- LocateTagItem *new_items =
- g_memdup(items, sizeof(LocateTagItem) * numItems);
+ struct locate_item *new_items =
+ g_memdup(items, sizeof(items[0]) * numItems);
for (i = 0; i < numItems; i++)
new_items[i].needle = g_utf8_casefold(new_items[i].needle, -1);
@@ -1199,7 +1200,7 @@ searchForSongsInPlaylist(struct client *client,
void
findSongsInPlaylist(struct client *client,
- unsigned numItems, const LocateTagItem *items)
+ unsigned numItems, const struct locate_item *items)
{
for (unsigned i = 0; i < queue_length(&playlist.queue); i++) {
const struct song *song = queue_get(&playlist.queue, i);
diff --git a/src/playlist.h b/src/playlist.h
index 7fe10cb40..e05fe0530 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -19,7 +19,6 @@
#ifndef MPD_PLAYLIST_H
#define MPD_PLAYLIST_H
-#include "locate.h"
#include "queue.h"
#include <stdbool.h>
@@ -28,6 +27,7 @@
#define PLAYLIST_COMMENT '#'
struct client;
+struct locate_item;
enum playlist_result {
PLAYLIST_RESULT_SUCCESS,
@@ -177,11 +177,11 @@ void playlistVersionChange(void);
void
searchForSongsInPlaylist(struct client *client,
- unsigned numItems, const LocateTagItem *items);
+ unsigned numItems, const struct locate_item *items);
void
findSongsInPlaylist(struct client *client,
- unsigned numItems, const LocateTagItem *items);
+ unsigned numItems, const struct locate_item *items);
int is_valid_playlist_name(const char *utf8path);