⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckudia.c

📁 操作系统源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
char *dialv = "Dial Command, V2.0(009) 24 Jan 88";/*  C K U D I A  --  Dialing program for connection to remote system *//* Author: Herm Fischer (HFISCHER@USC-ECLB) Contributed to Columbia University for inclusion in C-Kermit. Copyright (C) 1985, Herman Fischer, 16400 Ventura Blvd, Encino CA 91436 Permission is granted to any individual or institution to use, copy, or redistribute this software so long as it is not sold for profit, provided this copyright notice is retained.  ------ This module should work under all versions of Unix.  It calls externally defined system-depended functions for i/o, but depends upon the existence of various modem control functions. This module, and the supporting routines in the ckutio.c module, assume that the computer and modem properly utilize the following data communi- cations signals (that means one should prepare the modem to use, not circumvent, these signals):     Data Terminal Ready:  This signal is asserted by the computer     when Kermit is about to ask the modem to dial a call, and is     removed when Kermit wishes to have the modem hang up a call.     The signal is asserted both while Kermit is asking the modem     to dial a specific number, and after connection, while Kermit     is in a data exchange mode.       Carrier detect:  This signal must be asserted by the modem when     a carrier is detected from a remote modem on a communications     circuit.  It must be removed by the modem when the circuit     disconnects or is hung up.  (Carrier detect is ignored while     Kermit is asking the modem to dial the call, because there is     no consistant usage of this signal during the dialing phase     among different modem manufacturers.)*//* * Modifications: * *	21-Jul-85	Fixed failure returns hanging on no carrier signal *			Requires tthang change too (ckutio.c revision) *							-- Herm Fischer * *	28-Jun-85	Fixed bug with defaulting the modem-failure message *			in lbuf. *							-- Dan Schullman * *	27-Jun-85	Merged in code from Joe Orost at Berkeley for *			supporting the US Robotics modem, which included *			changing the single characters in MDMINF into *			multi-character strings and modifying waitFor. *							-- Dan Schullman * *	26-Jun-85	Allow interrupts to be used to abort dialing, *			and ring the bell when a connection is made. *			Reorganized some of the failure paths to use the *			same code, and now close the line on failures. *			Allow use of stored numbers with the DF100 and *			DF200 modems.  Handlers now declared after the *			call to setjmp. *							-- Dan Schullman * *	24-May-85	DF03, DF100-series, DF200-series, and "unknown" modem *			support added.  Also restructured the various data *			tables, fixed some bugs related to missing data and *			missing case labels, and modified the failure message *			to display the "reason" given by the modem. *							-- Dan Schullman *	16-Mar-87	Support for the ATT7300 UNIX PC internal modem was *			added. *							-- Richard E. Hill *//* * To add support for another modem, do the following: * *	Define a modem number symbol (n_XXX) for it, keeping the list *	in alphabetical and numerical order, and renumbering the values *	as necessary. * *	Create a MDMINF structure for it, again keeping the list alphabetical *	for sanity's sake. * *	Add the address of the MDMINF structure to the ptrtab array, again *	in alphabetical and numerical order. * *	Add the "user visible" modem name and corresponding modem number to *	the mdmtab array, again in alphabetical order. * *	Read through the code and add modem-specific sections as necessary. *//* * The intent of the "unknown" modem is hopefully to allow KERMIT to support * unknown modems by having the user type the entire autodial sequence * (possibly including control characters, etc.) as the "phone number". * The only reason that the CONNECT command cannot be used to do this is * that a remote line cannot normally be opened unless carrier is present. * * The protocol and other characteristics of this modem are unknown, with * some "reasonable" values being chosen for some of them.  The only way to * detect if a connection is made is to look for carrier present. * * SUPPORT IS CURRENTLY ONLY PARTIALLY SKETCHED OUT FOR THIS.  ALSO, IT * SHOULD PERHAPS BE HANDLED MUCH EARLIER, SIMPLY READING USER INPUT AND * SENDING IT TO THE MODEM AND ECHOING MODEM RESPONSES BACK TO THE USER, * ALL THE TIME LOOKING FOR CARRIER.  OF COURSE, THE PROBLEM THEN BECOMES * ONE OF ALLOWING THE USER TO ABORT THE DIALING.  WE COULD CHOOSE SOME * PHRASE THAT WOULD PRESUMABLY NEVER BE A PART OF A VALID AUTODIAL SEQUENCE * (E.G., "QUIT" and "quit"). -- DS */#include <sys/types.h>#include "ckcdeb.h"#include <stdio.h>#include <ctype.h>#include <signal.h>#include "ckcker.h"#include "ckucmd.h"#ifndef ZILOG#include <setjmp.h>			/* Longjumps */#else#include <setret.h>#endifextern int flow, local, mdmtyp, quiet, speed, parity, seslog;extern char ttname[], sesfil[];#ifndef MINIX#define	MDMINF	struct mdminfMDMINF		/* structure for modem-specific information */    {    int		dial_time;	/* time modem allows for dialing (secs) */    char	*pause_chars;	/* character(s) to tell modem to pause */    int		pause_time;	/* time associated with pause chars (secs) */    char	*wake_str;	/* string to wakeup modem & put in cmd mode */    int		wake_rate;	/* delay between wake_str characters (msecs) */    char	*wake_prompt;	/* string prompt after wake_str */    char	*dmode_str;	/* string to put modem in dialing mode */    char	*dmode_prompt;	/* string prompt for dialing mode */    char	*dial_str;	/* dialing string, with "%s" for number */    int		dial_rate;	/* delay between dialing characters (msecs) */    };/* * Define symbolic modem numbers. * * The numbers MUST correspond to the ordering of entries * within the ptrtab array, and start at one (1). * * It is assumed that there are relatively few of these * values, and that the high(er) bytes of the value may * be used for modem-specific mode information. * * REMEMBER that only the first eight characters of these * names are guaranteed to be unique. */#define		n_CERMETEK	 1#define		n_DF03		 2#define		n_DF100		 3#define		n_DF200		 4#define		n_GDC		 5#define		n_HAYES		 6#define		n_PENRIL	 7#define		n_RACAL		 8#define		n_UNKNOWN	 9#define		n_USROBOT	10#define		n_VENTEL	11#define         n_CONCORD       12#define		n_ATT7300	13	/* added for PC7300 *//* * Declare modem "variant" numbers for any of the above for which it is * necessary to note various operational modes, using the second byte * of a modem number. * * It is assumed that such modem modes share the same modem-specific * information (see MDMINF structure) but may differ in some of the actions * that are performed. */#define		n_HAYESNV	( n_HAYES + ( 1<<8 ) )/* * Declare structures containing modem-specific information. * * REMEMBER that only the first SEVEN characters of these * names are guaranteed to be unique. */staticMDMINF CERMETEK =	/* information for "Cermetek Info-Mate 212 A" modem */    {    20,			/* dial_time */    "BbPpTt",		/* pause_chars */    0,			/* pause_time */	/** unknown -- DS **/    "  XY\016R\r",	/* wake_str */    200,		/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "\016D '%s'\r",	/* dial_str */    200			/* dial_rate */    };staticMDMINF DF03 =		/* information for "DEC DF03-AC" modem */    {    27,			/* dial_time */    "=",		/* pause_chars */	/* wait for second dial tone */    15,			/* pause_time */    "\001\002",		/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "%s",		/* dial_str */    0			/* dial_rate */    };staticMDMINF DF100 =		/* information for "DEC DF100-series" modem */			/*			 * The telephone "number" can include "P"s and/or "T"s			 * within it to indicate that subsequent digits are			 * to be dialed using pulse or tone dialing.  The			 * modem defaults to pulse dialing.  You may modify			 * the dial string below to explicitly default all			 * dialing to pulse or tone, but doing so prevents			 * the use of phone numbers that you may have stored			 * in the modem's memory.			 */    {    30,			/* dial_time */    "=",		/* pause_chars */	/* wait for second dial tone */    15,			/* pause_time */    "\001",		/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "%s#",		/* dial_str */    0			/* dial_rate */    };staticMDMINF DF200 =		/* information for "DEC DF200-series" modem */			/*			 * The telephone "number" can include "P"s and/or "T"s			 * within it to indicate that subsequent digits are			 * to be dialed using pulse or tone dialing.  The			 * modem defaults to pulse dialing.  You may modify			 * the dial string below to explicitly default all			 * dialing to pulse or tone, but doing so prevents			 * the use of phone numbers that you may have stored			 * in the modem's memory.			 */    {    30,			/* dial_time */    "=W",		/* pause_chars */	/* =: second tone; W: 5 secs */    15,			/* pause_time */	/* worst case */    "\002",		/* wake_str */		/* allow stored number usage */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "%s!",		/* dial_str */    0			/* dial_rate */    };staticMDMINF GDC =		/* information for "GeneralDataComm 212A/ED" modem */    {    32,			/* dial_time */    "%",		/* pause_chars */    3,			/* pause_time */    "\r\r",		/* wake_str */    500,		/* wake_rate */    "$",		/* wake_prompt */    "D\r",		/* dmode_str */    ":",		/* dmode_prompt */    "T%s\r",		/* dial_str */    0			/* dial_rate */    };staticMDMINF HAYES =		/* information for "Hayes" modem */    {    35,			/* dial_time */    ",",		/* pause_chars */    2,			/* pause_time */    "AT\r",		/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "AT D %s\r",	/* dial_str */    0			/* dial_rate */    };staticMDMINF PENRIL =		/* information for "Penril" modem */    {    50,			/* dial_time */    "",			/* pause_chars */	/** unknown -- HF **/    0,			/* pause_time */    "\r\r",		/* wake_str */    300,		/* wake_rate */    ">",		/* wake_prompt */    "k\r",		/* dmode_str */    ":",		/* dmode_prompt */    "%s\r",		/* dial_str */    0			/* dial_rate */    };staticMDMINF RACAL =		/* information for "Racal Vadic" modem */    {    35,			/* dial_time */    "Kk",		/* pause_chars */    5,			/* pause_time */    "\005\r",		/* wake_str */    50,			/* wake_rate */    "*",		/* wake_prompt */    "D\r",		/* dmode_str */    "?",		/* dmode_prompt */    "%s\r",		/* dial_str */    0			/* dial_rate */    };staticMDMINF UNKNOWN =	/* information for "Unknown" modem */    {    30,			/* dial_time */    "",			/* pause_chars */    0,			/* pause_time */    "",			/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "%s\r",		/* dial_str */    0			/* dial_rate */    };staticMDMINF USROBOT =	/* information for "US Robotics 212A" modem */    {    30,			/* dial_time */    ",",		/* pause_chars */    2,			/* pause_time */    "ATS2=01\r",	/* wake_str */    0,			/* wake_rate */    "OK\r",		/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "ATTD%s\r",		/* dial_str */    0			/* dial_rate */    };staticMDMINF VENTEL =		/* information for "Ventel" modem */    {    20,			/* dial_time */    "%",		/* pause_chars */    5,			/* pause_time */    "\r\r\r",		/* wake_str */    300,		/* wake_rate */    "$",		/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "<K%s\r>",		/* dial_str */    0			/* dial_rate */    };staticMDMINF CONCORD =	/* Info for Condor CDS 220 2400b modem */    {    35,			/* dial_time */    ",",		/* pause_chars */    2,			/* pause_time */    "\r\r",		/* wake_str */    20,			/* wake_rate */    "CDS >",		/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "<D M%s\r>",	/* dial_str */    0			/* dial_rate */    };staticMDMINF ATT7300 =	/* dummy information for "ATT7300" internal modem */    {    30,			/* dial_time */    "",			/* pause_chars */    0,			/* pause_time */    "",			/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "%s\r",		/* dial_str */    0			/* dial_rate */    };/* * Declare table for converting modem numbers to information pointers. * * The entries MUST be in ascending order by modem number, without any * "gaps" in the numbers, and starting from one (1). * * This table should NOT include entries for the "variant" modem numbers, * since it is assumed that they share the same information as the normal * value. */staticMDMINF *ptrtab[] =    {    &CERMETEK,    &DF03,    &DF100,    &DF200,    &GDC,    &HAYES,    &PENRIL,    &RACAL,    &UNKNOWN,    &USROBOT,    &VENTEL,    &CONCORD,    &ATT7300    };/* * Declare modem names and associated numbers for command parsing, * and also for doing number-to-name translation. * * The entries MUST be in alphabetical order by modem name. */struct keytab mdmtab[] =    {    "att7300",          n_ATT7300,      0,    "cermetek",		n_CERMETEK,	0,    "concord",          n_CONCORD,      0,    "df03-ac",		n_DF03,		0,    "df100-series",	n_DF100,	0,    "df200-series",	n_DF200,	0,    "direct",		0,		0,    "gendatacomm",	n_GDC,		0,    "hayes",		n_HAYES,	0,    "penril",		n_PENRIL,	0,    "racalvadic",	n_RACAL,	0,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -