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
00053 #define BRLAPI_SOCKETPORT "35751"
00054
00059 #define BRLAPI_ETCDIR "/etc"
00060
00064 #define BRLAPI_AUTHFILE "brlapi.key"
00065
00067 #define BRLAPI_DEFAUTHPATH BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00068
00099 typedef struct {
00106 char *authKey;
00107
00116 char *hostName;
00117 } brlapi_settings_t;
00118
00119
00160 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00161
00162
00170 void brlapi_closeConnection(void);
00171
00172
00185 int brlapi_loadAuthKey(const char *filename, int *authlength, void *auth);
00186
00200
00211 int brlapi_getDriverId(unsigned char *id, size_t n);
00212
00213
00224 int brlapi_getDriverName(unsigned char *name, size_t n);
00225
00226
00228 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00229
00254
00278 int brlapi_getTty(int tty, int how);
00279
00281 #define BRLKEYCODES 1
00282
00283 #define BRLCOMMANDS 2
00284
00285
00290 int brlapi_leaveTty(void);
00291
00306
00317 int brlapi_writeBrl(int cursor, const unsigned char *str);
00318
00319
00327 int brlapi_writeBrlDots(const unsigned char *dots);
00328
00329
00331 typedef struct {
00332 int displayNumber;
00333 uint32_t regionBegin, regionEnd;
00334 char *text;
00335 char *attrAnd;
00336 char *attrOr;
00337 int cursor;
00338 } brlapi_extWriteStruct;
00339
00340
00349 #define BRLAPI_EXTWRITESTRUCT_INITIALIZER \
00350 { -1, 0, 0, NULL, NULL, NULL, -1};
00351
00352
00359 int brlapi_extWriteBrl(const brlapi_extWriteStruct *s);
00360
00383 #define BRL_KEYBUF_SIZE 256
00384
00389 typedef uint32_t brl_keycode_t;
00390
00394 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00395
00396
00420 int brlapi_readKey(int block, brl_keycode_t *code);
00421
00422
00444 int brlapi_readCommand(int block, brl_keycode_t *code);
00445
00446
00455 int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
00456
00457
00468 int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
00469
00490
00493 int brlapi_getRaw(void);
00494
00495
00498 int brlapi_leaveRaw(void);
00499
00500
00506 int brlapi_sendRaw(const unsigned char *buf, size_t size);
00507
00508
00515 int brlapi_recvRaw(unsigned char *buf, size_t size);
00516
00524
00525 #define BRLERR_SUCCESS 0
00526 #define BRLERR_NOMEM 1
00527 #define BRLERR_TTYBUSY 2
00528 #define BRLERR_UNKNOWN_INSTRUCTION 3
00529 #define BRLERR_ILLEGAL_INSTRUCTION 4
00530 #define BRLERR_INVALID_PARAMETER 5
00531 #define BRLERR_INVALID_PACKET 6
00532 #define BRLERR_RAWNOTSUPP 7
00533 #define BRLERR_KEYSNOTSUPP 8
00534 #define BRLERR_CONNREFUSED 9
00535 #define BRLERR_OPNOTSUPP 10
00536 #define BRLERR_GAIERR 11
00537 #define BRLERR_LIBCERR 12
00538 #define BRLERR_UNKNOWNTTY 13
00539 #define BRLERR_PROTOCOL_VERSION 14
00541
00542
00546 extern const char *brlapi_errlist[];
00547
00548
00550 extern const int brlapi_nerr;
00551
00552
00557 void brlapi_perror(const char *s);
00558
00567 int *brlapi_errno_location(void);
00568
00574 extern int brlapi_errno;
00576 #define brlapi_errno (*brlapi_errno_location ())
00577
00578
00584 extern const char *brlapi_strerror(void);
00585
00600 #define BRLAPI_MAXPACKETSIZE 512
00601
00603 typedef uint32_t brl_type_t;
00604
00605 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 2)
00607 #define BRLPACKET_AUTHKEY 'K'
00608 #define BRLPACKET_BYE 'B'
00609 #define BRLPACKET_GETDRIVERID 'd'
00610 #define BRLPACKET_GETDRIVERNAME 'n'
00611 #define BRLPACKET_GETDISPLAYSIZE 's'
00612 #define BRLPACKET_GETTTY 't'
00613 #define BRLPACKET_LEAVETTY 'L'
00614 #define BRLPACKET_KEY 'k'
00615 #define BRLPACKET_COMMAND 'c'
00616 #define BRLPACKET_MASKKEYS 'm'
00617 #define BRLPACKET_UNMASKKEYS 'u'
00618 #define BRLPACKET_WRITEDOTS 'D'
00619 #define BRLPACKET_STATWRITE 'S'
00620 #define BRLPACKET_EXTWRITE 'e'
00621 #define BRLPACKET_GETRAW '*'
00622 #define BRLPACKET_LEAVERAW '#'
00623 #define BRLPACKET_PACKET 'p'
00624 #define BRLPACKET_ACK 'A'
00625 #define BRLPACKET_ERROR 'E'
00628 #define BRLRAW_MAGIC (0xdeadbeefL)
00629
00631 #define BRLAPI_EWF_DISPLAYNUMBER 0X01
00632 #define BRLAPI_EWF_REGION 0X02
00633 #define BRLAPI_EWF_TEXT 0X04
00634 #define BRLAPI_EWF_ATTR_AND 0X08
00635 #define BRLAPI_EWF_ATTR_OR 0X10
00636 #define BRLAPI_EWF_CURSOR 0X20
00639 typedef struct {
00640 uint32_t flags;
00641 unsigned char data;
00642 } extWriteStruct;
00643
00644 typedef struct {
00645 uint32_t protocolVersion;
00646 unsigned char key;
00647 } authStruct;
00648
00649
00660 int brlapi_writePacket(int fd, brl_type_t type, const void *buf, size_t size);
00661
00662
00675 int brlapi_readPacket(int fd, brl_type_t *type, void *buf, size_t size);
00676
00677 #include <pthread.h>
00678
00679
00705 extern pthread_mutex_t brlapi_fd_mutex;
00706
00709 #ifdef __cplusplus
00710 }
00711 #endif
00712
00713 #endif