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

📄 ckuusx.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
/*  C K U U S X --  "User Interface" common functions. *//*  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.*//*  This module contains user interface functions needed by both the interactive  user interface and the command-line-only user interface.*//* Includes */#include "ckcdeb.h"#include "ckcasc.h"#include "ckcker.h"#include "ckuusr.h"#ifndef WINTCP#include <signal.h>#endif /* WINTCP */#ifdef VMS#ifdef WINTCP#include <descrip.h>#include <ssdef.h>#include <stsdef.h>#include <signal.h>#else#include <descrip.h>#include <ssdef.h>#include <stsdef.h>#endif /* WINTCP */#endif /* VMS *//* Used internally */_PROTOTYP( VOID screenc, (int, char, long, char *) );static int ft_win = 0;  /* Fullscreen file transfer display window is active *//* Variables declared here */int fdispla = XYFD_R;			/* File transfer display type */int tt_crd = 0;				/* Carriage return display */#ifdef DEBUGchar debfil[50];			/* Debugging log file name */#endif /* DEBUG */#ifdef TLOGchar trafil[50];			/* Transaction log file name */#endif /* TLOG */char pktfil[50];			/* Packet log file name */char sesfil[50];			/* Session log file name */#ifndef NOFRILLSchar optbuf[100];			/* Options for MAIL or REMOTE PRINT */#endif /* NOFRILLS */char cmdstr[256];			/* Place to build generic command */char fspec[FSPECL];			/* Filename string for \v(filespec) *//*  C C N T A B  --  Names of ASCII control characters 0-31 */char *ccntab[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1/XON", "DC2", "DC3/XOFF", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"};int success = 1,			/* Command success/failure flag */#ifndef NOSPL    cmdlvl = 0,				/* Command level */#endif /* NOSPL */    action,				/* Action selected on command line*/    sessft = 0,				/* Session log file type, 0 = text */    pflag = 1,				/* Print prompt */    msgflg = 1;				/* Print informational messages */#ifndef NOMSEND				/* Multiple SEND */char *msfiles[MSENDMAX];#endif /* NOMSEND *//* External variables */#ifndef NODIALextern FILE * dialfd;			/* Dialing directory */#endif /* NODIAL */extern int local, quiet, binary, bctu, rptflg, ebqflg, network, server,  what, spsiz, urpsiz, wmax, czseen, cxseen, winlo, displa, timint, parity,  npad, ebq, ebqflg, bctr, rptq, atcapu, lpcapu, swcapu, wslotn, wslotr, rtimo,  mypadn, sq, capas, rpsiz, tsecs, dfloc, tralog, pktlog, seslog, lscapu,  xitsta, escape, tlevel, bgset, backgrd, wslots, suspend, srvdis,  spackets, spktl, rpktl, retrans, wcur, numerrs, fsecs;#ifdef datageneral			/* 2/12/92 ENH */#include <sysid.h>extern int con_reads_mt, conint_ch, conint_avl;#endif /* datageneral */extern long speed, filcnt, ffc, tfc, rptn, fsize;extern CHAR *rdatap, padch, seol, ctlq, mypadc, eol;extern char ttname[], *dftty, *cmarg, **cmlist, *versio, myhost[];#ifndef NOICP#ifdef DCMDBUFextern char *cmdbuf;			/* Command buffer */#elseextern char cmdbuf[];			/* Command buffer */#endif /* DCMDBUF */#endif /* NOICP */#ifndef NOCCTRAP#include <setjmp.h>			/* Control-C trap */jmp_buf cmjbuf;#endif /* NOCCTRAP *//*  P A R N A M  --  Return parity name */char *#ifdef CK_ANSICparnam(char c)#elseparnam(c) char c;#endif /* CK_ANSIC *//* parnam */ {    switch (c) {	case 'e': return("even");	case 'o': return("odd");	case 'm': return("mark");	case 's': return("space");	case 0:   return("none");	default:  return("invalid");    }}/*  S H O M D M  --  Show modem signals  */VOIDshomdm() {/*  Note use of "\r\n" to make sure this report prints right, even when  called during CONNECT mode.*/    int y;    y = ttgmdm();    switch (y) {      case -3: printf(	         "Modem signals unavailable in this version of Kermit\r\n");	       break;      case -2: printf("No modem control for this device\r\n"); break;      case -1: printf("Modem signals unavailable\r\n"); break;      default:#ifndef MAC        printf(	  " Carrier Detect      (CD):  %s\r\n",(y & BM_DCD) ? "On": "Off");	printf(          " Dataset Ready       (DSR): %s\r\n",(y & BM_DSR) ? "On": "Off");#endif /* MAC */	printf(          " Clear To Send       (CTS): %s\r\n",(y & BM_CTS) ? "On": "Off");#ifndef MAC        printf(          " Ring Indicator      (RI):  %s\r\n",(y & BM_RNG) ? "On": "Off");#endif /* MAC */        printf(          " Data Terminal Ready (DTR): %s\r\n",(y & BM_DTR) ? "On": "Off");#ifndef MAC        printf(          " Request to Send     (RTS): %s\r\n",(y & BM_RTS) ? "On": "Off");#endif /* MAC */    }}/*  S D E B U  -- Record spar results in debugging log  */VOIDsdebu(len) int len; {    debug(F111,"spar: data",(char *) rdatap,len);    debug(F101," spsiz ","", spsiz);    debug(F101," timint","",timint);    debug(F101," npad  ","",  npad);    debug(F101," padch ","", padch);    debug(F101," seol  ","",  seol);    debug(F101," ctlq  ","",  ctlq);    debug(F101," ebq   ","",   ebq);    debug(F101," ebqflg","",ebqflg);    debug(F101," bctr  ","",  bctr);    debug(F101," rptq  ","",  rptq);    debug(F101," rptflg","",rptflg);    debug(F101," lscapu","",lscapu);    debug(F101," atcapu","",atcapu);    debug(F101," lpcapu","",lpcapu);    debug(F101," swcapu","",swcapu);    debug(F101," wslotn","", wslotn);}/*  R D E B U -- Debugging display of rpar() values  */VOIDrdebu(d,len) CHAR *d; int len; {    debug(F111,"rpar: data",d,len);    debug(F101," rpsiz ","", xunchar(d[0]));    debug(F101," rtimo ","", rtimo);    debug(F101," mypadn","",mypadn);    debug(F101," mypadc","",mypadc);    debug(F101," eol   ","",   eol);    debug(F101," ctlq  ","",  ctlq);    debug(F101," sq    ","",    sq);    debug(F101," ebq   ","",   ebq);    debug(F101," ebqflg","",ebqflg);    debug(F101," bctr  ","",  bctr);    debug(F101," rptq  ","",  d[8]);    debug(F101," rptflg","",rptflg);    debug(F101," capas ","", capas);    debug(F101," bits  ","",d[capas]);    debug(F101," lscapu","",lscapu);    debug(F101," atcapu","",atcapu);    debug(F101," lpcapu","",lpcapu);    debug(F101," swcapu","",swcapu);    debug(F101," wslotr","", wslotr);    debug(F101," rpsiz(extended)","",rpsiz);}#ifdef COMMENT/*  C H K E R R  --  Decide whether to exit upon a protocol error  */VOIDchkerr() {    if (backgrd && !server) fatal("Protocol error");}#endif /* COMMENT *//*  F A T A L  --  Fatal error message */VOIDfatal(msg) char *msg; {#ifdef VMS#ifndef NOICP    if (strncmp(msg,"%CKERMIT",8)) {	sprintf(cmdbuf,"%%CKERMIT-E-FATAL, %s",msg);	msg = cmdbuf;    }#endif /* NOICP */    conoll(msg);#else    screen(SCR_EM,0,0L,msg);#endif /* VMS */    debug(F110,"fatal",msg,0);    tlog(F110,"Fatal:",msg,0L);    doexit(BAD_EXIT,xitsta | 1);	/* Exit indicating failure */}/*  B L D L E N  --  Make length-encoded copy of string  */char *bldlen(str,dest) char *str, *dest; {    int len;    len = (int)strlen(str);    *dest = tochar(len);    strcpy(dest+1,str);    return(dest+len+1);}/*  S E T G E N  --  Construct a generic command  */CHAR#ifdef CK_ANSICsetgen(char type,char * arg1, char * arg2, char * arg3)#elsesetgen(type,arg1,arg2,arg3) char type, *arg1, *arg2, *arg3;#endif /* CK_ANSIC *//* setgen */ {    char *upstr, *cp;    cp = cmdstr;    *cp++ = type;    *cp = NUL;    if (*arg1 != NUL) {	upstr = bldlen(arg1,cp);	if (*arg2 != NUL) {	    upstr = bldlen(arg2,upstr);	    if (*arg3 != NUL) bldlen(arg3,upstr);	}    }    cmarg = cmdstr;    debug(F110,"setgen",cmarg,0);    return('g');}#ifndef NOMSENDstatic char *mgbufp = NULL;/*  F N P A R S E  --  *//*  Argument is a character string containing one or more filespecs.  This function breaks the string apart into an array of pointers, one  to each filespec, and returns the number of filespecs.  Used by server  when it receives a GET command to allow it to process multiple file  specifications in one transaction.  Sets cmlist to point to a list of  file pointers, exactly as if they were command line arguments.  This version of fnparse treats spaces as filename separators.  If your  operating system allows spaces in filenames, you'll need a different  separator.  This version of fnparse mallocs a string buffer to contain the names.  It  cannot assume that the string that is pointed to by the argument is safe.*/intfnparse(string) char *string; {    char *p, *s, *q;    int r = 0, x;			/* Return code */    if (mgbufp) free(mgbufp);		/* Free this from last time. */    mgbufp = malloc((int)strlen(string)+2);    if (!mgbufp) {	debug(F100,"fnparse malloc error","",0);	return(0);    }	#ifndef NOICP#ifndef NOSPL    strncpy(fspec,string,FSPECL);	/* Make copy for \v(filespec) */#endif /* NOSPL */#endif /* NOICP */    s = string;				/* Input string */    p = q = mgbufp;			/* Point to the copy */    r = 0;				/* Initialize our return code */    while (*s == SP || *s == HT)	/* Skip leading spaces and tabs */      s++;    for (x = strlen(s);			/* Strip trailing spaces */	 (x > 1) && (s[x-1] == SP || s[x-1] == HT);	 x--)      s[x-1] = NUL;    while (1) {				/* Loop through rest of string */	if (*s == CMDQ) {		/* Backslash (quote character)? */	    if ((x = xxesc(&s)) > -1) {	/* Go interpret it. */		*q++ = (char) x;	/* Numeric backslash code, ok */	    } else {			/* Just let it quote next char */		s++;			/* get past the backslash */		*q++ = *s++;		/* deposit next char */	    }	    continue;	} else if (*s == SP || *s == NUL) { /* Unquoted space or NUL? */	    *q++ = NUL;			/* End of output filename. */	    msfiles[r] = p;		/* Add this filename to the list */	    debug(F111,"fnparse",msfiles[r],r);	    r++;			/* Count it */	    if (*s == NUL) break;	/* End of string? */	    while (*s == SP) s++;	/* Skip repeated spaces */	    p = q;			/* Start of next name */	    continue;	} else *q++ = *s;		/* Otherwise copy the character */	s++;				/* Next input character */    }    debug(F101,"fnparse r","",r);    msfiles[r] = "";			/* Put empty string at end of list */    cmlist = msfiles;    return(r);}#endif /* NOMSEND */char *					/* dbchr() for DEBUG SESSION */dbchr(c) int c; {    static char s[8];    char *cp = s;    c &= 0xff;    if (c & 0x80) {			/* 8th bit on */	*cp++ = '~';	c &= 0x7f;    }    if (c < SP) {			/* Control character */	*cp++ = '^';	*cp++ = ctl(c);    } else if (c == DEL) {	*cp++ = '^';	*cp++ = '?';    } else {				/* Printing character */	*cp++ = c;    }    *cp = '\0';				/* Terminate string */    cp = s;				/* Return pointer to it */    return(cp);}/*  C K H O S T  --  Get name of local host (where C-Kermit is running)  *//*  Call with pointer to buffer to put hostname in, and length of buffer.  Copies hostname into buffer on success, puts null string in buffer on  failure.*/#ifdef BSD44#define BSD4#undef ATTSV#endif /* BSD44 */#ifdef ATTSV#include <sys/utsname.h>#endif /* ATTSV */VOIDckhost(vvbuf,vvlen) char * vvbuf; int vvlen; {    char *g;#ifdef VMS    int x;#endif /* VMS */#ifdef ATTSV    struct utsname hname;#endif /* ATTSV */#ifdef datageneral    int ac0 = (char *) vvbuf, ac1 = -1, ac2 = 0;#endif /* datageneral */    *vvbuf = NUL;#ifdef ATTSV    if (uname(&hname) > -1) strncpy(vvbuf,hname.nodename,vvlen);#else#ifdef BSD4    if (gethostname(vvbuf,vvlen) < 0) *vvbuf = NUL;#else#ifdef VMS    g = getenv("SYS$NODE");    if (g) strncpy(vvbuf,g,vvlen);    x = (int)strlen(vvbuf);    if (x > 1 && vvbuf[x-1] == ':' && vvbuf[x-2] == ':') vvbuf[x-2] = NUL;#else#ifdef datageneral    if (sys($HNAME,&ac0,&ac1,&ac2) == 0) /* successful */        vvlen = ac2 + 1;		/* enh - have to add one */#else

⌨️ 快捷键说明

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