-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.h
65 lines (55 loc) · 1.96 KB
/
index.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright (C) 2016 Mark Hills <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2, as published by the Free Software Foundation.
*
* 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 version 2 for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#ifndef INDEX_H
#define INDEX_H
#include <stddef.h>
#define SORT_ARTIST 0
#define SORT_BPM 1
#define SORT_PLAYLIST 2
#define SORT_END 3
struct record {
char *pathname, *artist, *title;
double bpm; /* or 0.0 if not known */
};
/* Index points to records, but does not manage those pointers */
struct index {
struct record **record;
size_t size, entries;
};
/* A 'compiled' search criteria, so we can repeat searches and
* matches efficiently */
struct match {
char buf[512];
char *words[32]; /* NULL-terminated array */
};
void index_init(struct index *ls);
void index_clear(struct index *ls);
void index_blank(struct index *ls);
void index_add(struct index *li, struct record *lr);
bool record_match(struct record *re, const struct match *h);
int index_copy(const struct index *src, struct index *dest);
void match_compile(struct match *h, const char *d);
int index_match(struct index *src, struct index *dest,
const struct match *match);
struct record* index_insert(struct index *ls, struct record *item,
int sort);
int index_reserve(struct index *i, unsigned int n);
size_t index_find(struct index *ls, struct record *item, int sort);
void index_debug(struct index *ls);
#endif