Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

api.h

Go to the documentation of this file.
00001 /* Programs/api.h.  Generated by configure.  */
00002 /*
00003  * libbrlapi - A library providing access to braille terminals for applications.
00004  *
00005  * Copyright (C) 2002-2005 by
00006  *   Samuel Thibault <Samuel.Thibault@ens-lyon.org>
00007  *   Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>
00008  * All rights reserved.
00009  *
00010  * libbrlapi comes with ABSOLUTELY NO WARRANTY.
00011  *
00012  * This is free software, placed under the terms of the
00013  * GNU Lesser General Public License, as published by the Free Software
00014  * Foundation; either version 2.1 of the License,
00015  * or (at your option) any later version.
00016  * Please see the file COPYING-API for details.
00017  *
00018  * Web Page: http://mielke.cc/brltty/
00019  *
00020  * This software is maintained by Dave Mielke <dave@mielke.cc>.
00021  */
00022 
00027 #ifndef BRLTTY_INCLUDED_API
00028 #define BRLTTY_INCLUDED_API
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif /* __cplusplus */
00033 
00034 /* Define this to be a string containing the library version. */
00035 #define BRLAPI_RELEASE "0.4.1"
00036 
00037 /* Types are defined there */
00038 #include <sys/types.h>
00039 
00040 /* this is for UINT32_MAX */
00041 #include <stdint.h>
00042 
00043 /* NULL is defined there */
00044 #include <unistd.h>
00045 
00057 #define BRLAPI_SOCKETPORTNUM 35751
00058 #define BRLAPI_SOCKETPORT "35751"
00059 
00062 #define BRLAPI_MAXPACKETSIZE 512
00063 
00065 #define BRLAPI_MAXNAMELENGTH 31
00066 
00068 #ifdef WINDOWS
00069 #define BRLAPI_SOCKETPATH "\\\\.\\pipe\\BrlAPI"
00070 #else /* WINDOWS */
00071 #define BRLAPI_SOCKETPATH "/var/lib/BrlAPI/"
00072 #endif /* WINDOWS */
00073 
00078 #define BRLAPI_ETCDIR "/etc"
00079 
00083 #define BRLAPI_AUTHFILE "brlapi.key"
00084 
00086 #define BRLAPI_DEFAUTHPATH BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
00087 
00118 typedef struct {
00125   char *authKey;
00126 
00135   char *hostName;
00136 } brlapi_settings_t;
00137 
00138 /* brlapi_initializeConnection */
00184 int brlapi_initializeConnection(const brlapi_settings_t *clientSettings, brlapi_settings_t *usedSettings);
00185 
00186 /* brlapi_closeConnection */
00193 void brlapi_closeConnection(void);
00194 
00195 /* brlapi_splitHost */
00196 /* splits host into hostname & port, returns address family to use */
00197 int brlapi_splitHost(const char *host, char **hostname, char **port);
00198 
00199 /* brlapi_loadAuthKey */
00212 int brlapi_loadAuthKey(const char *filename, size_t *authlength, void *auth);
00213 
00227 /* brlapi_getDriverId */
00239 int brlapi_getDriverId(char *id, size_t n);
00240 
00241 /* brlapi_getDriverName */
00253 int brlapi_getDriverName(char *name, size_t n);
00254 
00255 /* brlapi_getDisplaySize */
00257 int brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
00258 
00283 /* The following macro is for backward compatibility. */
00284 /* It should be removed in the long run. */
00285 #define BRLCOMMANDS NULL
00286 
00287 /* brlapi_getTty */
00315 int brlapi_getTty(int tty, const char *how);
00316 
00317 /* brlapi_getTtyPath */
00329 int brlapi_getTtyPath(int *ttys, int nttys, const char *how);
00330 
00331 /* brlapi_leaveTty */
00338 int brlapi_leaveTty(void);
00339 
00340 /* brlapi_setFocus */
00351 int brlapi_setFocus(int tty);
00352 
00372 /* brlapi_writeText */
00387 int brlapi_writeText(int cursor, const char *str);
00388 
00389 /* brlapi_writeDots */
00397 int brlapi_writeDots(const unsigned char *dots);
00398 
00399 /* brlapi_writeStruct */
00401 typedef struct {
00402   int displayNumber; 
00403   unsigned int regionBegin; 
00404   unsigned int regionSize; 
00405   char *text; 
00406   unsigned char *attrAnd; 
00407   unsigned char *attrOr; 
00408   int cursor; 
00409   char *charset; 
00410 } brlapi_writeStruct;
00411 
00412 /* BRLAPI_WRITESTRUCT_INITIALIZER */
00420 #define BRLAPI_WRITESTRUCT_INITIALIZER \
00421   { -1, 0, 0, NULL, NULL, NULL, -1, NULL };
00422 
00423 /* brlapi_write */
00430 int brlapi_write(const brlapi_writeStruct *s);
00431 
00451 typedef uint32_t brl_keycode_t;
00452 
00456 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00457 
00461 #define BRLAPI_MAXKEYSETSIZE (BRLAPI_MAXPACKETSIZE / sizeof(brl_keycode_t))
00462 
00463 /* brlapi_readKey */
00498 int brlapi_readKey(int block, brl_keycode_t *code);
00499 
00500 /* brlapi_ignoreKeyRange */
00509 int brlapi_ignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00510 
00511 /* brlapi_ignoreKeySet */
00520 int brlapi_ignoreKeySet(const brl_keycode_t *s, unsigned int n);
00521 
00522 /* brlapi_unignoreKeyRange */
00533 int brlapi_unignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00534 
00535 /* brlapi_unignoreKeySet */
00546 int brlapi_unignoreKeySet(const brl_keycode_t *s, unsigned int n);
00547 
00568 /* brlapi_getRaw */
00573 int brlapi_getRaw(const char *driver);
00574 
00575 /* brlapi_leaveRaw */
00578 int brlapi_leaveRaw(void);
00579 
00580 /* brlapi_sendRaw */
00586 ssize_t brlapi_sendRaw(const void *buf, size_t size);
00587 
00588 /* brlapi_recvRaw */
00595 ssize_t brlapi_recvRaw(void *buf, size_t size);
00596 
00621 /* Error codes */
00622 #define BRLERR_SUCCESS                  0  
00623 #define BRLERR_NOMEM                    1  
00624 #define BRLERR_TTYBUSY                  2  
00625 #define BRLERR_RAWMODEBUSY              3  
00626 #define BRLERR_UNKNOWN_INSTRUCTION      4  
00627 #define BRLERR_ILLEGAL_INSTRUCTION      5  
00628 #define BRLERR_INVALID_PARAMETER        6  
00629 #define BRLERR_INVALID_PACKET           7  
00630 #define BRLERR_CONNREFUSED              8  
00631 #define BRLERR_OPNOTSUPP                9  
00632 #define BRLERR_GAIERR                  10  
00633 #define BRLERR_LIBCERR                 11  
00634 #define BRLERR_UNKNOWNTTY              12  
00635 #define BRLERR_PROTOCOL_VERSION        13  
00636 #define BRLERR_EOF                     14  
00637 #define BRLERR_EMPTYKEY                15  
00638 #define BRLERR_DRIVERERROR             16  
00640 /* brlapi_errlist */
00641 
00645 extern const char *brlapi_errlist[];
00646 
00647 /* brlapi_nerr */
00649 extern const int brlapi_nerr;
00650 
00651 /* brlapi_perror */
00656 void brlapi_perror(const char *s);
00657 
00658 /* brlapi_error_t */
00660 typedef struct {
00661   int brlerrno;
00662   union {
00663     int libcerrno;
00664     int gaierrno;
00665   } exterrno;
00666   const char *errfun;
00667 } brlapi_error_t;
00668 
00677 brlapi_error_t *brlapi_error_location(void);
00678 
00687 extern brlapi_error_t brlapi_error;
00688 
00690 extern int brlapi_errno;
00692 extern int brlapi_libcerrno;
00694 extern int brlapi_gaierrno;
00696 extern const char *brlapi_errfun;
00697 
00699 #define brlapi_error (*brlapi_error_location())
00700 
00701 #define brlapi_errno (brlapi_error.brlerrno)
00702 
00703 #define brlapi_libcerrno (brlapi_error.exterrno.libcerrno)
00704 
00705 #define brlapi_gaierrno (brlapi_error.exterrno.gaierrno)
00706 
00707 #define brlapi_errfun (brlapi_error.errfun)
00708 
00709 /* brlapi_strerror */
00715 const char *brlapi_strerror(const brlapi_error_t *error);
00716 
00718 typedef uint32_t brl_type_t;
00719 
00720 /* brlapi_packetType */
00726 const char *brlapi_packetType(brl_type_t ptype);
00727 
00728 /* brlapi_exceptionHandler_t */
00739 typedef void (*brlapi_exceptionHandler_t)(int err, brl_type_t type, const void *buf, size_t size);
00740 
00741 /* brlapi_strexception */
00751 int brlapi_strexception(char *buf, size_t n, int err, brl_type_t type, const void *packet, size_t
00752 size);
00753 
00754 /* brlapi_setExceptionHandler */
00763 brlapi_exceptionHandler_t brlapi_setExceptionHandler(brlapi_exceptionHandler_t handler);
00764 void brlapi_defaultExceptionHandler(int err, brl_type_t type, const void *buf, size_t size);
00765 
00768 #ifdef __cplusplus
00769 }
00770 #endif /* __cplusplus */
00771 
00772 #endif /* BRLTTY_INCLUDED_API */

Generated on Mon Dec 12 08:29:10 2005 for BrlAPI by  doxygen 1.4.4