BrlAPI  1.0
brlapi.h
Go to the documentation of this file.
1 /* Programs/brlapi.h. Generated from brlapi.h.in by configure. */
2 /*
3  * libbrlapi - A library providing access to braille terminals for applications.
4  *
5  * Copyright (C) 2002-2012 by
6  * Samuel Thibault <Samuel.Thibault@ens-lyon.org>
7  * Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>
8  *
9  * libbrlapi comes with ABSOLUTELY NO WARRANTY.
10  *
11  * This is free software, placed under the terms of the
12  * GNU Lesser General Public License, as published by the Free Software
13  * Foundation; either version 2.1 of the License, or (at your option) any
14  * later version. Please see the file LICENSE-LGPL for details.
15  *
16  * Web Page: http://mielke.cc/brltty/
17  *
18  * This software is maintained by Dave Mielke <dave@mielke.cc>.
19  */
20 
25 #ifndef BRLAPI_INCLUDED
26 #define BRLAPI_INCLUDED
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 
32 /* #undef BRLAPI_WIN32 */
33 
38 #define BRLAPI_RELEASE "0.5.7"
39 
41 #define BRLAPI_MAJOR 0
42 
44 #define BRLAPI_MINOR 5
45 
47 #define BRLAPI_REVISION 7
48 
51 /* Types are defined there */
52 #include <sys/types.h>
53 
54 #ifdef BRLAPI_WIN32
55 #include <windows.h>
56 #define BRLAPI_STDCALL __stdcall
57 #else /* BRLAPI_WIN32 */
58 #define BRLAPI_STDCALL
59 #endif /* BRLAPI_WIN32 */
60 
61 #ifdef _MSC_VER
62 typedef __int64 uint64_t;
63 typedef __int32 uint32_t;
64 #define UINT64_C(x) (x ## Ui64)
65 #define PRIx64 "I64x"
66 typedef signed int ssize_t;
67 #else /* _MSC_VER */
68 
69 /* this is for uint*_t */
70 #include <stdint.h>
71 
72 /* NULL is defined there */
73 #include <unistd.h>
74 
75 #include <inttypes.h> /* For PRIx64 */
76 #endif /* _MSC_VER */
77 
101 
104 
118 #define BRLAPI_SOCKETPORTNUM 4101
119 #define BRLAPI_SOCKETPORT "4101"
120 
122 #define BRLAPI_SOCKETPATH "/var/lib/BrlAPI"
123 
128 #define BRLAPI_ETCDIR "/etc"
129 
133 #define BRLAPI_AUTHKEYFILE "brlapi.key"
134 
136 #define BRLAPI_DEFAUTH BRLAPI_ETCDIR "/" BRLAPI_AUTHKEYFILE
137 
138 #ifdef __MINGW32__
139 typedef HANDLE brlapi_fileDescriptor;
140 #else /* __MINGW32__ */
142 #endif /* __MINGW32__ */
143 
174 typedef struct {
182  char *auth;
183 
192  char *host;
194 
195 /* BRLAPI_SETTINGS_INITIALIZER */
198 #define BRLAPI_SETTINGS_INITIALIZER { NULL, NULL }
199 
200 /* brlapi_openConnection */
245 #ifndef BRLAPI_NO_SINGLE_SESSION
246 brlapi_fileDescriptor BRLAPI_STDCALL brlapi_openConnection(const brlapi_connectionSettings_t *desiredSettings, brlapi_connectionSettings_t *actualSettings);
247 #endif /* BRLAPI_NO_SINGLE_SESSION */
248 brlapi_fileDescriptor BRLAPI_STDCALL brlapi__openConnection(brlapi_handle_t *handle, const brlapi_connectionSettings_t *desiredSettings, brlapi_connectionSettings_t *actualSettings);
249 
250 /* brlapi_closeConnection */
257 #ifndef BRLAPI_NO_SINGLE_SESSION
259 #endif /* BRLAPI_NO_SINGLE_SESSION */
261 
277 #define BRLAPI_MAXNAMELENGTH 31
278 
279 /* brlapi_getDriverName */
291 #ifndef BRLAPI_NO_SINGLE_SESSION
292 int BRLAPI_STDCALL brlapi_getDriverName(char *buffer, size_t size);
293 #endif /* BRLAPI_NO_SINGLE_SESSION */
294 int BRLAPI_STDCALL brlapi__getDriverName(brlapi_handle_t *handle, char *buffer, size_t size);
295 
296 /* brlapi_getDisplaySize */
298 #ifndef BRLAPI_NO_SINGLE_SESSION
299 int BRLAPI_STDCALL brlapi_getDisplaySize(unsigned int *x, unsigned int *y);
300 #endif /* BRLAPI_NO_SINGLE_SESSION */
301 int BRLAPI_STDCALL brlapi__getDisplaySize(brlapi_handle_t *handle, unsigned int *x, unsigned int *y);
302 
326 /* brlapi_enterTtyMode */
346 #ifndef BRLAPI_NO_SINGLE_SESSION
347 int BRLAPI_STDCALL brlapi_enterTtyMode(int tty, const char *driver);
348 #endif /* BRLAPI_NO_SINGLE_SESSION */
349 int BRLAPI_STDCALL brlapi__enterTtyMode(brlapi_handle_t *handle, int tty, const char *driver);
350 
360 #define BRLAPI_TTY_DEFAULT -1
361 
362 /* brlapi_enterTtyModeWithPath */
374 #ifndef BRLAPI_NO_SINGLE_SESSION
375 int BRLAPI_STDCALL brlapi_enterTtyModeWithPath(int *ttys, int count, const char *driver);
376 #endif /* BRLAPI_NO_SINGLE_SESSION */
377 int BRLAPI_STDCALL brlapi__enterTtyModeWithPath(brlapi_handle_t *handle, int *ttys, int count, const char *driver);
378 
379 /* brlapi_leaveTtyMode */
386 #ifndef BRLAPI_NO_SINGLE_SESSION
388 #endif /* BRLAPI_NO_SINGLE_SESSION */
390 
391 /* brlapi_setFocus */
402 #ifndef BRLAPI_NO_SINGLE_SESSION
403 int BRLAPI_STDCALL brlapi_setFocus(int tty);
404 #endif /* BRLAPI_NO_SINGLE_SESSION */
405 int BRLAPI_STDCALL brlapi__setFocus(brlapi_handle_t *handle, int tty);
406 
436 /* brlapi_writeText */
451 #ifndef BRLAPI_NO_SINGLE_SESSION
452 int BRLAPI_STDCALL brlapi_writeText(int cursor, const char *text);
453 #endif /* BRLAPI_NO_SINGLE_SESSION */
454 int BRLAPI_STDCALL brlapi__writeText(brlapi_handle_t *handle, int cursor, const char *text);
455 
456 /* brlapi_writeDots */
464 #ifndef BRLAPI_NO_SINGLE_SESSION
465 int BRLAPI_STDCALL brlapi_writeDots(const unsigned char *dots);
466 #endif /* BRLAPI_NO_SINGLE_SESSION */
467 int BRLAPI_STDCALL brlapi__writeDots(brlapi_handle_t *handle, const unsigned char *dots);
468 
469 /* brlapi_writeArguments_t */
471 typedef struct {
472  int displayNumber ;
473  unsigned int regionBegin ;
474  unsigned int regionSize ;
475  char *text ;
476  int textSize ;
477  unsigned char *andMask ;
478  unsigned char *orMask ;
479  int cursor ;
480  char *charset ;
482 
487 #define BRLAPI_DISPLAY_DEFAULT -1
488 
493 #define BRLAPI_CURSOR_LEAVE -1
494 
499 #define BRLAPI_CURSOR_OFF 0
500 
501 /* BRLAPI_WRITEARGUMENTS_INITIALIZER */
511 #define BRLAPI_WRITEARGUMENTS_INITIALIZER { BRLAPI_DISPLAY_DEFAULT, 0, 0, NULL, -1, NULL, NULL, BRLAPI_CURSOR_LEAVE, NULL }
512 
513 /* brlapi_write */
549 #ifndef BRLAPI_NO_SINGLE_SESSION
551 #endif /* BRLAPI_NO_SINGLE_SESSION */
553 
556 #include "brlapi_keycodes.h"
557 
571 /* brlapi_expandedKeyCode_t */
573 typedef struct {
574  unsigned int type ;
575  unsigned int command ;
576  unsigned int argument ;
577  unsigned int flags ;
579 
580 /* brlapi_expandKeyCode */
589 
590 /* brlapi_describedKeyCode_t */
592 typedef struct {
593  const char *type ;
594  const char *command ;
595  unsigned int argument ;
596  unsigned int flags ;
597  const char *flag[64 - BRLAPI_KEY_FLAGS_SHIFT] ;
600 
601 /* brlapi_describeKeyCode */
610 
612 #define BRLAPI_UC_ROW 0x2800UL
613 
614 /* brlapi_readKey */
681 #ifndef BRLAPI_NO_SINGLE_SESSION
682 int BRLAPI_STDCALL brlapi_readKey(int wait, brlapi_keyCode_t *code);
683 #endif /* BRLAPI_NO_SINGLE_SESSION */
684 int BRLAPI_STDCALL brlapi__readKey(brlapi_handle_t *handle, int wait, brlapi_keyCode_t *code);
685 
687 typedef enum {
694 
695 /* brlapi_ignoreKeys */
708 #ifndef BRLAPI_NO_SINGLE_SESSION
709 int BRLAPI_STDCALL brlapi_ignoreKeys(brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
710 #endif /* BRLAPI_NO_SINGLE_SESSION */
711 int BRLAPI_STDCALL brlapi__ignoreKeys(brlapi_handle_t *handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
712 
713 /* brlapi_acceptKeys */
726 #ifndef BRLAPI_NO_SINGLE_SESSION
727 int BRLAPI_STDCALL brlapi_acceptKeys(brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
728 #endif /* BRLAPI_NO_SINGLE_SESSION */
729 int BRLAPI_STDCALL brlapi__acceptKeys(brlapi_handle_t *handle, brlapi_rangeType_t type, const brlapi_keyCode_t keys[], unsigned int count);
730 
731 /* brlapi_ignoreAllKeys */
737 #ifndef BRLAPI_NO_SINGLE_SESSION
739 #define brlapi_ignoreAllKeys() brlapi_ignoreKeys(brlapi_rangeType_all, NULL, 0)
740 #endif /* BRLAPI_NO_SINGLE_SESSION */
742 #define brlapi__ignoreAllKeys(handle) brlapi__ignoreKeys(handle, brlapi_rangeType_all, NULL, 0)
743 
744 /* brlapi_acceptAllKeys */
753 #ifndef BRLAPI_NO_SINGLE_SESSION
755 #define brlapi_acceptAllKeys() brlapi_acceptKeys(brlapi_rangeType_all, NULL, 0)
756 #endif /* BRLAPI_NO_SINGLE_SESSION */
758 #define brlapi__acceptAllKeys(handle) brlapi__acceptKeys(handle, brlapi_rangeType_all, NULL, 0)
759 
764 typedef struct {
768 
769 /* brlapi_ignoreKeyRanges */
780 #ifndef BRLAPI_NO_SINGLE_SESSION
781 int BRLAPI_STDCALL brlapi_ignoreKeyRanges(brlapi_range_t ranges[], unsigned int count);
782 #endif /* BRLAPI_NO_SINGLE_SESSION */
783 int BRLAPI_STDCALL brlapi__ignoreKeyRanges(brlapi_handle_t *handle, brlapi_range_t ranges[], unsigned int count);
784 
785 /* brlapi_acceptKeyRanges */
796 #ifndef BRLAPI_NO_SINGLE_SESSION
797 int BRLAPI_STDCALL brlapi_acceptKeyRanges(brlapi_range_t ranges[], unsigned int count);
798 #endif /* BRLAPI_NO_SINGLE_SESSION */
799 int BRLAPI_STDCALL brlapi__acceptKeyRanges(brlapi_handle_t *handle, brlapi_range_t ranges[], unsigned int count);
825 /* brlapi_enterRawMode */
830 #ifndef BRLAPI_NO_SINGLE_SESSION
831 int BRLAPI_STDCALL brlapi_enterRawMode(const char *driver);
832 #endif /* BRLAPI_NO_SINGLE_SESSION */
833 int BRLAPI_STDCALL brlapi__enterRawMode(brlapi_handle_t *handle, const char *driver);
834 
835 /* brlapi_leaveRawMode */
838 #ifndef BRLAPI_NO_SINGLE_SESSION
840 #endif /* BRLAPI_NO_SINGLE_SESSION */
842 
843 /* brlapi_sendRaw */
849 #ifndef BRLAPI_NO_SINGLE_SESSION
850 ssize_t BRLAPI_STDCALL brlapi_sendRaw(const void *buffer, size_t size);
851 #endif /* BRLAPI_NO_SINGLE_SESSION */
852 ssize_t BRLAPI_STDCALL brlapi__sendRaw(brlapi_handle_t *handle, const void *buffer, size_t size);
853 
854 /* brlapi_recvRaw */
861 #ifndef BRLAPI_NO_SINGLE_SESSION
862 ssize_t BRLAPI_STDCALL brlapi_recvRaw(void *buffer, size_t size);
863 #endif /* BRLAPI_NO_SINGLE_SESSION */
864 ssize_t BRLAPI_STDCALL brlapi__recvRaw(brlapi_handle_t *handle, void *buffer, size_t size);
865 
866 /* brlapi_suspendDriver */
871 #ifndef BRLAPI_NO_SINGLE_SESSION
872 int BRLAPI_STDCALL brlapi_suspendDriver(const char *driver);
873 #endif /* BRLAPI_NO_SINGLE_SESSION */
874 int BRLAPI_STDCALL brlapi__suspendDriver(brlapi_handle_t *handle, const char *driver);
875 
876 /* brlapi_resumeDriver */
880 #ifndef BRLAPI_NO_SINGLE_SESSION
882 #endif /* BRLAPI_NO_SINGLE_SESSION */
907 /* Error codes */
908 #define BRLAPI_ERROR_SUCCESS 0
909 #define BRLAPI_ERROR_NOMEM 1
910 #define BRLAPI_ERROR_TTYBUSY 2
911 #define BRLAPI_ERROR_DEVICEBUSY 3
912 #define BRLAPI_ERROR_UNKNOWN_INSTRUCTION 4
913 #define BRLAPI_ERROR_ILLEGAL_INSTRUCTION 5
914 #define BRLAPI_ERROR_INVALID_PARAMETER 6
915 #define BRLAPI_ERROR_INVALID_PACKET 7
916 #define BRLAPI_ERROR_CONNREFUSED 8
917 #define BRLAPI_ERROR_OPNOTSUPP 9
918 #define BRLAPI_ERROR_GAIERR 10
919 #define BRLAPI_ERROR_LIBCERR 11
920 #define BRLAPI_ERROR_UNKNOWNTTY 12
921 #define BRLAPI_ERROR_PROTOCOL_VERSION 13
922 #define BRLAPI_ERROR_EOF 14
923 #define BRLAPI_ERROR_EMPTYKEY 15
924 #define BRLAPI_ERROR_DRIVERERROR 16
925 #define BRLAPI_ERROR_AUTHENTICATION 17
927 /* brlapi_errlist */
928 
932 extern const char *brlapi_errlist[];
933 
934 /* brlapi_nerr */
936 extern const int brlapi_nerr;
937 
938 /* brlapi_perror */
943 void BRLAPI_STDCALL brlapi_perror(const char *s);
944 
945 /* brlapi_error_t */
947 typedef struct {
948  int brlerrno;
950  int gaierrno;
951  const char *errfun;
953 
963 
973 
975 extern int brlapi_errno;
977 extern int brlapi_libcerrno;
979 extern int brlapi_gaierrno;
981 extern const char *brlapi_errfun;
982 
984 #define brlapi_error (*brlapi_error_location())
985 
986 #define brlapi_errno (brlapi_error.brlerrno)
987 
988 #define brlapi_libcerrno (brlapi_error.libcerrno)
989 
990 #define brlapi_gaierrno (brlapi_error.gaierrno)
991 
992 #define brlapi_errfun (brlapi_error.errfun)
993 
994 /* brlapi_strerror */
1000 const char * BRLAPI_STDCALL brlapi_strerror(const brlapi_error_t *error);
1001 
1003 typedef uint32_t brlapi_packetType_t;
1004 
1005 /* brlapi_getPacketTypeName */
1011 const char * BRLAPI_STDCALL brlapi_getPacketTypeName(brlapi_packetType_t type);
1012 
1013 /* brlapi_exceptionHandler_t */
1025 #ifndef BRLAPI_NO_SINGLE_SESSION
1026 typedef void (BRLAPI_STDCALL *brlapi_exceptionHandler_t)(int error, brlapi_packetType_t type, const void *packet, size_t size);
1027 #endif /* BRLAPI_NO_SINGLE_SESSION */
1028 typedef void (BRLAPI_STDCALL *brlapi__exceptionHandler_t)(brlapi_handle_t *handle, int error, brlapi_packetType_t type, const void *packet, size_t size);
1029 
1030 /* brlapi_strexception */
1040 #ifndef BRLAPI_NO_SINGLE_SESSION
1041 int BRLAPI_STDCALL brlapi_strexception(char *buffer, size_t bufferSize, int error, brlapi_packetType_t type, const void *packet, size_t packetSize);
1042 #endif /* BRLAPI_NO_SINGLE_SESSION */
1043 int BRLAPI_STDCALL brlapi__strexception(brlapi_handle_t *handle, char *buffer, size_t bufferSize, int error, brlapi_packetType_t type, const void *packet, size_t packetSize);
1044 
1045 /* brlapi_setExceptionHandler */
1054 #ifndef BRLAPI_NO_SINGLE_SESSION
1056 #endif /* BRLAPI_NO_SINGLE_SESSION */
1058 
1059 #ifndef BRLAPI_NO_SINGLE_SESSION
1060 void BRLAPI_STDCALL brlapi_defaultExceptionHandler(int error, brlapi_packetType_t type, const void *packet, size_t size);
1061 #endif /* BRLAPI_NO_SINGLE_SESSION */
1062 void BRLAPI_STDCALL brlapi__defaultExceptionHandler(brlapi_handle_t *handle, int error, brlapi_packetType_t type, const void *packet, size_t size);
1063 
1066 /* Windows-specific tricks - don't look at this */
1067 #ifdef BRLAPI_WIN32
1068 #ifndef BRLAPI_NO_SINGLE_SESSION
1069 int BRLAPI_STDCALL brlapi_writeTextWin(int cursor, const void *str, int wide);
1070 #endif /* BRLAPI_NO_SINGLE_SESSION */
1071 int BRLAPI_STDCALL brlapi__writeTextWin(brlapi_handle_t *handle, int cursor, const void *str, int wide);
1072 
1073 #ifndef BRLAPI_NO_SINGLE_SESSION
1074 int BRLAPI_STDCALL brlapi_writeWin(const brlapi_writeArguments_t *s, int wide);
1075 #endif /* BRLAPI_NO_SINGLE_SESSION */
1076 int BRLAPI_STDCALL brlapi__writeWin(brlapi_handle_t *handle, const brlapi_writeArguments_t *s, int wide);
1077 
1078 #ifdef UNICODE
1079 #ifndef BRLAPI_NO_SINGLE_SESSION
1080 #define brlapi_writeText(cursor, str) brlapi_writeTextWin(cursor, str, 1)
1081 #endif /* BRLAPI_NO_SINGLE_SESSION */
1082 #define brlapi__writeText(handle, cursor, str) brlapi__writeTextWin(handle, cursor, str, 1)
1083 
1084 #ifndef BRLAPI_NO_SINGLE_SESSION
1085 #define brlapi_write(s) brlapi_writeWin(s, 1)
1086 #endif /* BRLAPI_NO_SINGLE_SESSION */
1087 #define brlapi__write(handle, s) brlapi__writeWin(handle, s, 1)
1088 
1089 #else /* UNICODE */
1090 
1091 #ifndef BRLAPI_NO_SINGLE_SESSION
1092 #define brlapi_writeText(cursor, str) brlapi_writeTextWin(cursor, str, 0)
1093 #endif /* BRLAPI_NO_SINGLE_SESSION */
1094 #define brlapi__writeText(handle, cursor, str) brlapi__writeTextWin(handle, cursor, str, 0)
1095 
1096 #ifndef BRLAPI_NO_SINGLE_SESSION
1097 #define brlapi_write(s) brlapi_writeWin(s, 0)
1098 #endif /* BRLAPI_NO_SINGLE_SESSION */
1099 #define brlapi__write(handle, s) brlapi__writeWin(handle, s, 0)
1100 
1101 #endif /* UNICODE */
1102 #endif /* BRLAPI_WIN32 */
1103 
1104 #ifndef BRLAPI_NO_DEPRECATED
1105 
1117 #define brlapi_settings_t brlapi_connectionSettings_t
1118 
1120 typedef struct {
1122  unsigned int regionBegin;
1123  unsigned int regionSize;
1124  char *text;
1126  unsigned char *attrAnd;
1127  unsigned char *attrOr;
1128  int cursor;
1129  char *charset;
1131 #define BRLAPI_WRITESTRUCT_INITIALIZER BRLAPI_WRITEARGUMENTS_INITIALIZER
1132 
1133 #define brl_keycode_t brlapi_keyCode_t
1134 #define brl_type_t brlapi_packetType_t
1135 
1136 #define BRLCOMMANDS NULL
1137 #define BRL_KEYCODE_MAX BRLAPI_KEY_MAX
1138 
1139 #ifndef BRLAPI_NO_SINGLE_SESSION
1140 #define brlapi_initializeConnection brlapi_openConnection
1141 #define brlapi_getTty brlapi_enterTtyMode
1142 #define brlapi_getTtyPath brlapi_enterTtyModeWithPath
1143 #define brlapi_leaveTty brlapi_leaveTtyMode
1144 #define brlapi_unignoreKeyRange brlapi_acceptKeyRange
1145 #define brlapi_unignoreKeySet brlapi_acceptKeySet
1146 #define brlapi_getRaw brlapi_enterRawMode
1147 #define brlapi_leaveRaw brlapi_leaveRawMode
1148 #define brlapi_suspend brlapi_suspendDriver
1149 #define brlapi_resume brlapi_resumeDriver
1150 #endif /* BRLAPI_NO_SINGLE_SESSION */
1151 
1152 #define BRLERR_SUCCESS BRLAPI_ERROR_SUCCESS
1153 #define BRLERR_NOMEM BRLAPI_ERROR_NOMEM
1154 #define BRLERR_TTYBUSY BRLAPI_ERROR_TTYBUSY
1155 #define BRLERR_DEVICEBUSY BRLAPI_ERROR_DEVICEBUSY
1156 #define BRLERR_UNKNOWN_INSTRUCTION BRLAPI_ERROR_UNKNOWN_INSTRUCTION
1157 #define BRLERR_ILLEGAL_INSTRUCTION BRLAPI_ERROR_ILLEGAL_INSTRUCTION
1158 #define BRLERR_INVALID_PARAMETER BRLAPI_ERROR_INVALID_PARAMETER
1159 #define BRLERR_INVALID_PACKET BRLAPI_ERROR_INVALID_PACKET
1160 #define BRLERR_CONNREFUSED BRLAPI_ERROR_CONNREFUSED
1161 #define BRLERR_OPNOTSUPP BRLAPI_ERROR_OPNOTSUPP
1162 #define BRLERR_GAIERR BRLAPI_ERROR_GAIERR
1163 #define BRLERR_LIBCERR BRLAPI_ERROR_LIBCERR
1164 #define BRLERR_UNKNOWNTTY BRLAPI_ERROR_UNKNOWNTTY
1165 #define BRLERR_PROTOCOL_VERSION BRLAPI_ERROR_PROTOCOL_VERSION
1166 #define BRLERR_EOF BRLAPI_ERROR_EOF
1167 #define BRLERR_EMPTYKEY BRLAPI_ERROR_EMPTYKEY
1168 #define BRLERR_DRIVERERROR BRLAPI_ERROR_DRIVERERROR
1169 
1171 #endif /* BRLAPI_NO_DEPRECATED */
1172 
1173 #ifdef __cplusplus
1174 }
1175 #endif /* __cplusplus */
1176 
1177 #endif /* BRLAPI_INCLUDED */