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

📄 ckuus5.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
  directory listing or terminal emulation, are invoked directly from below.*/    sstate = 0;				/* Start with no start state. */#ifndef NOXFER#ifndef NOSPL    query = 0;				/* QUERY not active */#endif /* NOSPL */#ifndef NOHINTS    if (sndcmd && !success && hints && !interrupted && !fatalio && !cmdsrc()) {	int x = 0;        printf("\n*************************\n");	printf("SEND-class command failed.\n");	printf(" Packets sent: %d\n", spackets);	printf(" Retransmissions: %d\n",retrans);	printf(" Timeouts: %d\n", timeouts);	if (epktrcvd) {	    printf(" Transfer canceled by receiver.\n");	    printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);	}	printf(" Most recent local error: \"%s\"\n",ck_errstr());	printf(   "\nHINTS... If the preceding error message%s not explain the failure:\n",	       epktrcvd ? "s do" : " does"	       );#ifndef NOLOCAL	if (local) {	    if (rpackets == 0)	      printf(" . Did you start a Kermit receiver on the far end?\n");	    else	      printf(	      " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");	} else if (rpackets > 0) {	    if (flow == FLO_NONE)	     printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");	    else	     printf(" . Give me a SET FLOW NONE command and try again.\n");	}	x++;#endif /* NOLOCAL */#ifdef CK_SPEED	if (prefixing != PX_ALL && rpackets > 2) {	    printf(" . Try it again with SET PREFIXING ALL.\n");	    x++;	}#endif /* CK_SPEED */#ifdef STREAMING	if (streamed) {	    printf(" . Try it again with SET STREAMING OFF.\n");	    x++;	} else if (reliable) {	    printf(" . Try it again with SET RELIABLE OFF.\n");	    x++;	}#endif /* STREAMING */        if (clearrq > 0 && prefixing == PX_NON) {	    printf(" . Try it again with SET CLEAR-CHANNEL OFF.\n");	    x++;        }	if (!parity) {	    printf(" . Try it again with SET PARITY SPACE.\n");	    x++;	}	printf(" . %sive a ROBUST command and try again.\n",	       (x > 0) ? "As a last resort, g" : "G"	       );	printf("Also:\n");        printf(" . Be sure the source file has read permission.\n");	printf(" . Be sure the target directory has write permission.\n");	printf("(Use SET HINTS OFF to suppress hints.)\n");	printf("*************************\n\n");    }    if (getcmd && !success && hints && !interrupted && !fatalio && !cmdsrc()) {	int x = 0;	extern int urpsiz, wslotr;        printf("\n*************************\n");	printf("RECEIVE- or GET-class command failed.\n");	printf(" Packets received: %d\n", rpackets);	printf(" Damaged packets: %d\n", crunched);	printf(" Timeouts: %d\n", timeouts);	if (rpackets > 0)	  printf(" Packet length: %d\n", urpsiz);	if (epktrcvd) {	    printf(" Transfer canceled by sender.\n");	    printf(" Sender's message: \"%s\"\n",(char *)epktmsg);	}	printf(" Most recent local error: \"%s\"\n",ck_errstr());	printf(   "\nHINTS... If the preceding error message%s not explain the failure:\n",	       epktrcvd ? "s do" : " does"	       );#ifndef NOLOCAL	if (local) {	    if (rpackets == 0)	      printf(" . Did you start a Kermit sender on the far end?\n");	    else	      printf(	      " . Choose a different FLOW-CONTROL setting and try again.\n");	}	if (rpackets > 0 && urpsiz > 90)	  printf(" . Try smaller packets (SET RECEIVE PACKET-LENGH).\n");	if (rpackets > 0 && wslotr > 1 && !streamed)	  printf(" . Try a smaller window size (SET WINDOW).\n");	if (!local && rpackets > 0) {	    if (flow == FLO_NONE)	     printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");	    else	     printf(" . Give me a SET FLOW NONE command and try again.\n");	}	x++;#endif /* NOLOCAL */#ifdef STREAMING	if (streamed) {	    printf(" . Try it again with SET STREAMING OFF.\n");	    x++;	} else if (reliable && local) {	    printf(" . Try it again with SET RELIABLE OFF.\n");	    x++;        } else#endif /* STREAMING */	if (!parity) {	    printf(" . Try it again with SET PARITY SPACE.\n");	    x++;	}	printf((x > 0) ?	       " . As a last resort, give a ROBUST command and try again.\n" :	       " . Give a ROBUST command and try again.\n"	       );	printf("Also:\n");	printf(" . Be sure the target directory has write permission.\n");        printf(" . Try telling sender to SET PREFIXING ALL.\n");	printf(" . Try giving a ROBUST command to the sender.\n");	printf("(Use SET HINTS OFF to suppress hints.)\n");	printf("*************************\n\n");    }#endif /* NOHINTS */    getcmd = 0;    sndcmd = 0;    interrupted = 0;#endif /* NOXFER */    while (sstate == 0) {		/* Parse cmds until action requested */	debug(F100,"parse top","",0);#ifdef IKS_OPTION        if ((local &&	     !cmdsrc() &&	     is_tn &&	     TELOPT_ME(TELOPT_KERMIT) &&	     TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||	    (!local &&	     !cmdadl &&	     TELOPT_ME(TELOPT_KERMIT) &&	     TELOPT_SB(TELOPT_KERMIT).kermit.me_start)	    ) {            tn_siks(KERMIT_STOP);        }#endif /* IKS_OPTION */#ifndef NOXFER	if (autopath) {	    fnrpath = PATH_AUTO;	    autopath = 0;	}	remfile = 0;			/* Clear these in case REMOTE */	remappd = 0;			/* command was interrupted... */	rempipe = 0;	makestr(&snd_move,g_snd_move);	/* Restore these */	makestr(&rcv_move,g_rcv_move);	makestr(&snd_rename,g_snd_rename);	makestr(&rcv_rename,g_rcv_rename);#endif /* NOXFER */	diractive = 0;#ifndef NOSPL	askflag = 0;#endif /* NOSPL */    /* Take requested action if there was an error in the previous command */	setint();	debug(F101,"parser tlevel","",tlevel);	debug(F101,"parser cmd_rows","",cmd_rows);#ifndef NOLOCAL	if (wasclosed) {		/* If connection was just closed */#ifndef NOSPL	    int k;	    k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */	    if (k >= 0) {		/* If found, */		/* printf("ON_CLOSE CMD LOOP\n"); */		dodo(k,ckitoa(whyclosed),0); /* Set it up */	    }#endif /* NOSPL */	    whyclosed = WC_REMO;	    wasclosed = 0;        }#endif /* NOLOCAL */#ifndef NOSPL	xxdot = 0;			/* Clear this... */	if (success == 0) {	    if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {		printf("Command file terminated by error.\n");		popclvl();		if (cmdlvl == 0) return(0);	    }	    if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {		printf("Command error: macro terminated.\n");		popclvl();		if (m && (cmdlvl < inlevel))		  return((int) sstate);	    }	}	nulcmd = (m == 2);#else	if (success == 0 && tlevel > -1 && takerr[tlevel]) {	    printf("Command file terminated by error.\n");	    popclvl();	    cmini(ckxech);		/* Clear the cmd buffer. */	    if (tlevel < 0) 		/* Just popped out of cmd files? */	      return(0);		/* End of init file or whatever. */	}#endif /* NOSPL */#ifdef MAC	/* Check for TAKE initiated by menu. */	if ((tlevel == -1) && lfiles)	    startlfile();#endif /* MAC */        /* If in TAKE file, check for EOF */#ifndef NOSPL#ifdef MAC	if#else	while#endif /* MAC */	  ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */	       && (tlevel > -1)	       && feof(tfile[tlevel])) {	    popclvl();			/* pop command level */	    cmini(ckxech);		/* and clear the cmd buffer. */	    if (cmdlvl == 0) {		/* Just popped out of all cmd files? */		return(0);		/* End of init file or whatever. */	    }	}#ifdef MAC	miniparser(1);	if (sstate == 'a') {		/* if cmd-. cancel */	    debug(F100, "parser: cancel take due to sstate", "", sstate);	    sstate = '\0';	    dostop();	    return(0);			/* End of init file or whatever. */	}#endif /*  MAC */#else /* NOSPL */	if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */	    popclvl();			/* Pop up one level. */	    cmini(ckxech);		/* and clear the cmd buffer. */	    if (tlevel < 0) 		/* Just popped out of cmd files? */	      return(0);		/* End of init file or whatever. */ 	}#endif /* NOSPL */#ifndef NOSPL        if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */	    debug(F100,"parser macro","",0);	    maclvl = cmdstk[cmdlvl].lvl; /* Get current level */	    debug(F101,"parser maclvl","",maclvl);	    cbp = cmdbuf;		/* Copy next cmd to command buffer. */	    *cbp = NUL;	    if (*savbuf) {		/* In case then-part of 'if' command */		strcpy(cbp,savbuf);	/* was saved, restore it. */		*savbuf = '\0';	    } else {			/* Else get next cmd from macro def */		if (getncm(cbp,CMDBL) < 0) {		    if (m && (cmdlvl < inlevel))		      return((int) sstate);		    else /* if (!m) */ continue;		}	    }	    debug(F110,"cmdbuf from macro",cmdbuf,0);	} else if (cmdstk[cmdlvl].src == CMD_TF)#else	  if (tlevel > -1)#endif /* NOSPL */	  {#ifndef NOSPL	    if (*savbuf) {		/* In case THEN-part of IF command */		strcpy(cmdbuf,savbuf);	/* was saved, restore it. */		*savbuf = '\0';	    } else#endif /* NOSPL */	      /* Get next line from TAKE file */	      if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {		  if (tfcode < -1) {	/* Error */		      printf("?Error in TAKE command file: %s\n",			     (tfcode == -2) ? "Memory allocation failure" :			     "Line too long or contains NUL characters"			     );		      dostop();		  }		  continue;		/* -1 means EOF */	      }        /* If interactive, get next command from user. */	} else {			/* User types it in. */	    if (pflag) prompt(xxstring);	    cmini(ckxech);    	}    /* Now we know where next command is coming from. Parse and execute it. */	repars = 1;			/* 1 = command needs parsing */#ifndef NOXFER	displa = 0;			/* Assume no file transfer display */#endif /* NOXFER */	while (repars) {		/* Parse this cmd until entered. */	    debug(F101,"parser top of while loop","",0);	    /* In case of "send /recursive ./?<Ctrl-U>" etc */#ifdef RECURSIVE	    recursive = 0;			/* This is never sticky */#endif /* RECURSIVE */	    /* This might have been changed by a switch */	    if (g_matchdot > -1) {		matchdot = g_matchdot;		g_matchdot = -1;	    }	    if (saveask > -1) {		xaskmore = saveask;		saveask = -1;	    }	    cmres();			/* Reset buffer pointers. */#ifdef OS2#ifdef COMMENT	    /* we check to see if a macro is waiting to be executed */	    /* if so, we call domac on it */	    if (cmdmac) {		ckstrncpy(cmdbuf, cmdmac, CMDBL);		free(cmdmac);		cmdmac = NULL;	    }#endif /* COMMENT */#endif /* OS2 */#ifndef NOXFER	    bye_active = 0;#endif /* NOXFER */	    xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);	    debug(F101,"top-level cmkey2","",xx);	    if (xx == -5) {		yy = chktok(toktab);		debug(F101,"top-level cmkey token","",yy);		ungword();		switch (yy) {		  case '#': xx = XXCOM; break; /* Comment */		  case ';': xx = XXCOM; break; /* Comment */#ifndef NOSPL		  case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */		  case ':': xx = XXLBL; break; /* GOTO label */#endif /* NOSPL */#ifndef NOPUSH#ifdef CK_REDIR                  case '<':#endif /* CK_REDIR */                  case '@':                  case '!':		    if (!nopush) {			switch(yy) {#ifdef CK_REDIR			  case '<': xx = XXFUN; break; /* REDIRECT */#endif /* CK_REDIR */			  case '@':			  case '!': xx = XXSHE; break; /* Shell escape */			}		    }		    break;#endif /* NOPUSH */#ifdef CK_RECALL		  case '^': xx = XXREDO; break;#endif /* CK_RECALL */#ifndef NOSPL		  case '{': xx = XXMACRO; break;#endif /* NOSPL */		  default:		    if (!quiet) {			printf("\n?Invalid - \"%s\"\n",cmdbuf);#ifdef COMMENT#ifndef NOSPL			if (maclvl > -1 && cmdsrc() == 2)			  printf("Macro: %s; ",				 m_arg[maclvl][0] ?				 m_arg[maclvl][0] : "");#endif /* NOSPL */			if (tlevel > -1) {			    printf("Command file: %s, line %d\n",				   tfnam[tlevel] ? tfnam[tlevel] : "",				   tfline[tlevel]				   );			}#else			if (cmdsrc() > 0) {			    printf("Command stack:\n");			    shostack();			}#endif /* COMMENT */		    }		    xx = -2;		}	    }	    topcmd = xx;		/* Top-level command index */#ifndef NOSPL            /* Special handling for IF..ELSE */	    if (ifcmd[cmdlvl])		/* Count stmts after IF */	      ifcmd[cmdlvl]++;	    if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)	      ifcmd[cmdlvl] = 0;	    /* Execute the command and take action based on return code. */	    if (nulcmd) {		/* Ignoring this command? */		xx = XXCOM;		/* Make this command a comment. */	    }	    fnsuccess = 1;		/* For catching \function() errors */#endif /* NOSPL */	    zz = docmd(xx);		/* Parse rest of command & execute. */#ifndef NOSPL	    if (fnerror && !fnsuccess)	      success = 0;#endif /* NOSPL */	    debug(F101,"docmd returns","",zz);	    debug(F110,"cmdbuf",cmdbuf,"");	    debug(F110,"atmbuf",atmbuf,"");#ifdef CK_RECALL	    if (zz < 0 && cmflgs == 1)	      addcmd(cmdbuf);#endif /* CK_RECALL */#ifdef MAC	    if (tlevel > -1) {		if (sstate == 'a') {	/* if cmd-. cancel */		    debug(F110, "parser: cancel take, sstate:", "a", 0);		    sstate = '\0';		    dostop();		    return(0);		/* End of init file or whatever. */		}	    }#endif /* MAC */	    switch (zz) {	      case -4:			/* EOF (e.g. on redirected stdin) */		doexit(GOOD_EXIT,xitsta); /* ...exit successfully */	      case -1:			/* Reparse needed */		repars = 1;		/* Just set reparse flag and... */		continue;#ifdef OS2	      case -7:			/* They typed a disk letter */		if (!zchdir((char *)cmdbuf)) {		    perror((char *)cmdbuf);		    success = 0;		} else success = 1;		repars = 0;		continue;#endif /* OS2 */	      case -

⌨️ 快捷键说明

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