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 316 317 318 319 320 321 322 323 324 325 326 327
|
/* conn.h
Header file for routines which manipulate connections.
Copyright (C) 1991, 1992, 1993, 1994, 2002 Ian Lance Taylor
This file is part of the Taylor UUCP package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com.
*/
#ifndef CONN_H
#define CONN_H
#if ANSI_C
/* These structures are used in prototypes but are not defined in this
header file. */
struct uuconf_system;
struct uuconf_dialer;
struct uuconf_chat;
#endif
/* This structure represents a connection. */
struct sconnection
{
/* Pointer to command table for this type of connection. */
const struct sconncmds *qcmds;
/* Pointer to system dependent information. */
pointer psysdep;
/* Pointer to system independent information. */
struct uuconf_port *qport;
};
/* Whether fconn_dial got a dialer. */
enum tdialerfound
{
/* Did not find a dialer. */
DIALERFOUND_FALSE,
/* Found a dialer which does not need to be freed. */
DIALERFOUND_TRUE,
/* Found a dialer which does need to be freed. */
DIALERFOUND_FREE
};
/* Parity settings to pass to fconn_set. */
enum tparitysetting
{
/* Do not change output parity generation. */
PARITYSETTING_DEFAULT,
/* No parity (all eight output bits used). */
PARITYSETTING_NONE,
/* Even parity. */
PARITYSETTING_EVEN,
/* Odd parity. */
PARITYSETTING_ODD,
/* Mark parity. */
PARITYSETTING_MARK,
/* Space parity. */
PARITYSETTING_SPACE
};
/* Type of strip control argument to fconn_set. */
enum tstripsetting
{
/* Do not change the stripping of input characters. */
STRIPSETTING_DEFAULT,
/* Do not strip input characters to seven bits. */
STRIPSETTING_EIGHTBITS,
/* Strip input characters to seven bits. */
STRIPSETTING_SEVENBITS
};
/* Type of XON/XOFF control argument to fconn_set. */
enum txonxoffsetting
{
/* Do not change XON/XOFF handshake setting. */
XONXOFF_DEFAULT,
/* Do not do XON/XOFF handshaking. */
XONXOFF_OFF,
/* Do XON/XOFF handshaking. */
XONXOFF_ON
};
/* A command table holds the functions which implement actions for
each different kind of connection. */
struct sconncmds
{
/* Free up a connection. */
void (*pufree) P((struct sconnection *qconn));
/* Lock the connection. The fin argument is TRUE if the connection
is to be used for an incoming call. The fuser argument is TRUE
if, should the port be opened, it should be opened using the
user's permissions rather than the effective permissions. May be
NULL. */
boolean (*pflock) P((struct sconnection *qconn, boolean fin, boolean fuser));
/* Unlock the connection. May be NULL. */
boolean (*pfunlock) P((struct sconnection *qconn));
/* Open the connection. */
boolean (*pfopen) P((struct sconnection *qconn, long ibaud,
boolean fwait, boolean fuser, boolean nortscts));
/* Close the connection. */
boolean (*pfclose) P((struct sconnection *qconn,
pointer puuconf,
struct uuconf_dialer *qdialer,
boolean fsuccess));
/* Dial a number on a connection. This set *qdialer to the dialer
used, if any, and sets *ptdialerfound appropriately. The qsys
and zphone arguments are for the chat script. This field may be
NULL. */
boolean (*pfdial) P((struct sconnection *qconn, pointer puuconf,
const struct uuconf_system *qsys,
const char *zphone,
struct uuconf_dialer *qdialer,
enum tdialerfound *ptdialerfound));
/* Read data from a connection, with a timeout in seconds. When
called *pclen is the length of the buffer; on successful return
*pclen is the number of bytes read into the buffer. The cmin
argument is the minimum number of bytes to read before returning
ahead of a timeout. */
boolean (*pfread) P((struct sconnection *qconn, char *zbuf, size_t *pclen,
size_t cmin, int ctimeout, boolean freport));
/* Write data to the connection. */
boolean (*pfwrite) P((struct sconnection *qconn, const char *zbuf,
size_t clen));
/* Read and write data to the connection. This reads and writes
data until either all passed in data has been written or the read
buffer has been filled. When called *pcread is the size of the
read buffer and *pcwrite is the number of bytes to write; on
successful return *pcread is the number of bytes read and
*pcwrite is the number of bytes written. */
boolean (*pfio) P((struct sconnection *qconn, const char *zwrite,
size_t *pcwrite, char *zread, size_t *pcread));
/* Send a break character. This field may be NULL. */
boolean (*pfbreak) P((struct sconnection *qconn));
/* Change the connection setting. This field may be NULL. */
boolean (*pfset) P((struct sconnection *qconn,
enum tparitysetting tparity,
enum tstripsetting tstrip,
enum txonxoffsetting txonxoff));
/* Require or ignore carrer. This field may be NULL. */
boolean (*pfcarrier) P((struct sconnection *qconn,
boolean fcarrier));
/* Run a chat program on a connection. */
boolean (*pfchat) P((struct sconnection *qconn, char **pzprog));
/* Get the baud rate of a connection. This field may be NULL. */
long (*pibaud) P((struct sconnection *qconn));
};
/* Connection functions. */
/* Initialize a connection. This must be called before any of the
other connection functions are called. It initializes the fields
of qconn. If qport is NULL, this opens standard input as a port
using type ttype. This function returns FALSE on error. */
extern boolean fconn_init P((struct uuconf_port *qport,
struct sconnection *qconn,
enum uuconf_porttype ttype));
/* Free up connection data. */
extern void uconn_free P((struct sconnection *qconn));
/* Lock a connection. The fin argument is TRUE if the port is to be
used for an incoming call; certains type of Unix locking need this
information because they need to open the port. The fuser argument
is TRUE if, should the port be opened, it should be opened using
the user's permissions rather than the effective permissions. */
extern boolean fconn_lock P((struct sconnection *qconn, boolean fin,
boolean fuser));
/* Unlock a connection. */
extern boolean fconn_unlock P((struct sconnection *qconn));
/* Open a connection. If ibaud is 0, the natural baud rate of the
port is used. If ihighbaud is not 0, fconn_open chooses the
highest supported baud rate between ibaud and ihighbaud. If fwait
is TRUE, this should wait for an incoming call. If fuser is true,
the device should be opened using the user's permissions rather
than the effective permissions. */
extern boolean fconn_open P((struct sconnection *qconn, long ibaud,
long ihighbaud, boolean fwait,
boolean fuser, boolean nortscts));
/* Close a connection. The fsuccess argument is TRUE if the
conversation completed normally, FALSE if it is being aborted. */
extern boolean fconn_close P((struct sconnection *qconn,
pointer puuconf,
struct uuconf_dialer *qdialer,
boolean fsuccess));
/* Dial out on a connection. The qsys and zphone arguments are for
the chat scripts; zphone is the phone number to dial. If qdialer
is not NULL, *qdialer will be set to the dialer information used if
any; *ptdialerfound will be set appropriately. */
extern boolean fconn_dial P((struct sconnection *q, pointer puuconf,
const struct uuconf_system *qsys,
const char *zphone,
struct uuconf_dialer *qdialer,
enum tdialerfound *ptdialerfound));
/* Read from a connection.
zbuf -- buffer to read bytes into
*pclen on call -- length of zbuf
*pclen on successful return -- number of bytes read
cmin -- minimum number of bytes to read before returning ahead of timeout
ctimeout -- timeout in seconds, 0 if none
freport -- whether to report errors. */
extern boolean fconn_read P((struct sconnection *qconn, char *zbuf,
size_t *pclen, size_t cmin,
int ctimeout, boolean freport));
/* Write to a connection. */
extern boolean fconn_write P((struct sconnection *qconn, const char *zbuf,
size_t cbytes));
/* Read and write to a connection. This reads and writes data until
either all passed-in data has been written or the read buffer is
full.
zwrite -- buffer to write bytes from
*pcwrite on call -- number of bytes to write
*pcwrite on successful return -- number of bytes written
zread -- buffer to read bytes into
*pcread on call -- size of read buffer
*pcread on successful return -- number of bytes read. */
extern boolean fconn_io P((struct sconnection *qconn, const char *zwrite,
size_t *pcwrite, char *zread, size_t *pcread));
/* Send a break character to a connection. */
extern boolean fconn_break P((struct sconnection *qconn));
/* Change the settings of a connection. This allows independent
control over the parity of output characters, whether to strip
input characters, and whether to do XON/XOFF handshaking. There is
no explicit control over parity checking of input characters. This
function returns FALSE on error. Attempts to set values not
supported by the hardware are silently ignored. */
extern boolean fconn_set P((struct sconnection *qconn,
enum tparitysetting tparity,
enum tstripsetting tstrip,
enum txonxoffsetting txonxoff));
/* Get the baud rate of a connection. */
extern long iconn_baud P((struct sconnection *qconn));
/* Do a chat script with a system. */
extern boolean fchat P((struct sconnection *qconn, pointer puuconf,
const struct uuconf_chat *qchat,
const struct uuconf_system *qsys,
const struct uuconf_dialer *qdialer,
const char *zphone, boolean ftranslate,
const char *zport, long ibaud));
/* Tell the connection to either require or ignore carrier as fcarrier
is TRUE or FALSE respectively. This is called with fcarrier TRUE
when \m is encountered in a chat script, and with fcarrier FALSE
when \M is encountered. */
extern boolean fconn_carrier P((struct sconnection *qconn,
boolean fcarrier));
/* Run a chat program on a connection. */
extern boolean fconn_run_chat P((struct sconnection *qconn,
char **pzprog));
/* Run through a dialer sequence. This is a support routine for the
port type specific dialing routines. */
extern boolean fconn_dial_sequence P((struct sconnection *qconn,
pointer puuconf, char **pzdialer,
const struct uuconf_system *qsys,
const char *zphone,
struct uuconf_dialer *qdialer,
enum tdialerfound *ptdialerfound));
/* Dialing out on a modem is partially system independent. This is
the modem dialing routine. */
extern boolean fmodem_dial P((struct sconnection *qconn, pointer puuconf,
const struct uuconf_system *qsys,
const char *zphone,
struct uuconf_dialer *qdialer,
enum tdialerfound *ptdialerfound));
/* Begin dialing out. This should open the dialer device if there is
one, toggle DTR if requested and possible, and tell the port to
ignore carrier. It should return FALSE on error. */
extern boolean fsysdep_modem_begin_dial P((struct sconnection *qconn,
struct uuconf_dialer *qdial));
/* Finish dialing out on a modem. This should close the dialer device
if there is one. If the dialer and the port both support carrier,
the connection should be told to pay attention to carrier. If it
is possible to wait for carrier to come on, and the dialer and the
port both the port support carrier, it should wait until carrier
comes on. */
extern boolean fsysdep_modem_end_dial P((struct sconnection *qconn,
struct uuconf_dialer *qdial));
/* System dependent initialization routines. */
extern boolean fsysdep_stdin_init P((struct sconnection *qconn));
extern boolean fsysdep_modem_init P((struct sconnection *qconn));
extern boolean fsysdep_direct_init P((struct sconnection *qconn));
#if HAVE_TCP
extern boolean fsysdep_tcp_init P((struct sconnection *qconn));
#endif
#if HAVE_TLI
extern boolean fsysdep_tli_init P((struct sconnection *qconn));
#endif
extern boolean fsysdep_pipe_init P((struct sconnection *qconn));
#endif /* ! defined (CONN_H) */
|