📄 ckuusx.c
字号:
/* 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 STRATUS#ifndef MAC printf( " Ring Indicator (RI): %s\r\n",(y & BM_RNG) ? "On": "Off");#endif /* MAC */ printf( " Data Terminal Ready (DTR): %s\r\n",#ifdef NT "(unknown)"#else /* NT */ (y & BM_DTR) ? "On": "Off"#endif /* NT */ );#ifndef MAC printf( " Request To Send (RTS): %s\r\n",#ifdef NT "(unknown)"#else /* NT */ (y & BM_RTS) ? "On": "Off"#endif /* NT */ );#endif /* MAC */#endif /* STRATUS */ }#ifdef BETATEST#ifdef CK_TAPI if (tttapi && !tapipass) { LPDEVCFG lpDevCfg = NULL; LPCOMMCONFIG lpCommConfig = NULL; LPMODEMSETTINGS lpModemSettings = NULL; DCB * lpDCB = NULL; if (cktapiGetModemSettings(&lpDevCfg,&lpModemSettings, &lpCommConfig,&lpDCB)) { printf("\n"); cktapiDisplayModemSettings(lpDevCfg,lpModemSettings, lpCommConfig,lpDCB); } }#endif /* CK_TAPI */#endif /* BETATEST */}#endif /* NOSHOW */#endif /* NOLOCAL */#ifndef NOXFER/* 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); debug(F101," whatru","", whatru);}/* 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 */#endif /* NOXFER *//* F A T A L -- Fatal error message */VOIDfatal(msg) char *msg; { extern int initflg; if (!msg) msg = ""; debug(F111,"fatal",msg,initflg); if (!initflg) /* In case called from prescan. */ sysinit();#ifdef VMS if (strncmp(msg,"%CKERMIT",8)) conol("%CKERMIT-E-FATAL, "); conoll(msg);#else /* !VMS */ conoll(msg);#endif /* VMS */ debug(F111,"fatal",msg,xitsta); tlog(F110,"Fatal:",msg,0L);#ifdef OS2 if (xfrbel) bleep(BP_FAIL); sleep(1); if (xfrbel) bleep(BP_FAIL);#endif /* OS2 */ doexit(BAD_EXIT,xitsta | 1); /* Exit indicating failure */}#ifndef NOXFER/* 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); if (len > 94) *dest = SP; else *dest = (char) tochar(len); strcpy(dest+1,str); return(dest+len+1);}/* S E T G E N -- Construct a generic command *//* Call with Generic command character followed by three string arguments. Trailing strings are allowed to be empty (""). Each string except the last non-empty string must be less than 95 characters long. The final nonempty string is allowed to be longer.*/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;#ifdef DYNAMIC if (!cmdstr) if (!(cmdstr = malloc(MAXSP + 1))) fatal("setgen: can't allocate memory");#endif /* DYNAMIC */ cp = cmdstr; *cp++ = type; *cp = NUL; if (!arg1) arg1 = ""; if (!arg2) arg2 = ""; if (!arg3) arg3 = ""; 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');}#endif /* NOXFER */#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 */#ifdef RECURSIVE debug(F111,"fnparse",string,recursive);#endif /* RECURSIVE */ 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 ckstrncpy(fspec,string,fspeclen); /* 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++ = (char) ctl(c); } else if (c == DEL) { *cp++ = '^'; *cp++ = '?'; } else { /* Printing character */ *cp++ = (char) 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 SVORPOSIX#ifndef BSD44#ifndef apollo#include <sys/utsname.h>#endif /* apollo */#endif /* BSD44 */#else#ifdef BELLV10#include <utsname.h>#endif /* BELLV10 */#endif /* SVORPOSIX*/#ifdef CKSYSLOGextern char uidbuf[], * clienthost;#endif /* CKSYSLOG */VOIDckhost(vvbuf,vvlen) char * vvbuf; int vvlen; {#ifndef NOPUSH extern int nopush;#ifndef NOSERVER extern int en_hos;#endif /* NOSERVER */#endif /* NOPUSH */#ifdef pdp11 *vvbuf = NUL;#else /* Everything else - rest of this routine */ char *g;#ifdef VMS int x;#endif /* VMS */#ifdef SVORPOSIX#ifndef BSD44#ifndef _386BSD#ifndef APOLLOSR10 struct utsname hname;#endif /* APOLLOSR10 */#endif /* _386BSD */#endif /* BSD44 */#endif /* SVORPOSIX */#ifdef datageneral int ac0 = (char *) vvbuf, ac1 = -1, ac2 = 0;#endif /* datageneral */#ifndef NOPUSH if (getenv("CK_NOPUSH")) { /* No shell access allowed */ nopush = 1; /* on this host... */#ifndef NOSERVER en_hos = 0;#endif /* NOSERVER */ }#endif /* NOPUSH */ *vvbuf = NUL; /* How let's get our host name ... */#ifndef BELLV10 /* Does not have gethostname() */#ifndef OXOS#ifdef SVORPOSIX#ifdef APOLLOSR10 ckstrncpy(vvbuf,"Apollo",vvlen);#else#ifdef BSD44 if (gethostname(vvbuf,vvlen) < 0) *vvbuf = NUL;#else#ifdef _386BSD if (gethostname(vvbuf,vvlen) < 0) *vvbuf = NUL;#else#ifdef QNX#ifdef TCPSOCKET if (gethostname(vvbuf,vvlen) < 0) *vvbuf = NUL;#else if (uname(&hname) > -1) ckstrncpy(vvbuf,hname.nodename,vvlen);#endif /* TCPSOCKET */#else /* SVORPOSIX but not _386BSD or BSD44 */ if (uname(&hname) > -1) ckstrncpy(vvbuf,hname.nodename,vvlen);#endif /* QNX */#endif /* _386BSD */#endif /* BSD44 */#endif /* APOLLOSR10 */#else /* !SVORPOSIX */#ifdef BSD4 if (gethostname(vvbuf,vvlen) < 0) *vvbuf = NUL;#else /* !BSD4 */#ifdef VMS g = getenv("SYS$NODE"); if (g) ckstrncpy(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#ifdef OS2 /* OS/2 */ g = os2_gethostname(); if (g) ckstrncpy(vvbuf,g,vvlen);#else /* OS2 */#ifdef OSK#ifdef TCPSOCKET if (gethostname(vvbuf, vvlen) < 0) *vvbuf = NUL;#endif /* TCPSOCKET */#endif /* OSK */#endif /* OS2 */#endif /* datageneral */#endif /* VMS */#endif /* BSD4 */#endif /* SVORPOSIX */#else /* OXOS */ /* If TCP/IP is not installed, gethostname() fails, use uname() */ if (gethostname(vvbuf,vvlen) < 0) { if (uname(&hname) > -1) ckstrncpy(vvbuf,hname.nodename,vvlen); else *vvbuf = NUL; }#endif /* OXOS */#endif /* BELLV10 */ if (*vvbuf == NUL) { /* If it's still empty */ g = getenv("HOST"); /* try this */ if (g) ckstrncpy(vvbuf,g,vvlen); } vvbuf[vvlen-1] = NUL; /* Make sure result is terminated. */#endif /* pdp11 */}#ifdef BSD44#undef BSD4#define ATTSV#endif /* BSD44 *//* A S K M O R E -- Poor person's "more". Returns 0 if no more, 1 if more wanted.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -