Commit | Line | Data |
---|---|---|
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 | ||
24 | struct ev_source; | |
25 | ||
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 */ | |
29 | ||
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 */ | |
36 | ||
37 | void trackdb_master(struct ev_source *ev); | |
38 | /* start deadlock manager */ | |
39 | ||
40 | void trackdb_open(void); | |
41 | void trackdb_close(void); | |
42 | /* open/close track databases */ | |
43 | ||
44 | char **trackdb_stats(int *nstatsp); | |
45 | /* return a list of database stats */ | |
46 | ||
47 | int trackdb_set(const char *track, | |
48 | const char *name, | |
49 | const char *value); | |
50 | /* set a pref (remove if value=0). Return 0 t */ | |
51 | ||
52 | const char *trackdb_get(const char *track, | |
53 | const char *name); | |
54 | /* get a pref */ | |
55 | ||
56 | struct kvp *trackdb_get_all(const char *track); | |
57 | /* get all prefs */ | |
58 | ||
59 | const char *trackdb_resolve(const char *track); | |
60 | /* resolve alias - returns a null pointer if not found */ | |
61 | ||
62 | int trackdb_isalias(const char *track); | |
63 | /* return true if TRACK is an alias */ | |
64 | ||
65 | int trackdb_exists(const char *track); | |
66 | /* test whether a track exists (perhaps an alias) */ | |
67 | ||
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. */ | |
71 | ||
72 | char **trackdb_alltags(void); | |
73 | /* Return the list of all tags */ | |
74 | ||
75 | const char *trackdb_getpart(const char *track, | |
76 | const char *context, | |
77 | const char *part); | |
78 | /* get a track name part, like trackname_part(), but taking the database into | |
79 | * account. */ | |
80 | ||
81 | const char *trackdb_rawpath(const char *track); | |
82 | /* get the raw path name for TRACK (might be an alias); returns a null pointer | |
83 | * if not found. */ | |
84 | ||
85 | enum trackdb_listable { | |
86 | trackdb_files = 1, | |
87 | trackdb_directories = 2 | |
88 | }; | |
89 | ||
90 | char **trackdb_list(const char *dir, int *np, enum trackdb_listable what, | |
91 | const pcre *rec); | |
92 | /* Return the directories and/or files below DIR. If DIR is a null pointer | |
93 | * then concatenate the listing of all collections. | |
94 | * | |
95 | * If REC is not a null pointer then only names where the basename matches the | |
96 | * regexp are returned. | |
97 | */ | |
98 | ||
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. */ | |
102 | ||
103 | void trackdb_rescan(struct ev_source *ev); | |
104 | /* Start a rescan, if one is not running already */ | |
105 | ||
106 | int trackdb_rescan_cancel(void); | |
107 | /* interrupt any running rescan. Return 1 if one was running, else 0. */ | |
108 | ||
109 | void trackdb_gc(void); | |
110 | /* tidy up old database log files */ | |
111 | ||
112 | void trackdb_set_global(const char *name, | |
113 | const char *value, | |
114 | const char *who); | |
115 | /* set a global pref (remove if value=0). */ | |
116 | ||
117 | const char *trackdb_get_global(const char *name); | |
118 | /* get a global pref */ | |
119 | ||
2a10b70b RK |
120 | char **trackdb_new(int *ntracksp, int maxtracks); |
121 | ||
460b9539 | 122 | #endif /* TRACKDB_H */ |
123 | ||
124 | /* | |
125 | Local Variables: | |
126 | c-basic-offset:2 | |
127 | comment-column:40 | |
128 | fill-column:79 | |
129 | indent-tabs-mode:nil | |
130 | End: | |
131 | */ |