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.1"
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_AUTHNAME BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00068
00099 typedef struct
00100
{
00107 char *authKey;
00108
00117 char *hostName;
00118 }
brlapi_settings_t;
00119
00120
00161
int brlapi_initializeConnection(
const brlapi_settings_t *clientSettings,
brlapi_settings_t *usedSettings);
00162
00163
00171
void brlapi_closeConnection(
void);
00172
00173
00186
int brlapi_loadAuthKey(
const char *filename,
int *authlength,
void *auth);
00187
00188
00210
int brlapi_getControllingTty(
void);
00211
00225
00232
char *
brlapi_getDriverId(
void);
00233
00234
00241
char *
brlapi_getDriverName(
void);
00242
00243
00245
int brlapi_getDisplaySize(
unsigned int *x,
unsigned int *y);
00246
00257 typedef struct
00258
{
00263 const char *client;
00264 }
brlapi_keybinding_t;
00265
00288
00304
int brlapi_getTty(uint32_t tty, uint32_t how,
brlapi_keybinding_t *keybinding);
00305
00307 #define BRLKEYCODES ((uint32_t) 1)
00308
00309 #define BRLCOMMANDS ((uint32_t) 2)
00310
00311
00316
int brlapi_leaveTty(
void);
00317
00332
00343
int brlapi_writeBrl(uint32_t cursor,
const char *str);
00344
00345
00353
int brlapi_writeBrlDots(
const char *dots);
00354
00377 #define BRL_KEYBUF_SIZE 256
00378
00383 typedef uint32_t
brl_keycode_t;
00384
00388 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00389
00390
00414
int brlapi_readKey(
int block, brl_keycode_t *code);
00415
00416
00438
int brlapi_readCommand(
int block, brl_keycode_t *code);
00439
00444 #define BRLAPI_HOMEKEYDIR ".brlkeys"
00445
00448 #define BRLAPI_HOMEKEYEXT ".kbd"
00449
00455 #define BRLAPI_ETCKEYFILE "brlkeys"
00456
00457
00475
int brlapi_readBinding(
int block,
const char **code);
00476
00477
00486
int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
00487
00488
00499
int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
00500
00521
00524
int brlapi_getRaw(
void);
00525
00526
00529
int brlapi_leaveRaw(
void);
00530
00531
00537
int brlapi_sendRaw(
const unsigned char *buf, size_t size);
00538
00539
00546
int brlapi_recvRaw(
unsigned char *buf, size_t size);
00547
00555
00556 #define BRLERR_SUCCESS 0
00557 #define BRLERR_NOMEM 1
00558 #define BRLERR_TTYBUSY 2
00559 #define BRLERR_UNKNOWN_INSTRUCTION 3
00560 #define BRLERR_ILLEGAL_INSTRUCTION 4
00561 #define BRLERR_INVALID_PARAMETER 5
00562 #define BRLERR_INVALID_PACKET 6
00563 #define BRLERR_RAWNOTSUPP 7
00564 #define BRLERR_KEYSNOTSUPP 8
00565 #define BRLERR_CONNREFUSED 9
00566 #define BRLERR_OPNOTSUPP 10
00567 #define BRLERR_GAIERR 11
00568 #define BRLERR_LIBCERR 12
00569 #define BRLERR_UNKNOWNTTY 13
00571
00572
00576 extern const char *
brlapi_errlist[];
00577
00578
00580 extern const int brlapi_nerr;
00581
00582
00587
void brlapi_perror(
const char *s);
00588
00597
int *
brlapi_errno_location(
void);
00598
00604 extern int brlapi_errno;
00606 #define brlapi_errno (*brlapi_errno_location ())
00607
00622 #define BRLAPI_MAXPACKETSIZE 512
00623
00625 typedef uint32_t
brl_type_t;
00626
00627 #define BRLPACKET_AUTHKEY 'K'
00628 #define BRLPACKET_BYE 'B'
00629 #define BRLPACKET_GETDRIVERID 'd'
00630 #define BRLPACKET_GETDRIVERNAME 'n'
00631 #define BRLPACKET_GETDISPLAYSIZE 's'
00632 #define BRLPACKET_GETTTY 't'
00633 #define BRLPACKET_LEAVETTY 'L'
00634 #define BRLPACKET_KEY 'k'
00635 #define BRLPACKET_COMMAND 'c'
00636 #define BRLPACKET_MASKKEYS 'm'
00637 #define BRLPACKET_UNMASKKEYS 'u'
00638 #define BRLPACKET_WRITE 'W'
00639 #define BRLPACKET_WRITEDOTS 'D'
00640 #define BRLPACKET_STATWRITE 'S'
00641 #define BRLPACKET_GETRAW '*'
00642 #define BRLPACKET_LEAVERAW '#'
00643 #define BRLPACKET_PACKET 'p'
00644 #define BRLPACKET_ACK 'A'
00645 #define BRLPACKET_ERROR 'E'
00648 #define BRLRAW_MAGIC (0xdeadbeefL)
00649
00650
00661
int brlapi_writePacket(
int fd, brl_type_t type,
const void *buf, size_t size);
00662
00663
00676
int brlapi_readPacket(
int fd, brl_type_t *type,
void *buf, size_t size);
00677
00678
#include <pthread.h>
00679
00680
00706 extern pthread_mutex_t
brlapi_fd_mutex;
00707
00710
#ifdef __cplusplus
00711
}
00712
#endif
00713
00714
#endif