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
00119 #define BRLAPI_SOCKETPORTNUM 4101
00120 #define BRLAPI_SOCKETPORT "4101"
00121
00123 #ifdef BRLAPI_WIN32
00124 #define BRLAPI_SOCKETPATH "\\\\.\\pipe\\BrlAPI"
00125 #else
00126 #define BRLAPI_SOCKETPATH "/var/lib/BrlAPI/"
00127 #endif
00128
00133 #define BRLAPI_ETCDIR "/etc"
00134
00138 #define BRLAPI_AUTHKEYFILE "brlapi.key"
00139
00141 #define BRLAPI_DEFAUTH BRLAPI_ETCDIR "/" BRLAPI_AUTHKEYFILE
00142
00143 #ifdef __MINGW32__
00144 typedef HANDLE brlapi_fileDescriptor;
00145 #else
00146 typedef int brlapi_fileDescriptor;
00147 #endif
00148
00179 typedef struct {
00187 char *auth;
00188
00197 char *host;
00198 } brlapi_connectionSettings_t;
00199
00200
00203 #define BRLAPI_SETTINGS_INITIALIZER { NULL, NULL }
00204
00205
00250 #ifndef BRLAPI_NO_SINGLE_SESSION
00251 brlapi_fileDescriptor BRLAPI_STDCALL brlapi_openConnection(const brlapi_connectionSettings_t *desiredSettings, brlapi_connectionSettings_t *actualSettings);
00252 #endif
00253 brlapi_fileDescriptor BRLAPI_STDCALL brlapi__openConnection(brlapi_handle_t *handle, const brlapi_connectionSettings_t *desiredSettings, brlapi_connectionSettings_t *actualSettings);
00254
00255
00262 #ifndef BRLAPI_NO_SINGLE_SESSION
00263 void BRLAPI_STDCALL brlapi_closeConnection(void);
00264 #endif
00265 void BRLAPI_STDCALL brlapi__closeConnection(brlapi_handle_t *handle);
00266
00282 #define BRLAPI_MAXNAMELENGTH 31
00283
00284
00296 #ifndef BRLAPI_NO_SINGLE_SESSION
00297 int BRLAPI_STDCALL brlapi_getDriverName(char *buffer, size_t size);
00298 #endif
00299 int BRLAPI_STDCALL brlapi__getDriverName(brlapi_handle_t *handle, char *buffer, size_t size);
00300
00301
00303 #ifndef BRLAPI_NO_SINGLE_SESSION
00304 int BRLAPI_STDCALL brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00305 #endif
00306 int BRLAPI_STDCALL brlapi__getDisplaySize(brlapi_handle_t *handle, unsigned int *x, unsigned int *y);
00307
00331
00358 #ifndef BRLAPI_NO_SINGLE_SESSION
00359 int BRLAPI_STDCALL brlapi_enterTtyMode(int tty, const char *driver);
00360 #endif
00361 int BRLAPI_STDCALL brlapi__enterTtyMode(brlapi_handle_t *handle, int tty, const char *driver);
00362
00372 #define BRLAPI_TTY_DEFAULT -1
00373
00374
00386 #ifndef BRLAPI_NO_SINGLE_SESSION
00387 int BRLAPI_STDCALL brlapi_enterTtyModeWithPath(int *ttys, int count, const char *driver);
00388 #endif
00389 int BRLAPI_STDCALL brlapi__enterTtyModeWithPath(brlapi_handle_t *handle, int *ttys, int count, const char *driver);
00390
00391
00398 #ifndef BRLAPI_NO_SINGLE_SESSION
00399 int BRLAPI_STDCALL brlapi_leaveTtyMode(void);
00400 #endif
00401 int BRLAPI_STDCALL brlapi__leaveTtyMode(brlapi_handle_t *handle);
00402
00403
00414 #ifndef BRLAPI_NO_SINGLE_SESSION
00415 int BRLAPI_STDCALL brlapi_setFocus(int tty);
00416 #endif
00417 int BRLAPI_STDCALL brlapi__setFocus(brlapi_handle_t *handle, int tty);
00418
00438
00453 #ifndef BRLAPI_NO_SINGLE_SESSION
00454 int BRLAPI_STDCALL brlapi_writeText(int cursor, const char *text);
00455 #endif
00456 int BRLAPI_STDCALL brlapi__writeText(brlapi_handle_t *handle, int cursor, const char *text);
00457
00458
00466 #ifndef BRLAPI_NO_SINGLE_SESSION
00467 int BRLAPI_STDCALL brlapi_writeDots(const unsigned char *dots);
00468 #endif
00469 int BRLAPI_STDCALL brlapi__writeDots(brlapi_handle_t *handle, const unsigned char *dots);
00470
00471
00473 typedef struct {
00474 int displayNumber ;
00475 unsigned int regionBegin ;
00476 unsigned int regionSize ;
00477 char *text ;
00478 int textSize ;
00479 unsigned char *andMask ;
00480 unsigned char *orMask ;
00481 int cursor ;
00482 char *charset ;
00483 } brlapi_writeArguments_t;
00484
00489 #define BRLAPI_DISPLAY_DEFAULT -1
00490
00495 #define BRLAPI_CURSOR_LEAVE -1
00496
00501 #define BRLAPI_CURSOR_OFF 0
00502
00503
00513 #define BRLAPI_WRITEARGUMENTS_INITIALIZER { BRLAPI_DISPLAY_DEFAULT, 0, 0, NULL, -1, NULL, NULL, BRLAPI_CURSOR_LEAVE, NULL }
00514
00515
00552 #ifndef BRLAPI_NO_SINGLE_SESSION
00553 int BRLAPI_STDCALL brlapi_write(const brlapi_writeArguments_t *arguments);
00554 #endif
00555 int BRLAPI_STDCALL brlapi__write(brlapi_handle_t *handle, const brlapi_writeArguments_t *arguments);
00556
00559 #include "brlapi_keycodes.h"
00560
00574
00576 typedef struct {
00577 unsigned int type ;
00578 unsigned int command ;
00579 unsigned int argument ;
00580 unsigned int flags ;
00581 } brlapi_expandedKeyCode_t;
00582
00583
00591 int BRLAPI_STDCALL brlapi_expandKeyCode (brlapi_keyCode_t code, brlapi_expandedKeyCode_t *expansion);
00592
00593
00595 typedef struct {
00596 const char *type ;
00597 const char *command ;
00598 unsigned int argument ;
00599 unsigned int flags ;
00600 const char *flag[64 - BRLAPI_KEY_FLAGS_SHIFT] ;
00601 brlapi_expandedKeyCode_t values ;
00602 } brlapi_describedKeyCode_t;
00603
00604
00612 int BRLAPI_STDCALL brlapi_describeKeyCode (brlapi_keyCode_t code, brlapi_describedKeyCode_t *description);
00613
00615 #define BRLAPI_UC_ROW 0x2800UL
00616
00620 #define BRLAPI_MAXKEYSETSIZE (BRLAPI_MAXPACKETSIZE / sizeof(brlapi_keyCode_t))
00621
00622
00687 #ifndef BRLAPI_NO_SINGLE_SESSION
00688 int BRLAPI_STDCALL brlapi_readKey(int wait, brlapi_keyCode_t *code);
00689 #endif
00690 int BRLAPI_STDCALL brlapi__readKey(brlapi_handle_t *handle, int wait, brlapi_keyCode_t *code);
00691
00693 typedef enum {
00694 brlapi_rangeType_all,
00695 brlapi_rangeType_type,
00696 brlapi_rangeType_command,
00697 brlapi_rangeType_key,
00698 brlapi_rangeType_code,
00699 } brlapi_rangeType_t;
00700
00701
00714 #ifndef BRLAPI_NO_SINGLE_SESSION
00715 int BRLAPI_STDCALL brlapi_ignoreKeys(brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00716 #endif
00717 int BRLAPI_STDCALL brlapi__ignoreKeys(brlapi_handle_t *handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00718
00719
00732 #ifndef BRLAPI_NO_SINGLE_SESSION
00733 int BRLAPI_STDCALL brlapi_acceptKeys(brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00734 #endif
00735 int BRLAPI_STDCALL brlapi__acceptKeys(brlapi_handle_t *handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
00736
00737
00743 #ifndef BRLAPI_NO_SINGLE_SESSION
00744 int BRLAPI_STDCALL brlapi_ignoreAllKeys(void);
00745 #define brlapi_ignoreAllKeys() brlapi_ignoreKeys(brlapi_rangeType_all, NULL, 0)
00746 #endif
00747 int BRLAPI_STDCALL brlapi__ignoreAllKeys(brlapi_handle_t *handle);
00748 #define brlapi__ignoreAllKeys(handle) brlapi__ignoreKeys(handle, brlapi_rangeType_all, NULL, 0)
00749
00750
00759 #ifndef BRLAPI_NO_SINGLE_SESSION
00760 int BRLAPI_STDCALL brlapi_acceptAllKeys(void);
00761 #define brlapi_acceptAllKeys() brlapi_acceptKeys(brlapi_rangeType_all, NULL, 0)
00762 #endif
00763 int BRLAPI_STDCALL brlapi__acceptAllKeys(brlapi_handle_t *handle);
00764 #define brlapi__acceptAllKeys(handle) brlapi__acceptKeys(handle, brlapi_rangeType_all, NULL, 0)
00765
00770 typedef struct {
00771 brlapi_keyCode_t first;
00772 brlapi_keyCode_t last;
00773 } brlapi_range_t;
00774
00775
00786 #ifndef BRLAPI_NO_SINGLE_SESSION
00787 int BRLAPI_STDCALL brlapi_ignoreKeyRanges(brlapi_range_t ranges[], unsigned int count);
00788 #endif
00789 int BRLAPI_STDCALL brlapi__ignoreKeyRanges(brlapi_handle_t *handle, brlapi_range_t ranges[], unsigned int count);
00790
00791
00802 #ifndef BRLAPI_NO_SINGLE_SESSION
00803 int BRLAPI_STDCALL brlapi_acceptKeyRanges(brlapi_range_t ranges[], unsigned int count);
00804 #endif
00805 int BRLAPI_STDCALL brlapi__acceptKeyRanges(brlapi_handle_t *handle, brlapi_range_t ranges[], unsigned int count);
00831
00836 #ifndef BRLAPI_NO_SINGLE_SESSION
00837 int BRLAPI_STDCALL brlapi_enterRawMode(const char *driver);
00838 #endif
00839 int BRLAPI_STDCALL brlapi__enterRawMode(brlapi_handle_t *handle, const char *driver);
00840
00841
00844 #ifndef BRLAPI_NO_SINGLE_SESSION
00845 int BRLAPI_STDCALL brlapi_leaveRawMode(void);
00846 #endif
00847 int BRLAPI_STDCALL brlapi__leaveRawMode(brlapi_handle_t *handle);
00848
00849
00855 #ifndef BRLAPI_NO_SINGLE_SESSION
00856 ssize_t BRLAPI_STDCALL brlapi_sendRaw(const void *buffer, size_t size);
00857 #endif
00858 ssize_t BRLAPI_STDCALL brlapi__sendRaw(brlapi_handle_t *handle, const void *buffer, size_t size);
00859
00860
00867 #ifndef BRLAPI_NO_SINGLE_SESSION
00868 ssize_t BRLAPI_STDCALL brlapi_recvRaw(void *buffer, size_t size);
00869 #endif
00870 ssize_t BRLAPI_STDCALL brlapi__recvRaw(brlapi_handle_t *handle, void *buffer, size_t size);
00871
00872
00877 #ifndef BRLAPI_NO_SINGLE_SESSION
00878 int BRLAPI_STDCALL brlapi_suspendDriver(const char *driver);
00879 #endif
00880 int BRLAPI_STDCALL brlapi__suspendDriver(brlapi_handle_t *handle, const char *driver);
00881
00882
00886 #ifndef BRLAPI_NO_SINGLE_SESSION
00887 int BRLAPI_STDCALL brlapi_resumeDriver(void);
00888 #endif
00889 int BRLAPI_STDCALL brlapi__resumeDriver(brlapi_handle_t *handle);
00913
00914 #define BRLAPI_ERROR_SUCCESS 0
00915 #define BRLAPI_ERROR_NOMEM 1
00916 #define BRLAPI_ERROR_TTYBUSY 2
00917 #define BRLAPI_ERROR_DEVICEBUSY 3
00918 #define BRLAPI_ERROR_UNKNOWN_INSTRUCTION 4
00919 #define BRLAPI_ERROR_ILLEGAL_INSTRUCTION 5
00920 #define BRLAPI_ERROR_INVALID_PARAMETER 6
00921 #define BRLAPI_ERROR_INVALID_PACKET 7
00922 #define BRLAPI_ERROR_CONNREFUSED 8
00923 #define BRLAPI_ERROR_OPNOTSUPP 9
00924 #define BRLAPI_ERROR_GAIERR 10
00925 #define BRLAPI_ERROR_LIBCERR 11
00926 #define BRLAPI_ERROR_UNKNOWNTTY 12
00927 #define BRLAPI_ERROR_PROTOCOL_VERSION 13
00928 #define BRLAPI_ERROR_EOF 14
00929 #define BRLAPI_ERROR_EMPTYKEY 15
00930 #define BRLAPI_ERROR_DRIVERERROR 16
00931 #define BRLAPI_ERROR_AUTHENTICATION 17
00933
00934
00938 extern const char *brlapi_errlist[];
00939
00940
00942 extern const int brlapi_nerr;
00943
00944
00949 void BRLAPI_STDCALL brlapi_perror(const char *s);
00950
00951
00953 typedef struct {
00954 int brlerrno;
00955 int libcerrno;
00956 int gaierrno;
00957 const char *errfun;
00958 } brlapi_error_t;
00959
00968 brlapi_error_t * BRLAPI_STDCALL brlapi_error_location(void);
00969
00978 extern brlapi_error_t brlapi_error;
00979
00981 extern int brlapi_errno;
00983 extern int brlapi_libcerrno;
00985 extern int brlapi_gaierrno;
00987 extern const char *brlapi_errfun;
00988
00990 #define brlapi_error (*brlapi_error_location())
00991
00992 #define brlapi_errno (brlapi_error.brlerrno)
00993
00994 #define brlapi_libcerrno (brlapi_error.libcerrno)
00995
00996 #define brlapi_gaierrno (brlapi_error.gaierrno)
00997
00998 #define brlapi_errfun (brlapi_error.errfun)
00999
01000
01006 const char * BRLAPI_STDCALL brlapi_strerror(const brlapi_error_t *error);
01007
01009 typedef uint32_t brlapi_packetType_t;
01010
01011
01017 const char * BRLAPI_STDCALL brlapi_getPacketTypeName(brlapi_packetType_t type);
01018
01019
01031 #ifndef BRLAPI_NO_SINGLE_SESSION
01032 typedef void (BRLAPI_STDCALL *brlapi_exceptionHandler_t)(int error, brlapi_packetType_t type, const void *packet, size_t size);
01033 #endif
01034 typedef void (BRLAPI_STDCALL *brlapi__exceptionHandler_t)(brlapi_handle_t *handle, int error, brlapi_packetType_t type, const void *packet, size_t size);
01035
01036
01046 #ifndef BRLAPI_NO_SINGLE_SESSION
01047 int BRLAPI_STDCALL brlapi_strexception(char *buffer, size_t bufferSize, int error, brlapi_packetType_t type, const void *packet, size_t packetSize);
01048 #endif
01049 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);
01050
01051
01060 #ifndef BRLAPI_NO_SINGLE_SESSION
01061 brlapi_exceptionHandler_t BRLAPI_STDCALL brlapi_setExceptionHandler(brlapi_exceptionHandler_t handler);
01062 #endif
01063 brlapi__exceptionHandler_t BRLAPI_STDCALL brlapi__setExceptionHandler(brlapi_handle_t *handle, brlapi__exceptionHandler_t handler);
01064
01065 #ifndef BRLAPI_NO_SINGLE_SESSION
01066 void BRLAPI_STDCALL brlapi_defaultExceptionHandler(int error, brlapi_packetType_t type, const void *packet, size_t size);
01067 #endif
01068 void BRLAPI_STDCALL brlapi__defaultExceptionHandler(brlapi_handle_t *handle, int error, brlapi_packetType_t type, const void *packet, size_t size);
01069
01072
01073 #ifdef BRLAPI_WIN32
01074 #ifndef BRLAPI_NO_SINGLE_SESSION
01075 int BRLAPI_STDCALL brlapi_writeTextWin(int cursor, const void *str, int wide);
01076 #endif
01077 int BRLAPI_STDCALL brlapi__writeTextWin(brlapi_handle_t *handle, int cursor, const void *str, int wide);
01078
01079 #ifndef BRLAPI_NO_SINGLE_SESSION
01080 int BRLAPI_STDCALL brlapi_writeWin(const brlapi_writeArguments_t *s, int wide);
01081 #endif
01082 int BRLAPI_STDCALL brlapi__writeWin(brlapi_handle_t *handle, const brlapi_writeArguments_t *s, int wide);
01083
01084 #ifdef UNICODE
01085 #ifndef BRLAPI_NO_SINGLE_SESSION
01086 #define brlapi_writeText(cursor, str) brlapi_writeTextWin(cursor, str, 1)
01087 #endif
01088 #define brlapi__writeText(handle, cursor, str) brlapi__writeTextWin(handle, cursor, str, 1)
01089
01090 #ifndef BRLAPI_NO_SINGLE_SESSION
01091 #define brlapi_write(s) brlapi_writeWin(s, 1)
01092 #endif
01093 #define brlapi__write(handle, s) brlapi__writeWin(handle, s, 1)
01094
01095 #else
01096
01097 #ifndef BRLAPI_NO_SINGLE_SESSION
01098 #define brlapi_writeText(cursor, str) brlapi_writeTextWin(cursor, str, 0)
01099 #endif
01100 #define brlapi__writeText(handle, cursor, str) brlapi__writeTextWin(handle, cursor, str, 0)
01101
01102 #ifndef BRLAPI_NO_SINGLE_SESSION
01103 #define brlapi_write(s) brlapi_writeWin(s, 0)
01104 #endif
01105 #define brlapi__write(handle, s) brlapi__writeWin(handle, s, 0)
01106
01107 #endif
01108 #endif
01109
01110 #ifndef BRLAPI_NO_DEPRECATED
01111
01123 #define brlapi_settings_t brlapi_connectionSettings_t
01124
01126 typedef struct {
01127 int displayNumber;
01128 unsigned int regionBegin;
01129 unsigned int regionSize;
01130 char *text;
01131 int textSize;
01132 unsigned char *attrAnd;
01133 unsigned char *attrOr;
01134 int cursor;
01135 char *charset;
01136 } brlapi_writeStruct;
01137 #define BRLAPI_WRITESTRUCT_INITIALIZER BRLAPI_WRITEARGUMENTS_INITIALIZER
01138
01139 #define brl_keycode_t brlapi_keyCode_t
01140 #define brl_type_t brlapi_packetType_t
01141
01142 #define BRLCOMMANDS NULL
01143 #define BRL_KEYCODE_MAX BRLAPI_KEY_MAX
01144
01145 #ifndef BRLAPI_NO_SINGLE_SESSION
01146 #define brlapi_initializeConnection brlapi_openConnection
01147 #define brlapi_getTty brlapi_enterTtyMode
01148 #define brlapi_getTtyPath brlapi_enterTtyModeWithPath
01149 #define brlapi_leaveTty brlapi_leaveTtyMode
01150 #define brlapi_unignoreKeyRange brlapi_acceptKeyRange
01151 #define brlapi_unignoreKeySet brlapi_acceptKeySet
01152 #define brlapi_getRaw brlapi_enterRawMode
01153 #define brlapi_leaveRaw brlapi_leaveRawMode
01154 #define brlapi_suspend brlapi_suspendDriver
01155 #define brlapi_resume brlapi_resumeDriver
01156 #endif
01157
01158 #define BRLERR_SUCCESS BRLAPI_ERROR_SUCCESS
01159 #define BRLERR_NOMEM BRLAPI_ERROR_NOMEM
01160 #define BRLERR_TTYBUSY BRLAPI_ERROR_TTYBUSY
01161 #define BRLERR_DEVICEBUSY BRLAPI_ERROR_DEVICEBUSY
01162 #define BRLERR_UNKNOWN_INSTRUCTION BRLAPI_ERROR_UNKNOWN_INSTRUCTION
01163 #define BRLERR_ILLEGAL_INSTRUCTION BRLAPI_ERROR_ILLEGAL_INSTRUCTION
01164 #define BRLERR_INVALID_PARAMETER BRLAPI_ERROR_INVALID_PARAMETER
01165 #define BRLERR_INVALID_PACKET BRLAPI_ERROR_INVALID_PACKET
01166 #define BRLERR_CONNREFUSED BRLAPI_ERROR_CONNREFUSED
01167 #define BRLERR_OPNOTSUPP BRLAPI_ERROR_OPNOTSUPP
01168 #define BRLERR_GAIERR BRLAPI_ERROR_GAIERR
01169 #define BRLERR_LIBCERR BRLAPI_ERROR_LIBCERR
01170 #define BRLERR_UNKNOWNTTY BRLAPI_ERROR_UNKNOWNTTY
01171 #define BRLERR_PROTOCOL_VERSION BRLAPI_ERROR_PROTOCOL_VERSION
01172 #define BRLERR_EOF BRLAPI_ERROR_EOF
01173 #define BRLERR_EMPTYKEY BRLAPI_ERROR_EMPTYKEY
01174 #define BRLERR_DRIVERERROR BRLAPI_ERROR_DRIVERERROR
01175
01177 #endif
01178
01179 #ifdef __cplusplus
01180 }
01181 #endif
01182
01183 #endif