STATUS FtpDebugIO(FTP *ftp,int n, char * Message) { FtpLog("FtpDebugIO",""); FtpLog(ftp->title,Message); if ( ! FtpTestFlag(ftp,FTP_NOEXIT)) exit(1); return 0; }
void FtpSessionRun(FtpSession *f) { char buf[2048]; int len = 0, i = 0, cmd_parse_ret = 0; FtpCommand cmd; /* say hello */ SendReadme(f, 220); FtpSessionReply(f, 220, "Service ready for new user."); /* process commands */ while (f->session_active && TelnetReadLine(f->telnet_session, buf, sizeof(buf))) { /* increase our command count */ if (f->command_number == ULONG_MAX) { f->command_number = 0; } else { f->command_number++; } /* make sure we read a whole line */ len = strlen(buf); if (buf[len-1] != '\n') { FtpSessionReply(f, 500, "Command line too long."); while (TelnetReadLine(f->telnet_session, buf, sizeof(buf))) { len = strlen(buf); if (buf[len-1] == '\n') { break; } } goto next_command; } /* parse the line */ if ((cmd_parse_ret = FtpCommandParse(buf, &cmd)) != 0) { if (cmd_parse_ret == COMMAND_PARAMETERS_ERROR) { FtpSessionReply(f, 501, "Syntax error in parameters or arguments of command %s.", buf); } else { FtpSessionReply(f, 500, "Syntax error, command %s unrecognized.", buf); } goto next_command; } FtpLog(LOG_INFO, "%s", cmd.command); /* dispatch the command */ for (i = 0; i < kCommandFuncNum; i++) { if (strcasecmp(cmd.command, command_func[i].name) == 0) { (command_func[i].func)(f, &cmd); goto next_command; } } /* oops, we don't have this command (shouldn't happen - shrug) */ FtpSessionReply(f, 502, "Command not implemented."); next_command: {} } }
STATUS FtpDebugDebug(FTP *ftp,int n, char * Message) { FtpString tmp; strcpy(tmp,Message); if (strncmp(tmp,"PASS ",5)==0) { char *p=tmp+5; while ( *p != '\0') *p++='*'; }; FtpLog(ftp->title,tmp); return 1; }