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

📄 ckudia.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "ckcsym.h"#ifndef NOLOCAL#ifndef NODIAL#ifndef NOICPchar *dialv = "Dial Command, 6.0.091, 6 Sep 96";#ifndef NOOLDMODEMS        /* Unless instructed otherwise, */#define OLDMODEMS          /* keep support for old modems. */#endif /* NOOLDMODEMS */#ifndef M_OLD		   /* Hide old modem keywords in SET MODEM table. */#define M_OLD 0            /* Define as to CM_INV to make them invisible. */#endif /* M_OLD */ /*  C K U D I A	 --  Module for automatic modem dialing. *//*  Copyright (C) 1985, 1996, Trustees of Columbia University in the City of New  York.  The C-Kermit software may not be, in whole or in part, licensed or  sold for profit as a software product itself, nor may it be included in or  distributed with commercial products or otherwise distributed by commercial  concerns to their clients or customers without written permission of the  Office of Kermit Development and Distribution, Columbia University.  This  copyright notice must not be removed, altered, or obscured.*//*  Authors:  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: Jeffrey  Altman, Mark Berryman, 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).*//*  Entry points:    ckdial(char * number)   Dial a number or answer a call    dialhup()               Hang up a dialed connection    mdmhup()                Use modem commands to hang up  All other routines are static.  Don't call dialhup() or mdmhup() without first calling ckdial().*//*  This module calls externally defined system-dependent functions for  communications i/o, as described 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, the next highest one.  2. Adjust MAX_MDM to the new number of modem types.  3. Create a MDMINF structure for it.  NOTE: The wake_str should include     all invariant setup info, e.g. enable result codes, BREAK transparency,     modulation negotiation, etc.  See ckcker.h for MDMINF struct definition.  4. Add the address of the MDMINF structure to the modemp[] 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 any modem-specific sections as necessary.     For most modern Hayes-compatible modems, no specific code will be     needed.  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"#include "ckuusr.h"#ifdef OS2ONLY#define INCL_VIO			/* Needed for ckocon.h */#include <os2.h>#include "ckocon.h"#endif /* OS2ONLY */#ifdef NT#include "cknwin.h"#endif /* NT */#ifdef OS2#include "ckowin.h"#endif /* OS2 */#ifndef ZILOG#ifdef NT#include <setjmpex.h>#else /* NT */#include <setjmp.h>#endif /* NT */#else#include <setret.h>#endif /* ZILOG */#include "ckcsig.h"        /* C-Kermit signal processing */#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 */#ifdef AMIGA#define signal asignal#define alarm aalarm#define SIGALRM (_NUMSIG+1)#define SIGTYP voidSIGTYP (*asignal(int type, SIGTYP (*func)(int)))(int);unsigned aalarm(unsigned);#endif /* AMIGA */#ifdef STRATUS/*  VOS doesn't have alarm(), but it does have some things we can work with.  However, we have to catch all the signals in one place to do this, so  we intercept the signal() routine and call it from our own replacement.*/#define signal vsignal#define alarm valarmSIGTYP (*vsignal(int type, SIGTYP (*func)(int)))(int);int valarm(int interval);#ifdef putchar#undef putchar#endif /* putchar */#define putchar(x) conoc(x)#ifdef getchar#undef getchar#endif /* getchar */#define getchar(x) coninc(0)#endif /* STRATUS */#ifdef OS2#ifdef putchar#undef putchar#endif /* putchar */#define putchar(x) conoc(x)#endif /* OS2 */#ifdef BIGBUFOK /* Only for verions that are not tight on memory */char * dialmsg[] = {			/* DIAL status strings */    /* Keyed to numbers defined in ckcker.h -- keep in sync! */    "DIAL succeeded",			    /*  0 */    "Modem type not specified",		    /*  1 */    "Communication device not specified",   /*  2 */    "Communication device can't be opened", /*  3 */    "Speed not specified",		    /*  4 */    "Pre-DIAL hangup failed",		    /*  5 */    "Internal error",			    /*  6 */    "Device input/output error",	    /*  7 */    "DIAL TIMEOUT expired",		    /*  8 */    "Interrupted by user",		    /*  9 */    "Modem not ready",			    /* 10 */    "Partial dial OK",			    /* 11 */    "Dial directory lookup error",	    /* 12 */    NULL,				    /* 13 */    NULL,				    /* 14 */    NULL,				    /* 15 */    NULL,				    /* 16 */    NULL,				    /* 17 */    NULL,				    /* 18 */    NULL,				    /* 19 */    "Modem command error",		    /* 20 */    "Failure to initialize modem",	    /* 21 */    "Phone busy",			    /* 22 */    "No carrier",			    /* 23 */    "No dialtone",			    /* 24 */    "Incoming call",			    /* 25 */    "No answer",			    /* 26 */    "Disconnected",			    /* 27 */    "Answered by voice",		    /* 28 */    "Access denied / forbidden call",	    /* 29 */    "Blacklisted",			    /* 30 */    "Delayed",    			    /* 31 */    "Fax connection",			    /* 32 */    NULL				    /* 33 */};#endif /* BIGBUFOK */#ifndef NOSPLchar modemmsg[80];			/* DIAL response from modem */#endif /* NOSPL */#ifdef NTSIGextern int TlsIndex;#endif /* NTSIG */int					/* SET DIAL parameters */  dialhng = 1,				/* DIAL HANGUP, default is ON */  dialdpy = 0,				/* DIAL DISPLAY, default is OFF */  mdmspd  = 0,				/* DIAL SPEED-MATCHING (0 = OFF) */  dialtmo = 0,				/* DIAL TIMEOUT */  dialatmo = -1,			/* ANSWER TIMEOUT */  dialksp = 0,				/* DIAL KERMIT-SPOOF, 0 = OFF */#ifdef NOMDMHUP  dialmhu = 0;				/* DIAL MODEM-HANGUP, 0 = OFF */#else  dialmhu = 1;				/* DIAL MODEM-HANGUP */#endif /* NOMDMHUP */int  dialec = 0,				/* DIAL ERROR-CORRECTION */  dialdc = 0,				/* DIAL COMPRESSION  */  dialfc = FLO_AUTO,			/* DIAL FLOW-CONTROL */  dialmth = XYDM_D,			/* DIAL METHOD */  dialesc = 0;				/* DIAL ESCAPE */int telephony = 0;			/* Command-line '-T' option */long dialmax = 0L,			/* Modem's max interface speed */  dialcapas  = 0L;			/* Modem's capabilities */int dialsta = DIA_UNK;			/* Detailed return code (ckuusr.h) */int is_rockwell = 0;int is_hayeshispd = 0;char *dialdir[MAXDDIR];			/* DIAL DIRECTORY filename array */int   ndialdir = 0;			/* How many dial directories */char *dialini = NULL;			/* DIAL INIT-STRING, default none */char *dialmstr = NULL;			/* DIAL MODE-STRING, default none */char *dialmprmt = NULL;			/* DIAL MODE-PROMPT, default none */char *dialcmd = NULL;			/* DIAL DIAL-COMMAND, default none */char *dialnpr = NULL;			/* DIAL PREFIX, ditto */char *diallac = NULL;			/* DIAL LOCAL-AREA-CODE, ditto */char *diallcc = NULL;			/* DIAL LOCAL-COUNTRY-CODE, ditto */char *dialixp = NULL;			/* DIAL INTL-PREFIX */char *dialixs = NULL;			/* DIAL INTL-SUFFIX */char *dialldp = NULL;			/* DIAL LD-PREFIX */char *diallds = NULL;			/* DIAL LD-SUFFIX */char *dialpxx = NULL;			/* DIAL PBX-EXCHANGE */char *dialpxi = NULL;			/* DIAL INTERNAL-PREFIX */char *dialpxo = NULL;			/* DIAL OUTSIDE-PREFIX */char *dialsfx = NULL;			/* DIAL SUFFIX */char *dialtfp = NULL;			/* DIAL TOLL-FREE-PREFIX */extern char * d_name;extern char * dialtfc[];extern int ntollfree;char *dialname  = NULL;			/* Descriptive name for modem */char *dialdcon  = NULL;			/* DC ON command */char *dialdcoff = NULL;			/* DC OFF command */char *dialecon  = NULL;			/* EC ON command */char *dialecoff = NULL;			/* EC OFF command */char *dialaaon  = NULL;			/* Autoanswer ON command */char *dialaaoff = NULL;			/* Autoanswer OFF command */char *dialhcmd  = NULL;			/* Hangup command */char *dialhwfc  = NULL;			/* Hardware flow control command */char *dialswfc  = NULL;			/* (Local) software f.c. command */char *dialnofc  = NULL;			/* No (Local) flow control command */char *dialtone  = NULL;			/* Command to force tone dialing */char *dialpulse = NULL;			/*  ..to force pulse dialing */char *mdmname   = NULL;#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  970                          Qblazer Plus  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, mdmsav;#ifdef NETCONNextern int ttnproto;#endif /* NETCONN */extern CHAR stchr;extern long speed;extern char ttname[], sesfil[];/*  Failure codes  */#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#ifdef OS2 volatile#endif /* OS2 */ int fail_code =  0;			/* Default failure reason. */static int func_code;			/* 0 = dialing, nonzero = answering */static int partial;static int mymdmtyp = 0;#define DW_NOTHING      0		/* What we are doing */#define DW_INIT         1#define DW_DIAL         2static int dial_what = DW_NOTHING;	/* Nothing at first. */static int nonverbal = 0;		/* Hayes in numeric response mode */static MDMINF * mp;static CHAR escbuf[6];static long mdmcapas;_PROTOTYP (static VOID dreset, (void) );_PROTOTYP (static int (*xx_ok), (int,int) );_PROTOTYP (static int ddinc, (int) );_PROTOTYP (int dialhup, (void) );_PROTOTYP (static int getok, (int,int) );_PROTOTYP (char * ck_time, (void) );_PROTOTYP (static VOID ttslow, (char *, int) );#ifdef COMMENT_PROTOTYP (static VOID xcpy, (char *, char *, unsigned int) );#endif /* COMMENT */_PROTOTYP (static VOID waitfor, (char *) );_PROTOTYP (static VOID dialoc, (char) );_PROTOTYP (static int didweget, (char *, char *) );_PROTOTYP (static VOID spdchg, (long) );#ifndef MINIDIAL#ifdef OLDTBCODE_PROTOTYP (static VOID tbati3, (int) );#endif /* OLDTBCODE */#endif /* MINIDIAL */_PROTOTYP (static int dialfail, (int) );_PROTOTYP (static VOID gethrw, (void) );_PROTOTYP (static VOID gethrn, (void) );/* * Define symbolic modem numbers. * * The numbers MUST correspond to the ordering of entries * within the modemp 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	/* CCITT/ITU-T V.25bis */#define		n_HAYES		 2	/* Hayes 2400 */#define		n_UNKNOWN	 3	/* Unknown */#define         n_UDEF           4	/* User-Defined */

⌨️ 快捷键说明

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