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 */
00160 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00161 
00162 /* brlapi_closeConnection */
00170 void brlapi_closeConnection(void);
00171 
00172 /* brlapi_loadAuthKey */
00185 int brlapi_loadAuthKey(const char *filename, int *authlength, void *auth);
00186 
00200 /* brlapi_getDriverId */
00211 int brlapi_getDriverId(unsigned char *id, size_t n);
00212 
00213 /* brlapi_getDriverName */
00224 int brlapi_getDriverName(unsigned char *name, size_t n);
00225 
00226 /* brlapi_getDisplaySize */
00228 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00229 
00254 /* brlapi_getTty */
00278 int brlapi_getTty(int tty, int how);
00279 
00281 #define BRLKEYCODES 1
00282 
00283 #define BRLCOMMANDS 2
00284 
00285 /* brlapi_leaveTty */
00290 int brlapi_leaveTty(void);
00291 
00306 /* brlapi_writeBrl */
00317 int brlapi_writeBrl(int cursor, const unsigned char *str);
00318 
00319 /* brlapi_writeBrlDots */
00327 int brlapi_writeBrlDots(const unsigned char *dots);
00328 
00329 /* brlapi_extWriteStruct */
00331 typedef struct {
00332   int displayNumber; 
00333   uint32_t regionBegin, regionEnd; 
00334   char *text; 
00335   char *attrAnd; 
00336   char *attrOr; 
00337   int cursor; /* -1 == don't touch, 0 == turn off, 1 = 1st char of display, ... */
00338 } brlapi_extWriteStruct;
00339 
00340 /* BRLAPI_EXTWRITESTRUCT_INITIALIZER */
00349 #define BRLAPI_EXTWRITESTRUCT_INITIALIZER \
00350   { -1, 0, 0, NULL, NULL, NULL, -1};
00351 
00352 /* brlapi_extWriteBrl */
00359 int brlapi_extWriteBrl(const brlapi_extWriteStruct *s);
00360 
00383 #define BRL_KEYBUF_SIZE 256
00384 
00389 typedef uint32_t brl_keycode_t;
00390 
00394 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00395 
00396 /* brlapi_readKey */
00420 int brlapi_readKey(int block, brl_keycode_t *code);
00421 
00422 /* brlapi_readCommand */
00444 int brlapi_readCommand(int block, brl_keycode_t *code);
00445 
00446 /* brlapi_ignoreKeys */
00455 int brlapi_ignoreKeys(brl_keycode_t x, brl_keycode_t y);
00456 
00457 /* brlapi_unignoreKeys */
00468 int brlapi_unignoreKeys(brl_keycode_t x, brl_keycode_t y);
00469 
00490 /* brlapi_getRaw */
00493 int brlapi_getRaw(void);
00494 
00495 /* brlapi_leaveRaw */
00498 int brlapi_leaveRaw(void);
00499 
00500 /* brlapi_sendRaw */
00506 int brlapi_sendRaw(const unsigned char *buf, size_t size);
00507 
00508 /* brlapi_recvRaw */
00515 int brlapi_recvRaw(unsigned char *buf, size_t size);
00516 
00524 /* Error codes */
00525 #define BRLERR_SUCCESS                  0  
00526 #define BRLERR_NOMEM                    1  
00527 #define BRLERR_TTYBUSY                  2  
00528 #define BRLERR_UNKNOWN_INSTRUCTION      3  
00529 #define BRLERR_ILLEGAL_INSTRUCTION      4  
00530 #define BRLERR_INVALID_PARAMETER        5  
00531 #define BRLERR_INVALID_PACKET           6  
00532 #define BRLERR_RAWNOTSUPP               7  
00533 #define BRLERR_KEYSNOTSUPP              8  
00534 #define BRLERR_CONNREFUSED              9  
00535 #define BRLERR_OPNOTSUPP               10  
00536 #define BRLERR_GAIERR                  11  
00537 #define BRLERR_LIBCERR                 12  
00538 #define BRLERR_UNKNOWNTTY              13  
00539 #define BRLERR_PROTOCOL_VERSION        14  
00541 /* brlapi_errlist */
00542 
00546 extern const char *brlapi_errlist[];
00547 
00548 /* brlapi_nerr */
00550 extern const int brlapi_nerr;
00551 
00552 /* brlapi_perror */
00557 void brlapi_perror(const char *s);
00558 
00567 int *brlapi_errno_location(void);
00568 
00574 extern int brlapi_errno;
00576 #define brlapi_errno (*brlapi_errno_location ())
00577 
00578 /* brlapi_strerror */
00584 extern const char *brlapi_strerror(void);
00585 
00600 #define BRLAPI_MAXPACKETSIZE 512
00601 
00603 typedef uint32_t brl_type_t;
00604 
00605 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 2) 
00607 #define BRLPACKET_AUTHKEY           'K'    
00608 #define BRLPACKET_BYE               'B'    
00609 #define BRLPACKET_GETDRIVERID       'd'    
00610 #define BRLPACKET_GETDRIVERNAME     'n'    
00611 #define BRLPACKET_GETDISPLAYSIZE    's'    
00612 #define BRLPACKET_GETTTY            't'    
00613 #define BRLPACKET_LEAVETTY          'L'    
00614 #define BRLPACKET_KEY               'k'    
00615 #define BRLPACKET_COMMAND           'c'    
00616 #define BRLPACKET_MASKKEYS          'm'    
00617 #define BRLPACKET_UNMASKKEYS        'u'    
00618 #define BRLPACKET_WRITEDOTS         'D'    
00619 #define BRLPACKET_STATWRITE         'S'    
00620 #define BRLPACKET_EXTWRITE          'e'    
00621 #define BRLPACKET_GETRAW            '*'    
00622 #define BRLPACKET_LEAVERAW          '#'    
00623 #define BRLPACKET_PACKET            'p'    
00624 #define BRLPACKET_ACK               'A'    
00625 #define BRLPACKET_ERROR             'E'    
00628 #define BRLRAW_MAGIC (0xdeadbeefL)
00629 
00631 #define BRLAPI_EWF_DISPLAYNUMBER 0X01   
00632 #define BRLAPI_EWF_REGION        0X02   
00633 #define BRLAPI_EWF_TEXT          0X04   
00634 #define BRLAPI_EWF_ATTR_AND      0X08   
00635 #define BRLAPI_EWF_ATTR_OR       0X10   
00636 #define BRLAPI_EWF_CURSOR        0X20   
00639 typedef struct {
00640   uint32_t flags;
00641   unsigned char data;
00642 } extWriteStruct;
00643 
00644 typedef struct {
00645   uint32_t protocolVersion;
00646   unsigned char key;
00647 } authStruct;
00648 
00649 /* brlapi_writePacket */
00660 int brlapi_writePacket(int fd, brl_type_t type, const void *buf, size_t size);
00661 
00662 /* brlapi_readPacket */
00675 int brlapi_readPacket(int fd, brl_type_t *type, void *buf, size_t size);
00676 
00677 #include <pthread.h>
00678 
00679 /* brlapi_fd_mutex */
00705 extern pthread_mutex_t brlapi_fd_mutex;
00706 
00709 #ifdef __cplusplus
00710 }
00711 #endif /* __cplusplus */
00712 
00713 #endif /* _BRLAPI_H */

Generated on Mon Mar 8 11:45:58 2004 for BrlAPI by doxygen1.2.18