📄 ckcmai.c
字号:
*rdatap, /* Pointer to received packet data */ *data = (CHAR *)0, /* Pointer to send-packet data */ *srvptr, /* Pointer to srvcmd */ mystch = SOH, /* Outbound packet-start character */ stchr = SOH; /* Incoming packet-start character *//* File-related variables */#ifndef NOMSEND /* Multiple SEND */struct filelist * filehead = NULL;struct filelist * filetail = NULL;struct filelist * filenext = NULL;int addlist = 0;#endif /* NOMSEND */char filnam[CKMAXPATH + 1]; /* Name of current file. */char cmdfil[CKMAXPATH + 1]; /* Application file name. */int cfilef = 0; /* Application file flag. */#ifndef NOSERVERint ngetpath = 0; /* GET search path */char * getpath[MAXGETPATH];char * x_user = NULL; /* Server login information */char * x_passwd = NULL;char * x_acct = NULL;int x_login = 0; /* Login required */int x_logged = 0; /* User is logged in */#endif /* NOSERVER */int nfils = 0; /* Number of files in file group */long fsize; /* Size of current file */int wildxpand = 0; /* Who expands wildcards */int clfils = 0; /* Flag for command-line files */int stayflg = 0; /* Flag for "stay", i.e. "-S" *//* Communication line variables */#ifdef BIGBUFOKchar ttname[512]; /* Name of communication device */#else#ifdef MACchar ttname[256];#elsechar ttname[80];#endif /* MAC */#endif /* BIGBUFOK */#ifdef MACint connected = 0; /* True if connected */int startconnected; /* initial state of connected */#endif /* MAC */long speed = -1L; /* Line speed */int parity = DEFPAR, /* Parity specified, 0,'e','o',etc */ autopar = 0, /* Automatic parity change flag */ sosi = 0, /* Shift-In/Out flag */ flow = FLO_XONX, /* Flow control */ autoflow = 1, /* Automatic flow control */ turn = 0, /* Line turnaround handshake flag */ turnch = XON, /* Line turnaround character */ duplex = 0, /* Duplex, full by default */ escape = DFESC, /* Escape character for connect */ delay = DDELAY, /* Initial delay before sending */ tnlm = 0, /* Terminal newline mode */ mdmtyp = 0; /* Modem type (initially none) *//* Networks for SET HOST */#define MYHOSTL 100 char myhost[MYHOSTL]; /* Local host name */ int network = 0; /* Network vs serial connection */#ifdef NETCONN#ifdef TCPSOCKET int nettype = NET_TCPB; /* Assume TCP/IP (BSD sockets) */#else#ifdef SUNX25 int nettype = NET_SX25;#else#ifdef STRATUSX25 int nettype = NET_VX25;#else#ifdef DECNET int nettype = NET_DEC;#else#ifdef SUPERLAT int nettype = NET_SLAT;#else int nettype = NET_NONE;#endif /* SUPERLAT */#endif /* DECNET */#endif /* STRATUSX25 */#endif /* SUNX25 */#endif /* TCPSOCKET */#else int nettype = NET_NONE;#endif /* NETCONN */#ifdef ANYX25 int revcall = 0; /* X.25 reverse call not selected */ int closgr = -1; /* X.25 closed user group not selected */ int cudata = 0; /* X.25 call user data not specified */ char udata[MAXCUDATA]; /* X.25 call user data */ CHAR padparms[MAXPADPARMS+1]; /* X.3 parameters */#endif /* ANYX25 *//* Other items */int isinterrupted = 0; /* Used in exception handling */extern int what;#ifdef NTextern int StartedFromDialer;#ifdef NTSIGextern int TlsIndex;#endif /* NTSIG */#ifdef NTASM unsigned long ESPToRestore ; /* Ditto */#endif /* NTASM */#endif /* NT */#ifdef OS2PMint os2pm = 0; /* OS/2 Presentation Manager flag */#endif /* OS2PM *//* Terminal screen size, if known, -1 means unknown. */#ifdef OS2#include "ckocon.h"int tt_rows[VNUM] = {25,24,25,1}; /* Rows (height) */int tt_cols[VNUM] = {80,80,80,80}; /* Columns (width) */#else /* OS2 */int tt_rows = -1; /* Rows (height) */int tt_cols = -1; /* Columns (width) */#endif /* OS2 */int tt_escape = 1; /* Escaping back is enabled */#ifdef NETCONNextern int ttyfd, tn_exit;#endif /* NETCONN */ int exitonclose = 0; /* Exit on close */ int tlevel = -1; /* Take-file command level */#ifdef NOLOCAL int remonly = 1; /* Remote-mode-only advisory (-R) */#else int remonly = 0;#endif /* NOLOCAL */#ifndef NOSPL extern int cmdlvl; /* Command level */ extern int maclvl; /* Macro invocation level */#endif /* NOSPL */ int protocol = PROTO_K; /* File transfer protocol = Kermit */#ifdef NEWDEFAULTS int prefixing = PX_CAU;#else int prefixing = PX_ALL;#endif /* NEWDEFAULTS */ extern short ctlp[]; /* Control-prefix table */ int carrier = CAR_AUT; /* Pay attention to carrier signal */ int cdtimo = 0; /* Carrier wait timeout */ int xitsta = GOOD_EXIT; /* Program exit status */#ifdef VMS /* Default filename collision action */ int fncact = XYFX_X; /* REPLACE for VAX/VMS */#else int fncact = XYFX_B; /* BACKUP for everybody else */#endif /* VMS */ int fncsav = -1; /* For saving & restoring the above */ int bgset = -1; /* BACKGROUND mode set explicitly */#ifdef UNIX int suspend = DFSUSP; /* Whether SUSPEND command, etc, */#else /* is to be allowed. */ int suspend = 0;#endif /* UNIX *//* Statistics variables */long filcnt, /* Number of files in transaction */ filrej, /* Number of files rejected in transaction */ flci, /* Characters from line, current file */ flco, /* Chars to line, current file */ tlci, /* Chars from line in transaction */ tlco, /* Chars to line in transaction */ ffc, /* Chars to/from current file */ tfc, /* Chars to/from files in transaction */ ccu, /* Control chars unprefixed in transaction */ ccp, /* Control chars prefixed in transaction */ rptn; /* Repeated characters compressed */int tsecs = 0; /* Seconds for transaction */int fsecs = 0; /* Per-file timer *//* Flags */int deblog = 0, /* Flag for debug logging */ debses = 0, /* Flag for DEBUG SESSION */ pktlog = 0, /* Flag for packet logging */ seslog = 0, /* Session logging */ tralog = 0, /* Transaction logging */ displa = 0, /* File transfer display on/off */ stdouf = 0, /* Flag for output to stdout */ stdinf = 0, /* Flag for input from stdin */ xflg = 0, /* Flag for X instead of F packet */ hcflg = 0, /* Doing Host command */ dest = DEST_D, /* Destination for packet data *//* If you change this, also see struct ptab above... */#ifdef OS2 /* Flag for file name conversion */ fncnv = XYFN_L, /* Default is Literal in OS/2, */ f_save = XYFN_L, /* (saved copy of same) */#else fncnv = XYFN_C, /* elsewhere Convert them */ f_save = XYFN_C, /* (ditto) */#endif /* OS2 */ fnspath = 1, /* Send-file path 1 = strip */ fnrpath = 1, /* Receive-file path 1 = strip */#ifdef NEWDEFAULTS binary = XYFT_B, /* Default file transfer mode */ b_save = XYFT_B, /* Saved file mode */#else binary = XYFT_T, /* Default file transfer mode */ b_save = XYFT_T, /* Saved file mode */#endif /* NEWDEFAULTS */#ifdef OS2 cursor_save = -1, /* Cursor state */#endif /* OS2 */ xfermode = XMODE_A, /* Transfer mode, manual or auto */ sendmode = SM_SEND, /* Which type of SEND operation */ slostart = 1, /* Slow start (grow packet lengths) */ cmask = 0177, /* CONNECT (terminal) byte mask */ fmask = 0377, /* File byte mask */ warn = 0, /* Flag for file warning */ quiet = 0, /* Be quiet during file transfer */ local = 0, /* 1 = local mode, 0 = remote mode */ server = 0, /* Flag for being a server */ bye_active = 0, /* Flag for BYE command active */ cflg = 0, /* Connect before transaction */ cnflg = 0, /* Connect after transaction */ cxseen = 0, /* Flag for cancelling a file */ czseen = 0, /* Flag for cancelling file group */ discard = 0, /* Flag for file to be discarded */ keep = 1, /* Keep incomplete files */ unkcs = 1, /* Keep file w/unknown character set */ nakstate = 0, /* In a state where we can send NAKs */ dblchar = -1, /* Character to double when sending */ moving = 0; /* MOVE = send, then delete */long sendstart = 0L; /* SEND start position *//* Variables passed from command parser to protocol module */#ifndef NOSPL#ifndef NOICP_PROTOTYP( int parser, (int) ); /* The parser itself */#ifdef CK_APC_PROTOTYP( VOID apconect, (void) );#endif /* CK_APC */#endif /* NOICP */#endif /* NOSPL */char *clcmds = NULL; /* Pointer to command-line commands */#ifdef CK_CURSES#ifndef OS2#ifndef COHERENT_PROTOTYP( VOID fxdinit, (void) );#endif /* COHERENT */#endif /* OS2 */#endif /* CK_CURSES */CHAR sstate = (CHAR) 0; /* Starting state for automaton */CHAR zstate = (CHAR) 0; /* For remembering sstate */char *cmarg = ""; /* Pointer to command data */char *cmarg2 = ""; /* Pointer to 2nd command data */char **cmlist; /* Pointer to file list in argv */int autodl = /* Autodownload */#ifdef CK_AUTODL#ifdef OS2 1 /* Enabled by default only in */#else /* terminal-emulating versions, */ 0 /* disabled by default for others */#endif /* OS2 */#else 0 /* (or if not implemented). */#endif /* CK_AUTODL */ ;int remfile = 0, rempipe = 0, remappd = 0; /* REMOTE output redirection */char * remdest = NULL;char * printfile = NULL; /* NULL if printer not redirected */int printpipe = 0; /* For SET PRINTER *//* Server services: 0 = disabled 1 = enabled in local mode 2 = enabled in remote mode 3 = enabled in both local and remote modes only as initial (default) values.*/int en_cwd = 3; /* CD/CWD */int en_cpy = 3; /* COPY */int en_del = 2; /* DELETE */int en_dir = 3; /* DIRECTORY */int en_fin = 3; /* FINISH */int en_get = 3; /* GET */int nopush = 0; /* PUSH enabled */#ifndef NOPUSHint en_hos = 2; /* HOST enabled */#elseint en_hos = 0; /* HOST disabled */#endif /* NOPUSH */int en_ren = 3; /* RENAME */int en_sen = 3; /* SEND */int en_set = 3; /* SET */int en_spa = 3; /* SPACE */int en_typ = 3; /* TYPE */int en_who = 3; /* WHO */#ifdef datageneral/* Data General AOS/VS can't do this */int en_bye = 0; /* BYE */#elseint en_bye = 2; /* PCs in local mode... */#endif /* datageneral */int en_asg = 3; /* ASSIGN */int en_que = 3; /* QUERY */int en_ret = 2; /* RETRIEVE */int en_mai = 3; /* MAIL */int en_pri = 3; /* PRINT *//* Miscellaneous */char **xargv; /* Global copies of argv */int xargc; /* and argc */int xargs; /* an immutable copy of argc */char *xarg0; /* and of argv[0] */char *pipedata; /* Pointer to -P (pipe) data */extern char *dftty; /* Default tty name from ck?tio.c */extern int dfloc; /* Default location: remote/local */extern int dfprty; /* Default parity */extern int dfflow; /* Default flow control *//* Buffered file input and output buffers. See getpkt() in ckcfns.c and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).*/#ifndef DYNAMIC/* Now we allocate them dynamically, see getiobs() below. */char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];#endif /* DYNAMIC */char *zinptr, *zoutptr;int zincnt, zoutcnt;_PROTOTYP( int getiobs, (VOID) );/* M A I N -- C-Kermit main program */#include <signal.h>#ifndef NOCCTRAP#include <setjmp.h>#include "ckcsig.h"ckjmpbuf cmjbuf;#ifdef GEMDOS /* Special for Atari ST */cc_clean(); /* This can't be right? */#endif /* GEMDOS */#endif /* NOCCTRAP *//* C K I N D E X -- C-Kermit's index function *//* We can't depend on C libraries to have one, so here is our own. Call with: s1 - String to look for. s2 - String to look in. t - Starting position in s2. r - 0 for left-to-right search, non-0 for right-to-left. icase 0 for case independence, non-0 if alphabetic case matters. Returns 0 if string not found, otherwise a 1-based result.*/intckindex(s1,s2,t,r,icase) char *s1, *s2; int t, r, icase; { int len1, len2, i, j, x; char * s; char * ss1 = NULL; char * ss2 = NULL; if (!s1 || !s2) return(0); len1 = (int)strlen(s1); /* length of string to look for */ len2 = (int)strlen(s = s2); /* length of string to look in */ if (len1 < 0) return(0); /* paranoia */ if (len2 < 0) return(0); j = len2 - len1; /* length difference */ if (j < 0 || t > j) { /* search string is longer */ return(0); } else { /* Args are OK */ s = s2 + t; /* Point to beginning of target */ if (r == 0) { /* Index */ for (i = 0; i <= (j - t); i++) { /* Now compare */ x = icase ? strncmp(s1,s++,len1) : xxstrcmp(s1,s++,len1); if (!x) return(i+1+t); } } else { /* Reverse Index */ for (i = t; i > -1 && s >= s1; i--) { /* Compare */ x = icase ? strncmp(s1,s--,len1) : xxstrcmp(s1,s--,len1); if (!x) return(i+1); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -