📄 ckudia.c
字号:
#include "ckcsym.h"char *dialv = "Dial Command, 8.0.160, 29 Apr 2002";/* C K U D I A -- Module for automatic modem dialing. *//* Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New York. All rights reserved. See the C-Kermit COPYING.TXT file or the copyright text in the ckcmai.c module for disclaimer and permissions.*//* 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 many others.*//* 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. HOW TO ADD SUPPORT FOR ANOTHER MODEM: 1. In ckuusr.h, define a modem-type number symbol (n_XXX) for the new modem, the next highest one. 2. In ckuusr.h, adjust MAX_MDM to the new number of modem types.The remaining steps are in this module: 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. If this falls into a class like is_rockwell, is_supra, etc, add the new one to the definition of the class. 7. Adjust the gethrn() routine to account for any special numeric result codes (if it's a Hayes compatible modem). 8. 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 1200 and 2400, ITU-T (CCITT) V.25bis and V.25ter (V.250), Generic-High-Speed, "Unknown", and None. When adding support for a new modem type, keep it outside of the MINIDIAL sections unless it deserves to be in it.*/#include "ckcdeb.h"#ifndef NOLOCAL#ifndef NODIAL#ifndef NOICP#ifndef CK_ATDT#define CK_ATDT#endif /* CK_ATDT */#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 CM_INV to make them invisible. */#endif /* M_OLD */#ifndef M_ALIAS#define M_ALIAS 64#endif /* M_ALIAS */#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>#undef COMMENT#include "ckocon.h"#endif /* OS2ONLY */#ifdef NT#include <windows.h>#include <tapi.h>#include "cknwin.h"#include "ckntap.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 */#ifndef NOHINTSextern int hints;#endif /* NOHINTS */#ifdef CK_TAPIextern int tttapi;extern int tapipass;#endif /* CK_TAPI */#ifdef CKLOGDIALextern int dialog;#endif /* CKLOGDIAL */char * dialmsg[] = { /* DIAL status strings */ /* Keyed to numbers defined in ckcker.h -- keep in sync! */ "DIAL succeeded", /* 0 DIA_OK */ "Modem type not specified", /* 1 DIA_NOMO */ "Communication device not specified", /* 2 DIA_NOLI */ "Communication device can't be opened", /* 3 DIA_OPEN */ "Speed not specified", /* 4 DIA_NOSP */ "Pre-DIAL hangup failed", /* 5 DIA_HANG */ "Internal error", /* 6 DIA_IE */ "Device input/output error", /* 7 DIA_IO */ "DIAL TIMEOUT expired", /* 8 DIA_TIMO */ "Interrupted by user", /* 9 DIA_INTR */ "Modem not ready", /* 10 DIA_NRDY */ "Partial dial OK", /* 11 DIA_PART */ "Dial directory lookup error", /* 12 DIA_DIR */ "Hangup OK", /* 13 DIA_HUP */ NULL, /* 14 (undef) */ NULL, /* 15 (undef) */ NULL, /* 16 (undef) */ NULL, /* 17 (undef) */ NULL, /* 18 (undef) */ "No response from modem", /* 19 DIA_NRSP */ "Modem command error", /* 20 DIA_ERR */ "Failure to initialize modem", /* 21 DIA_NOIN */ "Phone busy", /* 22 DIA_BUSY */ "No carrier", /* 23 DIA_NOCA */ "No dialtone", /* 24 DIA_NODT */ "Incoming call", /* 25 DIA_RING */ "No answer", /* 26 DIA_NOAN */ "Disconnected", /* 27 DIA_DISC */ "Answered by voice", /* 28 DIA_VOIC */ "Access denied / forbidden call", /* 29 DIA_NOAC */ "Blacklisted", /* 30 DIA_BLCK */ "Delayed", /* 31 DIA_DELA */ "Fax connection", /* 32 DIA_FAX */ "Digital line", /* 33 DIA_DIGI */ "TAPI dialing failure", /* 34 DIA_TAPI */ NULL /* 34 */};#ifdef COMMENT#ifdef NOSPLstatic#endif /* NOSPL */char modemmsg[128] = { NUL, NUL }; /* DIAL response from modem */#endif /* COMMENT */#ifdef NTSIGextern int TlsIndex;#endif /* NTSIG */int mdmtyp = n_GENERIC; /* Default modem type */int mdmset = 0; /* User explicitly set a modem type */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) */ mdmspk = 1, /* MODEM SPEAKER */ mdmvol = 2, /* MODEM VOLUME */ dialtmo = 0, /* DIAL TIMEOUT */ dialatmo = -1, /* ANSWER TIMEOUT */ dialksp = 0, /* DIAL KERMIT-SPOOF, 0 = OFF */ dialidt = 0, /* DIAL IGNORE-DIALTONE */#ifndef CK_RTSCTS /* If we can't do RTS/CTS then there's no flow control at first. */ /* So we might easily lose the echo to the init string and the OK */ /* and then give "No response from modem" errors. */ dialpace = 150, /* DIAL PACING */#else dialpace = -1,#endif /* CK_RTSCTS */ /* 0 = RS232 (drop DTR); 1 = MODEM-COMMAND (e.g. <sec>+++<sec>ATH0) */ dialmhu = DEFMDMHUP; /* MODEM HANGUP-METHOD */int dialec = 1, /* DIAL ERROR-CORRECTION */ dialdc = 1, /* DIAL COMPRESSION */#ifdef VMS /* VMS can only use Xon/Xoff */ dialfc = FLO_XONX, /* DIAL FLOW-CONTROL */#else dialfc = FLO_AUTO,#endif /* VMS */ dialmth = XYDM_D, /* DIAL METHOD (Tone, Pulse, Defalt) */ dialmauto = 1, /* DIAL METHOD is AUTO */ 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) */#ifdef COMMENTint ans_cid = 0; /* SET ANSWER parameters */int ans_rings = 0; /* (not used yet...) */#endif /* COMMENT */int is_rockwell = 0;int is_motorola = 0;int is_supra = 0;int is_hayeshispd = 0;/* Dialing directory list */char *dialdir[MAXDDIR]; /* DIAL DIRECTORY filename array */int ndialdir = 0; /* How many dial directories *//* User overrides for built-in modem commands */char *dialini = NULL; /* MODEM INIT-STRING none */char *dialmstr = NULL; /* MODEM DIALMODE-STRING */char *dialmprmt = NULL; /* MODEM DIALMODE-PROMPT */char *dialcmd = NULL; /* MODEM DIAL-COMMAND, default none */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 *dialx3 = NULL; /* Ignore dialtone */char *mdmname = NULL;char *dialspon = NULL; /* Speaker On command */char *dialspoff = NULL; /* Speaker Off command */char *dialvol1 = NULL; /* Volume Low command */char *dialvol2 = NULL; /* Volume Medium command */char *dialvol3 = NULL; /* Volume High command */char *dialini2 = NULL; /* Second init string *//* Phone number options */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 *diallcp = NULL; /* DIAL LOCAL-PREFIX */char *diallcs = NULL; /* DIAL LOCAL-SUFFIX */char *dialpxi = NULL; /* DIAL PBX-INTERNAL-PREFIX */char *dialpxo = NULL; /* DIAL PBX-OUTSIDE-PREFIX */char *dialsfx = NULL; /* DIAL SUFFIX */char *dialtfp = NULL; /* DIAL TOLL-FREE-PREFIX */char *callid_date = NULL; /* Caller ID strings */char *callid_time = NULL;char *callid_name = NULL;char *callid_nmbr = NULL;char *callid_mesg = NULL;extern char * d_name;extern char * dialtfc[]; /* DIAL TOLL-FREE-AREA-CODE */extern char * dialpxx[]; /* DIAL PBX-EXCHANGE */extern int ntollfree;extern int ndialpxx;extern char * dialpucc[]; /* DIAL Pulse countries */extern int ndialpucc;extern char * dialtocc[]; /* DIAL Tone countries */extern int ndialtocc;char *dialmac = NULL; /* DIAL macro *//* Countries where pulse dialing must be used (tone is not available) */static char * pulsecc[] = { NULL }; /* (Unknown at present) *//* Countries where tone dialing may safely be the default. *//* "+" marks countries where pulse is also allowed. *//* Both Pulse and Tone are allowed in Austria & Switzerland but it is not *//* yet known if Tone is universally in those countries. */static char * tonecc[] = { "1", /* + North American Numbering Plan */ "31", /* Netherlands */ "32", /* Belgium */ "33", /* France */ "352", /* Luxembourg */ "353", /* Ireland */ "354", /* Iceland */ "358", /* Finland */ "39", /* Italy */ "44", /* + UK */ "45", /* Denmark */ "46", /* Sweden */ "47", /* Norway */ "49", /* + Germany */ 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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -