LIRC libraries Linux Infrared Remote Control

Loading...
Searching...
No Matches
lirc_client.h
Go to the documentation of this file.
1/****************************************************************************
2** lirc_client.h ***********************************************************
3****************************************************************************
4*
5* Copyright (C) 1998 Trent Piepho <xyzzy@u.washington.edu>
6* Copyright (C) 1998 Christoph Bartelmus <lirc@bartelmus.de>
7*
8*/
9
109#ifndef LIRC_CLIENT_H
110#define LIRC_CLIENT_H
111
112#include <errno.h>
113#include <stdarg.h>
114#include <stddef.h>
115#include <stdint.h>
116#include <stdio.h>
117#include <stdlib.h>
118#include <string.h>
119#include <syslog.h>
120#include <unistd.h>
121
122#include "lirc/paths.h"
123#include "lirc/lirc_config.h"
124#include "lirc/curl_poll.h"
125
126#ifdef __cplusplus
127 extern "C" {
128#endif
129
130
131#define LIRC_RET_SUCCESS (0)
132#define LIRC_RET_ERROR (-1)
133
134#define LIRC_ALL ((char*)(-1))
135
136
137 enum lirc_flags { none = 0x00,
138 once = 0x01,
139 quit = 0x02,
140 mode = 0x04,
141 ecno = 0x08,
142 startup_mode = 0x10,
143 toggle_reset = 0x20, };
144
145 struct lirc_list {
146 char* string;
147 struct lirc_list* next;
148};
149
150 struct lirc_code {
151 char* remote;
152 char* button;
153 struct lirc_code* next;
154};
155
156 struct lirc_config {
157 char* lircrc_class;
158 char* current_mode;
159 struct lirc_config_entry* next;
160 struct lirc_config_entry* first;
161
162 int sockfd;
163};
164
165 struct lirc_config_entry {
166 char* prog;
167 struct lirc_code* code;
168 unsigned int rep_delay;
169 unsigned int ign_first_events;
170 unsigned int rep;
171 struct lirc_list* config;
172 char* change_mode;
173 unsigned int flags;
174
175 char* mode;
176 struct lirc_list* next_config;
177 struct lirc_code* next_code;
178
179 struct lirc_config_entry* next;
180};
181
188 typedef struct {
189 char packet[PACKET_SIZE + 1];
190 char buffer[PACKET_SIZE + 1];
191 char reply[PACKET_SIZE + 1];
192 int head;
193 int reply_to_stdout;
194 char* next;
195} lirc_cmd_ctx;
196
204 int lirc_init(const char* prog, int verbose);
205
207 void lirc_set_verbose(int verbose);
208
213 int lirc_deinit(void);
214
229 int lirc_readconfig(const char* path,
230 struct lirc_config** config,
231 int (check) (char* s));
232
234 void lirc_freeconfig(struct lirc_config* config);
235
237 char* lirc_nextir(void);
238
240 char* lirc_ir2char(struct lirc_config* config, char* code);
241
251 int lirc_nextcode(char** code);
252
264 int lirc_code2char(struct lirc_config* config, char* code, char** string);
265
266
267/* new interface for client daemon */
280 int lirc_readconfig_only(const char* file,
281 struct lirc_config** config,
282 int (check) (char* s));
283
284 int lirc_code2charprog(struct lirc_config* config,
285 char* code,
286 char** string,
287 char** prog);
288
297 size_t lirc_getsocketname(const char* id, char* buf, size_t size);
298
307 const char* lirc_getmode(struct lirc_config* config);
308
318 const char* lirc_setmode(struct lirc_config* config, const char* mode);
319
320/* 0.9.2: New interface for sending data. */
321
332 int lirc_command_init(lirc_cmd_ctx* ctx, const char* fmt, ...);
333
334
345 int lirc_command_run(lirc_cmd_ctx* ctx, int fd);
346
353 void lirc_command_reply_to_stdout(lirc_cmd_ctx* ctx);
354
367 int lirc_send_one(int fd, const char* remote, const char* keysym);
368
369
385 int lirc_simulate(int fd,
386 const char* remote,
387 const char* keysym,
388 int scancode,
389 int repeat);
390
391
402 int lirc_get_remote_socket(const char* address, int port, int quiet);
403
404
415 int lirc_get_local_socket(const char* path, int quiet);
416
417
421#ifdef __cplusplus
422}
423#endif
424
425#endif
lirc_send_one
int lirc_send_one(int fd, const char *remote, const char *keysym)
Send keysym using given remote.
Definition lirc_client.c:1995
lirc_get_local_socket
int lirc_get_local_socket(const char *path, int quiet)
Return an opened and connected file descriptor to local lirc socket.
Definition lirc_client.c:2056
lirc_nextir
char * lirc_nextir(void)
Definition lirc_client.c:1861
lirc_command_init
int lirc_command_init(lirc_cmd_ctx *ctx, const char *fmt,...)
Initiate a lirc_cmd_ctx to run a command.
Definition lirc_client.c:110
lirc_setmode
const char * lirc_setmode(struct lirc_config *config, const char *mode)
Set mode defined in lircrc.
Definition lirc_client.c:1967
lirc_deinit
int lirc_deinit(void)
Release resources allocated by lirc_init(), basically disconnect from socket.
Definition lirc_client.c:365
lirc_set_verbose
void lirc_set_verbose(int verbose)
Dynamically change the verbose level defined by lirc_init().
Definition lirc_client.c:384
lirc_readconfig
int lirc_readconfig(const char *path, struct lirc_config **config, int(check)(char *s))
Parse a lircrc configuration file.
Definition lirc_client.c:1447
lirc_ir2char
char * lirc_ir2char(struct lirc_config *config, char *code)
Definition lirc_client.c:1726
lirc_freeconfig
void lirc_freeconfig(struct lirc_config *config)
Deallocate an object retrieved using lirc_readconfig().
Definition lirc_client.c:1534
lirc_get_remote_socket
int lirc_get_remote_socket(const char *address, int port, int quiet)
Return an opened and connected file descriptor to remote lirc socket.
Definition lirc_client.c:2078
lirc_command_run
int lirc_command_run(lirc_cmd_ctx *ctx, int fd)
Run a command in non-blocking mode.
Definition lirc_client.c:190
lirc_code2char
int lirc_code2char(struct lirc_config *config, char *code, char **string)
Translate a code string to an application string using .lircrc.
Definition lirc_client.c:1813
lirc_readconfig_only
int lirc_readconfig_only(const char *file, struct lirc_config **config, int(check)(char *s))
Parse a lircrc configuration file without connecting to lircrcd.
Definition lirc_client.c:1526
lirc_getmode
const char * lirc_getmode(struct lirc_config *config)
Get mode defined in lircrc.
Definition lirc_client.c:1946
lirc_getsocketname
size_t lirc_getsocketname(const char *id, char *buf, size_t size)
Retrieve default lircrcd socket path.
Definition lirc_client.c:1937
lirc_command_reply_to_stdout
void lirc_command_reply_to_stdout(lirc_cmd_ctx *ctx)
Set command_ctx write_to_stdout flag.
Definition lirc_client.c:127
lirc_simulate
int lirc_simulate(int fd, const char *remote, const char *keysym, int scancode, int repeat)
Send a simulated lirc event.This call might block for some time since it involves communication with ...
Definition lirc_client.c:2010
lirc_nextcode
int lirc_nextcode(char **code)
Get next available code from the lircd daemon.
Definition lirc_client.c:1879
lirc_init
int lirc_init(const char *prog, int verbose)
Initial setup: connect to lircd socket.
Definition lirc_client.c:344
PACKET_SIZE
#define PACKET_SIZE
IR transmission packet size.
Definition lirc_config.h:84
lirc_cmd_ctx
The data needed to run a command on remote server.
Definition lirc_client.h:188
lirc_cmd_ctx::reply_to_stdout
int reply_to_stdout
If true, write reply on stdout.
Definition lirc_client.h:193
lirc_cmd_ctx::next
char * next
Next newline-separated word in buffer.
Definition lirc_client.h:194
lirc_cmd_ctx::head
int head
First free buffer index.
Definition lirc_client.h:192
lirc_code
Definition lirc_client.h:150
lirc_config_entry
Definition lirc_client.h:165
lirc_config
Definition lirc_client.h:156
lirc_config::lircrc_class
char * lircrc_class
The lircrc instance used, if any.
Definition lirc_client.h:157
lirc_list
Definition lirc_client.h:145