// File: /workspace/github_c_makefile_star2_O3/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 0x2f17(%rip), %rdx      # 0x832e
movl $0xdc, %esi
callq 0x4cf4
movq %rbx, 0x6f00(%rip)      # 0xc328
movl $0x0, 0x6eee(%rip)      # 0xc320
movl 0x8(%rbx), %edi
callq 0x3d4a
cmpl $-0x1, %eax
jne 0x544b
leaq 0x2ef5(%rip), %rdi      # 0x833b
jmp 0x558d
movl 0x8(%rbx), %edi
callq 0x3d6d
cmpl $-0x1, %eax
jne 0x5464
leaq 0x2ef4(%rip), %rdi      # 0x8353
jmp 0x558d
leaq -0x1a8(%rip), %rsi      # 0x52c3
movl $0x17, %edi
callq 0x32f0
cmpq $-0x1, %rax
jne 0x5487
leaq 0x2ee8(%rip), %rdi      # 0x836a
jmp 0x558d
leaq 0x18(%rbx), %r14
leaq 0x418(%rbx), %r15
leaq 0x818(%rbx), %r12
leaq 0x6680(%rip), %rbp      # 0xbb20
movl $0xc00, %edx            # imm = 0xC00
movq %r14, %rdi
xorl %esi, %esi
callq 0x3220
callq 0x51f7
movl 0x8(%rbx), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
callq 0x4500
cmpl $-0x1, %eax
je 0x5545
testl %eax, %eax
je 0x557f
movq %r14, %rdi
callq 0x4974
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl $0x20, %ecx
callq 0x499a
movq %r15, %rdi
callq 0x4a1a
leaq 0x2e07(%rip), %rdi      # 0x8302
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x31c0
movl $0x8, %r13d
movq -0x8(%r13,%rbp), %rdi
movq %r15, %rsi
callq 0x32e0
testl %eax, %eax
je 0x5555
addq $0x10, %r13
cmpq $0x298, %r13            # imm = 0x298
jne 0x550e
movq %rbx, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0x2e55(%rip), %rdx      # 0x8390
callq 0x4cf4
jmp 0x54a0
callq 0x3060
cmpl $0x4, (%rax)
je 0x54a0
jmp 0x5586
movq (%r13,%rbp), %rax
movq %rbx, %rdi
testq %rax, %rax
je 0x5569
callq *%rax
jmp 0x54a0
movl $0x1f6, %esi            # imm = 0x1F6
leaq 0x2e03(%rip), %rdx      # 0x8378
callq 0x4cf4
jmp 0x54a0
xorl %edi, %edi
callq 0x34e0
leaq 0x2d6a(%rip), %rdi      # 0x82f7
callq 0x3470
movl $0x1, %edi
callq 0x34e0