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

📄 ckuus6.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	if (cmdlvl > 0)			/* In VMS and not at top level, */	  conres();			/*  restore console again. */#endif /* VMS */	timelimit = 0;	return(success = y < 0 ? 0 : 1);    }}#endif /* NOSPL */#ifndef NOSPLintdoincr(cx) int cx; {			/* INCREMENT, DECREMENT */    char vnambuf[VNAML+1];		/* Buffer for variable names */    int eval = 0;    eval = (cx == XX_DECR || cx == XX_INCR);    if ((y = cmfld("Variable name","",&s, eval ? xxstring : NULL)) < 0) {	if (y == -3) {	    printf("?Variable name required\n");	    return(-9);	} else return(y);    }    ckstrncpy(vnambuf,s,VNAML);    if ((y = cmnum("by amount","1",10,&x,xxstring)) < 0)      return(y);    if ((y = cmcfm()) < 0)      return(y);    z = (cx == XX_INCR || cx == XXINC) ? 1 : 0;	/* Increment or decrement? */    if (incvar(vnambuf,x,z) < 0) {	printf("?Variable %s not defined or not numeric\n",vnambuf);	return(success = 0);    }    return(success = 1);}#endif /* NOSPL *//* Do the (_)DEFINE, (_)ASSIGN, and UNDEFINE commands */#ifndef NOSPLintdodef(cx) int cx; {    extern int xxdot;    extern char ppvnambuf[];    int doeval = 0;    char vnambuf[VNAML+1];		/* Buffer for variable names */    char *vnp;				/* Pointer to same */    int k, mydot;    mydot = xxdot;			/* Copy */    xxdot = 0;				/* and reset *//*  In case we got here from a command that begins like ".\%a", cmkey() has  already evaluated \%a, but we don't want that, so we retrieve the variable  name from a special pre-evaluation buffer in the command module, and we  undo the "unget word" that would be done because of the token, because if  the variable was defined, it will unget its value rather than its name.*/    s = NULL;    if (mydot && ppvnambuf[0] == '.' && ppvnambuf[1]) {	s = ppvnambuf+1;	unungw();    }    if (!s) {	if (cx == XXDFX || cx == XXASX)	  /* Evaluate variable name */	  y = cmfld("Macro or variable name","",&s,xxstring);	else	  /* Don't evaluate the variable name */	  y = cmfld("Macro or variable name","",&s,NULL);	if (y < 0) {	    if (y == -3) {		printf("?Variable name required\n");		return(-9);	    } else return(y);	}    }    k = strlen(s);    if (k > VNAML) {	printf("?Name too long: \"%s\"\n",s);	return(-9);    }    strcpy(vnambuf,s);    vnambuf[VNAML] = NUL;    vnp = vnambuf;    if (vnambuf[0] == CMDQ && (vnambuf[1] == '%' || vnambuf[1] == '&')) vnp++;    if (*vnp == '%' || *vnp == '&') {	if ((y = parsevar(vnp,&x,&z)) < 0) return(y);	if (cx == XXUNDEF) {		/* Undefine */	    if ((y = cmtxt("Text to be ignored","",&s,NULL)) < 0) return(y);	    delmac(vnp);	    return(success = 1);	}	debug(F101,"dodef parsevar x","",x);	if (mydot) {	    if ((doeval = cmkey(asgtab,nasgtab,"operator","=",NULL)) < 0)	      return(doeval);	    if (doeval > 0)		/* Type of assignment */	      cx = XXASS;	}	if (y == 1) {			/* Simple variable */	    if ((y = cmtxt("Definition of variable","",&s,NULL)) < 0)	      return(y);	    s = brstrip(s);	    debug(F110,"xxdef var name",vnp,0);	    debug(F110,"xxdef var def",s,0);	} else if (y == 2) {		/* Array element */	    if ((y = arraynam(vnp,&x,&z)) < 0) return(y);	    if (x == 96) {		printf("?Argument vector array is read-only\n");		return(-9);	    }	    if (chkarray(x,z) < 0) return(-2);	    if ((y = cmtxt("Definition of array element","",&s,NULL)) < 0)	      return(y);	    debug(F110,"xxdef array ref",vnp,0);	    debug(F110,"xxdef array def",s,0);	}    } else {				/* Macro */	if (cx == XXUNDEF) {		/* Undefine */	    if ((y = cmtxt("Text to be ignored","",&s,NULL)) < 0) return(y);	    delmac(vnp);	    return(success = 1);	}	if (mydot) {	    if ((doeval = cmkey(asgtab,nasgtab,"operator","=",NULL)) < 0)	      return(doeval);	    if (doeval > 0)	      cx = XXASS;	}	if ((y = cmtxt("Definition of macro","",&s,NULL)) < 0) return(y);	debug(F110,"xxdef macro name",vnp,0);	debug(F110,"xxdef macro def",s,0);#ifdef COMMENT	/* This did not require a close bracket */	if (*s == '{') {		/* Allow macro def to be bracketed. */	    s++;			/* If it is, remove the brackets. */	    y = (int)strlen(s);		/* FOR command depends on this! */	    if (y > 0 && s[y-1] == '}') s[y-1] = NUL;	}#else	s = brstrip(s);#endif /* COMMENT */    }    if (*s == NUL) {			/* No arg given, undefine */	delmac(vnp);			/* silently... */	return(success = 1);		/* even if it doesn't exist... */    }    /* Defining a new macro or variable */    if (cx == XXASS || cx == XXASX) {	/* ASSIGN rather than DEFINE? */	int t;	t = LINBUFSIZ-1;	lp = line;			/* If so, expand its value now */	zzstring(s,&lp,&t);	s = line;    }    if (doeval == 2) {			/* Arithmetic evaluation wanted too? */	strcpy(line,evala(s));	line[LINBUFSIZ] = NUL;    }    debug(F111,"calling addmac",s,(int)strlen(s));    y = addmac(vnp,s);			/* Add it to the appropriate table. */    if (y < 0) {	printf("?%s failed\n",(cx == XXASS || cx == XXASX) ?	       "ASSIGN" : "DEFINE");	return(success = 0);    } else if (cx == XXASX || cx == XXDFX) /* For _ASG or _DEF, */      return(1);			   /* don't change success variable */    else      return(success = 1);}#endif /* NOSPL */#ifndef NODIAL/*   L U D I A L  --  Lookup up dialing directory entry.   Call with string to look up and file descriptor of open dialing directory   file.  On success, returns number of matches found, with numbers stored   in an array accessible via getdnum().*/static char *dn_p[MAXDNUMS + 1];	/* Dial Number pointers */static char *dn_p2[MAXDNUMS + 1];	/* Converted dial number pointers */static int dn_x[MAXDNUMS + 1];		/* Type of call */static int dncount = 0;char * d_name = NULL;			/* Dial name pointer */char *					/* Get dial directory entry name */getdname() {    return(d_name ? d_name : "");}char *getdnum(n) int n; {			/* Get dial number n from directory */    if (n < 0 || n > dncount || n > MAXDNUMS)      return("");    else      return(dn_p[n]);}char *			/* Check area code for spurious leading digit */chk_ac(i,buf) int i; char buf[]; {    char *p;    if (!buf)      return("");    p = (char *) buf;			/* Country we are calling: */    if (i ==  44 ||			/* UK */	i ==  49 ||			/* Germany */	i ==  39 ||			/* Italy */	i ==  31 ||			/* Netherlands */	i == 351 ||			/* Portugal */	i ==  55 ||			/* Brazil */	i == 972 ||			/* Israel */	i ==  41 ||			/* Switzerland */	i ==  43 ||			/* Austria */	i ==  42 ||			/* Czech Republic */	i ==  36 ||			/* Hungary */	i ==  30 ||			/* Greece */	i == 352 ||			/* Luxembourg */	i ==  48 ||			/* Poland */	i ==  27 ||			/* South Africa */	i ==  33 ||			/* France (as of 1997) */	i ==  358			/* Finland (ditto) */	) {	if (buf[0] == '0')	  p++;    }    return(p);}/* Call Is Long Distance -- Expand this to cover 10-digit local dialing etc *//*   src  = area code of caller   dest = area code of callee   Returns:     0 if call is local     1 if call is long distance     2 if call is local but area code must be dialed anyway*/static intcallisld(src, dest) char * src, * dest; {    int i;    if (dialfld)			/* Force long distance? */      return(1);    if (!strcmp(src,dest)) {		/* Area codes are the same */	for (i = 0; i < nlocalac; i++)	/* Is AC in the lc-area-codes list? */	  if (!strcmp(src,diallcac[i]))	    return(2);			/* Yes so must be dialed */	return(0);			/* No so don't dial it. */    }    for (i = 0; i < nlocalac; i++)	/* ACs not the same so look in list */      if (!strcmp(dest,diallcac[i]))	/* Match */	return(2);			/* So local call with area code */    return(1);				/* Not local so long-distance */}char pdsfx[64] = { NUL, NUL };#ifndef NOSPLstatic char *xdial(s) char *s; {			/* Run dial string thru macro */    int x, m;    if (!dialmac)			/* Dial macro name given? */      return(NULL);    if ((x = mxlook(mactab,dialmac,nmac)) < 0) /* Is the macro defined? */      return(NULL);    m = maclvl;    x = dodo(x,s,0);			/* Set up the macro */    if (x > 0) {	while (maclvl > m)		/* Execute the parser */	  parser(1);	return(mrval[maclvl+1]);	/* Return the result */    }    return(NULL);}#endif /* NOSPL */static intdncvt(k,cx, prefix, suffix)    int k, cx, prefix, suffix; {        /* Dial Number Convert */    int i, j, n, what;			/* cx is top-level command index */    char *ss;                           /* prefix - add prefixes? */    char *p, *p2, *pxo;                 /* suffix - add suffixes? */    char *lac;    char *npr;    char *sfx;    /* char *psfx; */    char ccbuf[128];    int cc;    char acbuf[24];    char *acptr;    char outbuf[256];/*  First pass for strict (punctuation-based) interpretation.  If it fails, we try the looser (length-based) one.*/    dialtype = -1;    what = 0;				/* Type of call */    s = dn_p[k];			/* Number to be converted. */    debug(F111,"dncvt",s,k);    if (dn_p2[k]) {	free(dn_p2[k]);	dn_p2[k] = NULL;    }    if (!s) {	printf("Error - No phone number to convert\n");	return(-1);    }    npr = (prefix && dialnpr) ? dialnpr : "";    sfx = (suffix && dialsfx) ? dialsfx : "";    /* if (partial) psfx = dialsfx ? dialsfx : ""; */    pxo = (prefix && dialpxo) ? dialpxo : "";    lac = diallac ? diallac : "";	/* Local area code */    outbuf[0] = NUL;			/* Initialize conversion buffer */    ss = s;				/* Remember original string */    if (*s != '+') {			/* Literal number */	dn_x[k] = DN_UNK;		/* Sort key is "unknown". */	sprintf(outbuf,			/* Sandwich it between */		"%s%s%s%s",		/* DIAL PREFIX and SUFFIX */		pxo,npr,s,sfx		);#ifdef CK_TAPI	if (tttapi &&			/* TAPI does its own conversions */	    !tapipass &&		/* if not in passthru mode */	    tapiconv == CK_AUTO ||	/* and TAPI conversions are AUTO */	    tapiconv == CK_ON		/* OR if TAPI conversions are ON */	    ) {	    char * p = NULL;	    dialtype = -2;	    if (!cktapiConvertPhoneNumber(dn_p[k], &p))	      return(-1);	    makestr(&dn_p2[k], p);	    if (p) free(p);	    return(0);	} else#endif /* CK_TAPI */	  makestr(&dn_p2[k], outbuf);	/* Not TAPI */	dialtype = what;	return(0);			/* Done. */    }    i = 0;				/* Portable number */    s++;				/* Tiptoe past the plus sign */    ccbuf[0] = NUL;			/* Do country code first */    if (!diallcc) {			/* Do we know our own? */	if (cx != XXLOOK)	  printf("Error - prior SET DIAL COUNTRY-CODE command required\n");	return(-1);    }    /* Parse the number */    while (1) {				/* Get the country code */        while (*s == HT || *s == SP)	  s++;	if (!s)				/* Not in standard format */	  break;        if (*s == '(') {		/* Beginning of area code  */	    s++;			/* Skip past parenthesis   */	    ccbuf[i] = NUL;		/* End of country code */	    if (!s) {			/* Check for end of string */		printf("Error - phone number ends prematurely: \"%s\"\n",ss);		return(-1);	    }	    break;	} else {			/* Collect country code */	    if (isdigit(*s))	      ccbuf[i++] = *s;		/* copy this character */	    s++;	    if (!*s || i > 127)		/* watch out for memory leak */	      break;	}    }    cc = atoi(ccbuf);			/* Numeric version of country code */    i = 0;				/* Now get area code */    acbuf[0] = NUL;			/* Initialize area-code buffer */    acptr = acbuf;			/* and pointer. */    while (1) {        while (*s == HT || *s == SP)	/* Ignore whitespace */	  s++;	if (!s)				/* String finished */	  break;	if (*s == ')') {		/* End of area code  */	    s++;			/* Skip past parenthesis   */	    acbuf[i] = NUL;		/* Terminate area-code buffer */	    break;	} else {			/* Part of area code */	    if (isdigit(*s))		/* If it's a digit, */	      acbuf[i++] = *s;		/* copy this character */	    s++;			/* Point to next */	    if (!*s || i > 23)		/* Watch out for overflow */	      break;	}    }/*   Here we strip any leading 0 for countries that we know have   0 as a long-distance prefix and do not have any area codes that   start with 0 (formerly also ditto for "9" in Finland...)*/    i = atoi(ccbuf);    acptr = chk_ac(i,acbuf);    while (*s == HT || *s == SP)	/* Skip whitespace */      s++;/* printf("S=[%s], ACPTR=[%s]\n",s,acptr); */    if (*s && *acptr) {			/* Area code was delimited */	while (*s == '-' || *s == '.')	/* Skip past gratuitious punctuation */	  s++;	if (!*s) s--;			/* But not to end of string */	if (strcmp(diallcc,ccbuf)) {	/* Out of country? */	    if (!dialixp) {		/* Need intl-prefix */		if (cx != XXLOOK)		  printf("Error - No international dialing prefix defined\n");		return(-1);	    }	    what = dn_x[k] = DN_INTL;	    p  = (prefix && dialixp) ? dialixp : ""; /* Intl-prefix */	    p2 = (suffix && dialixs) ? dialixs : ""; /* Intl-suffix */	    sprintf(pdsfx,"%s%s",p2,sfx);	    sprintf(outbuf,		/* Form the final phone number */		    "%s%s%s%s%s%s%s%s",		    pxo,npr,p,ccbuf,acptr,s,p2,sfx		    );	} else if ((x = callisld(lac,acptr)) >= 1) { /* In-country LD */	    if (!diallac && cx != XXLOOK) { /* Don't know my own area code */		if (cc == 1)		  printf("WARNING - Prior SET DIAL AREA-CODE needed\n");	    }            if (x == 2) {		/* Local call with area code */	        what = dn_x[k] = DN_LOCAL;	/* Local-call */                p  = (prefix && diallcp) ? diallcp : ""; /* local-prefix */		p2 = (suffix && diallcs) ? diallcs : ""; /* local-suffix */            } else {	        what = dn_x[k] = DN_LONG;	/* Long-distance */                for (i = 0; i < ntollfree; i++) { /* But toll-free too? */                    if (!strcmp(acptr,dialtfc[i])) {                        what = dn_x[k] = DN_FREE;                        break;                    }                }                if (what == DN_FREE) {	/* Toll-free call */                    p = (prefix && dialtfp) ? dialtfp :                        ((prefix && dialldp) ? dialldp : "");                    p2 = "";		/* no suffix */                } else {			/* normal long distance */                    p  = (prefix && dialldp) ? dialldp : ""; /* ld-prefix */                    p2 = (suffix && diallds) ? diallds : ""; /* ld-suffix */                }            }

⌨️ 快捷键说明

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