// File: /workspace/github_c_makefile_star2_O1/icysunlight[P]miniftpd/ftpproto.c
// Function: handle_ftp
int handle_ftp(session_t* ssinf)
{
    ftp_reply(ssinf,220,"miniftp v0.1");
    pssinf = ssinf;
    b_dataconn = 0;

    //开启紧急数据接收
    if (activate_oobinline(ssinf->ctrlfd) == -1 )
        ERR_EXIT("active_oobinline error.");
    if (activate_sigurg(ssinf->ctrlfd) == -1 )
        ERR_EXIT("activate sigurg error.");
    if (signal(SIGURG,handle_sigurg) == SIG_ERR )
        ERR_EXIT("signal error.");

    while (1)
    {
        memset(ssinf->cmdline,0,sizeof(char) * MAXCMDLINE);
        memset(ssinf->cmd,0,sizeof(char) * MAXCMDLINE);
        memset(ssinf->arg,0,sizeof(char) * MAXCMDLINE);

        cmd_disconn_start();

        int ret = readline(ssinf->ctrlfd,ssinf->cmdline,MAXCMDLINE);
        if ( -1 == ret && errno == EINTR )
            continue;
        if (-1 == ret )
            ERR_EXIT("read error");
        if (0 == ret)
            exit(EXIT_SUCCESS);
 
        str_trim_crlf(ssinf->cmdline);
        str_split(ssinf->cmdline,ssinf->cmd,ssinf->arg,' ');
        str_upper(ssinf->cmd);
        printf("[%s]\t[%s]\n",ssinf->cmd,ssinf->arg);

        int arrsize = sizeof(ftp_cmd_arr) / sizeof(struct ftp_cmd_t);
        int i = 0;
        while (i < arrsize)
        {
            if ( 0 == strcmp(ftp_cmd_arr[i].fc_name,ssinf->cmd))
            {
                if (NULL == ftp_cmd_arr[i].fc_func)
                {
                    ftp_reply(ssinf,FTP_COMMANDNOTIMPL,"command not implemented");
                }
                else 
                {
                    ftp_cmd_arr[i].fc_func(ssinf);
                }
                break;
            }
            i++;
        }
        
        if (i == arrsize)
        {
            ftp_reply(ssinf,FTP_BADCMD,"Unknown Command."); 
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x2ecb(%rip), %rdx      # 0x832e
movl $0xdc, %esi
callq 0x4d4c
movq %rbx, 0x6ea4(%rip)      # 0xc318
movl $0x0, 0x6e92(%rip)      # 0xc310
movl 0x8(%rbx), %edi
callq 0x3d3a
cmpl $-0x1, %eax
jne 0x5497
leaq 0x2ea9(%rip), %rdi      # 0x833b
jmp 0x55de
movl 0x8(%rbx), %edi
callq 0x3d5d
cmpl $-0x1, %eax
jne 0x54b0
leaq 0x2ea8(%rip), %rdi      # 0x8353
jmp 0x55de
leaq -0x1a8(%rip), %rsi      # 0x530f
movl $0x17, %edi
callq 0x32e0
cmpq $-0x1, %rax
jne 0x54d3
leaq 0x2e9c(%rip), %rdi      # 0x836a
jmp 0x55de
leaq 0x18(%rbx), %r14
leaq 0x418(%rbx), %r15
leaq 0x818(%rbx), %r12
movl $0xc00, %edx            # imm = 0xC00
movq %r14, %rdi
xorl %esi, %esi
callq 0x3220
callq 0x5243
movl 0x8(%rbx), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
callq 0x4528
cmpl $-0x1, %eax
je 0x557c
testl %eax, %eax
je 0x55d0
movq %r14, %rdi
callq 0x49cc
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl $0x20, %ecx
callq 0x49f2
movq %r15, %rdi
callq 0x4a72
leaq 0x2dc2(%rip), %rdi      # 0x8302
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x31c0
leaq 0x65d4(%rip), %rbp      # 0xbb28
xorl %r13d, %r13d
movq -0x8(%rbp), %rdi
movq %r15, %rsi
callq 0x32d0
testl %eax, %eax
je 0x558c
incq %r13
addq $0x10, %rbp
cmpq $0x29, %r13
jne 0x5557
movl $0x29, %r13d
jmp 0x55ad
callq 0x3060
cmpl $0x4, (%rax)
je 0x54e5
jmp 0x55d7
movq (%rbp), %rax
movq %rbx, %rdi
testq %rax, %rax
je 0x559c
callq *%rax
jmp 0x55ad
movl $0x1f6, %esi            # imm = 0x1F6
leaq 0x2dd0(%rip), %rdx      # 0x8378
callq 0x4d4c
cmpl $0x29, %r13d
jne 0x54e5
movq %rbx, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0x2dca(%rip), %rdx      # 0x8390
callq 0x4d4c
jmp 0x54e5
xorl %edi, %edi
callq 0x34d0
leaq 0x2d19(%rip), %rdi      # 0x82f7
callq 0x3460
movl $0x1, %edi
callq 0x34d0