00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #ifndef _BRLAPI_H
00028 #define _BRLAPI_H
00029
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034
00035 #define BRLAPI_RELEASE "0.3.2"
00036
00037
00038 #include <inttypes.h>
00039 #ifndef UINT32_MAX
00040 #define UINT32_MAX (4294967295U)
00041 #endif
00042
00043
00044 #include <unistd.h>
00045
00048 #define BRLAPI_MAXPACKETSIZE 512
00049
00061 #define BRLAPI_SOCKETPORTNUM 35751
00062 #define BRLAPI_SOCKETPORT "35751"
00063
00065 #define BRLAPI_SOCKETPATH "/var/lib/BrlAPI/"
00066
00071 #define BRLAPI_ETCDIR "/etc"
00072
00076 #define BRLAPI_AUTHFILE "brlapi.key"
00077
00079 #define BRLAPI_DEFAUTHPATH BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00080
00111 typedef struct {
00118 char *authKey;
00119
00128 char *hostName;
00129 } brlapi_settings_t;
00130
00131
00175 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00176
00177
00184 void brlapi_closeConnection(void);
00185
00186
00199 int brlapi_loadAuthKey(const char *filename, size_t *authlength, void *auth);
00200
00214
00226 int brlapi_getDriverId(unsigned char *id, size_t n);
00227
00228
00240 int brlapi_getDriverName(unsigned char *name, size_t n);
00241
00242
00244 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00245
00270
00296 int brlapi_getTty(int tty, int how);
00297
00299 #define BRLCOMMANDS 0
00300
00301 #define BRLKEYCODES 1
00302
00303
00310 int brlapi_leaveTty(void);
00311
00312
00323 int brlapi_setFocus(int tty);
00324
00339
00350 int brlapi_writeText(int cursor, const unsigned char *str);
00351
00352
00360 int brlapi_writeDots(const unsigned char *dots);
00361
00362
00364 typedef struct {
00365 int displayNumber;
00366 unsigned int regionBegin, regionEnd;
00367 char *text;
00368 char *attrAnd;
00369 char *attrOr;
00370 int cursor;
00371 } brlapi_writeStruct;
00372
00373
00381 #define BRLAPI_WRITESTRUCT_INITIALIZER \
00382 { -1, 0, 0, NULL, NULL, NULL, -1};
00383
00384
00391 int brlapi_write(const brlapi_writeStruct *s);
00392
00415 #define BRL_KEYBUF_SIZE 256
00416
00421 typedef uint32_t brl_keycode_t;
00422
00426 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00427
00428
00463 int brlapi_readKey(int block, brl_keycode_t *code);
00464
00465
00474 int brlapi_ignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00475
00476
00485 int brlapi_ignoreKeySet(const brl_keycode_t *s, unsigned int n);
00486
00487
00498 int brlapi_unignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00499
00500
00511 int brlapi_unignoreKeySet(const brl_keycode_t *s, unsigned int n);
00512
00533
00536 int brlapi_getRaw(void);
00537
00538
00541 int brlapi_leaveRaw(void);
00542
00543
00549 ssize_t brlapi_sendRaw(const unsigned char *buf, size_t size);
00550
00551
00558 ssize_t brlapi_recvRaw(unsigned char *buf, size_t size);
00559
00583
00584 #define BRLERR_SUCCESS 0
00585 #define BRLERR_NOMEM 1
00586 #define BRLERR_TTYBUSY 2
00587 #define BRLERR_RAWMODEBUSY 3
00588 #define BRLERR_UNKNOWN_INSTRUCTION 4
00589 #define BRLERR_ILLEGAL_INSTRUCTION 5
00590 #define BRLERR_INVALID_PARAMETER 6
00591 #define BRLERR_INVALID_PACKET 7
00592 #define BRLERR_RAWNOTSUPP 8
00593 #define BRLERR_KEYSNOTSUPP 9
00594 #define BRLERR_CONNREFUSED 10
00595 #define BRLERR_OPNOTSUPP 11
00596 #define BRLERR_GAIERR 12
00597 #define BRLERR_LIBCERR 13
00598 #define BRLERR_UNKNOWNTTY 14
00599 #define BRLERR_PROTOCOL_VERSION 15
00600 #define BRLERR_EOF 16
00601 #define BRLERR_TOORECURSE 17
00602 #define BRLERR_DRIVERERROR 18
00604
00605
00609 extern const char *brlapi_errlist[];
00610
00611
00613 extern const int brlapi_nerr;
00614
00615
00620 void brlapi_perror(const char *s);
00621
00630 int *brlapi_errno_location(void);
00631
00637 extern int brlapi_errno;
00639 #define brlapi_errno (*brlapi_errno_location ())
00640
00641
00647 const char *brlapi_strerror(int err);
00648
00650 typedef uint32_t brl_type_t;
00651
00652
00658 const char *brlapi_packetType(brl_type_t ptype);
00659
00660
00671 typedef void (*brlapi_errorHandler_t)(int err, brl_type_t type, const void *buf, size_t size);
00672
00673
00682 brlapi_errorHandler_t brlapi_setErrorHandler(brlapi_errorHandler_t handler);
00683 void brlapi_defaultErrorHandler(int err, brl_type_t type, const void *buf, size_t size);
00684
00687 #include <pthread.h>
00688
00689
00715 extern pthread_mutex_t brlapi_fd_mutex;
00716
00717 #ifdef __cplusplus
00718 }
00719 #endif
00720
00721 #endif