00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef _BRLAPI_H
00024 #define _BRLAPI_H
00025
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030
00031 #define BRLAPI_RELEASE "0.2.0"
00032
00033
00034 #include <inttypes.h>
00035 #ifndef UINT32_MAX
00036 #define UINT32_MAX (4294967295U)
00037 #endif
00038
00039
00040 #include <unistd.h>
00041
00044 #define BRLAPI_MAXPACKETSIZE 512
00045
00057 #define BRLAPI_SOCKETPORT "35751"
00058
00063 #define BRLAPI_ETCDIR "/etc"
00064
00068 #define BRLAPI_AUTHFILE "brlapi.key"
00069
00071 #define BRLAPI_DEFAUTHPATH BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00072
00103 typedef struct {
00110 char *authKey;
00111
00120 char *hostName;
00121 } brlapi_settings_t;
00122
00123
00167 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00168
00169
00176 void brlapi_closeConnection(void);
00177
00178
00191 int brlapi_loadAuthKey(const char *filename, size_t *authlength, void *auth);
00192
00206
00218 int brlapi_getDriverId(unsigned char *id, size_t n);
00219
00220
00232 int brlapi_getDriverName(unsigned char *name, size_t n);
00233
00234
00236 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00237
00262
00288 int brlapi_getTty(int tty, int how);
00289
00291 #define BRLKEYCODES 1
00292
00293 #define BRLCOMMANDS 2
00294
00295
00302 int brlapi_leaveTty(void);
00303
00318
00329 int brlapi_writeBrl(int cursor, const unsigned char *str);
00330
00331
00339 int brlapi_writeBrlDots(const unsigned char *dots);
00340
00341
00343 typedef struct {
00344 int displayNumber;
00345 uint32_t regionBegin, regionEnd;
00346 char *text;
00347 char *attrAnd;
00348 char *attrOr;
00349 int cursor;
00350 } brlapi_extWriteStruct;
00351
00352
00361 #define BRLAPI_EXTWRITESTRUCT_INITIALIZER \
00362 { -1, 0, 0, NULL, NULL, NULL, -1};
00363
00364
00371 int brlapi_extWriteBrl(const brlapi_extWriteStruct *s);
00372
00395 #define BRL_KEYBUF_SIZE 256
00396
00401 typedef uint32_t brl_keycode_t;
00402
00406 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00407
00408
00432 int brlapi_readKey(int block, brl_keycode_t *code);
00433
00434
00456 int brlapi_readCommand(int block, brl_keycode_t *code);
00457
00458
00467 int brlapi_ignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00468
00469
00478 int brlapi_ignoreKeySet(const brl_keycode_t *s, uint32_t n);
00479
00480
00491 int brlapi_unignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00492
00493
00504 int brlapi_unignoreKeySet(const brl_keycode_t *s, uint32_t n);
00505
00526
00529 int brlapi_getRaw(void);
00530
00531
00534 int brlapi_leaveRaw(void);
00535
00536
00542 ssize_t brlapi_sendRaw(const unsigned char *buf, size_t size);
00543
00544
00551 ssize_t brlapi_recvRaw(unsigned char *buf, size_t size);
00552
00560
00561 #define BRLERR_SUCCESS 0
00562 #define BRLERR_NOMEM 1
00563 #define BRLERR_TTYBUSY 2
00564 #define BRLERR_UNKNOWN_INSTRUCTION 3
00565 #define BRLERR_ILLEGAL_INSTRUCTION 4
00566 #define BRLERR_INVALID_PARAMETER 5
00567 #define BRLERR_INVALID_PACKET 6
00568 #define BRLERR_RAWNOTSUPP 7
00569 #define BRLERR_KEYSNOTSUPP 8
00570 #define BRLERR_CONNREFUSED 9
00571 #define BRLERR_OPNOTSUPP 10
00572 #define BRLERR_GAIERR 11
00573 #define BRLERR_LIBCERR 12
00574 #define BRLERR_UNKNOWNTTY 13
00575 #define BRLERR_PROTOCOL_VERSION 14
00576 #define BRLERR_EOF 15
00578
00579
00583 extern const char *brlapi_errlist[];
00584
00585
00587 extern const int brlapi_nerr;
00588
00589
00594 void brlapi_perror(const char *s);
00595
00604 int *brlapi_errno_location(void);
00605
00611 extern int brlapi_errno;
00613 #define brlapi_errno (*brlapi_errno_location ())
00614
00615
00621 extern const char *brlapi_strerror(void);
00622
00626 #define BRLAPI_EWF_DISPLAYNUMBER 0X01
00627 #define BRLAPI_EWF_REGION 0X02
00628 #define BRLAPI_EWF_TEXT 0X04
00629 #define BRLAPI_EWF_ATTR_AND 0X08
00630 #define BRLAPI_EWF_ATTR_OR 0X10
00631 #define BRLAPI_EWF_CURSOR 0X20
00634 typedef struct {
00635 uint32_t flags;
00636 unsigned char data;
00637 } extWriteStruct;
00638
00639 #include <pthread.h>
00640
00641
00667 extern pthread_mutex_t brlapi_fd_mutex;
00668
00669 #ifdef __cplusplus
00670 }
00671 #endif
00672
00673 #endif