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

📄 ckuusr.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
char *userv = "User Interface 5A(092), 23 Nov 92";/*  C K U U S R --  "User Interface" for Unix Kermit (Part 1)  *//*  Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),  Columbia University Center for Computing Activities.  First released January 1985.  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.*//*  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 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 int size, local, sndsrc, xitsta, server, displa, binary, msgflg,   escape, duplex, nfils, quiet, tlevel, pflag, zincnt, atcapr, atdiso, verwho; extern long vernum;extern char *versio;extern char *ckxsys, *cmarg, *cmarg2, **cmlist;#ifndef NOHELPextern char *introtxt[];#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 */#endif /* NETCONN */#ifndef NOMSEND				/* Multiple SEND */extern char *msfiles[];#endif /* NOMSEND */extern char fspec[];			/* Most recent filespec */#ifndef NOCSETSextern int nfilc;extern struct keytab fcstab[];#endif /* NOCSETS */int rcflag = 0;				/* Pointer to home directory string */int repars,				/* Reparse needed */    techo = 0,				/* Take echo */    terror = 0;				/* Take error action, 1 = quit */#ifndef NOSCRIPTint secho = 1;#endif /* NOSCRIPT */#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 int *ifcmd;#elseextern char cmdbuf[];			/* Command buffers */extern char atmbuf[];extern char line[];			/* Character buffer for anything */extern int ifcmd[];#endif /* DCMDBUF */char *lp;				/* Pointer to line buffer */#ifndef NOSPLextern char inpbuf[];			/* Buffer for INPUT and REINPUT */char *inpbp = inpbuf;			/* And pointer to same */extern char lblbuf[];			/* Buffer for labels */#endif /* NOSPL */char psave[80] = { NUL };		/* For saving & restoring prompt */extern char tmpbuf[];			/* Temporary buffer */ extern int success;			/* Command success/failure flag */#ifndef NOSPLint					/* SET INPUT parameters. */  indef = 5,				/* 5 seconds default timeout */  intime = 0,				/* 0 = proceed */  incase = 0,				/* 0 = ignore */  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 */int merror = 0;				/* Macro error action */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 */#endif /* NOSPL */static int x, y, z = 0;			/* Local workers */static char *s;#define xsystem(s) zsyscmd(s)/* Top-Level Interactive Command Keyword Table */ 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    "@",           XXSHE, CM_INV,	/* DCL escape */#endif /* NOPUSH */#ifndef NOSPL    "asg",         XXASS, CM_INV,       /* invisible synonym for assign */    "ask",         XXASK, 0,		/* ask */    "askq",        XXASKQ,0,            /* ask quietly */    "assign",      XXASS, 0,            /* assign */#endif /* NOSPL */#ifndef NOFRILLS    "bug",         XXBUG, 0,		/* bug report instructions */#endif /* NOFRILLS */    "bye",         XXBYE, 0,		/* bye to remote server */    "c",           XXCON, CM_INV|CM_ABR, /* invisible synonym for connect */#ifndef NOFRILLS    "cat",         XXTYP, CM_INV,	/* display a local file */#endif /* NOFRILLS */    "cd",          XXCWD, 0,		/* change directory */    "check",       XXCHK, 0,		/* check for a feature */#ifndef NOFRILLS    "clear",       XXCLE, 0,		/* clear input buffer */#endif /* NOFRILLS */    "close",	   XXCLO, 0,		/* close a log file */#ifdef NOFRILLS    "comment",     XXCOM, CM_INV,	/* comment */#else    "comment",     XXCOM, 0,		/* comment */#endif /* NOFRILLS */    "connect",     XXCON, 0,		/* connect to remote system */    "cwd",	   XXCWD, CM_INV,	/* invisisble synonym for cd */#ifndef NOSPL    "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 */#endif /* NOSPL */#ifndef NOFRILLS    "delete",      XXDEL, 0,		/* delete a file */#endif /* NOFRILLS */#ifndef NODIAL    "dial",	   XXDIAL,0,		/* dial a phone number */#endif /* NODIAL */#ifndef MAC    "directory",   XXDIR, 0,		/* directory of files */#endif /* MAC */#ifndef NOFRILLS    "disable",     XXDIS, 0,		/* disable server function */#endif /* NOFRILLS */#ifndef NOSPL    "do",          XXDO,  0,		/* execute a macro */#endif /* NOSPL */#ifndef NOFRILLS    "e-packet",    XXERR, CM_INV,	/* Send an Error packet */#endif /* NOFRILLS */    "echo",        XXECH, 0,		/* echo argument */#ifndef NOSPL    "else",        XXELS, CM_INV,	/* ELSE part of IF statement */#endif /* NOSPL */#ifndef NOFRILLS    "enable",      XXENA, 0,		/* ENABLE a server function */#endif /* NOFRILLS */#ifndef NOSPL    "end",         XXEND, 0,		/* END command file or macro */#endif /* NOSPL */    "ex",          XXEXI, CM_INV|CM_ABR, /* Let "ex" still be EXIT */    "exit",	   XXEXI, 0,		/* exit the program */    "extproc",     XXCOM, CM_INV,       /* dummy command */    "finish",      XXFIN, 0,		/* FINISH */#ifndef NOSPL    "for",         XXFOR, 0,		/* FOR loop */#endif /* NOSPL */#ifndef NOFRILLS#ifndef MAC    "fot",	   XXDIR, CM_INV,	/* "fot" = "dir" (for Chris) */#endif /* MAC */#endif /* NOFRILLS */    "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#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 */    "hangup",      XXHAN, 0,		/* hangup dialed phone 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 string from comm line */#endif /* NOSPL */#ifndef NOHELP     "introduction", XXINT, 0,		/* Print introductory text */#endif /* NOHELP */#ifndef NOFRILLS    "l",           XXLOG, CM_INV|CM_ABR,/* invisible synonym for log */#endif /* NOFRILLS */    "log",  	   XXLOG, 0,		/* open a log file */#ifndef NOFRILLS#ifndef MAC    "ls",          XXDIR, CM_INV,	/* invisible synonym for directory */#endif /* MAC */    "mail",        XXMAI, 0,		/* mail file to user */    "man",         XXHLP, CM_INV,       /* Synonym for help */#endif /* NOFRILLS */#ifndef NOMSEND    "mget",        XXGET, CM_INV,	/* MGET = GET */#endif /* NOMSEND */#ifndef NOSPL    "mpause",      XXMSL, CM_INV,	/* Millisecond sleep */#endif /* NOSPL */#ifndef NOMSEND    "ms",          XXMSE, CM_INV|CM_ABR,    "msend",       XXMSE, 0,		/* Multiple SEND */#endif /* NOMSEND */#ifndef NOSPL    "msleep",      XXMSL, 0,		/* Millisecond sleep */#endif /* NOSPL */#ifndef NOMSEND    "mput",        XXMSE, CM_INV,	/* MPUT = MSEND */#endif /* NOMSEND */#ifndef NOFRILLS    "mv",          XXREN, CM_INV,	/* rename a local file */#endif /* NOFRILLS */#ifndef NOSPL    "o",           XXOUT, CM_INV|CM_ABR,/* invisible synonym for OUTPUT */    "open",        XXOPE, 0,		/* open file for reading or writing */    "output",      XXOUT, 0,		/* output string to comm line */#endif /* NOSPL */#ifdef SUNX25    "pad",         XXPAD, 0,            /* PAD commands */#endif /* SUNX25 */#ifndef NOSPL    "pause",       XXPAU, 0,		/* sleep for specified interval */#ifdef TCPSOCKET    "ping",        XXPNG, 0,		/* PING (for TCP/IP) */#endif /* TCPSOCKET */    "pop",         XXEND, CM_INV,	/* allow POP as synonym for END */#endif /* NOSPL */#ifndef NOFRILLS    "print",       XXPRI, 0,		/* PRINT */#ifndef NOPUSH    "pu",          XXSHE, CM_INV,	/* PU = PUSH */    "push",        XXSHE, 0,		/* PUSH command (like RUN, !) */#endif /* NOPUSH */    "put",	   XXSEN, CM_INV,	/* PUT = SEND */#ifndef MAC    "pwd",         XXPWD, 0,            /* print working directory */#endif /* MAC */#endif /* NOFRILLS */    "quit",	   XXQUI, 0,		/* quit from program = exit */    "r",           XXREC, CM_INV,	/* invisible synonym for receive */#ifndef NOSPL    "read",        XXREA, 0,            /* read */#endif /* NOSPL */    "receive",	   XXREC, 0,		/* receive files */#ifndef NODIAL    "redial",      XXRED, 0,		/* redial */#endif /* NODIAL */#ifndef NOSPL    "reinput",     XXREI, 0,            /* reinput */#endif /* NOSPL */    "remote",	   XXREM, 0,		/* send generic command to server */#ifndef NOFRILLS    "rename",      XXREN, 0,		/* rename a local file */    "replay",      XXTYP, CM_INV,	/* replay (for now, just type) */#endif /* NOFRILLS */#ifndef NOSPL    "return",      XXRET, 0,		/* return from function */#endif /* NOSPL */#ifndef NOFRILLS    "rm",          XXDEL, CM_INV,	/* invisible synonym for delete */#endif /* NOFRILLS */#ifndef NOPUSH    "run",         XXSHE, 0,		/* run a program or command */#endif /* NOPUSH */    "s",           XXSEN, CM_INV|CM_ABR, /* invisible synonym for send */#ifndef NOSCRIPT    "script",	   XXLOGI,0,		/* execute a uucp-style script */#endif /* NOSCRIPT */    "send",	   XXSEN, 0,		/* send files */#ifndef NOSERVER    "server",	   XXSER, 0,		/* be a server */#endif /* NOSERVER */    "set",	   XXSET, 0,		/* set parameters */#ifndef NOSHOW    "show", 	   XXSHO, 0,		/* show parameters */#endif /* NOSHOW */#ifndef NOSPL#ifndef NOFRILLS    "sleep",       XXPAU, CM_INV,	/* sleep for specified interval */#endif /* NOFRILLS */#endif /* NOSPL */#ifndef MAC#ifndef NOFRILLS    "sp",          XXSPA, CM_INV|CM_ABR,    "spa",         XXSPA, CM_INV|CM_ABR,#endif /* NOFRILLS */    "space",       XXSPA, 0,		/* show available disk space */#endif /* MAC */#ifndef NOFRILLS#ifndef NOPUSH    "spawn",       XXSHE, CM_INV,	/* synonym for PUSH, RUN */#endif /* NOPUSH */#endif /* NOFRILLS */    "statistics",  XXSTA, 0,		/* display file transfer stats */#ifndef NOSPL    "stop",        XXSTO, 0,		/* stop all take files */#endif /* NOSPL */#ifndef NOJC    "suspend",     XXSUS, 0,		/* Suspend */#endif /* NOJC */    "take",	   XXTAK, 0,		/* take commands from file */#ifndef NOFRILLS#ifdef NETCONN    "telnet",      XXTEL, 0,		/* telnet */#endif /* NETCONN */    "test",        XXTES, CM_INV,	/* (for testing) */#endif /* NOFRILLS */#ifndef NOCSETS    "translate",   XXXLA, 0,		/* translate local file char sets */#endif#ifndef NOXMIT    "transmit",    XXTRA, 0,		/* raw upload file */#endif /* NOXMIT */#ifndef NOFRILLS    "type",        XXTYP, 0,		/* display a local file */#endif /* NOFRILLS */    "version",     XXVER, 0		/* version number display */#ifndef NOSPL,   "wait",        XXWAI, 0		/* wait (like pause) */,   "while",       XXWHI, 0		/* while */#endif /* NOSPL */#ifndef MAC#ifndef NOFRILLS,   "who",         XXWHO, 0		/* who */#endif /* NOFRILLS */#endif /* MAC */#ifndef NOSPL,   "write",       XXWRI, 0		/* write */,   "xif",         XXIFX, 0		/* Extended IF */#endif /* NOSPL */#ifndef NOCSETS,   "xlate",       XXXLA, CM_INV	/* translate local file char sets */#endif#ifndef NOXMIT,   "xmit",        XXTRA, CM_INV	/* raw upload file */#endif /* NOXMIT */,   "z",           XXSUS, CM_INV	/* Suspend */#ifndef NOSPL,   "_assign",     XXASX, CM_INV	/* used internally by FOR, etc */,   "_define",     XXDFX, CM_INV	/* used internally by FOR, etc */,   "_getargs",    XXGTA, CM_INV        /* used internally by FOR, etc */,   "_putargs",    XXPTA, CM_INV        /* used internally by FOR, etc */#endif /* NOSPL */};int ncmd = (sizeof(cmdtab) / sizeof(struct keytab));char toktab[] = {#ifndef NOPUSH    '!',				/* Shell escape */#endif /* NOPUSH */    '#',				/* Comment */    ';',				/* Comment */#ifndef NOSPL    ':',				/* Label */#endif /* NOSPL */#ifndef NOPUSH    '@',				/* DCL escape */#endif /* NOPUSH */    '\0'				/* End of this string */};#ifndef NOSPL#ifndef NOFRILLSstruct keytab yesno[] = {    "no",    0, 0,

⌨️ 快捷键说明

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