Permalink
Browse files

command: moved database functions to database.c

  • Loading branch information...
1 parent 615f368 commit 699c0c9822bead172c380d0437c74330119ee971 @MaxKellermann MaxKellermann committed Sep 10, 2009
Showing with 151 additions and 81 deletions.
  1. +2 −0 Makefile.am
  2. +1 −0 include/mpd/client.h
  3. +0 −29 include/mpd/command.h
  4. +74 −0 include/mpd/database.h
  5. +0 −7 include/mpd/response.h
  6. +0 −30 src/command.c
  7. +74 −0 src/database.c
  8. +0 −15 src/response.c
View
@@ -8,6 +8,7 @@ mpdinclude_HEADERS = \
include/mpd/command.h \
include/mpd/connection.h \
include/mpd/cpos.h \
+ include/mpd/database.h \
include/mpd/directory.h \
include/mpd/entity.h \
include/mpd/error.h \
@@ -43,6 +44,7 @@ src_libmpdclient_la_SOURCES = \
src/command.c \
src/connection.c \
src/cpos.c \
+ src/database.c \
src/directory.c \
src/output.c \
src/coutput.c \
View
@@ -47,6 +47,7 @@
#include <mpd/connection.h>
#include <mpd/command.h>
+#include <mpd/database.h>
#include <mpd/directory.h>
#include <mpd/entity.h>
#include <mpd/list.h>
View
@@ -156,35 +156,6 @@ bool
mpd_send_rm(struct mpd_connection *connection, const char *name);
-/*
- * Music database commands
- *
- */
-
-/**
- * recursively fetches all songs/dir/playlists in "dir" (no metadata
- * is returned)
- */
-bool
-mpd_send_listall(struct mpd_connection *connection, const char *dir);
-
-/**
- * same as mpd_send_listall(), but also metadata is returned
- */
-bool
-mpd_send_listallinfo(struct mpd_connection *connection, const char *dir);
-
-
-/**
- * non-recursive version of mpd_send_listallinfo()
- */
-bool
-mpd_send_lsinfo(struct mpd_connection *connection, const char *dir);
-
-bool
-mpd_send_update(struct mpd_connection *connection, const char *path);
-
-
/*
* Mixer commands
*
View
@@ -0,0 +1,74 @@
+/* libmpdclient
+ (c) 2003-2009 The Music Player Daemon Project
+ This project's homepage is: http://www.musicpd.org
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef MPD_DATABASE_H
+#define MPD_DATABASE_H
+
+#include <stdbool.h>
+
+struct mpd_connection;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * recursively fetches all songs/dir/playlists in "dir" (no metadata
+ * is returned)
+ */
+bool
+mpd_send_listall(struct mpd_connection *connection, const char *dir);
+
+/**
+ * same as mpd_send_listall(), but also metadata is returned
+ */
+bool
+mpd_send_listallinfo(struct mpd_connection *connection, const char *dir);
+
+
+/**
+ * non-recursive version of mpd_send_listallinfo()
+ */
+bool
+mpd_send_lsinfo(struct mpd_connection *connection, const char *dir);
+
+bool
+mpd_send_update(struct mpd_connection *connection, const char *path);
+
+/**
+ * Receives the id the of the update job which was submitted by
+ * mpd_send_update().
+ */
+int
+mpd_recv_update_id(struct mpd_connection *connection);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
View
@@ -59,13 +59,6 @@ mpd_response_finish(struct mpd_connection *connection);
bool
mpd_response_next(struct mpd_connection *connection);
-/**
- * Receives the id the of the update job which was submitted by
- * mpd_send_update().
- */
-int
-mpd_recv_update_id(struct mpd_connection *connection);
-
/**
* Receives the next supported command. Call this in a loop after
* mpd_send_commands() or mpd_send_notcommands().
View
@@ -215,36 +215,6 @@ mpd_send_rm(struct mpd_connection *connection, const char *name)
}
-/*
- * Music database commands
- *
- */
-
-bool
-mpd_send_listall(struct mpd_connection *connection, const char *dir)
-{
- return mpd_send_command(connection, "listall", dir, NULL);
-}
-
-bool
-mpd_send_listallinfo(struct mpd_connection *connection, const char *dir)
-{
- return mpd_send_command(connection, "listallinfo", dir, NULL);
-}
-
-bool
-mpd_send_lsinfo(struct mpd_connection *connection, const char *dir)
-{
- return mpd_send_command(connection, "lsinfo", dir, NULL);
-}
-
-bool
-mpd_send_update(struct mpd_connection *connection, const char *path)
-{
- return mpd_send_command(connection, "update", path, NULL);
-}
-
-
/*
* Mixer commands
*
View
@@ -0,0 +1,74 @@
+/* libmpdclient
+ (c) 2003-2009 The Music Player Daemon Project
+ This project's homepage is: http://www.musicpd.org
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <mpd/database.h>
+#include <mpd/send.h>
+#include <mpd/recv.h>
+#include <mpd/pair.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+
+bool
+mpd_send_listall(struct mpd_connection *connection, const char *dir)
+{
+ return mpd_send_command(connection, "listall", dir, NULL);
+}
+
+bool
+mpd_send_listallinfo(struct mpd_connection *connection, const char *dir)
+{
+ return mpd_send_command(connection, "listallinfo", dir, NULL);
+}
+
+bool
+mpd_send_lsinfo(struct mpd_connection *connection, const char *dir)
+{
+ return mpd_send_command(connection, "lsinfo", dir, NULL);
+}
+
+bool
+mpd_send_update(struct mpd_connection *connection, const char *path)
+{
+ return mpd_send_command(connection, "update", path, NULL);
+}
+
+int
+mpd_recv_update_id(struct mpd_connection *connection)
+{
+ struct mpd_pair *pair;
+ int ret = 0;
+
+ pair = mpd_recv_pair_named(connection, "updating_db");
+ if (pair != NULL) {
+ ret = atoi(pair->value);
+ mpd_return_pair(connection, pair);
+ }
+
+ return ret;
+}
View
@@ -106,21 +106,6 @@ mpd_response_next(struct mpd_connection *connection)
return true;
}
-int
-mpd_recv_update_id(struct mpd_connection *connection)
-{
- struct mpd_pair *pair;
- int ret = 0;
-
- pair = mpd_recv_pair_named(connection, "updating_db");
- if (pair != NULL) {
- ret = atoi(pair->value);
- mpd_return_pair(connection, pair);
- }
-
- return ret;
-}
-
char *
mpd_recv_command_name(struct mpd_connection *connection)
{

0 comments on commit 699c0c9

Please sign in to comment.