// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movl $0xdc, %esi
leaq 0x31ba(%rip), %rdx      # 0x9336
callq 0x5600
movq -0x8(%rbp), %rax
movq %rax, 0x751c(%rip)      # 0xd6a8
movl $0x0, 0x750a(%rip)      # 0xd6a0
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x3b20
cmpl $-0x1, %eax
jne 0x61bf
jmp 0x61a9
leaq 0x3193(%rip), %rdi      # 0x9343
callq 0x3470
movl $0x1, %edi
callq 0x34e0
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x3b60
cmpl $-0x1, %eax
jne 0x61e8
jmp 0x61d2
leaq 0x3182(%rip), %rdi      # 0x935b
callq 0x3470
movl $0x1, %edi
callq 0x34e0
movl $0x17, %edi
leaq -0x294(%rip), %rsi      # 0x5f60
callq 0x32f0
movq $-0x1, %rcx
cmpq %rcx, %rax
jne 0x621d
jmp 0x6207
leaq 0x3164(%rip), %rdi      # 0x9372
callq 0x3470
movl $0x1, %edi
callq 0x34e0
jmp 0x621f
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x3220
movq -0x8(%rbp), %rdi
addq $0x418, %rdi            # imm = 0x418
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x3220
movq -0x8(%rbp), %rdi
addq $0x818, %rdi            # imm = 0x818
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x3220
callq 0x5e40
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x18, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x4790
movl %eax, -0xc(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl -0xc(%rbp), %eax
jne 0x6298
callq 0x3050
cmpl $0x4, (%rax)
jne 0x6298
jmp 0x621f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl -0xc(%rbp), %eax
jne 0x62ba
jmp 0x62a4
leaq 0x3054(%rip), %rdi      # 0x92ff
callq 0x3470
movl $0x1, %edi
callq 0x34e0
xorl %eax, %eax
cmpl -0xc(%rbp), %eax
jne 0x62c8
xorl %edi, %edi
callq 0x34e0
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
callq 0x4f90
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
movq -0x8(%rbp), %rsi
addq $0x418, %rsi            # imm = 0x418
movq -0x8(%rbp), %rdx
addq $0x818, %rdx            # imm = 0x818
movl $0x20, %ecx
callq 0x5010
movq -0x8(%rbp), %rdi
addq $0x418, %rdi            # imm = 0x418
callq 0x50f0
movq -0x8(%rbp), %rsi
addq $0x418, %rsi            # imm = 0x418
movq -0x8(%rbp), %rdx
addq $0x818, %rdx            # imm = 0x818
leaq 0x2fe0(%rip), %rdi      # 0x930a
movb $0x0, %al
callq 0x31b0
movl $0x29, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x63d5
movslq -0x14(%rbp), %rcx
leaq 0x709a(%rip), %rax      # 0xd3f0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
addq $0x418, %rsi            # imm = 0x418
callq 0x32e0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x63c7
movslq -0x14(%rbp), %rax
leaq 0x706d(%rip), %rcx      # 0xd3f0
shlq $0x4, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq 0x8(%rcx), %rax
jne 0x63a9
movq -0x8(%rbp), %rdi
movl $0x1f6, %esi            # imm = 0x1F6
leaq 0x2fde(%rip), %rdx      # 0x9380
callq 0x5600
jmp 0x63c5
movslq -0x14(%rbp), %rcx
leaq 0x703c(%rip), %rax      # 0xd3f0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0x63d5
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x633f
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x63f2
movq -0x8(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0x2fab(%rip), %rdx      # 0x9398
callq 0x5600
jmp 0x621f
nopw (%rax,%rax)