include stdio include stdlib include libmpd libmpd include libmpd libm

 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
#include <stdio.h>
#include <stdlib.h>
#include <libmpd/libmpd.h>
#include <libmpd/libmpdclient.h>
#include <libmpd/debug_printf.h>
extern int debug_level;
void
error_callback(MpdObj *obj,
int errorid,
char *msg,
void *userdata)
{
}
void
status_changed(MpdObj *obj,
ChangedStatusType what)
{
}
int
main(int argc, char *argv[])
{
char *host = getenv("MPD_HOST");
char *port = getenv("MPD_PORT");
char *passwd = getenv("MPD_PASSWORD");
MpdObj *obj = NULL;
if (!host) host = "localhost";
int iport = (!port) ? 6600 : atoi(port);
// Establishing connection
obj = mpd_new(host, iport, passwd);
// Connecting signals
mpd_signal_connect_error(obj, (ErrorCallback) error_callback, NULL);
mpd_signal_connect_status_changed(obj, (StatusChangedCallback) status_changed, NULL);
// Timeout
mpd_set_connection_timeout(obj, 10);
mpd_free(obj);
return 0;
}