Main Page   Modules   Data Structures   File List   Data Fields   Globals  

api.h

Go to the documentation of this file.
00001 /* Programs/api.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-2004 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.2.0"
00032 
00033 /* this is for UINT32_MAX */
00034 #include <inttypes.h>
00035 #ifndef UINT32_MAX
00036 #define UINT32_MAX (4294967295U)
00037 #endif /* UINT32_MAX */
00038 
00039 /* The type size_t is defined there! */
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 /* brlapi_initializeConnection */
00163 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00164 
00165 /* brlapi_closeConnection */
00172 void brlapi_closeConnection(void);
00173 
00174 /* brlapi_loadAuthKey */
00187 int brlapi_loadAuthKey(const char *filename, size_t *authlength, void *auth);
00188 
00202 /* brlapi_getDriverId */
00214 int brlapi_getDriverId(unsigned char *id, size_t n);
00215 
00216 /* brlapi_getDriverName */
00228 int brlapi_getDriverName(unsigned char *name, size_t n);
00229 
00230 /* brlapi_getDisplaySize */
00232 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00233 
00258 /* brlapi_getTty */
00284 int brlapi_getTty(int tty, int how);
00285 
00287 #define BRLKEYCODES 1
00288 
00289 #define BRLCOMMANDS 2
00290 
00291 /* brlapi_leaveTty */
00298 int brlapi_leaveTty(void);
00299 
00314 /* brlapi_writeBrl */
00325 int brlapi_writeBrl(int cursor, const unsigned char *str);
00326 
00327 /* brlapi_writeBrlDots */
00335 int brlapi_writeBrlDots(const unsigned char *dots);
00336 
00337 /* brlapi_extWriteStruct */
00339 typedef struct {
00340   int displayNumber; 
00341   uint32_t regionBegin, regionEnd; 
00342   char *text; 
00343   char *attrAnd; 
00344   char *attrOr; 
00345   int cursor; /* -1 == don't touch, 0 == turn off, 1 = 1st char of display, ... */
00346 } brlapi_extWriteStruct;
00347 
00348 /* BRLAPI_EXTWRITESTRUCT_INITIALIZER */
00357 #define BRLAPI_EXTWRITESTRUCT_INITIALIZER \
00358   { -1, 0, 0, NULL, NULL, NULL, -1};
00359 
00360 /* brlapi_extWriteBrl */
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 /* brlapi_readKey */
00428 int brlapi_readKey(int block, brl_keycode_t *code);
00429 
00430 /* brlapi_readCommand */
00452 int brlapi_readCommand(int block, brl_keycode_t *code);
00453 
00454 /* brlapi_ignoreKeys */
00463 int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
00464 
00465 /* brlapi_unignoreKeys */
00476 int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
00477 
00498 /* brlapi_getRaw */
00501 int brlapi_getRaw(void);
00502 
00503 /* brlapi_leaveRaw */
00506 int brlapi_leaveRaw(void);
00507 
00508 /* brlapi_sendRaw */
00514 ssize_t brlapi_sendRaw(const unsigned char *buf, size_t size);
00515 
00516 /* brlapi_recvRaw */
00523 ssize_t brlapi_recvRaw(unsigned char *buf, size_t size);
00524 
00532 /* Error codes */
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 /* brlapi_errlist */
00551 
00555 extern const char *brlapi_errlist[];
00556 
00557 /* brlapi_nerr */
00559 extern const int brlapi_nerr;
00560 
00561 /* brlapi_perror */
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 /* brlapi_strerror */
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 /* brlapi_writePacket */
00672 ssize_t brlapi_writePacket(int fd, brl_type_t type, const void *buf, size_t size);
00673 
00674 /* brlapi_readPacket */
00690 ssize_t brlapi_readPacket(int fd, brl_type_t *type, void *buf, size_t size);
00691 
00692 #include <pthread.h>
00693 
00694 /* brlapi_fd_mutex */
00720 extern pthread_mutex_t brlapi_fd_mutex;
00721 
00724 #ifdef __cplusplus
00725 }
00726 #endif /* __cplusplus */
00727 
00728 #endif /* _BRLAPI_H */

Generated on Sat Jun 12 00:53:18 2004 for BrlAPI by doxygen1.2.18