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.1.0"
00032
00033
00034 #include <inttypes.h>
00035
00036 #include <unistd.h>
00037
00049 #define BRLAPI_SOCKETPORT "35751"
00050
00055 #define BRLAPI_ETCDIR "/etc"
00056
00060 #define BRLAPI_AUTHFILE "brlapi.key"
00061
00063 #define BRLAPI_AUTHNAME BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00064
00095 typedef struct
00096 {
00103 char *authKey;
00104
00113 char *hostName;
00114 } brlapi_settings_t;
00115
00116
00157 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00158
00159
00167 void brlapi_closeConnection(void);
00168
00169
00182 int brlapi_loadAuthKey(const char *filename, int *authlength, void *auth);
00183
00184
00206 int brlapi_getControllingTty(void);
00207
00221
00228 char *brlapi_getDriverId(void);
00229
00230
00237 char *brlapi_getDriverName(void);
00238
00239
00241 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00242
00253 typedef struct
00254 {
00259 const char *client;
00260 } brlapi_keybinding_t;
00261
00284
00300 int brlapi_getTty(uint32_t tty, uint32_t how, brlapi_keybinding_t *keybinding);
00301
00303 #define BRLKEYCODES ((uint32_t) 1)
00304
00305 #define BRLCOMMANDS ((uint32_t) 2)
00306
00307
00312 int brlapi_leaveTty(void);
00313
00328
00339 int brlapi_writeBrl(uint32_t cursor, const char *str);
00340
00341
00349 int brlapi_writeBrlDots(const char *dots);
00350
00373 #define BRL_KEYBUF_SIZE 256
00374
00379 typedef uint32_t brl_keycode_t;
00380
00384 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00385
00386
00410 int brlapi_readKey(int block, brl_keycode_t *code);
00411
00412
00434 int brlapi_readCommand(int block, brl_keycode_t *code);
00435
00440 #define BRLAPI_HOMEKEYDIR ".brlkeys"
00441
00444 #define BRLAPI_HOMEKEYEXT ".kbd"
00445
00451 #define BRLAPI_ETCKEYFILE "brlkeys"
00452
00453
00471 int brlapi_readBinding(int block, const char **code);
00472
00473
00482 int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
00483
00484
00495 int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
00496
00517
00520 int brlapi_getRaw(void);
00521
00522
00525 int brlapi_leaveRaw(void);
00526
00527
00533 int brlapi_sendRaw(const unsigned char *buf, size_t size);
00534
00535
00542 int brlapi_recvRaw(unsigned char *buf, size_t size);
00543
00551
00552 #define BRLERR_SUCCESS 0
00553 #define BRLERR_NOMEM 1
00554 #define BRLERR_TTYBUSY 2
00555 #define BRLERR_UNKNOWN_INSTRUCTION 3
00556 #define BRLERR_ILLEGAL_INSTRUCTION 4
00557 #define BRLERR_INVALID_PARAMETER 5
00558 #define BRLERR_INVALID_PACKET 6
00559 #define BRLERR_RAWNOTSUPP 7
00560 #define BRLERR_KEYSNOTSUPP 8
00561 #define BRLERR_CONNREFUSED 9
00562 #define BRLERR_OPNOTSUPP 10
00563 #define BRLERR_GAIERR 11
00564 #define BRLERR_LIBCERR 12
00565 #define BRLERR_UNKNOWNTTY 13
00567
00568
00572 extern const char *brlapi_errlist[];
00573
00574
00576 extern const int brlapi_nerr;
00577
00578
00583 void brlapi_perror(const char *s);
00584
00593 int *brlapi_errno_location(void);
00594
00600 extern int brlapi_errno;
00602 #define brlapi_errno (*brlapi_errno_location ())
00603
00618 #define BRLAPI_MAXPACKETSIZE 512
00619
00621 typedef uint32_t brl_type_t;
00622
00623 #define BRLPACKET_AUTHKEY 'K'
00624 #define BRLPACKET_BYE 'B'
00625 #define BRLPACKET_GETDRIVERID 'd'
00626 #define BRLPACKET_GETDRIVERNAME 'n'
00627 #define BRLPACKET_GETDISPLAYSIZE 's'
00628 #define BRLPACKET_GETTTY 't'
00629 #define BRLPACKET_LEAVETTY 'L'
00630 #define BRLPACKET_KEY 'k'
00631 #define BRLPACKET_COMMAND 'c'
00632 #define BRLPACKET_MASKKEYS 'm'
00633 #define BRLPACKET_UNMASKKEYS 'u'
00634 #define BRLPACKET_WRITE 'W'
00635 #define BRLPACKET_WRITEDOTS 'D'
00636 #define BRLPACKET_STATWRITE 'S'
00637 #define BRLPACKET_GETRAW '*'
00638 #define BRLPACKET_LEAVERAW '#'
00639 #define BRLPACKET_PACKET 'p'
00640 #define BRLPACKET_ACK 'A'
00641 #define BRLPACKET_ERROR 'E'
00644 #define BRLRAW_MAGIC (0xdeadbeefL)
00645
00646
00657 int brlapi_writePacket(int fd, brl_type_t type, const void *buf, size_t size);
00658
00659
00672 int brlapi_readPacket(int fd, brl_type_t *type, void *buf, size_t size);
00673
00674 #include <pthread.h>
00675
00676
00702 extern pthread_mutex_t brlapi_fd_mutex;
00703
00706 #ifdef __cplusplus
00707 }
00708 #endif
00709
00710 #endif