📄 ckcpro.c
字号:
tlog(F110," remote name:",(char *) srvcmd,0L); makestr(&srfspec,(char *)srvcmd); } } if (atcapu) { /* If attributes are to be used */ if (sattr(xflg | stdinf, 1) < 0) { /* send them */ errpkt((CHAR *)"Can't send attributes"); /* if problem, say so */ RESUME; /* and quit */ } else BEGIN ssattr; /* if ok, switch to attribute state */ } else { /* Attributes not negotiated */ if (window(wslotn) < 0) { /* Open window */ errpkt((CHAR *)"Can't open window"); RESUME; } if ((x = sdata()) == -2) { /* Send first data packet data */ window(1); /* Failed, put window size back to 1 */ x = clsif(); /* Close input 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 == -1) { /* EOF (empty file) */ 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 */ } }} break;case 66: { /* Got ACK to A packet */ ffc = 0L; /* Reset file byte counter */ 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 */ 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 timeout */ return(success = 0); /* Failed */ } else if (x == -1) { /* EOF */ 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 */ } }} break;case 67: { /* 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 */} break;case 68: { /* Got ACK to Data packet */ canned(rdatap); /* Check if file transfer cancelled */ if ((x = sdata()) == -2) { /* Try to send next data */ window(1); /* Set window size back to 1... */ 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 == -1) { /* 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 */ }} break;case 69: { /* Got ACK to EOF */ int g; success = (cxseen == 0 && czseen == 0); /* Transfer status... */ 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... */ if (moving) { /* If MOVE'ing */ tlog(F110," deleting",filnam,0); /* delete the file */ zdelet(filnam); } else if (snd_move) { /* Or move it */ int x; tlog(F110," moving source to",snd_move,0); x = zrename(filnam,snd_move); debug(F111,"send MOVE zrename",snd_move,x); } 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); debug(F111,"send RENAME zrename",snd_rename,x); if (x > -1) tlog(F110," renaming source to",s,0);#ifdef COMMENT *s = NUL;#endif /* COMMENT */ } } } g = gnfile(); debug(F111,"<seof>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 */ }} break;case 70: { /* Got ACK to EOT */ debug(F101,"sseot justone","",justone); RESUME; /* All done, just quit */} break;case 71: { /* 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); x = quiet; quiet = 1; /* Close files silently, */ epktrcvd = 1; /* Prevent messages from clsof() */ clsif(); clsof(1); /* discarding any output file. */ success = 0; /* Transfer failed */ xferstat = success; /* Remember transfer status */ ermsg(s); /* Issue the message (calls screen). */ tstats(); /* Get stats */ quiet = x; /* Restore quiet state *//* 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 !cmdsrc() &&#endif /* NOICP */ backgrd && !server) fatal("Protocol error"); xitsta |= what; /* 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;} break;case 72: { success = 0; QUIT; } break;case 73: { /* Anything not accounted for above */ errpkt((CHAR *)"Unexpected packet type"); /* Give error message */ window(1); xitsta |= what; /* Save this for doexit(). */ RESUME; /* and quit */} break; } }}char tbl[] = { -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 15, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 13, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 56, 73, 73, 71, 52, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 53, 73, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 54, 73, 73, 55, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 58, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 57, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 60, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 59, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 64, 73, 71, 73, 63, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 62, 73, 73, 73, 73, 73, 73, 61, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 65, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 66, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 68, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 67, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 69, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 70, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 26, 29, 29, 29, 25, 19, 17, 22, 29, 29, 29, 28, 23, 29, 29, 18, 12, 29, 29, 20, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 11, 29, 7, 29, 29, 29, 9, 4, 29, 5, 8, 29, 29, 29, 6, 29, 27, 3, 1, 29, 29, 2, 29, 10, 29, 29, 29, 29, 29, 29, 29, -1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 32, 49, 31, 33, 34, 35, 49, 38, 30, 49, 40, 37, 49, 49, 49, 49, 49, 39, 41, 42, 45, 47, 46, 36, 49, 49, 49, 49, 49, 49, 49, 49, 11, 49, 7, 44, 49, 49, 9, 4, 49, 5, 8, 49, 43, 49, 6, 49, 48, 3, 1, 49, 49, 2, 49, 10, 49, 49, 49, 49, 49, 49, 49, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 17, 73, 73, 73, 73, 73, 73, 73, 73, 73, 12, 73, 73, 73, 73, 73, 16, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 52, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 12, 73, 73, 73, 73, 53, 51, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 50, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, -1, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 14, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73, 73, 0, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 71, 73, 73, 73, 73, 73, 73, 73, 73, 73, 24, 73, 73, 73, 12, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 11, 73, 7, 73, 73, 73, 9, 4, 73, 5, 8, 73, 73, 73, 6, 73, 72, 3, 1, 73, 73, 2, 73, 10, 73, 73, 73, 73, 73, 73,73};/* 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() { 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 (*(iattr.disp.val) == 'M') { char *s; char tmp[1024]; extern char *MAILCMD; s = iattr.disp.val + 1; sprintf(tmp,"%s -s %c%s%c %s", MAILCMD, '"', ofn1, '"', s); x = openc(ZOFILE,(char *)tmp); } else if (*(iattr.disp.val) == 'P') { /* Ditto for print */ char tmp[1024]; extern char *PRINTCMD; sprintf(tmp,"%s %s", PRINTCMD, iattr.disp.val + 1); x = openc(ZOFILE,(char *)tmp); } 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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -