📄 ckcpro.c
字号:
errpkt((CHAR *)"Can't check space"); /* send error message */ RESUME; /* and await next server command */ }#endif /* OS2 */ } }#endif /* NOSERVER */} break;case 46: { /* REMOTE WHO */#ifndef NOSERVER#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "REMOTE WHO", (char *)srvcmd);#endif /* CKSYSLOG */#ifdef IKSDB if (ikdbopen) slotstate(what,"REMOTE WHO", (char *)(srvcmd+2), "");#endif /* IKSDB */ if (!ENABLED(en_who)) { errpkt((CHAR *)"REMOTE WHO disabled"); RESUME; } else {#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 */} break;case 47: { /* Variable query or set */ rc = srv_query(); debug(F101,"srv_query","",rc); if (rc > -1) return(rc);} break;case 48: { /* 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; 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; QUIT; } } else { /* Shouldn't happen */ debug(F100,"SERVER (generic) GOT UNEXPECTED 'q'","",0); QUIT; }#endif /* NOSERVER */} break;case 49: { /* Anything else in this state... */#ifndef NOSERVER errpkt((CHAR *)"Unimplemented REMOTE command"); /* Complain */ RESUME; /* and return to server command wait */#endif /* NOSERVER */} break;case 50: { /* 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 */ }} break;case 51: { /* Short-Form reply */ rc = rcv_shortreply(); debug(F101,"<rgen>Y rcv_shortreply","",rc); if (rc > -1) return(rc);} break;case 52: { /* File header */ char *n2; extern int rsn; debug(F101,"<rfile>F winlo 1","",winlo); xflg = 0; /* Not screen data */ 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 */ }} break;case 53: { /* X-packet instead of file header */ xflg = 1; /* Screen data */ 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 */} break;case 54: { /* 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 */ }} break;case 55: { /* First data packet */ rc = rcv_firstdata(); debug(F101,"srv_firstdata","",rc); if (rc > -1) return(rc); /* (see below) */} break;case 56: { /* 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 */} break;case 57: { /* Data packet */ if (cxseen || discard) { /* If file interrupt */#ifdef STREAMING if (streaming) { if (cancel++ == 0) ack1((CHAR *)"X"); /* put "X" in ACK */ else fastack(); } else#endif /* STREAMING */ ack1((CHAR *)"X"); /* put "X" in ACK */ } else if (czseen) { /* If file-group interrupt */#ifdef STREAMING if (streaming) { if (cancel++ == 0) ack1((CHAR *)"Z"); /* put "Z" in ACK */ else fastack(); } else#endif /* STREAMING */ ack1((CHAR *)"Z"); /* put "Z" in ACK */ } else { 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(); }} break;case 58: { /* 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 || reof(filnam, &iattr) < 0) { /* Now close & dispose of the file */ errpkt((CHAR *) rf_err); /* If problem, send error msg */ RESUME; /* and quit */ } else { /* otherwise */ ack(); /* acknowledge the EOF packet */ BEGIN rfile; /* and await another file */ }} break;case 59: { /* 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 */} break;case 60: { /* 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 -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: case 3: xxscreen(SCR_EM,0,0L,"Can't delete temp file"); /* Not fatal */ 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 */ 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 */} break;case 61: { /* ACK for Send-Init */ spar(rdatap); /* set parameters from it */ 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 */} break;case 62: { /* R packet was retransmitted. */ xsinit(); /* Resend packet 0 */} break;case 63: { /* Same deal if G packet comes again */ xsinit();} break;case 64: { /* Same deal if C packet comes again */ xsinit();} break;case 65: { /* 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 */ if (*srvcmd) { /* If remote name was recorded */ if (sendmode != SM_RESEND) { extern char * srfspec; if (fdispla == XYFD_C || fdispla == XYFD_S) xxscreen(SCR_AN,0,0L,(char *)srvcmd);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -