brlapi.h Source File

Main Page Modules Data Structures File List Data Fields Globals

# brlapi.h

Go to the documentation of this file.

    00001 /* Programs/brlapi.h.  Generated by configure.  */
    00002 /*
    00003  * BRLTTY - A background process providing access to the Linux console (when in
    00004  *          text mode) for a blind person using a refreshable braille display.
    00005  *
    00006  * Copyright (C) 1995-2003 by The BRLTTY Team. All rights reserved.
    00007  *
    00008  * BRLTTY comes with ABSOLUTELY NO WARRANTY.
    00009  *
    00010  * This is free software, placed under the terms of the
    00011  * GNU General Public License, as published by the Free Software
    00012  * Foundation.  Please see the file COPYING for details.
    00013  *
    00014  * Web Page: http://mielke.cc/brltty/
    00015  *
    00016  * This software is maintained by Dave Mielke <dave@mielke.cc>.
    00017  */
    00018
    00023 #ifndef _BRLAPI_H
    00024 #define _BRLAPI_H
    00025
    00026 #ifdef __cplusplus
    00027 extern "C" {
    00028 #endif /* __cplusplus */
    00029
    00030 /* Define this to be a string containing the library version. */
    00031 #define BRLAPI_RELEASE "0.1.0"
    00032
    00033 /* this is for UINT32_MAX */
    00034 #include <inttypes.h>
    00035 /* The type size_t is defined there! */
    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 /* brlapi_initializeConnection */
    00157 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
    00158
    00159 /* brlapi_closeConnection */
    00167 void brlapi_closeConnection(void);
    00168
    00169 /* brlapi_loadAuthKey */
    00182 int brlapi_loadAuthKey(const char *filename, int *authlength, void *auth);
    00183
    00184 /* brlapi_getControllingTty */
    00206 int brlapi_getControllingTty(void);
    00207
    00221 /* brlapi_getDriverId */
    00228 char *brlapi_getDriverId(void);
    00229
    00230 /* brlapi_getDriverName */
    00237 char *brlapi_getDriverName(void);
    00238
    00239 /* brlapi_getDisplaySize */
    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 /* brlapi_getTty */
    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 /* brlapi_leaveTty */
    00312 int brlapi_leaveTty(void);
    00313
    00328 /* brlapi_writeBrl */
    00339 int brlapi_writeBrl(uint32_t cursor, const char *str);
    00340
    00341 /* brlapi_writeBrlDots */
    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 /* brlapi_readKey */
    00410 int brlapi_readKey(int block, brl_keycode_t *code);
    00411
    00412 /* brlapi_readCommand */
    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 /* brlapi_readBinding */
    00471 int brlapi_readBinding(int block, const char **code);
    00472
    00473 /* brlapi_ignoreKeys */
    00482 int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
    00483
    00484 /* brlapi_unignoreKeys */
    00495 int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
    00496
    00517 /* brlapi_getRaw */
    00520 int brlapi_getRaw(void);
    00521
    00522 /* brlapi_leaveRaw */
    00525 int brlapi_leaveRaw(void);
    00526
    00527 /* brlapi_sendRaw */
    00533 int brlapi_sendRaw(const unsigned char *buf, size_t size);
    00534
    00535 /* brlapi_recvRaw */
    00542 int brlapi_recvRaw(unsigned char *buf, size_t size);
    00543
    00551 /* Error codes */
    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 /* brlapi_errlist */
    00568
    00572 extern const char *brlapi_errlist[];
    00573
    00574 /* brlapi_nerr */
    00576 extern const int brlapi_nerr;
    00577
    00578 /* brlapi_perror */
    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 /* brlapi_writePacket */
    00657 int brlapi_writePacket(int fd, brl_type_t type, const void *buf, size_t size);
    00658
    00659 /* brlapi_readPacket */
    00672 int brlapi_readPacket(int fd, brl_type_t *type, void *buf, size_t size);
    00673
    00674 #include <pthread.h>
    00675
    00676 /* brlapi_fd_mutex */
    00702 extern pthread_mutex_t brlapi_fd_mutex;
    00703
    00706 #ifdef __cplusplus
    00707 }
    00708 #endif /* __cplusplus */
    00709
    00710 #endif /* _BRLAPI_H */