~ubuntu-branches/ubuntu/karmic/brltty/karmic

« back to all changes in this revision

Viewing changes to Documents/BrlAPIref/man/man3/brlapi_error.3

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-05-28 09:56:12 UTC
  • mfrom: (1.1.7 upstream) (2.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20090528095612-yt0urjjk7mdghsro
Tags: 4.0-6ubuntu1
* Merge from debian unstable, remaining changes:
  - Conflicts: libbrlapi, libbrlapi-dev, libbrlapi1-dev.
  - Add brltty-setup, installed in both the udeb and the normal system.
  - Add initramfs integration to run brltty-setup if necessary before
    usplash starts.
  - Add ubiquity integration to propagate any brltty configuration to the
    target system.
  - Add udev rules and /lib/brltty/brltty.sh to the normal (non-udeb)
    package as well.
  - Enable brltty if /etc/default/brltty has RUN_BRLTTY=yes, which is set
    by the installer if brltty is configured; add a NEWS entry for
    upgraders.
  - Install udev rules with the same name (85-brltty.rules) in the udeb as
    in the deb.
  - Only copy the brltty config file from the initramfs if the md5sum differs.
  - Change maintainer to Ubuntu Accessibility Developers
    <ubuntu-accessibility-devel@lists.ubuntu.com>
  - Disable BrlTTY grabbing devices that use the FTDI USB to serial chip.
  - Remove the dh-lisp build-dependency, remove the cl-brlapi package, and
    adjust the brltty package description accordingly. dh-lisp is not
    in main.
  - Do not build the speechd package, speech-dispatcher is not in main.
  - Build for python 2.6.
  - Build against openjdk in Ubuntu.
  - Put udev rules file in /lib/udev/rules.d.
  - Enable brltty at startup on the target system if the alternate installer
    is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.TH "Error handling" 3 "15 May 2009" "Version 1.0" "BrlAPI" \" -*- nroff -*-
 
2
.ad l
 
3
.nh
 
4
.SH NAME
 
5
Error handling \- How to handle errors.  
 
6
 
 
7
.PP
 
8
.SS "Data Structures"
 
9
 
 
10
.in +1c
 
11
.ti -1c
 
12
.RI "struct \fBbrlapi_error_t\fP"
 
13
.br
 
14
.in -1c
 
15
.SS "Defines"
 
16
 
 
17
.in +1c
 
18
.ti -1c
 
19
.RI "#define \fBBRLAPI_ERROR_SUCCESS\fP   0"
 
20
.br
 
21
.ti -1c
 
22
.RI "#define \fBBRLAPI_ERROR_NOMEM\fP   1"
 
23
.br
 
24
.ti -1c
 
25
.RI "#define \fBBRLAPI_ERROR_TTYBUSY\fP   2"
 
26
.br
 
27
.ti -1c
 
28
.RI "#define \fBBRLAPI_ERROR_DEVICEBUSY\fP   3"
 
29
.br
 
30
.ti -1c
 
31
.RI "#define \fBBRLAPI_ERROR_UNKNOWN_INSTRUCTION\fP   4"
 
32
.br
 
33
.ti -1c
 
34
.RI "#define \fBBRLAPI_ERROR_ILLEGAL_INSTRUCTION\fP   5"
 
35
.br
 
36
.ti -1c
 
37
.RI "#define \fBBRLAPI_ERROR_INVALID_PARAMETER\fP   6"
 
38
.br
 
39
.ti -1c
 
40
.RI "#define \fBBRLAPI_ERROR_INVALID_PACKET\fP   7"
 
41
.br
 
42
.ti -1c
 
43
.RI "#define \fBBRLAPI_ERROR_CONNREFUSED\fP   8"
 
44
.br
 
45
.ti -1c
 
46
.RI "#define \fBBRLAPI_ERROR_OPNOTSUPP\fP   9"
 
47
.br
 
48
.ti -1c
 
49
.RI "#define \fBBRLAPI_ERROR_GAIERR\fP   10"
 
50
.br
 
51
.ti -1c
 
52
.RI "#define \fBBRLAPI_ERROR_LIBCERR\fP   11"
 
53
.br
 
54
.ti -1c
 
55
.RI "#define \fBBRLAPI_ERROR_UNKNOWNTTY\fP   12"
 
56
.br
 
57
.ti -1c
 
58
.RI "#define \fBBRLAPI_ERROR_PROTOCOL_VERSION\fP   13"
 
59
.br
 
60
.ti -1c
 
61
.RI "#define \fBBRLAPI_ERROR_EOF\fP   14"
 
62
.br
 
63
.ti -1c
 
64
.RI "#define \fBBRLAPI_ERROR_EMPTYKEY\fP   15"
 
65
.br
 
66
.ti -1c
 
67
.RI "#define \fBBRLAPI_ERROR_DRIVERERROR\fP   16"
 
68
.br
 
69
.ti -1c
 
70
.RI "#define \fBBRLAPI_ERROR_AUTHENTICATION\fP   17"
 
71
.br
 
72
.ti -1c
 
73
.RI "#define \fBbrlapi_error\fP   (*brlapi_error_location())"
 
74
.br
 
75
.ti -1c
 
76
.RI "#define \fBbrlapi_errno\fP   (brlapi_error.brlerrno)"
 
77
.br
 
78
.ti -1c
 
79
.RI "#define \fBbrlapi_libcerrno\fP   (brlapi_error.libcerrno)"
 
80
.br
 
81
.ti -1c
 
82
.RI "#define \fBbrlapi_gaierrno\fP   (brlapi_error.gaierrno)"
 
83
.br
 
84
.ti -1c
 
85
.RI "#define \fBbrlapi_errfun\fP   (brlapi_error.errfun)"
 
86
.br
 
87
.in -1c
 
88
.SS "Typedefs"
 
89
 
 
90
.in +1c
 
91
.ti -1c
 
92
.RI "typedef uint32_t \fBbrlapi_packetType_t\fP"
 
93
.br
 
94
.ti -1c
 
95
.RI "typedef void(BRLAPI_STDCALL *) \fBbrlapi_exceptionHandler_t\fP (int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t size)"
 
96
.br
 
97
.ti -1c
 
98
.RI "typedef void(BRLAPI_STDCALL *) \fBbrlapi__exceptionHandler_t\fP (\fBbrlapi_handle_t\fP *handle, int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t size)"
 
99
.br
 
100
.in -1c
 
101
.SS "Functions"
 
102
 
 
103
.in +1c
 
104
.ti -1c
 
105
.RI "void BRLAPI_STDCALL \fBbrlapi_perror\fP (const char *s)"
 
106
.br
 
107
.ti -1c
 
108
.RI "\fBbrlapi_error_t\fP *BRLAPI_STDCALL \fBbrlapi_error_location\fP (void)"
 
109
.br
 
110
.ti -1c
 
111
.RI "const char *BRLAPI_STDCALL \fBbrlapi_strerror\fP (const \fBbrlapi_error_t\fP *error)"
 
112
.br
 
113
.ti -1c
 
114
.RI "const char *BRLAPI_STDCALL \fBbrlapi_getPacketTypeName\fP (\fBbrlapi_packetType_t\fP type)"
 
115
.br
 
116
.ti -1c
 
117
.RI "int BRLAPI_STDCALL \fBbrlapi_strexception\fP (char *buffer, size_t bufferSize, int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t packetSize)"
 
118
.br
 
119
.ti -1c
 
120
.RI "int BRLAPI_STDCALL \fBbrlapi__strexception\fP (\fBbrlapi_handle_t\fP *handle, char *buffer, size_t bufferSize, int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t packetSize)"
 
121
.br
 
122
.ti -1c
 
123
.RI "\fBbrlapi_exceptionHandler_t\fP BRLAPI_STDCALL \fBbrlapi_setExceptionHandler\fP (\fBbrlapi_exceptionHandler_t\fP handler)"
 
124
.br
 
125
.ti -1c
 
126
.RI "\fBbrlapi__exceptionHandler_t\fP BRLAPI_STDCALL \fBbrlapi__setExceptionHandler\fP (\fBbrlapi_handle_t\fP *handle, \fBbrlapi__exceptionHandler_t\fP handler)"
 
127
.br
 
128
.ti -1c
 
129
.RI "void BRLAPI_STDCALL \fBbrlapi_defaultExceptionHandler\fP (int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t size)"
 
130
.br
 
131
.ti -1c
 
132
.RI "void BRLAPI_STDCALL \fBbrlapi__defaultExceptionHandler\fP (\fBbrlapi_handle_t\fP *handle, int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t size)"
 
133
.br
 
134
.in -1c
 
135
.SS "Variables"
 
136
 
 
137
.in +1c
 
138
.ti -1c
 
139
.RI "const char * \fBbrlapi_errlist\fP []"
 
140
.br
 
141
.ti -1c
 
142
.RI "const int \fBbrlapi_nerr\fP"
 
143
.br
 
144
.ti -1c
 
145
.RI "\fBbrlapi_error_t\fP \fBbrlapi_error\fP"
 
146
.br
 
147
.ti -1c
 
148
.RI "int \fBbrlapi_errno\fP"
 
149
.br
 
150
.ti -1c
 
151
.RI "int \fBbrlapi_libcerrno\fP"
 
152
.br
 
153
.ti -1c
 
154
.RI "int \fBbrlapi_gaierrno\fP"
 
155
.br
 
156
.ti -1c
 
157
.RI "const char * \fBbrlapi_errfun\fP"
 
158
.br
 
159
.in -1c
 
160
.SH "Detailed Description"
 
161
.PP 
 
162
When a function fails, \fBbrlapi_errno\fP will hold an error code to explain why it failed. It should always be reported somehow.
 
163
.PP
 
164
Although most errors are reported that way, some (called exceptions) are reported asynchronously for efficiency reasons, because they always just report a programming error. The affected functions are: brlapi_setFocus, brlapi_write* and brlapi_sendRaw. When they happen, the next call to brlapi_something will close the connection and call the \fIexception\fP handler. If the exception handler returns, the brlapi_something function will return an end-of-file error.
 
165
.PP
 
166
The default exception handler (\fBbrlapi_defaultExceptionHandler()\fP) dumps the guilty packet before abort()ing. It can be replaced by calling \fBbrlapi_setExceptionHandler()\fP. For instance, the Java and Python bindings use this for raising a Java or Python exception that may be caught. 
 
167
.SH "Define Documentation"
 
168
.PP 
 
169
.SS "#define \fBbrlapi_errfun\fP   (brlapi_error.errfun)"
 
170
.PP
 
171
Cheat about the brlapi_errfun C token 
 
172
.SS "#define \fBbrlapi_errno\fP   (brlapi_error.brlerrno)"
 
173
.PP
 
174
Cheat about the brlapi_errno C token 
 
175
.SS "#define \fBbrlapi_error\fP   (*brlapi_error_location())"
 
176
.PP
 
177
Cheat about the brlapi_error C token 
 
178
.SS "#define BRLAPI_ERROR_AUTHENTICATION   17"
 
179
.PP
 
180
Authentication failed 
 
181
.SS "#define BRLAPI_ERROR_CONNREFUSED   8"
 
182
.PP
 
183
Connection refused 
 
184
.SS "#define BRLAPI_ERROR_DEVICEBUSY   3"
 
185
.PP
 
186
A connection is already using RAW or suspend mode 
 
187
.SS "#define BRLAPI_ERROR_DRIVERERROR   16"
 
188
.PP
 
189
Packet returned by driver too large 
 
190
.SS "#define BRLAPI_ERROR_EMPTYKEY   15"
 
191
.PP
 
192
Key file empty 
 
193
.SS "#define BRLAPI_ERROR_EOF   14"
 
194
.PP
 
195
Unexpected end of file 
 
196
.SS "#define BRLAPI_ERROR_GAIERR   10"
 
197
.PP
 
198
Getaddrinfo error 
 
199
.SS "#define BRLAPI_ERROR_ILLEGAL_INSTRUCTION   5"
 
200
.PP
 
201
Forbiden in current mode 
 
202
.SS "#define BRLAPI_ERROR_INVALID_PACKET   7"
 
203
.PP
 
204
Invalid size 
 
205
.SS "#define BRLAPI_ERROR_INVALID_PARAMETER   6"
 
206
.PP
 
207
Out of range or have no sense 
 
208
.SS "#define BRLAPI_ERROR_LIBCERR   11"
 
209
.PP
 
210
Libc error 
 
211
.SS "#define BRLAPI_ERROR_NOMEM   1"
 
212
.PP
 
213
Not enough memory 
 
214
.SS "#define BRLAPI_ERROR_OPNOTSUPP   9"
 
215
.PP
 
216
Operation not supported 
 
217
.SS "#define BRLAPI_ERROR_PROTOCOL_VERSION   13"
 
218
.PP
 
219
Bad protocol version 
 
220
.SS "#define BRLAPI_ERROR_SUCCESS   0"
 
221
.PP
 
222
Success 
 
223
.SS "#define BRLAPI_ERROR_TTYBUSY   2"
 
224
.PP
 
225
A connection is already running in this tty 
 
226
.SS "#define BRLAPI_ERROR_UNKNOWN_INSTRUCTION   4"
 
227
.PP
 
228
Not implemented in protocol 
 
229
.SS "#define BRLAPI_ERROR_UNKNOWNTTY   12"
 
230
.PP
 
231
Couldn't find out the tty number 
 
232
.SS "#define \fBbrlapi_gaierrno\fP   (brlapi_error.gaierrno)"
 
233
.PP
 
234
Cheat about the brlapi_gaierrno C token 
 
235
.SS "#define \fBbrlapi_libcerrno\fP   (brlapi_error.libcerrno)"
 
236
.PP
 
237
Cheat about the brlapi_libcerrno C token 
 
238
.SH "Typedef Documentation"
 
239
.PP 
 
240
.SS "typedef void(BRLAPI_STDCALL *) \fBbrlapi__exceptionHandler_t\fP(\fBbrlapi_handle_t\fP *handle, int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t size)"
 
241
.PP
 
242
.SS "typedef void(BRLAPI_STDCALL *) \fBbrlapi_exceptionHandler_t\fP(int error, \fBbrlapi_packetType_t\fP type, const void *packet, size_t size)"
 
243
.PP
 
244
Types for exception handlers
 
245
.PP
 
246
Types of exception handlers which are to be given to \fBbrlapi_setExceptionHandler()\fP and \fBbrlapi__setExceptionHandler()\fP.
 
247
.PP
 
248
\fBParameters:\fP
 
249
.RS 4
 
250
\fIhandle\fP is the handle corresponding to the guilty connection; 
 
251
.br
 
252
\fIerror\fP is a BRLAPI_ERROR_ error code; 
 
253
.br
 
254
\fItype\fP is the type of the guilty packet; 
 
255
.br
 
256
\fIpacket\fP points to the content of the guilty packet (might be a little bit truncated); 
 
257
.br
 
258
\fIsize\fP gives the guilty packet's size. 
 
259
.RE
 
260
.PP
 
261
 
 
262
.SS "typedef uint32_t \fBbrlapi_packetType_t\fP"
 
263
.PP
 
264
Type for packet type. Only unsigned can cross networks, 32bits 
 
265
.SH "Function Documentation"
 
266
.PP 
 
267
.SS "void BRLAPI_STDCALL brlapi__defaultExceptionHandler (\fBbrlapi_handle_t\fP * handle, int error, \fBbrlapi_packetType_t\fP type, const void * packet, size_t size)"
 
268
.PP
 
269
.SS "\fBbrlapi__exceptionHandler_t\fP BRLAPI_STDCALL brlapi__setExceptionHandler (\fBbrlapi_handle_t\fP * handle, \fBbrlapi__exceptionHandler_t\fP handler)"
 
270
.PP
 
271
.SS "int BRLAPI_STDCALL brlapi__strexception (\fBbrlapi_handle_t\fP * handle, char * buffer, size_t bufferSize, int error, \fBbrlapi_packetType_t\fP type, const void * packet, size_t packetSize)"
 
272
.PP
 
273
.SS "void BRLAPI_STDCALL brlapi_defaultExceptionHandler (int error, \fBbrlapi_packetType_t\fP type, const void * packet, size_t size)"
 
274
.PP
 
275
.SS "\fBbrlapi_error_t\fP* BRLAPI_STDCALL brlapi_error_location (void)"
 
276
.PP
 
277
Get per-thread error location
 
278
.PP
 
279
In multithreaded software, \fBbrlapi_error\fP is thread-specific, so api.h cheats about the brlapi_error token and actually calls \fBbrlapi_error_location()\fP.
 
280
.PP
 
281
This gets the thread specific location of global variable \fBbrlapi_error\fP 
 
282
.SS "const char* BRLAPI_STDCALL brlapi_getPacketTypeName (\fBbrlapi_packetType_t\fP type)"
 
283
.PP
 
284
Get plain packet type
 
285
.PP
 
286
\fBbrlapi_getPacketTypeName()\fP returns the plain packet type name corresponding to its argument. 
 
287
.SS "void BRLAPI_STDCALL brlapi_perror (const char * s)"
 
288
.PP
 
289
Print a BrlAPI error message
 
290
.PP
 
291
\fBbrlapi_perror()\fP reads \fBbrlapi_error\fP, and acts just like perror(). 
 
292
.SS "\fBbrlapi_exceptionHandler_t\fP BRLAPI_STDCALL brlapi_setExceptionHandler (\fBbrlapi_exceptionHandler_t\fP handler)"
 
293
.PP
 
294
Set a new exception handler
 
295
.PP
 
296
\fBbrlapi_setExceptionHandler()\fP replaces the previous exception handler with the handler parameter. The previous exception handler is returned to make chaining error handlers possible.
 
297
.PP
 
298
The default handler just prints the exception and abort()s. 
 
299
.SS "const char* BRLAPI_STDCALL brlapi_strerror (const \fBbrlapi_error_t\fP * error)"
 
300
.PP
 
301
Get plain error message
 
302
.PP
 
303
\fBbrlapi_strerror()\fP returns the plain error message corresponding to its argument. 
 
304
.SS "int BRLAPI_STDCALL brlapi_strexception (char * buffer, size_t bufferSize, int error, \fBbrlapi_packetType_t\fP type, const void * packet, size_t packetSize)"
 
305
.PP
 
306
Describes an exception
 
307
.PP
 
308
\fBbrlapi_strexception()\fP puts a text describing the given exception in buffer.
 
309
.PP
 
310
The beginning of the guilty packet is dumped as a sequence of hex bytes.
 
311
.PP
 
312
\fBReturns:\fP
 
313
.RS 4
 
314
the size of the text describing the exception, following snprintf()'s semantics. 
 
315
.RE
 
316
.PP
 
317
 
 
318
.SH "Variable Documentation"
 
319
.PP 
 
320
.SS "const char* \fBbrlapi_errfun\fP"
 
321
.PP
 
322
Shorthand for brlapi_error.errfun 
 
323
.SS "const char* \fBbrlapi_errlist\fP[]"
 
324
.PP
 
325
Error message list
 
326
.PP
 
327
These are the string constants used by \fBbrlapi_perror()\fP. 
 
328
.SS "int \fBbrlapi_errno\fP"
 
329
.PP
 
330
Shorthand for brlapi_error.errno 
 
331
.SS "\fBbrlapi_error_t\fP \fBbrlapi_error\fP"
 
332
.PP
 
333
Global variable brlapi_error
 
334
.PP
 
335
\fBbrlapi_error\fP is a global left-value containing the last error information. Its errno field is not reset to BRLAPI_ERROR_SUCCESS on success.
 
336
.PP
 
337
This information may be copied in \fBbrlapi_error_t\fP variables for later use with the brlapi_strerror function. 
 
338
.SS "int \fBbrlapi_gaierrno\fP"
 
339
.PP
 
340
Shorthand for brlapi_error.gaierrno 
 
341
.SS "int \fBbrlapi_libcerrno\fP"
 
342
.PP
 
343
Shorthand for brlapi_error.libcerrno 
 
344
.SS "const int \fBbrlapi_nerr\fP"
 
345
.PP
 
346
Number of error messages