chiark / gitweb /
database upgrade tool. needs to be run manually.
[disorder] / server / trackdb.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder
78efa64e 3 * Copyright (C) 2005, 2006, 2007 Richard Kettlewell
460b9539 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
26extern const struct cache_type cache_files_type;
27extern unsigned long cache_files_hits, cache_files_misses;
28/* Cache entry type and tracking for regexp-based lookups */
29
30void trackdb_init(int recover);
31#define TRACKDB_NO_RECOVER 0
32#define TRACKDB_NORMAL_RECOVER 1
33#define TRACKDB_FATAL_RECOVER 2
34void trackdb_deinit(void);
35/* close/close environment */
36
37void trackdb_master(struct ev_source *ev);
38/* start deadlock manager */
39
3dc3d7db 40void trackdb_open(int dbupgrade);
460b9539 41void trackdb_close(void);
42/* open/close track databases */
43
44char **trackdb_stats(int *nstatsp);
45/* return a list of database stats */
46
d6dde5a3
RK
47void trackdb_stats_subprocess(struct ev_source *ev,
48 void (*done)(char *data, void *u),
49 void *u);
50/* collect stats in background and call done() with results */
51
460b9539 52int trackdb_set(const char *track,
53 const char *name,
54 const char *value);
55/* set a pref (remove if value=0). Return 0 t */
56
57const char *trackdb_get(const char *track,
58 const char *name);
59/* get a pref */
60
61struct kvp *trackdb_get_all(const char *track);
62/* get all prefs */
63
64const char *trackdb_resolve(const char *track);
65/* resolve alias - returns a null pointer if not found */
66
67int trackdb_isalias(const char *track);
68/* return true if TRACK is an alias */
69
70int trackdb_exists(const char *track);
71/* test whether a track exists (perhaps an alias) */
72
73const char *trackdb_random(int tries);
74/* Pick a random non-alias track, making at most TRIES attempts. Returns a
75 * null pointer on failure. */
76
77char **trackdb_alltags(void);
78/* Return the list of all tags */
79
80const char *trackdb_getpart(const char *track,
81 const char *context,
82 const char *part);
83/* get a track name part, like trackname_part(), but taking the database into
84 * account. */
85
86const char *trackdb_rawpath(const char *track);
87/* get the raw path name for TRACK (might be an alias); returns a null pointer
88 * if not found. */
89
90enum trackdb_listable {
91 trackdb_files = 1,
92 trackdb_directories = 2
93};
94
95char **trackdb_list(const char *dir, int *np, enum trackdb_listable what,
96 const pcre *rec);
97/* Return the directories and/or files below DIR. If DIR is a null pointer
98 * then concatenate the listing of all collections.
99 *
100 * If REC is not a null pointer then only names where the basename matches the
101 * regexp are returned.
102 */
103
104char **trackdb_search(char **wordlist, int nwordlist, int *ntracks);
105/* return a list of tracks containing all of the words given. If you
106 * ask for only stopwords you get no tracks. */
107
108void trackdb_rescan(struct ev_source *ev);
109/* Start a rescan, if one is not running already */
110
111int trackdb_rescan_cancel(void);
112/* interrupt any running rescan. Return 1 if one was running, else 0. */
113
114void trackdb_gc(void);
115/* tidy up old database log files */
116
117void trackdb_set_global(const char *name,
118 const char *value,
119 const char *who);
120/* set a global pref (remove if value=0). */
121
122const char *trackdb_get_global(const char *name);
123/* get a global pref */
124
2a10b70b
RK
125char **trackdb_new(int *ntracksp, int maxtracks);
126
1e64e9fb
RK
127void trackdb_expire_noticed(time_t when);
128
460b9539 129#endif /* TRACKDB_H */
130
131/*
132Local Variables:
133c-basic-offset:2
134comment-column:40
135fill-column:79
136indent-tabs-mode:nil
137End:
138*/