*/
DB *trackdb_usersdb;
+/** @brief The playlists database
+ * - Keys are playlist names
+ * - Values are encoded key-value pairs
+ * - Data is user data and cannot be reconstructed
+ */
+DB *trackdb_playlistsdb;
+
static pid_t db_deadlock_pid = -1; /* deadlock manager PID */
static pid_t rescan_pid = -1; /* rescanner PID */
static int initialized, opened; /* state */
trackdb_noticeddb = open_db("noticed.db",
DB_DUPSORT, DB_BTREE, dbflags, 0666);
trackdb_scheduledb = open_db("schedule.db", 0, DB_HASH, dbflags, 0666);
- if(!trackdb_existing_database) {
+ trackdb_playlistsdb = open_db("playlists.db", 0, DB_HASH, dbflags, 0666);
+ if(!trackdb_existing_database && !(flags & TRACKDB_READ_ONLY)) {
/* Stash the database version */
char buf[32];
CLOSE("noticed.db", trackdb_noticeddb);
CLOSE("schedule.db", trackdb_scheduledb);
CLOSE("users.db", trackdb_usersdb);
+ CLOSE("playlists.db", trackdb_playlistsdb);
D(("closed databases"));
}
pid = subprogram(ev, p[1], "disorder-stats", (char *)0);
xclose(p[1]);
ev_child(ev, pid, 0, stats_finished, d);
- ev_reader_new(ev, p[0], stats_read, stats_error, d, "disorder-stats reader");
+ if(!ev_reader_new(ev, p[0], stats_read, stats_error, d,
+ "disorder-stats reader"))
+ fatal(0, "ev_reader_new for disorder-stats reader failed");
}
/** @brief Parse a track name part preference
choose_callback = callback;
choose_output.nvec = 0;
choose_complete = 0;
- ev_reader_new(ev, p[0], choose_readable, choose_read_error, 0,
- "disorder-choose reader"); /* owns p[0] */
+ if(!ev_reader_new(ev, p[0], choose_readable, choose_read_error, 0,
+ "disorder-choose reader")) /* owns p[0] */
+ fatal(0, "ev_reader_new for disorder-choose reader failed");
ev_child(ev, choose_pid, 0, choose_exited, 0); /* owns the subprocess */
return 0;
}
* Currently we only allow the letters and digits in ASCII. We could be more
* liberal than this but it is a nice simple test. It is critical that
* semicolons are never allowed.
+ *
+ * NB also used by playlist_parse_name() to validate playlist names!
*/
-static int valid_username(const char *user) {
+int valid_username(const char *user) {
if(!*user)
return 0;
while(*user) {