update r18 plug adblock rule

This commit is contained in:
JamesonHuang
2016-02-16 15:48:49 +08:00
parent ac497e45c4
commit d388c17999
359 changed files with 729038 additions and 387521 deletions

View File

@ -0,0 +1,215 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief Asynchronous MPD connections
*
* This class provides a very basic interface to MPD connections. It
* does not know much about the MPD protocol, it does not know any
* specific MPD command.
*
* The constructor expects a socket descriptor which is already
* connected to MPD. The first thing it does is read the server's
* handshake code ("OK MPD 0.15.0").
*/
#ifndef MPD_ASYNC_H
#define MPD_ASYNC_H
#include <mpd/error.h>
#include <mpd/compiler.h>
#include <stdbool.h>
#include <stdarg.h>
/**
* Event bit mask for polling.
*/
enum mpd_async_event {
/** ready to read from the file descriptor */
MPD_ASYNC_EVENT_READ = 1,
/** ready to write to the file descriptor */
MPD_ASYNC_EVENT_WRITE = 2,
/** hangup detected */
MPD_ASYNC_EVENT_HUP = 4,
/** I/O error */
MPD_ASYNC_EVENT_ERROR = 8,
};
/**
* \struct mpd_async
*
* This opaque object represents an asynchronous connection to a MPD
* server. Call mpd_async_new() to create a new instance.
*/
struct mpd_async;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new asynchronous MPD connection, based on a stream socket
* connected with MPD.
*
* @param fd the socket file descriptor of the stream connection to MPD
* @return a mpd_async object, or NULL on out of memory
*/
mpd_malloc
struct mpd_async *
mpd_async_new(int fd);
/**
* Closes the socket and frees memory.
*/
void
mpd_async_free(struct mpd_async *async);
/**
* After an error has occurred, this function returns the error code.
* If no error has occurred, it returns #MPD_ERROR_SUCCESS.
*/
mpd_pure
enum mpd_error
mpd_async_get_error(const struct mpd_async *async);
/**
* If mpd_async_is_alive() returns false, this function returns the
* human readable error message which caused this. This message is
* optional, and may be NULL. The pointer is invalidated by
* mpd_async_free().
*
* For #MPD_ERROR_SERVER, the error message is encoded in UTF-8.
* #MPD_ERROR_SYSTEM obtains its error message from the operating
* system, and thus the locale's character set (and probably language)
* is used. Keep that in mind when you print error messages.
*/
mpd_pure
const char *
mpd_async_get_error_message(const struct mpd_async *async);
/**
* Returns the error code from the operating system; on most operating
* systems, this is the errno value. Calling this function is only
* valid if mpd_async_get_error() returned #MPD_ERROR_SYSTEM.
*
* May be 0 if the operating system did not specify an error code.
*/
mpd_pure
int
mpd_async_get_system_error(const struct mpd_async *async);
/**
* Returns the file descriptor which should be polled by the caller.
* Do not use the file descriptor for anything except polling! The
* file descriptor never changes during the lifetime of this
* #mpd_async object.
*/
mpd_pure
int
mpd_async_get_fd(const struct mpd_async *async);
/**
* Enables (or disables) TCP keepalives.
*
* Keepalives are enabled using the SO_KEEPALIVE socket option. They may be
* required for long-idled connections to persist on some networks that
* would otherwise terminate inactive TCP sessions.
*
* The default value is false.
*
* @param async the #mpd_async object
* @param keepalive whether TCP keepalives should be enabled
*
* @since libmpdclient 2.10
*/
void mpd_async_set_keepalive(struct mpd_async *async,
bool keepalive);
/**
* Returns a bit mask of events which should be polled for.
*/
mpd_pure
enum mpd_async_event
mpd_async_events(const struct mpd_async *async);
/**
* Call this function when poll() has returned events for this
* object's file descriptor. libmpdclient will attempt to perform I/O
* operations.
*
* @return false if the connection was closed due to an error
*/
bool
mpd_async_io(struct mpd_async *async, enum mpd_async_event events);
/**
* Appends a command to the output buffer.
*
* @param async the connection
* @param command the command name, followed by arguments, terminated by
* NULL
* @param args the argument list
* @return true on success, false if the buffer is full
*/
bool
mpd_async_send_command_v(struct mpd_async *async, const char *command,
va_list args);
/**
* Appends a command to the output buffer.
*
* @param async the connection
* @param command the command name, followed by arguments, terminated by
* NULL
* @return true on success, false if the buffer is full
*/
mpd_sentinel
bool
mpd_async_send_command(struct mpd_async *async, const char *command, ...);
/**
* Receives a line from the input buffer. The result will be
* null-terminated, without the newline character. The pointer is
* only valid until the next async function is called.
*
* @param async the connection
* @return a line on success, NULL otherwise
*/
mpd_malloc
char *
mpd_async_recv_line(struct mpd_async *async);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,87 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_AUDIO_FORMAT_H
#define MPD_AUDIO_FORMAT_H
#include <stdint.h>
enum {
/**
* 32 bit floating point samples.
*/
MPD_SAMPLE_FORMAT_FLOAT = 0xe0,
/**
* DSD samples.
*/
MPD_SAMPLE_FORMAT_DSD = 0xe1,
};
/**
* This structure describes the format of a raw PCM stream.
*/
struct mpd_audio_format {
/**
* The sample rate in Hz. A better name for this attribute is
* "frame rate", because technically, you have two samples per
* frame in stereo sound.
*/
uint32_t sample_rate;
/**
* The number of significant bits per sample. Samples are
* currently always signed. Supported values are 8, 16, 24,
* 32 and the special values #MPD_SAMPLE_FORMAT_FLOAT,
* #MPD_SAMPLE_FORMAT_DSD.
*
* @since libmpdclient 2.10 added support for #MPD_SAMPLE_FORMAT_FLOAT and
* #MPD_SAMPLE_FORMAT_DSD.
*/
uint8_t bits;
/**
* The number of channels. Only mono (1) and stereo (2) are
* fully supported currently.
*/
uint8_t channels;
/** reserved for future use */
uint16_t reserved0;
/** reserved for future use */
uint32_t reserved1;
};
#endif

View File

