chiark / gitweb /
Convert track names and input lines to NFC. This is a database format
[disorder] / server / trackdb.h
... / ...
CommitLineData
1/*
2 * This file is part of DisOrder
3 * Copyright (C) 2005, 2006, 2007 Richard Kettlewell
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20
21#ifndef TRACKDB_H
22#define TRACKDB_H
23
24struct ev_source;
25
26/* Database version string */
27#define DBVERSION "2.0"
28
29extern const struct cache_type cache_files_type;
30extern unsigned long cache_files_hits, cache_files_misses;
31/* Cache entry type and tracking for regexp-based lookups */
32
33void trackdb_init(int recover);
34#define TRACKDB_NO_RECOVER 0
35#define TRACKDB_NORMAL_RECOVER 1
36#define TRACKDB_FATAL_RECOVER 2
37void trackdb_deinit(void);
38/* close/close environment */
39
40void trackdb_master(struct ev_source *ev);
41/* start deadlock manager */
42
43void trackdb_open(void);
44void trackdb_close(void);
45/* open/close track databases */
46
47char **trackdb_stats(int *nstatsp);
48/* return a list of database stats */
49
50void trackdb_stats_subprocess(struct ev_source *ev,
51 void (*done)(char *data, void *u),
52 void *u);
53/* collect stats in background and call done() with results */
54
55int trackdb_set(const char *track,
56 const char *name,
57 const char *value);
58/* set a pref (remove if value=0). Return 0 t */
59
60const char *trackdb_get(const char *track,
61 const char *name);
62/* get a pref */
63
64struct kvp *trackdb_get_all(const char *track);
65/* get all prefs */
66
67const char *trackdb_resolve(const char *track);
68/* resolve alias - returns a null pointer if not found */
69
70int trackdb_isalias(const char *track);
71/* return true if TRACK is an alias */
72
73int trackdb_exists(const char *track);
74/* test whether a track exists (perhaps an alias) */
75
76const char *trackdb_random(int tries);
77/* Pick a random non-alias track, making at most TRIES attempts. Returns a
78 * null pointer on failure. */
79
80char **trackdb_alltags(void);
81/* Return the list of all tags */
82
83const char *trackdb_getpart(const char *track,
84 const char *context,
85 const char *part);
86/* get a track name part, like trackname_part(), but taking the database into
87 * account. */
88
89const char *trackdb_rawpath(const char *track);
90/* get the raw path name for TRACK (might be an alias); returns a null pointer
91 * if not found. */
92
93enum trackdb_listable {
94 trackdb_files = 1,
95 trackdb_directories = 2
96};
97
98char **trackdb_list(const char *dir, int *np, enum trackdb_listable what,
99 const pcre *rec);
100/* Return the directories and/or files below DIR. If DIR is a null pointer
101 * then concatenate the listing of all collections.
102 *
103 * If REC is not a null pointer then only names where the basename matches the
104 * regexp are returned.
105 */
106
107char **trackdb_search(char **wordlist, int nwordlist, int *ntracks);
108/* return a list of tracks containing all of the words given. If you
109 * ask for only stopwords you get no tracks. */
110
111void trackdb_rescan(struct ev_source *ev);
112/* Start a rescan, if one is not running already */
113
114int trackdb_rescan_cancel(void);
115/* interrupt any running rescan. Return 1 if one was running, else 0. */
116
117void trackdb_gc(void);
118/* tidy up old database log files */
119
120void trackdb_set_global(const char *name,
121 const char *value,
122 const char *who);
123/* set a global pref (remove if value=0). */
124
125const char *trackdb_get_global(const char *name);
126/* get a global pref */
127
128char **trackdb_new(int *ntracksp, int maxtracks);
129
130void trackdb_expire_noticed(time_t when);
131
132#endif /* TRACKDB_H */
133
134/*
135Local Variables:
136c-basic-offset:2
137comment-column:40
138fill-column:79
139indent-tabs-mode:nil
140End:
141*/