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

📄 ckcpro.w

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 W
📖 第 1 页 / 共 5 页
字号:
	    return(success = 0);	/* Return failure */	} else if (x == -9) {		/* User interrupted */	    errpkt((CHAR *)"User cancelled"); /* Send Error packet */	    window(1);			/* Set window size back to 1... */	    timint = s_timint;		/* Restore timeout */	    return(success = 0);	/* Failed */	} else if (x < 0) {		/* EOF (empty file) or interrupted */	    window(1);			/* put window size back to 1, */	    debug(F101,"<ssfile>Y cxseen","",cxseen);	    x = clsif();		/* If not ok, close input file, */	    if (x < 0)			/* treating failure as interruption */	      cxseen = 1;		/* Send EOF packet */	    seof(cxseen||czseen);	    BEGIN sseof;		/* and switch to EOF state. */	} else {			/* First data sent OK */	    BEGIN ssdata;		/* All ok, switch to send-data state */	}    }}<ssattr>Y {				/* Got ACK to A packet */    ffc = 0L;				/* Reset file byte counter */    debug(F101,"<ssattr>Y cxseen","",cxseen);    if (cxseen||czseen) {		/* Interrupted? */	debug(F101,"<sattr>Y canceling","",0);	x = clsif();			/* Close input file */	sxeof(1);			/* Send EOF(D) */	BEGIN sseof;			/* and switch to EOF state. */    } else if (rsattr(rdatap) < 0) {	/* Was the file refused? */	discard = 1;			/* Set the discard flag */	clsif();			/* Close the file */	sxeof(1);			/* send EOF with "discard" code */	BEGIN sseof;			/* switch to send-EOF state */    } else if ((x = sattr(xflg | stdinf, 0)) < 0) { /* Send more? */	errpkt((CHAR *)"Can't send attributes"); /* Trouble... */	RESUME;    } else if (x == 0) {		/* No more to send so now the data */	if (window(wslotn) < 0) {	/* Allocate negotiated window slots */	    errpkt((CHAR *)"Can't open window");	    RESUME;	}	if ((x = sdata()) == -2) {	/* File accepted, send first data */	    window(1);			/* Connection broken */	    x = clsif();		/* Close file */	    return(success = 0);	/* Return failure */	} else if (x == -9) {		/* User interrupted */	    errpkt((CHAR *)"User cancelled"); /* Send Error packet */	    window(1);			/* Set window size back to 1... */	    timint = s_timint;		/* Restore timeout */	    return(success = 0);	/* Failed */	} else if (x < 0) {		/* If data was not sent */	    window(1);			/* put window size back to 1, */	    debug(F101,"<ssattr>Y cxseen","",cxseen);	    if (clsif() < 0)		/* Close input file */	      cxseen = 1;		/* Send EOF packet */	    seof(cxseen||czseen);	    BEGIN sseof;		/* and switch to EOF state. */	} else {	    BEGIN ssdata;		/* All ok, switch to send-data state */	}    }}<ssdata>q {  				/* Ctrl-C or connection loss. */    window(1);				/* Set window size back to 1... */    cxseen = 1;				/* To indicate interruption */    x = clsif();			/* Close file */    return(success = 0);		/* Failed */}<ssdata>Y {				/* Got ACK to Data packet */    canned(rdatap);			/* Check if file transfer cancelled */    debug(F111,"<ssdata>Y cxseen",rdatap,cxseen);    debug(F111,"<ssdata>Y czseen",rdatap,czseen);    if ((x = sdata()) == -2) {		/* Try to send next data */	window(1);			/* Connection lost, reset window */	x = clsif();			/* Close file */	return(success = 0);		/* Failed */    } else if (x == -9) {		/* User interrupted */	errpkt((CHAR *)"User cancelled"); /* Send Error packet */	window(1);			/* Set window size back to 1... */	timint = s_timint;		/* Restore original timeout */	return(success = 0);		/* Failed */    } else if (x < 0) {			/* EOF - finished sending data */	debug(F101,"<ssdata>Y cxseen","",cxseen);	window(1);			/* Set window size back to 1... */	if (clsif() < 0)		/* Close input file */	  cxseen = 1;			/* Send EOF packet */	debug(F101,"<ssdata>Y CALLING SEOF()","",cxseen);	seof(cxseen||czseen);	BEGIN sseof;			/* and enter send-eof state */    }    /* NOTE: If x == 0 it means we're draining: see sdata()! */}<sseof>Y {				/* Got ACK to EOF */    int g, xdiscard;    canned(rdatap);			/* Check if file transfer cancelled */    debug(F111,"<sseof>Y cxseen",rdatap,cxseen);    debug(F111,"<sseof>Y czseen",rdatap,czseen);    debug(F111,"<sseof>Y discard",rdatap,discard);    xdiscard = discard;    discard = 0;    success = (cxseen == 0 && czseen == 0); /* Transfer status... */    debug(F101,"<sseof>Y success","",success);    if (success && rejection > 0)	    /* If rejected, succeed if */      if (rejection != '#' &&		    /* reason was date */	  rejection != 1 && rejection != '?') /* or name; */	success = 0;			    /* fail otherwise. */    cxseen = 0;				/* This goes back to zero. */    if (success) {			/* Only if transfer succeeded... */	xxscreen(SCR_ST,ST_OK,0L,"");	if (!xdiscard) {	    makestr(&sfspec,psfspec);	/* Record filenames for WHERE */	    makestr(&srfspec,psrfspec);	}	if (moving) {			/* If MOVE'ing */	    x = zdelet(filnam);		/* Try to delete the source file */#ifdef TLOG	    if (tralog) {		if (x > -1) {		    tlog(F110," deleted",filnam,0);		} else {		    tlog(F110," delete failed:",ck_errstr(),0);		}	    }#endif /* TLOG */	} else if (snd_move) {		/* Or move it */	    int x;	    x = zrename(filnam,snd_move);#ifdef TLOG	    if (tralog) {		if (x > -1) {		    tlog(F110," moved to ",snd_move,0);		} else {		    tlog(F110," move failed:",ck_errstr(),0);		}	    }#endif /* TLOG */	} else if (snd_rename) {	/* Or rename it */	    char *s = snd_rename;	/* Renaming string */#ifndef NOSPL	    int y;			/* Pass it thru the evaluator */	    extern int cmd_quoting;	/* for \v(filename) */	    if (cmd_quoting) {		/* But only if cmd_quoting is on */		y = MAXRP;		s = (char *)srvcmd;		zzstring(snd_rename,&s,&y);		s = (char *)srvcmd;	    }#endif /* NOSPL */	    if (s) if (*s) {		int x;		x = zrename(filnam,s);#ifdef TLOG	    if (tralog) {		if (x > -1) {		    tlog(F110," renamed to",s,0);		} else {		    tlog(F110," rename failed:",ck_errstr(),0);		}	    }#endif /* TLOG */#ifdef COMMENT		*s = NUL;#endif /* COMMENT */	    }	}    }    if (czseen) {			/* Check group interruption flag */	g = 0;				/* No more files if interrupted */    } else {				/* Otherwise... */#ifdef COMMENT	/* This code makes any open error fatal to a file-group transfer. */	g = gnfile();	debug(F111,"<sseof>Y gnfile",filnam,g);	if (g > 0) {			/* Any more files to send? */	    if (sfile(xflg))		/* Yes, try to send next file header */	      BEGIN ssfile;		/* if ok, enter send-file state */	    else {			/* otherwise */		s = xflg ? "Can't execute command" : (char *)epktmsg;		if (!*s) s = "Can't open file";		errpkt((CHAR *)s);	/* send error message */		RESUME;			/* and quit */	    }	} else {			/* No next file */	    tsecs = gtimer();		/* get statistics timers */#ifdef GFTIMER	    fptsecs = gftimer();#endif /* GFTIMER */	    seot();			/* send EOT packet */	    BEGIN sseot;		/* enter send-eot state */	}#else  /* COMMENT */	while (1) {			/* Keep trying... */	    g = gnfile();		/* Get next file */	    debug(F111,"<sseof>Y gnfile",filnam,g);	    if (g == 0 && gnferror == 0) /* No more, stop trying */	      break;	    if (g > 0) {		/* Have one */		if (sfile(xflg)) {	/* Try to open and send F packet */		    BEGIN ssfile;	/* If OK, enter send-file state */		    break;		/* and break out of loop. */		}	    } /* Otherwise keep trying to get one we can send... */	}    }    if (g == 0) {	debug(F101,"<sseof>Y no more files","",czseen);	tsecs = gtimer();		/* Get statistics timers */#ifdef GFTIMER	fptsecs = gftimer();#endif /* GFTIMER */	seot();				/* Send EOT packet */	BEGIN sseot;			/* Enter send-eot state */    }#endif /* COMMENT */}<sseot>Y {				/* Got ACK to EOT */    debug(F101,"sseot justone","",justone);    RESUME;				/* All done, just quit */}E {					/* Got Error packet, in any state */    char *s = "";    window(1);				/* Close window */    timint = s_timint;			/* Restore original timeout */    if (*epktmsg)			/* Message from Error packet */      s = (char *)epktmsg;    if (!*s) {				/* If not there then maybe here */	s = (char *)rdatap;	ckstrncpy((char *)epktmsg,(char *)rdatap,PKTMSGLEN);    }    if (!*s)				/* Hopefully we'll never see this. */      s = "Unknown error";    success = 0;			/* For IF SUCCESS/FAIL. */    debug(F101,"ckcpro.w justone at E pkt","",justone);    success = 0;			/* Transfer failed */    xferstat = success;			/* Remember transfer status */    if (!epktsent) {	x = quiet; quiet = 1;		/* Close files silently, */	epktrcvd = 1;			/* Prevent messages from clsof() */	clsif();	clsof(1); 			/* discarding any output file. */	ermsg(s);			/* Issue the message (calls screen). */	quiet = x;			/* Restore quiet state */    }    tstats();				/* Get stats *//*  If we are executing commands from a command file or macro, let the command  file or macro decide whether to exit, based on SET { TAKE, MACRO } ERROR.*/    if (#ifndef NOICP	!xcmdsrc &&#endif /* NOICP */	backgrd && !server)      fatal("Protocol error");    xitsta |= (what & W_KERMIT);	/* Save this for doexit(). */#ifdef CK_TMPDIR/* If we were cd'd temporarily to another device or directory ... */    if (f_tmpdir) {	int x;	x = zchdir((char *) savdir);	/* ... restore previous directory */	f_tmpdir = 0;			/* and remember we did it. */	debug(F111,"ckcpro.w E tmpdir restored",savdir,x);    }#endif /* CK_TMPDIR */#ifdef IKSDB    if (ikdbopen) slotstate(what,"ERROR", (char *)epktmsg, "");#endif /* IKSDB */    RESUME;}q { success = 0; QUIT; }		/* Ctrl-C or connection loss. */. {					/* Anything not accounted for above */    errpkt((CHAR *)"Unexpected packet type"); /* Give error message */    window(1);    xitsta |= (what & W_KERMIT);	/* Save this for doexit(). */    RESUME;				/* and quit */}%%/*  From here down to proto() are routines that were moved out of the state  table switcher because the resulting switch() had become too large.  To move the contents of a state-table case to a routine:    1. Add a prototype to the list above the state table switcher.    2. Make a routine with an appropriate name, returning int.    3. Move the code into it.    4. Put a call to the new routine in the former spot:         rc = name_of_routine();         if (rc > -1) return(rc);    5. Add "return(-1);" after every RESUME, SERVE, or BEGIN macro and       at the end if the code is open-ended.*/static intrcv_firstdata() {    extern int dispos;    debug(F101,"rcv_firstdata","",dispos);    if (discard) {			/* if we're discarding the file */	ack1((CHAR *)"X");		/* just ack the data like this. */	cancel++;			/* and count it */	BEGIN rdpkt;			/* and wait for more data packets. */	return(-1);    } else {				/* Not discarding. */	rf_err = "Can't open file";	if (xflg) {			/* If screen data */	    if (remfile) {		/* redirected to file */		if (rempipe)		/* or pipe */		  x = openc(ZOFILE,remdest); /* Pipe: start command */		else		  x = opena(remdest,&iattr); /* File: open with attributes */	    } else {			/* otherwise */		x = opent(&iattr);	/* "open" the screen */	    }	} else {			/* otherwise */#ifdef CALIBRATE	    if (calibrate) {		/* If calibration run */		x = ckopenx(&iattr);	/* open nothing */#ifdef STREAMING		if (streaming)		/* Streaming */		  fastack();		/* ACK without ACKing. */		else#endif /* STREAMING */		  ack();		/* Send real ACK */		BEGIN rdpkt;		/* Proceed to next state */		return(-1);	    } else#endif /* CALIBRATE */#ifdef UNIX/*  In UNIX we can pipe the file data into the mail program, which is to be  preferred to writing it out to a temp file and then mailing it afterwards.  This depends rather heavily on all UNIXes having a mail command that  accepts '-s "subject"' on the command line.  MAILCMD (e.g. mail, Mail, mailx)  is defined in ckufio.c.*/	    if (dispos == 'M') {	/* Mail... */		char *s;		char * tmp = NULL;		int n = 0;		extern char *MAILCMD;		s = iattr.disp.val + 1;		n = (int)strlen(MAILCMD) +    /* Mail command */		  (int)strlen(s) +	      /* address */		  (int)strlen(ofilnam) + 32;  /* subject */		if (tmp = (char *)malloc(n)) {		    ckmakxmsg(tmp,n,			      MAILCMD," -s \"",ofilnam,"\" ",s,			      NULL,NULL,NULL,NULL,NULL,NULL,NULL);		    debug(F111,"rcv_firsdata mail",tmp,(int)strlen(tmp));		    x = openc(ZOFILE,(char *)tmp);		    free(tmp);		} else		  x = 0;	    } else if (dispos == 'P') { /* Ditto for print */		char * tmp = NULL;		int n;		extern char *PRINTCMD;		n = (int)strlen(PRINTCMD) + (int)strlen(iattr.disp.val+1) + 4;		if (tmp = (char *)malloc(n)) {		    sprintf(tmp,	/* safe (prechecked) */			    "%s %s", PRINTCMD, iattr.disp.val + 1);		    x = openc(ZOFILE,(char *)tmp);		    free(tmp);		} else		  x = 0;	    } else#endif /* UNIX */	      x = opena(filnam,&iattr);	/* open the file, with attributes */	}	if (x) {			/* If file was opened ok */	    int rc, qf;#ifndef NOSPL	    qf = query;#else	    qf = 0;#endif /* NOSPL */#ifdef CKTUNING	    rc = (binary && !parity) ?	      bdecode(rdatap,putfil):	       decode(rdatap, qf ? puttrm : putfil, 1);#else	    rc = decode(rdatap, qf ? puttrm : putfil, 1);#endif /* CKTUNING */	    if (rc < 0) {		errpkt((CHAR *)"Error writing data");		RESUME;		return(-1);	    }#ifdef STREAMING	    if (streaming)		/* Streaming was negotiated */	      fastack();		/* ACK without ACKing. */	    else#endif /* STREAMING */	      ack();			/* acknowledge it */	    BEGIN rdpkt;		/* and switch to receive-data state */	    return(-1);	} else {			/* otherwise */	    errpkt((CHAR *) rf_err);	/* send error packet */    	    RESUME;			/* and quit. */	    return(-1);	}    }}static intrcv_shortreply() {#ifdef PKTZEROHACK    success = 0;    debug(F111,"rcv_shortreply",rdatap,ipktlen);    if (ipktack[0] && !strncmp(ipktack,(char *)rdatap,ipktlen)) {	/* No it's the ACK to the I packet again */	x = scmd(vcmd,(CHAR *)cmarg);	/* So send the REMOTE command again */	/* Maybe this should be resend() */	debug(F110,"IPKTZEROHACK",ipktack,x);	if (x < 0) {	    errpkt((CHAR *)srimsg);	    RESUME;	    return(-1);	}    } else {	ipktack[0] = NUL;#endif /* PKTZEROHACK */	urserver = 1;#ifndef NOSERVER#ifndef NOSPL	if (query) {			/* If to query, */	    qbufp = querybuf;		/*  initialize query response buffer */	    qbufn = 0;	    querybuf[0] = NUL;	}#endif /* NOSPL 

⌨️ 快捷键说明

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