locate.h 2.24 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2011 The Music Player Daemon Project
3
 * http://www.musicpd.org
4 5 6 7 8 9 10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 19
 */

20 21
#ifndef MPD_LOCATE_H
#define MPD_LOCATE_H
22

23 24
#include "gcc.h"

25
#include <stdint.h>
26
#include <stdbool.h>
27 28 29 30

#define LOCATE_TAG_FILE_TYPE	TAG_NUM_OF_ITEM_TYPES+10
#define LOCATE_TAG_ANY_TYPE     TAG_NUM_OF_ITEM_TYPES+20

31 32
struct song;

33
/* struct used for search, find, list queries */
34
struct locate_item {
Max Kellermann's avatar
Max Kellermann committed
35
	int8_t tag;
36 37
	/* what we are looking for */
	char *needle;
38
};
39

40 41 42 43 44 45 46 47 48 49 50
/**
 * 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];
};

Max Kellermann's avatar
Max Kellermann committed
51 52
int
locate_parse_type(const char *str);
53

54 55 56 57 58 59 60
/**
 * Allocates a new struct locate_item_list, and initializes all
 * members with zero bytes.
 */
struct locate_item_list *
locate_item_list_new(unsigned length);

61
/* return number of items or -1 on error */
62
gcc_nonnull(1)
63 64
struct locate_item_list *
locate_item_list_parse(char *argv[], int argc);
65

66 67 68 69
/**
 * Duplicate the struct locate_item_list object and convert all
 * needles with g_utf8_casefold().
 */
70
gcc_nonnull(1)
71 72 73
struct locate_item_list *
locate_item_list_casefold(const struct locate_item_list *list);

74
gcc_nonnull(1)
Max Kellermann's avatar
Max Kellermann committed
75
void
76
locate_item_list_free(struct locate_item_list *list);
77

78
gcc_nonnull(1)
Max Kellermann's avatar
Max Kellermann committed
79 80
void
locate_item_free(struct locate_item *item);
81

82
gcc_nonnull(1,2)
83
bool
84 85
locate_song_search(const struct song *song,
		   const struct locate_item_list *criteria);
86

87
gcc_nonnull(1,2)
88
bool
89 90
locate_song_match(const struct song *song,
		   const struct locate_item_list *criteria);
91 92

#endif