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

📄 ckuus3.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
struct keytab ftrtab[] = {		/* Feature table */#ifndef NOCSETS				/* 0 = we have it, 1 = we don't */"character-sets",	0, 0,#else"character-sets",	1, 0,#endif /* NOCSETS */#ifndef NOCYRIL"cyrillic",		0, 0,#else"cyrillic",		1, 0,#endif /* NOCYRIL */#ifndef NODEBUG"debug",		0, 0,#else"debug",		1, 0,#endif /* NODEBUG */#ifndef NODIAL"dial",			0, 0,#else"dial",			1, 0,#endif /* NODIAL */#ifdef DYNAMIC"dynamic-memory",       0, 0,#else"dynamic-memory",       1, 0,#endif /* DYNAMIC */#ifdef XXFWD"forward",              0, 0,#else"forward",              1, 0,#endif /* XXFWD */#ifdef CK_CURSES"fullscreen-display",	0, 0,#else"fullscreen-display",	1, 0,#endif /* CK_CURSES */#ifdef HEBREW"hebrew",               0, 0,#else"hebrew",               1, 0,#endif /* HEBREW */#ifndef NOHELP"help",			0, 0,#else"help",			1, 0,#endif /* NOHELP */#ifndef NOSPL"if-command",		0, 0,#else"if-command",		1, 0,#endif /* NOSPL */#ifndef NOJC#ifdef UNIX"job-control",		0, 0,#else"job-control",		1, 0,#endif /* UNIX */#else"job-control",		1, 0,#endif /* NOJC */#ifdef KANJI"kanji",		0, 0,#else"kanji",		1, 0,#endif /* KANJI */#ifndef NOCSETS"latin1",		0, 0,#else"latin1",		1, 0,#endif /* NOCSETS */#ifdef LATIN2"latin2",		0, 0,#else"latin2",		1, 0,#endif /* LATIN2 */#ifdef NETCONN"network",		0, 0,#else"network",		1, 0,#endif /* NETCONN */#ifndef NOPUSH"push",			0, 0,#else"push",			1, 0,#endif /* PUSH */#ifdef CK_RTSCTS"rts/cts",		0, 0,#else"rts/cts",		1, 0,#endif /* RTS/CTS */#ifdef CK_REDIR"redirect",             0, 0,#else"redirect",             1, 0,#endif /* CK_REDIR */#ifndef NOSCRIPT"script-command",	0, 0,#else"script-command",	1, 0,#endif /* NOSCRIPT */#ifndef NOSERVER"server-mode",		0, 0,#else"server-mode",		1, 0,#endif /* NOSERVER */#ifndef NOSHOW"show-command",		0, 0,#else"show-command",		1, 0,#endif /* NOSHOW */#ifndef NOXMIT"transmit",		0, 0,#else"transmit",		1, 0,#endif /* NOXMIT */#ifdef CK_XYZ"xyzmodem",		0, 0,#else"xyzmodem",		1, 0,#endif /* NOXMIT */"", 0, 0};int nftr = (sizeof(ftrtab) / sizeof(struct keytab)) - 1;struct keytab desttab[] = {		/* SET DESTINATION */    "disk",    DEST_D, 0,    "printer", DEST_P, 0,    "screen",  DEST_S, 0};int ndests =  (sizeof(desttab) / sizeof(struct keytab));#ifndef NOICP /* Used only with script programming items... */#ifndef NOSERVER			/* This is just to avoid some */#define CK_PARSDIR			/* "statement not reached" */#else					/* complaints... */#ifndef NODIAL#define CK_PARSDIR#endif /* NODIAL */#endif /* NOSERVER *//*  cx == 0 means dial directory  cx == 1 means network directory  cx == 2 means a directory path list*/static intparsdir(cx) int cx; {    int i, x, y, z, dd;			/* Workers */    int nxdir;    char *s;    char ** xdir;    char *pp[MAXGETPATH];		/* Temporary name pointers */#ifdef ZFNQFP    char dirpath[1024];			/* For fully qualified filenames */    struct zfnfp * fnp;#ifdef OS2    char * env;#endif /* OS2 */#endif /* ZFNQFP */    int max = 0;			/* Maximum number of things to parse */    char c;#ifndef NODIAL    if (cx == 0) {			/* Dialing */	nxdir = ndialdir;	xdir = dialdir;	max = MAXDDIR;    } else #ifdef NETCONN    if (cx == 1) {			/* Network */	nxdir = nnetdir;	xdir = netdir;	max = MAXDDIR;    } else #endif /* NETCONN */#endif /* NODIAL */#ifndef NOSERVER    if (cx == 2) {			/* GET path */	nxdir = ngetpath;	xdir = getpath;	max = MAXGETPATH;    } else				/* Called with invalid function code */#endif /* NOSERVER */      return(-2);#ifdef CK_PARSDIR    dd = 0;				/* Temporary name counter */    while (1) {	if (cx != 2) {			/* Dialing or Network Directory */#ifdef OS2    #ifdef NT	    env = getenv("K95PHONES");#else /* NT */	    env = getenv("K2PHONES");#endif /* NT */	    if (!env)	      env = getenv("K95PHONES");	    sprintf(dirpath,"%s%s%s;%s%s;%s;%s%s;%s;%s%s", 		    /* semicolon-separated path list */		    env?env:"",		    (env && env[strlen(env)-1]==';')?"":";",		    startupdir,		    startupdir, "PHONES/",		    inidir,		    inidir, "PHONES/",		    exedir,		    exedir, "PHONES/"		    );#else#ifdef UNIX	    y = 1024;	    s = dirpath;	    zzstring("\\v(home)",&s,&y);#endif /* UNIX */#endif /* OS2 */	    y = cmifip(		  "Names of one or more directory files, separated by spaces", 		       "",&s,&x,0,#ifdef OS2ORUNIX		       dirpath,#else		       NULL,#endif /* OS2ORUNIX */		       xxstring		       );	} else {	    x = 0;	    y = cmdir("Directory name","",&s,xxstring);	}	if (y < 0) {	    if (y == -3) {		/* EOL or user typed <CR> */		for (i = 0; i < max; i++) { /* Clear these */		    if (i < nxdir && xdir[i]) {			free(xdir[i]);		    }		    xdir[i] = (i < dd) ? pp[i] : NULL;		}#ifndef NODIAL		if (cx == 0)		  ndialdir = dd;#ifdef NETCONN		if (cx == 1)		  nnetdir = dd;#endif /* NETCONN */#endif /* NODIAL */#ifndef NOSERVER		if (cx == 2)		  ngetpath = dd;#endif /* NOSERVER */		return(success = 1);	    } else {			/* Parse error */		for (i = 0; i < dd; i++) {  /* Free temp storage */		    if (pp[i]) free(pp[i]); /* but don't change */		    pp[i] = NULL;           /* anything else */		}		return(y);	    }	}	if (x) {	    printf("?Wildcards not allowed\n");	    return(-9);	}#ifdef CK_TMPDIR	if (cx == 2 && !isdir(s)) {	    printf("?Not a directory - %s\n", s);	    return(-9);	}#endif /* CK_TMPDIR */#ifdef ZFNQFP	/* Get fully qualified pathname */	if (fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf)) {	    if (fnp->fpath)	      if ((int) strlen(fnp->fpath) > 0)		s = fnp->fpath;	}#endif /* ZFNQFP */	c = NUL;	x = strlen(s);	if (x > 0)			/* Get last char */	  c = s[x-1];	debug(F000,"parsdir s",s,c);	if ((pp[dd] = malloc(strlen(s)+2)) == NULL) {	    printf("?Internal error - malloc\n");	    for (i = 0; i < dd; i++) {  /* Free temp storage */		if (pp[i]) free(pp[i]);		pp[i] = NULL;	    }	    return(-9);	} else {			/* Have storage for name */	    strcpy(pp[dd],s);		/* Copy string into new storage */	    debug(F111,"parsdir pp[dd] 1",pp[dd],dd);	    if (cx == 2) {		/* If we are parsing directories */		char dirsep[2];		extern int myindex;	/* Append directory separator if */		extern struct sysdata sysidlist[]; /* it is missing...   */		debug(F101,"parsdir myindex","",myindex);		if (myindex > -1)		  if (sysidlist[myindex].sid_unixlike)		    if (c != sysidlist[myindex].sid_dirsep) {			dirsep[0] = sysidlist[myindex].sid_dirsep;			dirsep[1] = NUL;			strcat(pp[dd], (char *) dirsep);		    }	    }	    debug(F111,"parsdir pp[dd] 2",pp[dd],dd);	    if (++dd > max) {		printf("?Too many directories - %d max\n", max);		for (i = 0; i < dd; i++) {  /* Free temp storage */		    if (pp[i]) free(pp[i]);		    pp[i] = NULL;		}	    }	}    }#endif /* CK_PARSDIR */}#endif /* NOICP */#ifndef NOSERVERstatic intcklogin() {    int x;    char * s;    char username[LOGINLEN+1];    char password[LOGINLEN+1];    char account[LOGINLEN+1];    extern char * x_user, * x_passwd, * x_acct;    extern int x_login, x_logged;    username[0] = NUL;    password[0] = NUL;    account[0]  = NUL;    x = cmfld("username", "", &s, xxstring);    if (x != -3) {	if (x < 0)	  return(x);	if ((int)strlen(s) > LOGINLEN) {	    printf("\"%s\" - too long, %d max\n", s, LOGINLEN);	    return(-9);	}	strcpy(username,s);	x = cmfld("password", "", &s, xxstring);	if (x != -3) {	    if (x < 0)	      return(x);	    if ((int)strlen(s) > LOGINLEN) {		printf("\"%s\" - too long, %d max\n", s, LOGINLEN);		return(-9);	    }	    strcpy(password,s);	    x = cmfld("account", "", &s, xxstring);	    if (x != -3) {		if (x < 0)		  return(x);		if ((int)strlen(s) > LOGINLEN) {		    printf("\"%s\" - too long, %d max\n", s, LOGINLEN);		    return(-9);		}		strcpy(account,s);		if ((x = cmcfm()) < 0)		  return(x);	    }	}    }    makestr(&x_user,username);    makestr(&x_passwd,password);    makestr(&x_acct,account);    x_login = (x_user) ? 1 : 0;    x_logged = 0;    return(1);}#endif /* NOSERVER */#ifndef NOLOCALVOIDsetflow() {#ifndef NODIAL    MDMINF * p = NULL;    long bits = 0;#endif /* NODIAL */    if (!autoflow)			/* Only if FLOW is AUTO */      return;#ifdef VMS    flow = FLO_XONX;			/* Special for VMS */    return;#endif /* VMS */    if (network)			/* Network connection */      flow = FLO_NONE;			/* None for all non-VMS */    if (mdmtyp < 1) {			/* Direct connection */#ifdef CK_RTSCTS			/* If we can do RTS/CTS flow control */	flow = FLO_RTSC;		/* then do it */#else					/* Otherwise */	flow = FLO_XONX;		/* Use Xon/Xoff. */#endif /* CK_RTSCTS */	return;    }#ifndef NODIAL    bits = dialcapas;			/* Capability bits */    if (!bits) {			/* No bits? */	p = modemp[mdmtyp - 1];		/* Look in modem info structure */	if (p)	  bits = p->capas;    }    if (dialfc == FLO_AUTO) {		/* If DIAL flow is AUTO */#ifdef CK_RTSCTS			/* If we can do RTS/CTS flow control */	if (bits & CKD_HW)		/* and modem can do it too */	  flow = FLO_RTSC;		/* then switch to RTS/CTS */	else				/* otherwise */	  flow = FLO_XONX;		/* use Xon/Xoff. */#else	flow = FLO_XONX;		/* No RTS/CTS so use Xon/Xoff. */#endif /* CK_RTSCTS */    }#endif /* NODIAL */    return;}static intsetdcd() {    int x, y, z;    if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);    if (y == CAR_ON) {	x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring);	if (x < 0) return(x);    }    if ((x = cmcfm()) < 0) return(x);    carrier = ttscarr(y);    cdtimo = z;    return(1);}#endif /* NOLOCAL */extern struct keytab yesno[];extern int nyesno;intgetyesno(msg) char * msg; {		/* Ask question, get yes/no answer */    int x, y, z;#ifdef VMS/*  In VMS, whenever a TAKE file or macro is active, we restore the   original console modes so Ctrl-C/Ctrl-Y can work.  But here we  go interactive again, so we have to temporarily put them back.*/    if (cmdlvl > 0)      concb((char)escape);#endif /* VMS */          cmsavp(psave,PROMPTL);		/* Save old prompt */    cmsetp(msg);			/* Make new prompt */    z = 0;				/* Initialize answer to No. */    cmini(ckxech);			/* Initialize parser. */    do {	prompt(NULL);			/* Issue prompt. */	y = cmkey(yesno,nyesno,"","",NULL); /* Get Yes or No */	if (y < 0) {	    if (y == -4) {		/* EOF */		z = y;		break;	    } else if (y == -3)		/* No answer? */

⌨️ 快捷键说明

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