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.1"
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
00283
00284
00285 #define BRLCOMMANDS NULL
00286
00287
00315 int brlapi_getTty(int tty, const char *how);
00316
00317
00329 int brlapi_getTtyPath(int *ttys, int nttys, const char *how);
00330
00331
00338 int brlapi_leaveTty(void);
00339
00340
00351 int brlapi_setFocus(int tty);
00352
00372
00387 int brlapi_writeText(int cursor, const char *str);
00388
00389
00397 int brlapi_writeDots(const unsigned char *dots);
00398
00399
00401 typedef struct {
00402 int displayNumber;
00403 unsigned int regionBegin;
00404 unsigned int regionSize;
00405 char *text;
00406 unsigned char *attrAnd;
00407 unsigned char *attrOr;
00408 int cursor;
00409 char *charset;
00410 } brlapi_writeStruct;
00411
00412
00420 #define BRLAPI_WRITESTRUCT_INITIALIZER \
00421 { -1, 0, 0, NULL, NULL, NULL, -1, NULL };
00422
00423
00430 int brlapi_write(const brlapi_writeStruct *s);
00431
00451 typedef uint32_t brl_keycode_t;
00452
00456 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00457
00461 #define BRLAPI_MAXKEYSETSIZE (BRLAPI_MAXPACKETSIZE / sizeof(brl_keycode_t))
00462
00463
00498 int brlapi_readKey(int block, brl_keycode_t *code);
00499
00500
00509 int brlapi_ignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00510
00511
00520 int brlapi_ignoreKeySet(const brl_keycode_t *s, unsigned int n);
00521
00522
00533 int brlapi_unignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00534
00535
00546 int brlapi_unignoreKeySet(const brl_keycode_t *s, unsigned int n);
00547
00568
00573 int brlapi_getRaw(const char *driver);
00574
00575
00578 int brlapi_leaveRaw(void);
00579
00580
00586 ssize_t brlapi_sendRaw(const void *buf, size_t size);
00587
00588
00595 ssize_t brlapi_recvRaw(void *buf, size_t size);
00596
00621
00622 #define BRLERR_SUCCESS 0
00623 #define BRLERR_NOMEM 1
00624 #define BRLERR_TTYBUSY 2
00625 #define BRLERR_RAWMODEBUSY 3
00626 #define BRLERR_UNKNOWN_INSTRUCTION 4
00627 #define BRLERR_ILLEGAL_INSTRUCTION 5
00628 #define BRLERR_INVALID_PARAMETER 6
00629 #define BRLERR_INVALID_PACKET 7
00630 #define BRLERR_CONNREFUSED 8
00631 #define BRLERR_OPNOTSUPP 9
00632 #define BRLERR_GAIERR 10
00633 #define BRLERR_LIBCERR 11
00634 #define BRLERR_UNKNOWNTTY 12
00635 #define BRLERR_PROTOCOL_VERSION 13
00636 #define BRLERR_EOF 14
00637 #define BRLERR_EMPTYKEY 15
00638 #define BRLERR_DRIVERERROR 16
00640
00641
00645 extern const char *brlapi_errlist[];
00646
00647
00649 extern const int brlapi_nerr;
00650
00651
00656 void brlapi_perror(const char *s);
00657
00658
00660 typedef struct {
00661 int brlerrno;
00662 union {
00663 int libcerrno;
00664 int gaierrno;
00665 } exterrno;
00666 const char *errfun;
00667 } brlapi_error_t;
00668
00677 brlapi_error_t *brlapi_error_location(void);
00678
00687 extern brlapi_error_t brlapi_error;
00688
00690 extern int brlapi_errno;
00692 extern int brlapi_libcerrno;
00694 extern int brlapi_gaierrno;
00696 extern const char *brlapi_errfun;
00697
00699 #define brlapi_error (*brlapi_error_location())
00700
00701 #define brlapi_errno (brlapi_error.brlerrno)
00702
00703 #define brlapi_libcerrno (brlapi_error.exterrno.libcerrno)
00704
00705 #define brlapi_gaierrno (brlapi_error.exterrno.gaierrno)
00706
00707 #define brlapi_errfun (brlapi_error.errfun)
00708
00709
00715 const char *brlapi_strerror(const brlapi_error_t *error);
00716
00718 typedef uint32_t brl_type_t;
00719
00720
00726 const char *brlapi_packetType(brl_type_t ptype);
00727
00728
00739 typedef void (*brlapi_exceptionHandler_t)(int err, brl_type_t type, const void *buf, size_t size);
00740
00741
00751 int brlapi_strexception(char *buf, size_t n, int err, brl_type_t type, const void *packet, size_t
00752 size);
00753
00754
00763 brlapi_exceptionHandler_t brlapi_setExceptionHandler(brlapi_exceptionHandler_t handler);
00764 void brlapi_defaultExceptionHandler(int err, brl_type_t type, const void *buf, size_t size);
00765
00768 #ifdef __cplusplus
00769 }
00770 #endif
00771
00772 #endif