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

📄 ckuus3.c

📁 操作系统源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  C K U U S 3 --  "User Interface" for Unix Kermit, part 3  */ /* Author: Frank da Cruz (SY.FDC@CU20B), Columbia University Center for Computing Activities, January 1985. Copyright (C) 1985, Trustees of Columbia University in the City of New York. Permission is granted to any individual or institution to use, copy, or redistribute this software so long as it is not sold for profit, provided this copyright notice is retained. */ /*  SET and REMOTE commands; screen, debug, interrupt, and logging functions */ /* Includes */ #include "ckcdeb.h"#include <stdio.h>#include <ctype.h>#include "ckcker.h"#include "ckucmd.h"#include "ckuusr.h"#ifdef UXIII#include <termio.h>#endif #ifdef datageneralextern int con_reads_mt,            /* Flag if console read asynch is active */           conint_ch,               /* The character read by asynch read */           conint_avl;              /* Flag that char available */#endif /* Variables */extern int size, spsiz, rpsiz, urpsiz, npad, timint, rtimo, speed,  local, server, lpcapr, fmask, cmask, backgrd,  flow, displa, binary, fncnv, delay, parity, deblog, escape, xargc,  turn, duplex, cxseen, czseen, nfils, ckxech, pktlog, seslog, tralog, stdouf,  turnch, bctr, bctu, dfloc, mdmtyp, keep, maxtry,  rptflg, ebqflg, warn, quiet, cnflg, timef, spsizf, mypadn; extern long filcnt, tlci, tlco, ffc, tfc, fsize;extern char *versio, *protv, *ckxv, *ckzv, *fnsv, *connv, *dftty, *cmdv;extern char *cmarg, *cmarg2, **xargv, **cmlist;extern CHAR stchr, mystch, sstate, padch, mypadc, eol, seol, ctlq;extern CHAR filnam[], ttname[];char *strcpy(); /* Declarations from cmd package */ extern char cmdbuf[];			/* Command buffer */ /* From main ckuser module... */ extern char line[100], *lp;		/* Character buffer for anything */extern char debfil[50],			/* Debugging log file name */ pktfil[50],				/* Packet log file name */ sesfil[50],				/* Session log file name */ trafil[50];				/* Transaction log file name */ extern int tlevel;			/* Take Command file level */extern FILE *tfile[];			/* Array of take command fd's */ /* Keyword tables for SET commands */  /* Block checks */ struct keytab blktab[] = {    "1", 1, 0,    "2", 2, 0,    "3", 3, 0}; /* Duplex keyword table */ struct keytab dpxtab[] = {    "full", 	 0, 0,    "half",      1, 0}; struct keytab filtab[] = {    "display", XYFILD, 0,    "names",   XYFILN, 0,    "type",    XYFILT, 0,    "warning", XYFILW, 0};int nfilp = (sizeof(filtab) / sizeof(struct keytab)); /* Send/Receive Parameters */ struct keytab srtab[] = {    "end-of-packet", XYEOL, 0,    "packet-length", XYLEN, 0,    "pad-character", XYPADC, 0,    "padding", XYNPAD, 0,    "start-of-packet", XYMARK, 0,    "timeout", XYTIMO, 0};int nsrtab = (sizeof(srtab) / sizeof(struct keytab)); /* Flow Control */ struct keytab flotab[] = {    "none",     0, 0,    "xon/xoff", 1, 0};int nflo = (sizeof(flotab) / sizeof(struct keytab));/*  Handshake characters  */ struct keytab hshtab[] = {    "bell", 007, 0,    "cr",   015, 0,    "esc",  033, 0,    "lf",   012, 0,    "none", 999, 0,			/* (can't use negative numbers) */    "xoff", 023, 0,    "xon",  021, 0};int nhsh = (sizeof(hshtab) / sizeof(struct keytab)); struct keytab fntab[] = {   		/* File naming */    "converted", 1, 0,    "literal",   0, 0}; struct keytab fttab[] = {		/* File types */    "binary",    1, 0,    "text",      0, 0}; extern struct keytab mdmtab[] ;		/* Modem types (in module ckudia.c) */extern int nmdm; /* Parity keyword table */ struct keytab partab[] = {    "even",    'e', 0,    "mark",    'm', 0,    "none",      0, 0,    "odd",     'o', 0,    "space",   's', 0};int npar = (sizeof(partab) / sizeof(struct keytab));  /* On/Off table */ struct keytab onoff[] = {    "off",       0, 0,    "on",        1, 0}; /* Incomplete File Disposition table */ struct keytab ifdtab[] = {    "discard",   0, 0,    "keep",      1, 0};/* Terminal parameters table */struct keytab trmtab[] = {    "bytesize",  0, 0};/*  D O P R M  --  Set a parameter.  *//* Returns:  -2: illegal input  -1: reparse needed   0: success*/doprm(xx) int xx; {    int x, y, z;    char *s; switch (xx) {  case XYEOL:	/* These have all been moved to set send/receive... */case XYLEN: 	/* Let the user know what to do. */case XYMARK:case XYNPAD:case XYPADC:case XYTIMO:    printf("...Use 'set send' or 'set receive' instead.\n");    printf("Type 'help set send' or 'help set receive' for more info.\n");    return(0); case XYIFD:				/* Incomplete file disposition */    if ((y = cmkey(ifdtab,2,"","discard")) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    keep = y;    return(0); case XYLINE:    if ((x = cmtxt("Device name",dftty,&s)) < 0) return(x);    ttclos();				/* close old line, if any was open */     x = strcmp(s,dftty) ? -1 : dfloc;	/* Maybe let ttopen figure it out... */    if (ttopen(s,&x,mdmtyp) < 0 ) { 	/* Can we open the new line? */	perror("Sorry, can't open line");	return(-2);			/* If not, give bad return */    }    if (x > -1) local = x;		/* Set local/remote status. */    strcpy(ttname,s);			/* OK, copy name into real place. */    if (!local) speed = -1;		/* If remote, say speed unknown. */    debug(F111,"set line ",ttname,local);    return(0); case XYCHKT:    if ((y = cmkey(blktab,3,"","1")) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    bctr = y;    return(0); case XYDEBU:    return(seton(&deblog)); case XYDELA:    y = cmnum("Number of seconds before starting to send","5",10,&x);    debug(F101,"XYDELA: y","",y);    return(setnum(&delay,x,y,94)); case XYDUPL:    if ((y = cmkey(dpxtab,2,"","full")) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    duplex = y;    return(0); case XYESC:    y = cmnum("Decimal ASCII code for escape character","",10,&x);    return(setcc(&escape,x,y));case XYFILE:    if ((y = cmkey(filtab,nfilp,"File parameter","")) < 0) return(y);    switch (y) {	int z;	case XYFILD:			/* Display */	    y = seton(&z);	    if (y < 0) return(y);	    quiet = !z;	    return(0); 	case XYFILN:			/* Names */	    if ((x = cmkey(fntab,2,"how to handle filenames","converted")) < 0)	    	return(x);	    if ((z = cmcfm()) < 0) return(z);	    fncnv = x;	    return(0); 	case XYFILT:			/* Type */	    if ((x = cmkey(fttab,2,"type of file","text")) < 0)	    	return(x);	    if ((y = cmnum("file byte size (7 or 8)","8",10,&z)) < 0)	        return(y);	    if (z != 7 && z != 8) {		printf("\n?The choices are 7 and 8\n");		return(-2);	    }	    if ((y = cmcfm()) < 0) return(y);	    binary = x;	    if (z == 7) fmask = 0177;	      else if (z == 8) fmask = 0377;	    return(0); 	case XYFILW:			/* Warning/Write-Protect */	    return(seton(&warn)); 	default:	    printf("?unexpected file parameter\n");	    return(-2);    } case XYFLOW:				/* Flow control */    if ((y = cmkey(flotab,nflo,"","xon/xoff")) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    flow = y;    return(0); case XYHAND:				/* Handshake */    if ((y = cmkey(hshtab,nhsh,"","none")) < 0) return(y);    if ((x = cmcfm()) < 0) return(x);    turn = (y > 0127) ? 0 : 1 ;    turnch = y;    return(0); case XYMODM:#ifndef MINIX    if ((x=cmkey(mdmtab,nmdm,"type of modem, direct means none","direct")) < 0)	return(x);#endif    if ((z = cmcfm()) < 0) return(z);    mdmtyp = x;    return(0);	case XYPARI:				/* Parity */    if ((y = cmkey(partab,npar,"","none")) < 0) return(y);    if ((x = cmcfm()) < 0) return(x); /* If parity not none, then we also want 8th-bit prefixing */     if (parity = y) ebqflg = 1; else ebqflg = 0;    return(0); case XYPROM:    if ((x = cmtxt("Program's command prompt","C-Kermit>",&s)) < 0) return(x);    if (*s == '\42') {			/* Quoted string? */	x = strlen(s) - 1;		/* Yes, strip quotes. */	if (*(s+x) == '\42')		/* This allows leading or trailing */	    *(s+x) = '\0';		/* blanks. */	    s++;	}    cmsetp(s);    return(0); case XYRETR:				/* Per-packet retry limit */    y = cmnum("Maximum retries per packet","10",10,&x);    return(setnum(&maxtry,x,y,94)); case XYTERM:				/* Terminal parameters */    if ((y = cmkey(trmtab,1,"","bytesize")) < 0) return(y);    switch (y) {      case 0:	if ((y = cmnum("bytesize for terminal connection","8",10,&x)) < 0)	  return(y);	if (x != 7 && x != 8) {	    printf("\n?The choices are 7 and 8\n");	    return(-2);	}	if ((y = cmcfm()) < 0) return(y);	if (x == 7) cmask = 0177;	else if (x == 8) cmask = 0377;        return(y);      default:       /* Add more cases when we think of more parameters */	return(-2);    }    /* SET SEND/RECEIVE... */ case XYRECV:case XYSEND:    if (xx == XYRECV)    	strcpy(line,"Parameter for inbound packets");    else    	strcpy(line,"Parameter for outbound packets");     if ((y = cmkey(srtab,nsrtab,line,"")) < 0) return(y);    switch (y) { case XYEOL:    y = cmnum("Decimal ASCII code for packet terminator","13",10,&x);    if ((y = setcc(&z,x,y)) < 0) return(y);    if (xx == XYRECV) eol = z; else seol = z;    return(y); case XYLEN:    y = cmnum("Maximum number of characters in a packet","90",10,&x);    if (xx == XYRECV) {			/* Receive... */	if ((y = setnum(&z,x,y,MAXRP)) < 0)	  return(y);	urpsiz = z;	rpsiz =  (z > 94) ? 94 : z;    } else {				/* Send... */	if ((y = setnum(&z,x,y,MAXSP)) < 0)	  return(y);	spsiz = z;			/*   Set it and flag that it was set */	spsizf = 1;			/*   to allow overriding Send-Init. */    }    if (z > 94 && !backgrd) printf("Extended-length packets requested\n");    return(y); case XYMARK:    y = cmnum("Decimal ASCII code for packet-start character","1",10,&x);    if ((y = setcc(&z,x,y)) < 0) return(y);    if (xx == XYRECV) stchr = z; else mystch = z;    return(y);case XYNPAD:				/* Padding */    y = cmnum("How many padding characters for inbound packets","0",10,&x);    if ((y = setnum(&z,x,y,94)) < 0) return(y);    if (xx == XYRECV) mypadn = z; else npad = z;    return(y); case XYPADC:				/* Pad character */    y = cmnum("Decimal ASCII code for inbound pad character","0",10,&x);    if ((y = setcc(&z,x,y)) < 0) return(y);    if (xx == XYRECV) mypadc = z; else padch = z;    return(y); case XYTIMO:    y = cmnum("Interpacket timeout interval","5",10,&x);    if ((y = setnum(&z,x,y,94)) < 0) return(y);    if (xx == XYRECV) {	timef = 1;	timint = z;    } else rtimo = z;    return(y);     } case XYSPEE:    if (!local) {	printf("\nSpeed setting can only be done on an external line\n");	printf("You must 'set line' before issuing this command\n");	return(0);    }	    lp = line;    sprintf(lp,"Baud rate for %s",ttname);    if ((y = cmnum(line,"",10,&x)) < 0) return(y);    if (y = (cmcfm()) < 0) return(y);    y = chkspd(x);    if (y < 0)     	printf("?Unsupported line speed - %d\n",x);    else {    	speed = y;	if (!backgrd) printf("%s: %d baud\n",ttname,speed);    }    return(0); default:    if ((x = cmcfm()) < 0) return(x);    printf("Not working yet - %s\n",cmdbuf);    return(0);    }}/*  C H K S P D  --  Check if argument is a valid baud rate  */ chkspd(x) int x; {    switch (x) {#ifndef AMIGA	case 0:#endif#ifndef datageneral	case 110:	case 150:	case 300:	case 600:	case 1200:	case 1800:	case 2400:	case 4800:	case 9600:#ifdef MINIX        case 19200:	case 38400:	case 57600:	case 115200:#else#ifdef apollo        case 19200:#else#ifdef AMIGA        case 19200:	case 38400:	case 57600:#else/* #ifdef B19200       (this high speed stuff needs much more work...)/*      case 19200:    (have to make corresponding changes in ckuus2, ckutio)/* #else/* #ifdef B38400/*      case 38400:/* #endif/* #endif*/#endif#endif#endif#endif#ifdef datageneral	case 50:	case 75:	case 134:	case 3600:	case 7200:	case 19200:	case 38400:#endif	    return(x);	default: #ifdef AMIGA	    if (ttsspd(x) > 0)	    {	    	printf("Warning: non-standard baud rate - %d\n", x);		return(x);	    }#endif	    return(-1);      }

⌨️ 快捷键说明

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