brlapi_protocol.h

Go to the documentation of this file.
00001 /*
00002  * libbrlapi - A library providing access to braille terminals for applications.
00003  *
00004  * Copyright (C) 2002-2010 by
00005  *   Samuel Thibault <Samuel.Thibault@ens-lyon.org>
00006  *   Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>
00007  *
00008  * libbrlapi comes with ABSOLUTELY NO WARRANTY.
00009  *
00010  * This is free software, placed under the terms of the
00011  * GNU Lesser General Public License, as published by the Free Software
00012  * Foundation; either version 2.1 of the License, or (at your option) any
00013  * later version. Please see the file LICENSE-LGPL for details.
00014  *
00015  * Web Page: http://mielke.cc/brltty/
00016  *
00017  * This software is maintained by Dave Mielke <dave@mielke.cc>.
00018  */
00019 
00024 #ifndef BRLAPI_INCLUDED_PROTOCOL
00025 #define BRLAPI_INCLUDED_PROTOCOL
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif /* __cplusplus */
00030 
00031 #include "brlapi.h"
00032 
00033 /* this is for UINT32_MAX */
00034 #include <inttypes.h>
00035 #ifndef UINT32_MAX
00036 #define UINT32_MAX (4294967295U)
00037 #endif /* UINT32_MAX */
00038 
00039 /* The type size_t is defined there! */
00040 #include <unistd.h>
00041 
00052 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 8) 
00056 #define BRLAPI_MAXPACKETSIZE 512
00057 
00058 #define BRLAPI_PACKET_VERSION         'v'   
00059 #define BRLAPI_PACKET_AUTH            'a'   
00060 #define BRLAPI_PACKET_GETDRIVERNAME   'n'   
00061 #define BRLAPI_PACKET_GETDISPLAYSIZE  's'   
00062 #define BRLAPI_PACKET_ENTERTTYMODE    't'   
00063 #define BRLAPI_PACKET_SETFOCUS        'F'   
00064 #define BRLAPI_PACKET_LEAVETTYMODE    'L'   
00065 #define BRLAPI_PACKET_KEY             'k'   
00066 #define BRLAPI_PACKET_IGNOREKEYRANGES 'm'   
00067 #define BRLAPI_PACKET_ACCEPTKEYRANGES 'u'   
00068 #define BRLAPI_PACKET_WRITE           'w'   
00069 #define BRLAPI_PACKET_ENTERRAWMODE    '*'   
00070 #define BRLAPI_PACKET_LEAVERAWMODE    '#'   
00071 #define BRLAPI_PACKET_PACKET          'p'   
00072 #define BRLAPI_PACKET_ACK             'A'   
00073 #define BRLAPI_PACKET_ERROR           'e'   
00074 #define BRLAPI_PACKET_EXCEPTION       'E'   
00075 #define BRLAPI_PACKET_SUSPENDDRIVER   'S'   
00076 #define BRLAPI_PACKET_RESUMEDRIVER    'R'   
00079 #define BRLAPI_DEVICE_MAGIC (0xdeadbeefL)
00080 
00082 typedef struct {
00083   uint32_t size;
00084   brlapi_packetType_t type;
00085 } brlapi_header_t;
00086 
00088 #define BRLAPI_HEADERSIZE sizeof(brlapi_header_t)
00089 
00091 typedef struct {
00092   uint32_t protocolVersion;
00093 } brlapi_versionPacket_t;
00094 
00096 typedef struct {
00097   uint32_t type;
00098   unsigned char key;
00099 } brlapi_authClientPacket_t;
00100 
00101 typedef struct {
00102   uint32_t type[1];
00103 } brlapi_authServerPacket_t;
00104 
00105 #define BRLAPI_AUTH_NONE 'N' 
00106 #define BRLAPI_AUTH_KEY  'K' 
00107 #define BRLAPI_AUTH_CRED 'C' 
00110 typedef struct {
00111   uint32_t code;
00112   brlapi_packetType_t type;
00113   unsigned char packet;
00114 } brlapi_errorPacket_t;
00115 
00117 typedef struct {
00118   uint32_t magic;
00119   unsigned char nameLength;
00120   char name;
00121 } brlapi_getDriverSpecificModePacket_t;
00122 
00124 #define BRLAPI_WF_DISPLAYNUMBER 0X01    
00125 #define BRLAPI_WF_REGION        0X02    
00126 #define BRLAPI_WF_TEXT          0X04    
00127 #define BRLAPI_WF_ATTR_AND      0X08    
00128 #define BRLAPI_WF_ATTR_OR       0X10    
00129 #define BRLAPI_WF_CURSOR        0X20    
00130 #define BRLAPI_WF_CHARSET       0X40    
00133 typedef struct {
00134   uint32_t flags; 
00135   unsigned char data; 
00136 } brlapi_writeArgumentsPacket_t;
00137 
00140 typedef union {
00141         unsigned char data[BRLAPI_MAXPACKETSIZE];
00142         brlapi_versionPacket_t version;
00143         brlapi_authClientPacket_t authClient;
00144         brlapi_authServerPacket_t authServer;
00145         brlapi_errorPacket_t error;
00146         brlapi_getDriverSpecificModePacket_t getDriverSpecificMode;
00147         brlapi_writeArgumentsPacket_t writeArguments;
00148         uint32_t uint32;
00149 } brlapi_packet_t;
00150 
00151 /* brlapi_writePacket */
00167 ssize_t brlapi_writePacket(brlapi_fileDescriptor fd, brlapi_packetType_t type, const void *buf, size_t size);
00168 
00169 /* brlapi_readPacketHeader */
00186 ssize_t brlapi_readPacketHeader(brlapi_fileDescriptor fd, brlapi_packetType_t *packetType);
00187 
00188 /* brlapi_readPacketContent */
00209 ssize_t brlapi_readPacketContent(brlapi_fileDescriptor fd, size_t packetSize, void *buf, size_t bufSize);
00210 
00211 /* brlapi_readPacket */
00233 ssize_t brlapi_readPacket(brlapi_fileDescriptor fd, brlapi_packetType_t *type, void *buf, size_t size);
00234 
00235 /* brlapi_fd_mutex */
00262 #ifdef __MINGW32__
00263 #include <windows.h>
00264 extern HANDLE brlapi_fd_mutex;
00265 #else /* __MINGW32__ */
00266 #include <pthread.h>
00267 extern pthread_mutex_t brlapi_fd_mutex;
00268 #endif /* __MINGW32__ */
00269 
00270 /* @} */
00271 
00272 #ifdef __cplusplus
00273 }
00274 #endif /* __cplusplus */
00275 
00276 #endif /* BRLAPI_INCLUDED_PROTOCOL */

Generated on Tue Aug 24 08:38:37 2010 for BrlAPI by  doxygen 1.5.7.1