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-2007 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,
00013  * or (at your option) any later version.
00014  * Please see the file COPYING-API for details.
00015  *
00016  * Web Page: http://mielke.cc/brltty/
00017  *
00018  * This software is maintained by Dave Mielke <dave@mielke.cc>.
00019  */
00020 
00025 #ifndef BRLAPI_INCLUDED_PROTOCOL
00026 #define BRLAPI_INCLUDED_PROTOCOL
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif /* __cplusplus */
00031 
00032 #include "brlapi.h"
00033 
00034 /* this is for UINT32_MAX */
00035 #include <inttypes.h>
00036 #ifndef UINT32_MAX
00037 #define UINT32_MAX (4294967295U)
00038 #endif /* UINT32_MAX */
00039 
00040 /* The type size_t is defined there! */
00041 #include <unistd.h>
00042 
00053 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 8) 
00057 #define BRLAPI_MAXPACKETSIZE 512
00058 
00059 #define BRLAPI_PACKET_VERSION         'v'   
00060 #define BRLAPI_PACKET_AUTH            'a'   
00061 #define BRLAPI_PACKET_GETDRIVERNAME   'n'   
00062 #define BRLAPI_PACKET_GETDISPLAYSIZE  's'   
00063 #define BRLAPI_PACKET_ENTERTTYMODE    't'   
00064 #define BRLAPI_PACKET_SETFOCUS        'F'   
00065 #define BRLAPI_PACKET_LEAVETTYMODE    'L'   
00066 #define BRLAPI_PACKET_KEY             'k'   
00067 #define BRLAPI_PACKET_IGNOREKEYRANGES 'm'   
00068 #define BRLAPI_PACKET_ACCEPTKEYRANGES 'u'   
00069 #define BRLAPI_PACKET_WRITE           'w'   
00070 #define BRLAPI_PACKET_ENTERRAWMODE    '*'   
00071 #define BRLAPI_PACKET_LEAVERAWMODE    '#'   
00072 #define BRLAPI_PACKET_PACKET          'p'   
00073 #define BRLAPI_PACKET_ACK             'A'   
00074 #define BRLAPI_PACKET_ERROR           'e'   
00075 #define BRLAPI_PACKET_EXCEPTION       'E'   
00076 #define BRLAPI_PACKET_SUSPENDDRIVER   'S'   
00077 #define BRLAPI_PACKET_RESUMEDRIVER    'R'   
00080 #define BRLAPI_DEVICE_MAGIC (0xdeadbeefL)
00081 
00083 typedef struct {
00084   uint32_t size;
00085   brlapi_packetType_t type;
00086 } brlapi_header_t;
00087 
00089 #define BRLAPI_HEADERSIZE sizeof(brlapi_header_t)
00090 
00092 typedef struct {
00093   uint32_t protocolVersion;
00094 } brlapi_versionPacket_t;
00095 
00097 typedef struct {
00098   uint32_t type;
00099   unsigned char key;
00100 } brlapi_authClientPacket_t;
00101 
00102 typedef struct {
00103   uint32_t type[1];
00104 } brlapi_authServerPacket_t;
00105 
00106 #define BRLAPI_AUTH_NONE 'N' 
00107 #define BRLAPI_AUTH_KEY  'K' 
00108 #define BRLAPI_AUTH_CRED 'C' 
00111 typedef struct {
00112   uint32_t code;
00113   brlapi_packetType_t type;
00114   unsigned char packet;
00115 } brlapi_errorPacket_t;
00116 
00118 typedef struct {
00119   uint32_t magic;
00120   unsigned char nameLength;
00121   char name;
00122 } brlapi_getDriverSpecificModePacket_t;
00123 
00125 #define BRLAPI_WF_DISPLAYNUMBER 0X01    
00126 #define BRLAPI_WF_REGION        0X02    
00127 #define BRLAPI_WF_TEXT          0X04    
00128 #define BRLAPI_WF_ATTR_AND      0X08    
00129 #define BRLAPI_WF_ATTR_OR       0X10    
00130 #define BRLAPI_WF_CURSOR        0X20    
00131 #define BRLAPI_WF_CHARSET       0X40    
00134 typedef struct {
00135   uint32_t flags; 
00136   unsigned char data; 
00137 } brlapi_writeArgumentsPacket_t;
00138 
00141 typedef union {
00142         unsigned char data[BRLAPI_MAXPACKETSIZE];
00143         brlapi_versionPacket_t version;
00144         brlapi_authClientPacket_t authClient;
00145         brlapi_authServerPacket_t authServer;
00146         brlapi_errorPacket_t error;
00147         brlapi_getDriverSpecificModePacket_t getDriverSpecificMode;
00148         brlapi_writeArgumentsPacket_t writeArguments;
00149         uint32_t uint32;
00150 } brlapi_packet_t;
00151 
00152 /* brlapi_writePacket */
00168 ssize_t brlapi_writePacket(brlapi_fileDescriptor fd, brlapi_packetType_t type, const void *buf, size_t size);
00169 
00170 /* brlapi_readPacketHeader */
00187 ssize_t brlapi_readPacketHeader(brlapi_fileDescriptor fd, brlapi_packetType_t *packetType);
00188 
00189 /* brlapi_readPacketContent */
00210 ssize_t brlapi_readPacketContent(brlapi_fileDescriptor fd, size_t packetSize, void *buf, size_t bufSize);
00211 
00212 /* brlapi_readPacket */
00234 ssize_t brlapi_readPacket(brlapi_fileDescriptor fd, brlapi_packetType_t *type, void *buf, size_t size);
00235 
00236 /* brlapi_fd_mutex */
00263 #ifdef __MINGW32__
00264 #include <windows.h>
00265 extern HANDLE brlapi_fd_mutex;
00266 #else /* __MINGW32__ */
00267 #include <pthread.h>
00268 extern pthread_mutex_t brlapi_fd_mutex;
00269 #endif /* __MINGW32__ */
00270 
00271 /* @} */
00272 
00273 #ifdef __cplusplus
00274 }
00275 #endif /* __cplusplus */
00276 
00277 #endif /* BRLAPI_INCLUDED_PROTOCOL */

Generated on Wed Oct 17 11:27:42 2007 for BrlAPI by  doxygen 1.5.1