13 #include <netinet/in.h>
14 #include <sys/socket.h>
16 #define RECONNECTDELAY 3000 // ms
22 addr.sun_family = AF_UNIX;
23 strcpy(
addr.sun_path, DeviceName);
42 if ((
f = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) {
43 if (connect(
f, (
struct sockaddr *)&
addr,
sizeof(
addr)) >= 0)
73 int ret = ready ?
safe_read(
f, buf,
sizeof(buf)) : -1;
75 if (ready && ret <= 0 ) {
76 esyslog(
"ERROR: lircd connection broken, trying to reconnect every %.1f seconds",
float(
RECONNECTDELAY) / 1000);
82 isyslog(
"reconnected to lircd");
88 if (ready && ret > 0) {
92 if (sscanf(buf,
"%*x %x %29s", &count, KeyName) != 2) {
93 esyslog(
"ERROR: unparseable lirc command: %s", buf);
102 Put(LastKeyName,
false,
true);
103 strcpy(LastKeyName, KeyName);
116 timeout = Delta * 10 / 9;
120 Put(KeyName, repeat);
123 else if (pressed && repeat) {
124 Put(LastKeyName,
false,
true);