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.0"
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 
00259 /* brlapi_getDriverInfo */
00261 int brlapi_getDriverInfo(void *buf, size_t count);
00262 
00287 /* The following macro is for backward compatibility. */
00288 /* It should be removed in the long run. */
00289 #define BRLCOMMANDS NULL
00290 
00291 /* brlapi_getTty */
00319 int brlapi_getTty(int tty, const char *how);
00320 
00321 /* brlapi_getTtyPath */
00333 int brlapi_getTtyPath(int *ttys, int nttys, const char *how);
00334 
00335 /* brlapi_leaveTty */
00342 int brlapi_leaveTty(void);
00343 
00344 /* brlapi_setFocus */
00355 int brlapi_setFocus(int tty);
00356 
00376 /* brlapi_writeText */
00391 int brlapi_writeText(int cursor, const char *str);
00392 
00393 /* brlapi_writeDots */
00401 int brlapi_writeDots(const unsigned char *dots);
00402 
00403 /* brlapi_writeStruct */
00405 typedef struct {
00406   int displayNumber; 
00407   unsigned int regionBegin; 
00408   unsigned int regionSize; 
00409   char *text; 
00410   unsigned char *attrAnd; 
00411   unsigned char *attrOr; 
00412   int cursor; 
00413   char *charset; 
00414 } brlapi_writeStruct;
00415 
00416 /* BRLAPI_WRITESTRUCT_INITIALIZER */
00424 #define BRLAPI_WRITESTRUCT_INITIALIZER \
00425   { -1, 0, 0, NULL, NULL, NULL, -1, NULL };
00426 
00427 /* brlapi_write */
00434 int brlapi_write(const brlapi_writeStruct *s);
00435 
00455 typedef uint32_t brl_keycode_t;
00456 
00460 #define BRL_KEYCODE_MAX ((brl_keycode_t) (UINT32_MAX))
00461 
00465 #define BRLAPI_MAXKEYSETSIZE (BRLAPI_MAXPACKETSIZE / sizeof(brl_keycode_t))
00466 
00467 /* brlapi_readKey */
00502 int brlapi_readKey(int block, brl_keycode_t *code);
00503 
00504 /* brlapi_ignoreKeyRange */
00513 int brlapi_ignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00514 
00515 /* brlapi_ignoreKeySet */
00524 int brlapi_ignoreKeySet(const brl_keycode_t *s, unsigned int n);
00525 
00526 /* brlapi_unignoreKeyRange */
00537 int brlapi_unignoreKeyRange(brl_keycode_t x, brl_keycode_t y);
00538 
00539 /* brlapi_unignoreKeySet */
00550 int brlapi_unignoreKeySet(const brl_keycode_t *s, unsigned int n);
00551 
00572 /* brlapi_getRaw */
00577 int brlapi_getRaw(const char *driver);
00578 
00579 /* brlapi_leaveRaw */
00582 int brlapi_leaveRaw(void);
00583 
00584 /* brlapi_sendRaw */
00590 ssize_t brlapi_sendRaw(const void *buf, size_t size);
00591 
00592 /* brlapi_recvRaw */
00599 ssize_t brlapi_recvRaw(void *buf, size_t size);
00600 
00625 /* Error codes */
00626 #define BRLERR_SUCCESS                  0  
00627 #define BRLERR_NOMEM                    1  
00628 #define BRLERR_TTYBUSY                  2  
00629 #define BRLERR_RAWMODEBUSY              3  
00630 #define BRLERR_UNKNOWN_INSTRUCTION      4  
00631 #define BRLERR_ILLEGAL_INSTRUCTION      5  
00632 #define BRLERR_INVALID_PARAMETER        6  
00633 #define BRLERR_INVALID_PACKET           7  
00634 #define BRLERR_CONNREFUSED              8  
00635 #define BRLERR_OPNOTSUPP                9  
00636 #define BRLERR_GAIERR                  10  
00637 #define BRLERR_LIBCERR                 11  
00638 #define BRLERR_UNKNOWNTTY              12  
00639 #define BRLERR_PROTOCOL_VERSION        13  
00640 #define BRLERR_EOF                     14  
00641 #define BRLERR_EMPTYKEY                15  
00642 #define BRLERR_DRIVERERROR             16  
00644 /* brlapi_errlist */
00645 
00649 extern const char *brlapi_errlist[];
00650 
00651 /* brlapi_nerr */
00653 extern const int brlapi_nerr;
00654 
00655 /* brlapi_perror */
00660 void brlapi_perror(const char *s);
00661 
00662 /* brlapi_error_t */
00664 typedef struct {
00665   int brlerrno;
00666   union {
00667     int libcerrno;
00668     int gaierrno;
00669   } exterrno;
00670   const char *errfun;
00671 } brlapi_error_t;
00672 
00681 brlapi_error_t *brlapi_error_location(void);
00682 
00691 extern brlapi_error_t brlapi_error;
00692 
00694 extern int brlapi_errno;
00696 extern int brlapi_libcerrno;
00698 extern int brlapi_gaierrno;
00700 extern const char *brlapi_errfun;
00701 
00703 #define brlapi_error (*brlapi_error_location())
00704 
00705 #define brlapi_errno (brlapi_error.brlerrno)
00706 
00707 #define brlapi_libcerrno (brlapi_error.exterrno.libcerrno)
00708 
00709 #define brlapi_gaierrno (brlapi_error.exterrno.gaierrno)
00710 
00711 #define brlapi_errfun (brlapi_error.errfun)
00712 
00713 /* brlapi_strerror */
00719 const char *brlapi_strerror(const brlapi_error_t *error);
00720 
00722 typedef uint32_t brl_type_t;
00723 
00724 /* brlapi_packetType */
00730 const char *brlapi_packetType(brl_type_t ptype);
00731 
00732 /* brlapi_exceptionHandler_t */
00743 typedef void (*brlapi_exceptionHandler_t)(int err, brl_type_t type, const void *buf, size_t size);
00744 
00745 /* brlapi_strexception */
00755 int brlapi_strexception(char *buf, size_t n, int err, brl_type_t type, const void *packet, size_t
00756 size);
00757 
00758 /* brlapi_setExceptionHandler */
00767 brlapi_exceptionHandler_t brlapi_setExceptionHandler(brlapi_exceptionHandler_t handler);
00768 void brlapi_defaultExceptionHandler(int err, brl_type_t type, const void *buf, size_t size);
00769 
00772 #ifdef __cplusplus
00773 }
00774 #endif /* __cplusplus */
00775 
00776 #endif /* BRLTTY_INCLUDED_API */

Generated on Sat Sep 17 15:15:33 2005 for BrlAPI by  doxygen 1.4.4