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

📄 ckuusr.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "ckcsym.h"char *userv = "User Interface 6.0.177, 6 Sep 96";/*  C K U U S R --  "User Interface" for C-Kermit (Part 1)  *//*  Author: Frank da Cruz <fdc@columbia.edu>  Columbia University Academic Information Systems, New York City.  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.*//*  NOTE: Because of the massive additions in functionality, and therefore  the increase in the number of commands, much code was moved from here to  the two new modules, ckuus4.c and ckuus5.c.  This module now contains only  the top-level command keyword table, the SET command keyword table, and  the top-level interactive command parser/dispatcher.  ckuus3.c contains the  rest of the SET and REMOTE command parsers; ckuus2.c contains the help  command parser and help text strings, and ckuus4.c and ckuus5.c contain  miscellaneous pieces that logically belong in the ckuusr.c file but had to  be moved because of size problems with some C compilers / linkers.  Later...  as the other modules became too large, a ckuus6.c was created.  Still later...  ckuus7.c.  Also: ckuusy.c contains the UNIX-style command-line interface;  ckuusx.c contains routines needed by both the command-line interface and  the interactive command parser.*//* The ckuus*.c modules depend on the existence of C library features like fopen, fgets, feof, (f)printf, argv/argc, etc.  Other functions that are likely to vary among Unix implementations -- like setting terminal modes or interrupts -- are invoked via calls to functions that are defined in the system- dependent modules, ck?[ft]io.c.  The command line parser processes any arguments found on the command line, as passed to main() via argv/argc.  The interactive parser uses the facilities of the cmd package (developed for this program, but usable by any program).  Any command parser may be substituted for this one.  The only requirements for the Kermit command parser are these:1. Set parameters via global variables like duplex, speed, ttname, etc.  See   ckmain.c for the declarations and descriptions of these variables.2. If a command can be executed without the use of Kermit protocol, then   execute the command directly and set the variable sstate to 0. Examples   include 'set' commands, local directory listings, the 'connect' command.3. If a command requires the Kermit protocol, set the following variables:    sstate                             string data      'x' (enter server mode)            (none)      'r' (send a 'get' command)         cmarg, cmarg2      'v' (enter receive mode)           cmarg2      'g' (send a generic command)       cmarg      's' (send files)                   nfils, cmarg & cmarg2 OR cmlist      'c' (send a remote host command)   cmarg    cmlist is an array of pointers to strings.    cmarg, cmarg2 are pointers to strings.    nfils is an integer.    cmarg can be a filename string (possibly wild), or       a pointer to a prefabricated generic command string, or       a pointer to a host command string.    cmarg2 is the name to send a single file under, or       the name under which to store an incoming file; must not be wild.       If it's the name for receiving, a null value means to store the       file under the name it arrives with.    cmlist is a list of nonwild filenames, such as passed via argv.    nfils is an integer, interpreted as follows:      -1: filespec (possibly wild) in cmarg, must be expanded internally.       0: send from stdin (standard input).      >0: number of files to send, from cmlist. The screen() function is used to update the screen during file transfer. The tlog() function writes to a transaction log. The debug() function writes to a debugging log. The intmsg() and chkint() functions provide the user i/o for interrupting   file transfers.*/#ifndef NOICP/* Includes */#include "ckcdeb.h"#include "ckcasc.h"#include "ckcker.h"#include "ckuusr.h"#include "ckcxla.h"#include "ckcnet.h"			/* Network symbols */#ifdef OS2#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 "cknwin.h"#include "ckntap.h"			/* CK_TAPI definition */#endif /* NT */#include "ckowin.h"#include "ckocon.h"extern int tcp_avail;extern bool viewonly;extern tt_status;#endif /* OS2 */#ifdef datageneral#include <packets:common.h>#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 long xvernum;extern char *ck_ver;extern int size, local, sndsrc, xitsta, server, displa, binary, msgflg,  escape, duplex, nfils, quiet, tlevel, pflag, zincnt, atcapr, atdiso, verwho,  ckxech, carrier, deblog, sendmode, epktflg, what, moving, protocol;extern int bye_active;extern long sendstart;#ifdef CK_TTYFDextern int ttyfd;#endif /* CK_TTYFD */extern long vernum;extern char *versio, *copyright[];extern char *ckxsys, *cmarg, *cmarg2, **cmlist;#ifndef NOHELPextern char *introtxt[];extern char *newstxt[];#endif /* NOHELP */extern char *PWDCMD, *WHOCMD, *TYPCMD;extern char ttname[];#ifndef NOFRILLSextern int rmailf;			/* MAIL command items */extern char optbuf[];#endif /* NOFRILLS */extern CHAR sstate;#ifdef NETCONNextern int network,			/* Have active network connection */  nettype,  				/* Type of network */  ttnproto;				/* Network Protocol */#endif /* NETCONN */#ifndef NODIALextern int dialsta, dialatmo, dialcon, dialcq; /* DIAL status, etc. */#endif /* NODIAL */#ifdef CK_APCextern int apcactive, apcstatus;#endif /* CK_APC */#ifndef NOMSEND				/* Multiple SEND */extern char *msfiles[];int filesinlist = 0;			/* And ADD ... */extern struct filelist * filehead;extern struct filelist * filetail;extern struct filelist * filenext;extern int addlist;static struct keytab addtab[] = {    "send-list", 0, 0};static int naddtab = sizeof(addtab)/sizeof(struct keytab);#endif /* NOMSEND */extern char fspec[];			/* Most recent filespec */#ifndef NOCSETSextern int nfilc;extern struct keytab fcstab[];#endif /* NOCSETS */#ifdef CK_TMPDIRint f_tmpdir = 0;			/* Directory changed temporarily */char savdir[TMPDIRLEN];			/* For saving current directory */extern char * dldir;#endif /* CK_TMPDIR */int activecmd = -1;#ifdef COMMENT#ifdef pdp11/* Normally this is defined in ckcfns.c */#define ENCBUFL 200CHAR encbuf[ENCBUFL];#endif /* pdp11 */#endif /* COMMENT */int rcflag = 0;				/* Pointer to home directory string */int repars,				/* Reparse needed */    techo = 0;				/* Take echo */#ifndef NOSCRIPTint secho = 1;#endif /* NOSCRIPT */#ifdef OS2int xitwarn = 1;	        /* Warn about open connection on exit */#elseint xitwarn = 1;#endif /* OS2 */#ifndef NOXMIT/* Variables for TRANSMIT command */int xmitx = 1;			/* Whether to echo during TRANSMIT */int xmitf = 0;			/* Character to fill empty lines */int xmitl = 0;			/* 0 = Don't send linefeed too */int xmitp = LF;			/* Host line prompt */int xmits = 0;			/* Use shift-in/shift-out, 0 = no */int xmitw = 0;			/* Milliseconds to pause during TRANSMIT */#endif /* NOXMIT *//* Declarations from ck?fio.c module */extern char *SPACMD, *SPACM2;		/* SPACE commands *//* Command-oriented items */#ifdef DCMDBUFextern char *cmdbuf;			/* Command buffers */extern char *atmbuf;extern char *line;			/* Character buffer for anything */extern char *tmpbuf;			/* Short temporary string buffer */extern int *ifcmd;extern int *intime;#elseextern char cmdbuf[];			/* Command buffers */extern char atmbuf[];extern char line[];			/* Character buffer for anything */extern char tmpbuf[];			/* Temporary buffer */extern int ifcmd[];extern int intime[];#endif /* DCMDBUF */char *lp;				/* Pointer to line buffer */#ifndef NOSPLchar evalbuf[33];			/* EVALUATE result */extern char * inpbuf;			/* Buffer for INPUT and REINPUT */char *inpbp;				/* And pointer to same */extern char lblbuf[];			/* Buffer for labels */int m_found;				/* MINPUT result */int i_active = 0;			/* INPUT command is active */char *ms[MINPMAX];			/* Pointers to MINPUT strings */#endif /* NOSPL */char psave[PROMPTL] = { NUL };		/* For saving & restoring prompt */extern int success;			/* Command success/failure flag */#ifndef NOSPLint					/* SET INPUT parameters. *//* Note, INPUT TIMEOUT, intime[], is on the command-level stack. */  inbufsize = 0,			/* INPUT buffer size */  indef = 1,				/* default timeout, seconds */  inecho = 1,				/* 1 = echo on */  insilence = 0;			/* 0 = no silence constraint */int maclvl = -1;			/* Macro nesting level */int mecho = 0;				/* Macro echo, 0 = don't */char varnam[6];				/* For variable names */extern int macargc[];			/* ARGC from macro invocation */extern char *m_arg[MACLEVEL][NARGS];	/* Stack of macro arguments */extern char **a_ptr[];			/* Array pointers */extern int a_dim[];			/* Array dimensions */#ifdef DCMDBUFextern struct cmdptr *cmdstk;		/* The command stack itself */#elseextern struct cmdptr cmdstk[];		/* The command stack itself */#endif /* DCMDBUF */extern int cmdlvl;			/* Current position in command stack */long ck_alarm = 0;			/* SET ALARM value */char alrm_date[10] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };char alrm_time[ 8] = { ' ',' ',' ',' ',' ',' ',' ' };#endif /* NOSPL */static int x, y, z = 0;			/* Local workers */static char *s;#define xsystem(s) zsyscmd(s)/* Top-Level Interactive Command Keyword Table *//* Keywords must be in lowercase and in alphabetical order. */struct keytab cmdtab[] = {#ifndef NOPUSH    "!",	   XXSHE, CM_INV,	/* Shell escape */#endif /* NOPUSH */    "#",    	   XXCOM, CM_INV,	/* Comment */#ifndef NOSPL    ":",           XXLBL, CM_INV,	/* Label */#endif /* NOSPL */#ifndef NOPUSH#ifdef CK_REDIR    "<",           XXFUN, CM_INV,	/* REDIRECT */#endif /* CK_REDIR */    "@",           XXSHE, CM_INV,	/* DCL escape */#endif /* NOPUSH */    "about",       XXVER, CM_INV,	/* Synonym for VERSION */#ifndef NOSPL#ifndef NOMSEND    "add",         XXADD, 0,		/* ADD */#endif /* NOMSEND */#ifndef NODIAL    "answer",      XXANSW, 0,		/* ANSWER the phone */#endif /* NODIAL */    "apc",         XXAPC, 0,		/* Application Program Command */    "ascii",       XXASC, CM_INV,    "asg",         XXASS, CM_INV,       /* Invisible synonym for ASSIGN */    "ask",         XXASK, 0,		/* ASK for text, assign to variable */    "askq",        XXASKQ,0,            /* ASK quietly (no echo) */    "assign",      XXASS, 0,            /* ASSIGN value to variable or macro */#endif /* NOSPL */#ifndef NOSPL    "beep",        XXBEEP,CM_INV,	/* BEEP */#endif /* NOSPL */    "binary",      XXBIN, CM_INV,#ifndef NOFRILLS    "bug",         XXBUG, 0,		/* BUG report instructions */#endif /* NOFRILLS */    "bye",         XXBYE, 0,		/* BYE to remote server */#ifndef NOLOCAL    "c",           XXCON, CM_INV|CM_ABR, /* invisible synonym for CONNECT */#endif /* NOLOCAL */#ifndef NOFRILLS    "cat",         XXTYP, CM_INV,	/* Invisible synonym for TYPE */#endif /* NOFRILLS */    "cd",          XXCWD, 0,		/* Change Directory */    "check",       XXCHK, 0,		/* CHECK for a feature */#ifndef NOFRILLS    "clear",       XXCLE, 0,		/* CLEAR input and/or device buffer */#endif /* NOFRILLS */    "close",	   XXCLO, 0,		/* CLOSE a log or other file */#ifdef OS2    "cls",         XXCLS, CM_INV,	/* Clear Screen (CLS) */#endif /* OS2 */    "comment",     XXCOM, 0,		/* Introduce a comment */#ifndef NOLOCAL    "connect",     XXCON, 0,		/* Begin terminal connection */#endif /* NOLOCAL */#ifndef NOFRILLS#ifdef ZCOPY    "copy",        XXCPY, 0,		/* COPY a file */#endif /* ZCOPY */#endif /* NOFRILLS */    "cwd",	   XXCWD, CM_INV,	/* Invisisble synonym for cd */#ifndef NOSPL    "date",        XXDATE,0,		/* DATE */    "dcl",         XXDCL, CM_INV,	/* DECLARE an array */    "declare",     XXDCL, 0,		/* DECLARE an array */    "decrement",   XXDEC, 0,		/* DECREMENT a numeric variable */    "define",      XXDEF, 0,		/* DEFINE a macro or variable */#endif /* NOSPL */#ifndef NOFRILLS    "delete",      XXDEL, 0,		/* DELETE a file */#endif /* NOFRILLS */#ifndef NODIAL    "dial",	   XXDIAL,0,		/* DIAL a phone number */#endif /* NODIAL */    "directory",   XXDIR, 0,		/* DIRECTORY of files */#ifndef NOFRILLS#ifndef NOSERVER    "disable",     XXDIS, 0,		/* DISABLE a server function */#endif /* NOSERVER */#endif /* NOFRILLS */#ifndef NOSPL    "do",          XXDO,  0,		/* DO (execute) a macro */#endif /* NOSPL */    "e",           XXEXI, CM_INV|CM_ABR,#ifndef NOFRILLS    "e-packet",    XXERR, CM_INV,	/* Send an Error-Packet */#endif /* NOFRILLS */    "echo",        XXECH, 0,		/* ECHO text */    "eightbit",    XXEIGHT, 0,		/* EIGHTBIT */#ifndef NOSPL    "else",        XXELS, CM_INV,	/* ELSE part of IF statement */#endif /* NOSPL */#ifndef NOSERVER#ifndef NOFRILLS    "enable",      XXENA, 0,		/* ENABLE a server function */#endif /* NOFRILLS */#endif /* NOSERVER */#ifndef NOSPL    "end",         XXEND, 0,		/* END command file or macro */    "evaluate",    XXEVAL, 0,		/* EVALUATE */#endif /* NOSPL */    "ex",          XXEXI, CM_INV|CM_ABR, /* Let "ex" still be EXIT */    "exit",	   XXEXI, 0,		 /* EXIT from C-Kermit */#ifdef OS2    "extproc",     XXCOM, CM_INV,        /* Dummy command for OS/2 */#endif /* OS2 */    "f",           XXFIN, CM_INV|CM_ABR, /* Invisible abbreviation for... */    "finish",      XXFIN, 0,		 /* FINISH */#ifndef NOSPL    "fo",          XXFOR, CM_INV|CM_ABR, /* Invisible abbreviation for... */    "for",         XXFOR, 0,		/* FOR loop */    "forward",     XXFWD, CM_INV,	/* FORWARD (ugh) */#endif /* NOSPL */#ifndef NOFRILLS    "fot",	   XXDIR, CM_INV,	/* "fot" = "dir" (for Chris) */#endif /* NOFRILLS */#ifdef TCPSOCKET    "ftp",	   XXFTP, 0,		/* FTP (for TCP/IP) */#endif /* TCPSOCKET */    "g",           XXGET, CM_INV|CM_ABR, /* Invisible abbreviation for GET */#ifndef NOSPL    "ge",          XXGET, CM_INV|CM_ABR, /* Ditto */#endif /* NOSPL */    "get",         XXGET, 0,		/* GET */#ifndef NOSPL    "getc",        XXGETC, 0,		/* GETC */#ifndef NOFRILLS    "getok",       XXGOK, 0,		/* GETOK (ask for Yes/No) */#endif /* NOFRILLS */#endif /* NOSPL */#ifndef NOSPL    "goto",        XXGOTO,0,		/* GOTO label in take file or macro */#endif /* NOSPL */    "h",           XXHLP, CM_INV|CM_ABR, /* Invisible synonym for HELP */    "hangup",      XXHAN, 0,		 /* HANGUP the connection */    "help",	   XXHLP, 0,		 /* Display HELP text */#ifndef NOSPL    "i",           XXINP, CM_INV|CM_ABR, /* Invisible synonym for INPUT */    "if",          XXIF,  0,		 /* IF (condition) command */    "in",          XXINP, CM_INV|CM_ABR, /* Invisible synonym for INPUT */    "increment",   XXINC, 0,		 /* Increment a numeric variable */    "input",       XXINP, 0,		 /* INPUT text from comm device */#endif /* NOSPL */#ifndef NOHELP     "introduction", XXINT, 0,		/* Print introductory text */#endif /* NOHELP */    "kermit",      XXKERMI, 0,		/* Hmmm what's this... */#ifndef NOFRILLS    "l",           XXLOG, CM_INV|CM_ABR, /* Invisible synonym for log */#endif /* NOFRILLS */#ifndef NOSPL    "local",       XXLOCAL, 0,		/* LOCAL variable declaration */#endif /* NOSPL */    "log",  	   XXLOG, 0,		/* Open a log file */#ifndef NOFRILLS#ifndef NODIAL    "lookup",      XXLOOK,0,		/* LOOKUP */#endif /* NODIAL */    "ls",          XXDIR, CM_INV,	/* Invisible synonym for DIRECTORY */    "mail",        XXMAI, 0,		/* Send a file as e-mail */    "man",         XXHLP, CM_INV,       /* Synonym for HELP */#endif /* NOFRILLS */#ifdef CK_MKDIR    "md",          XXMKDIR, CM_INV,	/* Synonym for MKDIR */#endif /* CK_MKDIR */#ifdef CK_MINPUT    "minput",      XXMINP, 0,		/* MINPUT */#endif /* CK_MINPUT */#ifndef NOMSEND    "mget",        XXGET, CM_INV,	/* MGET = GET */#endif /* NOMSEND */#ifdef CK_MKDIR    "mkdir",       XXMKDIR, 0,		/* MKDIR */#endif /* CK_MKDIR */#ifndef NOMSEND    "mmove",       XXMMOVE, 0,		/* MMOVE */#endif /* NOMSEND */    "move",        XXMOVE, 0,		/* MOVE  */

⌨️ 快捷键说明

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