// File: /workspace/github_c_makefile_star2_O2/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 0x235b(%rip), %rdx      # 0x732e
movl $0xdc, %esi
callq 0x489c
movq %rbx, 0x6344(%rip)      # 0xb328
andl $0x0, 0x6335(%rip)      # 0xb320
movl 0x8(%rbx), %edi
callq 0x3991
cmpl $-0x1, %eax
jne 0x5004
leaq 0x233c(%rip), %rdi      # 0x733b
jmp 0x5140
movl 0x8(%rbx), %edi
callq 0x39ae
cmpl $-0x1, %eax
jne 0x501d
leaq 0x233b(%rip), %rdi      # 0x7353
jmp 0x5140
leaq -0x1af(%rip), %rsi      # 0x4e75
pushq $0x17
popq %rdi
callq 0x32f0
cmpq $-0x1, %rax
jne 0x503e
leaq 0x2331(%rip), %rdi      # 0x736a
jmp 0x5140
leaq 0x18(%rbx), %r14
leaq 0x418(%rbx), %r15
leaq 0x818(%rbx), %r12
leaq 0x5ac9(%rip), %rbp      # 0xab20
movl $0xc00, %edx            # imm = 0xC00
movq %r14, %rdi
xorl %esi, %esi
callq 0x3220
callq 0x4db5
movl 0x8(%rbx), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
callq 0x40b7
cmpl $-0x1, %eax
je 0x50f3
testl %eax, %eax
je 0x5132
movq %r14, %rdi
callq 0x450c
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
pushq $0x20
popq %rcx
callq 0x4532
movq %r15, %rdi
callq 0x45ad
leaq 0x2252(%rip), %rdi      # 0x7302
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x31c0
xorl %ecx, %ecx
leaq 0x10(%rcx), %r13
cmpq $0x2a0, %r13            # imm = 0x2A0
je 0x5103
movq (%rcx,%rbp), %rdi
movq %r15, %rsi
callq 0x32e0
movq %r13, %rcx
testl %eax, %eax
jne 0x50bf
movq -0x8(%r13,%rbp), %rax
movq %rbx, %rdi
testq %rax, %rax
je 0x511c
callq *%rax
jmp 0x5057
callq 0x3060
cmpl $0x4, (%rax)
je 0x5057
jmp 0x5139
movq %rbx, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0x227e(%rip), %rdx      # 0x7390
callq 0x489c
jmp 0x5057
movl $0x1f6, %esi            # imm = 0x1F6
leaq 0x2250(%rip), %rdx      # 0x7378
callq 0x489c
jmp 0x5057
xorl %edi, %edi
callq 0x34e0
leaq 0x21b7(%rip), %rdi      # 0x72f7
callq 0x3470
pushq $0x1
popq %rdi
callq 0x34e0