1 |
#include "../helper.c" |
2 |
|
3 |
#include <errno.h> |
4 |
#include <irman.h> |
5 |
|
6 |
static int |
7 |
if_init (int argc, char *argv[]) |
8 |
{ |
9 |
char *portname; |
10 |
int fd; |
11 |
|
12 |
if (argc < 1) |
13 |
tx_abort ("irman: portname expected"); |
14 |
|
15 |
portname = argv[0]; |
16 |
|
17 |
if (ir_init_commands (0, 0)) |
18 |
tx_abort ("irman: ir_init_commands failed"); |
19 |
|
20 |
if ((fd = ir_init (portname[0] ? portname : ir_default_portname ())) < 0) |
21 |
tx_abort (ir_strerror (errno)); |
22 |
|
23 |
return fd; |
24 |
} |
25 |
|
26 |
static void |
27 |
if_exit (int fd) |
28 |
{ |
29 |
/* ir_finish (); */ |
30 |
/* ir_free_commands (); */ |
31 |
} |
32 |
|
33 |
static void |
34 |
if_parse (int fd) |
35 |
{ |
36 |
static unsigned char *last_code; |
37 |
unsigned char *code = ir_get_code (); |
38 |
|
39 |
/* irman is badly designed */ |
40 |
if (!code && errno == IR_EDUPCODE) |
41 |
code = last_code; |
42 |
|
43 |
if (code) |
44 |
{ |
45 |
char *text = ir_code_to_text (code); |
46 |
last_code = code; |
47 |
|
48 |
tx_code (text, ir_text_to_name (text)); |
49 |
} |
50 |
} |
51 |
|
52 |
|
53 |
|