|
|
1.1 ! root 1: /* conn.h ! 2: Header file for routines which manipulate connections. ! 3: ! 4: Copyright (C) 1991, 1992 Ian Lance Taylor ! 5: ! 6: This file is part of the Taylor UUCP package. ! 7: ! 8: This program is free software; you can redistribute it and/or ! 9: modify it under the terms of the GNU General Public License as ! 10: published by the Free Software Foundation; either version 2 of the ! 11: License, or (at your option) any later version. ! 12: ! 13: This program is distributed in the hope that it will be useful, but ! 14: WITHOUT ANY WARRANTY; without even the implied warranty of ! 15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! 16: General Public License for more details. ! 17: ! 18: You should have received a copy of the GNU General Public License ! 19: along with this program; if not, write to the Free Software ! 20: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! 21: ! 22: The author of the program may be contacted at [email protected] or ! 23: c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. ! 24: */ ! 25: ! 26: #ifndef CONN_H ! 27: ! 28: #define CONN_H ! 29: ! 30: #if ANSI_C ! 31: /* These structures are used in prototypes but are not defined in this ! 32: header file. */ ! 33: struct uuconf_system; ! 34: struct uuconf_dialer; ! 35: struct uuconf_chat; ! 36: #endif ! 37: ! 38: /* This structure represents a connection. */ ! 39: ! 40: struct sconnection ! 41: { ! 42: /* Pointer to command table for this type of connection. */ ! 43: const struct sconncmds *qcmds; ! 44: /* Pointer to system dependent information. */ ! 45: pointer psysdep; ! 46: /* Pointer to system independent information. */ ! 47: struct uuconf_port *qport; ! 48: }; ! 49: ! 50: /* Whether fconn_dial got a dialer. */ ! 51: ! 52: enum tdialerfound ! 53: { ! 54: /* Did not find a dialer. */ ! 55: DIALERFOUND_FALSE, ! 56: /* Found a dialer which does not need to be freed. */ ! 57: DIALERFOUND_TRUE, ! 58: /* Found a dialer which does need to be freed. */ ! 59: DIALERFOUND_FREE ! 60: }; ! 61: ! 62: /* Parity settings to pass to fconn_set. */ ! 63: ! 64: enum tparitysetting ! 65: { ! 66: /* Do not change output parity generation. */ ! 67: PARITYSETTING_DEFAULT, ! 68: /* No parity (all eight output bits used). */ ! 69: PARITYSETTING_NONE, ! 70: /* Even parity. */ ! 71: PARITYSETTING_EVEN, ! 72: /* Odd parity. */ ! 73: PARITYSETTING_ODD, ! 74: /* Mark parity. */ ! 75: PARITYSETTING_MARK, ! 76: /* Space parity. */ ! 77: PARITYSETTING_SPACE ! 78: }; ! 79: ! 80: /* Type of strip control argument to fconn_set. */ ! 81: ! 82: enum tstripsetting ! 83: { ! 84: /* Do not change the stripping of input characters. */ ! 85: STRIPSETTING_DEFAULT, ! 86: /* Do not strip input characters to seven bits. */ ! 87: STRIPSETTING_EIGHTBITS, ! 88: /* Strip input characters to seven bits. */ ! 89: STRIPSETTING_SEVENBITS ! 90: }; ! 91: ! 92: /* Type of XON/XOFF control argument to fconn_set. */ ! 93: ! 94: enum txonxoffsetting ! 95: { ! 96: /* Do not change XON/XOFF handshake setting. */ ! 97: XONXOFF_DEFAULT, ! 98: /* Do not do XON/XOFF handshaking. */ ! 99: XONXOFF_OFF, ! 100: /* Do XON/XOFF handshaking. */ ! 101: XONXOFF_ON ! 102: }; ! 103: ! 104: /* A command table holds the functions which implement actions for ! 105: each different kind of connection. */ ! 106: ! 107: struct sconncmds ! 108: { ! 109: /* Free up a connection. */ ! 110: void (*pufree) P((struct sconnection *qconn)); ! 111: /* Lock the connection. The fin argument is TRUE if the connection ! 112: is to be used for an incoming call. May be NULL. */ ! 113: boolean (*pflock) P((struct sconnection *qconn, boolean fin)); ! 114: /* Unlock the connection. May be NULL. */ ! 115: boolean (*pfunlock) P((struct sconnection *qconn)); ! 116: /* Open the connection. */ ! 117: boolean (*pfopen) P((struct sconnection *qconn, long ibaud, ! 118: boolean fwait)); ! 119: /* Close the connection. */ ! 120: boolean (*pfclose) P((struct sconnection *qconn, ! 121: pointer puuconf, ! 122: struct uuconf_dialer *qdialer, ! 123: boolean fsuccess)); ! 124: /* Reset the connection so that another call may be accepted. */ ! 125: boolean (*pfreset) P((struct sconnection *qconn)); ! 126: /* Dial a number on a connection. This set *qdialer to the dialer ! 127: used, if any, and sets *ptdialerfound appropriately. The qsys ! 128: and zphone arguments are for the chat script. This field may be ! 129: NULL. */ ! 130: boolean (*pfdial) P((struct sconnection *qconn, pointer puuconf, ! 131: const struct uuconf_system *qsys, ! 132: const char *zphone, ! 133: struct uuconf_dialer *qdialer, ! 134: enum tdialerfound *ptdialerfound)); ! 135: /* Read data from a connection, with a timeout in seconds. When ! 136: called *pclen is the length of the buffer; on successful return ! 137: *pclen is the number of bytes read into the buffer. The cmin ! 138: argument is the minimum number of bytes to read before returning ! 139: ahead of a timeout. */ ! 140: boolean (*pfread) P((struct sconnection *qconn, char *zbuf, size_t *pclen, ! 141: size_t cmin, int ctimeout, boolean freport)); ! 142: /* Write data to the connection. */ ! 143: boolean (*pfwrite) P((struct sconnection *qconn, const char *zbuf, ! 144: size_t clen)); ! 145: /* Read and write data to the connection. This reads and writes ! 146: data until either all passed in data has been written or the read ! 147: buffer has been filled. When called *pcread is the size of the ! 148: read buffer and *pcwrite is the number of bytes to write; on ! 149: successful return *pcread is the number of bytes read and ! 150: *pcwrite is the number of bytes written. */ ! 151: boolean (*pfio) P((struct sconnection *qconn, const char *zwrite, ! 152: size_t *pcwrite, char *zread, size_t *pcread)); ! 153: /* Send a break character. This field may be NULL. */ ! 154: boolean (*pfbreak) P((struct sconnection *qconn)); ! 155: /* Change the connection setting. This field may be NULL. */ ! 156: boolean (*pfset) P((struct sconnection *qconn, ! 157: enum tparitysetting tparity, ! 158: enum tstripsetting tstrip, ! 159: enum txonxoffsetting txonxoff)); ! 160: /* Require or ignore carrer. This field may be NULL. */ ! 161: boolean (*pfcarrier) P((struct sconnection *qconn, ! 162: boolean fcarrier)); ! 163: /* Run a chat program on a connection. */ ! 164: boolean (*pfchat) P((struct sconnection *qconn, char **pzprog)); ! 165: /* Get the baud rate of a connection. This field may be NULL. */ ! 166: long (*pibaud) P((struct sconnection *qconn)); ! 167: }; ! 168: ! 169: /* Connection functions. */ ! 170: ! 171: /* Initialize a connection. This must be called before any of the ! 172: other connection functions are called. It initializes the fields ! 173: of qconn. It returns FALSE on error. */ ! 174: extern boolean fconn_init P((struct uuconf_port *qport, ! 175: struct sconnection *qconn)); ! 176: ! 177: /* Free up connection data. */ ! 178: extern void uconn_free P((struct sconnection *qconn)); ! 179: ! 180: /* Lock a connection. The fin argument is TRUE if the port is to be ! 181: used for an incoming call; certains type of Unix locking need this ! 182: information because they need to open the port. */ ! 183: extern boolean fconn_lock P((struct sconnection *qconn, boolean fin)); ! 184: ! 185: /* Unlock a connection. */ ! 186: extern boolean fconn_unlock P((struct sconnection *qconn)); ! 187: ! 188: /* Open a connection. If ibaud is 0, the natural baud rate of the ! 189: port is used. If ihighbaud is not 0, fconn_open chooses the ! 190: highest supported baud rate between ibaud and ihighbaud. If fwait ! 191: is TRUE, this should wait for an incoming call. */ ! 192: extern boolean fconn_open P((struct sconnection *qconn, long ibaud, ! 193: long ihighbaud, boolean fwait)); ! 194: ! 195: /* Close a connection. The fsuccess argument is TRUE if the ! 196: conversation completed normally, FALSE if it is being aborted. */ ! 197: extern boolean fconn_close P((struct sconnection *qconn, ! 198: pointer puuconf, ! 199: struct uuconf_dialer *qdialer, ! 200: boolean fsuccess)); ! 201: ! 202: /* Reset a connection such that another call may be accepted. */ ! 203: extern boolean fconn_reset P((struct sconnection *q)); ! 204: ! 205: /* Dial out on a connection. The qsys and zphone arguments are for ! 206: the chat scripts; zphone is the phone number to dial. If qdialer ! 207: is not NULL, *qdialer will be set to the dialer information used if ! 208: any; *ptdialerfound will be set appropriately. */ ! 209: extern boolean fconn_dial P((struct sconnection *q, pointer puuconf, ! 210: const struct uuconf_system *qsys, ! 211: const char *zphone, ! 212: struct uuconf_dialer *qdialer, ! 213: enum tdialerfound *ptdialerfound)); ! 214: ! 215: /* Read from a connection. ! 216: zbuf -- buffer to read bytes into ! 217: *pclen on call -- length of zbuf ! 218: *pclen on successful return -- number of bytes read ! 219: cmin -- minimum number of bytes to read before returning ahead of timeout ! 220: ctimeout -- timeout in seconds, 0 if none ! 221: freport -- whether to report errors. */ ! 222: extern boolean fconn_read P((struct sconnection *qconn, char *zbuf, ! 223: size_t *pclen, size_t cmin, ! 224: int ctimeout, boolean freport)); ! 225: ! 226: /* Write to a connection. */ ! 227: extern boolean fconn_write P((struct sconnection *qconn, const char *zbuf, ! 228: size_t cbytes)); ! 229: ! 230: /* Read and write to a connection. This reads and writes data until ! 231: either all passed-in data has been written or the read buffer is ! 232: full. ! 233: zwrite -- buffer to write bytes from ! 234: *pcwrite on call -- number of bytes to write ! 235: *pcwrite on successful return -- number of bytes written ! 236: zread -- buffer to read bytes into ! 237: *pcread on call -- size of read buffer ! 238: *pcread on successful return -- number of bytes read. */ ! 239: extern boolean fconn_io P((struct sconnection *qconn, const char *zwrite, ! 240: size_t *pcwrite, char *zread, size_t *pcread)); ! 241: ! 242: /* Send a break character to a connection. */ ! 243: extern boolean fconn_break P((struct sconnection *qconn)); ! 244: ! 245: /* Change the settings of a connection. This allows independent ! 246: control over the parity of output characters, whether to strip ! 247: input characters, and whether to do XON/XOFF handshaking. There is ! 248: no explicit control over parity checking of input characters. This ! 249: function returns FALSE on error. Attempts to set values not ! 250: supported by the hardware are silently ignored. */ ! 251: extern boolean fconn_set P((struct sconnection *qconn, ! 252: enum tparitysetting tparity, ! 253: enum tstripsetting tstrip, ! 254: enum txonxoffsetting txonxoff)); ! 255: ! 256: /* Get the baud rate of a connection. */ ! 257: extern long iconn_baud P((struct sconnection *qconn)); ! 258: ! 259: /* Do a chat script with a system. */ ! 260: extern boolean fchat P((struct sconnection *qconn, pointer puuconf, ! 261: const struct uuconf_chat *qchat, ! 262: const struct uuconf_system *qsys, ! 263: const struct uuconf_dialer *qdialer, ! 264: const char *zphone, boolean ftranslate, ! 265: const char *zport, long ibaud)); ! 266: ! 267: /* Tell the connection to either require or ignore carrier as fcarrier ! 268: is TRUE or FALSE respectively. This is called with fcarrier TRUE ! 269: when \m is encountered in a chat script, and with fcarrier FALSE ! 270: when \M is encountered. */ ! 271: extern boolean fconn_carrier P((struct sconnection *qconn, ! 272: boolean fcarrier)); ! 273: ! 274: /* Run a chat program on a connection. */ ! 275: extern boolean fconn_run_chat P((struct sconnection *qconn, ! 276: char **pzprog)); ! 277: ! 278: /* Dialing out on a modem is partially system independent. This is ! 279: the modem dialing routine. */ ! 280: extern boolean fmodem_dial P((struct sconnection *qconn, pointer puuconf, ! 281: const struct uuconf_system *qsys, ! 282: const char *zphone, ! 283: struct uuconf_dialer *qdialer, ! 284: enum tdialerfound *ptdialerfound)); ! 285: ! 286: /* Begin dialing out. This should open the dialer device if there is ! 287: one, toggle DTR if requested and possible, and tell the port to ! 288: ignore carrier. It should return FALSE on error. */ ! 289: extern boolean fsysdep_modem_begin_dial P((struct sconnection *qconn, ! 290: struct uuconf_dialer *qdial)); ! 291: ! 292: /* Finish dialing out on a modem. This should close the dialer device ! 293: if there is one. If the dialer and the port both support carrier, ! 294: the connection should be told to pay attention to carrier. If it ! 295: is possible to wait for carrier to come on, and the dialer and the ! 296: port both the port support carrier, it should wait until carrier ! 297: comes on. */ ! 298: extern boolean fsysdep_modem_end_dial P((struct sconnection *qconn, ! 299: struct uuconf_dialer *qdial)); ! 300: ! 301: /* System dependent initialization routines. */ ! 302: extern boolean fsysdep_stdin_init P((struct sconnection *qconn)); ! 303: extern boolean fsysdep_modem_init P((struct sconnection *qconn)); ! 304: extern boolean fsysdep_direct_init P((struct sconnection *qconn)); ! 305: #if HAVE_TCP ! 306: extern boolean fsysdep_tcp_init P((struct sconnection *qconn)); ! 307: #endif ! 308: #if HAVE_TLI ! 309: extern boolean fsysdep_tli_init P((struct sconnection *qconn)); ! 310: #endif ! 311: ! 312: #endif /* ! defined (CONN_H) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.