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
127extern "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
137enum 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
145struct lirc_list {
146 char* string;
147 struct lirc_list* next;
148};
149
150struct lirc_code {
151 char* remote;
152 char* button;
153 struct lirc_code* next;
154};
155
158 char* current_mode;
159 struct lirc_config_entry* next;
160 struct lirc_config_entry* first;
161
162 int sockfd;
163};
164
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
188typedef struct {
189 char packet[PACKET_SIZE + 1];
190 char buffer[PACKET_SIZE + 1];
191 char reply[PACKET_SIZE + 1];
192 int head;
194 char* next;
196
204int lirc_init(const char* prog, int verbose);
205
210int lirc_deinit(void);
211
226int lirc_readconfig(const char* path,
227 struct lirc_config** config,
228 int (check) (char* s));
229
231void lirc_freeconfig(struct lirc_config* config);
232
234char* lirc_nextir(void);
235
237char* lirc_ir2char(struct lirc_config* config, char* code);
238
248int lirc_nextcode(char** code);
249
261int lirc_code2char(struct lirc_config* config, char* code, char** string);
262
263
264/* new interface for client daemon */
277int lirc_readconfig_only(const char* file,
278 struct lirc_config** config,
279 int (check) (char* s));
280
281int lirc_code2charprog(struct lirc_config* config,
282 char* code,
283 char** string,
284 char** prog);
285
294size_t lirc_getsocketname(const char* id, char* buf, size_t size);
295
304const char* lirc_getmode(struct lirc_config* config);
305
315const char* lirc_setmode(struct lirc_config* config, const char* mode);
316
317/* 0.9.2: New interface for sending data. */
318
329int lirc_command_init(lirc_cmd_ctx* ctx, const char* fmt, ...);
330
331
342int lirc_command_run(lirc_cmd_ctx* ctx, int fd);
343
351
364int lirc_send_one(int fd, const char* remote, const char* keysym);
365
366
382int lirc_simulate(int fd,
383 const char* remote,
384 const char* keysym,
385 int scancode,
386 int repeat);
387
388
399int lirc_get_remote_socket(const char* address, int port, int quiet);
400
401
412int lirc_get_local_socket(const char* path, int quiet);
413
414
418#ifdef __cplusplus
419}
420#endif
421
422#endif
int lirc_send_one(int fd, const char *remote, const char *keysym)
Send keysym using given remote.
int lirc_get_local_socket(const char *path, int quiet)
Return an opened and connected file descriptor to local lirc socket.
char * lirc_nextir(void)
int lirc_command_init(lirc_cmd_ctx *ctx, const char *fmt,...)
Initiate a lirc_cmd_ctx to run a command.
const char * lirc_setmode(struct lirc_config *config, const char *mode)
Set mode defined in lircrc.
int lirc_deinit(void)
Release resources allocated by lirc_init(), basically disconnect from socket.
int lirc_readconfig(const char *path, struct lirc_config **config, int(check)(char *s))
Parse a lircrc configuration file.
char * lirc_ir2char(struct lirc_config *config, char *code)
void lirc_freeconfig(struct lirc_config *config)
Deallocate an object retrieved using lirc_readconfig().
int lirc_get_remote_socket(const char *address, int port, int quiet)
Return an opened and connected file descriptor to remote lirc socket.
int lirc_command_run(lirc_cmd_ctx *ctx, int fd)
Run a command in non-blocking mode.
int lirc_code2char(struct lirc_config *config, char *code, char **string)
Translate a code string to an application string using .lircrc.
int lirc_readconfig_only(const char *file, struct lirc_config **config, int(check)(char *s))
Parse a lircrc configuration file without connecting to lircrcd.
const char * lirc_getmode(struct lirc_config *config)
Get mode defined in lircrc.
size_t lirc_getsocketname(const char *id, char *buf, size_t size)
Retrieve default lircrcd socket path.
void lirc_command_reply_to_stdout(lirc_cmd_ctx *ctx)
Set command_ctx write_to_stdout flag.
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 ...
int lirc_nextcode(char **code)
Get next available code from the lircd daemon.
int lirc_init(const char *prog, int verbose)
Initial setup: connect to lircd socket.
#define PACKET_SIZE
IR transmission packet size.
Definition lirc_config.h:84
The data needed to run a command on remote server.
int reply_to_stdout
If true, write reply on stdout.
char * next
Next newline-separated word in buffer.
int head
First free buffer index.
char * lircrc_class
The lircrc instance used, if any.