|
|
1.1 ! root 1: /* tdialc.c ! 2: Handle a Taylor UUCP dialer command. ! 3: ! 4: Copyright (C) 1992 Ian Lance Taylor ! 5: ! 6: This file is part of the Taylor UUCP uuconf library. ! 7: ! 8: This library is free software; you can redistribute it and/or ! 9: modify it under the terms of the GNU Library General Public License ! 10: as published by the Free Software Foundation; either version 2 of ! 11: the License, or (at your option) any later version. ! 12: ! 13: This library 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: Library General Public License for more details. ! 17: ! 18: You should have received a copy of the GNU Library General Public ! 19: License along with this library; 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: #include "uucnfi.h" ! 27: ! 28: #if USE_RCS_ID ! 29: const char _uuconf_tdialc_rcsid[] = "$Id: tdialc.c,v 1.1 93/07/30 08:07:41 bin Exp Locker: bin $"; ! 30: #endif ! 31: ! 32: static int idchat P((pointer pglobal, int argc, char **argv, pointer pvar, ! 33: pointer pinfo)); ! 34: static int iddtr_toggle P((pointer pglobal, int argc, char **argv, ! 35: pointer pvar, pointer pinfo)); ! 36: static int idcomplete P((pointer pglobal, int argc, char **argv, ! 37: pointer pvar, pointer pinfo)); ! 38: static int idproto_param P((pointer pglobal, int argc, char **argv, ! 39: pointer pvar, pointer pinfo)); ! 40: static int idcunknown P((pointer pglobal, int argc, char **argv, ! 41: pointer pvar, pointer pinfo)); ! 42: ! 43: /* The command table for dialer commands. The "dialer" command is ! 44: handled specially. */ ! 45: static const struct cmdtab_offset asDialer_cmds[] = ! 46: { ! 47: { "chat", UUCONF_CMDTABTYPE_PREFIX | 0, ! 48: offsetof (struct uuconf_dialer, uuconf_schat), idchat }, ! 49: { "dialtone", UUCONF_CMDTABTYPE_STRING, ! 50: offsetof (struct uuconf_dialer, uuconf_zdialtone), NULL }, ! 51: { "pause", UUCONF_CMDTABTYPE_STRING, ! 52: offsetof (struct uuconf_dialer, uuconf_zpause), NULL }, ! 53: { "carrier", UUCONF_CMDTABTYPE_BOOLEAN, ! 54: offsetof (struct uuconf_dialer, uuconf_fcarrier), NULL }, ! 55: { "carrier-wait", UUCONF_CMDTABTYPE_INT, ! 56: offsetof (struct uuconf_dialer, uuconf_ccarrier_wait), NULL }, ! 57: { "dtr-toggle", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iddtr_toggle }, ! 58: { "complete", UUCONF_CMDTABTYPE_FN | 2, ! 59: offsetof (struct uuconf_dialer, uuconf_scomplete), idcomplete }, ! 60: { "complete-chat", UUCONF_CMDTABTYPE_PREFIX, ! 61: offsetof (struct uuconf_dialer, uuconf_scomplete), idchat }, ! 62: { "abort", UUCONF_CMDTABTYPE_FN | 2, ! 63: offsetof (struct uuconf_dialer, uuconf_sabort), idcomplete }, ! 64: { "abort-chat", UUCONF_CMDTABTYPE_PREFIX, ! 65: offsetof (struct uuconf_dialer, uuconf_sabort), idchat }, ! 66: { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0, ! 67: offsetof (struct uuconf_dialer, uuconf_qproto_params), idproto_param }, ! 68: { "seven-bit", UUCONF_CMDTABTYPE_FN | 2, ! 69: offsetof (struct uuconf_dialer, uuconf_ireliable), _uuconf_iseven_bit }, ! 70: { "reliable", UUCONF_CMDTABTYPE_FN | 2, ! 71: offsetof (struct uuconf_dialer, uuconf_ireliable), _uuconf_ireliable }, ! 72: { "half-duplex", UUCONF_CMDTABTYPE_FN | 2, ! 73: offsetof (struct uuconf_dialer, uuconf_ireliable), ! 74: _uuconf_ihalf_duplex }, ! 75: { NULL, 0, 0, NULL } ! 76: }; ! 77: ! 78: #define CDIALER_CMDS (sizeof asDialer_cmds / sizeof asDialer_cmds[0]) ! 79: ! 80: /* Handle a command passed to a dialer from a Taylor UUCP ! 81: configuration file. This can be called when reading the dialer ! 82: file, the port file, or the sys file. The return value may have ! 83: UUCONF_CMDTABRET_KEEP set, but not UUCONF_CMDTABRET_EXIT. It ! 84: assigns values to the elements of qdialer. The first time this is ! 85: called, qdialer->uuconf_palloc should be set. This will not set ! 86: qdialer->uuconf_zname. */ ! 87: ! 88: int ! 89: _uuconf_idialer_cmd (qglobal, argc, argv, qdialer) ! 90: struct sglobal *qglobal; ! 91: int argc; ! 92: char **argv; ! 93: struct uuconf_dialer *qdialer; ! 94: { ! 95: struct uuconf_cmdtab as[CDIALER_CMDS]; ! 96: int iret; ! 97: ! 98: _uuconf_ucmdtab_base (asDialer_cmds, CDIALER_CMDS, (char *) qdialer, as); ! 99: ! 100: iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as, ! 101: (pointer) qdialer, idcunknown, 0, ! 102: qdialer->uuconf_palloc); ! 103: ! 104: return iret &~ UUCONF_CMDTABRET_EXIT; ! 105: } ! 106: ! 107: /* Reroute a chat script command. */ ! 108: ! 109: static int ! 110: idchat (pglobal, argc, argv, pvar, pinfo) ! 111: pointer pglobal; ! 112: int argc; ! 113: char **argv; ! 114: pointer pvar; ! 115: pointer pinfo; ! 116: { ! 117: struct sglobal *qglobal = (struct sglobal *) pglobal; ! 118: struct uuconf_chat *qchat = (struct uuconf_chat *) pvar; ! 119: struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; ! 120: ! 121: return _uuconf_ichat_cmd (qglobal, argc, argv, qchat, ! 122: qdialer->uuconf_palloc); ! 123: } ! 124: ! 125: /* Handle the "dtr-toggle" command, which may take two arguments. */ ! 126: ! 127: /*ARGSUSED*/ ! 128: static int ! 129: iddtr_toggle (pglobal, argc, argv, pvar, pinfo) ! 130: pointer pglobal; ! 131: int argc; ! 132: char **argv; ! 133: pointer pvar; ! 134: pointer pinfo; ! 135: { ! 136: struct sglobal *qglobal = (struct sglobal *) pglobal; ! 137: struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; ! 138: int iret; ! 139: ! 140: if (argc < 2 || argc > 3) ! 141: return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; ! 142: ! 143: iret = _uuconf_iboolean (qglobal, argv[1], &qdialer->uuconf_fdtr_toggle); ! 144: if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) ! 145: return iret; ! 146: ! 147: if (argc < 3) ! 148: return iret; ! 149: ! 150: iret |= _uuconf_iboolean (qglobal, argv[2], ! 151: &qdialer->uuconf_fdtr_toggle_wait); ! 152: ! 153: return iret; ! 154: } ! 155: ! 156: /* Handle the "complete" and "abort" commands. These just turn a ! 157: string into a trivial chat script. */ ! 158: ! 159: /*ARGSUSED*/ ! 160: static int ! 161: idcomplete (pglobal, argc, argv, pvar, pinfo) ! 162: pointer pglobal; ! 163: int argc; ! 164: char **argv; ! 165: pointer pvar; ! 166: pointer pinfo; ! 167: { ! 168: struct sglobal *qglobal = (struct sglobal *) pglobal; ! 169: struct uuconf_chat *qchat = (struct uuconf_chat *) pvar; ! 170: struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; ! 171: char *azargs[3]; ! 172: ! 173: azargs[0] = (char *) "complete-chat"; ! 174: azargs[1] = (char *) "\"\""; ! 175: azargs[2] = (char *) argv[1]; ! 176: ! 177: return _uuconf_ichat_cmd (qglobal, 3, azargs, qchat, ! 178: qdialer->uuconf_palloc); ! 179: } ! 180: ! 181: /* Handle the "protocol-parameter" command. */ ! 182: ! 183: static int ! 184: idproto_param (pglobal, argc, argv, pvar, pinfo) ! 185: pointer pglobal; ! 186: int argc; ! 187: char **argv; ! 188: pointer pvar; ! 189: pointer pinfo; ! 190: { ! 191: struct sglobal *qglobal = (struct sglobal *) pglobal; ! 192: struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar; ! 193: struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; ! 194: ! 195: return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam, ! 196: qdialer->uuconf_palloc); ! 197: } ! 198: ! 199: /* Give an error for an unknown dialer command. */ ! 200: ! 201: /*ARGSUSED*/ ! 202: static int ! 203: idcunknown (pglobal, argc, argv, pvar, pinfo) ! 204: pointer pglobal; ! 205: int argc; ! 206: char **argv; ! 207: pointer pvar; ! 208: pointer pinfo; ! 209: { ! 210: return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; ! 211: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.