BrlAPI: brlapi_protocol.h Source File

BrlAPI 0.6

- 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-2018 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://brltty.com/
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_GETMODELID 'd'
62 #define BRLAPI_PACKET_GETDISPLAYSIZE 's'
63 #define BRLAPI_PACKET_ENTERTTYMODE 't'
64 #define BRLAPI_PACKET_SETFOCUS 'F'
65 #define BRLAPI_PACKET_LEAVETTYMODE 'L'
66 #define BRLAPI_PACKET_KEY 'k'
67 #define BRLAPI_PACKET_IGNOREKEYRANGES 'm'
68 #define BRLAPI_PACKET_ACCEPTKEYRANGES 'u'
69 #define BRLAPI_PACKET_WRITE 'w'
70 #define BRLAPI_PACKET_ENTERRAWMODE '*'
71 #define BRLAPI_PACKET_LEAVERAWMODE '#'
72 #define BRLAPI_PACKET_PACKET 'p'
73 #define BRLAPI_PACKET_ACK 'A'
74 #define BRLAPI_PACKET_ERROR 'e'
75 #define BRLAPI_PACKET_EXCEPTION 'E'
76 #define BRLAPI_PACKET_SUSPENDDRIVER 'S'
77 #define BRLAPI_PACKET_RESUMEDRIVER 'R'
80 #define BRLAPI_DEVICE_MAGIC (0xdeadbeefL)
81
83 typedef struct {
84 uint32_t size;
85 brlapi_packetType_t type;
86 } brlapi_header_t;
87
89 #define BRLAPI_HEADERSIZE sizeof(brlapi_header_t)
90
92 typedef struct {
93 uint32_t protocolVersion;
94 } brlapi_versionPacket_t;
95
97 typedef struct {
98 uint32_t type;
99 unsigned char key;
100 } brlapi_authClientPacket_t;
101
102 typedef struct {
103 uint32_t type[1];
104 } brlapi_authServerPacket_t;
105
106 #define BRLAPI_AUTH_NONE 'N'
107 #define BRLAPI_AUTH_KEY 'K'
108 #define BRLAPI_AUTH_CRED 'C'
111 typedef struct {
112 uint32_t code;
113 brlapi_packetType_t type;
114 unsigned char packet;
115 } brlapi_errorPacket_t;
116
118 typedef struct {
119 uint32_t magic;
120 unsigned char nameLength;
121 char name;
122 } brlapi_getDriverSpecificModePacket_t;
123
125 #define BRLAPI_WF_DISPLAYNUMBER 0X01
126 #define BRLAPI_WF_REGION 0X02
127 #define BRLAPI_WF_TEXT 0X04
128 #define BRLAPI_WF_ATTR_AND 0X08
129 #define BRLAPI_WF_ATTR_OR 0X10
130 #define BRLAPI_WF_CURSOR 0X20
131 #define BRLAPI_WF_CHARSET 0X40
134 typedef struct {
135 uint32_t flags;
136 unsigned char data;
137 } brlapi_writeArgumentsPacket_t;
138
141 typedef union {
142 unsigned char data[BRLAPI_MAXPACKETSIZE];
143 brlapi_versionPacket_t version;
144 brlapi_authClientPacket_t authClient;
145 brlapi_authServerPacket_t authServer;
146 brlapi_errorPacket_t error;
147 brlapi_getDriverSpecificModePacket_t getDriverSpecificMode;
148 brlapi_writeArgumentsPacket_t writeArguments;
149 uint32_t uint32;
150 } brlapi_packet_t;
151
152 /* brlapi_writePacket */
168 ssize_t brlapi_writePacket(brlapi_fileDescriptor fd, brlapi_packetType_t type, const void *buf, size_t size);
169
170 /* brlapi_readPacketHeader */
187 ssize_t brlapi_readPacketHeader(brlapi_fileDescriptor fd, brlapi_packetType_t *packetType);
188
189 /* brlapi_readPacketContent */
210 ssize_t brlapi_readPacketContent(brlapi_fileDescriptor fd, size_t packetSize, void *buf, size_t bufSize);
211
212 /* brlapi_readPacket */
234 ssize_t brlapi_readPacket(brlapi_fileDescriptor fd, brlapi_packetType_t *type, void *buf, size_t size);
235
236 /* 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 */