BrlAPI 1.0

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

brlapi_protocol.h
Go to the documentation of this file.
1 /*
2 * libbrlapi - A library providing access to braille terminals for applications.
3 *
4 * Copyright (C) 2002-2014 by
5 * Samuel Thibault <Samuel.Thibault@ens-lyon.org>
6 * Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>
7 *
8 * libbrlapi comes with ABSOLUTELY NO WARRANTY.
9 *
10 * This is free software, placed under the terms of the
11 * GNU Lesser General Public License, as published by the Free Software
12 * Foundation; either version 2.1 of the License, or (at your option) any
13 * later version. Please see the file LICENSE-LGPL for details.
14 *
15 * Web Page: http://mielke.cc/brltty/
16 *
17 * This software is maintained by Dave Mielke <dave@mielke.cc>.
18 */
19
24 #ifndef BRLAPI_INCLUDED_PROTOCOL
25 #define BRLAPI_INCLUDED_PROTOCOL
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 #include "brlapi.h"
32
33 /* this is for UINT32_MAX */
34 #include <inttypes.h>
35 #ifndef UINT32_MAX
36 #define UINT32_MAX (4294967295U)
37 #endif /* UINT32_MAX */
38
39 /* The type size_t is defined there! */
40 #include <unistd.h>
41
52 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 8)
56 #define BRLAPI_MAXPACKETSIZE 512
57
58 #define BRLAPI_PACKET_VERSION 'v'
59 #define BRLAPI_PACKET_AUTH 'a'
60 #define BRLAPI_PACKET_GETDRIVERNAME 'n'
61 #define BRLAPI_PACKET_GETDISPLAYSIZE 's'
62 #define BRLAPI_PACKET_ENTERTTYMODE 't'
63 #define BRLAPI_PACKET_SETFOCUS 'F'
64 #define BRLAPI_PACKET_LEAVETTYMODE 'L'
65 #define BRLAPI_PACKET_KEY 'k'
66 #define BRLAPI_PACKET_IGNOREKEYRANGES 'm'
67 #define BRLAPI_PACKET_ACCEPTKEYRANGES 'u'
68 #define BRLAPI_PACKET_WRITE 'w'
69 #define BRLAPI_PACKET_ENTERRAWMODE '*'
70 #define BRLAPI_PACKET_LEAVERAWMODE '#'
71 #define BRLAPI_PACKET_PACKET 'p'
72 #define BRLAPI_PACKET_ACK 'A'
73 #define BRLAPI_PACKET_ERROR 'e'
74 #define BRLAPI_PACKET_EXCEPTION 'E'
75 #define BRLAPI_PACKET_SUSPENDDRIVER 'S'
76 #define BRLAPI_PACKET_RESUMEDRIVER 'R'
79 #define BRLAPI_DEVICE_MAGIC (0xdeadbeefL)
80
82 typedef struct {
83 uint32_t size;
84 brlapi_packetType_t type;
85 } brlapi_header_t;
86
88 #define BRLAPI_HEADERSIZE sizeof(brlapi_header_t)
89
91 typedef struct {
92 uint32_t protocolVersion;
93 } brlapi_versionPacket_t;
94
96 typedef struct {
97 uint32_t type;
98 unsigned char key;
99 } brlapi_authClientPacket_t;
100
101 typedef struct {
102 uint32_t type[1];
103 } brlapi_authServerPacket_t;
104
105 #define BRLAPI_AUTH_NONE 'N'
106 #define BRLAPI_AUTH_KEY 'K'
107 #define BRLAPI_AUTH_CRED 'C'
110 typedef struct {
111 uint32_t code;
112 brlapi_packetType_t type;
113 unsigned char packet;
114 } brlapi_errorPacket_t;
115
117 typedef struct {
118 uint32_t magic;
119 unsigned char nameLength;
120 char name;
121 } brlapi_getDriverSpecificModePacket_t;
122
124 #define BRLAPI_WF_DISPLAYNUMBER 0X01
125 #define BRLAPI_WF_REGION 0X02
126 #define BRLAPI_WF_TEXT 0X04
127 #define BRLAPI_WF_ATTR_AND 0X08
128 #define BRLAPI_WF_ATTR_OR 0X10
129 #define BRLAPI_WF_CURSOR 0X20
130 #define BRLAPI_WF_CHARSET 0X40
133 typedef struct {
134 uint32_t flags;
135 unsigned char data;
136 } brlapi_writeArgumentsPacket_t;
137
140 typedef union {
141 unsigned char data[BRLAPI_MAXPACKETSIZE];
142 brlapi_versionPacket_t version;
143 brlapi_authClientPacket_t authClient;
144 brlapi_authServerPacket_t authServer;
145 brlapi_errorPacket_t error;
146 brlapi_getDriverSpecificModePacket_t getDriverSpecificMode;
147 brlapi_writeArgumentsPacket_t writeArguments;
148 uint32_t uint32;
149 } brlapi_packet_t;
150
151 /* brlapi_writePacket */
167 ssize_t brlapi_writePacket(brlapi_fileDescriptor fd, brlapi_packetType_t type, const void *buf, size_t size);
168
169 /* brlapi_readPacketHeader */
186 ssize_t brlapi_readPacketHeader(brlapi_fileDescriptor fd, brlapi_packetType_t *packetType);
187
188 /* brlapi_readPacketContent */
209 ssize_t brlapi_readPacketContent(brlapi_fileDescriptor fd, size_t packetSize, void *buf, size_t bufSize);
210
211 /* brlapi_readPacket */
233 ssize_t brlapi_readPacket(brlapi_fileDescriptor fd, brlapi_packetType_t *type, void *buf, size_t size);
234
235 /* brlapi_fd_mutex */
262 #ifdef __MINGW32__
263 #include <windows.h>
264 extern HANDLE brlapi_fd_mutex;
265 #else /* __MINGW32__ */
266 #include <pthread.h>
267 extern pthread_mutex_t brlapi_fd_mutex;
268 #endif /* __MINGW32__ */
269
270 /* @} */
271
272 #ifdef __cplusplus
273 }
274 #endif /* __cplusplus */
275
276 #endif /* BRLAPI_INCLUDED_PROTOCOL */