📄 ckcpro.w
字号:
rtimer(); /* Reset the elapsed seconds timer. */#ifdef GFTIMER rftimer();#endif /* GFTIMER */ winlo = 0; /* Window back to 0, again. */ debug(F101,"<ipkt>Y vstate","",vstate); nakstate = 1; /* Can send NAKs from here. */ BEGIN vstate; /* Switch to desired state */ }}<ssopkt>Y { /* Got ACK to O-Packet */ debug(F100,"CPCPRO <ssopkt>Y","",0); x = sopkt(); debug(F101,"CPCPRO <ssopkt>Y x","",x); if (x < 0) { /* If error */ errpkt((CHAR *)srimsg); /* cancel both sides. */ success = 0; RESUME; } else if (x == 0) { /* This was the last O-Packet */ rtimer(); /* Reset the elapsed seconds timer. */#ifdef GFTIMER rftimer();#endif /* GFTIMER */ winlo = 0; /* Window back to 0, again. */ debug(F101,"<ssopkt>Y winlo","",winlo); nakstate = 1; /* Can send NAKs from here. */ BEGIN vstate; /* Switch to desired state */ } debug(F101,"CPCPRO <ssopkt>Y not changing state","",x);}<ipkt>E { /* Ignore Error reply to I packet */ int x = 0; winlo = 0; /* Set window-low back to zero */ debug(F101,"<ipkt>E winlo","",winlo); if (vcmd) { /* In case other Kermit doesn't */ if (tinit(0) < 0) return(-9); x = scmd(vcmd,(CHAR *)cmarg); /* understand I-packets. */ if (x >= 0) x = 0; /* (because of O-Packet) */ vcmd = 0; /* Otherwise act as above... */ } else if (vstate == get) x = srinit(reget, retrieve, opkt); if (x < 0) { /* If command was too long */ errpkt((CHAR *)srimsg); /* cancel both sides. */ success = 0; RESUME; } else if (x > 0) { /* Need to send more O-Packets */ BEGIN ssopkt; } else { winlo = 0; /* Back to packet 0 again. */ debug(F101,"<ipkt>E winlo","",winlo); freerpkt(winlo); /* Discard the Error packet. */ nakstate = 1; /* Can send NAKs from here. */ BEGIN vstate; }}<get>Y { /* Resend of previous I-pkt ACK, same seq number! */ srinit(reget, retrieve, opkt); /* Send the GET packet again. */}/* States in which we're being a server */<serve,get>I { /* Get I-packet */#ifndef NOSERVER spar(rdatap); /* Set parameters from it */ ack1(rpar()); /* Respond with our own parameters */#ifdef COMMENT pktinit(); /* Reinitialize packet numbers */#else#ifdef COMMENT /* This can't be right - it undoes the stuff we just negotiated */ x = justone; tinit(1); /* Reinitialize EVERYTHING */ justone = x; /* But this... */#else tinit(0); /* Initialize most things */#endif /* COMMENT */#endif /* COMMENT */#endif /* NOSERVER */}<serve>R { /* GET */#ifndef NOSERVER if (x_login && !x_logged) { errpkt((CHAR *)"Login required"); SERVE; } else if (sgetinit(0,0) < 0) { RESUME; } else {#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "GET", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; }#endif /* NOSERVER */}<serve>H { /* GET /DELETE (RETRIEVE) */#ifndef NOSERVER if (x_login && !x_logged) { errpkt((CHAR *)"Login required"); RESUME; } else if (!ENABLED(en_del)) { errpkt((CHAR *)"Deleting files is disabled"); RESUME; } else if (sgetinit(0,0) < 0) { RESUME; } else { moving = 1;#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "GET /DELETE", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; }#endif /* NOSERVER */}<serve>V { /* GET /RECURSIVE */#ifndef NOSERVER recursive = 1; /* Set these before sgetinit() */ if (fnspath == PATH_OFF) fnspath = PATH_REL; /* Don't worry, they will be */ if (x_login && !x_logged) { /* reset next time through. */ errpkt((CHAR *)"Login required"); RESUME; } else if (sgetinit(0,0) < 0) { RESUME; } else {#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "GET /RECURSIVE", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; }#endif /* NOSERVER */}<serve>W { /* GET /RECURSIVE /DELETE */#ifndef NOSERVER recursive = 1; /* Set these before sgetinit() */ if (fnspath == PATH_OFF) fnspath = PATH_REL; /* Don't worry, they will be */ moving = 1; /* reset next time through. */ if (x_login && !x_logged) { errpkt((CHAR *)"Login required"); RESUME; } else if (!ENABLED(en_del)) { errpkt((CHAR *)"Deleting files is disabled"); RESUME; } else if (sgetinit(0,0) < 0) { RESUME; } else {#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR,1,"server", "GET /RECURSIVE /DELETE",(char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; }#endif /* NOSERVER */}<serve>J { /* GET /RECOVER (REGET) */#ifndef NOSERVER if (x_login && !x_logged) { errpkt((CHAR *)"Login required"); SERVE; } else if (sgetinit(1,0) < 0) { RESUME; } else {#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "GET /RECOVER", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; }#endif /* NOSERVER */}<serve>O { /* Extended GET */#ifndef NOSERVER if (x_login && !x_logged) { /* (any combination of options) */ errpkt((CHAR *)"Login required"); SERVE; } else if ((x = sgetinit(0,1)) < 0) { debug(F101,"CKCPRO <serve>O sgetinit fail","",x); RESUME; } else if (x == 0) { debug(F101,"CKCPRO <serve>O sgetinit done","",x);#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "EXTENDED GET", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; } else { /* Otherwise stay in this state */ debug(F101,"CKCPRO <serve>O sgetinit TBC","",x); ack(); BEGIN ropkt; }#endif /* NOSERVER */}<ropkt>O {#ifndef NOSERVER if (x_login && !x_logged) { /* (any combination of options) */ errpkt((CHAR *)"Login required"); SERVE; } else if ((x = sgetinit(0,1)) < 0) { debug(F101,"CKCPRO <ropkt>O sgetinit fail","",x); RESUME; } else if (x == 0) { debug(F101,"CKCPRO <ropkt>O sgetinit done","",x);#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "EXTENDED GET", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; } else { /* Otherwise stay in this state */ debug(F101,"CKCPRO <ropkt>O sgetinit TBC","",x); ack(); }#endif /* NOSERVER */}<serve>G { /* Generic server command */#ifndef NOSERVER srvptr = srvcmd; /* Point to command buffer */ decode(rdatap,putsrv,0); /* Decode packet data into it */ putsrv(NUL); /* Insert a couple nulls */ putsrv(NUL); /* for termination */ if (srvcmd[0]) { sstate = srvcmd[0]; /* Set requested start state */ if (x_login && !x_logged && /* Login required? */ /* Login, Logout, and Help are allowed when not logged in */ sstate != 'I' && sstate != 'L' && sstate != 'H') { errpkt((CHAR *)"Login required"); SERVE; } else { nakstate = 0; /* Now I'm the sender. */ what = W_REMO; /* Doing a REMOTE command. */#ifdef STREAMING if (!streaming)#endif /* STREAMING */ if (timint < 1) timint = chktimo(rtimo,timef); /* Switch to per-packet timer */ binary = XYFT_T; /* Switch to text mode */ BEGIN generic; /* Switch to generic command state */ } } else { errpkt((CHAR *)"Badly formed server command"); /* report error */ RESUME; /* & go back to server command wait */ }#endif /* NOSERVER */}<serve>C { /* Receive Host command */#ifndef NOSERVER if (x_login && !x_logged) { errpkt((CHAR *)"Login required"); SERVE; } else if (!ENABLED(en_hos)) { errpkt((CHAR *)"REMOTE HOST disabled"); RESUME; } else if (nopush) { errpkt((CHAR *)"HOST commands not available"); RESUME; } else { srvptr = srvcmd; /* Point to command buffer */ decode(rdatap,putsrv,0); /* Decode command packet into it */ putsrv(NUL); /* Null-terminate */ nakstate = 0; /* Now sending, not receiving */ binary = XYFT_T; /* Switch to text mode */ if (syscmd((char *)srvcmd,"")) { /* Try to execute the command */ what = W_REMO; /* Doing a REMOTE command. */#ifdef STREAMING if (!streaming)#endif /* STREAMING */ if (timint < 1) timint = chktimo(rtimo,timef); /* Switch to per-packet timer */#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "REMOTE HOST", (char *)srvcmd);#endif /* CKSYSLOG */ BEGIN ssinit; /* If OK, send back its output */ } else { /* Otherwise */ errpkt((CHAR *)"Can't do system command"); /* report error */ RESUME; /* & go back to server command wait */ } }#endif /* NOSERVER */}<serve>q { /* Interrupted or connection lost */ rc = srv_timeout(); debug(F101,"srv_timeout","",rc); if (rc > -1) return(rc); /* (see below) */}<serve>N { /* Server got a NAK in command-wait */#ifndef NOSERVER errpkt((CHAR *)"Did you say RECEIVE instead of GET?"); RESUME;#endif /* NOSERVER */}<serve>. { /* Any other command in this state */#ifndef NOSERVER if (c != ('E' - SP) && c != ('Y' - SP)) /* except E and Y packets. */ errpkt((CHAR *)"Unimplemented server function"); /* If we answer an E with an E, we get an infinite loop. */ /* A Y (ACK) can show up here if we sent back a short-form reply to */ /* a G packet and it was echoed. ACKs can be safely ignored here. */ RESUME; /* Go back to server command wait. */#endif /* NOSERVER */}<generic>I { /* Login/Out */ rc = srv_login(); debug(F101,"<generic>I srv_login","",rc); if (rc > -1) return(rc); /* (see below) */}<generic>C { /* Got REMOTE CD command */#ifndef NOSERVER#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "REMOTE CD", (char *)srvcmd);#endif /* CKSYSLOG */ if (!ENABLED(en_cwd)) { errpkt((CHAR *)"REMOTE CD disabled"); RESUME; } else { char * p = NULL; x = cwd((char *)(srvcmd+1)); /* Try to change directory */#ifdef IKSDB if (ikdbopen) slotstate(what,"REMOTE CD", (char *)(srvcmd+2), "");#endif /* IKSDB */ if (!x) { /* Failed */ errpkt((CHAR *)"Can't change directory"); RESUME; /* Back to server command wait */ } else if (x == 2) { /* User wants message */ if (!ENABLED(en_typ)) { /* Messages (REMOTE TYPE) disabled? */ errpkt((CHAR *)"REMOTE TYPE disabled"); RESUME; } else { /* TYPE is enabled */ int i; for (i = 0; i < 8; i++) { if (zchki(cdmsgfile[i]) > -1) { break; } } binary = XYFT_T; /* Use text mode for this. */ if (i < 8 && sndtype(cdmsgfile[i])) { /* Have readme file? */ BEGIN ssinit; /* OK */ } else { /* not OK */ p = zgtdir(); if (!p) p = ""; success = (*p) ? 1 : 0; ack1((CHAR *)p); /* ACK with new directory name */ success = 1; RESUME; /* wait for next server command */ } } } else { /* User doesn't want message */ p =zgtdir(); if (!p) p = ""; success = (*p) ? 1 : 0; ack1((CHAR *)p); success = 1; RESUME; /* Wait for next server command */ } }#endif /* NOSERVER */}<generic>A { /* Got REMOTE PWD command */#ifndef NOSERVER#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "REMOTE PWD", NULL);#endif /* CKSYSLOG */ if (!ENABLED(en_cwd)) { errpkt((CHAR *)"REMOTE CD disabled"); RESUME; } else { if (encstr((CHAR *)zgtdir()) > -1) { /* Encode current directory */ ack1(data); /* If it fits, send it back in ACK */ success = 1; } else { /* Failed */ ack(); /* Send empty ACK */ success = 0; /* and indicate failure locally */ } RESUME; /* Back to server command wait */ }#endif /* NOSERVER */}<generic>D { /* REMOTE DIRECTORY command */#ifndef NOSERVER char *n2;#ifdef CKSYSLOG if (ckxsyslog >= SYSLG_PR && ckxlogging) cksyslog(SYSLG_PR, 1, "server", "REMOTE DIRECTORY", (char *)srvcmd);#endif /* CKSYSLOG */ if (!ENABLED(en_dir)) { /* If DIR is disabled, */ errpkt((CHAR *)"REMOTE DIRECTORY disabled"); /* refuse. */ RESUME; } else { /* DIR is enabled. */#ifdef IKSDB if (ikdbopen) slotstate(what,"REMOTE DIR", (char *)(srvcmd+2), "");#endif /* IKSDB */ if (!ENABLED(en_cwd)) { /* But CWD is disabled */ zstrip((char *)(srvcmd+2),&n2); /* and they included a pathname, */ if (strcmp((char *)(srvcmd+2),n2)) { /* so refuse. */ errpkt((CHAR *)"Access denied"); RESUME; /* Remember, this is not a goto! */ } } if (state == generic) { /* It's OK to go ahead. */#ifdef COMMENT n2 = (*(srvcmd+2)) ? DIRCMD : DIRCM2; if (syscmd(n2,(char *)(srvcmd+2))) /* If it can be done */#else int x; if ((x = snddir((char*)(srvcmd+2))) > 0)#endif /* COMMENT */ { BEGIN ssinit; /* send the results back; */ } else { /* otherwise */ if (x < 0) errpkt((CHAR *)"No files match"); else errpkt((CHAR *)"Can't list directory"); RESUME; /* return to server command wait */ } } }#endif /* NOSERVER */}<generic>E { /* REMOTE DELETE (Erase) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -