libmpdclient  2.7
mpd/async.h
Go to the documentation of this file.
00001 /* libmpdclient
00002    (c) 2003-2010 The Music Player Daemon Project
00003    This project's homepage is: http://www.musicpd.org
00004 
00005    Redistribution and use in source and binary forms, with or without
00006    modification, are permitted provided that the following conditions
00007    are met:
00008 
00009    - Redistributions of source code must retain the above copyright
00010    notice, this list of conditions and the following disclaimer.
00011 
00012    - Redistributions in binary form must reproduce the above copyright
00013    notice, this list of conditions and the following disclaimer in the
00014    documentation and/or other materials provided with the distribution.
00015 
00016    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00017    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00018    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00019    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00020    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00021    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00022    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00023    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 */
00028 
00041 #ifndef MPD_ASYNC_H
00042 #define MPD_ASYNC_H
00043 
00044 #include <mpd/error.h>
00045 #include <mpd/compiler.h>
00046 
00047 #include <stdbool.h>
00048 #include <stdarg.h>
00049 
00053 enum mpd_async_event {
00055         MPD_ASYNC_EVENT_READ = 1,
00056 
00058         MPD_ASYNC_EVENT_WRITE = 2,
00059 
00061         MPD_ASYNC_EVENT_HUP = 4,
00062 
00064         MPD_ASYNC_EVENT_ERROR = 8,
00065 };
00066 
00073 struct mpd_async;
00074 
00075 #ifdef __cplusplus
00076 extern "C" {
00077 #endif
00078 
00086 mpd_malloc
00087 struct mpd_async *
00088 mpd_async_new(int fd);
00089 
00093 void
00094 mpd_async_free(struct mpd_async *async);
00095 
00100 mpd_pure
00101 enum mpd_error
00102 mpd_async_get_error(const struct mpd_async *async);
00103 
00115 mpd_pure
00116 const char *
00117 mpd_async_get_error_message(const struct mpd_async *async);
00118 
00126 mpd_pure
00127 int
00128 mpd_async_get_system_error(const struct mpd_async *async);
00129 
00136 mpd_pure
00137 int
00138 mpd_async_get_fd(const struct mpd_async *async);
00139 
00143 mpd_pure
00144 enum mpd_async_event
00145 mpd_async_events(const struct mpd_async *async);
00146 
00154 bool
00155 mpd_async_io(struct mpd_async *async, enum mpd_async_event events);
00156 
00166 bool
00167 mpd_async_send_command_v(struct mpd_async *async, const char *command,
00168                          va_list args);
00169 
00178 mpd_sentinel
00179 bool
00180 mpd_async_send_command(struct mpd_async *async, const char *command, ...);
00181 
00190 mpd_malloc
00191 char *
00192 mpd_async_recv_line(struct mpd_async *async);
00193 
00194 #ifdef __cplusplus
00195 }
00196 #endif
00197 
00198 #endif