/usr/include/mpd/async.h is in libmpdclient-dev 2.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | /* libmpdclient
(c) 2003-2010 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);
/**
* 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
|