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

📄 ckuus6.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "ckcsym.h"#ifndef NOICP/*  C K U U S 6 --  "User Interface" for Unix Kermit (Part 6)  *//*  Author: Frank da Cruz (fdc@columbia.edu),  Columbia University Academic Information Systems, New York City.  Copyright (C) 1985, 2000,    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.*//* Includes */#include "ckcdeb.h"#include "ckcasc.h"#include "ckcker.h"#include "ckuusr.h"/* #include "ckcxla.h" */#include "ckcnet.h"			/* Network symbols */#include <signal.h>#ifdef VMS#ifndef TCPSOCKET#include <errno.h>#endif /* TCPSOCKET */#endif /* VMS */#ifdef datageneral#define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)#endif /* datageneral *//* External Kermit Variables, see ckmain.c for description. */extern xx_strp xxstring;extern int local, xitsta, binary, parity, escape, flow, cmd_rows, turn,  turnch, duplex, ckxech, seslog, dfloc, cnflg, tlevel, pflag, msgflg, mdmtyp,  zincnt, quiet, repars, techo, network, nzxopts;extern int xaskmore, tt_rows, tt_cols, cmd_cols, g_matchdot;#ifdef CK_IFRO  extern int remonly;#endif /* CK_IFRO */#ifdef OS2extern int StartedFromDialer ;extern int vmode;#ifndef NT#define INCL_NOPM#define INCL_VIO			/* Needed for ckocon.h */#include <os2.h>#undef COMMENT#else#define APIRET ULONG#include <windows.h>#include <tapi.h>#include "ckntap.h"#endif /* NT */#include "ckocon.h"#endif /* OS2 */extern long vernum, speed;extern char *versio, *protv, *ckxv, *ckzv, *fnsv, *connv, *dftty, *cmdv;extern char *dialv, *loginv, *for_def[], *whil_def[], *xif_def[], *sw_def[];extern char *ckxsys, *ckzsys;#ifndef OS2extern char *DIRCMD;#ifndef UNIXextern char *DELCMD;#endif /* UNIX */#endif /* OS2 */extern char ttname[], filnam[];extern CHAR sstate;extern char *zinptr;#ifndef NOXFERextern int oopts, omode, oname, opath;	/* O-Packet options */extern int stdinf, sndsrc, size, rpsiz, urpsiz, fncnv, fnrpath, displa,  stdouf, isguest, pktlog, nfils, keep, maxrps, fblksiz, frecl, frecfm,  atcapr, atdiso, spsizf, spsiz, spsizr, spmax, wslotr, prefixing,  fncact, fnspath, nprotos, g_proto, g_urpsiz, g_spsizf,  g_spsiz, g_spsizr, g_spmax, g_wslotr, g_prefixing, g_fncact, g_fncnv,  g_fnspath, g_fnrpath;extern char *cmarg, *cmarg2;#ifndef NOMSEND				/* Multiple SEND */extern char *msfiles[];#endif /* NOMSEND */extern char fspec[];			/* Most recent filespec */extern int fspeclen;#ifdef CK_TMPDIRextern int f_tmpdir;			/* Directory changed temporarily */extern char savdir[];			/* For saving current directory */extern char * dldir;#endif /* CK_TMPDIR */extern struct keytab protos[];	/* File transfer protocols */extern struct ck_p ptab[NPROTOS];#endif /* NOXFER *//* Declarations from cmd package */#ifdef DCMDBUFextern char *cmdbuf, *atmbuf;		/* Command buffers */#elseextern char cmdbuf[], atmbuf[];		/* Command buffers */#endif /* DCMDBUF */extern int nopush;#ifndef NOSPLint askflag = 0;			/* ASK-class command active */extern char **a_ptr[];extern int a_dim[];extern char **m_xarg[];extern int n_xarg[];extern struct mtab *mactab;extern int nmac;extern long ck_alarm;extern char alrm_date[], alrm_time[];extern int x_ifnum;#endif /* NOSPL */extern int inserver;			/* I am IKSD */extern int backgrd;			/* Kermit executing in background */extern char psave[];			/* For saving & restoring prompt */extern char *tp;			/* Temporary buffer */int saveask = -1;			/* For saving askmore() status */int readblock = 4096;			/* READ buffer size */CHAR * readbuf = NULL;			/* Pointer to read buffer */int readsize = 0;			/* Number of chars actually read */int getcmd = 0;				/* GET-class command was given */extern int zchkod, zchkid;struct keytab deltab[] = {		/* DELETE Command Options */    "/after",       DEL_AFT,  CM_ARG,    "/ask",         DEL_ASK,  0,    "/before",      DEL_BEF,  CM_ARG,    "/dotfiles",    DEL_DOT,  0,    "/except",      DEL_EXC,  CM_ARG,    "/heading",     DEL_HDG,  0,    "/l",           DEL_LIS,  CM_INV|CM_ABR,    "/larger-than", DEL_LAR,  CM_ARG,    "/list",        DEL_LIS,  0,    "/log",         DEL_LIS,  CM_INV,    "/noask",       DEL_NAS,  0,    "/nodotfiles",  DEL_NOD,  0,    "/noheading",   DEL_NOH,  0,    "/nol",         DEL_NOL,  CM_INV|CM_ABR,    "/nolist",      DEL_NOL,  0,    "/nolog",       DEL_NOL,  CM_INV,#ifndef CK_TTGWSIZ    "/nopage",      DEL_NOP,  0,#endif /* CK_TTGWSIZ */    "/not-after",   DEL_NAF,  CM_ARG,    "/not-before",  DEL_NBF,  CM_ARG,    "/not-since",   DEL_NAF,  CM_INV|CM_ARG,#ifndef CK_TTGWSIZ    "/page",        DEL_PAG,  0,#endif /* CK_TTGWSIZ */    "/quiet",       DEL_QUI,  CM_INV,    "/simulate",    DEL_SIM,  0,    "/since",       DEL_AFT,  CM_ARG|CM_INV,    "/smaller-than",DEL_SMA,  CM_ARG,    "/verbose",     DEL_VRB,  CM_INV};int ndeltab = sizeof(deltab)/sizeof(struct keytab);/* /QUIET-/VERBOSE (/LIST-/NOLIST) (/LOG-/NOLOG) table */struct keytab qvswtab[] = {    "/l",           DEL_LIS,  CM_INV|CM_ABR,    "/list",        DEL_LIS,  0,    "/log",         DEL_LIS,  CM_INV,    "/nol",         DEL_NOL,  CM_INV|CM_ABR,    "/nolist",      DEL_NOL,  0,    "/nolog",       DEL_NOL,  CM_INV,    "/quiet",       DEL_QUI,  CM_INV,    "/verbose",     DEL_VRB,  CM_INV};int nqvswtab = sizeof(qvswtab)/sizeof(struct keytab);struct keytab copytab[] = {    "/append",      998,      0,#ifndef NOSPL    "/fromb64",     997,      0,#endif /* NOSPL */    "/l",           DEL_LIS,  CM_INV|CM_ABR,    "/list",        DEL_LIS,  0,    "/log",         DEL_LIS,  CM_INV,    "/nol",         DEL_NOL,  CM_INV|CM_ABR,    "/nolist",      DEL_NOL,  0,    "/nolog",       DEL_NOL,  CM_INV,    "/quiet",       DEL_QUI,  CM_INV,    "/swap-bytes",  999,      0,#ifndef NOSPL    "/tob64",       996,      0,#endif /* NOSPL */    "/verbose",     DEL_VRB,  CM_INV};int ncopytab = sizeof(copytab)/sizeof(struct keytab);#ifndef NOXFERstatic struct keytab gettab[] = {	/* GET options */    "/as-name",         SND_ASN, CM_ARG,    "/binary",          SND_BIN, 0,#ifdef CALIBRATE    "/calibrate",       SND_CAL, CM_INV,#endif /* CALIBRATE */#ifdef PIPESEND    "/command",         SND_CMD, 0,#endif /* PIPESEND */    "/delete",          SND_DEL, 0,    "/except",          SND_EXC, CM_ARG,    "/filenames",       SND_NAM, CM_ARG,#ifdef PIPESEND    "/filter",          SND_FLT, CM_ARG,#endif /* PIPESEND */#ifdef VMS    "/image",           SND_IMG, 0,    "/labeled",         SND_LBL, 0,#else    "/image",           SND_BIN, CM_INV,#endif /* VMS */#ifdef CK_TMPDIR    "/move-to",         SND_MOV, CM_ARG,#endif /* CK_TMPDIR */    "/pathnames",       SND_PTH, CM_ARG,    "/quiet",           SND_SHH, 0,#ifdef CK_RESEND    "/recover",         SND_RES, 0,#endif /* CK_RESEND */    "/recursive",       SND_REC, 0,    "/rename-to",       SND_REN, CM_ARG,#ifdef COMMENT    "/smaller-than",    SND_SMA, CM_ARG,    "/subdirectories",  SND_REC, CM_INV,#endif /* COMMENT */    "/text",            SND_TXT, 0};#define NGETTAB sizeof(gettab)/sizeof(struct keytab)static int ngettab = NGETTAB;static struct keytab rcvtab[] = {	/* RECEIVE options */    "/as-name",         SND_ASN, CM_ARG,    "/binary",          SND_BIN, 0,#ifdef CALIBRATE    "/calibrate",       SND_CAL, CM_INV,#endif /* CALIBRATE */#ifdef PIPESEND    "/command",         SND_CMD, 0,#endif /* PIPESEND */    "/except",          SND_EXC, CM_ARG,    "/filenames",       SND_NAM, CM_ARG,#ifdef PIPESEND    "/filter",          SND_FLT, CM_ARG,#endif /* PIPESEND */#ifdef VMS    "/image",           SND_IMG, 0,    "/labeled",         SND_LBL, 0,#else    "/image",           SND_BIN, CM_INV,#endif /* VMS */#ifdef CK_TMPDIR    "/move-to",         SND_MOV, CM_ARG,#endif /* CK_TMPDIR */    "/pathnames",       SND_PTH, CM_ARG,#ifdef CK_XYZ    "/protocol",        SND_PRO, CM_ARG,#else    "/protocol",        SND_PRO, CM_ARG|CM_INV,#endif /* CK_XYZ */    "/quiet",           SND_SHH, 0,    "/recursive",       SND_REC, 0,    "/rename-to",       SND_REN, CM_ARG,    "/text",            SND_TXT, 0};#define NRCVTAB sizeof(rcvtab)/sizeof(struct keytab)static int nrcvtab = NRCVTAB;#endif /* NOXFER *//* WAIT table */#define WAIT_FIL 997#define WAIT_MDM 998struct keytab waittab[] = {    "cd",            BM_DCD,   CM_INV,	/* (Carrier Detect) */    "cts",           BM_CTS,   CM_INV,	/* (Clear To Send)  */    "dsr",           BM_DSR,   CM_INV,	/* (Data Set Ready) */    "file",          WAIT_FIL, 0,	/* New category selector keywords */    "modem-signals", WAIT_MDM, 0,	/* ... */    "ri",            BM_RNG,   CM_INV	/* (Ring Indicator) */};int nwaittab = (sizeof(waittab) / sizeof(struct keytab));/* Modem signal table */struct keytab mstab[] = {#ifdef COMMENT/* The forms preceded by backslash are for MS-DOS Kermit compatibility. *//* But... \dsr doesn't work because \d = decimal constant introducer. *//* Anyway MS-DOS Kermit 3.14 and later accept the keywords without the *//* backslash. */    "\\cd",  BM_DCD, CM_INV,		/* Carrier Detect */    "\\cts", BM_CTS, CM_INV,		/* Clear To Send  */    "\\dsr", BM_DSR, CM_INV,		/* Data Set Ready */    "\\ri",  BM_RNG, CM_INV,		/* Ring Indicator */#endif /* COMMENT */    "cd",    BM_DCD, 0,			/* Carrier Detect */    "cts",   BM_CTS, 0,			/* Clear To Send  */    "dsr",   BM_DSR, 0,			/* Data Set Ready */    "ri",    BM_RNG, 0			/* Ring Indicator */};int nms = (sizeof(mstab) / sizeof(struct keytab));#define WF_MOD 1#define WF_DEL 2#define WF_CRE 3struct keytab wfswi[] = {		/* WAIT FILE switches */    "creation",     WF_CRE, 0,		/* Wait for file to be created */    "deletion",     WF_DEL, 0,		/* Wait for file to be deleted */    "modification", WF_MOD, 0		/* Wait for file to be modified */};int nwfswi = (sizeof(wfswi) / sizeof(struct keytab));#ifndef NOSPLstruct keytab asgtab[] = {		/* Assignment operators for "." */    "=",   0, 0,			/* DEFINE */    ":=",  1, 0,			/* ASSIGN */    "::=", 2, 0				/* ASSIGN and EVALUATE */};int nasgtab = (sizeof(asgtab) / sizeof(struct keytab));struct keytab opntab[] = {#ifndef NOPUSH    "!read",  OPN_PI_R, CM_INV,    "!write", OPN_PI_W, CM_INV,#endif /* NOPUSH */    "append", OPN_FI_A, 0,    "host",   OPN_NET,  0,#ifdef OS2    "line",   OPN_SER,  CM_INV,    "port",   OPN_SER,  0,#else    "line",   OPN_SER,  0,    "port",   OPN_SER,  CM_INV,#endif /* OS2 */    "read",   OPN_FI_R, 0,    "write",  OPN_FI_W, 0};int nopn = (sizeof(opntab) / sizeof(struct keytab));struct keytab iftab[] = {		/* IF commands */    "!",          XXIFNO, 0,    "!=",         XXIFNQ, 0,    "&&",         XXIFAN, 0,    "(",          XXIFLP, 0,    ")",          XXIFRP, 0,    "<",          XXIFLT, 0,    "<=",         XXIFLE, 0,    "=",          XXIFAE, 0,    "==",         XXIFAE, CM_INV,    ">",          XXIFGT, 0,    ">=",         XXIFGE, 0,    "||",         XXIFOR, 0,    "and",        XXIFAN, 0,    "asktimeout", XXIFAT, 0,    "absolute",   XXIFAB, 0,    "alarm",      XXIFAL, 0,    "available",  XXIFAV, 0,    "background", XXIFBG, 0,    "c-kermit",   XXIFCK, 0,    "command",    XXIFCM, 0,    "count",      XXIFCO, 0,    "defined",    XXIFDE, 0,#ifdef CK_TMPDIR    "directory",  XXIFDI, 0,#endif /* CK_TMPDIR */    "emulation",  XXIFEM, 0,#ifdef COMMENT    "eof",        XXIFEO, 0,#endif /* COMMENT */    "equal",      XXIFEQ, 0,    "error",      XXIFFA, CM_INV,    "exist",      XXIFEX, 0,    "failure",    XXIFFA, 0,    "false",      XXIFNT, 0,    "flag",       XXIFFL, 0,#ifdef CKFLOAT    "float",      XXIFFP, 0,#endif /* CKFLOAT */    "foreground", XXIFFG, 0,#ifdef IKSD    "iksd",       XXIFIK, 0,#else    "iksd",       XXIFIK, CM_INV,#endif /* IKSD */    "k-95",       XXIFK9, 0,    "lgt",        XXIFLG, 0,    "llt",        XXIFLL, 0,    "local",      XXIFLO, 0,    "match",      XXIFMA, 0,    "ms-kermit",  XXIFMS, CM_INV,#ifdef ZFCDAT    "newer",      XXIFNE, 0,#endif /* ZFCDAT */    "not",        XXIFNO, 0,    "numeric",    XXIFNU, 0,    "ok",         XXIFSU, CM_INV,    "open",       XXIFOP, 0,    "or",         XXIFOR, 0,    "quiet",      XXIFQU, 0,    "readable",   XXIFRD, 0,    "remote-only",XXIFRO, 0,    "started-from-dialer",XXIFSD, CM_INV,    "success",    XXIFSU, 0,    "tapi",       XXIFTA, 0,#ifdef OS2    "terminal-macro", XXIFTM, CM_INV,#endif /* OS2 */    "true",       XXIFTR, 0,    "wild",       XXIFWI, 0,    "writeable",  XXIFWR, 0,    "", 0, 0};int nif = (sizeof(iftab) / sizeof(struct keytab)) - 1;struct keytab iotab[] = {		/* Keywords for IF OPEN */    "!read-file",      ZRFILE, CM_INV,    "!write-file",     ZWFILE, CM_INV,    "append-file",     ZWFILE, CM_INV,    "connection",      8888,   0,#ifdef CKLOGDIAL    "cx-log",          7777,   0,#endif /* CKLOGDIAL */    "debug-log",       ZDFILE, 0,    "error",           9999,   0,    "packet-log",      ZPFILE, 0,    "read-file",       ZRFILE, 0,    "screen",          ZSTDIO, 0,    "session-log",     ZSFILE, 0,    "transaction-log", ZTFILE, 0,    "write-file",      ZWFILE, 0};int niot = (sizeof(iotab) / sizeof(struct keytab));#endif /* NOSPL *//* Variables and prototypes */#ifdef NETCONNextern int nnetdir;			/* How many network directories */

⌨️ 快捷键说明

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