#ifndef __FTPD_H
#define __FTPD_H
#include "avltree.h"
#include "includes.h"
#include "os_cpu.h"
#include "tcpip.h"
#include <sys/_intsup.h>

#define FTP_STR2ID(str) ((*(int *)(str)) & 0xDFDFDFDF)

#define msg200 "220 lwIP FTP Server ready.\r\n"
#define msg230 "230 User logged in, proceed.\r\n"
#define msg331 "331 User name okay, need password.\r\n"
#define msg250 "250 Operation successful\r\n"
#define msg450 "450 Operation error\r\n"
#define msg501 "501 Syntax error in parameters or arguments."
#define msg503 "503 Bad sequence of commands.\r\n"

typedef struct
{
    int cmd_socket;

    char *arg;
    INT8U arglen;
    char  event;

#define FTP_LIST           1U
#define FTP_SEND_FILE_DATA 2U
#define FTP_RECV_FILE      3U

    char current_dir[128];
} ftp_mbox_t;

typedef void (*ftp_cmd_func)(ftp_mbox_t *pmbox);

typedef struct
{
    uint32_t        index;    // 命令标识码
    ftp_cmd_func    func;     // 记录命令函数指针
    struct avl_node cmd_node; // avl树节点
} ftp_cmd_t;

ftp_cmd_t *ftp_search_command(int i_ctrl_cmd);
int        ftp_insert_command(ftp_cmd_t *p_cmd);

char *data_port_list_file(ftp_mbox_t *msgbox);
// char *data_port_recv_file(ftp_mbox_t *msgbox);

#endif