// File: yckwong[P]tinywebserver/http/http_conn.cpp
// Function: http_conn::initresultFile(connection_pool*)
void http_conn::initresultFile(connection_pool *connPool)
{
    ofstream out("./CGImysql/id_passwd.txt");
    //先从连接池中取一个连接
    MYSQL *mysql = NULL;
    connectionRAII mysqlcon(&mysql, connPool);

    //在user表中检索username，passwd数据，浏览器端输入
    if (mysql_query(mysql, "SELECT username,passwd FROM user"))
    {
        LOG_ERROR("SELECT error:%s\n", mysql_error(mysql));
    }

    //从表中检索完整的结果集
    MYSQL_RES *result = mysql_store_result(mysql);

    //返回结果集中的列数
    int num_fields = mysql_num_fields(result);

    //返回所有字段结构的数组
    MYSQL_FIELD *fields = mysql_fetch_fields(result);

    //从结果集中获取下一行，将对应的用户名和密码，存入map中
    while (MYSQL_ROW row = mysql_fetch_row(result))
    {
        string temp1(row[0]);
        string temp2(row[1]);
        out << temp1 << " " << temp2 << endl;
        users[temp1] = temp2;
    }

    out.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq 0xa4d8(%rip), %rsi      # 0x1021d
leaq -0x210(%rbp), %rdi
movl $0x10, %edx
callq 0x4510
movq $0x0, -0x218(%rbp)
movq -0x10(%rbp), %rdx
leaq -0x228(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0xc0d0
jmp 0x5d7a
movq -0x218(%rbp), %rdi
leaq 0xa463(%rip), %rsi      # 0x101eb
callq 0x4320
movl %eax, -0x2b4(%rbp)
jmp 0x5d95
movl -0x2b4(%rbp), %eax
cmpl $0x0, %eax
je 0x5e4d
movq -0x2b0(%rbp), %rcx
xorl %eax, %eax
cmpl 0xe38(%rcx), %eax
jne 0x5e4b
callq 0x8ad0
movq %rax, -0x2c0(%rbp)
jmp 0x5dc7
movq -0x218(%rbp), %rdi
callq 0x41d0
movq %rax, -0x2c8(%rbp)
jmp 0x5ddc
movq -0x2c8(%rbp), %rcx
movq -0x2c0(%rbp), %rdi
leaq 0xa41b(%rip), %rdx      # 0x1020c
xorl %eax, %eax
movl $0x3, %esi
callq 0xafe0
jmp 0x5dff
callq 0x8ad0
movq %rax, -0x2d0(%rbp)
jmp 0x5e0d
movq -0x2d0(%rbp), %rdi
callq 0xb550
jmp 0x5e1b
jmp 0x5e4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x60db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x60cf
jmp 0x5e4d
movq -0x218(%rbp), %rdi
callq 0x4260
movq %rax, -0x2d8(%rbp)
jmp 0x5e62
movq -0x2d8(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rdi
callq 0x4740
movl %eax, -0x2dc(%rbp)
jmp 0x5e84
movl -0x2dc(%rbp), %eax
movl %eax, -0x244(%rbp)
movq -0x240(%rbp), %rdi
callq 0x4540
movq %rax, -0x2e8(%rbp)
jmp 0x5ea5
movq -0x2e8(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x240(%rbp), %rdi
callq 0x44c0
movq %rax, -0x2f0(%rbp)
jmp 0x5ec8
movq -0x2f0(%rbp), %rax
movq %rax, -0x258(%rbp)
cmpq $0x0, -0x258(%rbp)
je 0x60a0
movq -0x258(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x300(%rbp)
leaq -0x279(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x47e0
movq -0x300(%rbp), %rsi
movq -0x2f8(%rbp), %rdx
leaq -0x278(%rbp), %rdi
callq 0x4f60
jmp 0x5f24
leaq -0x279(%rbp), %rdi
callq 0x4500
movq -0x258(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x310(%rbp)
leaq -0x2a1(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x47e0
movq -0x310(%rbp), %rsi
movq -0x308(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x4f60
jmp 0x5f71
leaq -0x2a1(%rbp), %rdi
callq 0x4500
leaq -0x210(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x4430
movq %rax, -0x318(%rbp)
jmp 0x5f99
movq -0x318(%rbp), %rdi
leaq 0xa50a(%rip), %rsi      # 0x104b1
callq 0x4480
movq %rax, -0x320(%rbp)
jmp 0x5fb5
movq -0x320(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x4430
movq %rax, -0x328(%rbp)
jmp 0x5fd1
movq -0x328(%rbp), %rdi
movq 0xffd1(%rip), %rsi      # 0x15fb0
callq 0x44e0
jmp 0x5fe6
leaq 0x1052b(%rip), %rdi     # 0x16518
leaq -0x278(%rbp), %rsi
callq 0x8b60
movq %rax, -0x330(%rbp)
jmp 0x6002
movq -0x330(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x4050
jmp 0x6017
leaq -0x2a0(%rbp), %rdi
callq 0x42d0
leaq -0x278(%rbp), %rdi
callq 0x42d0
jmp 0x5eb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x279(%rbp), %rdi
callq 0x4500
jmp 0x60cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x2a1(%rbp), %rdi
callq 0x4500
jmp 0x6092
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x42d0
leaq -0x278(%rbp), %rdi
callq 0x42d0
jmp 0x60cf
leaq -0x210(%rbp), %rdi
callq 0x46b0
jmp 0x60ae
leaq -0x228(%rbp), %rdi
callq 0xc120
leaq -0x210(%rbp), %rdi
callq 0x46f0
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0xc120
leaq -0x210(%rbp), %rdi
callq 0x46f0
movq -0x230(%rbp), %rdi
callq 0x47d0
nopw %cs:(%rax,%rax)