📄 ckuusr.c
字号:
#include "ckcsym.h"char *userv = "User Interface 7.0.222, 1 Jan 2000";/* 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, 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.*//* Originally the entire user interface was in one module, ckuusr.c. Over the years it has been split into many modules: ckuus2.c, ckuus3.c, ..., ckuus7.c. ckuus2.c contains the help command parser and help text strings 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 different platforms -- 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: . Set parameters via global variables like duplex, speed, ttname, etc. See ckmain.c for the declarations and descriptions of these variables. . 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. . 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 an "as-name" - the name to send file(s) under, or the name under which to store incoming file(s); must not be wild. A null or empty value means to use the file's own name. cmlist is a list of 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.*/int g_fncact = -1; /* Needed for NOICP builds */int noinit = 0; /* Flag for skipping init file */#ifndef NOICP/* Includes */#include "ckcdeb.h"#include "ckcasc.h"#include "ckcker.h"#include "ckcnet.h" /* Network symbols */#include "ckuusr.h"#include "ckcxla.h"#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 <tapi.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;int display_demo = 1;#endif /* OS2 */int optlines = 0;int didsetlin = 0;#ifdef VMSextern int batch;#endif /* VMS */#ifdef datageneral#include <packets:common.h>#define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)#endif /* datageneral */extern int hints, cmflgs, whyclosed;#ifndef NOCSETSextern int nfilc;extern struct keytab fcstab[];extern int fcharset;#endif /* NOCSETS */char * g_pswd = NULL;int g_pcpt = -1;int g_pflg = -1;extern int cmd_rows, cmd_cols;#ifndef NOXFERextern int atcapr, atdiso, nfils, moving, protocol, sendmode, epktflg, size, sndsrc, server, displa, inserver, fncnv, fnspath, fnrpath, xfermode, urpsiz, spsizf, spsiz, spsizr, spmax, wslotr, prefixing, fncact;#ifdef CK_LOGINextern int isguest;#endif /* CK_LOGIN */extern long sendstart;extern char *cmarg, *cmarg2, **cmlist, * dftty;extern struct keytab fntab[]; extern int nfntab;extern struct ck_p ptab[NPROTOS];int sndcmd = 0; /* Last command was a SEND-class command. */int g_xfermode = -1;int g_proto = -1;int g_urpsiz = -1;int g_spsizf = -1;int g_spsiz = -1;int g_spsizr = -1;int g_spmax = -1;int g_wslotr = -1;int g_prefixing = -1;int g_fncnv = -1;int g_fnspath = -1;int g_fnrpath = -1;int g_fnact = -1;int g_displa = -1;int g_spath = -1;int g_rpath = -1;char * g_sfilter = NULL;char * g_rfilter = NULL;#ifdef PATTERNSextern int patterns;int g_patterns = -1;#endif /* PATTERNS */int g_skipbup = -1;#ifdef PIPESENDextern int usepipes, pipesend;extern char * sndfilter, * rcvfilter;#endif /* PIPESEND */#ifdef PATTERNSextern char *txtpatterns[], *binpatterns[];#endif /* PATTERNS */#ifndef NOSPLextern int sndxlo, sndxhi, sndxin;#endif /* NOSPL */extern char fspec[]; /* Most recent filespec */extern int fspeclen; /* Length of fspec[] buffer */#ifndef NOFRILLSextern int rmailf; /* MAIL command items */extern char optbuf[];#endif /* NOFRILLS */extern int en_cpy, en_cwd, en_del, en_dir, en_fin, en_get, en_bye, en_mai, en_pri, en_hos, en_ren, en_sen, en_spa, en_set, en_typ, en_who, en_ret, en_xit, en_mkd, en_rmd, en_asg;#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;#endif /* NOMSEND */static struct keytab addtab[] = {#ifdef PATTERNS "binary-patterns", ADD_BIN, 0,#endif /* PATTERNS */#ifndef NOMSEND "send-list", ADD_SND, 0,#endif /* NOMSEND */#ifdef PATTERNS "text-patterns", ADD_TXT, 0,#endif /* PATTERNS */ "", 0, 0};static int naddtab = sizeof(addtab)/sizeof(struct keytab) - 1;#ifndef NOCSETSstruct keytab assoctab[] = { "file-character-set", ASSOC_FC, 0, "transfer-character-set", ASSOC_TC, 0, "xfer-character-set", ASSOC_TC, CM_INV};static int nassoc = sizeof(assoctab)/sizeof(struct keytab);extern int afcset[MAXFCSETS+1]; /* Character-set associations */extern int axcset[MAXTCSETS+1];#endif /* NOCSETS */#ifndef ADDCMD#ifndef NOMSEND#define ADDCMD#endif /* NOMSEND */#ifndef ADDCMD#ifdef PATTERNS#define ADDCMD#endif /* PATTERNS */#endif /* ADDCMD */#endif /* ADDCMD */#endif /* NOXFER *//* External Kermit Variables, see ckmain.c for description. */extern xx_strp xxstring;extern long xvernum;extern int local, xitsta, binary, msgflg, escape, duplex, quiet, tlevel, pflag, zincnt, ckxech, carrier, what, nopush, haveline, bye_active;#ifdef TNCODEextern int debses;extern char tn_msg[];#endif /* TNCODE */int sleepcan = 1;int g_binary = -1;int g_recursive = -1;int g_matchdot = -1;extern long vernum;extern char *versio, *copyright[];extern char *ckxsys;#ifndef NOHELPextern char *introtxt[];extern char *newstxt[];#endif /* NOHELP */#ifndef OS2#ifndef UNIXextern char *PWDCMD;#endif /* UNIX */extern char *WHOCMD;#endif /* OS2 */extern char ttname[];extern CHAR sstate;extern int network; /* Have active network connection */#ifdef NETCONNextern int 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 NOPUSH#ifndef NOFRILLSextern char editor[];extern char editopts[];extern char editfile[];#endif /* NOFRILLS */#endif /* NOPUSH */#ifdef BROWSERextern char browser[]; /* Web browser application */extern char browsopts[]; /* Web browser options */extern char browsurl[]; /* Most recent URL */char ftpapp[CKMAXPATH+1] = { NUL, NUL }; /* ftp executable */char ftpopts[128] = { NUL, NUL }; /* ftp command-line options */#endif /* BROWSER */extern struct keytab onoff[]; /* On/Off keyword table */#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; /* Keyword index of active command */int doconx = -1; /* CONNECT-class command active */int ooflag = 0; /* User-settable on/off flag */int rcflag = 0; /* Pointer to home directory string */int repars, /* Reparse needed */ techo = 0; /* Take echo */int secho = 1; /* SCRIPT echo */int xitwarn = /* Warn about open connection on exit */#ifdef NOWARN0#else1#endif /* NOWARN */;struct keytab onoffsw[] = { "/off", 0, 0, "/on", 1, 0};#ifdef CKEXECstruct keytab redirsw[] = { "/redirect", 1, 0};#endif /* CKEXEC */#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 */int xmitt = 1; /* Seconds to wait for each char to echo */int xmita = 1; /* Action upon timeout */#define XMI_BIN 1#define XMI_TXT 2#define XMI_CMD 3#define XMI_TRA 4#define XMI_VRB 5#define XMI_QUI 6#define XMI_NOW 7static struct keytab xmitsw[] = { /* TRANSMIT command options */ "/binary", XMI_BIN, 0,#ifdef PIPESEND "/command", XMI_CMD, CM_INV,#endif /* PIPESEND */ "/nowait", XMI_NOW, 0,#ifdef PIPESEND "/pipe", XMI_CMD, 0,#endif /* PIPESEND */#ifdef COMMENT "/quiet", XMI_QUI, 0,#endif /* COMMENT */ "/text", XMI_TXT, 0, "/transparent", XMI_TRA, 0,#ifdef COMMENT "/verbose", XMI_VRB, 0,#endif /* COMMENT */ "", 0, 0};#define NXMITSW sizeof(xmitsw)/sizeof(struct keytab) - 1static int nxmitsw = NXMITSW;#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;extern char *inpcas;#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[];extern char inpcas[];#endif /* DCMDBUF */char *lp; /* Pointer to line buffer */#ifndef NOSPLint oldeval = 0;char 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 */static int mp[MINPMAX]; /* and flags */extern int fndiags, fnerror, fnsuccess; /* Function diagnostics */#endif /* NOSPL */char psave[PROMPTL] = { NUL }; /* For saving & restoring prompt */extern int success; /* Command success/failure flag */extern int cmdlvl; /* Current position in command stack */#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 */ inautodl = 0, /* INPUT autodownload */ inintr = 1, /* INPUT interrupion allowed */ insilence = 0; /* 0 = no silence constraint */#ifdef OS2int interm = 1; /* Terminal emulator displays input */#endif /* OS2 */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 *mrval[];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 */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 */#else "!", XXNOTAV, CM_INV,#endif /* NOPUSH */ "#", XXCOM, CM_INV, /* Comment */#ifndef NOSPL ".", XXDEF, CM_INV, /* Assignment */ ":", XXLBL, CM_INV, /* Label */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -