aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/playlist_vector.h')
-rw-r--r--src/playlist_vector.h49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/playlist_vector.h b/src/playlist_vector.h
index 62861ae49..0af6df8b4 100644
--- a/src/playlist_vector.h
+++ b/src/playlist_vector.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,15 +20,23 @@
#ifndef MPD_PLAYLIST_VECTOR_H
#define MPD_PLAYLIST_VECTOR_H
+#include "util/list.h"
+
#include <stdbool.h>
#include <stddef.h>
#include <sys/time.h>
+#define playlist_vector_for_each(pos, head) \
+ list_for_each_entry(pos, head, siblings)
+
+#define playlist_vector_for_each_safe(pos, n, head) \
+ list_for_each_entry_safe(pos, n, head, siblings)
+
/**
* A directory entry pointing to a playlist file.
*/
struct playlist_metadata {
- struct playlist_metadata *next;
+ struct list_head siblings;
/**
* The UTF-8 encoded name of the playlist file.
@@ -38,40 +46,35 @@ struct playlist_metadata {
time_t mtime;
};
-struct playlist_vector {
- struct playlist_metadata *head;
-};
-
-static inline void
-playlist_vector_init(struct playlist_vector *pv)
-{
- pv->head = NULL;
-}
-
void
-playlist_vector_deinit(struct playlist_vector *pv);
-
-static inline bool
-playlist_vector_is_empty(const struct playlist_vector *pv)
-{
- return pv->head == NULL;
-}
+playlist_vector_deinit(struct list_head *pv);
+/**
+ * Caller must lock the #db_mutex.
+ */
struct playlist_metadata *
-playlist_vector_find(struct playlist_vector *pv, const char *name);
+playlist_vector_find(struct list_head *pv, const char *name);
+/**
+ * Caller must lock the #db_mutex.
+ */
void
-playlist_vector_add(struct playlist_vector *pv,
+playlist_vector_add(struct list_head *pv,
const char *name, time_t mtime);
/**
+ * Caller must lock the #db_mutex.
+ *
* @return true if the vector or one of its items was modified
*/
bool
-playlist_vector_update_or_add(struct playlist_vector *pv,
+playlist_vector_update_or_add(struct list_head *pv,
const char *name, time_t mtime);
+/**
+ * Caller must lock the #db_mutex.
+ */
bool
-playlist_vector_remove(struct playlist_vector *pv, const char *name);
+playlist_vector_remove(struct list_head *pv, const char *name);
#endif /* SONGVEC_H */