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
00163 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00164
00165
00172 void brlapi_closeConnection(void);
00173
00174
00187 int brlapi_loadAuthKey(const char *filename, size_t *authlength, void *auth);
00188
00202
00214 int brlapi_getDriverId(unsigned char *id, size_t n);
00215
00216
00228 int brlapi_getDriverName(unsigned char *name, size_t n);
00229
00230
00232 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00233
00258
00284 int brlapi_getTty(int tty, int how);
00285
00287 #define BRLKEYCODES 1
00288
00289 #define BRLCOMMANDS 2
00290
00291
00298 int brlapi_leaveTty(void);
00299
00314
00325 int brlapi_writeBrl(int cursor, const unsigned char *str);
00326
00327
00335 int brlapi_writeBrlDots(const unsigned char *dots);
00336
00337
00339 typedef struct {
00340 int displayNumber;
00341 uint32_t regionBegin, regionEnd;
00342 char *text;
00343 char *attrAnd;
00344 char *attrOr;
00345 int cursor;
00346 } brlapi_extWriteStruct;
00347
00348
00357 #define BRLAPI_EXTWRITESTRUCT_INITIALIZER \
00358 { -1, 0, 0, NULL, NULL, NULL, -1};
00359
00360
00367 int brlapi_extWriteBrl(const brlapi_extWriteStruct *s);
00368
00391 #define BRL_KEYBUF_SIZE 256
00392
00397 typedef uint32_t brl_keycode_t;
00398
00402 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00403
00404
00428 int brlapi_readKey(int block, brl_keycode_t *code);
00429
00430
00452 int brlapi_readCommand(int block, brl_keycode_t *code);
00453
00454
00463 int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
00464
00465
00476 int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
00477
00498
00501 int brlapi_getRaw(void);
00502
00503
00506 int brlapi_leaveRaw(void);
00507
00508
00514 ssize_t brlapi_sendRaw(const unsigned char *buf, size_t size);
00515
00516
00523 ssize_t brlapi_recvRaw(unsigned char *buf, size_t size);
00524
00532
00533 #define BRLERR_SUCCESS 0
00534 #define BRLERR_NOMEM 1
00535 #define BRLERR_TTYBUSY 2
00536 #define BRLERR_UNKNOWN_INSTRUCTION 3
00537 #define BRLERR_ILLEGAL_INSTRUCTION 4
00538 #define BRLERR_INVALID_PARAMETER 5
00539 #define BRLERR_INVALID_PACKET 6
00540 #define BRLERR_RAWNOTSUPP 7
00541 #define BRLERR_KEYSNOTSUPP 8
00542 #define BRLERR_CONNREFUSED 9
00543 #define BRLERR_OPNOTSUPP 10
00544 #define BRLERR_GAIERR 11
00545 #define BRLERR_LIBCERR 12
00546 #define BRLERR_UNKNOWNTTY 13
00547 #define BRLERR_PROTOCOL_VERSION 14
00548 #define BRLERR_EOF 15
00550
00551
00555 extern const char *brlapi_errlist[];
00556
00557
00559 extern const int brlapi_nerr;
00560
00561
00566 void brlapi_perror(const char *s);
00567
00576 int *brlapi_errno_location(void);
00577
00583 extern int brlapi_errno;
00585 #define brlapi_errno (*brlapi_errno_location ())
00586
00587
00593 extern const char *brlapi_strerror(void);
00594
00609 #define BRLAPI_MAXPACKETSIZE 512
00610
00612 typedef uint32_t brl_type_t;
00613
00614 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 2)
00616 #define BRLPACKET_AUTHKEY 'K'
00617 #define BRLPACKET_BYE 'B'
00618 #define BRLPACKET_GETDRIVERID 'd'
00619 #define BRLPACKET_GETDRIVERNAME 'n'
00620 #define BRLPACKET_GETDISPLAYSIZE 's'
00621 #define BRLPACKET_GETTTY 't'
00622 #define BRLPACKET_LEAVETTY 'L'
00623 #define BRLPACKET_KEY 'k'
00624 #define BRLPACKET_COMMAND 'c'
00625 #define BRLPACKET_MASKKEYS 'm'
00626 #define BRLPACKET_UNMASKKEYS 'u'
00627 #define BRLPACKET_WRITEDOTS 'D'
00628 #define BRLPACKET_STATWRITE 'S'
00629 #define BRLPACKET_EXTWRITE 'e'
00630 #define BRLPACKET_GETRAW '*'
00631 #define BRLPACKET_LEAVERAW '#'
00632 #define BRLPACKET_PACKET 'p'
00633 #define BRLPACKET_ACK 'A'
00634 #define BRLPACKET_ERROR 'E'
00637 #define BRLRAW_MAGIC (0xdeadbeefL)
00638
00640 #define BRLAPI_EWF_DISPLAYNUMBER 0X01
00641 #define BRLAPI_EWF_REGION 0X02
00642 #define BRLAPI_EWF_TEXT 0X04
00643 #define BRLAPI_EWF_ATTR_AND 0X08
00644 #define BRLAPI_EWF_ATTR_OR 0X10
00645 #define BRLAPI_EWF_CURSOR 0X20
00648 typedef struct {
00649 uint32_t flags;
00650 unsigned char data;
00651 } extWriteStruct;
00652
00653 typedef struct {
00654 uint32_t protocolVersion;
00655 unsigned char key;
00656 } authStruct;
00657
00658
00672 ssize_t brlapi_writePacket(int fd, brl_type_t type, const void *buf, size_t size);
00673
00674
00690 ssize_t brlapi_readPacket(int fd, brl_type_t *type, void *buf, size_t size);
00691
00692 #include <pthread.h>
00693
00694
00720 extern pthread_mutex_t brlapi_fd_mutex;
00721
00724 #ifdef __cplusplus
00725 }
00726 #endif
00727
00728 #endif