File: level.c

package info (click to toggle)
rplay 3.3.2-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,132 kB
  • sloc: ansic: 42,169; makefile: 1,282; perl: 742; tcl: 345; sh: 311; java: 220
file content (34 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (11)
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
#include <rplay.h>

static void event_callback(int fd, int event, char *line);

main(int argc, char **argv)
{
    char buf[RPTP_MAX_LINE];
    int fd;

    fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf));
    rptp_async_notify(fd, RPTP_EVENT_LEVEL | RPTP_EVENT_CLOSE, event_callback);
    rptp_main_loop();

    exit(0);
}

static void
event_callback(int fd, int event, char *line)
{
    static int i;
    int left, right;

    switch (event)
    {
    case RPTP_EVENT_LEVEL:
	left = atoi(rptp_parse(line, "left"));
	right = atoi(rptp_parse(0, "right"));
	printf("%3d %3d\n", left, right);
	break;

    case RPTP_EVENT_CLOSE:
	exit(0);
    }
}