00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00026 #ifndef BRLAPI_INCLUDED
00027 #define BRLAPI_INCLUDED
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033
00034
00039 #define BRLAPI_RELEASE "0.5.1"
00040
00042 #define BRLAPI_MAJOR 0
00043
00045 #define BRLAPI_MINOR 5
00046
00048 #define BRLAPI_REVISION 1
00049
00052
00053 #include <sys/types.h>
00054
00055 #ifdef BRLAPI_WIN32
00056 #include <windows.h>
00057 #define BRLAPI_STDCALL __stdcall
00058 #else
00059 #define BRLAPI_STDCALL
00060 #endif
00061
00062 #ifdef _MSC_VER
00063 typedef __int64 uint64_t;
00064 typedef __int32 uint32_t;
00065 #define UINT64_C(x) (x ## Ui64)
00066 #define PRIx64 "I64x"
00067 typedef signed int ssize_t;
00068 #else
00069
00070
00071 #include <stdint.h>
00072
00073
00074 #include <unistd.h>
00075
00076 #include <inttypes.h>
00077 #endif
00078
00101 typedef struct brlapi_handle_t brlapi_handle_t;
00102
00104 size_t BRLAPI_STDCALL brlapi_getHandleSize(void);
00105
00121 #define BRLAPI_SOCKETPORTNUM 4101
00122 #define BRLAPI_SOCKETPORT "4101"
00123
00125 #ifdef BRLAPI_WIN32
00126 #define BRLAPI_SOCKETPATH "\\\\.\\pipe\\BrlAPI"
00127 #else
00128 #define BRLAPI_SOCKETPATH "/var/lib/BrlAPI/"
00129 #endif
00130
00135 #define BRLAPI_ETCDIR "/etc"
00136
00140 #define BRLAPI_AUTHKEYFILE "brlapi.key"
00141
00143 #define BRLAPI_DEFAUTH BRLAPI_ETCDIR "/" BRLAPI_AUTHKEYFILE
00144
00145 #ifdef __MINGW32__
00146 typedef HANDLE brlapi_fileDescriptor;
00147 #else
00148 typedef int brlapi_fileDescriptor;
00149 #endif
00150
00181 typedef struct {
00189 char *auth;
00190
00199 char *host;
00200 } brlapi_connectionSettings_t;
00201
00202
00205 #define BRLAPI_SETTINGS_INITIALIZER { NULL, NULL }
00206
00207
00252 #ifndef BRLAPI_NO_SINGLE_SESSION
00253 brlapi_fileDescriptor BRLAPI_STDCALL brlapi_openConnection(const brlapi_connectionSettings_t *desiredSettings, brlapi_connectionSettings_t *actualSettings);
00254 #endif
00255 brlapi_fileDescriptor BRLAPI_STDCALL brlapi__openConnection(brlapi_handle_t *handle, const brlapi_connectionSettings_t *desiredSettings, brlapi_connectionSettings_t *actualSettings);
00256
00257
00264 #ifndef BRLAPI_NO_SINGLE_SESSION
00265 void BRLAPI_STDCALL brlapi_closeConnection(void);
00266 #endif
00267 void BRLAPI_STDCALL brlapi__closeConnection(brlapi_handle_t *handle);
00268
00284 #define BRLAPI_MAXNAMELENGTH 31
00285
00286
00298 #ifndef BRLAPI_NO_SINGLE_SESSION
00299 int BRLAPI_STDCALL brlapi_getDriverName(char *buffer, size_t size);
00300 #endif
00301 int BRLAPI_STDCALL brlapi__getDriverName(brlapi_handle_t *handle, char *buffer, size_t size);
00302
00303
00305 #ifndef BRLAPI_NO_SINGLE_SESSION
00306 int BRLAPI_STDCALL brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00307 #endif
00308 int BRLAPI_STDCALL brlapi__getDisplaySize(brlapi_handle_t *handle, unsigned int *x, unsigned int *y);
00309
00333
00360 #ifndef BRLAPI_NO_SINGLE_SESSION
00361 int BRLAPI_STDCALL brlapi_enterTtyMode(int tty, const char *driver);
00362 #endif
00363 int BRLAPI_STDCALL brlapi__enterTtyMode(brlapi_handle_t *handle, int tty, const char *driver);
00364
00374 #define BRLAPI_TTY_DEFAULT -1
00375
00376
00388 #ifndef BRLAPI_NO_SINGLE_SESSION
00389 int BRLAPI_STDCALL brlapi_enterTtyModeWithPath(int *ttys, int count, const char *driver);
00390 #endif
00391 int BRLAPI_STDCALL brlapi__enterTtyModeWithPath(brlapi_handle_t *handle, int *ttys, int count, const char *driver);
00392
00393
00400 #ifndef BRLAPI_NO_SINGLE_SESSION
00401 int BRLAPI_STDCALL brlapi_leaveTtyMode(void);
00402 #endif
00403 int BRLAPI_STDCALL brlapi__leaveTtyMode(brlapi_handle_t *handle);
00404
00405
00416 #ifndef BRLAPI_NO_SINGLE_SESSION
00417 int BRLAPI_STDCALL brlapi_setFocus(int tty);
00418 #endif
00419 int BRLAPI_STDCALL brlapi__setFocus(brlapi_handle_t *handle, int tty);
00420
00440
00455 #ifndef BRLAPI_NO_SINGLE_SESSION
00456 int BRLAPI_STDCALL brlapi_writeText(int cursor, const char *text);
00457 #endif
00458 int BRLAPI_STDCALL brlapi__writeText(brlapi_handle_t *handle, int cursor, const char *text);
00459
00460
00468 #ifndef BRLAPI_NO_SINGLE_SESSION
00469 int BRLAPI_STDCALL brlapi_writeDots(const unsigned char *dots);
00470 #endif
00471 int BRLAPI_STDCALL brlapi__writeDots(brlapi_handle_t *handle, const unsigned char *dots);
00472
00473
00475 typedef struct {
00476 int displayNumber ;
00477 unsigned int regionBegin ;
00478 unsigned int regionSize ;
00479 char *text ;
00480 int textSize ;
00481 unsigned char *andMask ;
00482 unsigned char *orMask ;
00483 int cursor ;
00484 char *charset ;
00485 } brlapi_writeArguments_t;
00486
00491 #define BRLAPI_DISPLAY_DEFAULT -1
00492
00497 #define BRLAPI_CURSOR_LEAVE -1
00498
00503 #define BRLAPI_CURSOR_OFF 0
00504
00505
00515 #define BRLAPI_WRITEARGUMENTS_INITIALIZER { BRLAPI_DISPLAY_DEFAULT, 0, 0, NULL, -1, NULL, NULL, BRLAPI_CURSOR_LEAVE, NULL }
00516
00517
00554 #ifndef BRLAPI_NO_SINGLE_SESSION
00555 int BRLAPI_STDCALL brlapi_write(const brlapi_writeArguments_t *arguments);
00556 #endif
00557 int BRLAPI_STDCALL brlapi__write(brlapi_handle_t *handle, const brlapi_writeArguments_t *arguments);
00558
00561 #include "brlapi_keycodes.h"
00562
00576
00578 typedef struct {
00579 unsigned int type ;
00580 unsigned int command ;
00581 unsigned int argument ;
00582 unsigned int flags ;
00583 } brlapi_expandedKeyCode_t;
00584
00585
00593 int BRLAPI_STDCALL brlapi_expandKeyCode (brlapi_keyCode_t code, brlapi_expandedKeyCode_t *expansion);
00594
00595
00597 typedef struct {
00598 const char *type ;
00599 const char *command ;
00600 unsigned int argument ;
00601 unsigned int flags ;
00602 const char *flag[64 - BRLAPI_KEY_FLAGS_SHIFT] ;
00603 brlapi_expandedKeyCode_t values ;
00604 } brlapi_describedKeyCode_t;
00605
00606
00614 int BRLAPI_STDCALL brlapi_describeKeyCode (brlapi_keyCode_t code, brlapi_describedKeyCode_t *description);
00615
00617 #define BRLAPI_UC_ROW 0x2800UL
00618
00622 #define BRLAPI_MAXKEYSETSIZE (BRLAPI_MAXPACKETSIZE / sizeof(brlapi_keyCode_t))
00623
00624
00689 #ifndef BRLAPI_NO_SINGLE_SESSION
00690 int BRLAPI_STDCALL brlapi_readKey(int wait, brlapi_keyCode_t *code);
00691 #endif
00692 int BRLAPI_STDCALL brlapi__readKey(brlapi_handle_t *handle, int wait, brlapi_keyCode_t *code);
00693
00695 typedef enum {
00696 brlapi_rangeType_all,
00697 brlapi_rangeType_type,
00698 brlapi_rangeType_command,
00699 brlapi_rangeType_key,
00700 brlapi_rangeType_code,
00701 } brlapi_rangeType_t;
00702
00703
00716 #ifndef BRLAPI_NO_SINGLE_SESSION
00717 int BRLAPI_STDCALL brlapi_ignoreKeys(brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00718 #endif
00719 int BRLAPI_STDCALL brlapi__ignoreKeys(brlapi_handle_t *handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00720
00721
00734 #ifndef BRLAPI_NO_SINGLE_SESSION
00735 int BRLAPI_STDCALL brlapi_acceptKeys(brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00736 #endif
00737 int BRLAPI_STDCALL brlapi__acceptKeys(brlapi_handle_t *handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00738
00739
00745 #ifndef BRLAPI_NO_SINGLE_SESSION
00746 int BRLAPI_STDCALL brlapi_ignoreAllKeys(void);
00747 #define brlapi_ignoreAllKeys() brlapi_ignoreKeys(brlapi_rangeType_all, NULL, 0)
00748 #endif
00749 int BRLAPI_STDCALL brlapi__ignoreAllKeys(brlapi_handle_t *handle);
00750 #define brlapi__ignoreAllKeys(handle) brlapi__ignoreKeys(handle, brlapi_rangeType_all, NULL, 0)
00751
00752
00761 #ifndef BRLAPI_NO_SINGLE_SESSION
00762 int BRLAPI_STDCALL brlapi_acceptAllKeys(void);
00763 #define brlapi_acceptAllKeys() brlapi_acceptKeys(brlapi_rangeType_all, NULL, 0)
00764 #endif
00765 int BRLAPI_STDCALL brlapi__acceptAllKeys(brlapi_handle_t *handle);
00766 #define brlapi__acceptAllKeys(handle) brlapi__acceptKeys(handle, brlapi_rangeType_all, NULL, 0)
00767
00772 typedef struct {
00773 brlapi_keyCode_t first;
00774 brlapi_keyCode_t last;
00775 } brlapi_range_t;
00776
00777
00788 #ifndef BRLAPI_NO_SINGLE_SESSION
00789 int BRLAPI_STDCALL brlapi_ignoreKeyRanges(brlapi_range_t ranges[], unsigned int count);
00790 #endif
00791 int BRLAPI_STDCALL brlapi__ignoreKeyRanges(brlapi_handle_t *handle, brlapi_range_t ranges[], unsigned int count);
00792
00793
00804 #ifndef BRLAPI_NO_SINGLE_SESSION
00805 int BRLAPI_STDCALL brlapi_acceptKeyRanges(brlapi_range_t ranges[], unsigned int count);
00806 #endif
00807 int BRLAPI_STDCALL brlapi__acceptKeyRanges(brlapi_handle_t *handle, brlapi_range_t ranges[], unsigned int count);
00833
00838 #ifndef BRLAPI_NO_SINGLE_SESSION
00839 int BRLAPI_STDCALL brlapi_enterRawMode(const char *driver);
00840 #endif
00841 int BRLAPI_STDCALL brlapi__enterRawMode(brlapi_handle_t *handle, const char *driver);
00842
00843
00846 #ifndef BRLAPI_NO_SINGLE_SESSION
00847 int BRLAPI_STDCALL brlapi_leaveRawMode(void);
00848 #endif
00849 int BRLAPI_STDCALL brlapi__leaveRawMode(brlapi_handle_t *handle);
00850
00851
00857 #ifndef BRLAPI_NO_SINGLE_SESSION
00858 ssize_t BRLAPI_STDCALL brlapi_sendRaw(const void *buffer, size_t size);
00859 #endif
00860 ssize_t BRLAPI_STDCALL brlapi__sendRaw(brlapi_handle_t *handle, const void *buffer, size_t size);
00861
00862
00869 #ifndef BRLAPI_NO_SINGLE_SESSION
00870 ssize_t BRLAPI_STDCALL brlapi_recvRaw(void *buffer, size_t size);
00871 #endif
00872 ssize_t BRLAPI_STDCALL brlapi__recvRaw(brlapi_handle_t *handle, void *buffer, size_t size);
00873
00874
00879 #ifndef BRLAPI_NO_SINGLE_SESSION
00880 int BRLAPI_STDCALL brlapi_suspendDriver(const char *driver);
00881 #endif
00882 int BRLAPI_STDCALL brlapi__suspendDriver(brlapi_handle_t *handle, const char *driver);
00883
00884
00888 #ifndef BRLAPI_NO_SINGLE_SESSION
00889 int BRLAPI_STDCALL brlapi_resumeDriver(void);
00890 #endif
00891 int BRLAPI_STDCALL brlapi__resumeDriver(brlapi_handle_t *handle);
00915
00916 #define BRLAPI_ERROR_SUCCESS 0
00917 #define BRLAPI_ERROR_NOMEM 1
00918 #define BRLAPI_ERROR_TTYBUSY 2
00919 #define BRLAPI_ERROR_DEVICEBUSY 3
00920 #define BRLAPI_ERROR_UNKNOWN_INSTRUCTION 4
00921 #define BRLAPI_ERROR_ILLEGAL_INSTRUCTION 5
00922 #define BRLAPI_ERROR_INVALID_PARAMETER 6
00923 #define BRLAPI_ERROR_INVALID_PACKET 7
00924 #define BRLAPI_ERROR_CONNREFUSED 8
00925 #define BRLAPI_ERROR_OPNOTSUPP 9
00926 #define BRLAPI_ERROR_GAIERR 10
00927 #define BRLAPI_ERROR_LIBCERR 11
00928 #define BRLAPI_ERROR_UNKNOWNTTY 12
00929 #define BRLAPI_ERROR_PROTOCOL_VERSION 13
00930 #define BRLAPI_ERROR_EOF 14
00931 #define BRLAPI_ERROR_EMPTYKEY 15
00932 #define BRLAPI_ERROR_DRIVERERROR 16
00933 #define BRLAPI_ERROR_AUTHENTICATION 17
00935
00936
00940 extern const char *brlapi_errlist[];
00941
00942
00944 extern const int brlapi_nerr;
00945
00946
00951 void BRLAPI_STDCALL brlapi_perror(const char *s);
00952
00953
00955 typedef struct {
00956 int brlerrno;
00957 int libcerrno;
00958 int gaierrno;
00959 const char *errfun;
00960 } brlapi_error_t;
00961
00970 brlapi_error_t * BRLAPI_STDCALL brlapi_error_location(void);
00971
00980 extern brlapi_error_t brlapi_error;
00981
00983 extern int brlapi_errno;
00985 extern int brlapi_libcerrno;
00987 extern int brlapi_gaierrno;
00989 extern const char *brlapi_errfun;
00990
00992 #define brlapi_error (*brlapi_error_location())
00993
00994 #define brlapi_errno (brlapi_error.brlerrno)
00995
00996 #define brlapi_libcerrno (brlapi_error.libcerrno)
00997
00998 #define brlapi_gaierrno (brlapi_error.gaierrno)
00999
01000 #define brlapi_errfun (brlapi_error.errfun)
01001
01002
01008 const char * BRLAPI_STDCALL brlapi_strerror(const brlapi_error_t *error);
01009
01011 typedef uint32_t brlapi_packetType_t;
01012
01013
01019 const char * BRLAPI_STDCALL brlapi_getPacketTypeName(brlapi_packetType_t type);
01020
01021
01033 #ifndef BRLAPI_NO_SINGLE_SESSION
01034 typedef void (BRLAPI_STDCALL *brlapi_exceptionHandler_t)(int error, brlapi_packetType_t type, const void *packet, size_t size);
01035 #endif
01036 typedef void (BRLAPI_STDCALL *brlapi__exceptionHandler_t)(brlapi_handle_t *handle, int error, brlapi_packetType_t type, const void *packet, size_t size);
01037
01038
01048 #ifndef BRLAPI_NO_SINGLE_SESSION
01049 int BRLAPI_STDCALL brlapi_strexception(char *buffer, size_t bufferSize, int error, brlapi_packetType_t type, const void *packet, size_t packetSize);
01050 #endif
01051 int BRLAPI_STDCALL brlapi__strexception(brlapi_handle_t *handle, char *buffer, size_t bufferSize, int error, brlapi_packetType_t type, const void *packet, size_t packetSize);
01052
01053
01062 #ifndef BRLAPI_NO_SINGLE_SESSION
01063 brlapi_exceptionHandler_t BRLAPI_STDCALL brlapi_setExceptionHandler(brlapi_exceptionHandler_t handler);
01064 #endif
01065 brlapi__exceptionHandler_t BRLAPI_STDCALL brlapi__setExceptionHandler(brlapi_handle_t *handle, brlapi__exceptionHandler_t handler);
01066
01067 #ifndef BRLAPI_NO_SINGLE_SESSION
01068 void BRLAPI_STDCALL brlapi_defaultExceptionHandler(int error, brlapi_packetType_t type, const void *packet, size_t size);
01069 #endif
01070 void BRLAPI_STDCALL brlapi__defaultExceptionHandler(brlapi_handle_t *handle, int error, brlapi_packetType_t type, const void *packet, size_t size);
01071
01074
01075 #ifdef BRLAPI_WIN32
01076 #ifndef BRLAPI_NO_SINGLE_SESSION
01077 int BRLAPI_STDCALL brlapi_writeTextWin(int cursor, const void *str, int wide);
01078 #endif
01079 int BRLAPI_STDCALL brlapi__writeTextWin(brlapi_handle_t *handle, int cursor, const void *str, int wide);
01080
01081 #ifndef BRLAPI_NO_SINGLE_SESSION
01082 int BRLAPI_STDCALL brlapi_writeWin(const brlapi_writeArguments_t *s, int wide);
01083 #endif
01084 int BRLAPI_STDCALL brlapi__writeWin(brlapi_handle_t *handle, const brlapi_writeArguments_t *s, int wide);
01085
01086 #ifdef UNICODE
01087 #ifndef BRLAPI_NO_SINGLE_SESSION
01088 #define brlapi_writeText(cursor, str) brlapi_writeTextWin(cursor, str, 1)
01089 #endif
01090 #define brlapi__writeText(handle, cursor, str) brlapi__writeTextWin(handle, cursor, str, 1)
01091
01092 #ifndef BRLAPI_NO_SINGLE_SESSION
01093 #define brlapi_write(s) brlapi_writeWin(s, 1)
01094 #endif
01095 #define brlapi__write(handle, s) brlapi__writeWin(handle, s, 1)
01096
01097 #else
01098
01099 #ifndef BRLAPI_NO_SINGLE_SESSION
01100 #define brlapi_writeText(cursor, str) brlapi_writeTextWin(cursor, str, 0)
01101 #endif
01102 #define brlapi__writeText(handle, cursor, str) brlapi__writeTextWin(handle, cursor, str, 0)
01103
01104 #ifndef BRLAPI_NO_SINGLE_SESSION
01105 #define brlapi_write(s) brlapi_writeWin(s, 0)
01106 #endif
01107 #define brlapi__write(handle, s) brlapi__writeWin(handle, s, 0)
01108
01109 #endif
01110 #endif
01111
01112 #ifndef BRLAPI_NO_DEPRECATED
01113
01125 #define brlapi_settings_t brlapi_connectionSettings_t
01126
01128 typedef struct {
01129 int displayNumber;
01130 unsigned int regionBegin;
01131 unsigned int regionSize;
01132 char *text;
01133 int textSize;
01134 unsigned char *attrAnd;
01135 unsigned char *attrOr;
01136 int cursor;
01137 char *charset;
01138 } brlapi_writeStruct;
01139 #define BRLAPI_WRITESTRUCT_INITIALIZER BRLAPI_WRITEARGUMENTS_INITIALIZER
01140
01141 #define brl_keycode_t brlapi_keyCode_t
01142 #define brl_type_t brlapi_packetType_t
01143
01144 #define BRLCOMMANDS NULL
01145 #define BRL_KEYCODE_MAX BRLAPI_KEY_MAX
01146
01147 #ifndef BRLAPI_NO_SINGLE_SESSION
01148 #define brlapi_initializeConnection brlapi_openConnection
01149 #define brlapi_getTty brlapi_enterTtyMode
01150 #define brlapi_getTtyPath brlapi_enterTtyModeWithPath
01151 #define brlapi_leaveTty brlapi_leaveTtyMode
01152 #define brlapi_unignoreKeyRange brlapi_acceptKeyRange
01153 #define brlapi_unignoreKeySet brlapi_acceptKeySet
01154 #define brlapi_getRaw brlapi_enterRawMode
01155 #define brlapi_leaveRaw brlapi_leaveRawMode
01156 #define brlapi_suspend brlapi_suspendDriver
01157 #define brlapi_resume brlapi_resumeDriver
01158 #endif
01159
01160 #define BRLERR_SUCCESS BRLAPI_ERROR_SUCCESS
01161 #define BRLERR_NOMEM BRLAPI_ERROR_NOMEM
01162 #define BRLERR_TTYBUSY BRLAPI_ERROR_TTYBUSY
01163 #define BRLERR_DEVICEBUSY BRLAPI_ERROR_DEVICEBUSY
01164 #define BRLERR_UNKNOWN_INSTRUCTION BRLAPI_ERROR_UNKNOWN_INSTRUCTION
01165 #define BRLERR_ILLEGAL_INSTRUCTION BRLAPI_ERROR_ILLEGAL_INSTRUCTION
01166 #define BRLERR_INVALID_PARAMETER BRLAPI_ERROR_INVALID_PARAMETER
01167 #define BRLERR_INVALID_PACKET BRLAPI_ERROR_INVALID_PACKET
01168 #define BRLERR_CONNREFUSED BRLAPI_ERROR_CONNREFUSED
01169 #define BRLERR_OPNOTSUPP BRLAPI_ERROR_OPNOTSUPP
01170 #define BRLERR_GAIERR BRLAPI_ERROR_GAIERR
01171 #define BRLERR_LIBCERR BRLAPI_ERROR_LIBCERR
01172 #define BRLERR_UNKNOWNTTY BRLAPI_ERROR_UNKNOWNTTY
01173 #define BRLERR_PROTOCOL_VERSION BRLAPI_ERROR_PROTOCOL_VERSION
01174 #define BRLERR_EOF BRLAPI_ERROR_EOF
01175 #define BRLERR_EMPTYKEY BRLAPI_ERROR_EMPTYKEY
01176 #define BRLERR_DRIVERERROR BRLAPI_ERROR_DRIVERERROR
01177
01179 #endif
01180
01181 #ifdef __cplusplus
01182 }
01183 #endif
01184
01185 #endif