2 * This file is part of DisOrder
3 * Copyright (C) 2005, 2006 Richard Kettlewell
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.
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.
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
26 extern const struct cache_type cache_files_type;
27 extern unsigned long cache_files_hits, cache_files_misses;
28 /* Cache entry type and tracking for regexp-based lookups */
30 void trackdb_init(int recover);
31 #define TRACKDB_NO_RECOVER 0
32 #define TRACKDB_NORMAL_RECOVER 1
33 #define TRACKDB_FATAL_RECOVER 2
34 void trackdb_deinit(void);
35 /* close/close environment */
37 void trackdb_master(struct ev_source *ev);
38 /* start deadlock manager */
40 void trackdb_open(void);
41 void trackdb_close(void);
42 /* open/close track databases */
44 char **trackdb_stats(int *nstatsp);
45 /* return a list of database stats */
47 int trackdb_set(const char *track,
50 /* set a pref (remove if value=0). Return 0 t */
52 const char *trackdb_get(const char *track,
56 struct kvp *trackdb_get_all(const char *track);
59 const char *trackdb_resolve(const char *track);
60 /* resolve alias - returns a null pointer if not found */
62 int trackdb_isalias(const char *track);
63 /* return true if TRACK is an alias */
65 int trackdb_exists(const char *track);
66 /* test whether a track exists (perhaps an alias) */
68 const char *trackdb_random(int tries);
69 /* Pick a random non-alias track, making at most TRIES attempts. Returns a
70 * null pointer on failure. */
72 char **trackdb_alltags(void);
73 /* Return the list of all tags */
75 const char *trackdb_getpart(const char *track,
78 /* get a track name part, like trackname_part(), but taking the database into
81 const char *trackdb_rawpath(const char *track);
82 /* get the raw path name for TRACK (might be an alias); returns a null pointer
85 enum trackdb_listable {
87 trackdb_directories = 2
90 char **trackdb_list(const char *dir, int *np, enum trackdb_listable what,
92 /* Return the directories and/or files below DIR. If DIR is a null pointer
93 * then concatenate the listing of all collections.
95 * If REC is not a null pointer then only names where the basename matches the
96 * regexp are returned.
99 char **trackdb_search(char **wordlist, int nwordlist, int *ntracks);
100 /* return a list of tracks containing all of the words given. If you
101 * ask for only stopwords you get no tracks. */
103 void trackdb_rescan(struct ev_source *ev);
104 /* Start a rescan, if one is not running already */
106 int trackdb_rescan_cancel(void);
107 /* interrupt any running rescan. Return 1 if one was running, else 0. */
109 void trackdb_gc(void);
110 /* tidy up old database log files */
112 void trackdb_set_global(const char *name,
115 /* set a global pref (remove if value=0). */
117 const char *trackdb_get_global(const char *name);
118 /* get a global pref */
120 #endif /* TRACKDB_H */