00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #ifndef BRLTTY_INCLUDED_API
00028 #define BRLTTY_INCLUDED_API
00029
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034
00035 #define BRLAPI_RELEASE "0.4.0"
00036
00037
00038 #include <sys/types.h>
00039
00040
00041 #include <stdint.h>
00042
00043
00044 #include <unistd.h>
00045
00057 #define BRLAPI_SOCKETPORTNUM 35751
00058 #define BRLAPI_SOCKETPORT "35751"
00059
00062 #define BRLAPI_MAXPACKETSIZE 512
00063
00065 #define BRLAPI_MAXNAMELENGTH 31
00066
00068 #ifdef WINDOWS
00069 #define BRLAPI_SOCKETPATH "\\\\.\\pipe\\BrlAPI"
00070 #else
00071 #define BRLAPI_SOCKETPATH "/var/lib/BrlAPI/"
00072 #endif
00073
00078 #define BRLAPI_ETCDIR "/etc"
00079
00083 #define BRLAPI_AUTHFILE "brlapi.key"
00084
00086 #define BRLAPI_DEFAUTHPATH BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00087
00118 typedef struct {
00125 char *authKey;
00126
00135 char *hostName;
00136 } brlapi_settings_t;
00137
00138
00184 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00185
00186
00193 void brlapi_closeConnection(void);
00194
00195
00196
00197 int brlapi_splitHost(const char *host, char **hostname, char **port);
00198
00199
00212 int brlapi_loadAuthKey(const char *filename, size_t *authlength, void *auth);
00213
00227
00239 int brlapi_getDriverId(char *id, size_t n);
00240
00241
00253 int brlapi_getDriverName(char *name, size_t n);
00254
00255
00257 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00258
00259
00261 int brlapi_getDriverInfo(void *buf, size_t count);
00262
00287
00288
00289 #define BRLCOMMANDS NULL
00290
00291
00319 int brlapi_getTty(int tty, const char *how);
00320
00321
00333 int brlapi_getTtyPath(int *ttys, int nttys, const char *how);
00334
00335
00342 int brlapi_leaveTty(void);
00343
00344
00355 int brlapi_setFocus(int tty);
00356
00376
00391 int brlapi_writeText(int cursor, const char *str);
00392
00393
00401 int brlapi_writeDots(const unsigned char *dots);
00402
00403
00405 typedef struct {
00406 int displayNumber;
00407 unsigned int regionBegin;
00408 unsigned int regionSize;
00409 char *text;
00410 unsigned char *attrAnd;
00411 unsigned char *attrOr;
00412 int cursor;
00413 char *charset;
00414 } brlapi_writeStruct;
00415
00416
00424 #define BRLAPI_WRITESTRUCT_INITIALIZER \
00425 { -1, 0, 0, NULL, NULL, NULL, -1, NULL };
00426
00427
00434 int brlapi_write(const brlapi_writeStruct *s);
00435
00455 typedef uint32_t brl_keycode_t;
00456
00460 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00461
00465 #define BRLAPI_MAXKEYSETSIZE (BRLAPI_MAXPACKETSIZE / sizeof(brl_keycode_t))
00466
00467
00502 int brlapi_readKey(int block, brl_keycode_t *code);
00503
00504
00513 int brlapi_ignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00514
00515
00524 int brlapi_ignoreKeySet(const brl_keycode_t *s, unsigned int n);
00525
00526
00537 int brlapi_unignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00538
00539
00550 int brlapi_unignoreKeySet(const brl_keycode_t *s, unsigned int n);
00551
00572
00577 int brlapi_getRaw(const char *driver);
00578
00579
00582 int brlapi_leaveRaw(void);
00583
00584
00590 ssize_t brlapi_sendRaw(const void *buf, size_t size);
00591
00592
00599 ssize_t brlapi_recvRaw(void *buf, size_t size);
00600
00625
00626 #define BRLERR_SUCCESS 0
00627 #define BRLERR_NOMEM 1
00628 #define BRLERR_TTYBUSY 2
00629 #define BRLERR_RAWMODEBUSY 3
00630 #define BRLERR_UNKNOWN_INSTRUCTION 4
00631 #define BRLERR_ILLEGAL_INSTRUCTION 5
00632 #define BRLERR_INVALID_PARAMETER 6
00633 #define BRLERR_INVALID_PACKET 7
00634 #define BRLERR_CONNREFUSED 8
00635 #define BRLERR_OPNOTSUPP 9
00636 #define BRLERR_GAIERR 10
00637 #define BRLERR_LIBCERR 11
00638 #define BRLERR_UNKNOWNTTY 12
00639 #define BRLERR_PROTOCOL_VERSION 13
00640 #define BRLERR_EOF 14
00641 #define BRLERR_EMPTYKEY 15
00642 #define BRLERR_DRIVERERROR 16
00644
00645
00649 extern const char *brlapi_errlist[];
00650
00651
00653 extern const int brlapi_nerr;
00654
00655
00660 void brlapi_perror(const char *s);
00661
00662
00664 typedef struct {
00665 int brlerrno;
00666 union {
00667 int libcerrno;
00668 int gaierrno;
00669 } exterrno;
00670 const char *errfun;
00671 } brlapi_error_t;
00672
00681 brlapi_error_t *brlapi_error_location(void);
00682
00691 extern brlapi_error_t brlapi_error;
00692
00694 extern int brlapi_errno;
00696 extern int brlapi_libcerrno;
00698 extern int brlapi_gaierrno;
00700 extern const char *brlapi_errfun;
00701
00703 #define brlapi_error (*brlapi_error_location())
00704
00705 #define brlapi_errno (brlapi_error.brlerrno)
00706
00707 #define brlapi_libcerrno (brlapi_error.exterrno.libcerrno)
00708
00709 #define brlapi_gaierrno (brlapi_error.exterrno.gaierrno)
00710
00711 #define brlapi_errfun (brlapi_error.errfun)
00712
00713
00719 const char *brlapi_strerror(const brlapi_error_t *error);
00720
00722 typedef uint32_t brl_type_t;
00723
00724
00730 const char *brlapi_packetType(brl_type_t ptype);
00731
00732
00743 typedef void (*brlapi_exceptionHandler_t)(int err, brl_type_t type, const void *buf, size_t size);
00744
00745
00755 int brlapi_strexception(char *buf, size_t n, int err, brl_type_t type, const void *packet, size_t
00756 size);
00757
00758
00767 brlapi_exceptionHandler_t brlapi_setExceptionHandler(brlapi_exceptionHandler_t handler);
00768 void brlapi_defaultExceptionHandler(int err, brl_type_t type, const void *buf, size_t size);
00769
00772 #ifdef __cplusplus
00773 }
00774 #endif
00775
00776 #endif