slack gksu fix
[pandora_liveinfo.git] / custom.c
CommitLineData
b7d8fc1a 1/*
2 * This file is licensed under the Creative Commons Zero License,
3 * version 1.0, available at
4 * http://creativecommons.org/publicdomain/zero/1.0/legalcode
5 */
6
7#include <stdio.h>
8#include <sys/types.h>
9#include <sys/socket.h>
10#include <sys/un.h>
11#include <unistd.h>
12
13/*
14 * example usage:
15 * ./custom "fps: 60"
16 */
17int main(int argc, char *argv[])
18{
19 static const char socket_name[] = "\0liveinfo";
20 struct sockaddr_un sun;
21 int sock;
22 int ret;
23
24 if (argv[1] == NULL) {
25 fprintf(stderr, "usage:\n%s \"label: value\"\n", argv[0]);
26 return 1;
27 }
28
29 sock = socket(PF_UNIX, SOCK_DGRAM, 0);
30 if (sock == -1) {
31 perror("socket PF_UNIX");
32 return 1;
33 }
34
35 memset(&sun, 0, sizeof(sun));
36 sun.sun_family = AF_UNIX;
37 memcpy(sun.sun_path, socket_name, sizeof(socket_name));
38
39 ret = sendto(sock, argv[1], strlen(argv[1]), 0,
40 (struct sockaddr *)&sun, sizeof(sun));
41 if (ret < 0) {
42 perror("sendto");
43 return 1;
44 }
45
46 close(sock);
47 return 0;
48}