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

📄 ckuus3.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
		  makestr(&dialldp,"9");		if (!dialixp) 		/* International dialing prefix */		  makestr(&dialixp,"990");	    } else {			/* Everywhere else ... */		if (!dialldp) {		    if (dialldp = malloc(4))		      strcpy(dialldp,"0");		}		if (!dialixp) {		    if (dialixp = malloc(4))		      strcpy(dialixp,"00");		}	    }	}	return(success = 1);      case XYDIXP:			/* DIAL INTL-PREFIX */	return(dialstr(&dialixp,"International dialing prefix"));      case XYDIXS:			/* DIAL INTL-SUFFIX */	return(dialstr(&dialixs,"International dialing suffix"));      case XYDLDP:			/* DIAL INTL-PREFIX */	return(dialstr(&dialldp,"Long-distance dialing prefix"));      case XYDLDS:			/* DIAL INTL-SUFFIX */	return(dialstr(&diallds,"Long-distance dialing suffix"));      case XYDPXX:			/* DIAL PBX-EXCHANGE */	return(dialstr(&dialpxx,"Exchange of PBX you are calling from"));      case XYDPXI:			/* DIAL PBX-INTERNAL-PREFIX */	return(dialstr(&dialpxi,		       "Internal-call prefix of PBX you are calling from"));      case XYDPXO:			/* DIAL PBX-OUTSIDE-PREFIX */	return(dialstr(&dialpxo,		       "Outside-line prefix of PBX you are calling from"));      case XYDSFX:			/* DIAL INTL-SUFFIX */	return(dialstr(&dialsfx," Telephone number suffix for dialing"));      case XYDSRT:			/* DIAL SORT */	return(success = seton(&dialsrt));      case XYDTFC: {			/* DIAL TOLL-FREE-AREA-CODE  */	  int n, i;			/* (zero or more of them...) */	  char * p[MAXTOLLFREE];	/* Temporary pointers */	  for (n = 0; n < MAXTOLLFREE; n++) {	      if ((x = cmfld(		    "Toll-free area code in the country you are calling from",		       "",&s,xxstring)) < 0)		break;	      if (s) {		  int k;		  k = (int) strlen(s);		  if (k > 0) {		      if (p[n] = malloc(k + 1))			strcpy(p[n], s);		  } else break;	      } else break;	  }	  if (x == -3) {		/* Command was successful */	      for (i = 0; i < ntollfree; i++) /* Remove old list, if any */		if (dialtfc[i]) {		    free(dialtfc[i]);		    dialtfc[i] = NULL;		}	      ntollfree = n;		/* New count */	      for (i = 0; i < ntollfree; i++) /* New list */		dialtfc[i] = p[i];	      return(success = 1);	  } else {			/* Parse error, undo everything */	      for (i = 0; i < n; i++)		if (p[i]) free(p[i]);	      return(x);	  }      }      case XYDTFP:			/* TOLL-FREE-PREFIX */	return(dialstr(&dialtfp,		       " Long-distance prefix for toll-free dialing"));      case XYDCON:			/* CONNECT */	z = -1;	if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y);	if (y != CAR_OFF)		/* AUTO or ON? */	  if ((z = cmkey(qvtab,nqvt,"","verbose",xxstring)) < 0) return(z);	if ((x = cmcfm()) < 0) return(x);	if (z > -1)	  dialcq = z;	dialcon = y;	return(success = 1);      case XYDRSTR:			/* RESTRICT */	if ((y = cmkey(drstrtab,4,"","none",xxstring)) < 0) return(y);	if ((x = cmcfm()) < 0) return(x);	dialrstr = y;	return(success = 1);      default:	printf("?Unexpected SET DIAL parameter\n");	return(-9);    }}#ifdef CK_TAPIstatic int				/* Set DIAL command options */settapi() {    int x,y;    char *s;    if (!TAPIAvail) {	printf("\nTAPI is unavailable on this system.\n");	return(-9);    }    if ((y = cmkey(tapitab,ntapitab,"MS TAPI option","line",xxstring)) < 0)      return(y);    switch (y) {      case XYTAPI_LIN:			/* TAPI LINE */	return setlin(XYTAPI_LIN,1);	break;      case XYTAPI_LOC: {		/* TAPI LOCATION */	  extern char tapiloc[] ;	  extern int tapilocid ;	  int i=0, j = 9999, k = -1 ;	  cktapiBuildLocationTable(&tapiloctab, &ntapiloc);	  if (!tapiloctab || !ntapiloc) {	      printf("\nNo TAPI Locations are configured for this system\n");	      return(-9) ;	  }	  /* Find out what the lowest numbered TAPI location is */	  /* and use it as the default. */	  for (i = 0; i < ntapiloc; i++) {	      if (tapiloctab[i].kwval < j) {		  j = tapiloctab[i].kwval;		  k = i;	      }	  }			  if (k >= 0)	    s = tapiloctab[k].kwd;	  else	    s = "";	  if ((y = cmkey(tapiloctab,ntapiloc,			 "TAPI location",s,xxstring)) < 0)	    return(y);	  y = lookup(tapiloctab,s,ntapiloc,&x);	  if (y > -1) {	      strcpy(tapiloc,tapilinetab[x].kwd);	      tapilocid = y;	  }	  if ((x = cmcfm()) < 0) 	    return(x);        }	break;      case XYTAPI_CFG:			/* TAPI CONFIGURE-LINE */	if ((x = cmcfm()) < 0) return(x);	break;      case XYTAPI_DIAL:			/* TAPI DIALING-PROPERTIES */	if ((x = cmcfm()) < 0) return(x);	break;    }    return(1);}#endif /* CK_TAPI */#ifndef NOSHOWint					/* SHOW MODEM */shomodem() {    extern MDMINF * modemp[];    MDMINF * p;    int x, n;    char c;    long zz;    shmdmlin();    printf("\n");    p = (mdmtyp > 0) ? modemp[mdmtyp - 1] : NULL;    if (p) {	printf(" %s\n\n", dialname ? dialname : p->name);	printf(" Modem carrier-watch:    ");	if (carrier == CAR_OFF) printf("off\n");	else if (carrier == CAR_ON) printf("on\n");	else if (carrier == CAR_AUT) printf("auto\n");	else printf("unknown\n");	printf(" Modem capabilities:    ");	zz = dialcapas ? dialcapas : p->capas;	if (!zz) {	    printf(" (none)");	} else {	    if (zz & CKD_AT) printf(" AT");	    if (zz & CKD_V25) printf(" ITU");	    if (zz & CKD_SB) printf(" SB");	    if (zz & CKD_EC) printf(" EC");	    if (zz & CKD_DC) printf(" DC");	    if (zz & CKD_HW) printf(" HWFC");	    if (zz & CKD_SW) printf(" SWFC");	    if (zz & CKD_KS) printf(" KS");	    if (zz & CKD_TB) printf(" TB");	}	printf("\n Modem maximum-speed:    ");	zz = (dialmax > 0L) ? dialmax : p->max_speed;	if (zz > 0)	  printf("%ld bps\n", zz);	else	  printf("(unknown)\n");	printf(" Modem error-correction: %s\n", dialec ? "on" : "off");	printf(" Modem compression:      %s\n", dialdc ? "on" : "off");	printf(" Modem speed-matching:   %s",   mdmspd ? "on" : "off");	printf(" (interface speed %s)\n", mdmspd ? "changes" : "is locked");	printf(" Modem flow-control:     ");	if (dialfc == FLO_NONE) printf("none\n");        else if (dialfc == FLO_XONX) printf("xon/xoff\n");	else if (dialfc == FLO_RTSC) printf("rts/cts\n");	else if (dialfc == FLO_AUTO) printf("auto\n");	printf(" Modem kermit-spoof:     %s\n", dialksp ? "on" : "off");	c = (char) (x = (dialesc ? dialesc : p->esc_char));	printf(" Modem escape-character: %d", x);	if (isprint(c))	  printf(" (= \"%c\")",c);	printf("\n\nMODEM COMMANDs (* = set automatically by SET MODEM TYPE):\n\n");	printf(" %c Init-string:          ", dialini ? ' ' : '*' );	shods(dialini ? dialini : p->wake_str);    printf(" %c Dial-mode-string:     ", dialmstr ? ' ' : '*' );    shods(dialmstr ? dialmstr : p->dmode_str);    printf(" %c Dial-mode-prompt:     ", dialmprmt ? ' ' : '*' );    shods(dialmprmt ? dialmprmt : p->dmode_prompt);    printf(" %c Dial-command:         ", dialcmd ? ' ' : '*' );	shods(dialcmd ? dialcmd : p->dial_str);	printf(" %c Compression on:       ", dialdcon ? ' ' : '*' );	shods(dialdcon ? dialdcon : p->dc_on_str);	printf(" %c Compression off:      ", dialdcoff ? ' ' : '*' );	shods(dialdcoff ? dialdcoff : p->dc_off_str);	printf(" %c Error-correction on:  ", dialecon ? ' ' : '*' );	shods(dialecon ? dialecon : p->ec_on_str);	n = local ? 19 : 20;	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Error-correction off: ", dialecoff ? ' ' : '*' );	shods(dialecoff ? dialecoff : p->ec_off_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Autoanswer on:        ", dialaaoff ? ' ' : '*' );	shods(dialaaon ? dialaaon : p->aa_on_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Autoanswer off:       ", dialaaoff ? ' ' : '*' );	shods(dialaaoff ? dialaaoff : p->aa_off_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Hangup-command:       ", dialhcmd ? ' ' : '*' );	shods(dialhcmd ? dialhcmd : p->hup_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Hardware-flow:        ", dialhwfc ? ' ' : '*' );	shods(dialhwfc ? dialhwfc : p->hwfc_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Software-flow:        ", dialswfc ? ' ' : '*' );	shods(dialswfc ? dialswfc : p->swfc_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c No-flow-control:      ", dialnofc ? ' ' : '*' );	shods(dialnofc ? dialnofc : p->nofc_str);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Pulse:                ", dialpulse ? ' ' : '*');	shods(dialpulse ? dialpulse : p->pulse);	if (++n > cmd_rows - 3) if (!askmore()) return(0); else n = 0;	printf(" %c Tone:                 ", dialtone ? ' ' : '*');	shods(dialtone ? dialtone : p->tone);	if (++n > cmd_rows - 4) if (!askmore()) return(0); else n = 0;	printf("\n For more info: SHOW DIAL and SHOW COMMUNICATIONS\n");    } else if (mdmtyp > 0) {	printf("Modem info for \"%s\" not filled in yet\n", gmdmtyp());    } else printf(" No modem selected, so DIAL and most SET MODEM commands have no effect.\n\ Use SET MODEM TYPE to select a modem.\n");    return(1);}#endif /* NOSHOW */#endif /* NODIAL */#ifndef NOSPLstatic int mdays[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };_PROTOTYP(static int setalarm,(long));#ifdef CK_ANSIC				/* SET ALARM */static intsetalarm(long xx)#elsestatic intsetalarm(xx) long xx;#endif /* CK_ANSIC *//* setalarm */ {    int yyyy, mm, dd, x;    char *s;    long zz;    debug(F101,"setalarm xx","",xx);    ck_alarm = 0L;			/* 0 = no alarm (in case of error) */    if (xx < 0L) {	printf("%ld - illegal value, must be 0 or positive\n", xx);	return(-9);    }    x = 8;				/* Get current date */    s = alrm_date;    if (zzstring("\\v(ndate)",&s,&x) < 0) {	printf("Internal date error, sorry.\n");	alrm_date[0] = SP;	return(-9);    }    x = 5;				/* Get current time */    s = alrm_time;    if (zzstring("\\v(ntime)",&s,&x) < 0) {	printf("Internal time error, sorry.\n");	alrm_time[0] = SP;	return(-9);    }    debug(F110,"SET ALARM date (1)",alrm_date,0);    debug(F110,"SET ALARM time (1)",alrm_time,0);    if ((zz = atol(alrm_time) + xx) < 0L) {	printf("Internal time conversion error, sorry.\n");	return(-9);    }    if (zz > 86400L) {			/* Alarm crosses midnight */	char d[10];			/* Local date buffer */	int lastday;			/* Last day of this month */	strncpy(d,alrm_date,8);		/* We'll have to change the date */	x = (zz / 86400L);		/* How many days after today */	dd = atoi((char *)(d+6));	/* Parse yyyymmdd */	d[6] = NUL;			/* into yyyy, mm, dd ... */	mm = atoi((char *)(d+4));	d[4] = NUL;	yyyy = atoi((char *)d);	/* How many days in this month */	lastday = mdays[mm];	if (mm == 2 && yyyy % 4 == 0)	/* Works thru 2099 AD... */	  lastday++;	if (dd + x > lastday) {		/* Dumb loop */	    int y;	    	    x -= (mdays[mm] - dd);	/* Deduct rest of this month's days */	    /* There's a more elegant way to do this... */	    while (1) {		mm++;			/* Next month */		if (mm > 12) {		/* Wrap around */		    mm = 1;		/* Jan, next year */		    yyyy++;		}		y = mdays[mm];		/* Days in new month */		if (mm == 2 && yyyy % 4 == 0) /* Feb in leap year */		  y++;			/* Works until 2100 AD */		if (x - y < 1)		  break;		x -= y;	    }	    dd = x;			/* Day of alarm month */	} else dd += x;	sprintf(alrm_date,"%04d%02d%02d",yyyy,mm,dd);	zz = zz % 86400L;    }    sprintf(alrm_time,"%ld",zz);    debug(F110,"SET ALARM date (2)",alrm_date,0);    debug(F110,"SET ALARM time (2)",alrm_time,0);    ck_alarm = xx;    return(1);}#endif /* NOSPL */#ifndef NOSETKEYintset_key() {				/* SET KEY */    int x, y;    int flag = 0;    int kc;				/* Key code */    char *s;				/* Key binding */#ifndef NOKVERBS    char *p;				/* Worker */#endif /* NOKVERBS */#ifdef OS2    extern int os2gks;    extern int mskkeys;    extern int initvik;#endif /* OS2 */    x_ifnum = 1;    y = cmnum("numeric key code, or the word CLEAR,","",10,&kc,xxstring);    x_ifnum = 0;    if (y < 0) {	debug(F111,"SET KEY",atmbuf,y);	if (y == -2) {			/* Not a valid number */	    if ((y = strlen(atmbuf)) < 0) /* Check for SET KEY CLEAR */	      return(-2);	    if (xxstrcmp(atmbuf,"clear",y))	      return(-2);	    if ((x = cmcfm()) < 0)	      return(x);	    for (y = 0; y < KMSIZE; y++) {		keymap[y] = (KEY) y;		macrotab[y] = NULL;	    }#ifdef OS2	    keymapinit();		/* Special OS/2 initializations */	    initvik = 1;		/* Update the VIK table */#endif /* OS2 */	    return(1);	} else if (y == -3) {		/* SET KEY <Return> */	    printf(" Press key to be defined: "); /* Prompt for a keystroke */#ifdef UNIX#ifdef NOSETBUF	    fflush(stdout);#endif /* NOSETBUF */#endif /* UNIX */	    conbin((char)escape);	/* Put terminal in binary mode */#ifdef OS2	    os2gks = 0;			/* Turn off Kverb preprocessing */#endif /* OS2 */	    kc = congks(0);		/* Get character or scan code */#ifdef OS2	    os2gks = 1;			/* Turn on Kverb preprocessing */#endif /* OS2 */	    concb((char)escape);	/* Restore terminal to cbreak mode */	    if (kc < 0) {		/* Check for error */		printf("?Error reading key\n");		return(0);	    }	    shokeycode(kc);		/* Show current definition */	    flag = 1;			/* Remember it's a multiline command */	} else				/* Error */	  return(y);    }    /* Normal SET KEY <scancode> <value> command... */#ifdef OS2    if ( mskkeys )      kc = msktock(kc);#endif /* OS2 */    if (kc < 0 || kc >= KMSIZE) {	printf("?key code must be between 0 and %d\n", KMSIZE - 1);	return(-9);    }    if (kc == escape) {	printf("Sorry, %d is the CONNECT-mode escape character\n",kc);	return(-9);    }#ifdef OS2    wideresult = -1;#endif /* OS2 */    if (flag) {	cmsavp(psave,PROMPTL);	cmsetp(" Enter new definition: ");	cmini(ckxech);    }  def_again:    if (flag) prompt(NULL);    if ((y = cmtxt("key definition,\n\or Ctrl-C to cancel this command,\n\or Enter to restore default definition",		   "",&s,NULL)) < 0) {	if (flag)			/* Handle parse errors */	  goto def_again;	else	  return(y);    }    s = brstrip(s);#ifndef NOKVERBS    p = s;				/* Save this place */

⌨️ 快捷键说明

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