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

📄 ckudia.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifndef NODIALchar *dialv = "Dial Command, 5A(046) 2 Nov 92";/*  C K U D I A	 --  Module for automatic modem dialing. *//*  Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New  York.  Permission is granted to any individual or institution to use this  software as long as it is not sold for profit.  This copyright notice must be  retained.  This software may not be included in commercial products without  written permission of Columbia University.  Original (version 1, 1985) author: Herm Fischer, Encino, CA.  Contributed to Columbia University in 1985 for inclusion in C-Kermit 4.0.  Author and maintainer since 1985: Frank da Cruz, Columbia University,  fdc@columbia.edu.  Contributions by many others throughout the years, including: Fernando  Cabral, John Chmielewski, Joe Doupnik, Richard Hill, Larry Jacobs, Eric  Jones, Tom Kloos, Bob Larson, Peter Mauzey, Joe Orost, Kevin O'Gorman, Kai  Uwe Rommel, Dan Schullman, Warren Tucker, and others too numerous to list  here (but see acknowledgements in ckcmai.c).  This module calls externally defined system-dependent functions for  communications i/o, as defined in CKCPLM.DOC, the C-Kermit Program Logic  Manual, and thus should be portable to all systems that implement those  functions, and where alarm() and signal() work as they do in UNIX.*//*  To add support for another modem, do the following, all in this module:  1. Define a modem-type number symbol (n_XXX) for it.  2. Adjust MAX_MDM to the new number of modem types.  3. Create a MDMINF structure for it.  4. Add the address of the MDMINF structure to the ptrtab[] array,     according to the numerical value of the modem-type number.  5. Add the user-visible (SET MODEM) name and corresponding modem     number to the mdmtab[] array, in alphabetical order by modem-name string.  6. Read through the code and add modem-specific sections as necessary.  NOTE: The MINIDIAL symbol is used to build this module to include support  for only a minimum number of standard and/or generally useful modem types,  namely Hayes, CCITT V.25bis, "Unknown", and None.  When adding support for  a new modem type, keep it outside of the MINIDIAL sections.*/#include "ckcdeb.h"#ifndef MAC#include <signal.h>#endif /* MAC */#include "ckcasc.h"#include "ckcker.h"#include "ckucmd.h"#include "ckcnet.h"#ifndef ZILOG#include <setjmp.h>			/* Longjumps */#else#include <setret.h>#endif /* ZILOG */#ifdef MAC#define signal msignal#define SIGTYP long#define alarm malarm#define SIG_IGN 0#define SIGALRM 1#define SIGINT 2SIGTYP (*msignal(int type, SIGTYP (*func)(int)))(int);#endif /* MAC */int					/* SET DIAL parameters */  dialhng = 1,				/* DIAL HANGUP, default is ON */  dialdpy = 0,				/* DIAL DISPLAY, default is OFF */  mdmspd  = 1,				/* DIAL SPEED-MATCHING (1 = ON) */  dialtmo = 0,				/* DIAL TIMEOUT */  dialksp = 0,				/* DIAL KERMIT-SPOOF */  dialmnp = 0,				/* DIAL MNP-ENABLE */#ifdef NOMDMHUP  dialmhu = 0;				/* DIAL MODEM-HANGUP */#else  dialmhu = 1;				/* DIAL MODEM-HANGUP */#endif /* NOMDMHUP */char *dialdir = NULL;			/* DIAL DIRECTORY, default none */char *dialini = NULL;			/* DIAL INIT-STRING, default none */char *dialcmd = NULL;			/* DIAL DIAL-COMMAND, default none */char *dialnpr = NULL;			/* DIAL NUMBER-PREFIX, ditto */FILE * dialfd = NULL;			/* File descriptor of dial directory */#ifndef MINIDIAL/*  Telebit model codes:  ATI  Model Numbers           Examples  ---  -------------           --------  123                          Telebit in "total Hayes-1200" emulation mode  960                          Telebit in Conventional Command (Hayes) mode  961  RA12C                   IBM PC internal original Trailblazer  962  RA12E                   External original Trailblazer  963  RM12C                   Rackmount original Trailblazer  964  T18PC                   IBM PC internal Trailblazer-Plus (TB+)  965  T18SA, T2SAA, T2SAS     External TB+, T1600, T2000, T3000, WB, and later  966  T18RMM                  Rackmount TB+  967  T2MC                    IBM PS/2 internal TB+  968  T1000                   External T1000  969  ?                       Qblazer  971  T2500                   External T2500  972  T2500                   Rackmount T2500*//* Telebit model codes */#define TB_UNK  0			/* Unknown Telebit model */#define TB_BLAZ 1			/* Original TrailBlazer */#define TB_PLUS	2			/* TrailBlazer Plus */#define TB_1000 3			/* T1000 */#define TB_1500 4			/* T1500 */#define TB_1600 5			/* T1600 */#define TB_2000 6			/* T2000 */#define TB_2500 7			/* T2500 */#define TB_3000 8			/* T3000 */#define TB_QBLA 9			/* Qblazer */#define TB_WBLA 10			/* WorldBlazer */#define TB__MAX 10			/* Highest number */char *tb_name[] = {			/* Array of model names */    "Unknown",				/* TB_UNK  */    "TrailBlazer",			/* TB_BLAZ */    "TrailBlazer-Plus",			/* TB_PLUS */    "T1000",				/* TB_1000 */    "T1500",				/* TB_1500 */    "T1600",				/* TB_1600 */    "T2000",				/* TB_2000 */    "T2500",				/* TB_2500 */    "T3000",				/* TB_3000 */    "Qblazer",				/* TB_QBLA */    "WorldBlazer",			/* TB_WBLA */    ""};#endif /* MINIDIAL */extern int flow, local, mdmtyp, quiet, backgrd, parity, seslog, network;extern int carrier, duplex;#ifdef NETCONNextern int ttnproto;#endif /* NETCONN */extern CHAR stchr;extern long speed;extern char ttname[], sesfil[];/* * Failure reasons for use with the 'longjmp' exit. */#define F_time		1		/* timeout */#define F_int		2		/* interrupt */#define F_modem		3		/* modem-detected failure */#define F_minit		4		/* cannot initialize modem */static int mymdmtyp;			/* Local copy of modem type. */static int n1 = F_time;_PROTOTYP (static int ddinc, (int) );_PROTOTYP (int dialhup, (void) );_PROTOTYP (int getok, (int,int) );_PROTOTYP (char * getdws, (int) );_PROTOTYP (static VOID ttslow, (char *s, int millisec) );_PROTOTYP (VOID xcpy, (char *to, char *from, unsigned len) );_PROTOTYP (static VOID waitfor, (char *s) );_PROTOTYP (static VOID dialoc, (char c) );_PROTOTYP (static int didweget, (char *s, char *r) );_PROTOTYP (static VOID spdchg, (long s) );_PROTOTYP (static VOID tbati3, (int n) );#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) */    int		esc_time;	/* guard time on escape sequence (msecs) */    char	*esc_str;	/* escape sequence */    char	*hup_str;	/* hangup string */    _PROTOTYP( int (*ok_fn), (int,int) ); /* func to read response string */    };/* * 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. */#ifdef MINIDIAL				/* Minimum dialer support */					/* Only for CCITT, HAYES, and UNK */#define		n_CCITT		 1#define		n_HAYES		 2#define		n_UNKNOWN	 3#define		MAX_MDM		 3	/* Number of modem types */#else					/* Full-blown dialer support */#define		n_ATTDTDM	 1#define         n_ATTISN         2#define		n_ATTMODEM	 3#define		n_CCITT		 4#define		n_CERMETEK	 5#define		n_DF03		 6#define		n_DF100		 7#define		n_DF200		 8#define		n_GDC		 9#define		n_HAYES		10#define		n_PENRIL	11#define		n_RACAL		12#define		n_UNKNOWN	13#define		n_USROBOT	14#define		n_VENTEL	15#define		n_CONCORD	16#define		n_ATTUPC	17	/* aka UNIX PC and ATT7300 */#define		n_ROLM          18      /* Rolm CBX DCM */#define		n_MICROCOM	19#define         n_HST           20#define         n_TELEBIT       21      /* Telebits of all kinds */#define         n_DIGITEL       22	/* Digitel DT-22 (CCITT variant) */#define		MAX_MDM		22	/* Number of modem types */#endif /* MINIDIAL *//* * 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. *//*  Warning - this is starting to get kind of hokey... */#define DIAL_NV 256#define n_HAYESNV ( n_HAYES   | DIAL_NV )#ifndef MINIDIAL#define DIAL_PEP 512#define DIAL_V32 1024#define DIAL_V42 2048#define DIAL_SLO 4096#define n_TBPEP   ( n_TELEBIT | DIAL_PEP )#define n_TB3     ( n_TELEBIT | DIAL_V32 )#define n_TBNV    ( n_TELEBIT | DIAL_NV )#define n_TBPNV   ( n_TELEBIT | DIAL_NV | DIAL_PEP )#define n_TB3NV   ( n_TELEBIT | DIAL_NV | DIAL_V32 )#define n_TB4     ( n_TELEBIT | DIAL_V42 )#define n_TBS     ( n_TELEBIT | DIAL_SLO )#define n_TB4NV   ( n_TELEBIT | DIAL_NV | DIAL_V42 )#define n_TBSNV   ( n_TELEBIT | DIAL_NV | DIAL_SLO )#endif /* MINIDIAL *//* * Declare structures containing modem-specific information. * * REMEMBER that only the first SEVEN characters of these * names are guaranteed to be unique. */#ifndef MINIDIALstaticMDMINF ATTISN =				/* AT&T ISN Network */    {    30,					/* Dial time */    "",					/* Pause characters */    0,					/* Pause time */    "\015\015\015\015",			/* Wake string */    900,				/* Wake rate */    "DIAL",				/* Wake prompt */    "",					/* dmode_str */    "",					/* dmode_prompt */    "%s\015",				/* dial_str */    0,					/* dial_rate */    0,					/* esc_time */    "",					/* esc_str */    "",					/* hup_str */    NULL				/* ok_fn */    };staticMDMINF ATTMODEM =	/* information for AT&T switched-network modems */			/* "Number" following "dial" can include: p's and			 * t's to indicate pulse or tone (default) dialing,			 * + for wait for dial tone, , for pause, r for			 * last number dialed, and, except for 2224B, some			 * comma-delimited options like o12=y, before number. * "Important" options for the modems: * *	All:		Except for 2224B, enable option 12 for "transparent *			data," o12=y.  If a computer port used for both *			incoming and outgoing calls is connected to the *			modem, disable "enter interactive mode on carriage *			return," EICR.  The Kermit "dial" command can *			function with EIA leads standard, EIAS. * *	2212C:		Internal hardware switches at their default *			positions (four rockers down away from numbers) *			unless EICR is not wanted (rocker down at the 4). *			For EIAS, rocker down at the 1. * *	2224B:		Front-panel switch position 1 must be up (at the 1, *			closed).  Disable EICR with position 2 down. *			For EIAS, position 4 down. *			All switches on the back panel down. * *	2224CEO:	All front-panel switches down except either 5 or 6. *			Enable interactive flow control with o16=y. *			Select normal asynchronous mode with o34=0 (zero). *			Disable EICR with position 3 up.  For EIAS, 1 up. *			Reset the modem after changing switches. * *	2296A:		If option 00 (zeros) is present, use o00=0. *			Enable interactive flow control with o16=y. *			Select normal asynchronous mode with o34=0 (zero). *                      (available in Microcom Networking version, but *                      not necessarily other models of the 2296A). *			Enable modem-port flow control (if available) with * 			o42=y.  Enable asynchronous operation with o50=y. * 			Disable EICR with o69=n.  For EIAS, o66=n, using * 			front panel. */    {    20,			/* dial_time */    ",",		/* pause_chars */    2,			/* pause_time */    "+",		/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "at%s\015",		/* dial_str */    0,			/* dial_rate */    0,			/* esc_time */    "",			/* esc_str */    "",			/* hup_str */    NULL			/* ok_fn */    };staticMDMINF ATTDTDM =	/* information for AT&T Digital Terminal Data Module *			For dialing: KYBD switch down, others usually up. */    {    20,			/* dial_time */    "",			/* pause_chars */    0,			/* pause_time */    "",			/* wake_str */    0,			/* wake_rate */    "",			/* wake_prompt */    "",			/* dmode_str */    "",			/* dmode_prompt */    "%s\015",		/* dial_str */		/* not used */    0,			/* dial_rate */    0,			/* esc_time */    "",			/* esc_str */    "",			/* hup_str */    NULL		/* ok_fn */    };#endif /* MINIDIAL */staticMDMINF CCITT =				/* CCITT V.25bis autodialer *//*  According to V.25bis:  . Even parity is required for giving commands to the modem.  . Commands might or might not echo.  . Responses ("Indications") from the modem are terminated by CR and LF.  . Call setup is accomplished by:    - DTE raises DTR (V.24 circuit 108)              [ttopen() does this]    - Modem raises CTS (V.24 circuit 106)            [C-Kermit ignores this]    - DTE issues a call request command ("CRN")    - Modem responds with "VAL" ("command accepted")    - If the call is completed:        modem responds with "CNX" ("call connected");        modem turns CTS (106) OFF;        modem turns DSR (107) ON;      else:        modem responds with "CFI <parameter>" ("call failure indication").  . To clear a call, the DTE turns DTR (108) OFF.  . There is no mention of the Carrier Detect circuit (109) in the standard.  . There is no provision for "escaping back" to the modem's command mode.  It is not known whether there exists in real life a pure V.25bis modem.  If there is, this code has never been tested on it.  See the Digitel entry.*/    {    40,			/* dial_time -- programmable -- */    ",:",		/* pause_chars -- "," waits for programmable time */                        /* ":" waits for dial tone */    10,			/* pause_time (seconds, just a guess) */

⌨️ 快捷键说明

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