aboutsummaryrefslogtreecommitdiffstats
path: root/src/locate.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-07 23:36:21 +0200
committerMax Kellermann <max@duempel.org>2012-08-07 23:52:11 +0200
commit3d2092ee23687aebaeafbabaf72ed7998d10206b (patch)
tree546c3e59cb95e42619a8b5ca3a433a95deceae5d /src/locate.c
parent8855efebc0488555b5a985589ee1f070c352c687 (diff)
downloadmpd-3d2092ee23687aebaeafbabaf72ed7998d10206b.tar.gz
mpd-3d2092ee23687aebaeafbabaf72ed7998d10206b.tar.xz
mpd-3d2092ee23687aebaeafbabaf72ed7998d10206b.zip
locate: make the structs opaque
Diffstat (limited to 'src/locate.c')
-rw-r--r--src/locate.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/locate.c b/src/locate.c
index 6a7002f2e..e966747fd 100644
--- a/src/locate.c
+++ b/src/locate.c
@@ -31,6 +31,24 @@
#define LOCATE_TAG_FILE_KEY_OLD "filename"
#define LOCATE_TAG_ANY_KEY "any"
+/* struct used for search, find, list queries */
+struct locate_item {
+ int8_t tag;
+ /* what we are looking for */
+ char *needle;
+};
+
+/**
+ * An array of struct locate_item objects.
+ */
+struct locate_item_list {
+ /** number of items */
+ unsigned length;
+
+ /** this is a variable length array */
+ struct locate_item items[1];
+};
+
int
locate_parse_type(const char *str)
{
@@ -74,18 +92,27 @@ locate_item_list_free(struct locate_item_list *list)
g_free(list);
}
-struct locate_item_list *
+static struct locate_item_list *
locate_item_list_new(unsigned length)
{
struct locate_item_list *list =
- g_malloc0(sizeof(*list) - sizeof(list->items[0]) +
- length * sizeof(list->items[0]));
+ g_malloc(sizeof(*list) - sizeof(list->items[0]) +
+ length * sizeof(list->items[0]));
list->length = length;
return list;
}
struct locate_item_list *
+locate_item_list_new_single(unsigned tag, const char *needle)
+{
+ struct locate_item_list *list = locate_item_list_new(1);
+ list->items[0].tag = tag;
+ list->items[0].needle = g_strdup(needle);
+ return list;
+}
+
+struct locate_item_list *
locate_item_list_parse(char *argv[], unsigned argc, bool fold_case)
{
if (argc == 0 || argc % 2 != 0)