コード例 #1
0
ファイル: ftplib.c プロジェクト: cjpl/midas
int ftp_login(FTP_CON ** con, const char *host, unsigned short port,
              const char *user, const char *password, const char *account)
/* FTP login with username and password */
{
   int status;

   status = ftp_connect(con, host, port);
   if (status != FTP_SUCCESS)
      return status;

   status = ftp_user(*con, user);
   if (status >= 0)
      return status;

   if (status == -230)
      return status;

   if (status == -332) {
      if (account == NULL)
         return FTP_NET_ERROR;

      status = ftp_account(*con, account);
      if (status < 1)
         return status;

      if (status == -230)
         return status;
   }

   return ftp_password(*con, password);
}
コード例 #2
0
ファイル: handles.c プロジェクト: yuyuvn/ftp
/**
 * Generates response message for client
 * @param cmd Current command
 * @param state Current connection state
 */
void response(Command *cmd, State *state)
{
  switch(lookup_cmd(cmd->command)){
    case USER: ftp_user(cmd,state); break;
    case PASS: ftp_pass(cmd,state); break;
    case PASV: ftp_pasv(cmd,state); break;
    case LIST: ftp_list(cmd,state); break;
    case CWD:  ftp_cwd(cmd,state); break;
    case PWD:  ftp_pwd(cmd,state); break;
    case MKD:  ftp_mkd(cmd,state); break;
    case RMD:  ftp_rmd(cmd,state); break;
    case RETR: ftp_retr(cmd,state); break;
    case STOR: ftp_stor(cmd,state); break;
    case DELE: ftp_dele(cmd,state); break;
    case SIZE: ftp_size(cmd,state); break;
    case ABOR: ftp_abor(state); break;
    case QUIT: ftp_quit(state); break;
    case TYPE: ftp_type(cmd,state); break;
    case CDUP: ftp_cdup(state); break;
    case HELP: ftp_help(cmd, state); break;
    case NLST: ftp_nlst(cmd, state); break;
    case RNFR: ftp_rnfr(cmd, state); break;
    case RNTO: ftp_rnto(cmd, state); break;
    case APPE: ftp_appe(cmd, state); break;
    case NOOP:
      if(state->logged_in){
        state->message = "200 Zzz...\n";
      }else{
        state->message = "530 Please login with USER and PASS\n";
      }
      write_state(state);
      break;
    default: 
      state->message = "500 Unknown command\n";
      write_state(state);
      break;
  }
}