@ -0,0 +1,145 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_CAPABILITIES_H
#define MPD_CAPABILITIES_H
#include <mpd/recv.h>
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Requests a list of supported and allowed. Use
* mpd_recv_pair_named() to obtain the list of "command" pairs.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_allowed_commands(struct mpd_connection *connection);
/**
* Requests a list of supported commands which are not allowed for
* this connection. Use mpd_recv_pair_named() to obtain the list of
* "command" pairs.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_disallowed_commands(struct mpd_connection *connection);
/**
* Receives the next supported command. Call this in a loop after
* mpd_send_commands() or mpd_send_notcommands().
*
* Free the return value with mpd_return_pair().
*
* @param connection a #mpd_connection
* @returns a "command" pair, or NULL on error or if the end of the
* response is reached
*/
mpd_malloc
static inline struct mpd_pair *
mpd_recv_command_pair(struct mpd_connection *connection)
{
return mpd_recv_pair_named(connection, "command");
}
/**
* Requests a list of supported URL handlers in the form "scheme://",
* example: "http://". Use mpd_recv_pair_named() to obtain the list
* of "handler" pairs.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_list_url_schemes(struct mpd_connection *connection);
/**
* Receives one line of the mpd_send_urlhandlers() response.
*
* Free the return value with mpd_return_pair().
*
* @param connection a #mpd_connection
* @returns a "handler" pair, or NULL on error or if the end of the
* response is reached
*/
mpd_malloc
static inline struct mpd_pair *
mpd_recv_url_scheme_pair(struct mpd_connection *connection)
{
return mpd_recv_pair_named(connection, "handler");
}
/**
* Requests a list of supported tag types. Use mpd_recv_pair_named()
* to obtain the list of "tagtype" pairs.
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_list_tag_types(struct mpd_connection *connection);
/**
* Receives the next tag type name. Call this in a loop after
* mpd_send_tagtypes().
*
* Free the return value with mpd_return_pair().
*
* @param connection a #mpd_connection
* @returns a "tagtype" pair, or NULL on error or if the end of the
* response is reached
*/
mpd_malloc
static inline struct mpd_pair *
mpd_recv_tag_type_pair(struct mpd_connection *connection)
{
return mpd_recv_pair_named(connection, "tagtype");
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,75 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* This is a client library for the Music Player Daemon, written in C.
*
* You can choose one of several APIs, depending on your requirements:
*
* - struct mpd_async: a very low-level asynchronous API which knows
* the protocol syntax, but no specific commands
*
* - struct mpd_connection: a basic synchronous API which knows all
* MPD commands and parses all responses
*
* \author Max Kellermann (max@duempel.org)
*/
#ifndef MPD_CLIENT_H
#define MPD_CLIENT_H
#include <mpd/audio_format.h>
#include <mpd/capabilities.h>
#include <mpd/connection.h>
#include <mpd/database.h>
#include <mpd/directory.h>
#include <mpd/entity.h>
#include <mpd/idle.h>
#include <mpd/list.h>
#include <mpd/message.h>
#include <mpd/mixer.h>
#include <mpd/output.h>
#include <mpd/pair.h>
#include <mpd/password.h>
#include <mpd/player.h>
#include <mpd/playlist.h>
#include <mpd/queue.h>
#include <mpd/recv.h>
#include <mpd/response.h>
#include <mpd/search.h>
#include <mpd/send.h>
#include <mpd/settings.h>
#include <mpd/song.h>
#include <mpd/stats.h>
#include <mpd/status.h>
#include <mpd/sticker.h>
#include <mpd/version.h>
#endif

View File

@ -0,0 +1,64 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief Compiler specific definitions
*
* This file is not part of the official libmpdclient2 API. It
* provides access to gcc specific extensions.
*
*/
#ifndef MPD_COMPILER_H
#define MPD_COMPILER_H
#if !defined(SPARSE) && defined(__GNUC__) && __GNUC__ >= 3
/* GCC 4.x */
#define mpd_unused __attribute__((unused))
#define mpd_malloc __attribute__((malloc))
#define mpd_pure __attribute__((pure))
#define mpd_const __attribute__((const))
#define mpd_sentinel __attribute__((sentinel))
#define mpd_printf(a,b) __attribute__((format(printf, a, b)))
#else
/* generic C compiler */
#define mpd_unused
#define mpd_malloc
#define mpd_pure
#define mpd_const
#define mpd_sentinel
#define mpd_printf(a,b)
#endif
#endif

View File

@ -0,0 +1,283 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_CONNECTION_H
#define MPD_CONNECTION_H
#include <mpd/protocol.h>
#include <mpd/error.h>
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_async;
/**
* \struct mpd_connection
*
* This opaque object represents a connection to a MPD server. Call
* mpd_connection_new() to create a new instance. To free an
* instance, call mpd_connection_free().
*
* Error handling: most functions return a "bool" indicating success
* or failure. In this case, you may query the nature of the error
* with the functions mpd_connection_get_error(),
* mpd_connection_get_error_message(),
* mpd_connection_get_server_error().
*
* Some errors can be cleared by calling mpd_connection_clear_error(),
* like #MPD_ERROR_SERVER, #MPD_ERROR_ARGUMENT. Most others are
* fatal, and cannot be recovered, like #MPD_ERROR_CLOSED -
* mpd_connection_clear_error() returns false.
*
* Some functions like mpd_recv_pair() cannot differentiate between
* "end of response" and "error". If this function returns NULL, you
* have to check mpd_connection_get_error().
*/
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Opens a new connection to a MPD server. Both the name server
* lookup and the connect() call are done synchronously. After this
* function has returned, you should check if the connection was
* successful with mpd_connection_get_error().
*
* @param host the server's host name, IP address or Unix socket path.
* If the resolver returns more than one IP address for a host name,
* this functions tries all of them until one accepts the connection.
* NULL is allowed here, which will connect to the default host
* (using the MPD_HOST environment variable if present).
* @param port the TCP port to connect to, 0 for default port (using
* the MPD_PORT environment variable if present). If "host" is a Unix
* socket path, this parameter is ignored.
* @param timeout_ms the timeout in milliseconds, 0 for the default
* timeout (the environment variable MPD_TIMEOUT may specify a timeout
* in seconds); you may modify it later with
* mpd_connection_set_timeout()
* @return a mpd_connection object (which may have failed to connect),
* or NULL on out-of-memory
*
* @since libmpdclient 2.3 added support for #MPD_HOST, #MPD_PORT and
* #MPD_TIMEOUT.
*/
mpd_malloc
struct mpd_connection *
mpd_connection_new(const char *host, unsigned port, unsigned timeout_ms);
/**
* Creates a #mpd_connection object based on an existing asynchronous
* MPD connection. You should not continue to use the #mpd_async
* object. Note that mpd_connection_free() also frees your #mpd_async
* object!
*
* This function does not block at all, which is why you have to pass
* the welcome message to it.
*
* @param async a #mpd_async instance
* @param welcome the first line sent by MPD (the welcome message)
* @return a mpd_connection object, or NULL on out-of-memory
*/
mpd_malloc
struct mpd_connection *
mpd_connection_new_async(struct mpd_async *async, const char *welcome);
/**
* Close the connection and free all memory.
*
* @param connection the connection to MPD
*/
void mpd_connection_free(struct mpd_connection *connection);
/**
* Returns the settings which were used to connect to the server. May
* be NULL if the settings are not known.
*
* @since libmpdclient 2.4
*/
const struct mpd_settings *
mpd_connection_get_settings(const struct mpd_connection *connection);
/**
* Enables (or disables) TCP keepalives.
*
* Keepalives are enabled using the SO_KEEPALIVE socket option. They may be
* required for long-idled connections to persist on some networks that
* would otherwise terminate inactive TCP sessions.
*
* The default value is false.
*
* @param connection the connection to MPD
* @param keepalive whether TCP keepalives should be enabled
*
* @since libmpdclient 2.10
*/
void mpd_connection_set_keepalive(struct mpd_connection *connection,
bool keepalive);
/**
* Sets the timeout for synchronous operations. If the MPD server
* does not send a response during this time span, the operation is
* aborted by libmpdclient.
*
* The initial value is the one passed to mpd_connection_new(). If
* you have used mpd_connection_new_async(), then the default value is
* 30 seconds.
*
* @param connection the connection to MPD
* @param timeout_ms the desired timeout in milliseconds; must not be 0
*/
void mpd_connection_set_timeout(struct mpd_connection *connection,
unsigned timeout_ms);
/**
* Returns the file descriptor which should be polled by the caller.
* Do not use the file descriptor for anything except polling! The
* file descriptor never changes during the lifetime of this
* #mpd_connection object.
*/
mpd_pure
int
mpd_connection_get_fd(const struct mpd_connection *connection);
/**
* Returns the underlying #mpd_async object. This can be used to send
* commands asynchronously. During an asynchronous command, you must
* not use synchronous #mpd_connection functions until the
* asynchronous response has been finished.
*
* If an error occurs while using #mpd_async, you must close the
* #mpd_connection.
*/
mpd_pure
struct mpd_async *
mpd_connection_get_async(struct mpd_connection *connection);
/**
* Returns the libmpdclient error code. MPD_ERROR_SUCCESS means no
* error occurred.
*/
mpd_pure
enum mpd_error
mpd_connection_get_error(const struct mpd_connection *connection);
/**
* Returns the human-readable (English) libmpdclient error message.
* Calling this function is only valid if an error really occurred.
* Check with mpd_connection_get_error().
*
* For #MPD_ERROR_SERVER, the error message is encoded in UTF-8.
* #MPD_ERROR_SYSTEM obtains its error message from the operating
* system, and thus the locale's character set (and probably language)
* is used. Keep that in mind when you print error messages.
*/
mpd_pure
const char *
mpd_connection_get_error_message(const struct mpd_connection *connection);
/**
* Returns the error code returned from the server. Calling this
* function is only valid if mpd_connection_get_error() returned
* #MPD_ERROR_SERVER.
*/
mpd_pure
enum mpd_server_error
mpd_connection_get_server_error(const struct mpd_connection *connection);
/**
* Returns the location of the server error, i.e. an index within the
* command list. Calling this function is only valid in a command
* list response, and if mpd_connection_get_error() returned
* #MPD_ERROR_SERVER.
*
* @since libmpdclient 2.4
*/
mpd_pure
unsigned
mpd_connection_get_server_error_location(const struct mpd_connection *connection);
/**
* Returns the error code from the operating system; on most operating
* systems, this is the errno value. Calling this function is only
* valid if mpd_connection_get_error() returned #MPD_ERROR_SYSTEM.
*
* May be 0 if the operating system did not specify an error code.
*/
mpd_pure
int
mpd_connection_get_system_error(const struct mpd_connection *connection);
/**
* Attempts to recover from an error condition. This function must be
* called after a non-fatal error before you can continue using this
* object.
*
* @return true on success, false if the error is fatal and cannot be
* recovered
*/
bool
mpd_connection_clear_error(struct mpd_connection *connection);
/**
* Returns a three-tuple containing the major, minor and patch version
* of the MPD protocol.
*/
mpd_pure
const unsigned *
mpd_connection_get_server_version(const struct mpd_connection *connection);
/**
* Compares the MPD protocol version with the specified triple.
*
* @return -1 if the server is older, 1 if it is newer, 0 if it is
* equal
*/
mpd_pure
int
mpd_connection_cmp_server_version(const struct mpd_connection *connection,
unsigned major, unsigned minor,
unsigned patch);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,163 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief Database
*
* This file declares functions which query or update MPD's music
* database.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_DATABASE_H
#define MPD_DATABASE_H
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Get a recursive list of all directories, songs and playlist from
* MPD. They are returned without metadata. This is a rather
* expensive operation, because the response may be large.
*
* @param connection the connection to MPD
* @param path an optional base path for the query
* @return true on success, false on error
*/
bool
mpd_send_list_all(struct mpd_connection *connection, const char *path);
/**
* Like #mpd_send_list_all(), but return metadata. This operation is
* even more expensive, because the response is larger. If it is
* larger than a configurable server-side limit, MPD may disconnect
* you.
*
* To read the response, you may use mpd_recv_entity().
*
* @param connection the connection to MPD
* @param path an optional base path for the query
* @return true on success, false on error
*/
bool
mpd_send_list_all_meta(struct mpd_connection *connection, const char *path);
/**
* Get a list of all directories, songs and playlist in a directory
* from MPD, including metadata.
*
* To read the response, you may use mpd_recv_entity().
*
* @param connection the connection to MPD
* @param path the directory to be listed
* @return true on success, false on error
*/
bool
mpd_send_list_meta(struct mpd_connection *connection, const char *path);
/**
* Send "readcomments". Read the "comments" of a song file. This
* returns key/value pairs which can be read using mpd_recv_pair().
*
* @param connection the connection to MPD
* @param path the relative path of the song file within the music
* directory or an arbitrary file path starting with file:///
* @return true on success, false on error
*
* @since libmpdclient 2.9
*/
bool
mpd_send_read_comments(struct mpd_connection *connection, const char *path);
/**
* Instructs MPD to update the music database: find new files, remove
* deleted files, update modified files.
*
* @param connection the connection to MPD
* @param path optional path to update; if NULL, then all of the music
* directory is updated
* @return true on success, false on error
*/
bool
mpd_send_update(struct mpd_connection *connection, const char *path);
/**
* Like mpd_send_update(), but also rescans unmodified files.
*
* @param connection the connection to MPD
* @param path optional path to update; if NULL, then all of the music
* directory is updated
* @return true on success, false on error
*/
bool
mpd_send_rescan(struct mpd_connection *connection, const char *path);
/**
* Receives the id the of the update job which was submitted by
* mpd_send_update().
*
* @param connection the connection to MPD
* @return a positive job id on success, 0 on error
*/
unsigned
mpd_recv_update_id(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_update() and mpd_recv_update_id().
*
* @param connection the connection to MPD
* @param path optional path to update; if NULL, then all of the music
* directory is updated
* @return a positive job id on success, 0 on error
*/
unsigned
mpd_run_update(struct mpd_connection *connection, const char *path);
/**
* Like mpd_run_update(), but also rescans unmodified files.
*
* @param connection the connection to MPD
* @param path optional path to update; if NULL, then all of the music
* directory is updated
* @return a positive job id on success, 0 on error
*/
unsigned
mpd_run_rescan(struct mpd_connection *connection, const char *path);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,131 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_DIRECTORY_H
#define MPD_DIRECTORY_H
#include <mpd/compiler.h>
#include <stdbool.h>
#include <time.h>
struct mpd_pair;
struct mpd_connection;
/**
* \struct mpd_directory
*
* An opaque directory object. This is a container for more songs,
* directories or playlists.
*/
struct mpd_directory;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Duplicates a #mpd_directory object.
*
* @return the new object, or NULL on out of memory
*/
mpd_malloc
struct mpd_directory *
mpd_directory_dup(const struct mpd_directory *directory);
/**
* Free memory allocated by the #mpd_directory object.
*/
void mpd_directory_free(struct mpd_directory *directory);
/**
* Returns the path of this directory, relative to the MPD music
* directory. It does not begin with a slash.
*/
mpd_pure
const char *
mpd_directory_get_path(const struct mpd_directory *directory);
/**
* @return the POSIX UTC time stamp of the last modification, or 0 if
* that is unknown
*
* @since libmpdclient 2.9
*/
mpd_pure
time_t
mpd_directory_get_last_modified(const struct mpd_directory *directory);
/**
* Begins parsing a new directory.
*
* @param pair the first pair in this directory (name must be "directory")
* @return the new #mpd_entity object, or NULL on error (out of
* memory, or pair name is not "directory")
*/
mpd_malloc
struct mpd_directory *
mpd_directory_begin(const struct mpd_pair *pair);
/**
* Parses the pair, adding its information to the specified
* #mpd_directory object.
*
* @return true if the pair was parsed and added to the directory (or if
* the pair was not understood and ignored), false if this pair is the
* beginning of the next directory
*/
bool
mpd_directory_feed(struct mpd_directory *directory,
const struct mpd_pair *pair);
/**
* Receives the next directory from the MPD server.
*
* @return a #mpd_directory object, or NULL on error or if the directory list is
* finished
*/
mpd_malloc
struct mpd_directory *
mpd_recv_directory(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,168 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_ENTITY_H
#define MPD_ENTITY_H
#include <mpd/song.h>
#include <mpd/directory.h>
#include <mpd/client.h>
#include <mpd/compiler.h>
struct mpd_pair;
/**
* The type of a #mpd_entity object.
*/
enum mpd_entity_type {
/**
* The type of the entity received from MPD is not implemented
* in this version of libmpdclient.
*/
MPD_ENTITY_TYPE_UNKNOWN,
/**
* A directory (#mpd_directory) containing more entities.
*/
MPD_ENTITY_TYPE_DIRECTORY,
/**
* A song file (#mpd_song) which can be added to the playlist.
*/
MPD_ENTITY_TYPE_SONG,
/**
* A stored playlist (#mpd_playlist).
*/
MPD_ENTITY_TYPE_PLAYLIST,
};
/**
* \struct mpd_entity
*
* An "entity" is an object returned by commands like "lsinfo". It is
* an object wrapping all possible entity types.
*/
struct mpd_entity;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Releases an entity. This also frees the wrapped object.
*/
void
mpd_entity_free(struct mpd_entity *entity);
/**
* @return the type of this entity.
*/
mpd_pure
enum mpd_entity_type
mpd_entity_get_type(const struct mpd_entity *entity);
/**
* Obtains a pointer to the #mpd_directory object enclosed by this
* #mpd_entity. Calling this function is only allowed of
* mpd_entity_get_type() has returned #MPD_ENTITY_TYPE_DIRECTORY.
*
* @return the directory object
*/
mpd_pure
const struct mpd_directory *
mpd_entity_get_directory(const struct mpd_entity *entity);
/**
* Obtains a pointer to the #mpd_song object enclosed by this
* #mpd_entity. Calling this function is only allowed of
* mpd_entity_get_type() has returned #MPD_ENTITY_TYPE_SONG.
*
* @return the song object
*/
mpd_pure
const struct mpd_song *
mpd_entity_get_song(const struct mpd_entity *entity);
/**
* Obtains a pointer to the #mpd_playlist object enclosed by
* this #mpd_entity. Calling this function is only allowed of
* mpd_entity_get_type() has returned #MPD_ENTITY_TYPE_PLAYLIST.
*
* @return the directory object
*/
mpd_pure
const struct mpd_playlist *
mpd_entity_get_playlist(const struct mpd_entity *entity);
/**
* Begins parsing a new entity.
*
* @param pair the first pair in this entity
* @return the new #mpd_entity object, or NULL on error (out of memory)
*/
mpd_malloc
struct mpd_entity *
mpd_entity_begin(const struct mpd_pair *pair);
/**
* Parses the pair, adding its information to the specified
* #mpd_entity object.
*
* @return true if the pair was parsed and added to the entity (or if
* the pair was not understood and ignored), false if this pair is the
* beginning of the next entity
*/
bool
mpd_entity_feed(struct mpd_entity *entity, const struct mpd_pair *pair);
/**
* Receives the next entity from the MPD server.
*
* @return an entity object, or NULL on error or if the entity list is
* finished
*/
mpd_malloc
struct mpd_entity *
mpd_recv_entity(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,76 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h or
* mpd/async.h instead.
*/
#ifndef MPD_ERROR_H
#define MPD_ERROR_H
enum mpd_error {
/** no error */
MPD_ERROR_SUCCESS = 0,
/** out of memory */
MPD_ERROR_OOM,
/** a function was called with an unrecognized or invalid
argument */
MPD_ERROR_ARGUMENT,
/** a function was called which is not available in the
current state of libmpdclient */
MPD_ERROR_STATE,
/** timeout trying to talk to mpd */
MPD_ERROR_TIMEOUT,
/** system error */
MPD_ERROR_SYSTEM,
/** unknown host */
MPD_ERROR_RESOLVER,
/** malformed response received from MPD */
MPD_ERROR_MALFORMED,
/** connection closed by mpd */
MPD_ERROR_CLOSED,
/**
* The server has returned an error code, which can be queried
* with mpd_connection_get_server_error().
*/
MPD_ERROR_SERVER,
};
#endif

View File

@ -0,0 +1,206 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_IDLE_H
#define MPD_IDLE_H
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_pair;
struct mpd_connection;
/**
* This enum contains bit masks for all idle events.
*
* @since libmpdclient 2.5 added support for #MPD_IDLE_STICKER,
* #MPD_IDLE_SUBSCRIPTION and #MPD_IDLE_MESSAGE.
*/
enum mpd_idle {
/** song database has been updated*/
MPD_IDLE_DATABASE = 0x1,
/** a stored playlist has been modified, created, deleted or
renamed */
MPD_IDLE_STORED_PLAYLIST = 0x2,
/** the queue has been modified */
MPD_IDLE_QUEUE = 0x4,
/** deprecated, don't use */
MPD_IDLE_PLAYLIST = MPD_IDLE_QUEUE,
/** the player state has changed: play, stop, pause, seek, ... */
MPD_IDLE_PLAYER = 0x8,
/** the volume has been modified */
MPD_IDLE_MIXER = 0x10,
/** an audio output device has been enabled or disabled */
MPD_IDLE_OUTPUT = 0x20,
/** options have changed: crossfade, random, repeat, ... */
MPD_IDLE_OPTIONS = 0x40,
/** a database update has started or finished. */
MPD_IDLE_UPDATE = 0x80,
/** a sticker has been modified. */
MPD_IDLE_STICKER = 0x100,
/** a client has subscribed to or unsubscribed from a channel */
MPD_IDLE_SUBSCRIPTION = 0x200,
/** a message on a subscribed channel was received */
MPD_IDLE_MESSAGE = 0x400,
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Returns the name of the specified idle event.
*
* @param idle an idle event id
* @return the name, or NULL if that event is not known
*/
mpd_const
const char *
mpd_idle_name(enum mpd_idle idle);
/**
* Parses the name of an idle event.
*
* @param name an idle event name
* @return the id, or 0 if that event is not known
*/
mpd_pure
enum mpd_idle
mpd_idle_name_parse(const char *name);
/**
* Enters "idle" mode: MPD will stall the response until an event has
* occurred. Call mpd_send_noidle() to abort the idle mode, or
* mpd_recv_idle() to read the event mask (or synchronously wait for
* events).
*/
bool
mpd_send_idle(struct mpd_connection *connection);
/**
* Same as mpd_send_idle(), but listen only on specific events.
*
* @param connection the connection to MPD
* @param mask a bit mask of idle events; must not be 0
* @return a positive job id on success, 0 on error
*/
bool
mpd_send_idle_mask(struct mpd_connection *connection, enum mpd_idle mask);
/**
* Tells MPD to leave the "idle" mode. MPD will then respond with a
* list of events which have occurred (which may be empty). Call
* mpd_recv_idle() after that.
*/
bool
mpd_send_noidle(struct mpd_connection *connection);
/**
* Parses a "changed" pair, which is part of MPD's response to the
* "idle" command.
*
* @return an idle code, or 0 if the pair was not understood
*/
mpd_pure
enum mpd_idle
mpd_idle_parse_pair(const struct mpd_pair *pair);
/**
* Waits until MPD sends the list of idle events and returns it in a
* bit mask.
*
* @param connection the connection to MPD
* @param disable_timeout if true, then libmpdclients temporarily
* disables the configured timeout (see mpd_connection_set_timeout()):
* this function blocks forever, until either MPD sends a response, or
* an error occurs.
* @return the event bit mask, or 0 on error or if there were no
* events
*/
enum mpd_idle
mpd_recv_idle(struct mpd_connection *connection, bool disable_timeout);
/**
* Shortcut for mpd_send_idle() and mpd_recv_idle(). During
* mpd_recv_idle(), the configured timeout is disabled.
*
* @param connection the connection to MPD
* @return the event bit mask, or 0 on error
*/
enum mpd_idle
mpd_run_idle(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_idle_mask() and mpd_recv_idle(). During
* mpd_recv_idle(), the configured timeout is disabled.
*
* @param connection the connection to MPD
* @param mask a bit mask of idle events; must not be 0
* @return the event bit mask, or 0 on error
*/
enum mpd_idle
mpd_run_idle_mask(struct mpd_connection *connection, enum mpd_idle mask);
/**
* Shortcut for mpd_send_noidle() and mpd_recv_idle(). During
* mpd_recv_idle(), the configured timeout is not disabled.
*
* @param connection the connection to MPD
* @return the event bit mask, or 0 on error or if there were no
* events
*/
enum mpd_idle
mpd_run_noidle(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,84 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Functions for sending command lists.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_LIST_H
#define MPD_LIST_H
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Starts a command list, i.e. a group of pipelined commands which are
* transferred in one block. If one command fails, the rest of the
* command list is canceled.
*
* Note that there is no guarantee on atomicity.
*
* @param connection the connection to MPD
* @param discrete_ok tells MPD whether to acknowledge every list
* command with an "list_OK" response
* @return true on success
*/
bool
mpd_command_list_begin(struct mpd_connection *connection, bool discrete_ok);
/**
* Commits the command list, i.e. makes MPD execute all commands which
* were queued.
*
* Note: there is no way to cancel a command list once it is started.
* You may however close the socket connection.
*
* @param connection the connection to MPD
* @return true on success
*/
bool
mpd_command_list_end(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,241 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_MESSAGE_H
#define MPD_MESSAGE_H
#include <mpd/recv.h>
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_pair;
/**
* \struct mpd_message
*/
struct mpd_message;
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Begins parsing a new message.
*
* @param pair the first pair in this message (name must be "channel")
* @return the new #mpd_entity object, or NULL on error (out of
* memory, or pair name is not "channel")
*
* @since libmpdclient 2.5
*/
mpd_malloc
struct mpd_message *
mpd_message_begin(const struct mpd_pair *pair);
/**
* Parses the pair, adding its information to the specified
* #mpd_message object.
*
* @return true if the pair was parsed and added to the message (or if
* the pair was not understood and ignored), false if this pair is the
* beginning of the next message
*
* @since libmpdclient 2.5
*/
bool
mpd_message_feed(struct mpd_message *output, const struct mpd_pair *pair);
/**
* Frees a #mpd_message object.
*
* @since libmpdclient 2.5
*/
void
mpd_message_free(struct mpd_message *message);
/**
* Returns the channel name.
*
* @since libmpdclient 2.5
*/
mpd_pure
const char *
mpd_message_get_channel(const struct mpd_message *message);
/**
* Returns the message text.
*
* @since libmpdclient 2.5
*/
mpd_pure
const char *
mpd_message_get_text(const struct mpd_message *message);
/**
* Sends the "subscribe" command: subscribe to a message channel.
*
* @param connection the connection to MPD
* @param channel the channel name
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_send_subscribe(struct mpd_connection *connection, const char *channel);
/**
* Shortcut for mpd_send_subscribe() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param channel the channel name
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_run_subscribe(struct mpd_connection *connection, const char *channel);
/**
* Sends the "unsubscribe" command: unsubscribe from a message
* channel.
*
* @param connection the connection to MPD
* @param channel the channel name
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_send_unsubscribe(struct mpd_connection *connection, const char *channel);
/**
* Shortcut for mpd_send_unsubscribe() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param channel the channel name
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_run_unsubscribe(struct mpd_connection *connection, const char *channel);
/**
* Sends the "sendmessage" command: send a message to a channel.
*
* @param connection the connection to MPD
* @param channel the channel name
* @param text the message text
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_send_send_message(struct mpd_connection *connection,
const char *channel, const char *text);
/**
* Shortcut for mpd_send_send_message() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param channel the channel name
* @param text the message text
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_run_send_message(struct mpd_connection *connection,
const char *channel, const char *text);
/**
* Sends the "readmessages" command: send a message to a channel.
*
* @param connection the connection to MPD
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_send_read_messages(struct mpd_connection *connection);
/**
* Reads the next mpd_message from the MPD response. Free the return
* value with mpd_message_free().
*
* @return a mpd_message object on success, NULL on error or
* end-of-response
*
* @since libmpdclient 2.5
*/
mpd_malloc
struct mpd_message *
mpd_recv_message(struct mpd_connection *connection);
/**
* Sends the "channels" command: get a list of all channels.
*
* @param connection the connection to MPD
* @return true on success
*
* @since libmpdclient 2.5
*/
bool
mpd_send_channels(struct mpd_connection *connection);
/**
* Receives the next channel name. Call this in a loop after
* mpd_send_channels().
*
* Free the return value with mpd_return_pair().
*
* @param connection a #mpd_connection
* @returns a "channel" pair, or NULL on error or if the end of the
* response is reached
*
* @since libmpdclient 2.5
*/
mpd_malloc
static inline struct mpd_pair *
mpd_recv_channel_pair(struct mpd_connection *connection)
{
return mpd_recv_pair_named(connection, "channel");
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,96 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Functions for manipulating MPD's mixer controls.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_MIXER_H
#define MPD_MIXER_H
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Sets the volume of all output devices.
*
* @param connection the connection to MPD
* @param volume the volume, an integer between 0 and 100
* @return true on success, false on error
*/
bool
mpd_send_set_volume(struct mpd_connection *connection, unsigned volume);
/**
* Shortcut for mpd_send_set_volume() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param volume the volume, an integer between 0 and 100
* @return true on success, false on error
*/
bool
mpd_run_set_volume(struct mpd_connection *connection, unsigned volume);
/**
* Changes the volume of all output devices.
*
* @param connection the connection to MPD
* @param relative_volume the relative volume, an integer between -100 and 100
* @return true on success, false on error
*
* @since libmpdclient 2.9
*/
bool
mpd_send_change_volume(struct mpd_connection *connection, int relative_volume);
/**
* Shortcut for mpd_send_change_volume() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param relative_volume the relative volume, an integer between -100 and 100
* @return true on success, false on error
*
* @since libmpdclient 2.9
*/
bool
mpd_run_change_volume(struct mpd_connection *connection, int relative_volume);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,204 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_OUTPUT_H
#define MPD_OUTPUT_H
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_connection;
struct mpd_pair;
/**
* \struct mpd_output
*
* This type represents an audio output device on the MPD server.
*/
struct mpd_output;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Begins parsing a new #mpd_output.
*
* @param pair the first pair in this output (name is "outputid")
* @return the new #mpd_output object, or NULL on error (out of
* memory, or wrong pair name)
*/
mpd_malloc
struct mpd_output *
mpd_output_begin(const struct mpd_pair *pair);
/**
* Parses the pair, adding its information to the specified
* #mpd_output object.
*
* @return true if the pair was parsed and added to the output (or if
* the pair was not understood and ignored), false if this pair is the
* beginning of the next output
*/
bool
mpd_output_feed(struct mpd_output *output, const struct mpd_pair *pair);
/**
* Frees a mpd_output object returned from mpd_recv_output().
*/
void
mpd_output_free(struct mpd_output *output);
/**
* @return the id of the specified #mpd_output object
*/
mpd_pure
unsigned
mpd_output_get_id(const struct mpd_output *output);
/**
* @return the configured name of the specified #mpd_output object
*/
mpd_pure
const char *
mpd_output_get_name(const struct mpd_output *output);
/**
* @return true if this output is enabled
*/
mpd_pure
bool
mpd_output_get_enabled(const struct mpd_output *output);
/**
* Sends the "outputs" command to MPD. Call mpd_recv_output() to
* read the response.
*
* @param connection A valid and connected mpd_connection.
* @return true on success
*/
bool
mpd_send_outputs(struct mpd_connection *connection);
/**
* Reads the next mpd_output from the MPD response. Free the return
* value with mpd_output_free().
*
* @return a mpd_output object on success, NULL on error or
* end-of-response
*/
mpd_malloc
struct mpd_output *
mpd_recv_output(struct mpd_connection *connection);
/**
* Sends the "enableoutput" command to MPD.
*
* @param connection A valid and connected mpd_connection.
* @param output_id an identifier for the output device (see
* mpd_recv_output())
* @return true on success
*/
bool
mpd_send_enable_output(struct mpd_connection *connection, unsigned output_id);
/**
* Shortcut for mpd_send_enable_output() and mpd_response_finish().
*
* @param connection A valid and connected mpd_connection.
* @param output_id an identifier for the output device (see
* mpd_recv_output())
* @return true on success
*/
bool
mpd_run_enable_output(struct mpd_connection *connection, unsigned output_id);
/**
* Sends the "disableoutput" command to MPD.
*
* @param connection A valid and connected mpd_connection.
* @param output_id an identifier for the output device (see
* mpd_recv_output())
* @return true on success
*/
bool
mpd_send_disable_output(struct mpd_connection *connection, unsigned output_id);
/**
* Shortcut for mpd_send_disable_output() and mpd_response_finish().
*
* @param connection A valid and connected mpd_connection.
* @param output_id an identifier for the output device (see
* mpd_recv_output())
* @return true on success
*/
bool
mpd_run_disable_output(struct mpd_connection *connection, unsigned output_id);
/**
* Sends the "toggleoutput" command to MPD.
*
* @param connection a valid and connected mpd_connection.
* @param output_id an identifier for the output device (see
* mpd_recv_output())
* @return true on success
*
* @since libmpdclient 2.9
*/
bool
mpd_send_toggle_output(struct mpd_connection *connection, unsigned output_id);
/**
* Shortcut for mpd_send_toggle_output() and mpd_response_finish().
*
* @param connection a valid and connected mpd_connection.
* @param output_id an identifier for the output device (see
* mpd_recv_output())
* @return true on success
*
* @since libmpdclient 2.9
*/
bool
mpd_run_toggle_output(struct mpd_connection *connection, unsigned output_id);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,49 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef LIBMPDCLIENT_PAIR_H
#define LIBMPDCLIENT_PAIR_H
/**
* A name-value pair received from the MPD server.
*/
struct mpd_pair {
/** the name of the element */
const char *name;
/** the value of the element */
const char *value;
};
#endif

View File

@ -0,0 +1,181 @@
/* libmpdclient
(c) 2003-2015 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 LIBMPDCLIENT_PARSER_H
#define LIBMPDCLIENT_PARSER_H
#include <mpd/protocol.h>
#include <mpd/compiler.h>
#include <stdbool.h>
enum mpd_parser_result {
/**
* Response line was not understood.
*/
MPD_PARSER_MALFORMED,
/**
* MPD has returned "OK" or "list_OK" (check with
* mpd_parser_is_discrete()).
*/
MPD_PARSER_SUCCESS,
/**
* MPD has returned "ACK" with an error code. Call
* mpd_parser_get_server_error() to get the error code.
*/
MPD_PARSER_ERROR,
/**
* MPD has returned a name-value pair. Call
* mpd_parser_get_name() and mpd_parser_get_value().
*/
MPD_PARSER_PAIR,
};
/**
* \struct mpd_parser
*
* This opaque object is a low-level parser for the MPD protocol. You
* feed it with input lines, and it provides parsed representations.
*/
struct mpd_parser;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Allocates a new mpd_parser object. Returns NULL on error (out of
* memory).
*/
mpd_malloc
struct mpd_parser *
mpd_parser_new(void);
/**
* Frees a mpd_parser object.
*/
void
mpd_parser_free(struct mpd_parser *parser);
/**
* Feeds a line (without the trailing newline character) received from
* MPD / mpd_async_recv_line() into the parser.
*
* Note that the line parameter is writable, because the parser will
* modify it. The functions mpd_parser_get_name() and
* mpd_parser_get_value() will return pointers inside this buffer.
* This means that after passing the line to this function, you must
* not modify or free it, until the name and value pointers are not
* used anymore.
*
* @param parser the #mpd_parser object
* @param line a line received from the MPD server
* @return a result code indicating the type of line, or error
*/
enum mpd_parser_result
mpd_parser_feed(struct mpd_parser *parser, char *line);
/**
* Call this when mpd_parser_feed() has returned #MPD_PARSER_SUCCESS
* to find out whether this is an "OK" (false) or a "list_OK" (true)
* response.
*
* @param parser the #mpd_parser object
*/
mpd_pure
bool
mpd_parser_is_discrete(const struct mpd_parser *parser);
/**
* Call this when mpd_parser_feed() has returned #MPD_PARSER_ERROR to
* obtain the reason for the error.
*
* @param parser the #mpd_parser object
*/
mpd_pure
enum mpd_server_error
mpd_parser_get_server_error(const struct mpd_parser *parser);
/**
* On #MPD_PARSER_ERROR, this returns the number of the list command
* which failed. Don't call this outside of a command list.
*
* @param parser the #mpd_parser object
*/
mpd_pure
unsigned
mpd_parser_get_at(const struct mpd_parser *parser);
/**
* On #MPD_PARSER_ERROR, this returns the human readable error message
* returned by MPD (UTF-8).
*
* This returns a pointer into the line buffer passed to
* mpd_parser_feed(). It is valid as long as the buffer is not
* freed/modified.
*
* @param parser the #mpd_parser object
*/
mpd_pure
const char *
mpd_parser_get_message(const struct mpd_parser *parser);
/**
* On #MPD_PARSER_PAIR, this returns the name.
*
* This returns a pointer into the line buffer passed to
* mpd_parser_feed(). It is valid as long as the buffer is not
* freed/modified.
*
* @param parser the #mpd_parser object
*/
mpd_pure
const char *
mpd_parser_get_name(const struct mpd_parser *parser);
/**
* On #MPD_PARSER_PAIR, this returns the value.
*
* This returns a pointer into the line buffer passed to
* mpd_parser_feed(). It is valid as long as the buffer is not
* freed/modified.
*
* @param parser the #mpd_parser object
*/
mpd_pure
const char *
mpd_parser_get_value(const struct mpd_parser *parser);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,66 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Password authentication.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_PASSWORD_H
#define MPD_PASSWORD_H
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Sends the password to MPD, to gain more privileges.
*/
bool
mpd_send_password(struct mpd_connection *connection, const char *password);
/**
* Sends the password to MPD and receives its response.
*
* @return true on success, false on failure
*/
bool
mpd_run_password(struct mpd_connection *connection, const char *password);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,242 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Controlling playback.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_PLAYER_H
#define MPD_PLAYER_H
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_connection;
struct mpd_song;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Fetches the currently selected song (the song referenced by
* status->song and status->songid).
*/
bool
mpd_send_current_song(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_currentsong() and mpd_recv_song().
*
* @param connection the connection to MPD
* @return the current song, or NULL on error or if there is no
* current song
*/
mpd_malloc
struct mpd_song *
mpd_run_current_song(struct mpd_connection *connection);
/**
* Starts playing the current song from the beginning.
*
* @param connection the connection to MPD
*/
bool
mpd_send_play(struct mpd_connection *connection);
bool
mpd_run_play(struct mpd_connection *connection);
/**
* Starts playing the specified song from the beginning.
*
* @param song_pos the position of the song in the queue
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_send_play_pos(struct mpd_connection *connection, unsigned song_pos);
bool
mpd_run_play_pos(struct mpd_connection *connection, unsigned song_pos);
/**
* Starts playing the specified song from the beginning.
*
* @param connection the connection to MPD
* @param id the id of the song
* @return true on success, false on error
*/
bool
mpd_send_play_id(struct mpd_connection *connection, unsigned id);
bool
mpd_run_play_id(struct mpd_connection *connection, unsigned song_id);
bool
mpd_send_stop(struct mpd_connection *connection);
bool
mpd_run_stop(struct mpd_connection *connection);
/**
* Toggles the pause mode by sending "pause" without arguments.
*
* @param connection the connection to MPD
*/
bool
mpd_send_toggle_pause(struct mpd_connection *connection);
bool
mpd_run_toggle_pause(struct mpd_connection *connection);
bool
mpd_send_pause(struct mpd_connection *connection, bool mode);
bool
mpd_run_pause(struct mpd_connection *connection, bool mode);
bool
mpd_send_next(struct mpd_connection *connection);
bool
mpd_run_next(struct mpd_connection *connection);
bool
mpd_send_previous(struct mpd_connection *connection);
bool
mpd_run_previous(struct mpd_connection *connection);
/**
* Seeks the specified song.
*
* @param connection the connection to MPD
* @param song_pos the position of the song in the queue
* @param t the position within the song, in seconds
* @return true on success, false on error
*/
bool
mpd_send_seek_pos(struct mpd_connection *connection,
unsigned song_pos, unsigned t);
bool
mpd_run_seek_pos(struct mpd_connection *connection,
unsigned song_pos, unsigned t);
/**
* Seeks the specified song.
*
* @param connection the connection to MPD
* @param id the id of the song
* @param t the position within the song, in seconds
* @return true on success, false on error
*/
bool
mpd_send_seek_id(struct mpd_connection *connection, unsigned id, unsigned t);
bool
mpd_run_seek_id(struct mpd_connection *connection,
unsigned song_id, unsigned t);
bool
mpd_send_repeat(struct mpd_connection *connection, bool mode);
bool
mpd_run_repeat(struct mpd_connection *connection, bool mode);
bool
mpd_send_random(struct mpd_connection *connection, bool mode);
bool
mpd_run_random(struct mpd_connection *connection, bool mode);
bool
mpd_send_single(struct mpd_connection *connection, bool mode);
bool
mpd_run_single(struct mpd_connection *connection, bool mode);
bool
mpd_send_consume(struct mpd_connection *connection, bool mode);
bool
mpd_run_consume(struct mpd_connection *connection, bool mode);
bool
mpd_send_crossfade(struct mpd_connection *connection, unsigned seconds);
bool
mpd_run_crossfade(struct mpd_connection *connection, unsigned seconds);
/**
* @since libmpdclient 2.2
*/
bool
mpd_send_mixrampdb(struct mpd_connection *connection, float db);
/**
* @since libmpdclient 2.2
*/
bool
mpd_run_mixrampdb(struct mpd_connection *connection, float db);
/**
* @since libmpdclient 2.2
*/
bool
mpd_send_mixrampdelay(struct mpd_connection *connection, float seconds);
/**
* @since libmpdclient 2.2
*/
bool
mpd_run_mixrampdelay(struct mpd_connection *connection, float seconds);
/**
* @since libmpdclient 2.4
*/
bool
mpd_send_clearerror(struct mpd_connection *connection);
/**
* @since libmpdclient 2.4
*/
bool
mpd_run_clearerror(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,216 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Manipulate stored playlists.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef LIBMPDCLIENT_PLAYLIST_H
#define LIBMPDCLIENT_PLAYLIST_H
#include <mpd/compiler.h>
#include <stdbool.h>
#include <time.h>
struct mpd_pair;
struct mpd_connection;
/**
* \struct mpd_playlist
*
* An opaque representation for a playlist stored in MPD's
* playlist directory. Use the functions provided by this header to
* access the object's attributes.
*/
struct mpd_playlist;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Free memory allocated by the #mpd_playlist object.
*/
void
mpd_playlist_free(struct mpd_playlist *playlist);
/**
* Duplicates a #mpd_playlist object.
*
* @return the new object, or NULL on out of memory
*/
mpd_malloc
struct mpd_playlist *
mpd_playlist_dup(const struct mpd_playlist *playlist);
/**
* Returns the path name of this playlist file. It does not begin
* with a slash.
*/
mpd_pure
const char *
mpd_playlist_get_path(const struct mpd_playlist *playlist);
/**
* @return the POSIX UTC time stamp of the last modification, or 0 if
* that is unknown
*/
mpd_pure
time_t
mpd_playlist_get_last_modified(const struct mpd_playlist *playlist);
/**
* Begins parsing a new playlist.
*
* @param pair the first pair in this playlist (name must be
* "playlist")
* @return the new #mpd_entity object, or NULL on error (out of
* memory, or pair name is not "playlist")
*/
mpd_malloc
struct mpd_playlist *
mpd_playlist_begin(const struct mpd_pair *pair);
/**
* Parses the pair, adding its information to the specified
* #mpd_playlist object.
*
* @return true if the pair was parsed and added to the playlist (or if
* the pair was not understood and ignored), false if this pair is the
* beginning of the next playlist
*/
bool
mpd_playlist_feed(struct mpd_playlist *playlist, const struct mpd_pair *pair);
/**
* Obtain a list of stored playlists.
*
* @param connection the connection to MPD
* @return true on success, false on error
*
* @since libmpdclient 2.5
*/
bool
mpd_send_list_playlists(struct mpd_connection *connection);
/**
* Receives the next playlist from the MPD server.
*
* @return a #mpd_playlist object, or NULL on error or if the playlist list is
* finished
*/
mpd_malloc
struct mpd_playlist *
mpd_recv_playlist(struct mpd_connection *connection);
/**
* List the content of a stored playlist.
*
* @param connection the connection to MPD
* @param name the name of the playlist
* @return true on success, false on error
*/
bool
mpd_send_list_playlist(struct mpd_connection *connection, const char *name);
/**
* List the content, with full metadata, of a stored playlist.
*
* @param connection the connection to MPD
* @param name the name of the playlist
* @return true on success, false on error
*/
bool
mpd_send_list_playlist_meta(struct mpd_connection *connection, const char *name);
bool
mpd_send_playlist_clear(struct mpd_connection *connection, const char *name);
bool
mpd_run_playlist_clear(struct mpd_connection *connection, const char *name);
bool
mpd_send_playlist_add(struct mpd_connection *connection, const char *name,
const char *path);
bool
mpd_run_playlist_add(struct mpd_connection *connection,
const char *name, const char *path);
bool
mpd_send_playlist_move(struct mpd_connection *connection, const char *name,
unsigned from, unsigned to);
bool
mpd_send_playlist_delete(struct mpd_connection *connection, const char *name,
unsigned pos);
bool
mpd_run_playlist_delete(struct mpd_connection *connection,
const char *name, unsigned pos);
bool
mpd_send_save(struct mpd_connection *connection, const char *name);
bool
mpd_run_save(struct mpd_connection *connection, const char *name);
bool
mpd_send_load(struct mpd_connection *connection, const char *name);
bool
mpd_run_load(struct mpd_connection *connection, const char *name);
bool
mpd_send_rename(struct mpd_connection *connection,
const char *from, const char *to);
bool
mpd_run_rename(struct mpd_connection *connection,
const char *from, const char *to);
bool
mpd_send_rm(struct mpd_connection *connection, const char *name);
bool
mpd_run_rm(struct mpd_connection *connection, const char *name);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,57 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h or
* mpd/parser.h instead.
*/
#ifndef MPD_PROTOCOL_H
#define MPD_PROTOCOL_H
enum mpd_server_error {
MPD_SERVER_ERROR_UNK = -1,
MPD_SERVER_ERROR_NOT_LIST = 1,
MPD_SERVER_ERROR_ARG = 2,
MPD_SERVER_ERROR_PASSWORD = 3,
MPD_SERVER_ERROR_PERMISSION = 4,
MPD_SERVER_ERROR_UNKNOWN_CMD = 5,
MPD_SERVER_ERROR_NO_EXIST = 50,
MPD_SERVER_ERROR_PLAYLIST_MAX = 51,
MPD_SERVER_ERROR_SYSTEM = 52,
MPD_SERVER_ERROR_PLAYLIST_LOAD = 53,
MPD_SERVER_ERROR_UPDATE_ALREADY = 54,
MPD_SERVER_ERROR_PLAYER_SYNC = 55,
MPD_SERVER_ERROR_EXIST = 56,
};
#endif

View File

@ -0,0 +1,542 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Manipulate the queue (current playlist).
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_QUEUE_H
#define MPD_QUEUE_H
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Sends the "playlistinfo" command: list all songs in the queue
* including meta information.
*/
bool
mpd_send_list_queue_meta(struct mpd_connection *connection);
/**
* Like mpd_send_list_queue_meta(), but specifies a (position) range.
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
* @return true on success, false on error
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_send_list_queue_range_meta(struct mpd_connection *connection,
unsigned start, unsigned end);
/**
* Requests information (including tags) about one song in the
* playlist (command "playlistid").
*
* @param connection the connection to MPD
* @param pos the position of the requested song
*/
bool
mpd_send_get_queue_song_pos(struct mpd_connection *connection, unsigned pos);
/**
* Shortcut for mpd_send_get_queue_song_pos() and mpd_recv_song().
*
* @param connection the connection to MPD
* @param pos the position of the requested song
* @return the song at the specified position, or NULL on error
*/
mpd_malloc
struct mpd_song *
mpd_run_get_queue_song_pos(struct mpd_connection *connection, unsigned pos);
/**
* Requests information (including tags) about one song in the
* playlist (command "playlistid").
*
* @param connection the connection to MPD
* @param id the id of the requested song
*/
bool
mpd_send_get_queue_song_id(struct mpd_connection *connection, unsigned id);
/**
* Shortcut for mpd_send_get_queue_song_id() and mpd_recv_song().
*
* @param connection the connection to MPD
* @param id the id of the requested song
* @return the song at the specified id, or NULL on error
*/
mpd_malloc
struct mpd_song *
mpd_run_get_queue_song_id(struct mpd_connection *connection, unsigned id);
/**
* Request the queue changes from MPD since the specified version,
* including tags. The MPD command is called "plchanges".
*
* @param connection the connection to MPD
* @param version The playlist version you want the diff with.
* @return true on success, false on error
*/
bool
mpd_send_queue_changes_meta(struct mpd_connection *connection,
unsigned version);
/**
* A more bandwidth efficient version of the
* mpd_send_queue_changes_meta(). It only returns the position and id
* of changed songs. The MPD command is called "plchangesposid".
*
* @param connection A valid and connected mpd_connection.
* @param version The playlist version you want the diff with.
* @return true on success, false on error
*/
bool
mpd_send_queue_changes_brief(struct mpd_connection *connection,
unsigned version);
/**
* Receives a response element of mpd_send_queue_changes_brief().
*
* @param connection A valid and connected mpd_connection.
* @param position_r reference to the position of the changed song
* @param id_r reference to the id of the changed song
* @return true on success, false on error or if there are no more
* changes in this response
*/
bool
mpd_recv_queue_change_brief(struct mpd_connection *connection,
unsigned *position_r, unsigned *id_r);
/**
* Appends a song to the playlist.
*/
bool
mpd_send_add(struct mpd_connection *connection, const char *file);
/**
* Shortcut for mpd_send_add() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param uri the URI of the song to be added
* @return true on success, false on error
*/
bool
mpd_run_add(struct mpd_connection *connection, const char *uri);
/**
* Appends a song to the playlist, and returns its id.
*/
bool
mpd_send_add_id(struct mpd_connection *connection, const char *file);
/**
* Inserts a song into the playlist, and returns its id.
*
* @param connection the connection to MPD
* @param uri the URI of the song to be added
* @param to the desired position of the song
* @return true on success, false on error
*/
bool
mpd_send_add_id_to(struct mpd_connection *connection, const char *uri,
unsigned to);
/**
* Returns the id of the new song in the playlist. To be called after
* mpd_send_add_id().
*
* @return the new song id, -1 on error or if MPD did not send an id
*/
int
mpd_recv_song_id(struct mpd_connection *connection);
/**
* Executes the "addid" command and reads the response.
*
* @return the new song id, -1 on error or if MPD did not send an id
*/
int
mpd_run_add_id(struct mpd_connection *connection, const char *file);
/**
* Executes the "addid" command and reads the response.
*
* @param connection the connection to MPD
* @param uri the URI of the song to be added
* @param to the desired position of the song
* @return the new song id, -1 on error or if MPD did not send an id
*/
int
mpd_run_add_id_to(struct mpd_connection *connection, const char *uri,
unsigned to);
/**
* Deletes a song from the queue.
*
* @param connection the connection to MPD
* @param pos the position of the song to be deleted
*/
bool
mpd_send_delete(struct mpd_connection *connection, unsigned pos);
/**
* Shortcut for mpd_send_delete() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param pos the position of the song to be deleted
* @return true on success, false on error
*/
bool
mpd_run_delete(struct mpd_connection *connection, unsigned pos);
/**
* Deletes songs from the queue.
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
* @return true on success, false on error
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_send_delete_range(struct mpd_connection *connection,
unsigned start, unsigned end);
/**
* Shortcut for mpd_send_delete_range() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
* @return true on success, false on error
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_run_delete_range(struct mpd_connection *connection,
unsigned start, unsigned end);
/**
* Deletes a song from the queue.
*
* @param connection the connection to MPD
* @param id the id of the song to be deleted
*/
bool
mpd_send_delete_id(struct mpd_connection *connection, unsigned id);
/**
* Shortcut for mpd_send_delete_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param id the id of the song to be deleted
* @return true on success, false on error
*/
bool
mpd_run_delete_id(struct mpd_connection *connection, unsigned id);
/**
* Shuffles the queue.
*
* @param connection the connection to MPD
*/
bool
mpd_send_shuffle(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_shuffle() and mpd_response_finish().
*
* @param connection the connection to MPD
*/
bool
mpd_run_shuffle(struct mpd_connection *connection);
/**
* Shuffles a range within the queue.
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_send_shuffle_range(struct mpd_connection *connection, unsigned start, unsigned end);
/**
* Shortcut for mpd_send_shuffle_range() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_run_shuffle_range(struct mpd_connection *connection,
unsigned start, unsigned end);
/**
* Clear the queue.
*
* @param connection the connection to MPD
*/
bool
mpd_send_clear(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_clear() and mpd_response_finish().
*
* @param connection the connection to MPD
*/
bool
mpd_run_clear(struct mpd_connection *connection);
/**
* Moves a song within the queue.
*
* @param connection the connection to MPD
* @param from the source song position
* @param to the new position of the song
*/
bool
mpd_send_move(struct mpd_connection *connection, unsigned from, unsigned to);
/**
* Shortcut for mpd_send_move() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param from the source song position
* @param to the new position of the song
*/
bool
mpd_run_move(struct mpd_connection *connection, unsigned from, unsigned to);
/**
* Moves a song within the queue.
*
* @param connection the connection to MPD
* @param from the source song id
* @param to the new position of the song (not an id!)
*/
bool
mpd_send_move_id(struct mpd_connection *connection, unsigned from, unsigned to);
/**
* Shortcut for mpd_send_move_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param from the source song id
* @param to the new position of the song (not an id!)
*/
bool
mpd_run_move_id(struct mpd_connection *connection, unsigned from, unsigned to);
/**
* Moves a range of songs within the queue.
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
* @param to the new position of the song range
* @return true on success, false on error
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_send_move_range(struct mpd_connection *connection,
unsigned start, unsigned end, unsigned to);
/**
* Shortcut for mpd_send_move_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
* @param to the new position of the song range
* @return true on success, false on error
*
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_run_move_range(struct mpd_connection *connection,
unsigned start, unsigned end, unsigned to);
/**
* Swap the position of two songs in the queue.
*
* @param connection the connection to MPD
* @param pos1 the position of one song
* @param pos2 the position of the other song
*/
bool
mpd_send_swap(struct mpd_connection *connection, unsigned pos1, unsigned pos2);
/**
* Shortcut for mpd_send_swap() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param pos1 the position of one song
* @param pos2 the position of the other song
*/
bool
mpd_run_swap(struct mpd_connection *connection, unsigned pos1, unsigned pos2);
/**
* Swap the position of two songs in the queue.
*
* @param connection the connection to MPD
* @param id1 the id of one song
* @param id2 the id of the other song
*/
bool
mpd_send_swap_id(struct mpd_connection *connection, unsigned id1, unsigned id2);
/**
* Shortcut for mpd_send_swap_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param id1 the id of one song
* @param id2 the id of the other song
*/
bool
mpd_run_swap_id(struct mpd_connection *connection, unsigned id1, unsigned id2);
/**
* Change the priority of the specified song.
*
* @param connection the connection to MPD
* @param priority a number between 0 and 255
* @param position the position of the song
*
* @since libmpdclient 2.6
*/
bool
mpd_send_prio(struct mpd_connection *connection, int priority,
unsigned position);
/**
* Shortcut for mpd_send_prio() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param priority a number between 0 and 255
* @param position the position of the song
*
* @since libmpdclient 2.6
*/
bool
mpd_run_prio(struct mpd_connection *connection, int priority,
unsigned position);
/**
* Change the priority of a song range.
*
* @param connection the connection to MPD
* @param priority a number between 0 and 255
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
*
* @since libmpdclient 2.6
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_send_prio_range(struct mpd_connection *connection, int priority,
unsigned start, unsigned end);
/**
* Shortcut for mpd_send_prio_range() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param priority a number between 0 and 255
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* value "(unsigned)-1" makes the end of the range open
*
* @since libmpdclient 2.6
* @since libmpdclient 2.8 added support for "(unsigned)-1"
*/
bool
mpd_run_prio_range(struct mpd_connection *connection, int priority,
unsigned start, unsigned end);
/**
* Change the priority of the specified song.
*
* @param connection the connection to MPD
* @param priority a number between 0 and 255
* @param id the id of the song
*
* @since libmpdclient 2.6
*/
bool
mpd_send_prio_id(struct mpd_connection *connection, int priority,
unsigned id);
/**
* Shortcut for mpd_send_prio_id() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param priority a number between 0 and 255
* @param id the id of the song
*
* @since libmpdclient 2.6
*/
bool
mpd_run_prio_id(struct mpd_connection *connection, int priority,
unsigned id);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,88 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Receiving response lines from MPD.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_RECV_H
#define MPD_RECV_H
#include <mpd/compiler.h>
struct mpd_pair;
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Reads the next #mpd_pair from the server. Returns NULL if there
* are no more pairs.
*
* The caller must dispose the pair with either mpd_return_pair() or
* mpd_enqueue_pair().
*/
mpd_malloc
struct mpd_pair *
mpd_recv_pair(struct mpd_connection *connection);
/**
* Same as mpd_recv_pair(), but discards all pairs not matching the
* specified name.
*/
mpd_malloc
struct mpd_pair *
mpd_recv_pair_named(struct mpd_connection *connection, const char *name);
/**
* Indicates that the pair object is not needed anymore, and can be
* freed. You must free the previous #mpd_pair object before calling
* mpd_recv_pair() again.
*/
void
mpd_return_pair(struct mpd_connection *connection, struct mpd_pair *pair);
/**
* Unreads a #mpd_pair. You may unread only the one pair you just got
* from mpd_recv_pair(). Unreading the "NULL" pair is allowed, to
* allow you to call mpd_recv_pair() again at the end of a response.
*/
void
mpd_enqueue_pair(struct mpd_connection *connection, struct mpd_pair *pair);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,72 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_RESPONSE_H
#define MPD_RESPONSE_H
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Finishes the response and checks if the command was successful. If
* there are data pairs left, they are discarded.
*
* @return true on success, false on error
*/
bool
mpd_response_finish(struct mpd_connection *connection);
/**
* Finishes the response of the current list command. If there are
* data pairs left, they are discarded.
*
* @return true on success, false on error
*/
bool
mpd_response_next(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,254 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Search songs in the database or the queue.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_DB_H
#define MPD_DB_H
#include <mpd/connection.h>
#include <mpd/tag.h>
#include <mpd/compiler.h>
#include <stdbool.h>
#include <time.h>
/**
* This type is not yet used, it is reserved for a future protocol
* extension which will allow us to specify a comparison operator for
* constraints.
*/
enum mpd_operator {
/**
* The default search operator. If "exact" was passed as
* "true", then it means "full string comparison"; if false,
* then it means "search for substring".
*/
MPD_OPERATOR_DEFAULT,
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Search for songs in the database.
* Constraints may be specified with mpd_search_add_tag_constraint().
* Send the search command with mpd_search_commit(), and read the
* response items with mpd_recv_song().
*
* @param connection the connection to MPD
* @param exact if to match exact
* @return true on success, false on error
*/
bool
mpd_search_db_songs(struct mpd_connection *connection, bool exact);
/**
* Search for songs in the database and adds the result to the queue.
* Constraints may be specified with mpd_search_add_tag_constraint().
* Send the search command with mpd_search_commit().
*
* @param connection the connection to MPD
* @param exact if to match exact (only "true" supported by MPD 0.16)
* @return true on success, false on error
*/
bool
mpd_search_add_db_songs(struct mpd_connection *connection, bool exact);
/**
* Search for songs in the queue.
* Constraints may be specified with mpd_search_add_tag_constraint().
* Send the search command with mpd_search_commit(), and read the
* response items with mpd_recv_song().
*
* @param connection the connection to MPD
* @param exact if to match exact
* @return true on success, false on error
*/
bool
mpd_search_queue_songs(struct mpd_connection *connection, bool exact);
/**
* Obtains a list of unique tag values from the database.
* Constraints may be specified with mpd_search_add_tag_constraint().
* Send the search command with mpd_search_commit(), and read the
* response items with mpd_recv_pair_tag().
*
* @param connection the connection to MPD
* @param type The type of the tags to search for
* @return true on success, false on error
*/
bool
mpd_search_db_tags(struct mpd_connection *connection, enum mpd_tag_type type);
/**
* Gathers statistics on a set of songs in the database.
* Constraints may be specified with mpd_search_add_tag_constraint().
* Send the command with mpd_search_commit(), and read the response
* with mpd_recv_stats().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool mpd_count_db_songs(struct mpd_connection *connection);
/**
* Limit the search to a certain directory.
*
* @param connection a #mpd_connection
* @param oper reserved, pass #MPD_OPERATOR_DEFAULT
* @param value the URI relative to the music directory
* @return true on success, false on error
*
* @since libmpdclient 2.9
*/
bool
mpd_search_add_base_constraint(struct mpd_connection *connection,
enum mpd_operator oper,
const char *value);
/**
* Add a constraint on the song's URI.
*
* @param connection a #mpd_connection
* @param oper reserved, pass #MPD_OPERATOR_DEFAULT
* @param value The value of the constraint
* @return true on success, false on error
*/
bool
mpd_search_add_uri_constraint(struct mpd_connection *connection,
enum mpd_operator oper,
const char *value);
/**
* Add a constraint to a search limiting the value of a tag.
*
* @param connection a #mpd_connection
* @param oper reserved, pass #MPD_OPERATOR_DEFAULT
* @param type The tag type of the constraint
* @param value The value of the constraint
* @return true on success, false on error
*/
bool
mpd_search_add_tag_constraint(struct mpd_connection *connection,
enum mpd_operator oper,
enum mpd_tag_type type,
const char *value);
/**
* Add a constraint to a search, search for a value in any tag.
*
* @param connection a #mpd_connection
* @param oper reserved, pass #MPD_OPERATOR_DEFAULT
* @param value The value of the constraint
* @return true on success, false on error
*/
bool
mpd_search_add_any_tag_constraint(struct mpd_connection *connection,
enum mpd_operator oper,
const char *value);
/**
* Limit the search to files modified after the given time stamp.
*
* @param connection a #mpd_connection
* @param oper reserved, pass #MPD_OPERATOR_DEFAULT
* @param value the reference time stamp
* @return true on success, false on error
*
* @since libmpdclient 2.10
*/
bool
mpd_search_add_modified_since_constraint(struct mpd_connection *connection,
enum mpd_operator oper,
time_t value);
/**
* Request only a portion of the result set.
*
* @param connection a #mpd_connection
* @param oper reserved, pass #MPD_OPERATOR_DEFAULT
* @param type The tag type of the constraint
* @param value The value of the constraint
* @return true on success, false on error
*
* @since libmpdclient 2.10
*/
bool
mpd_search_add_window(struct mpd_connection *connection,
unsigned start, unsigned end);
/**
* Starts the real search with constraints added with
* mpd_search_add_constraint().
*
* @param connection the connection to MPD
* @return true on success, false on error
*/
bool
mpd_search_commit(struct mpd_connection *connection);
/**
* Cancels the search request before you have called
* mpd_search_commit(). Call this to clear the current search
* request.
*
* @param connection the connection to MPD
*/
void
mpd_search_cancel(struct mpd_connection *connection);
/**
* Same as mpd_recv_pair_named(), but the pair name is specified as
* #mpd_tag_type.
*
* @param connection the connection to MPD
* @param type the tag type you are looking for
* @return a pair, or NULL on error or if there are no more matching
* pairs in this response
*/
mpd_malloc
struct mpd_pair *
mpd_recv_pair_tag(struct mpd_connection *connection, enum mpd_tag_type type);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,64 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef LIBMPDCLIENT_SEND_H
#define LIBMPDCLIENT_SEND_H
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Sends a command with arguments to the MPD server. The argument
* list must be terminated with a NULL.
*
* @param connection the connection to the MPD server
* @param command the command to be sent
* @return true on success
*/
mpd_sentinel
bool
mpd_send_command(struct mpd_connection *connection, const char *command, ...);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,123 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Library to determine connection settings prior to calling
* mpd_connection_new().
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_SETTINGS_H
#define MPD_SETTINGS_H
#include <stdbool.h>
/**
* \struct mpd_settings
*
* An object which describes configurable connection settings.
*/
struct mpd_settings;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new #mpd_settings object. The values which are not
* passed by the caller are taken from environment variables.
*
* @param host the server's host name, IP address or Unix socket path.
* An address starting with '@' denotes an "abstract socket".
* NULL is allowed here, which will connect to the default host
* (using the MPD_HOST environment variable if present).
* @param port the TCP port to connect to, 0 for default port (using
* the MPD_PORT environment variable if present). If "host" is a Unix
* socket path, this parameter is ignored.
* @param timeout_ms the timeout in milliseconds, 0 for the default
* timeout (the environment variable MPD_TIMEOUT may specify a timeout
* in seconds)
* @param reserved reserved for future use, pass NULL
* @param password the password, or NULL to use the default (MPD_HOST
* before "@")
* @return a #mpd_settings object or NULL if out of memory
*
* @since libmpdclient 2.4
*/
struct mpd_settings *
mpd_settings_new(const char *host, unsigned port, unsigned timeout_ms,
const char *reserved, const char *password);
/**
* Releases a #mpd_settings object.
*
* @since libmpdclient 2.4
*/
void
mpd_settings_free(struct mpd_settings *settings);
/**
* Returns the host name (without password/port), or NULL if unknown.
*
* @since libmpdclient 2.4
*/
const char *
mpd_settings_get_host(const struct mpd_settings *settings);
/**
* Returns the port number, or 0 if not applicable.
*
* @since libmpdclient 2.4
*/
unsigned
mpd_settings_get_port(const struct mpd_settings *settings);
/**
* Returns the timeout in milliseconds, or 0 if unknown.
*
* @since libmpdclient 2.4
*/
unsigned
mpd_settings_get_timeout_ms(const struct mpd_settings *settings);
/**
* Returns the password, or NULL if none was configured.
*
* @since libmpdclient 2.4
*/
const char *
mpd_settings_get_password(const struct mpd_settings *settings);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,222 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_SONG_H
#define MPD_SONG_H
#include <mpd/tag.h>
#include <mpd/compiler.h>
#include <stdbool.h>
#include <time.h>
struct mpd_pair;
struct mpd_connection;
/**
* \struct mpd_song
*
* An opaque representation for a song in MPD's database or playlist.
* Use the functions provided by this header to access the object's
* attributes.
*/
struct mpd_song;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Free memory allocated by the #mpd_song object.
*/
void mpd_song_free(struct mpd_song *song);
/**
* Duplicates the specified #mpd_song object.
*
* @returns the copy, or NULL if out of memory
*/
mpd_malloc
struct mpd_song *
mpd_song_dup(const struct mpd_song *song);
/**
* Returns the URI of the song. This is either a path relative to the
* MPD music directory (without leading slash), or an URL with a
* scheme, e.g. a HTTP URL for a radio stream.
*/
mpd_pure
const char *
mpd_song_get_uri(const struct mpd_song *song);
/**
* Queries a tag value.
*
* @param song the song object
* @param type the tag type
* @param idx pass 0 to get the first value for this tag type. This
* argument may be used to iterate all values, until this function
* returns NULL
* @return the tag value, or NULL if this tag type (or this index)
* does not exist
*/
mpd_pure
const char *
mpd_song_get_tag(const struct mpd_song *song,
enum mpd_tag_type type, unsigned idx);
/**
* Returns the duration of this song in seconds. 0 means the duration
* is unknown.
*/
mpd_pure
unsigned
mpd_song_get_duration(const struct mpd_song *song);
/**
* Returns the duration of this song in milliseconds. 0 means the
* duration is unknown.
*
* @since libmpdclient 2.10
*/
mpd_pure
unsigned
mpd_song_get_duration_ms(const struct mpd_song *song);
/**
* Returns the start of the virtual song within the physical file in
* seconds.
*
* @since libmpdclient 2.3
*/
mpd_pure
unsigned
mpd_song_get_start(const struct mpd_song *song);
/**
* Returns the end of the virtual song within the physical file in
* seconds. Zero means that the physical song file is played to the
* end.
*
* @since libmpdclient 2.3
*/
mpd_pure
unsigned
mpd_song_get_end(const struct mpd_song *song);
/**
* @return the POSIX UTC time stamp of the last modification, or 0 if
* that is unknown
*/
mpd_pure
time_t
mpd_song_get_last_modified(const struct mpd_song *song);
/**
* Sets the position within the queue. This value is not used for
* songs which are not in the queue.
*
* This function is useful when applying the values returned by
* mpd_recv_queue_change_brief().
*/
void
mpd_song_set_pos(struct mpd_song *song, unsigned pos);
/**
* Returns the position of this song in the queue. The value is
* undefined if you did not obtain this song from the queue.
*/
mpd_pure
unsigned
mpd_song_get_pos(const struct mpd_song *song);
/**
* Returns the id of this song in the playlist. The value is
* undefined if you did not obtain this song from the queue.
*/
mpd_pure
unsigned
mpd_song_get_id(const struct mpd_song *song);
/**
* Returns the priority of this song in the playlist. The value is
* undefined if you did not obtain this song from the queue.
*
* @since libmpdclient 2.8
*/
mpd_pure
unsigned
mpd_song_get_prio(const struct mpd_song *song);
/**
* Begins parsing a new song.
*
* @param pair the first pair in this song (name must be "file")
* @return the new #mpd_entity object, or NULL on error (out of
* memory, or pair name is not "file")
*/
mpd_malloc
struct mpd_song *
mpd_song_begin(const struct mpd_pair *pair);
/**
* Parses the pair, adding its information to the specified
* #mpd_song object.
*
* @return true if the pair was parsed and added to the song (or if
* the pair was not understood and ignored), false if this pair is the
* beginning of the next song
*/
bool
mpd_song_feed(struct mpd_song *song, const struct mpd_pair *pair);
/**
* Receives the next song from the MPD server.
*
* @return a #mpd_song object, or NULL on error or if the song list is
* finished
*/
mpd_malloc
struct mpd_song *
mpd_recv_song(struct mpd_connection *connection);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,163 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_STATS_H
#define MPD_STATS_H
#include <mpd/compiler.h>
#include <stdbool.h>
struct mpd_connection;
struct mpd_pair;
/**
* \struct mpd_stats
*
* An opaque object representing MPD's response to the "stats"
* command. To release this object, call mpd_stats_free().
*/
struct mpd_stats;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Send the "stats" command to MPD.
*
* @return true on success
*/
bool
mpd_send_stats(struct mpd_connection *connection);
/**
* Begins parsing server stats: creates a new empty #mpd_stats object.
* Free it with mpd_stats_free().
*
* @return the newly allocated #mpd_stats object, or NULL if out of
* memory
*/
mpd_malloc
struct mpd_stats *
mpd_stats_begin(void);
/**
* Parses the pair, adding its information to the specified #mpd_stats
* object.
*/
void
mpd_stats_feed(struct mpd_stats *status, const struct mpd_pair *pair);
/**
* Reads the "stats" response from MPD.
*
* @return a #mpd_stats object, or NULL on error
*/
mpd_malloc
struct mpd_stats *
mpd_recv_stats(struct mpd_connection *connection);
/**
* Shortcut for mpd_send_stats() and mpd_recv_stats().
*/
mpd_malloc
struct mpd_stats *
mpd_run_stats(struct mpd_connection *connection);
/**
* Frees a #mpd_stats object.
*/
void mpd_stats_free(struct mpd_stats * stats);
/**
* @return the number of distinct artists in MPD's database, or 0 if
* unknown
*/
mpd_pure
unsigned
mpd_stats_get_number_of_artists(const struct mpd_stats * stats);
/**
* @return the number of distinct album names in MPD's database, or 0
* if unknown
*/
mpd_pure
unsigned
mpd_stats_get_number_of_albums(const struct mpd_stats * stats);
/**
* @return the total number of song files in MPD's database, or 0 if
* unknown
*/
mpd_pure
unsigned
mpd_stats_get_number_of_songs(const struct mpd_stats * stats);
/**
* @return the uptime of MPD in seconds, or 0 if unknown
*/
mpd_pure
unsigned long mpd_stats_get_uptime(const struct mpd_stats * stats);
/**
* @return the UNIX time stamp of the last database update, or 0 if
* unknown
*/
mpd_pure
unsigned long mpd_stats_get_db_update_time(const struct mpd_stats * stats);
/**
* @return the accumulated time MPD was playing music since the
* process was started, or 0 if unknown
*/
mpd_pure
unsigned long mpd_stats_get_play_time(const struct mpd_stats * stats);
/**
* @return the accumulated duration of all songs in the database, or 0
* if unknown
*/
mpd_pure
unsigned long mpd_stats_get_db_play_time(const struct mpd_stats * stats);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,309 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_STATUS_H
#define MPD_STATUS_H
#include <mpd/compiler.h>
#include <stdbool.h>
/**
* MPD's playback state.
*/
enum mpd_state {
/** no information available */
MPD_STATE_UNKNOWN = 0,
/** not playing */
MPD_STATE_STOP = 1,
/** playing */
MPD_STATE_PLAY = 2,
/** playing, but paused */
MPD_STATE_PAUSE = 3,
};
struct mpd_connection;
struct mpd_pair;
struct mpd_audio_format;
/**
* \struct mpd_status
*
* Holds information about MPD's status.
*/
struct mpd_status;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Begins parsing the server status: creates a new empty #mpd_status
* object. Free it with mpd_status_free().
*
* @return the newly allocated #mpd_status object, or NULL if out of
* memory
*/
mpd_malloc
struct mpd_status *
mpd_status_begin(void);
/**
* Parses the pair, adding its information to the specified
* #mpd_status object.
*/
void
mpd_status_feed(struct mpd_status *status, const struct mpd_pair *pair);
/**
* Sends the "status" command to MPD. Call mpd_recv_status() to read
* the response.
*
* @return true on success
*/
bool
mpd_send_status(struct mpd_connection *connection);
/**
* Receives a #mpd_status object from the server.
*
* @return the received #mpd_status object, or NULL on error
*/
mpd_malloc
struct mpd_status *
mpd_recv_status(struct mpd_connection *connection);
/**
* Executes the "status" command and reads the response.
*
* @return the #mpd_status object returned by the server, or NULL on
* error
*/
mpd_malloc
struct mpd_status *
mpd_run_status(struct mpd_connection *connection);
/**
* Releases a #mpd_status object.
*/
void mpd_status_free(struct mpd_status * status);
/**
* Returns the current volume: 0-100, or -1 when there is no volume
* support.
*/
mpd_pure
int mpd_status_get_volume(const struct mpd_status *status);
/**
* Returns true if repeat mode is on.
*/
mpd_pure
bool
mpd_status_get_repeat(const struct mpd_status *status);
/**
* Returns true if random mode is on.
*/
mpd_pure
bool
mpd_status_get_random(const struct mpd_status *status);
/**
* Returns true if single mode is on.
*/
mpd_pure
bool
mpd_status_get_single(const struct mpd_status *status);
/**
* Returns true if consume mode is on.
*/
mpd_pure
bool
mpd_status_get_consume(const struct mpd_status *status);
/**
* Returns the number of songs in the queue. If MPD did not
* specify that, this function returns 0.
*/
mpd_pure
unsigned
mpd_status_get_queue_length(const struct mpd_status *status);
/**
* Returns queue version number. You may use this to determine
* when the queue has changed since you have last queried it.
*/
mpd_pure
unsigned
mpd_status_get_queue_version(const struct mpd_status *status);
/**
* Returns the state of the player: either stopped, playing or paused.
*/
mpd_pure
enum mpd_state
mpd_status_get_state(const struct mpd_status *status);
/**
* Returns crossfade setting in seconds. 0 means crossfading is
* disabled.
*/
mpd_pure
unsigned
mpd_status_get_crossfade(const struct mpd_status *status);
/**
* Returns mixrampdb setting in db.
*
* @since libmpdclient 2.2
*/
mpd_pure
float
mpd_status_get_mixrampdb(const struct mpd_status *status);
/**
* Returns mixrampdelay setting in seconds. Negative means mixramp is
* disabled.
*
* @since libmpdclient 2.2
*/
mpd_pure
float
mpd_status_get_mixrampdelay(const struct mpd_status *status);
/**
* Returns the position of the currently playing song in the queue
* (beginning with 0) if a song is currently selected (always the case when
* state is PLAY or PAUSE). If there is no current song, -1 is returned.
*/
mpd_pure
int
mpd_status_get_song_pos(const struct mpd_status *status);
/**
* Returns the id of the current song. If there is no current song,
* -1 is returned.
*/
mpd_pure
int
mpd_status_get_song_id(const struct mpd_status *status);
/**
* The same as mpd_status_get_next_song_pos, but for the next song to be
* played.
*
* @since libmpdclient 2.7
*/
mpd_pure
int
mpd_status_get_next_song_pos(const struct mpd_status *status);
/**
* Returns the id of the next song to be played. If it is not known, -1 is
* returned.
*
* @since libmpdclient 2.7
*/
mpd_pure
int
mpd_status_get_next_song_id(const struct mpd_status *status);
/**
* Returns time in seconds that have elapsed in the currently playing/paused
* song
*/
mpd_pure
unsigned
mpd_status_get_elapsed_time(const struct mpd_status *status);
/**
* Returns time in milliseconds that have elapsed in the currently
* playing/paused song.
*
* @since libmpdclient 2.1
*/
mpd_pure
unsigned
mpd_status_get_elapsed_ms(const struct mpd_status *status);
/**
* Returns the length in seconds of the currently playing/paused song
*/
mpd_pure
unsigned
mpd_status_get_total_time(const struct mpd_status *status);
/**
* Returns current bit rate in kbps. 0 means unknown.
*/
mpd_pure
unsigned
mpd_status_get_kbit_rate(const struct mpd_status *status);
/**
* Returns audio format which MPD is currently playing. May return
* NULL if MPD is not playing or if the audio format is unknown.
*/
mpd_pure
const struct mpd_audio_format *
mpd_status_get_audio_format(const struct mpd_status *status);
/**
* Returns 1 if mpd is updating, 0 otherwise
*/
mpd_pure
unsigned
mpd_status_get_update_id(const struct mpd_status *status);
/**
* Returns the error message
*/
mpd_pure
const char *
mpd_status_get_error(const struct mpd_status *status);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,200 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Manipulate stickers.
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_STICKER_H
#define MPD_STICKER_H
#include <mpd/compiler.h>
#include <stdbool.h>
#include <stddef.h>
struct mpd_connection;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Adds or replaces a sticker value.
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param uri the URI of the object
* @param name the name of the sticker
* @param value the value of the sticker
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_send_sticker_set(struct mpd_connection *connection, const char *type,
const char *uri, const char *name, const char *value);
/**
* Shortcut for mpd_send_sticker_set() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param uri the URI of the object
* @param name the name of the sticker
* @param value the value of the sticker
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_run_sticker_set(struct mpd_connection *connection, const char *type,
const char *uri, const char *name, const char *value);
/**
* Deletes a sticker value.
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param uri the URI of the object
* @param name the name of the sticker
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_send_sticker_delete(struct mpd_connection *connection, const char *type,
const char *uri, const char *name);
/**
* Shortcut for mpd_send_sticker_delete() and mpd_response_finish().
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param uri the URI of the object
* @param name the name of the sticker
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_run_sticker_delete(struct mpd_connection *connection, const char *type,
const char *uri, const char *name);
/**
* Queries a sticker value. Call mpd_recv_sticker() to receive the response.
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param uri the URI of the object
* @param name the name of the sticker
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_send_sticker_get(struct mpd_connection *connection, const char *type,
const char *uri, const char *name);
/**
* Obtains a list of all stickers of the specified object. Call
* mpd_recv_sticker() to receive each response item.
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param uri the URI of the object
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_send_sticker_list(struct mpd_connection *connection, const char *type,
const char *uri);
/**
* Searches for stickers with the specified name.
*
* @param connection the connection to MPD
* @param type the object type, e.g. "song"
* @param base_uri the base URI to start the search, e.g. a directory;
* NULL to search for all objects of the specified type
* @param name the name of the sticker
* @return true on success, false on error
*
* @since libmpdclient 2.1
*/
bool
mpd_send_sticker_find(struct mpd_connection *connection, const char *type,
const char *base_uri, const char *name);
/**
* Parse a sticker input line in the form "name=value".
*
* @param input the input value, the value from a received pair named
* "sticker"
* @param name_length_r the length of the name (starting at the
* beginning of the input string) is returned here
* @return a pointer to the sticker value, or NULL on error
*
* @since libmpdclient 2.1
*/
const char *
mpd_parse_sticker(const char *input, size_t *name_length_r);
/**
* Receives the next sticker. You have to free the return value with
* mpd_return_sticker().
*
* @param connection the connection to MPD
* @return a #mpd_pair object on success, NULL on end of response or
* error
*
* @since libmpdclient 2.1
*/
mpd_malloc
struct mpd_pair *
mpd_recv_sticker(struct mpd_connection *connection);
/**
* Free the pair returned by mpd_recv_sticker().
*
* @since libmpdclient 2.1
*/
void
mpd_return_sticker(struct mpd_connection *connection, struct mpd_pair *pair);
#ifdef __cplusplus
}
#endif
#endif /* MPD_STICKER_H */

View File

@ -0,0 +1,106 @@
/* libmpdclient
(c) 2003-2015 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.
- Neither the name of the Music Player Daemon nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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 LIBMPDCLIENT_TAG_H
#define LIBMPDCLIENT_TAG_H
/**
* @since libmpdclient 2.10 added support for #MPD_TAG_MUSICBRAINZ_RELEASETRACKID.
* @since libmpdclient 2.11 added support for #MPD_TAG_ARTIST_SORT and #MPD_TAG_ALBUM_ARTIST_SORT.
*/
enum mpd_tag_type
{
/**
* Special value returned by mpd_tag_name_parse() when an
* unknown name was passed.
*/
MPD_TAG_UNKNOWN = -1,
MPD_TAG_ARTIST,
MPD_TAG_ARTIST_SORT,
MPD_TAG_ALBUM,
MPD_TAG_ALBUM_ARTIST,
MPD_TAG_ALBUM_ARTIST_SORT,
MPD_TAG_TITLE,
MPD_TAG_TRACK,
MPD_TAG_NAME,
MPD_TAG_GENRE,
MPD_TAG_DATE,
MPD_TAG_COMPOSER,
MPD_TAG_PERFORMER,
MPD_TAG_COMMENT,
MPD_TAG_DISC,
MPD_TAG_MUSICBRAINZ_ARTISTID,
MPD_TAG_MUSICBRAINZ_ALBUMID,
MPD_TAG_MUSICBRAINZ_ALBUMARTISTID,
MPD_TAG_MUSICBRAINZ_TRACKID,
MPD_TAG_MUSICBRAINZ_RELEASETRACKID,
MPD_TAG_COUNT
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Looks up the name of the specified tag.
*
* @return the name, or NULL if the tag type is not valid
*/
const char *
mpd_tag_name(enum mpd_tag_type type);
/**
* Parses a tag name, and returns its #mpd_tag_type value.
*
* @return a #mpd_tag_type value, or MPD_TAG_UNKNOWN if the name was
* not recognized
*/
enum mpd_tag_type
mpd_tag_name_parse(const char *name);
/**
* Same as mpd_tag_name_parse(), but ignores case.
*
* @return a #mpd_tag_type value, or MPD_TAG_UNKNOWN if the name was
* not recognized
*/
enum mpd_tag_type
mpd_tag_name_iparse(const char *name);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,58 @@
/* libmpdclient
(c) 2003-2015 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.
*/
/*! \file
* \brief MPD client library
*
* Do not include this header directly. Use mpd/client.h instead.
*/
#ifndef MPD_VERSION_H
#define MPD_VERSION_H
#define LIBMPDCLIENT_MAJOR_VERSION @MAJOR_VERSION@
#define LIBMPDCLIENT_MINOR_VERSION @MINOR_VERSION@
#define LIBMPDCLIENT_PATCH_VERSION @PATCH_VERSION@
/**
* Preprocessor macro which allows you to check which version of
* libmpdclient you are compiling with. It can be used in
* preprocessor directives.
*
* @return true if this libmpdclient version equals or is newer than
* the specified version number
* @since libmpdclient 2.1
*/
#define LIBMPDCLIENT_CHECK_VERSION(major, minor, patch) \
((major) < LIBMPDCLIENT_MAJOR_VERSION || \
((major) == LIBMPDCLIENT_MAJOR_VERSION && \
((minor) < LIBMPDCLIENT_MINOR_VERSION || \
((minor) == LIBMPDCLIENT_MINOR_VERSION && \
(patch) <= LIBMPDCLIENT_PATCH_VERSION))))
#endif