aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/telephony-and-music/receive-or-make-call.c
blob: cdd7390f3e152b405fe01aaed291a5fd2f35b08e (plain) (blame)
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
#include <bus.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>

#define t(stmt)  if (stmt) goto fail



static char message[BUS_MEMORY_SIZE];



int main()
{
	bus_t bus;
	sprintf(message, "%ji force-pause", (intmax_t)getppid());
	/* Yes, PPID; in this example we pretend the shell is the telephony process. */
	t(bus_open(&bus, "/tmp/example-bus", BUS_WRONLY));
	t(bus_write(&bus, message));
	bus_close(&bus);
	return 0;

fail:
	perror("receive-or-make-call");
	bus_close(&bus);
	return 1;
}