📄 ckcpro.w
字号:
#ifdef OS2_PROTOTYP(int sndwho,(char *)); if (sndwho((char *)(srvcmd+2))) { BEGIN ssinit; /* try to send it */ } else { /* If not ok, */ errpkt((CHAR *)"Can't do who command"); /* send error msg */ RESUME; /* and return to server command wait */ }#else if (syscmd(WHOCMD,(char *)(srvcmd+2))) { BEGIN ssinit; } else { errpkt((CHAR *)"Can't do who command"); RESUME; }#endif /* OS2 */ }#endif /* NOSERVER */}<generic>V { /* Variable query or set */ rc = srv_query(); debug(F101,"srv_query","",rc); if (rc > -1) return(rc);}<generic>q { /* Interrupted or connection lost */#ifndef NOSERVER if (fatalio) { /* Connection lost */#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "Interrupted", NULL);#endif /* CKSYSLOG */ success = 0; xitsta |= (what & W_KERMIT); QUIT; } else if (interrupted) { if (!ENABLED(en_fin)) { /* Ctrl-C typed */ errpkt((CHAR *)"QUIT disabled"); RESUME; } else {#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "Interrupted", NULL);#endif /* CKSYSLOG */ success = 0; xitsta |= (what & W_KERMIT); QUIT; } } else { /* Shouldn't happen */ debug(F100,"SERVER (generic) GOT UNEXPECTED 'q'","",0); QUIT; }#endif /* NOSERVER */}<generic>. { /* Anything else in this state... */#ifndef NOSERVER errpkt((CHAR *)"Unimplemented REMOTE command"); /* Complain */ RESUME; /* and return to server command wait */#endif /* NOSERVER */}<rgen>q { /* Sent BYE and connection broken */ if (bye_active && ttchk() < 0) { msleep(500); bye_active = 0; ttclos(0); /* Close our end of the connection */ clsof(0); return(success = 1); } else { /* Other generic command */ return(success = 0); /* or connection not broken */ }}<rgen>Y { /* Short-Form reply */ rc = rcv_shortreply(); debug(F101,"<rgen>Y rcv_shortreply","",rc); if (rc > -1) return(rc);}<rgen,rfile>F { /* File header */ /* char *n2; */ extern int rsn; debug(F101,"<rfile>F winlo 1","",winlo); xflg = 0; /* Not screen data */ if (!czseen) cancel = 0; /* Reset cancellation counter */#ifdef CALIBRATE if (dest == DEST_N) calibrate = 1;#endif /* CALIBRATE */ if (!rcvfil(filnam)) { /* Figure out local filename */ errpkt((CHAR *)rf_err); /* Trouble */ RESUME; } else { /* Real file, OK to receive */ char * fnp; debug(F111,"<rfile>F winlo 2",fspec,winlo); if (filcnt == 1) /* rcvfil set this to 1 for 1st file */ crc16 = 0L; /* Clear file CRC */ fnp = fspec; /* This is the full path */ if (server && !ENABLED(en_cwd) || /* if DISABLE CD */ !fackpath /* or F-ACK-PATH OFF */ ) { zstrip(fspec,&fnp); /* don't send back full path */ } encstr((CHAR *)fnp); if (fackbug) ack(); else ack1(data); /* Send it back in ACK */ initattr(&iattr); /* Clear file attribute structure */ streamon(); if (window(wslotn) < 0) { /* Allocate negotiated window slots */ errpkt((CHAR *)"Can't open window"); RESUME; }#ifdef IKSDB if (ikdbopen) slotstate(what, server ? "SERVER" : "", "RECEIVE", fspec );#endif /* IKSDB */ BEGIN rattr; /* Now expect Attribute packets */ }}<rgen,rfile>X { /* X-packet instead of file header */ xflg = 1; /* Screen data */ if (!czseen) cancel = 0; /* Reset cancellation counter */ ack(); /* Acknowledge the X-packet */ initattr(&iattr); /* Initialize attribute structure */ streamon(); if (window(wslotn) < 0) { /* allocate negotiated window slots */ errpkt((CHAR *)"Can't open window"); RESUME; }#ifndef NOSPL if (query) { /* If this is the response to */ qbufp = querybuf; /* a query that we sent, initialize */ qbufn = 0; /* the response buffer */ querybuf[0] = NUL; }#endif /* NOSPL */ what = W_REMO; /* we're doing a REMOTE command */#ifdef IKSDB if (ikdbopen) slotstate(what, server ? "SERVER" : "", "RECEIVE", fspec );#endif /* IKSDB */ BEGIN rattr; /* Expect Attribute packets */}<rattr>A { /* Attribute packet */ if (gattr(rdatap,&iattr) == 0) { /* Read into attribute structure */#ifdef CK_RESEND ack1((CHAR *)iattr.reply.val); /* Reply with data */#else ack(); /* If OK, acknowledge */#endif /* CK_RESEND */ } else { /* Otherwise */ extern long fsize; char *r; r = getreason(iattr.reply.val); ack1((CHAR *)iattr.reply.val); /* refuse to accept the file */ xxscreen(SCR_ST,ST_REFU,0L,r); /* reason */#ifdef TLOG if (tralog && !tlogfmt) doxlog(what,filnam,fsize,binary,1,r);#endif /* TLOG */ }}<rattr>D { /* First data packet */ debug(F100,"<rattr> D firstdata","",0); rc = rcv_firstdata(); debug(F101,"rcv_firstdata rc","",rc); if (rc > -1) return(rc); /* (see below) */}<rfile>B { /* EOT, no more files */ ack(); /* Acknowledge the B packet */ reot(); /* Do EOT things */#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 B tmpdir restoring",savdir,x); }#endif /* CK_TMPDIR */ RESUME; /* and quit */}<rdpkt>D { /* Got Data packet */ debug(F101,"<rdpkt>D cxseen","",cxseen); debug(F101,"<rdpkt>D czseen","",czseen); if (cxseen || czseen || discard) { /* If file or group interruption */ CHAR * msg; msg = czseen ? (CHAR *)"Z" : (CHAR *)"X";#ifdef STREAMING if (streaming) { /* Need to cancel */ debug(F111,"<rdpkt>D streaming cancel",msg,cancel); if (cancel++ == 0) { /* Only do this once */ ack1(msg); /* Put "X" or "Z" in ACK */ } else if (czseen) { errpkt((CHAR *)"User canceled"); RESUME; } else { fastack(); } } else#endif /* STREAMING */ ack1(msg); } else { /* No interruption */ 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) { discard = (keep == 0 || (keep == SET_AUTO && binary != XYFT_T)); errpkt((CHAR *)"Error writing data"); /* If failure, */ RESUME; } else /* Data written OK, send ACK */#ifdef STREAMING if (streaming) fastack(); else#endif /* STREAMING */ ack(); }}<rattr>Z { /* EOF immediately after A-Packet. */ rf_err = "Can't create file"; timint = s_timint; if (discard) { /* Discarding a real file... */ x = 1; } else 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 */ }#ifdef CALIBRATE } else if (calibrate) { /* If calibration run */ x = ckopenx(&iattr); /* do this */#endif /* CALIBRATE */ } else { /* otherwise */ x = opena(filnam,&iattr); /* open the file, with attributes */ if (x == -17) { /* REGET skipped because same size */ discard = 1; rejection = 1; } } if (!x || reof(filnam, &iattr) < 0) { /* Close output file */ errpkt((CHAR *) rf_err); /* If problem, send error msg */ RESUME; /* and quit */ } else { /* otherwise */ if (x == -17) xxscreen(SCR_ST,ST_SKIP,SKP_RES,""); ack(); /* acknowledge the EOF packet */ BEGIN rfile; /* and await another file */ }}<rdpkt>q { /* Ctrl-C or connection loss. */ timint = s_timint; window(1); /* Set window size back to 1... */ cxseen = 1; x = clsof(1); /* Close file */ return(success = 0); /* Failed */}<rdpkt>Z { /* End Of File (EOF) Packet *//* wslots = 1; */ /* (don't set) Window size back to 1 */#ifndef COHERENT /* Coherent compiler blows up on this switch() statement. */ x = reof(filnam, &iattr); /* Handle the EOF packet */ switch (x) { /* reof() sets the success flag */ case -5: /* Handle problems */ errpkt((CHAR *)"RENAME failed"); /* Fatal */ RESUME; break; case -4: errpkt((CHAR *)"MOVE failed"); /* Fatal */ RESUME; break; case -3: /* If problem, send error msg */ errpkt((CHAR *)"Can't print file"); /* Fatal */ RESUME; break; case -2: errpkt((CHAR *)"Can't mail file"); /* Fatal */ RESUME; break; case 2: /* Not fatal */ case 3: xxscreen(SCR_EM,0,0L,"Receiver can't delete temp file"); RESUME; break; default: if (x < 0) { /* Fatal */ errpkt((CHAR *)"Can't close file"); RESUME; } else { /* Success */#ifndef NOSPL if (query) /* Query reponses generally */ conoll(""); /* don't have line terminators */#endif /* NOSPL */ if (czseen) { /* Batch canceled? */ if (cancel++ == 0) { /* If we haven't tried this yet */ ack1((CHAR *)"Z"); /* Try it once */ } else { /* Otherwise */ errpkt((CHAR *)"User canceled"); /* quite with Error */ RESUME; } } else ack(); /* Acknowledge the EOF packet */ BEGIN rfile; /* and await another file */ } }#else if (reof(filnam, &iattr) < 0) { /* Close the file */ errpkt((CHAR *)"Error at end of file"); RESUME; } else { /* reof() sets success flag */ ack(); BEGIN rfile; }#endif /* COHERENT */}<ssinit>Y { /* ACK for Send-Init */ spar(rdatap); /* set parameters from it */ cancel = 0; bctu = bctr; /* switch to agreed-upon block check */ bctl = (bctu == 4) ? 2 : bctu; /* Set block-check length */#ifdef CK_RESEND if ((sendmode == SM_RESEND) && (!atcapu || !rscapu)) { /* RESEND */ errpkt((CHAR *) "RESEND capabilities not negotiated"); RESUME; } else {#endif /* CK_RESEND */ what = W_SEND; /* Remember we're sending */ lastxfer = W_SEND; x = sfile(xflg); /* Send X or F header packet */ cancel = 0; /* Reset cancellation counter */ if (x) { /* If the packet was sent OK */ if (!xflg && filcnt == 1) /* and it's a real file */ crc16 = 0L; /* Clear the file CRC */ resetc(); /* reset per-transaction counters */ rtimer(); /* reset timers */#ifdef GFTIMER rftimer();#endif /* GFTIMER */ streamon(); /* turn on streaming */#ifdef IKSDB if (ikdbopen) slotstate(what, (server ? "SERVER" : ""), "SEND", filnam );#endif /* IKSDB */ BEGIN ssfile; /* and switch to receive-file state */ } else { /* otherwise send error msg & quit */ s = xflg ? "Can't execute command" : (char *)epktmsg; if (!*s) s = "Can't open file"; errpkt((CHAR *)s); RESUME; }#ifdef CK_RESEND }#endif /* CK_RESEND */}/* These states are necessary to handle the case where we get a server command packet (R, G, or C) reply with an S packet, but the client retransmits the command packet. The input() function doesn't catch this because the packet number is still zero.*/<ssinit>R { /* R packet was retransmitted. */ xsinit(); /* Resend packet 0 */}<ssinit>G { /* Same deal if G packet comes again */ xsinit();}/* should probably add cases for O, W, V, H, J, ... */<ssinit>C { /* Same deal if C packet comes again */ xsinit();}<ssfile>Y { /* ACK for F or X packet */ srvptr = srvcmd; /* Point to string buffer */ decode(rdatap,putsrv,0); /* Decode data field, if any */ putsrv(NUL); /* Terminate with null */ ffc = 0L; /* Reset file byte counter */ debug(F101,"<ssfile>Y cxseen","",cxseen); if (*srvcmd) { /* If remote name was recorded */ if (sendmode != SM_RESEND) { if (fdispla == XYFD_C || fdispla == XYFD_S) xxscreen(SCR_AN,0,0L,(char *)srvcmd); tlog(F110," remote name:",(char *) srvcmd,0L); makestr(&psrfspec,(char *)srvcmd); } } if (cxseen||czseen) { /* Interrupted? */ debug(F101,"<ssfile>Y canceling","",0); x = clsif(); /* Close input file */ sxeof(1); /* Send EOF(D) */ BEGIN sseof; /* and switch to EOF state. */ } else 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; } else if ((x = sdata()) == -2) { /* Send first data packet data */ window(1); /* Connection lost, reset window */ x = clsif(); /* Close input file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -