File: irman.h

package info (click to toggle)
libirman 0.5.2-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,656 kB
  • sloc: sh: 4,099; ansic: 1,541; makefile: 82
file content (129 lines) | stat: -rw-r--r-- 3,717 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* irman.h v0.4.2 (c) 1998-99 Tom Wheeley <tomw@tsys.demon.co.uk> */
/* this code is placed under the LGPL, see www.gnu.org for info   */

#ifndef IRMAN_H
#define IRMAN_H

/* number of bytes sent back from the IR interface */

#define IR_CODE_LEN			6

/* timing details. we have `SSEC' instead of `SEC' due to clashes with
 * some (ie Solaris) <time.h> definitions  */

#define SSEC	* 1000000
#define MSEC	* 1000
#define USEC

/* Assuming LONG_MAX to be 2,000,000,000, we have a maximum timeout of
 * approx 2,000s, ie over half an hour.  Plenty! (I should hope)
 */

/* time we allow the port to sort itself out with */ 
#define IR_POWER_ON_LATENCY		(50 MSEC)
#define IR_POWER_OFF_LATENCY		(50 MSEC)
/* gap between sending 'I' and 'R' */
#define IR_HANDSHAKE_GAP		(2000 USEC)

/* successive initial garbage characters should not be more than this apart */
#define IR_GARBAGE_TIMEOUT		(50 MSEC)
/* letters 'O' and 'K' should arrive within this */
#define IR_HANDSHAKE_TIMEOUT		(2 SSEC)
/* successive bytes of an ir pseudocode should arrive within this time limit */
#define IR_POLL_TIMEOUT			(50 MSEC)
/* double signals should be no less than this apart */
#define IR_DOUBLE_TIMEOUT		(200 MSEC)

/* timeout for blocking IO */
#define IR_BLOCKING			(-1)

/* return from ir_get_command() on error */
#define IR_CMD_ERROR			-1
#define IR_CMD_UNKNOWN			0

/* size of hash table in ircmd.c.  must be prime */
#define IR_HT_SIZE			271

/* size of string to hold default Irman port name, eg /dev/ttyS0 */
#define IR_PORTNAME_LEN			127

/* filename for system irmanrc */
#ifndef IR_SYSCONF_DIR
# define IR_SYSCONF_DIR			"/etc"
#endif
#define IR_SYSTEM_IRMANRC		IR_SYSCONF_DIR "/irman.conf"
/* filename for users irmanrc */
#define IR_USER_IRMANRC			".irmanrc"

/* messages printed by ir_ask_for_code() */
#define IR_ASK_GREETING	"please press the button for %s\n"
#define IR_ASK_REPEAT	"press %s again, to be sure...\n"
#define IR_ASK_OK	"Thankyou.\n"
#define IR_ASK_NOMATCH	"The two codes do not match.  "


#define ir_code_to_name(c)	ir_text_to_name(ir_code_to_text(c))
#define ir_name_to_code(n)	ir_text_to_code(ir_name_to_text(n))

/*
 *  errno codes
 */
 
#define IR_EENABLED	-1	/* ir routines already enabled */
#define IR_EDISABLED	-2	/* ir routines disabled */
#define IR_EHANDSHAKE	-3	/* error in handshake with Irman */
#define IR_EDUPCODE	-4	/* duplicate code received */ 
#define IR_EBADCMD	-11	/* bad command number */
#define IR_ENOKEY	-12	/* key does not exist */
#define IR_EDUPKEY	-13	/* key already exists */

/*
 * Function prototypes
 */

/* high level: ircmd.c */
int ir_init_commands(char *rcname, int warn);
char *ir_text_to_name(char *text);
char *ir_name_to_text(char *name);
int ir_bind(char *name, char *text);
int ir_alias(char *newname, char *name);
int ir_register_command(char *name, int command);
int ir_remove_command(char *name);
int ir_get_command(void);
int ir_poll_command(void);
void ir_free_commands(void);
unsigned char *ir_ask_for_code(char *name, int display);
void ir_set_cmd_enabled(int val);
char *ir_default_portname(void);
char *ir_strerror(int eno);

/* mid level: irfunc.c */
int ir_init(char *filename);
int ir_finish(void);
unsigned char *ir_get_code(void);
unsigned char *ir_poll_code(void);
int ir_valid_code(char *text);
char *ir_code_to_text(unsigned char *code);
unsigned char *ir_text_to_code(char *text);
void ir_set_enabled(int val);

/* low level: irio.c */
int ir_open_port(char *filename);
int ir_close_port(void);
int ir_write_char(unsigned char data);
int ir_read_char(long timeout);
void ir_clear_buffer(void);
void ir_usleep(unsigned long usec);

/* purely internal stuff */

#ifdef __IR

#else

#endif /* __IR */


#endif /* IRMAN_H */

/* end of irman.h */