1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Connecting to BrlAPI</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.18 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center>
<hr><h1>Connecting to BrlAPI</h1><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
<tr><td nowrap align=right valign=top>struct </td><td valign=bottom><a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a></td></tr>
<tr><td> </td><td><font size=-1><em>Settings structure for <em>BrlAPI</em> connection.</em> <a href="structbrlapi__settings__t.html#_details">More...</a><em></em></font><br><br></td></tr>
<tr><td colspan=2><br><h2>Defines</h2></td></tr>
<tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a4">BRLAPI_SOCKETPORT</a> "35751"</td></tr>
<tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a5">BRLAPI_ETCDIR</a> "/etc"</td></tr>
<tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a6">BRLAPI_AUTHFILE</a> "brlapi.key"</td></tr>
<tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a7">BRLAPI_AUTHNAME</a> BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE</td></tr>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a0">brlapi_initializeConnection</a> (const <a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a> *clientSettings, <a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a> *usedSettings)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a1">brlapi_closeConnection</a> (void)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a2">brlapi_loadAuthKey</a> (const char *filename, int *authlength, void *auth)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="group__brlapi__connection.html#a3">brlapi_getControllingTty</a> (void)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Before calling any other function of the library, calling <a class="el" href="group__brlapi__connection.html#a0">brlapi_initializeConnection()</a> is needed to establish a connection to <em>BrlAPI</em> 's server. When the connection is no more needed, <a class="el" href="group__brlapi__connection.html#a1">brlapi_closeConnection()</a> must be called to close the connection. <hr><h2>Define Documentation</h2>
<a name="a6" doxytag="brlapi.h::BRLAPI_AUTHFILE"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> #define BRLAPI_AUTHFILE "brlapi.key"
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Default name of the file containing <em>BrlAPI</em> 's authentication key
<p>
This name is relative to BRLAPI_ETCDIR </td>
</tr>
</table>
<a name="a7" doxytag="brlapi.h::BRLAPI_AUTHNAME"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> #define BRLAPI_AUTHNAME BRLAPI_ETCDIR "/" BRLAPI_AUTHFILE
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Final path for default authentication key file </td>
</tr>
</table>
<a name="a5" doxytag="brlapi.h::BRLAPI_ETCDIR"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> #define BRLAPI_ETCDIR "/etc"
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<em>brltty</em> 's settings directory
<p>
This is where authentication key and driver-dependent key names are found for instance. </td>
</tr>
</table>
<a name="a4" doxytag="brlapi.h::BRLAPI_SOCKETPORT"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> #define BRLAPI_SOCKETPORT "35751"
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Default port number on which connections to <em>BrlAPI</em> can be established </td>
</tr>
</table>
<hr><h2>Function Documentation</h2>
<a name="a1" doxytag="brlapi.h::brlapi_closeConnection"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void brlapi_closeConnection </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Cleanly close the socket
<p>
This function locks until a closing acknowledgement is received from the server. The socket is then freed, so the file descriptor <a class="el" href="group__brlapi__connection.html#a0">brlapi_initializeConnection()</a> gave has no meaning any more </td>
</tr>
</table>
<a name="a3" doxytag="brlapi.h::brlapi_getControllingTty"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int brlapi_getControllingTty </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Return the number of the caller's controlling terminal
<p>
BrlAPI needs to know on which VT the application is connected. This function tries to find it out. It first looks for the CONTROLTTY environment variable, then tries to get it from /proc/self/stat
<p>
Hence people has to modify their xinitrc & xsession so that CONTROLTTY is set to 7 for instance, if the X server is launched on VT 7. The value can be got by grepping "using VT number [0-9]*" from X's log.
<p>
I personnaly have
<p>
CONTROLVT="$(grep "using VT number" "/var/log/XFree86.$(echo "$DISPLAY" | sed -e "s/^.*::*\([0-9]*\).*$/\1/").log" | sed -e "s/^.*using VT number \([0-9]*\).*$/\1/")" export CONTROLVT
<p>
in my .xsession
<p>
People also have to set CONTROLTTY when working remotely (as well as BRLAPI_HOSTNAME)
<p>
<dl compact><dt><b>Returns: </b></dt><dd>
-1 if unknown or on error </dl> </td>
</tr>
</table>
<a name="a0" doxytag="brlapi.h::brlapi_initializeConnection"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int brlapi_initializeConnection </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const <a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a> * </td>
<td class="mdname" nowrap> <em>clientSettings</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap><a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a> * </td>
<td class="mdname" nowrap> <em>usedSettings</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
open a socket and connect it to <em>BrlAPI</em> 's server
<p>
This function first loads an authentication key as specified in settings. It then creates a TCP socket and connects it to the specified machine, on the specified port. It writes the authentication key on the socket and waits for acknowledgement.
<p>
<dl compact><dt><b>Returns: </b></dt><dd>
the file descriptor, or -1 on error</dl><dl compact><dt><b>Note: </b></dt><dd>
The file descriptor is returned in case the client wants to communicate with the server without using <em>libbrlapi</em> functions. If it uses them however, it won't have to pass the file descriptor later, since the library keeps a copy of it</dl><dl compact><dt><b>Example:</b></dt><dd>
<div class="fragment"><pre> <span class="keywordflow">if</span> (<a class="code" href="group__brlapi__connection.html#a0">brlapi_initializeConnection</a>(&settings)<0) {
fprintf(stderr,<span class="stringliteral">"couldn't connect to BrlAPI!\n"</span>);
exit(1);
}
</pre></div></dl><dl compact><dt><b>Errors:</b></dt><dd>
<em>BrlAPI</em> might not be on this TCP port, the host name might not be resolvable, the authentication may fail,...</dl><dl compact><dt><b>Parameters: </b></dt><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>clientSettings</em> </td><td>
this gives the connection parameters, as described in <a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a>. If <code>NULL</code>, defaults values are used, so that it is generally a good idea to give <code>NULL</code> as default, and only fill a <a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a> structure when the user gave parameters to the program for instance. </td></tr>
<tr><td valign=top><em>usedSettings</em> </td><td>
if not <code>NULL</code>, parameters which were actually used are stored here, if the application ever needs them.</td></tr>
</table>
</dl><dl compact><dt><b>See also: </b></dt><dd>
<a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a> <a class="el" href="group__brlapi__connection.html#a2">brlapi_loadAuthKey()</a> <a class="el" href="group__brlapi__protocol.html#a2">brlapi_writePacket()</a> <a class="el" href="group__brlapi__protocol.html#a3">brlapi_readPacket()</a> </dl> </td>
</tr>
</table>
<a name="a2" doxytag="brlapi.h::brlapi_loadAuthKey"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int brlapi_loadAuthKey </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </td>
<td class="mdname" nowrap> <em>filename</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int * </td>
<td class="mdname" nowrap> <em>authlength</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>void * </td>
<td class="mdname" nowrap> <em>auth</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Load an authentication key from the given file
<p>
Calling this function shouldn't be needed if brlapi_initializeConnection is used.<dl compact><dt><b>Parameters: </b></dt><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>filename</em> </td><td>
gives the full path of the file ; </td></tr>
<tr><td valign=top><em>authlength</em> </td><td>
gives the size of the <em>auth</em> buffer ; </td></tr>
<tr><td valign=top><em>auth</em> </td><td>
is a buffer where the function will store the authentication key</td></tr>
</table>
</dl><dl compact><dt><b>Returns: </b></dt><dd>
the size of the key, -1 on error</dl><dl compact><dt><b>See also: </b></dt><dd>
<a class="el" href="structbrlapi__settings__t.html">brlapi_settings_t</a>, <a class="el" href="group__brlapi__connection.html#a0">brlapi_initializeConnection</a> </dl> </td>
</tr>
</table>
<hr><address style="align: right;"><small>Generated on Thu Jan 15 13:21:27 2004 for BrlAPI by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.18 </small></address>
</body>
</html>
|